@streamlayer/react 1.20.5 → 1.20.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/advertisement.js +29 -29
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/index2.js +4 -4
- package/lib/cjs/insight.js +1 -1
- package/lib/cjs/masters2.js +7 -7
- package/lib/cjs/notification.js +1 -1
- package/lib/cjs/pause-ad.js +1 -1
- package/lib/cjs/points.js +1 -1
- package/lib/cjs/provider.js +15 -39
- package/lib/cjs/useStreamLayerApp2.js +16 -17
- package/lib/classic/cjs/advertisement.js +29 -29
- package/lib/classic/cjs/bet-pack.js +4 -4
- package/lib/classic/cjs/index.js +1 -1
- package/lib/classic/cjs/insight.js +1 -1
- package/lib/classic/cjs/notification.js +1 -1
- package/lib/classic/cjs/pause-ad.js +1 -1
- package/lib/classic/cjs/points.js +1 -1
- package/lib/classic/cjs/provider.js +10 -34
- package/lib/classic/cjs/useStreamLayerApp2.js +16 -17
- package/lib/classic/es/advertisement.js +2193 -2265
- package/lib/classic/es/bet-pack.js +14 -12
- package/lib/classic/es/index.js +16 -11
- package/lib/classic/es/insight.js +35 -30
- package/lib/classic/es/notification.js +108 -103
- package/lib/classic/es/pause-ad.js +91 -87
- package/lib/classic/es/points.js +28 -23
- package/lib/classic/es/provider.js +4285 -10085
- package/lib/classic/es/useStreamLayerApp.js +1 -1
- package/lib/classic/es/useStreamLayerApp2.js +3111 -5772
- package/lib/dist/cjs/gamification-feature2.js +1 -1
- package/lib/dist/cjs/index.js +1 -1
- package/lib/dist/cjs/masters.js +35 -60
- package/lib/dist/es/gamification-feature2.js +112 -105
- package/lib/dist/es/index.js +12 -7
- package/lib/dist/es/masters.js +9909 -18734
- package/lib/dist/style.css +1 -1
- package/lib/es/advertisement.js +2193 -2265
- package/lib/es/index.js +16 -11
- package/lib/es/index2.js +12 -10
- package/lib/es/insight.js +35 -30
- package/lib/es/masters2.js +28 -25
- package/lib/es/notification.js +135 -130
- package/lib/es/pause-ad.js +91 -87
- package/lib/es/points.js +28 -23
- package/lib/es/provider.js +4302 -10466
- package/lib/es/useStreamLayerApp.js +1 -1
- package/lib/es/useStreamLayerApp2.js +3111 -5772
- package/lib/style.css +1 -1
- package/package.json +15 -15
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("react/jsx-runtime"),_e=require("react"),W=require("./provider.js"),oe=require("./useStreamLayerApp2.js"),Md=require("./vast-client.min-B0NUra1B.js"),em=require("./index-l-eyvmpL.js"),tm=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Rd(i){return typeof i=="string"&&tm.test(i)}function nu(i){if(!Rd(i))throw TypeError("Invalid UUID");let e;return Uint8Array.of((e=parseInt(i.slice(0,8),16))>>>24,e>>>16&255,e>>>8&255,e&255,(e=parseInt(i.slice(9,13),16))>>>8,e&255,(e=parseInt(i.slice(14,18),16))>>>8,e&255,(e=parseInt(i.slice(19,23),16))>>>8,e&255,(e=parseInt(i.slice(24,36),16))/1099511627776&255,e/4294967296&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255)}function im(i){i=unescape(encodeURIComponent(i));const e=new Uint8Array(i.length);for(let t=0;t<i.length;++t)e[t]=i.charCodeAt(t);return e}const nm="6ba7b810-9dad-11d1-80b4-00c04fd430c8",sm="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function rm(i,e,t,n,s,r){const a=typeof t=="string"?im(t):t,l=typeof n=="string"?nu(n):n;if(typeof n=="string"&&(n=nu(n)),(n==null?void 0:n.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+a.length);if(c.set(l),c.set(a,l.length),c=e(c),c[6]=c[6]&15|i,c[8]=c[8]&63|128,s){r=r||0;for(let g=0;g<16;++g)s[r+g]=c[g];return s}return oe.unsafeStringify(c)}function am(i,e,t,n){switch(i){case 0:return e&t^~e&n;case 1:return e^t^n;case 2:return e&t^e&n^t&n;case 3:return e^t^n}}function wa(i,e){return i<<e|i>>>32-e}function om(i){const e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(i.length+1);n.set(i),n[i.length]=128,i=n;const s=i.length/4+2,r=Math.ceil(s/16),a=new Array(r);for(let l=0;l<r;++l){const c=new Uint32Array(16);for(let g=0;g<16;++g)c[g]=i[l*64+g*4]<<24|i[l*64+g*4+1]<<16|i[l*64+g*4+2]<<8|i[l*64+g*4+3];a[l]=c}a[r-1][14]=(i.length-1)*8/Math.pow(2,32),a[r-1][14]=Math.floor(a[r-1][14]),a[r-1][15]=(i.length-1)*8&4294967295;for(let l=0;l<r;++l){const c=new Uint32Array(80);for(let A=0;A<16;++A)c[A]=a[l][A];for(let A=16;A<80;++A)c[A]=wa(c[A-3]^c[A-8]^c[A-14]^c[A-16],1);let g=t[0],m=t[1],b=t[2],C=t[3],w=t[4];for(let A=0;A<80;++A){const v=Math.floor(A/20),M=wa(g,5)+am(v,m,b,C)+w+e[v]+c[A]>>>0;w=C,C=b,b=wa(m,30)>>>0,m=g,g=M}t[0]=t[0]+g>>>0,t[1]=t[1]+m>>>0,t[2]=t[2]+b>>>0,t[3]=t[3]+C>>>0,t[4]=t[4]+w>>>0}return Uint8Array.of(t[0]>>24,t[0]>>16,t[0]>>8,t[0],t[1]>>24,t[1]>>16,t[1]>>8,t[1],t[2]>>24,t[2]>>16,t[2]>>8,t[2],t[3]>>24,t[3]>>16,t[3]>>8,t[3],t[4]>>24,t[4]>>16,t[4]>>8,t[4])}function rr(i,e,t,n){return rm(80,om,i,e,t,n)}rr.DNS=nm;rr.URL=sm;const lm=W.styled_default("div")({name:"Container",class:"c5b6wdg",propsAsIs:!1}),um="a1rlj479",dm="s35f1di",hm="sj4471g",cm="b12050d8",pm="b1d5ybek",fm=i=>i==="left"||i==="right"?dm:cm,gm=i=>i==="left"||i==="right"?hm:pm,mm=i=>i==="left"?"avdxyl3":i==="right"?"a1bisd08":i==="top"?"a1u9y2aj":"a1qqaks",To=({children:i,style:e,className:t,enabled:n=!0,hiding:s,direction:r="left",onAnimationEnd:a})=>z.jsx(lm,{style:e,className:W.cx_default(t,um,mm(r),n&&!s&&fm(r),n&&s&&gm(r)),onAnimationEnd:a,children:i}),ym=W.styled_default("a")({name:"Link",class:"l1sgte8c",propsAsIs:!1}),_m=W.styled_default("div")({name:"BannerContainer",class:"b7yfc72",propsAsIs:!1}),bm=()=>ym,Tm=W.styled_default(bm())({name:"BannerLink",class:"bejjq94",propsAsIs:!0}),Ud=({promotion:i,promotionId:e,hiding:t,isEventFired:n,fireEvent:s,direction:r="bottom"})=>{const a=(i==null?void 0:i.adUnit)===oe.AdUnit.STANDART,l=a?i.banner:i.additionalBanner;if(_e.useEffect(()=>{l!=null&&l.imageUrl&&i.type&&e&&(n!=null&&n("banner-showed")||(W.eventBus.emit("advertisement",{action:"bannerShown",payload:{id:e,type:i.type}}),s==null||s("banner-showed")))},[l==null?void 0:l.imageUrl,s,n,i.type,e]),!(l!=null&&l.imageUrl))return null;let c=l==null?void 0:l.url;return c&&c.indexOf("http")!==0&&(c=`https://${c}`),z.jsx(To,{direction:r,hiding:t,children:z.jsx(_m,{className:"BannerContainer","data-is-ad":a,children:z.jsx(Tm,{as:c?"a":"span",className:"BannerLink",href:c,style:{backgroundImage:`url(${l.imageUrl})`,cursor:c?"pointer":"default"},"data-promo-id":e,"data-promo-type":i.type,"data-a":"banner",target:"_blank","data-is-ad":a})})})},vm=({cardId:i,promotion:e,direction:t="bottom"})=>z.jsx(Ud,{promotion:e,promotionId:i,direction:t,hiding:!1}),Sm=W.styled_default("div")({name:"NotificationContent",class:"n18wsqoo",propsAsIs:!1}),Em=W.styled_default("div")({name:"Body",class:"b1ia90c2",propsAsIs:!1}),wm=W.styled_default("div")({name:"Title",class:"tg2z08v",propsAsIs:!1}),km=W.styled_default("div")({name:"Text",class:"t59zdk1",propsAsIs:!1}),vo=W.styled_default("div")({name:"MediaImgBottom",class:"m1ab9fq",propsAsIs:!1}),Cm=()=>vo,Im=W.styled_default(Cm())({name:"MediaImgMiddle",class:"m9fsr0y",propsAsIs:!0}),su=W.styled_default("img")({name:"CtaIcon",class:"cvi9y5q",propsAsIs:!1}),xm=W.styled_default("div")({name:"Logo",class:"l5mq0z",propsAsIs:!1}),Am=W.styled_default("div")({name:"Footer",class:"f1mse0ft",propsAsIs:!1}),Pm=W.styled_default("div")({name:"Vector",class:"v1hcloah",propsAsIs:!1}),Lm=W.styled_default("div")({name:"NotificationContainer",class:"n3n65jf",propsAsIs:!1}),Nd=W.styled_default("button")({name:"TVButton",class:"tkkfuqy",propsAsIs:!1}),Dm=()=>Nd,Om=W.styled_default(Dm())({name:"DismissButton",class:"dh9vato",propsAsIs:!0}),Mm=()=>Nd,Bd=W.styled_default(Mm())({name:"OpenButton",class:"oeah8gv",propsAsIs:!0}),Rm={[oe.NotificationPromotionImagePosition.BOTTOM]:vo,[oe.NotificationPromotionImagePosition.MIDDLE]:Im},Um=({src:i,imagePosition:e})=>{const t=Rm[e]||vo;return z.jsx(t,{children:z.jsx("img",{src:i,alt:""})})},Nm=W.O(Om),Bm=W.O(Bd),Fm=({notification:i,open:e,close:t,webos:n})=>{if(!i||!i.promotion||i.enabled!==oe.NotificationEnabled.NOTIFICATION_ENABLED)return null;const{title:s,body:r,image:a,promotion:l}=i,{sponsorLogo:c,sponsorLogoMode:g,imagePosition:m,ctaButton:b}=l;return z.jsxs(Lm,{"data-webos":n,className:"SL_Lower_Third_Notification",onClick:n?void 0:e,children:[z.jsxs(Sm,{children:[z.jsx(Um,{src:a,imagePosition:m}),z.jsxs(Em,{children:[s&&z.jsx(wm,{children:s}),r&&z.jsx(km,{children:r})]})]}),z.jsxs(Am,{children:[g!==oe.NotificationSponsorLogoMode.NOTIFICATION_SPONSOR_LOGO_NONE&&z.jsxs(z.Fragment,{children:[z.jsx(xm,{children:z.jsx("img",{src:c,alt:s})}),z.jsx(Pm,{})]}),n?z.jsxs(z.Fragment,{children:[z.jsx(Nm,{webos:!0,onClick:t,children:"Dismiss"}),z.jsxs(Bm,{webos:!0,autoFocus:!0,style:{color:b==null?void 0:b.textColor,backgroundColor:b==null?void 0:b.color},onClick:e,children:[(b==null?void 0:b.ctaIcon)&&(b==null?void 0:b.ctaIconMode)===oe.CtaIconMode.CTA_ICON_TRANSPARENT&&z.jsx(su,{src:b==null?void 0:b.ctaIcon,alt:"cta-icon"}),(b==null?void 0:b.label)||"Open"]})]}):z.jsxs(Bd,{name:"promo-button",style:{color:b==null?void 0:b.textColor,backgroundColor:b==null?void 0:b.color},children:[(b==null?void 0:b.ctaIcon)&&(b==null?void 0:b.ctaIconMode)===oe.CtaIconMode.CTA_ICON_TRANSPARENT&&z.jsx(su,{src:b==null?void 0:b.ctaIcon,alt:"cta-icon"}),(b==null?void 0:b.label)||"Open"]})]})]})},jm=W.styled_default("div")({name:"NotificationContent",class:"n1ku6hz",propsAsIs:!1}),$m=W.styled_default("div")({name:"NotificationContainer",class:"nbxqmol",propsAsIs:!1}),qm=W.styled_default("div")({name:"Body",class:"b1gu3eml",propsAsIs:!1}),Vm=W.styled_default("div")({name:"Title",class:"t1u17zva",propsAsIs:!1}),Hm=W.styled_default("div")({name:"Text",class:"t10ko1g",propsAsIs:!1}),Lr=W.styled_default("div")({name:"Media",class:"mntc42e",propsAsIs:!1}),zm=()=>Lr,ru=W.styled_default(zm())({name:"MediaImgFit",class:"ml060eo",propsAsIs:!0}),Wm=()=>Lr,Fd=W.styled_default(Wm())({name:"MediaImgCentered",class:"m1vqlvig",propsAsIs:!0}),Gm=()=>Fd,Xm=W.styled_default(Gm())({name:"MediaImgBottom",class:"m1e7tvi5",propsAsIs:!0}),Km=()=>Lr,Ym=W.styled_default(Km())({name:"MediaImgSolid",class:"mqvntt2",propsAsIs:!0}),Qm=()=>Lr,Jm=W.styled_default(Qm())({name:"MediaImgMiddle",class:"m12jtj3u",propsAsIs:!0}),Zm=W.styled_default("img")({name:"CtaIcon",class:"ckq1frv",propsAsIs:!1}),ey=()=>W.B1,ty=W.styled_default(ey())({name:"StyledChevronRight",class:"s9mjmz3",propsAsIs:!0}),iy=W.styled_default("div")({name:"Logo",class:"l1cf50a7",propsAsIs:!1}),jd=W.styled_default("button")({name:"TVButton",class:"thdqfl0",propsAsIs:!1}),ny=()=>jd,sy=W.styled_default(ny())({name:"DismissButton",class:"d11pe8bx",propsAsIs:!0}),ry=()=>jd,ay=W.styled_default(ry())({name:"OpenButton",class:"oy9k0kp",propsAsIs:!0}),oy={[oe.NotificationPromotionImagePosition.UNSET]:ru,[oe.NotificationPromotionImagePosition.FIT]:ru,[oe.NotificationPromotionImagePosition.CENTERED]:Fd,[oe.NotificationPromotionImagePosition.BOTTOM]:Xm,[oe.NotificationPromotionImagePosition.SOLID]:Ym,[oe.NotificationPromotionImagePosition.MIDDLE]:Jm},ly=({src:i,imagePosition:e})=>{const t=oy[e];return z.jsx(t,{children:z.jsx("img",{src:i,alt:""})})},uy=W.O(sy),dy=W.O(ay),hy=({notification:i,open:e,promotionId:t,hiding:n,direction:s="left",close:r,webos:a})=>{if(!i||!i.promotion||i.enabled!==oe.NotificationEnabled.NOTIFICATION_ENABLED)return null;if(i.promotion.mode===oe.NotificationPromotionMode.LOWER_THIRD)return z.jsx(Fm,{notification:i,open:e,close:r,webos:a});const{title:l,body:c,image:g,promotion:m}=i,{sponsorLogo:b,sponsorLogoMode:C,imagePosition:w,ctaButton:A}=m,v=M=>{M.stopPropagation(),r==null||r()};return z.jsx(To,{className:"SL_Rich_Notification",direction:s,hiding:n,children:z.jsxs($m,{onClick:a?()=>{}:e,children:[C!==oe.NotificationSponsorLogoMode.NOTIFICATION_SPONSOR_LOGO_NONE&&b&&z.jsx(iy,{children:z.jsx("img",{src:b,alt:l})}),z.jsxs(jm,{children:[z.jsx(ly,{src:g,imagePosition:w}),z.jsxs(qm,{children:[l&&z.jsx(Vm,{children:l}),c&&z.jsx(Hm,{children:c})]}),a&&z.jsx(uy,{webos:!0,onClick:v,children:"Dismiss"}),z.jsxs(dy,{webos:a,autoFocus:a,onClick:a?e:()=>{},name:"promo-button",style:{color:A==null?void 0:A.textColor,backgroundColor:A==null?void 0:A.color},children:[(A==null?void 0:A.ctaIcon)&&(A==null?void 0:A.ctaIconMode)===oe.CtaIconMode.CTA_ICON_TRANSPARENT&&z.jsx(Zm,{src:A==null?void 0:A.ctaIcon,alt:"cta-icon"}),(A==null?void 0:A.label)||"Open"]}),z.jsx(ty,{name:"chevronRight"})]})]})})},cy=W.styled_default("div")({name:"OverlayContainer",class:"okzhq2w",propsAsIs:!1}),$d=W.styled_default("div")({name:"PromoOverlay",class:"pmgz5i",propsAsIs:!1}),qd=W.styled_default("div")({name:"Header",class:"hyxi3jt",propsAsIs:!1}),Vd=W.styled_default("div")({name:"HeaderContent",class:"h149e3gp",propsAsIs:!1}),Hd="h10toh7",au=W.styled_default("img")({name:"SponsorLogo",class:"s1jyea6t",propsAsIs:!1}),py=W.styled_default("div")({name:"SponsorName",class:"szpfa3h",propsAsIs:!1}),zd=W.styled_default("div")({name:"Media",class:"m1crmu01",propsAsIs:!1}),fy=W.styled_default("img")({name:"PromoImg",class:"p1l37r8s",propsAsIs:!1}),gy="s1nmch9k",ou=W.styled_default("div")({name:"Content",class:"c1er0ljd",propsAsIs:!1}),my=W.styled_default("div")({name:"Description",class:"dydopmr",propsAsIs:!1}),yy=W.styled_default("div")({name:"Sponsor",class:"s1w6nt04",propsAsIs:!1}),_y=W.styled_default("div")({name:"SponsorText",class:"s1evcmtq",propsAsIs:!1}),Wd=W.styled_default("div")({name:"ADLogo",class:"awodx0x",propsAsIs:!1}),by=W.styled_default("span")({name:"SponsoredText",class:"s1q3n6oi",propsAsIs:!1}),Gd=W.styled_default("div")({name:"ActionBtnWrap",class:"a8d4xfk",propsAsIs:!1}),Xd=W.styled_default("a")({name:"ActionButton",class:"at6oobh",propsAsIs:!1}),Ty=W.styled_default("div")({name:"Title",class:"t1gyg7tt",propsAsIs:!1}),vy="h17rwbtk",Sy=W.styled_default("div")({name:"Container",class:"c10m2bce",propsAsIs:!1}),lu=W.styled_default("div")({name:"Item",class:"ig23yq5",propsAsIs:!1}),Ey=W.styled_default("div")({name:"Dot",class:"d1f6aqua",propsAsIs:!1}),wy=({time:i,adCount:e,adPosition:t})=>{const n=Math.floor(i/60),s=i-n*60;return n===0&&s===0&&e===t?null:z.jsxs(Sy,{children:[e>1&&z.jsxs(z.Fragment,{children:[z.jsxs(lu,{children:[t," of ",e]}),z.jsx(Ey,{})]}),z.jsxs(lu,{children:[n,":",s<10?`0${s}`:s]})]})},ky=W.styled_default("a")({name:"WhyThisAdLink",class:"w13o8uld",propsAsIs:!1}),Cy=({whyThisAd:i})=>{const[e,t]=_e.useState(!1);return!i.iconClickThroughURLTemplate||!i.staticResource?null:z.jsxs(ky,{style:{width:i.width,height:i.height,[i.xPosition]:3,[i.yPosition]:11},href:i.iconClickThroughURLTemplate,target:"_blank",rel:"noreferrer",children:[!e&&z.jsx("img",{alt:"ad choice",src:i.staticResource,onLoad:()=>t(!1),onError:()=>t(!0)}),e&&z.jsx("span",{children:"ad choice"})]})},Iy=W.styled_default("div")({name:"VideoControls",class:"v1xzooj9",propsAsIs:!1}),Kd=W.styled_default("button")({name:"ControlBtn",class:"c1bo41vr",propsAsIs:!1}),xy=()=>Kd,Ay=W.styled_default(xy())({name:"MuteIcon",class:"m13efyu8",propsAsIs:!0}),Py=()=>Kd,Ly=W.styled_default(Py())({name:"PauseIcon",class:"pladkgh",propsAsIs:!0}),Dy=W.styled_default("div")({name:"Container",class:"cjnga56",propsAsIs:!1}),Oy=W.styled_default("div")({name:"ControlsContainer",class:"c7qs1am",propsAsIs:!1}),uu="m12n261r",du="m16vcml8",hu="m1078nk6",cu=globalThis||void 0||self;class My{constructor(e){this.id=e.getAttribute("id"),this.allowMultipleAds=e.getAttribute("allowMultipleAds"),this.followRedirects=e.getAttribute("followRedirects"),this.vastAdData=null,this.adTagURI=null,this.customData=null;for(const t in e.childNodes){const n=e.childNodes[t];switch(n.localName){case"AdTagURI":this.adTagURI={templateType:n.getAttribute("templateType"),uri:(n.textContent||n.text||"").trim()};break;case"VASTAdData":for(this.vastAdData=n.firstChild;this.vastAdData&&this.vastAdData.nodeType!==1;)this.vastAdData=this.vastAdData.nextSibling;break;case"CustomAdData":this.customData=n;break}}}}function Yd(i,e){const t=[];for(const n in i.childNodes){const s=i.childNodes[n];(s.nodeName===e||e===`vmap:${s.nodeName}`||s.nodeName===`vmap:${e}`)&&t.push(s)}return t}function Ry(i){if(!i||!i.childNodes)return{};const e=i.childNodes,t=[];for(const s in e){const r=e[s];r.nodeName==="#cdata-section"&&t.push(r)}if(t&&t.length>0)try{return JSON.parse(t[0].data)}catch{}let n="";for(const s in e){const r=e[s];switch(r.nodeName){case"#text":n+=r.textContent.trim();break;case"#cdata-section":n+=r.data;break}}return n}function So(i){const e={attributes:{},children:{},value:{}};e.value=Ry(i);const t=i.attributes;if(t)for(const s in t){const r=t[s];r.nodeName&&r.nodeValue!==void 0&&r.nodeValue!==null&&(e.attributes[r.nodeName]=r.nodeValue)}const n=i.childNodes;if(n)for(const s in n){const r=n[s];r.nodeName&&r.nodeName.substring(0,1)!=="#"&&(e.children[r.nodeName]=So(r))}return e}class Uy{constructor(e){this.timeOffset=e.getAttribute("timeOffset"),this.breakType=e.getAttribute("breakType"),this.breakId=e.getAttribute("breakId"),this.repeatAfter=e.getAttribute("repeatAfter"),this.adSource=null,this.trackingEvents=[],this.extensions=[];for(const t in e.childNodes){const n=e.childNodes[t];switch(n.localName){case"AdSource":this.adSource=new My(n);break;case"TrackingEvents":for(const s in n.childNodes){const r=n.childNodes[s];r.localName==="Tracking"&&this.trackingEvents.push({event:r.getAttribute("event"),uri:(r.textContent||r.text||"").trim()})}break;case"Extensions":this.extensions=Yd(n,"Extension").map(s=>So(s));break}}}track(e,t){for(const n in this.trackingEvents){const s=this.trackingEvents[n];if(s.event===e){let{uri:r}=s;s.event==="error"&&(r=r.replace("[ERRORCODE]",t)),this.tracker(r)}}}tracker(e){if(typeof window<"u"&&window!==null){const t=new Image;t.src=e}}}class Ny{constructor(e){if(!e||!e.documentElement||e.documentElement.localName!=="VMAP")throw new Error("Not a VMAP document");this.version=e.documentElement.getAttribute("version"),this.adBreaks=[],this.extensions=[];for(const t in e.documentElement.childNodes){const n=e.documentElement.childNodes[t];switch(n.localName){case"AdBreak":this.adBreaks.push(new Uy(n));break;case"Extensions":this.extensions=Yd(n,"Extension").map(s=>So(s));break}}}}const By=(i,e)=>{const t=goog.pal,n=new t.ConsentSettings;n.allowStorage=!1;const s=new t.NonceLoader(n);return async()=>{try{const r=new URL(e),a=new t.NonceRequest;let l=localStorage.getItem("sl-device-id")||oe.v4(),c=sessionStorage.getItem("sl-ad-session-id");c||(c=oe.v4(),sessionStorage.setItem("sl-ad-session-id",c)),Rd(l)||(l=rr(`https://${l}`,rr.URL)),r.searchParams.get("url")||r.searchParams.set("url","https://streamlayer.io"),r.searchParams.get("description_url")||r.searchParams.set("description_url","https://streamlayer.io"),a.adWillAutoPlay=r.searchParams.get("vpa")==="auto",a.adWillPlayMuted=r.searchParams.get("vpmute")==="1",a.continuousPlayback=!0,a.descriptionUrl=r.searchParams.get("description_url"),a.iconsSupported=!0,a.sessionId=l,a.supportedApiFrameworks="2,7,9",a.videoHeight=i.clientHeight,a.videoWidth=i.clientWidth;const g=await s.loadNonceManager(a);return r.searchParams.get("is_lat")==="[placeholder]"&&r.searchParams.set("is_lat","1"),r.searchParams.get("rdid")==="[placeholder]"&&r.searchParams.set("rdid",l),r.searchParams.get("correlator")==="[placeholder]"&&r.searchParams.set("correlator",c),r.searchParams.set("wta","1"),r.searchParams.set("givn",g.getNonce()),{url:r,manager:g}}catch(r){console.log("AdsManager could not be started",r);return}}},Fy=new Md.ce,jy=i=>i.creatives.find(e=>e.mediaFiles),$y=i=>{var e;const t=i==null?void 0:i.mediaFiles;return t!=null&&t.length&&((e=t.find(n=>n.fileURL))==null?void 0:e.fileURL)||""},Gn=W.a({ads:[],autoplay:!0,muted:!1,nonceManager:void 0}),qy=(i,e)=>{const[t,n]=_e.useState(),s=_e.useRef(Date.now()),r=_e.useRef(Date.now());return _e.useEffect(()=>{if(!e||!(i!=null&&i.current))return;const a=By(i.current,e),l=Date.now();s.current=l,Gn.set({ads:[],autoplay:!0,muted:!1,nonceManager:void 0}),a().then(c=>{s.current===l&&c&&(n(c.url),Gn.set({ads:[],autoplay:!0,muted:!1,nonceManager:c.manager}))}).catch(c=>{console.error(c)})},[i,e]),_e.useEffect(()=>{const a=async(l,c)=>{let g=[];if(l.searchParams.get("output")==="vmap"){const w=await fetch(l.toString()),A=new DOMParser,v=await w.text(),M=A.parseFromString(v,"text/xml");g=new Ny(M).adBreaks.map(D=>D.adSource.adTagURI.uri)}else g=[l.toString()];const m=await Promise.all(g.map((w,A)=>Fy.get(w).then(v=>{if(r.current===c){const M=v.ads.find(N=>N.creatives.length>0);if(!M)return;const D=jy(M),R=$y(D);return{creative:D,order:A,mediaFileUrl:R,ad:M,raw:v}}}))),b=l.searchParams.get("vpa")!=="click",C=l.searchParams.get("vpmute")==="1";Gn.set({...Gn.get(),ads:m.filter(w=>!!w),autoplay:b,muted:C})};if(t){const l=Date.now();r.current=l,a(t,l)}return()=>{r.current=0}},[t]),Gn};var ar=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof cu<"u"?cu:typeof self<"u"?self:{};function gs(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Vy(i){if(i.__esModule)return i;var e=i.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(i).forEach(function(n){var s=Object.getOwnPropertyDescriptor(i,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:function(){return i[n]}})}),t}const or=globalThis||void 0||self;var Jn;typeof window<"u"?Jn=window:typeof ar<"u"?Jn=ar:typeof self<"u"?Jn=self:Jn={};var Dr=Jn;const x=gs(Dr),Hy={},zy=Object.freeze(Object.defineProperty({__proto__:null,default:Hy},Symbol.toStringTag,{value:"Module"})),Wy=Vy(zy);var pu=typeof ar<"u"?ar:typeof window<"u"?window:{},Gy=Wy,Zn;typeof document<"u"?Zn=document:(Zn=pu["__GLOBAL_DOCUMENT_CACHE@4"],Zn||(Zn=pu["__GLOBAL_DOCUMENT_CACHE@4"]=Gy));var Qd=Zn;const G=gs(Qd);var Eo={exports:{}},Jd={exports:{}};(function(i){function e(){return i.exports=e=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var r in s)({}).hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t},i.exports.__esModule=!0,i.exports.default=i.exports,e.apply(null,arguments)}i.exports=e,i.exports.__esModule=!0,i.exports.default=i.exports})(Jd);var Xy=Jd.exports,Ky=Qy,Yy=Object.prototype.toString;function Qy(i){if(!i)return!1;var e=Yy.call(i);return e==="[object Function]"||typeof i=="function"&&e!=="[object RegExp]"||typeof window<"u"&&(i===window.setTimeout||i===window.alert||i===window.confirm||i===window.prompt)}function Jy(i,e){var t=typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t)return(t=t.call(i)).next.bind(t);if(Array.isArray(i)||(t=Zy(i))||e){t&&(i=t);var n=0;return function(){return n>=i.length?{done:!0}:{done:!1,value:i[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("react/jsx-runtime"),_e=require("react");require("@nanostores/react");require("nanostores");const W=require("./provider.js");require("lodash.throttle");require("react-dom");require("react-countup");const ue=require("./useStreamLayerApp2.js"),Dd=require("./vast-client.min-B0NUra1B.js"),Qf=require("./index-l-eyvmpL.js"),Gn=require("uuid"),Jf=W.styled_default("div")({name:"Container",class:"c5b6wdg",propsAsIs:!1}),Zf="a1rlj479",em="s35f1di",tm="sj4471g",im="b12050d8",nm="b1d5ybek",sm=i=>i==="left"||i==="right"?em:im,rm=i=>i==="left"||i==="right"?tm:nm,am=i=>i==="left"?"avdxyl3":i==="right"?"a1bisd08":i==="top"?"a1u9y2aj":"a1qqaks",bo=({children:i,style:e,className:t,enabled:n=!0,hiding:s,direction:r="left",onAnimationEnd:a})=>z.jsx(Jf,{style:e,className:W.cx_default(t,Zf,am(r),n&&!s&&sm(r),n&&s&&rm(r)),onAnimationEnd:a,children:i}),om=W.styled_default("a")({name:"Link",class:"l1sgte8c",propsAsIs:!1}),lm=W.styled_default("div")({name:"BannerContainer",class:"b7yfc72",propsAsIs:!1}),um=()=>om,dm=W.styled_default(um())({name:"BannerLink",class:"bejjq94",propsAsIs:!0}),Od=({promotion:i,promotionId:e,hiding:t,isEventFired:n,fireEvent:s,direction:r="bottom"})=>{const a=(i==null?void 0:i.adUnit)===ue.AdUnit.STANDART,l=a?i.banner:i.additionalBanner;if(_e.useEffect(()=>{l!=null&&l.imageUrl&&i.type&&e&&(n!=null&&n("banner-showed")||(W.eventBus.emit("advertisement",{action:"bannerShown",payload:{id:e,type:i.type}}),s==null||s("banner-showed")))},[l==null?void 0:l.imageUrl,s,n,i.type,e]),!(l!=null&&l.imageUrl))return null;let c=l==null?void 0:l.url;return c&&c.indexOf("http")!==0&&(c=`https://${c}`),z.jsx(bo,{direction:r,hiding:t,children:z.jsx(lm,{className:"BannerContainer","data-is-ad":a,children:z.jsx(dm,{as:c?"a":"span",className:"BannerLink",href:c,style:{backgroundImage:`url(${l.imageUrl})`,cursor:c?"pointer":"default"},"data-promo-id":e,"data-promo-type":i.type,"data-a":"banner",target:"_blank","data-is-ad":a})})})},hm=({cardId:i,promotion:e,direction:t="bottom"})=>z.jsx(Od,{promotion:e,promotionId:i,direction:t,hiding:!1}),cm=W.styled_default("div")({name:"NotificationContent",class:"n18wsqoo",propsAsIs:!1}),pm=W.styled_default("div")({name:"Body",class:"b1ia90c2",propsAsIs:!1}),gm=W.styled_default("div")({name:"Title",class:"tg2z08v",propsAsIs:!1}),fm=W.styled_default("div")({name:"Text",class:"t59zdk1",propsAsIs:!1}),To=W.styled_default("div")({name:"MediaImgBottom",class:"m1ab9fq",propsAsIs:!1}),mm=()=>To,ym=W.styled_default(mm())({name:"MediaImgMiddle",class:"m9fsr0y",propsAsIs:!0}),iu=W.styled_default("img")({name:"CtaIcon",class:"cvi9y5q",propsAsIs:!1}),_m=W.styled_default("div")({name:"Logo",class:"l5mq0z",propsAsIs:!1}),bm=W.styled_default("div")({name:"Footer",class:"f1mse0ft",propsAsIs:!1}),Tm=W.styled_default("div")({name:"Vector",class:"v1hcloah",propsAsIs:!1}),vm=W.styled_default("div")({name:"NotificationContainer",class:"n3n65jf",propsAsIs:!1}),Md=W.styled_default("button")({name:"TVButton",class:"tkkfuqy",propsAsIs:!1}),Sm=()=>Md,Em=W.styled_default(Sm())({name:"DismissButton",class:"dh9vato",propsAsIs:!0}),wm=()=>Md,Rd=W.styled_default(wm())({name:"OpenButton",class:"oeah8gv",propsAsIs:!0}),km={[ue.NotificationPromotionImagePosition.BOTTOM]:To,[ue.NotificationPromotionImagePosition.MIDDLE]:ym},Cm=({src:i,imagePosition:e})=>{const t=km[e]||To;return z.jsx(t,{children:z.jsx("img",{src:i,alt:""})})},Im=W.O(Em),xm=W.O(Rd),Am=({notification:i,open:e,close:t,webos:n})=>{if(!i||!i.promotion||i.enabled!==ue.NotificationEnabled.NOTIFICATION_ENABLED)return null;const{title:s,body:r,image:a,promotion:l}=i,{sponsorLogo:c,sponsorLogoMode:f,imagePosition:m,ctaButton:b}=l;return z.jsxs(vm,{"data-webos":n,className:"SL_Lower_Third_Notification",onClick:n?void 0:e,children:[z.jsxs(cm,{children:[z.jsx(Cm,{src:a,imagePosition:m}),z.jsxs(pm,{children:[s&&z.jsx(gm,{children:s}),r&&z.jsx(fm,{children:r})]})]}),z.jsxs(bm,{children:[f!==ue.NotificationSponsorLogoMode.NOTIFICATION_SPONSOR_LOGO_NONE&&z.jsxs(z.Fragment,{children:[z.jsx(_m,{children:z.jsx("img",{src:c,alt:s})}),z.jsx(Tm,{})]}),n?z.jsxs(z.Fragment,{children:[z.jsx(Im,{webos:!0,onClick:t,children:"Dismiss"}),z.jsxs(xm,{webos:!0,autoFocus:!0,style:{color:b==null?void 0:b.textColor,backgroundColor:b==null?void 0:b.color},onClick:e,children:[(b==null?void 0:b.ctaIcon)&&(b==null?void 0:b.ctaIconMode)===ue.CtaIconMode.CTA_ICON_TRANSPARENT&&z.jsx(iu,{src:b==null?void 0:b.ctaIcon,alt:"cta-icon"}),(b==null?void 0:b.label)||"Open"]})]}):z.jsxs(Rd,{name:"promo-button",style:{color:b==null?void 0:b.textColor,backgroundColor:b==null?void 0:b.color},children:[(b==null?void 0:b.ctaIcon)&&(b==null?void 0:b.ctaIconMode)===ue.CtaIconMode.CTA_ICON_TRANSPARENT&&z.jsx(iu,{src:b==null?void 0:b.ctaIcon,alt:"cta-icon"}),(b==null?void 0:b.label)||"Open"]})]})]})},Pm=W.styled_default("div")({name:"NotificationContent",class:"n1ku6hz",propsAsIs:!1}),Lm=W.styled_default("div")({name:"NotificationContainer",class:"nbxqmol",propsAsIs:!1}),Dm=W.styled_default("div")({name:"Body",class:"b1gu3eml",propsAsIs:!1}),Om=W.styled_default("div")({name:"Title",class:"t1u17zva",propsAsIs:!1}),Mm=W.styled_default("div")({name:"Text",class:"t10ko1g",propsAsIs:!1}),Lr=W.styled_default("div")({name:"Media",class:"mntc42e",propsAsIs:!1}),Rm=()=>Lr,nu=W.styled_default(Rm())({name:"MediaImgFit",class:"ml060eo",propsAsIs:!0}),Um=()=>Lr,Ud=W.styled_default(Um())({name:"MediaImgCentered",class:"m1vqlvig",propsAsIs:!0}),Nm=()=>Ud,Bm=W.styled_default(Nm())({name:"MediaImgBottom",class:"m1e7tvi5",propsAsIs:!0}),Fm=()=>Lr,jm=W.styled_default(Fm())({name:"MediaImgSolid",class:"mqvntt2",propsAsIs:!0}),$m=()=>Lr,qm=W.styled_default($m())({name:"MediaImgMiddle",class:"m12jtj3u",propsAsIs:!0}),Vm=W.styled_default("img")({name:"CtaIcon",class:"ckq1frv",propsAsIs:!1}),Hm=()=>W.B1,zm=W.styled_default(Hm())({name:"StyledChevronRight",class:"s9mjmz3",propsAsIs:!0}),Wm=W.styled_default("div")({name:"Logo",class:"l1cf50a7",propsAsIs:!1}),Nd=W.styled_default("button")({name:"TVButton",class:"thdqfl0",propsAsIs:!1}),Gm=()=>Nd,Xm=W.styled_default(Gm())({name:"DismissButton",class:"d11pe8bx",propsAsIs:!0}),Km=()=>Nd,Ym=W.styled_default(Km())({name:"OpenButton",class:"oy9k0kp",propsAsIs:!0}),Qm={[ue.NotificationPromotionImagePosition.UNSET]:nu,[ue.NotificationPromotionImagePosition.FIT]:nu,[ue.NotificationPromotionImagePosition.CENTERED]:Ud,[ue.NotificationPromotionImagePosition.BOTTOM]:Bm,[ue.NotificationPromotionImagePosition.SOLID]:jm,[ue.NotificationPromotionImagePosition.MIDDLE]:qm},Jm=({src:i,imagePosition:e})=>{const t=Qm[e];return z.jsx(t,{children:z.jsx("img",{src:i,alt:""})})},Zm=W.O(Xm),ey=W.O(Ym),ty=({notification:i,open:e,promotionId:t,hiding:n,direction:s="left",close:r,webos:a})=>{if(!i||!i.promotion||i.enabled!==ue.NotificationEnabled.NOTIFICATION_ENABLED)return null;if(i.promotion.mode===ue.NotificationPromotionMode.LOWER_THIRD)return z.jsx(Am,{notification:i,open:e,close:r,webos:a});const{title:l,body:c,image:f,promotion:m}=i,{sponsorLogo:b,sponsorLogoMode:C,imagePosition:w,ctaButton:A}=m,v=M=>{M.stopPropagation(),r==null||r()};return z.jsx(bo,{className:"SL_Rich_Notification",direction:s,hiding:n,children:z.jsxs(Lm,{onClick:a?()=>{}:e,children:[C!==ue.NotificationSponsorLogoMode.NOTIFICATION_SPONSOR_LOGO_NONE&&b&&z.jsx(Wm,{children:z.jsx("img",{src:b,alt:l})}),z.jsxs(Pm,{children:[z.jsx(Jm,{src:f,imagePosition:w}),z.jsxs(Dm,{children:[l&&z.jsx(Om,{children:l}),c&&z.jsx(Mm,{children:c})]}),a&&z.jsx(Zm,{webos:!0,onClick:v,children:"Dismiss"}),z.jsxs(ey,{webos:a,autoFocus:a,onClick:a?e:()=>{},name:"promo-button",style:{color:A==null?void 0:A.textColor,backgroundColor:A==null?void 0:A.color},children:[(A==null?void 0:A.ctaIcon)&&(A==null?void 0:A.ctaIconMode)===ue.CtaIconMode.CTA_ICON_TRANSPARENT&&z.jsx(Vm,{src:A==null?void 0:A.ctaIcon,alt:"cta-icon"}),(A==null?void 0:A.label)||"Open"]}),z.jsx(zm,{name:"chevronRight"})]})]})})},iy=W.styled_default("div")({name:"OverlayContainer",class:"okzhq2w",propsAsIs:!1}),Bd=W.styled_default("div")({name:"PromoOverlay",class:"pmgz5i",propsAsIs:!1}),Fd=W.styled_default("div")({name:"Header",class:"hyxi3jt",propsAsIs:!1}),jd=W.styled_default("div")({name:"HeaderContent",class:"h149e3gp",propsAsIs:!1}),$d="h10toh7",su=W.styled_default("img")({name:"SponsorLogo",class:"s1jyea6t",propsAsIs:!1}),ny=W.styled_default("div")({name:"SponsorName",class:"szpfa3h",propsAsIs:!1}),qd=W.styled_default("div")({name:"Media",class:"m1crmu01",propsAsIs:!1}),sy=W.styled_default("img")({name:"PromoImg",class:"p1l37r8s",propsAsIs:!1}),ry="s1nmch9k",ru=W.styled_default("div")({name:"Content",class:"c1er0ljd",propsAsIs:!1}),ay=W.styled_default("div")({name:"Description",class:"dydopmr",propsAsIs:!1}),oy=W.styled_default("div")({name:"Sponsor",class:"s1w6nt04",propsAsIs:!1}),ly=W.styled_default("div")({name:"SponsorText",class:"s1evcmtq",propsAsIs:!1}),Vd=W.styled_default("div")({name:"ADLogo",class:"awodx0x",propsAsIs:!1}),uy=W.styled_default("span")({name:"SponsoredText",class:"s1q3n6oi",propsAsIs:!1}),Hd=W.styled_default("div")({name:"ActionBtnWrap",class:"a8d4xfk",propsAsIs:!1}),zd=W.styled_default("a")({name:"ActionButton",class:"at6oobh",propsAsIs:!1}),dy=W.styled_default("div")({name:"Title",class:"t1gyg7tt",propsAsIs:!1}),hy="h17rwbtk",cy=W.styled_default("div")({name:"Container",class:"c10m2bce",propsAsIs:!1}),au=W.styled_default("div")({name:"Item",class:"ig23yq5",propsAsIs:!1}),py=W.styled_default("div")({name:"Dot",class:"d1f6aqua",propsAsIs:!1}),gy=({time:i,adCount:e,adPosition:t})=>{const n=Math.floor(i/60),s=i-n*60;return n===0&&s===0&&e===t?null:z.jsxs(cy,{children:[e>1&&z.jsxs(z.Fragment,{children:[z.jsxs(au,{children:[t," of ",e]}),z.jsx(py,{})]}),z.jsxs(au,{children:[n,":",s<10?`0${s}`:s]})]})},fy=W.styled_default("a")({name:"WhyThisAdLink",class:"w13o8uld",propsAsIs:!1}),my=({whyThisAd:i})=>{const[e,t]=_e.useState(!1);return!i.iconClickThroughURLTemplate||!i.staticResource?null:z.jsxs(fy,{style:{width:i.width,height:i.height,[i.xPosition]:3,[i.yPosition]:11},href:i.iconClickThroughURLTemplate,target:"_blank",rel:"noreferrer",children:[!e&&z.jsx("img",{alt:"ad choice",src:i.staticResource,onLoad:()=>t(!1),onError:()=>t(!0)}),e&&z.jsx("span",{children:"ad choice"})]})},yy=W.styled_default("div")({name:"VideoControls",class:"v1xzooj9",propsAsIs:!1}),Wd=W.styled_default("button")({name:"ControlBtn",class:"c1bo41vr",propsAsIs:!1}),_y=()=>Wd,by=W.styled_default(_y())({name:"MuteIcon",class:"m13efyu8",propsAsIs:!0}),Ty=()=>Wd,vy=W.styled_default(Ty())({name:"PauseIcon",class:"pladkgh",propsAsIs:!0}),Sy=W.styled_default("div")({name:"Container",class:"cjnga56",propsAsIs:!1}),Ey=W.styled_default("div")({name:"ControlsContainer",class:"c7qs1am",propsAsIs:!1}),ou="m12n261r",lu="m16vcml8",uu="m1078nk6",du=globalThis||void 0||self;class wy{constructor(e){this.id=e.getAttribute("id"),this.allowMultipleAds=e.getAttribute("allowMultipleAds"),this.followRedirects=e.getAttribute("followRedirects"),this.vastAdData=null,this.adTagURI=null,this.customData=null;for(const t in e.childNodes){const n=e.childNodes[t];switch(n.localName){case"AdTagURI":this.adTagURI={templateType:n.getAttribute("templateType"),uri:(n.textContent||n.text||"").trim()};break;case"VASTAdData":for(this.vastAdData=n.firstChild;this.vastAdData&&this.vastAdData.nodeType!==1;)this.vastAdData=this.vastAdData.nextSibling;break;case"CustomAdData":this.customData=n;break}}}}function Gd(i,e){const t=[];for(const n in i.childNodes){const s=i.childNodes[n];(s.nodeName===e||e===`vmap:${s.nodeName}`||s.nodeName===`vmap:${e}`)&&t.push(s)}return t}function ky(i){if(!i||!i.childNodes)return{};const e=i.childNodes,t=[];for(const s in e){const r=e[s];r.nodeName==="#cdata-section"&&t.push(r)}if(t&&t.length>0)try{return JSON.parse(t[0].data)}catch{}let n="";for(const s in e){const r=e[s];switch(r.nodeName){case"#text":n+=r.textContent.trim();break;case"#cdata-section":n+=r.data;break}}return n}function vo(i){const e={attributes:{},children:{},value:{}};e.value=ky(i);const t=i.attributes;if(t)for(const s in t){const r=t[s];r.nodeName&&r.nodeValue!==void 0&&r.nodeValue!==null&&(e.attributes[r.nodeName]=r.nodeValue)}const n=i.childNodes;if(n)for(const s in n){const r=n[s];r.nodeName&&r.nodeName.substring(0,1)!=="#"&&(e.children[r.nodeName]=vo(r))}return e}class Cy{constructor(e){this.timeOffset=e.getAttribute("timeOffset"),this.breakType=e.getAttribute("breakType"),this.breakId=e.getAttribute("breakId"),this.repeatAfter=e.getAttribute("repeatAfter"),this.adSource=null,this.trackingEvents=[],this.extensions=[];for(const t in e.childNodes){const n=e.childNodes[t];switch(n.localName){case"AdSource":this.adSource=new wy(n);break;case"TrackingEvents":for(const s in n.childNodes){const r=n.childNodes[s];r.localName==="Tracking"&&this.trackingEvents.push({event:r.getAttribute("event"),uri:(r.textContent||r.text||"").trim()})}break;case"Extensions":this.extensions=Gd(n,"Extension").map(s=>vo(s));break}}}track(e,t){for(const n in this.trackingEvents){const s=this.trackingEvents[n];if(s.event===e){let{uri:r}=s;s.event==="error"&&(r=r.replace("[ERRORCODE]",t)),this.tracker(r)}}}tracker(e){if(typeof window<"u"&&window!==null){const t=new Image;t.src=e}}}class Iy{constructor(e){if(!e||!e.documentElement||e.documentElement.localName!=="VMAP")throw new Error("Not a VMAP document");this.version=e.documentElement.getAttribute("version"),this.adBreaks=[],this.extensions=[];for(const t in e.documentElement.childNodes){const n=e.documentElement.childNodes[t];switch(n.localName){case"AdBreak":this.adBreaks.push(new Cy(n));break;case"Extensions":this.extensions=Gd(n,"Extension").map(s=>vo(s));break}}}}const xy=(i,e)=>{const t=goog.pal,n=new t.ConsentSettings;n.allowStorage=!1;const s=new t.NonceLoader(n);return async()=>{try{const r=new URL(e),a=new t.NonceRequest;let l=localStorage.getItem("sl-device-id")||Gn.v4(),c=sessionStorage.getItem("sl-ad-session-id");c||(c=Gn.v4(),sessionStorage.setItem("sl-ad-session-id",c)),Gn.validate(l)||(l=Gn.v5(`https://${l}`,Gn.v5.URL)),r.searchParams.get("url")||r.searchParams.set("url","https://streamlayer.io"),r.searchParams.get("description_url")||r.searchParams.set("description_url","https://streamlayer.io"),a.adWillAutoPlay=r.searchParams.get("vpa")==="auto",a.adWillPlayMuted=r.searchParams.get("vpmute")==="1",a.continuousPlayback=!0,a.descriptionUrl=r.searchParams.get("description_url"),a.iconsSupported=!0,a.sessionId=l,a.supportedApiFrameworks="2,7,9",a.videoHeight=i.clientHeight,a.videoWidth=i.clientWidth;const f=await s.loadNonceManager(a);return r.searchParams.get("is_lat")==="[placeholder]"&&r.searchParams.set("is_lat","1"),r.searchParams.get("rdid")==="[placeholder]"&&r.searchParams.set("rdid",l),r.searchParams.get("correlator")==="[placeholder]"&&r.searchParams.set("correlator",c),r.searchParams.set("wta","1"),r.searchParams.set("givn",f.getNonce()),{url:r,manager:f}}catch(r){console.log("AdsManager could not be started",r);return}}},Ay=new Dd.ce,Py=i=>i.creatives.find(e=>e.mediaFiles),Ly=i=>{var e;const t=i==null?void 0:i.mediaFiles;return t!=null&&t.length&&((e=t.find(n=>n.fileURL))==null?void 0:e.fileURL)||""},Xn=W.a({ads:[],autoplay:!0,muted:!1,nonceManager:void 0}),Dy=(i,e)=>{const[t,n]=_e.useState(),s=_e.useRef(Date.now()),r=_e.useRef(Date.now());return _e.useEffect(()=>{if(!e||!(i!=null&&i.current))return;const a=xy(i.current,e),l=Date.now();s.current=l,Xn.set({ads:[],autoplay:!0,muted:!1,nonceManager:void 0}),a().then(c=>{s.current===l&&c&&(n(c.url),Xn.set({ads:[],autoplay:!0,muted:!1,nonceManager:c.manager}))}).catch(c=>{console.error(c)})},[i,e]),_e.useEffect(()=>{const a=async(l,c)=>{let f=[];if(l.searchParams.get("output")==="vmap"){const w=await fetch(l.toString()),A=new DOMParser,v=await w.text(),M=A.parseFromString(v,"text/xml");f=new Iy(M).adBreaks.map(D=>D.adSource.adTagURI.uri)}else f=[l.toString()];const m=await Promise.all(f.map((w,A)=>Ay.get(w).then(v=>{if(r.current===c){const M=v.ads.find(N=>N.creatives.length>0);if(!M)return;const D=Py(M),R=Ly(D);return{creative:D,order:A,mediaFileUrl:R,ad:M,raw:v}}}))),b=l.searchParams.get("vpa")!=="click",C=l.searchParams.get("vpmute")==="1";Xn.set({...Xn.get(),ads:m.filter(w=>!!w),autoplay:b,muted:C})};if(t){const l=Date.now();r.current=l,a(t,l)}return()=>{r.current=0}},[t]),Xn},ar=globalThis||void 0||self;var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof du<"u"?du:typeof self<"u"?self:{};function ms(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Oy(i){if(i.__esModule)return i;var e=i.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(i).forEach(function(n){var s=Object.getOwnPropertyDescriptor(i,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:function(){return i[n]}})}),t}var Zn;typeof window<"u"?Zn=window:typeof or<"u"?Zn=or:typeof self<"u"?Zn=self:Zn={};var Dr=Zn;const x=ms(Dr),My={},Ry=Object.freeze(Object.defineProperty({__proto__:null,default:My},Symbol.toStringTag,{value:"Module"})),Uy=Oy(Ry);var hu=typeof or<"u"?or:typeof window<"u"?window:{},Ny=Uy,es;typeof document<"u"?es=document:(es=hu["__GLOBAL_DOCUMENT_CACHE@4"],es||(es=hu["__GLOBAL_DOCUMENT_CACHE@4"]=Ny));var Xd=es;const G=ms(Xd);var So={exports:{}},Kd={exports:{}};(function(i){function e(){return i.exports=e=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var s=arguments[n];for(var r in s)({}).hasOwnProperty.call(s,r)&&(t[r]=s[r])}return t},i.exports.__esModule=!0,i.exports.default=i.exports,e.apply(null,arguments)}i.exports=e,i.exports.__esModule=!0,i.exports.default=i.exports})(Kd);var By=Kd.exports,Fy=$y,jy=Object.prototype.toString;function $y(i){if(!i)return!1;var e=jy.call(i);return e==="[object Function]"||typeof i=="function"&&e!=="[object RegExp]"||typeof window<"u"&&(i===window.setTimeout||i===window.alert||i===window.confirm||i===window.prompt)}function qy(i,e){var t=typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t)return(t=t.call(i)).next.bind(t);if(Array.isArray(i)||(t=Vy(i))||e){t&&(i=t);var n=0;return function(){return n>=i.length?{done:!0}:{done:!1,value:i[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vy(i,e){if(i){if(typeof i=="string")return cu(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return cu(i,e)}}function cu(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=i[t];return n}var Hy=function(){function i(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1}var e=i.prototype;return e.getIsEnabled=function(){return this.enabled_},e.enable=function(){this.enabled_=!0},e.disable=function(){this.enabled_=!1},e.reset=function(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1},e.addInterceptor=function(t,n){this.typeToInterceptorsMap_.has(t)||this.typeToInterceptorsMap_.set(t,new Set);var s=this.typeToInterceptorsMap_.get(t);return s.has(n)?!1:(s.add(n),!0)},e.removeInterceptor=function(t,n){var s=this.typeToInterceptorsMap_.get(t);return s&&s.has(n)?(s.delete(n),!0):!1},e.clearInterceptorsByType=function(t){var n=this.typeToInterceptorsMap_.get(t);return n?(this.typeToInterceptorsMap_.delete(t),this.typeToInterceptorsMap_.set(t,new Set),!0):!1},e.clear=function(){return this.typeToInterceptorsMap_.size?(this.typeToInterceptorsMap_=new Map,!0):!1},e.getForType=function(t){return this.typeToInterceptorsMap_.get(t)||new Set},e.execute=function(t,n){for(var s=this.getForType(t),r=qy(s),a;!(a=r()).done;){var l=a.value;try{n=l(n)}catch{}}return n},i}(),zy=Hy,Wy=function(){function i(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1}var e=i.prototype;return e.getIsEnabled=function(){return this.enabled_},e.enable=function(){this.enabled_=!0},e.disable=function(){this.enabled_=!1},e.reset=function(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1},e.getMaxAttempts=function(){return this.maxAttempts_},e.setMaxAttempts=function(t){this.maxAttempts_=t},e.getDelayFactor=function(){return this.delayFactor_},e.setDelayFactor=function(t){this.delayFactor_=t},e.getFuzzFactor=function(){return this.fuzzFactor_},e.setFuzzFactor=function(t){this.fuzzFactor_=t},e.getInitialDelay=function(){return this.initialDelay_},e.setInitialDelay=function(t){this.initialDelay_=t},e.createRetry=function(t){var n=t===void 0?{}:t,s=n.maxAttempts,r=n.delayFactor,a=n.fuzzFactor,l=n.initialDelay;return new Gy({maxAttempts:s||this.maxAttempts_,delayFactor:r||this.delayFactor_,fuzzFactor:a||this.fuzzFactor_,initialDelay:l||this.initialDelay_})},i}(),Gy=function(){function i(t){this.maxAttempts_=t.maxAttempts,this.delayFactor_=t.delayFactor,this.fuzzFactor_=t.fuzzFactor,this.currentDelay_=t.initialDelay,this.currentAttempt_=1}var e=i.prototype;return e.moveToNextAttempt=function(){this.currentAttempt_++;var t=this.currentDelay_*this.delayFactor_;this.currentDelay_=this.currentDelay_+t},e.shouldRetry=function(){return this.currentAttempt_<this.maxAttempts_},e.getCurrentDelay=function(){return this.currentDelay_},e.getCurrentMinPossibleDelay=function(){return(1-this.fuzzFactor_)*this.currentDelay_},e.getCurrentMaxPossibleDelay=function(){return(1+this.fuzzFactor_)*this.currentDelay_},e.getCurrentFuzzedDelay=function(){var t=this.getCurrentMinPossibleDelay(),n=this.getCurrentMaxPossibleDelay();return t+Math.random()*(n-t)},i}(),Xy=Wy,Ky=Dr,Yy=function(i,e){return e===void 0&&(e=!1),function(t,n,s){if(t){i(t);return}if(n.statusCode>=400&&n.statusCode<=599){var r=s;if(e)if(Ky.TextDecoder){var a=Qy(n.headers&&n.headers["content-type"]);try{r=new TextDecoder(a).decode(s)}catch{}}else r=String.fromCharCode.apply(null,new Uint8Array(s));i({cause:r});return}i(null,s)}};function Qy(i){return i===void 0&&(i=""),i.toLowerCase().split(";").reduce(function(e,t){var n=t.split("="),s=n[0],r=n[1];return s.trim()==="charset"?r.trim():e},"utf-8")}var Jy=Yy,Yd=Dr,Zy=By,e_=Fy,Qd=zy,t_=Xy;Fe.httpHandler=Jy;Fe.requestInterceptorsStorage=new Qd;Fe.responseInterceptorsStorage=new Qd;Fe.retryManager=new t_;/**
|
|
3
3
|
* @license
|
|
4
4
|
* slighly modified parse-headers 2.0.2 <https://github.com/kesla/parse-headers/>
|
|
5
5
|
* Copyright (c) 2014 David Björklund
|
|
6
6
|
* Available under the MIT license
|
|
7
7
|
* <https://github.com/kesla/parse-headers/blob/master/LICENCE>
|
|
8
|
-
*/var
|
|
9
|
-
`).forEach(function(t){var n=t.indexOf(":"),s=t.slice(0,n).trim().toLowerCase(),r=t.slice(n+1).trim();typeof e[s]>"u"?e[s]=r:Array.isArray(e[s])?e[s].push(r):e[s]=[e[s],r]}),e};Eo.exports=Fe;Eo.exports.default=Fe;Fe.XMLHttpRequest=Zd.XMLHttpRequest||m_;Fe.XDomainRequest="withCredentials"in new Fe.XMLHttpRequest?Fe.XMLHttpRequest:Zd.XDomainRequest;p_(["get","put","post","patch","head","delete"],function(i){Fe[i==="delete"?"del":i]=function(e,t,n){return t=th(e,t,n),t.method=i.toUpperCase(),wo(t)}});function p_(i,e){for(var t=0;t<i.length;t++)e(i[t])}function f_(i){for(var e in i)if(i.hasOwnProperty(e))return!1;return!0}function th(i,e,t){var n=i;return d_(e)?(t=e,typeof i=="string"&&(n={uri:i})):n=u_({},e,{uri:i}),n.callback=t,n}function Fe(i,e,t){return e=th(i,e,t),wo(e)}function wo(i){if(typeof i.callback>"u")throw new Error("callback argument missing");if(i.requestType&&Fe.requestInterceptorsStorage.getIsEnabled()){var e={uri:i.uri||i.url,headers:i.headers||{},body:i.body,metadata:i.metadata||{},retry:i.retry,timeout:i.timeout},t=Fe.requestInterceptorsStorage.execute(i.requestType,e);i.uri=t.uri,i.headers=t.headers,i.body=t.body,i.metadata=t.metadata,i.retry=t.retry,i.timeout=t.timeout}var n=!1,s=function(F,P,$){n||(n=!0,i.callback(F,P,$))};function r(){g.readyState===4&&!Fe.responseInterceptorsStorage.getIsEnabled()&&setTimeout(c,0)}function a(){var F=void 0;if(g.response?F=g.response:F=g.responseText||g_(g),D)try{F=JSON.parse(F)}catch{}return F}function l(F){if(clearTimeout(R),clearTimeout(i.retryTimeout),F instanceof Error||(F=new Error(""+(F||"Unknown XMLHttpRequest Error"))),F.statusCode=0,!b&&Fe.retryManager.getIsEnabled()&&i.retry&&i.retry.shouldRetry()){i.retryTimeout=setTimeout(function(){i.retry.moveToNextAttempt(),i.xhr=g,wo(i)},i.retry.getCurrentFuzzedDelay());return}if(i.requestType&&Fe.responseInterceptorsStorage.getIsEnabled()){var P={headers:N.headers||{},body:N.body,responseUrl:g.responseURL,responseType:g.responseType},$=Fe.responseInterceptorsStorage.execute(i.requestType,P);N.body=$.body,N.headers=$.headers}return s(F,N)}function c(){if(!b){var F;clearTimeout(R),clearTimeout(i.retryTimeout),i.useXDR&&g.status===void 0?F=200:F=g.status===1223?204:g.status;var P=N,$=null;if(F!==0?(P={body:a(),statusCode:F,method:w,headers:{},url:C,rawRequest:g},g.getAllResponseHeaders&&(P.headers=c_(g.getAllResponseHeaders()))):$=new Error("Internal XMLHttpRequest Error"),i.requestType&&Fe.responseInterceptorsStorage.getIsEnabled()){var Y={headers:P.headers||{},body:P.body,responseUrl:g.responseURL,responseType:g.responseType},X=Fe.responseInterceptorsStorage.execute(i.requestType,Y);P.body=X.body,P.headers=X.headers}return s($,P,P.body)}}var g=i.xhr||null;g||(i.cors||i.useXDR?g=new Fe.XDomainRequest:g=new Fe.XMLHttpRequest);var m,b,C=g.url=i.uri||i.url,w=g.method=i.method||"GET",A=i.body||i.data,v=g.headers=i.headers||{},M=!!i.sync,D=!1,R,N={body:void 0,headers:{},statusCode:0,method:w,url:C,rawRequest:g};if("json"in i&&i.json!==!1&&(D=!0,v.accept||v.Accept||(v.Accept="application/json"),w!=="GET"&&w!=="HEAD"&&(v["content-type"]||v["Content-Type"]||(v["Content-Type"]="application/json"),A=JSON.stringify(i.json===!0?A:i.json))),g.onreadystatechange=r,g.onload=c,g.onerror=l,g.onprogress=function(){},g.onabort=function(){b=!0,clearTimeout(i.retryTimeout)},g.ontimeout=l,g.open(w,C,!M,i.username,i.password),M||(g.withCredentials=!!i.withCredentials),!M&&i.timeout>0&&(R=setTimeout(function(){if(!b){b=!0,g.abort("timeout");var F=new Error("XMLHttpRequest timeout");F.code="ETIMEDOUT",l(F)}},i.timeout)),g.setRequestHeader)for(m in v)v.hasOwnProperty(m)&&g.setRequestHeader(m,v[m]);else if(i.headers&&!f_(i.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in i&&(g.responseType=i.responseType),"beforeSend"in i&&typeof i.beforeSend=="function"&&i.beforeSend(g),g.send(A||null),g}function g_(i){try{if(i.responseType==="document")return i.responseXML;var e=i.responseXML&&i.responseXML.documentElement.nodeName==="parsererror";if(i.responseType===""&&!e)return i.responseXML}catch{}return null}function m_(){}var y_=Eo.exports;const ih=gs(y_);var nh={exports:{}},gu=Qd,ko=Object.create||function(){function i(){}return function(e){if(arguments.length!==1)throw new Error("Object.create shim only accepts one parameter.");return i.prototype=e,new i}}();function Tt(i,e){this.name="ParsingError",this.code=i.code,this.message=e||i.message}Tt.prototype=ko(Error.prototype);Tt.prototype.constructor=Tt;Tt.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}};function Co(i){function e(n,s,r,a){return(n|0)*3600+(s|0)*60+(r|0)+(a|0)/1e3}var t=i.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);return t?t[3]?e(t[1],t[2],t[3].replace(":",""),t[4]):t[1]>59?e(t[1],t[2],0,t[4]):e(0,t[1],t[2],t[4]):null}function ss(){this.values=ko(null)}ss.prototype={set:function(i,e){!this.get(i)&&e!==""&&(this.values[i]=e)},get:function(i,e,t){return t?this.has(i)?this.values[i]:e[t]:this.has(i)?this.values[i]:e},has:function(i){return i in this.values},alt:function(i,e,t){for(var n=0;n<t.length;++n)if(e===t[n]){this.set(i,e);break}},integer:function(i,e){/^-?\d+$/.test(e)&&this.set(i,parseInt(e,10))},percent:function(i,e){return e.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(e=parseFloat(e),e>=0&&e<=100)?(this.set(i,e),!0):!1}};function es(i,e,t,n){var s=n?i.split(n):[i];for(var r in s)if(typeof s[r]=="string"){var a=s[r].split(t);if(a.length===2){var l=a[0].trim(),c=a[1].trim();e(l,c)}}}function __(i,e,t){var n=i;function s(){var l=Co(i);if(l===null)throw new Tt(Tt.Errors.BadTimeStamp,"Malformed timestamp: "+n);return i=i.replace(/^[^\sa-zA-Z-]+/,""),l}function r(l,c){var g=new ss;es(l,function(m,b){switch(m){case"region":for(var C=t.length-1;C>=0;C--)if(t[C].id===b){g.set(m,t[C].region);break}break;case"vertical":g.alt(m,b,["rl","lr"]);break;case"line":var w=b.split(","),A=w[0];g.integer(m,A),g.percent(m,A)&&g.set("snapToLines",!1),g.alt(m,A,["auto"]),w.length===2&&g.alt("lineAlign",w[1],["start","center","end"]);break;case"position":w=b.split(","),g.percent(m,w[0]),w.length===2&&g.alt("positionAlign",w[1],["start","center","end"]);break;case"size":g.percent(m,b);break;case"align":g.alt(m,b,["start","center","end","left","right"]);break}},/:/,/\s/),c.region=g.get("region",null),c.vertical=g.get("vertical","");try{c.line=g.get("line","auto")}catch{}c.lineAlign=g.get("lineAlign","start"),c.snapToLines=g.get("snapToLines",!0),c.size=g.get("size",100);try{c.align=g.get("align","center")}catch{c.align=g.get("align","middle")}try{c.position=g.get("position","auto")}catch{c.position=g.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},c.align)}c.positionAlign=g.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},c.align)}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),i.substr(0,3)!=="-->")throw new Tt(Tt.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '-->'): "+n);i=i.substr(3),a(),e.endTime=s(),a(),r(i,e)}var ka=gu.createElement&&gu.createElement("textarea"),b_={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},mu={white:"rgba(255,255,255,1)",lime:"rgba(0,255,0,1)",cyan:"rgba(0,255,255,1)",red:"rgba(255,0,0,1)",yellow:"rgba(255,255,0,1)",magenta:"rgba(255,0,255,1)",blue:"rgba(0,0,255,1)",black:"rgba(0,0,0,1)"},T_={v:"title",lang:"lang"},yu={rt:"ruby"};function sh(i,e){function t(){if(!e)return null;function A(M){return e=e.substr(M.length),M}var v=e.match(/^([^<]*)(<[^>]*>?)?/);return A(v[1]?v[1]:v[2])}function n(A){return ka.innerHTML=A,A=ka.textContent,ka.textContent="",A}function s(A,v){return!yu[v.localName]||yu[v.localName]===A.localName}function r(A,v){var M=b_[A];if(!M)return null;var D=i.document.createElement(M),R=T_[A];return R&&v&&(D[R]=v.trim()),D}for(var a=i.document.createElement("div"),l=a,c,g=[];(c=t())!==null;){if(c[0]==="<"){if(c[1]==="/"){g.length&&g[g.length-1]===c.substr(2).replace(">","")&&(g.pop(),l=l.parentNode);continue}var m=Co(c.substr(1,c.length-2)),b;if(m){b=i.document.createProcessingInstruction("timestamp",m),l.appendChild(b);continue}var C=c.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!C||(b=r(C[1],C[3]),!b)||!s(l,b))continue;if(C[2]){var w=C[2].split(".");w.forEach(function(A){var v=/^bg_/.test(A),M=v?A.slice(3):A;if(mu.hasOwnProperty(M)){var D=v?"background-color":"color",R=mu[M];b.style[D]=R}}),b.className=w.join(" ")}g.push(C[1]),l.appendChild(b),l=b;continue}l.appendChild(i.document.createTextNode(n(c)))}return a}var _u=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function v_(i){for(var e=0;e<_u.length;e++){var t=_u[e];if(i>=t[0]&&i<=t[1])return!0}return!1}function S_(i){var e=[],t="",n;if(!i||!i.childNodes)return"ltr";function s(l,c){for(var g=c.childNodes.length-1;g>=0;g--)l.push(c.childNodes[g])}function r(l){if(!l||!l.length)return null;var c=l.pop(),g=c.textContent||c.innerText;if(g){var m=g.match(/^.*(\n|\r)/);return m?(l.length=0,m[0]):g}if(c.tagName==="ruby")return r(l);if(c.childNodes)return s(l,c),r(l)}for(s(e,i);t=r(e);)for(var a=0;a<t.length;a++)if(n=t.charCodeAt(a),v_(n))return"rtl";return"ltr"}function E_(i){if(typeof i.line=="number"&&(i.snapToLines||i.line>=0&&i.line<=100))return i.line;if(!i.track||!i.track.textTrackList||!i.track.textTrackList.mediaElement)return-1;for(var e=i.track,t=e.textTrackList,n=0,s=0;s<t.length&&t[s]!==e;s++)t[s].mode==="showing"&&n++;return++n*-1}function Or(){}Or.prototype.applyStyles=function(i,e){e=e||this.div;for(var t in i)i.hasOwnProperty(t)&&(e.style[t]=i[t])};Or.prototype.formatStyle=function(i,e){return i===0?0:i+e};function lr(i,e,t){Or.call(this),this.cue=e,this.cueDiv=sh(i,e.text);var n={color:"rgba(255, 255, 255, 1)",backgroundColor:"rgba(0, 0, 0, 0.8)",position:"relative",left:0,right:0,top:0,bottom:0,display:"inline",writingMode:e.vertical===""?"horizontal-tb":e.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(n,this.cueDiv),this.div=i.document.createElement("div"),n={direction:S_(this.cueDiv),writingMode:e.vertical===""?"horizontal-tb":e.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:e.align==="middle"?"center":e.align,font:t.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(n),this.div.appendChild(this.cueDiv);var s=0;switch(e.positionAlign){case"start":case"line-left":s=e.position;break;case"center":s=e.position-e.size/2;break;case"end":case"line-right":s=e.position-e.size;break}e.vertical===""?this.applyStyles({left:this.formatStyle(s,"%"),width:this.formatStyle(e.size,"%")}):this.applyStyles({top:this.formatStyle(s,"%"),height:this.formatStyle(e.size,"%")}),this.move=function(r){this.applyStyles({top:this.formatStyle(r.top,"px"),bottom:this.formatStyle(r.bottom,"px"),left:this.formatStyle(r.left,"px"),right:this.formatStyle(r.right,"px"),height:this.formatStyle(r.height,"px"),width:this.formatStyle(r.width,"px")})}}lr.prototype=ko(Or.prototype);lr.prototype.constructor=lr;function ot(i){var e,t,n,s;if(i.div){t=i.div.offsetHeight,n=i.div.offsetWidth,s=i.div.offsetTop;var r=(r=i.div.childNodes)&&(r=r[0])&&r.getClientRects&&r.getClientRects();i=i.div.getBoundingClientRect(),e=r?Math.max(r[0]&&r[0].height||0,i.height/r.length):0}this.left=i.left,this.right=i.right,this.top=i.top||s,this.height=i.height||t,this.bottom=i.bottom||s+(i.height||t),this.width=i.width||n,this.lineHeight=e!==void 0?e:i.lineHeight}ot.prototype.move=function(i,e){switch(e=e!==void 0?e:this.lineHeight,i){case"+x":this.left+=e,this.right+=e;break;case"-x":this.left-=e,this.right-=e;break;case"+y":this.top+=e,this.bottom+=e;break;case"-y":this.top-=e,this.bottom-=e;break}};ot.prototype.overlaps=function(i){return this.left<i.right&&this.right>i.left&&this.top<i.bottom&&this.bottom>i.top};ot.prototype.overlapsAny=function(i){for(var e=0;e<i.length;e++)if(this.overlaps(i[e]))return!0;return!1};ot.prototype.within=function(i){return this.top>=i.top&&this.bottom<=i.bottom&&this.left>=i.left&&this.right<=i.right};ot.prototype.overlapsOppositeAxis=function(i,e){switch(e){case"+x":return this.left<i.left;case"-x":return this.right>i.right;case"+y":return this.top<i.top;case"-y":return this.bottom>i.bottom}};ot.prototype.intersectPercentage=function(i){var e=Math.max(0,Math.min(this.right,i.right)-Math.max(this.left,i.left)),t=Math.max(0,Math.min(this.bottom,i.bottom)-Math.max(this.top,i.top)),n=e*t;return n/(this.height*this.width)};ot.prototype.toCSSCompatValues=function(i){return{top:this.top-i.top,bottom:i.bottom-this.bottom,left:this.left-i.left,right:i.right-this.right,height:this.height,width:this.width}};ot.getSimpleBoxPosition=function(i){var e=i.div?i.div.offsetHeight:i.tagName?i.offsetHeight:0,t=i.div?i.div.offsetWidth:i.tagName?i.offsetWidth:0,n=i.div?i.div.offsetTop:i.tagName?i.offsetTop:0;i=i.div?i.div.getBoundingClientRect():i.tagName?i.getBoundingClientRect():i;var s={left:i.left,right:i.right,top:i.top||n,height:i.height||e,bottom:i.bottom||n+(i.height||e),width:i.width||t};return s};function w_(i,e,t,n){function s(M,D){for(var R,N=new ot(M),F=1,P=0;P<D.length;P++){for(;M.overlapsOppositeAxis(t,D[P])||M.within(t)&&M.overlapsAny(n);)M.move(D[P]);if(M.within(t))return M;var $=M.intersectPercentage(t);F>$&&(R=new ot(M),F=$),M=new ot(N)}return R||N}var r=new ot(e),a=e.cue,l=E_(a),c=[];if(a.snapToLines){var g;switch(a.vertical){case"":c=["+y","-y"],g="height";break;case"rl":c=["+x","-x"],g="width";break;case"lr":c=["-x","+x"],g="width";break}var m=r.lineHeight,b=m*Math.round(l),C=t[g]+m,w=c[0];Math.abs(b)>C&&(b=b<0?-1:1,b*=Math.ceil(C/m)*m),l<0&&(b+=a.vertical===""?t.height:t.width,c=c.reverse()),r.move(w,b)}else{var A=r.lineHeight/t.height*100;switch(a.lineAlign){case"center":l-=A/2;break;case"end":l-=A;break}switch(a.vertical){case"":e.applyStyles({top:e.formatStyle(l,"%")});break;case"rl":e.applyStyles({left:e.formatStyle(l,"%")});break;case"lr":e.applyStyles({right:e.formatStyle(l,"%")});break}c=["+y","-x","+x","-y"],r=new ot(e)}var v=s(r,c);e.move(v.toCSSCompatValues(t))}function Sn(){}Sn.StringDecoder=function(){return{decode:function(i){if(!i)return"";if(typeof i!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(i))}}};Sn.convertCueToDOMTree=function(i,e){return!i||!e?null:sh(i,e)};var k_=.05,C_="sans-serif",I_="1.5%";Sn.processCues=function(i,e,t){if(!i||!e||!t)return null;for(;t.firstChild;)t.removeChild(t.firstChild);var n=i.document.createElement("div");n.style.position="absolute",n.style.left="0",n.style.right="0",n.style.top="0",n.style.bottom="0",n.style.margin=I_,t.appendChild(n);function s(m){for(var b=0;b<m.length;b++)if(m[b].hasBeenReset||!m[b].displayState)return!0;return!1}if(!s(e)){for(var r=0;r<e.length;r++)n.appendChild(e[r].displayState);return}var a=[],l=ot.getSimpleBoxPosition(n),c=Math.round(l.height*k_*100)/100,g={font:c+"px "+C_};(function(){for(var m,b,C=0;C<e.length;C++)b=e[C],m=new lr(i,b,g),n.appendChild(m.div),w_(i,m,l,a),b.displayState=m.div,a.push(ot.getSimpleBoxPosition(m))})()};Sn.Parser=function(i,e,t){t||(t=e,e={}),e||(e={}),this.window=i,this.vttjs=e,this.state="INITIAL",this.buffer="",this.decoder=t||new TextDecoder("utf8"),this.regionList=[]};Sn.Parser.prototype={reportOrThrowError:function(i){if(i instanceof Tt)this.onparsingerror&&this.onparsingerror(i);else throw i},parse:function(i){var e=this;i&&(e.buffer+=e.decoder.decode(i,{stream:!0}));function t(){for(var m=e.buffer,b=0;b<m.length&&m[b]!=="\r"&&m[b]!==`
|
|
8
|
+
*/var i_=function(i){var e={};return i&&i.trim().split(`
|
|
9
|
+
`).forEach(function(t){var n=t.indexOf(":"),s=t.slice(0,n).trim().toLowerCase(),r=t.slice(n+1).trim();typeof e[s]>"u"?e[s]=r:Array.isArray(e[s])?e[s].push(r):e[s]=[e[s],r]}),e};So.exports=Fe;So.exports.default=Fe;Fe.XMLHttpRequest=Yd.XMLHttpRequest||a_;Fe.XDomainRequest="withCredentials"in new Fe.XMLHttpRequest?Fe.XMLHttpRequest:Yd.XDomainRequest;n_(["get","put","post","patch","head","delete"],function(i){Fe[i==="delete"?"del":i]=function(e,t,n){return t=Jd(e,t,n),t.method=i.toUpperCase(),Eo(t)}});function n_(i,e){for(var t=0;t<i.length;t++)e(i[t])}function s_(i){for(var e in i)if(i.hasOwnProperty(e))return!1;return!0}function Jd(i,e,t){var n=i;return e_(e)?(t=e,typeof i=="string"&&(n={uri:i})):n=Zy({},e,{uri:i}),n.callback=t,n}function Fe(i,e,t){return e=Jd(i,e,t),Eo(e)}function Eo(i){if(typeof i.callback>"u")throw new Error("callback argument missing");if(i.requestType&&Fe.requestInterceptorsStorage.getIsEnabled()){var e={uri:i.uri||i.url,headers:i.headers||{},body:i.body,metadata:i.metadata||{},retry:i.retry,timeout:i.timeout},t=Fe.requestInterceptorsStorage.execute(i.requestType,e);i.uri=t.uri,i.headers=t.headers,i.body=t.body,i.metadata=t.metadata,i.retry=t.retry,i.timeout=t.timeout}var n=!1,s=function(F,P,$){n||(n=!0,i.callback(F,P,$))};function r(){f.readyState===4&&!Fe.responseInterceptorsStorage.getIsEnabled()&&setTimeout(c,0)}function a(){var F=void 0;if(f.response?F=f.response:F=f.responseText||r_(f),D)try{F=JSON.parse(F)}catch{}return F}function l(F){if(clearTimeout(R),clearTimeout(i.retryTimeout),F instanceof Error||(F=new Error(""+(F||"Unknown XMLHttpRequest Error"))),F.statusCode=0,!b&&Fe.retryManager.getIsEnabled()&&i.retry&&i.retry.shouldRetry()){i.retryTimeout=setTimeout(function(){i.retry.moveToNextAttempt(),i.xhr=f,Eo(i)},i.retry.getCurrentFuzzedDelay());return}if(i.requestType&&Fe.responseInterceptorsStorage.getIsEnabled()){var P={headers:N.headers||{},body:N.body,responseUrl:f.responseURL,responseType:f.responseType},$=Fe.responseInterceptorsStorage.execute(i.requestType,P);N.body=$.body,N.headers=$.headers}return s(F,N)}function c(){if(!b){var F;clearTimeout(R),clearTimeout(i.retryTimeout),i.useXDR&&f.status===void 0?F=200:F=f.status===1223?204:f.status;var P=N,$=null;if(F!==0?(P={body:a(),statusCode:F,method:w,headers:{},url:C,rawRequest:f},f.getAllResponseHeaders&&(P.headers=i_(f.getAllResponseHeaders()))):$=new Error("Internal XMLHttpRequest Error"),i.requestType&&Fe.responseInterceptorsStorage.getIsEnabled()){var Y={headers:P.headers||{},body:P.body,responseUrl:f.responseURL,responseType:f.responseType},X=Fe.responseInterceptorsStorage.execute(i.requestType,Y);P.body=X.body,P.headers=X.headers}return s($,P,P.body)}}var f=i.xhr||null;f||(i.cors||i.useXDR?f=new Fe.XDomainRequest:f=new Fe.XMLHttpRequest);var m,b,C=f.url=i.uri||i.url,w=f.method=i.method||"GET",A=i.body||i.data,v=f.headers=i.headers||{},M=!!i.sync,D=!1,R,N={body:void 0,headers:{},statusCode:0,method:w,url:C,rawRequest:f};if("json"in i&&i.json!==!1&&(D=!0,v.accept||v.Accept||(v.Accept="application/json"),w!=="GET"&&w!=="HEAD"&&(v["content-type"]||v["Content-Type"]||(v["Content-Type"]="application/json"),A=JSON.stringify(i.json===!0?A:i.json))),f.onreadystatechange=r,f.onload=c,f.onerror=l,f.onprogress=function(){},f.onabort=function(){b=!0,clearTimeout(i.retryTimeout)},f.ontimeout=l,f.open(w,C,!M,i.username,i.password),M||(f.withCredentials=!!i.withCredentials),!M&&i.timeout>0&&(R=setTimeout(function(){if(!b){b=!0,f.abort("timeout");var F=new Error("XMLHttpRequest timeout");F.code="ETIMEDOUT",l(F)}},i.timeout)),f.setRequestHeader)for(m in v)v.hasOwnProperty(m)&&f.setRequestHeader(m,v[m]);else if(i.headers&&!s_(i.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in i&&(f.responseType=i.responseType),"beforeSend"in i&&typeof i.beforeSend=="function"&&i.beforeSend(f),f.send(A||null),f}function r_(i){try{if(i.responseType==="document")return i.responseXML;var e=i.responseXML&&i.responseXML.documentElement.nodeName==="parsererror";if(i.responseType===""&&!e)return i.responseXML}catch{}return null}function a_(){}var o_=So.exports;const Zd=ms(o_);var eh={exports:{}},pu=Xd,wo=Object.create||function(){function i(){}return function(e){if(arguments.length!==1)throw new Error("Object.create shim only accepts one parameter.");return i.prototype=e,new i}}();function Tt(i,e){this.name="ParsingError",this.code=i.code,this.message=e||i.message}Tt.prototype=wo(Error.prototype);Tt.prototype.constructor=Tt;Tt.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}};function ko(i){function e(n,s,r,a){return(n|0)*3600+(s|0)*60+(r|0)+(a|0)/1e3}var t=i.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);return t?t[3]?e(t[1],t[2],t[3].replace(":",""),t[4]):t[1]>59?e(t[1],t[2],0,t[4]):e(0,t[1],t[2],t[4]):null}function rs(){this.values=wo(null)}rs.prototype={set:function(i,e){!this.get(i)&&e!==""&&(this.values[i]=e)},get:function(i,e,t){return t?this.has(i)?this.values[i]:e[t]:this.has(i)?this.values[i]:e},has:function(i){return i in this.values},alt:function(i,e,t){for(var n=0;n<t.length;++n)if(e===t[n]){this.set(i,e);break}},integer:function(i,e){/^-?\d+$/.test(e)&&this.set(i,parseInt(e,10))},percent:function(i,e){return e.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(e=parseFloat(e),e>=0&&e<=100)?(this.set(i,e),!0):!1}};function ts(i,e,t,n){var s=n?i.split(n):[i];for(var r in s)if(typeof s[r]=="string"){var a=s[r].split(t);if(a.length===2){var l=a[0].trim(),c=a[1].trim();e(l,c)}}}function l_(i,e,t){var n=i;function s(){var l=ko(i);if(l===null)throw new Tt(Tt.Errors.BadTimeStamp,"Malformed timestamp: "+n);return i=i.replace(/^[^\sa-zA-Z-]+/,""),l}function r(l,c){var f=new rs;ts(l,function(m,b){switch(m){case"region":for(var C=t.length-1;C>=0;C--)if(t[C].id===b){f.set(m,t[C].region);break}break;case"vertical":f.alt(m,b,["rl","lr"]);break;case"line":var w=b.split(","),A=w[0];f.integer(m,A),f.percent(m,A)&&f.set("snapToLines",!1),f.alt(m,A,["auto"]),w.length===2&&f.alt("lineAlign",w[1],["start","center","end"]);break;case"position":w=b.split(","),f.percent(m,w[0]),w.length===2&&f.alt("positionAlign",w[1],["start","center","end"]);break;case"size":f.percent(m,b);break;case"align":f.alt(m,b,["start","center","end","left","right"]);break}},/:/,/\s/),c.region=f.get("region",null),c.vertical=f.get("vertical","");try{c.line=f.get("line","auto")}catch{}c.lineAlign=f.get("lineAlign","start"),c.snapToLines=f.get("snapToLines",!0),c.size=f.get("size",100);try{c.align=f.get("align","center")}catch{c.align=f.get("align","middle")}try{c.position=f.get("position","auto")}catch{c.position=f.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},c.align)}c.positionAlign=f.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},c.align)}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),i.substr(0,3)!=="-->")throw new Tt(Tt.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '-->'): "+n);i=i.substr(3),a(),e.endTime=s(),a(),r(i,e)}var wa=pu.createElement&&pu.createElement("textarea"),u_={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},gu={white:"rgba(255,255,255,1)",lime:"rgba(0,255,0,1)",cyan:"rgba(0,255,255,1)",red:"rgba(255,0,0,1)",yellow:"rgba(255,255,0,1)",magenta:"rgba(255,0,255,1)",blue:"rgba(0,0,255,1)",black:"rgba(0,0,0,1)"},d_={v:"title",lang:"lang"},fu={rt:"ruby"};function th(i,e){function t(){if(!e)return null;function A(M){return e=e.substr(M.length),M}var v=e.match(/^([^<]*)(<[^>]*>?)?/);return A(v[1]?v[1]:v[2])}function n(A){return wa.innerHTML=A,A=wa.textContent,wa.textContent="",A}function s(A,v){return!fu[v.localName]||fu[v.localName]===A.localName}function r(A,v){var M=u_[A];if(!M)return null;var D=i.document.createElement(M),R=d_[A];return R&&v&&(D[R]=v.trim()),D}for(var a=i.document.createElement("div"),l=a,c,f=[];(c=t())!==null;){if(c[0]==="<"){if(c[1]==="/"){f.length&&f[f.length-1]===c.substr(2).replace(">","")&&(f.pop(),l=l.parentNode);continue}var m=ko(c.substr(1,c.length-2)),b;if(m){b=i.document.createProcessingInstruction("timestamp",m),l.appendChild(b);continue}var C=c.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!C||(b=r(C[1],C[3]),!b)||!s(l,b))continue;if(C[2]){var w=C[2].split(".");w.forEach(function(A){var v=/^bg_/.test(A),M=v?A.slice(3):A;if(gu.hasOwnProperty(M)){var D=v?"background-color":"color",R=gu[M];b.style[D]=R}}),b.className=w.join(" ")}f.push(C[1]),l.appendChild(b),l=b;continue}l.appendChild(i.document.createTextNode(n(c)))}return a}var mu=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function h_(i){for(var e=0;e<mu.length;e++){var t=mu[e];if(i>=t[0]&&i<=t[1])return!0}return!1}function c_(i){var e=[],t="",n;if(!i||!i.childNodes)return"ltr";function s(l,c){for(var f=c.childNodes.length-1;f>=0;f--)l.push(c.childNodes[f])}function r(l){if(!l||!l.length)return null;var c=l.pop(),f=c.textContent||c.innerText;if(f){var m=f.match(/^.*(\n|\r)/);return m?(l.length=0,m[0]):f}if(c.tagName==="ruby")return r(l);if(c.childNodes)return s(l,c),r(l)}for(s(e,i);t=r(e);)for(var a=0;a<t.length;a++)if(n=t.charCodeAt(a),h_(n))return"rtl";return"ltr"}function p_(i){if(typeof i.line=="number"&&(i.snapToLines||i.line>=0&&i.line<=100))return i.line;if(!i.track||!i.track.textTrackList||!i.track.textTrackList.mediaElement)return-1;for(var e=i.track,t=e.textTrackList,n=0,s=0;s<t.length&&t[s]!==e;s++)t[s].mode==="showing"&&n++;return++n*-1}function Or(){}Or.prototype.applyStyles=function(i,e){e=e||this.div;for(var t in i)i.hasOwnProperty(t)&&(e.style[t]=i[t])};Or.prototype.formatStyle=function(i,e){return i===0?0:i+e};function lr(i,e,t){Or.call(this),this.cue=e,this.cueDiv=th(i,e.text);var n={color:"rgba(255, 255, 255, 1)",backgroundColor:"rgba(0, 0, 0, 0.8)",position:"relative",left:0,right:0,top:0,bottom:0,display:"inline",writingMode:e.vertical===""?"horizontal-tb":e.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(n,this.cueDiv),this.div=i.document.createElement("div"),n={direction:c_(this.cueDiv),writingMode:e.vertical===""?"horizontal-tb":e.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:e.align==="middle"?"center":e.align,font:t.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(n),this.div.appendChild(this.cueDiv);var s=0;switch(e.positionAlign){case"start":case"line-left":s=e.position;break;case"center":s=e.position-e.size/2;break;case"end":case"line-right":s=e.position-e.size;break}e.vertical===""?this.applyStyles({left:this.formatStyle(s,"%"),width:this.formatStyle(e.size,"%")}):this.applyStyles({top:this.formatStyle(s,"%"),height:this.formatStyle(e.size,"%")}),this.move=function(r){this.applyStyles({top:this.formatStyle(r.top,"px"),bottom:this.formatStyle(r.bottom,"px"),left:this.formatStyle(r.left,"px"),right:this.formatStyle(r.right,"px"),height:this.formatStyle(r.height,"px"),width:this.formatStyle(r.width,"px")})}}lr.prototype=wo(Or.prototype);lr.prototype.constructor=lr;function ot(i){var e,t,n,s;if(i.div){t=i.div.offsetHeight,n=i.div.offsetWidth,s=i.div.offsetTop;var r=(r=i.div.childNodes)&&(r=r[0])&&r.getClientRects&&r.getClientRects();i=i.div.getBoundingClientRect(),e=r?Math.max(r[0]&&r[0].height||0,i.height/r.length):0}this.left=i.left,this.right=i.right,this.top=i.top||s,this.height=i.height||t,this.bottom=i.bottom||s+(i.height||t),this.width=i.width||n,this.lineHeight=e!==void 0?e:i.lineHeight}ot.prototype.move=function(i,e){switch(e=e!==void 0?e:this.lineHeight,i){case"+x":this.left+=e,this.right+=e;break;case"-x":this.left-=e,this.right-=e;break;case"+y":this.top+=e,this.bottom+=e;break;case"-y":this.top-=e,this.bottom-=e;break}};ot.prototype.overlaps=function(i){return this.left<i.right&&this.right>i.left&&this.top<i.bottom&&this.bottom>i.top};ot.prototype.overlapsAny=function(i){for(var e=0;e<i.length;e++)if(this.overlaps(i[e]))return!0;return!1};ot.prototype.within=function(i){return this.top>=i.top&&this.bottom<=i.bottom&&this.left>=i.left&&this.right<=i.right};ot.prototype.overlapsOppositeAxis=function(i,e){switch(e){case"+x":return this.left<i.left;case"-x":return this.right>i.right;case"+y":return this.top<i.top;case"-y":return this.bottom>i.bottom}};ot.prototype.intersectPercentage=function(i){var e=Math.max(0,Math.min(this.right,i.right)-Math.max(this.left,i.left)),t=Math.max(0,Math.min(this.bottom,i.bottom)-Math.max(this.top,i.top)),n=e*t;return n/(this.height*this.width)};ot.prototype.toCSSCompatValues=function(i){return{top:this.top-i.top,bottom:i.bottom-this.bottom,left:this.left-i.left,right:i.right-this.right,height:this.height,width:this.width}};ot.getSimpleBoxPosition=function(i){var e=i.div?i.div.offsetHeight:i.tagName?i.offsetHeight:0,t=i.div?i.div.offsetWidth:i.tagName?i.offsetWidth:0,n=i.div?i.div.offsetTop:i.tagName?i.offsetTop:0;i=i.div?i.div.getBoundingClientRect():i.tagName?i.getBoundingClientRect():i;var s={left:i.left,right:i.right,top:i.top||n,height:i.height||e,bottom:i.bottom||n+(i.height||e),width:i.width||t};return s};function g_(i,e,t,n){function s(M,D){for(var R,N=new ot(M),F=1,P=0;P<D.length;P++){for(;M.overlapsOppositeAxis(t,D[P])||M.within(t)&&M.overlapsAny(n);)M.move(D[P]);if(M.within(t))return M;var $=M.intersectPercentage(t);F>$&&(R=new ot(M),F=$),M=new ot(N)}return R||N}var r=new ot(e),a=e.cue,l=p_(a),c=[];if(a.snapToLines){var f;switch(a.vertical){case"":c=["+y","-y"],f="height";break;case"rl":c=["+x","-x"],f="width";break;case"lr":c=["-x","+x"],f="width";break}var m=r.lineHeight,b=m*Math.round(l),C=t[f]+m,w=c[0];Math.abs(b)>C&&(b=b<0?-1:1,b*=Math.ceil(C/m)*m),l<0&&(b+=a.vertical===""?t.height:t.width,c=c.reverse()),r.move(w,b)}else{var A=r.lineHeight/t.height*100;switch(a.lineAlign){case"center":l-=A/2;break;case"end":l-=A;break}switch(a.vertical){case"":e.applyStyles({top:e.formatStyle(l,"%")});break;case"rl":e.applyStyles({left:e.formatStyle(l,"%")});break;case"lr":e.applyStyles({right:e.formatStyle(l,"%")});break}c=["+y","-x","+x","-y"],r=new ot(e)}var v=s(r,c);e.move(v.toCSSCompatValues(t))}function Sn(){}Sn.StringDecoder=function(){return{decode:function(i){if(!i)return"";if(typeof i!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(i))}}};Sn.convertCueToDOMTree=function(i,e){return!i||!e?null:th(i,e)};var f_=.05,m_="sans-serif",y_="1.5%";Sn.processCues=function(i,e,t){if(!i||!e||!t)return null;for(;t.firstChild;)t.removeChild(t.firstChild);var n=i.document.createElement("div");n.style.position="absolute",n.style.left="0",n.style.right="0",n.style.top="0",n.style.bottom="0",n.style.margin=y_,t.appendChild(n);function s(m){for(var b=0;b<m.length;b++)if(m[b].hasBeenReset||!m[b].displayState)return!0;return!1}if(!s(e)){for(var r=0;r<e.length;r++)n.appendChild(e[r].displayState);return}var a=[],l=ot.getSimpleBoxPosition(n),c=Math.round(l.height*f_*100)/100,f={font:c+"px "+m_};(function(){for(var m,b,C=0;C<e.length;C++)b=e[C],m=new lr(i,b,f),n.appendChild(m.div),g_(i,m,l,a),b.displayState=m.div,a.push(ot.getSimpleBoxPosition(m))})()};Sn.Parser=function(i,e,t){t||(t=e,e={}),e||(e={}),this.window=i,this.vttjs=e,this.state="INITIAL",this.buffer="",this.decoder=t||new TextDecoder("utf8"),this.regionList=[]};Sn.Parser.prototype={reportOrThrowError:function(i){if(i instanceof Tt)this.onparsingerror&&this.onparsingerror(i);else throw i},parse:function(i){var e=this;i&&(e.buffer+=e.decoder.decode(i,{stream:!0}));function t(){for(var m=e.buffer,b=0;b<m.length&&m[b]!=="\r"&&m[b]!==`
|
|
10
10
|
`;)++b;var C=m.substr(0,b);return m[b]==="\r"&&++b,m[b]===`
|
|
11
|
-
`&&++b,e.buffer=m.substr(b),C}function n(m){var b=new
|
|
11
|
+
`&&++b,e.buffer=m.substr(b),C}function n(m){var b=new rs;if(ts(m,function(w,A){switch(w){case"id":b.set(w,A);break;case"width":b.percent(w,A);break;case"lines":b.integer(w,A);break;case"regionanchor":case"viewportanchor":var v=A.split(",");if(v.length!==2)break;var M=new rs;if(M.percent("x",v[0]),M.percent("y",v[1]),!M.has("x")||!M.has("y"))break;b.set(w+"X",M.get("x")),b.set(w+"Y",M.get("y"));break;case"scroll":b.alt(w,A,["up"]);break}},/=/,/\s/),b.has("id")){var C=new(e.vttjs.VTTRegion||e.window.VTTRegion);C.width=b.get("width",100),C.lines=b.get("lines",3),C.regionAnchorX=b.get("regionanchorX",0),C.regionAnchorY=b.get("regionanchorY",100),C.viewportAnchorX=b.get("viewportanchorX",0),C.viewportAnchorY=b.get("viewportanchorY",100),C.scroll=b.get("scroll",""),e.onregion&&e.onregion(C),e.regionList.push({id:b.get("id"),region:C})}}function s(m){var b=new rs;ts(m,function(C,w){switch(C){case"MPEGT":b.integer(C+"S",w);break;case"LOCA":b.set(C+"L",ko(w));break}},/[^\d]:/,/,/),e.ontimestampmap&&e.ontimestampmap({MPEGTS:b.get("MPEGTS"),LOCAL:b.get("LOCAL")})}function r(m){m.match(/X-TIMESTAMP-MAP/)?ts(m,function(b,C){switch(b){case"X-TIMESTAMP-MAP":s(C);break}},/=/):ts(m,function(b,C){switch(b){case"Region":n(C);break}},/:/)}try{var a;if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;a=t();var l=a.match(/^WEBVTT([ \t].*)?$/);if(!l||!l[0])throw new Tt(Tt.Errors.BadSignature);e.state="HEADER"}for(var c=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(c?c=!1:a=t(),e.state){case"HEADER":/:/.test(a)?r(a):a||(e.state="ID");continue;case"NOTE":a||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){e.state="NOTE";break}if(!a)continue;e.cue=new(e.vttjs.VTTCue||e.window.VTTCue)(0,0,"");try{e.cue.align="center"}catch{e.cue.align="middle"}if(e.state="CUE",a.indexOf("-->")===-1){e.cue.id=a;continue}case"CUE":try{l_(a,e.cue,e.regionList)}catch(m){e.reportOrThrowError(m),e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":var f=a.indexOf("-->")!==-1;if(!a||f&&(c=!0)){e.oncue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}e.cue.text&&(e.cue.text+=`
|
|
12
12
|
`),e.cue.text+=a.replace(/\u2028/g,`
|
|
13
13
|
`).replace(/u2029/g,`
|
|
14
14
|
`);continue;case"BADCUE":a||(e.state="ID");continue}}}catch(m){e.reportOrThrowError(m),e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},flush:function(){var i=this;try{if(i.buffer+=i.decoder.decode(),(i.cue||i.state==="HEADER")&&(i.buffer+=`
|
|
15
15
|
|
|
16
|
-
`,i.parse()),i.state==="INITIAL")throw new Tt(Tt.Errors.BadSignature)}catch(e){i.reportOrThrowError(e)}return i.onflush&&i.onflush(),this}};var
|
|
16
|
+
`,i.parse()),i.state==="INITIAL")throw new Tt(Tt.Errors.BadSignature)}catch(e){i.reportOrThrowError(e)}return i.onflush&&i.onflush(),this}};var __=Sn,b_="auto",T_={"":1,lr:1,rl:1},v_={start:1,center:1,end:1,left:1,right:1,auto:1,"line-left":1,"line-right":1};function S_(i){if(typeof i!="string")return!1;var e=T_[i.toLowerCase()];return e?i.toLowerCase():!1}function ka(i){if(typeof i!="string")return!1;var e=v_[i.toLowerCase()];return e?i.toLowerCase():!1}function ih(i,e,t){this.hasBeenReset=!1;var n="",s=!1,r=i,a=e,l=t,c=null,f="",m=!0,b="auto",C="start",w="auto",A="auto",v=100,M="center";Object.defineProperties(this,{id:{enumerable:!0,get:function(){return n},set:function(D){n=""+D}},pauseOnExit:{enumerable:!0,get:function(){return s},set:function(D){s=!!D}},startTime:{enumerable:!0,get:function(){return r},set:function(D){if(typeof D!="number")throw new TypeError("Start time must be set to a number.");r=D,this.hasBeenReset=!0}},endTime:{enumerable:!0,get:function(){return a},set:function(D){if(typeof D!="number")throw new TypeError("End time must be set to a number.");a=D,this.hasBeenReset=!0}},text:{enumerable:!0,get:function(){return l},set:function(D){l=""+D,this.hasBeenReset=!0}},region:{enumerable:!0,get:function(){return c},set:function(D){c=D,this.hasBeenReset=!0}},vertical:{enumerable:!0,get:function(){return f},set:function(D){var R=S_(D);if(R===!1)throw new SyntaxError("Vertical: an invalid or illegal direction string was specified.");f=R,this.hasBeenReset=!0}},snapToLines:{enumerable:!0,get:function(){return m},set:function(D){m=!!D,this.hasBeenReset=!0}},line:{enumerable:!0,get:function(){return b},set:function(D){if(typeof D!="number"&&D!==b_)throw new SyntaxError("Line: an invalid number or illegal string was specified.");b=D,this.hasBeenReset=!0}},lineAlign:{enumerable:!0,get:function(){return C},set:function(D){var R=ka(D);R?(C=R,this.hasBeenReset=!0):console.warn("lineAlign: an invalid or illegal string was specified.")}},position:{enumerable:!0,get:function(){return w},set:function(D){if(D<0||D>100)throw new Error("Position must be between 0 and 100.");w=D,this.hasBeenReset=!0}},positionAlign:{enumerable:!0,get:function(){return A},set:function(D){var R=ka(D);R?(A=R,this.hasBeenReset=!0):console.warn("positionAlign: an invalid or illegal string was specified.")}},size:{enumerable:!0,get:function(){return v},set:function(D){if(D<0||D>100)throw new Error("Size must be between 0 and 100.");v=D,this.hasBeenReset=!0}},align:{enumerable:!0,get:function(){return M},set:function(D){var R=ka(D);if(!R)throw new SyntaxError("align: an invalid or illegal alignment string was specified.");M=R,this.hasBeenReset=!0}}}),this.displayState=void 0}ih.prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)};var E_=ih,w_={"":!0,up:!0};function k_(i){if(typeof i!="string")return!1;var e=w_[i.toLowerCase()];return e?i.toLowerCase():!1}function Kn(i){return typeof i=="number"&&i>=0&&i<=100}function C_(){var i=100,e=3,t=0,n=100,s=0,r=100,a="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return i},set:function(l){if(!Kn(l))throw new Error("Width must be between 0 and 100.");i=l}},lines:{enumerable:!0,get:function(){return e},set:function(l){if(typeof l!="number")throw new TypeError("Lines must be set to a number.");e=l}},regionAnchorY:{enumerable:!0,get:function(){return n},set:function(l){if(!Kn(l))throw new Error("RegionAnchorX must be between 0 and 100.");n=l}},regionAnchorX:{enumerable:!0,get:function(){return t},set:function(l){if(!Kn(l))throw new Error("RegionAnchorY must be between 0 and 100.");t=l}},viewportAnchorY:{enumerable:!0,get:function(){return r},set:function(l){if(!Kn(l))throw new Error("ViewportAnchorY must be between 0 and 100.");r=l}},viewportAnchorX:{enumerable:!0,get:function(){return s},set:function(l){if(!Kn(l))throw new Error("ViewportAnchorX must be between 0 and 100.");s=l}},scroll:{enumerable:!0,get:function(){return a},set:function(l){var c=k_(l);c===!1?console.warn("Scroll: an invalid or illegal string was specified."):a=c}}})}var I_=C_,ri=Dr,Vi=eh.exports={WebVTT:__,VTTCue:E_,VTTRegion:I_};ri.vttjs=Vi;ri.WebVTT=Vi.WebVTT;var x_=Vi.VTTCue,A_=Vi.VTTRegion,P_=ri.VTTCue,L_=ri.VTTRegion;Vi.shim=function(){ri.VTTCue=x_,ri.VTTRegion=A_};Vi.restore=function(){ri.VTTCue=P_,ri.VTTRegion=L_};ri.VTTCue||Vi.shim();var D_=eh.exports;const yu=ms(D_);function je(){return je=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},je.apply(null,arguments)}var _u="https://example.com",Mr=function(i,e){if(/^[a-z]+:/i.test(e))return e;/^data:/.test(i)&&(i=x.location&&x.location.href||"");var t=/^\/\//.test(i),n=!x.location&&!/\/\//i.test(i);i=new x.URL(i,x.location||_u);var s=new URL(e,i);return n?s.href.slice(_u.length):t?s.href.slice(s.protocol.length):s.href},Co=function(){function i(){this.listeners={}}var e=i.prototype;return e.on=function(t,n){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(n)},e.off=function(t,n){if(!this.listeners[t])return!1;var s=this.listeners[t].indexOf(n);return this.listeners[t]=this.listeners[t].slice(0),this.listeners[t].splice(s,1),s>-1},e.trigger=function(t){var n=this.listeners[t];if(n)if(arguments.length===2)for(var s=n.length,r=0;r<s;++r)n[r].call(this,arguments[1]);else for(var a=Array.prototype.slice.call(arguments,1),l=n.length,c=0;c<l;++c)n[c].apply(this,a)},e.dispose=function(){this.listeners={}},e.pipe=function(t){this.on("data",function(n){t.push(n)})},i}(),nh={},Rr={};Rr.byteLength=R_;Rr.toByteArray=N_;Rr.fromByteArray=j_;var Wt=[],It=[],O_=typeof Uint8Array<"u"?Uint8Array:Array,Ca="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Yi=0,M_=Ca.length;Yi<M_;++Yi)Wt[Yi]=Ca[Yi],It[Ca.charCodeAt(Yi)]=Yi;It[45]=62;It[95]=63;function sh(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function R_(i){var e=sh(i),t=e[0],n=e[1];return(t+n)*3/4-n}function U_(i,e,t){return(e+t)*3/4-t}function N_(i){var e,t=sh(i),n=t[0],s=t[1],r=new O_(U_(i,n,s)),a=0,l=s>0?n-4:n,c;for(c=0;c<l;c+=4)e=It[i.charCodeAt(c)]<<18|It[i.charCodeAt(c+1)]<<12|It[i.charCodeAt(c+2)]<<6|It[i.charCodeAt(c+3)],r[a++]=e>>16&255,r[a++]=e>>8&255,r[a++]=e&255;return s===2&&(e=It[i.charCodeAt(c)]<<2|It[i.charCodeAt(c+1)]>>4,r[a++]=e&255),s===1&&(e=It[i.charCodeAt(c)]<<10|It[i.charCodeAt(c+1)]<<4|It[i.charCodeAt(c+2)]>>2,r[a++]=e>>8&255,r[a++]=e&255),r}function B_(i){return Wt[i>>18&63]+Wt[i>>12&63]+Wt[i>>6&63]+Wt[i&63]}function F_(i,e,t){for(var n,s=[],r=e;r<t;r+=3)n=(i[r]<<16&16711680)+(i[r+1]<<8&65280)+(i[r+2]&255),s.push(B_(n));return s.join("")}function j_(i){for(var e,t=i.length,n=t%3,s=[],r=16383,a=0,l=t-n;a<l;a+=r)s.push(F_(i,a,a+r>l?l:a+r));return n===1?(e=i[t-1],s.push(Wt[e>>2]+Wt[e<<4&63]+"==")):n===2&&(e=(i[t-2]<<8)+i[t-1],s.push(Wt[e>>10]+Wt[e>>4&63]+Wt[e<<2&63]+"=")),s.join("")}var Io={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Io.read=function(i,e,t,n,s){var r,a,l=s*8-n-1,c=(1<<l)-1,f=c>>1,m=-7,b=t?s-1:0,C=t?-1:1,w=i[e+b];for(b+=C,r=w&(1<<-m)-1,w>>=-m,m+=l;m>0;r=r*256+i[e+b],b+=C,m-=8);for(a=r&(1<<-m)-1,r>>=-m,m+=n;m>0;a=a*256+i[e+b],b+=C,m-=8);if(r===0)r=1-f;else{if(r===c)return a?NaN:(w?-1:1)*(1/0);a=a+Math.pow(2,n),r=r-f}return(w?-1:1)*a*Math.pow(2,r-n)};Io.write=function(i,e,t,n,s,r){var a,l,c,f=r*8-s-1,m=(1<<f)-1,b=m>>1,C=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:r-1,A=n?1:-1,v=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(l=isNaN(e)?1:0,a=m):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),a+b>=1?e+=C/c:e+=C*Math.pow(2,1-b),e*c>=2&&(a++,c/=2),a+b>=m?(l=0,a=m):a+b>=1?(l=(e*c-1)*Math.pow(2,s),a=a+b):(l=e*Math.pow(2,b-1)*Math.pow(2,s),a=0));s>=8;i[t+w]=l&255,w+=A,l/=256,s-=8);for(a=a<<s|l,f+=s;f>0;i[t+w]=a&255,w+=A,a/=256,f-=8);i[t+w-A]|=v*128};/*!
|
|
17
17
|
* The buffer module from node.js, for the browser.
|
|
18
18
|
*
|
|
19
19
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
20
20
|
* @license MIT
|
|
21
|
-
*/(function(i){const e=Rr,t=xo,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=m,i.SlowBuffer=P,i.INSPECT_MAX_BYTES=50;const s=2147483647;i.kMaxLength=s;const{Uint8Array:r,ArrayBuffer:a,SharedArrayBuffer:l}=globalThis;m.TYPED_ARRAY_SUPPORT=c(),!m.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{const p=new r(1),_={foo:function(){return 42}};return Object.setPrototypeOf(_,r.prototype),Object.setPrototypeOf(p,_),p.foo()===42}catch{return!1}}Object.defineProperty(m.prototype,"parent",{enumerable:!0,get:function(){if(m.isBuffer(this))return this.buffer}}),Object.defineProperty(m.prototype,"offset",{enumerable:!0,get:function(){if(m.isBuffer(this))return this.byteOffset}});function g(p){if(p>s)throw new RangeError('The value "'+p+'" is invalid for option "size"');const _=new r(p);return Object.setPrototypeOf(_,m.prototype),_}function m(p,_,T){if(typeof p=="number"){if(typeof _=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return A(p)}return b(p,_,T)}m.poolSize=8192;function b(p,_,T){if(typeof p=="string")return v(p,_);if(a.isView(p))return D(p);if(p==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof p);if(ut(p,a)||p&&ut(p.buffer,a)||typeof l<"u"&&(ut(p,l)||p&&ut(p.buffer,l)))return R(p,_,T);if(typeof p=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const L=p.valueOf&&p.valueOf();if(L!=null&&L!==p)return m.from(L,_,T);const U=N(p);if(U)return U;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof p[Symbol.toPrimitive]=="function")return m.from(p[Symbol.toPrimitive]("string"),_,T);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof p)}m.from=function(p,_,T){return b(p,_,T)},Object.setPrototypeOf(m.prototype,r.prototype),Object.setPrototypeOf(m,r);function C(p){if(typeof p!="number")throw new TypeError('"size" argument must be of type number');if(p<0)throw new RangeError('The value "'+p+'" is invalid for option "size"')}function w(p,_,T){return C(p),p<=0?g(p):_!==void 0?typeof T=="string"?g(p).fill(_,T):g(p).fill(_):g(p)}m.alloc=function(p,_,T){return w(p,_,T)};function A(p){return C(p),g(p<0?0:F(p)|0)}m.allocUnsafe=function(p){return A(p)},m.allocUnsafeSlow=function(p){return A(p)};function v(p,_){if((typeof _!="string"||_==="")&&(_="utf8"),!m.isEncoding(_))throw new TypeError("Unknown encoding: "+_);const T=$(p,_)|0;let L=g(T);const U=L.write(p,_);return U!==T&&(L=L.slice(0,U)),L}function M(p){const _=p.length<0?0:F(p.length)|0,T=g(_);for(let L=0;L<_;L+=1)T[L]=p[L]&255;return T}function D(p){if(ut(p,r)){const _=new r(p);return R(_.buffer,_.byteOffset,_.byteLength)}return M(p)}function R(p,_,T){if(_<0||p.byteLength<_)throw new RangeError('"offset" is outside of buffer bounds');if(p.byteLength<_+(T||0))throw new RangeError('"length" is outside of buffer bounds');let L;return _===void 0&&T===void 0?L=new r(p):T===void 0?L=new r(p,_):L=new r(p,_,T),Object.setPrototypeOf(L,m.prototype),L}function N(p){if(m.isBuffer(p)){const _=F(p.length)|0,T=g(_);return T.length===0||p.copy(T,0,0,_),T}if(p.length!==void 0)return typeof p.length!="number"||Ci(p.length)?g(0):M(p);if(p.type==="Buffer"&&Array.isArray(p.data))return M(p.data)}function F(p){if(p>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return p|0}function P(p){return+p!=p&&(p=0),m.alloc(+p)}m.isBuffer=function(p){return p!=null&&p._isBuffer===!0&&p!==m.prototype},m.compare=function(p,_){if(ut(p,r)&&(p=m.from(p,p.offset,p.byteLength)),ut(_,r)&&(_=m.from(_,_.offset,_.byteLength)),!m.isBuffer(p)||!m.isBuffer(_))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(p===_)return 0;let T=p.length,L=_.length;for(let U=0,q=Math.min(T,L);U<q;++U)if(p[U]!==_[U]){T=p[U],L=_[U];break}return T<L?-1:L<T?1:0},m.isEncoding=function(p){switch(String(p).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},m.concat=function(p,_){if(!Array.isArray(p))throw new TypeError('"list" argument must be an Array of Buffers');if(p.length===0)return m.alloc(0);let T;if(_===void 0)for(_=0,T=0;T<p.length;++T)_+=p[T].length;const L=m.allocUnsafe(_);let U=0;for(T=0;T<p.length;++T){let q=p[T];if(ut(q,r))U+q.length>L.length?(m.isBuffer(q)||(q=m.from(q)),q.copy(L,U)):r.prototype.set.call(L,q,U);else if(m.isBuffer(q))q.copy(L,U);else throw new TypeError('"list" argument must be an Array of Buffers');U+=q.length}return L};function $(p,_){if(m.isBuffer(p))return p.length;if(a.isView(p)||ut(p,a))return p.byteLength;if(typeof p!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof p);const T=p.length,L=arguments.length>2&&arguments[2]===!0;if(!L&&T===0)return 0;let U=!1;for(;;)switch(_){case"ascii":case"latin1":case"binary":return T;case"utf8":case"utf-8":return pe(p).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T*2;case"hex":return T>>>1;case"base64":return Ss(p).length;default:if(U)return L?-1:pe(p).length;_=(""+_).toLowerCase(),U=!0}}m.byteLength=$;function Y(p,_,T){let L=!1;if((_===void 0||_<0)&&(_=0),_>this.length||((T===void 0||T>this.length)&&(T=this.length),T<=0)||(T>>>=0,_>>>=0,T<=_))return"";for(p||(p="utf8");;)switch(p){case"hex":return mt(this,_,T);case"utf8":case"utf-8":return Ye(this,_,T);case"ascii":return me(this,_,T);case"latin1":case"binary":return fe(this,_,T);case"base64":return Xe(this,_,T);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,_,T);default:if(L)throw new TypeError("Unknown encoding: "+p);p=(p+"").toLowerCase(),L=!0}}m.prototype._isBuffer=!0;function X(p,_,T){const L=p[_];p[_]=p[T],p[T]=L}m.prototype.swap16=function(){const p=this.length;if(p%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let _=0;_<p;_+=2)X(this,_,_+1);return this},m.prototype.swap32=function(){const p=this.length;if(p%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let _=0;_<p;_+=4)X(this,_,_+3),X(this,_+1,_+2);return this},m.prototype.swap64=function(){const p=this.length;if(p%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let _=0;_<p;_+=8)X(this,_,_+7),X(this,_+1,_+6),X(this,_+2,_+5),X(this,_+3,_+4);return this},m.prototype.toString=function(){const p=this.length;return p===0?"":arguments.length===0?Ye(this,0,p):Y.apply(this,arguments)},m.prototype.toLocaleString=m.prototype.toString,m.prototype.equals=function(p){if(!m.isBuffer(p))throw new TypeError("Argument must be a Buffer");return this===p?!0:m.compare(this,p)===0},m.prototype.inspect=function(){let p="";const _=i.INSPECT_MAX_BYTES;return p=this.toString("hex",0,_).replace(/(.{2})/g,"$1 ").trim(),this.length>_&&(p+=" ... "),"<Buffer "+p+">"},n&&(m.prototype[n]=m.prototype.inspect),m.prototype.compare=function(p,_,T,L,U){if(ut(p,r)&&(p=m.from(p,p.offset,p.byteLength)),!m.isBuffer(p))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof p);if(_===void 0&&(_=0),T===void 0&&(T=p?p.length:0),L===void 0&&(L=0),U===void 0&&(U=this.length),_<0||T>p.length||L<0||U>this.length)throw new RangeError("out of range index");if(L>=U&&_>=T)return 0;if(L>=U)return-1;if(_>=T)return 1;if(_>>>=0,T>>>=0,L>>>=0,U>>>=0,this===p)return 0;let q=U-L,K=T-_;const Se=Math.min(q,K),Ve=this.slice(L,U),ke=p.slice(_,T);for(let Te=0;Te<Se;++Te)if(Ve[Te]!==ke[Te]){q=Ve[Te],K=ke[Te];break}return q<K?-1:K<q?1:0};function re(p,_,T,L,U){if(p.length===0)return-1;if(typeof T=="string"?(L=T,T=0):T>2147483647?T=2147483647:T<-2147483648&&(T=-2147483648),T=+T,Ci(T)&&(T=U?0:p.length-1),T<0&&(T=p.length+T),T>=p.length){if(U)return-1;T=p.length-1}else if(T<0)if(U)T=0;else return-1;if(typeof _=="string"&&(_=m.from(_,L)),m.isBuffer(_))return _.length===0?-1:ce(p,_,T,L,U);if(typeof _=="number")return _=_&255,typeof r.prototype.indexOf=="function"?U?r.prototype.indexOf.call(p,_,T):r.prototype.lastIndexOf.call(p,_,T):ce(p,[_],T,L,U);throw new TypeError("val must be string, number or Buffer")}function ce(p,_,T,L,U){let q=1,K=p.length,Se=_.length;if(L!==void 0&&(L=String(L).toLowerCase(),L==="ucs2"||L==="ucs-2"||L==="utf16le"||L==="utf-16le")){if(p.length<2||_.length<2)return-1;q=2,K/=2,Se/=2,T/=2}function Ve(Te,Ue){return q===1?Te[Ue]:Te.readUInt16BE(Ue*q)}let ke;if(U){let Te=-1;for(ke=T;ke<K;ke++)if(Ve(p,ke)===Ve(_,Te===-1?0:ke-Te)){if(Te===-1&&(Te=ke),ke-Te+1===Se)return Te*q}else Te!==-1&&(ke-=ke-Te),Te=-1}else for(T+Se>K&&(T=K-Se),ke=T;ke>=0;ke--){let Te=!0;for(let Ue=0;Ue<Se;Ue++)if(Ve(p,ke+Ue)!==Ve(_,Ue)){Te=!1;break}if(Te)return ke}return-1}m.prototype.includes=function(p,_,T){return this.indexOf(p,_,T)!==-1},m.prototype.indexOf=function(p,_,T){return re(this,p,_,T,!0)},m.prototype.lastIndexOf=function(p,_,T){return re(this,p,_,T,!1)};function be(p,_,T,L){T=Number(T)||0;const U=p.length-T;L?(L=Number(L),L>U&&(L=U)):L=U;const q=_.length;L>q/2&&(L=q/2);let K;for(K=0;K<L;++K){const Se=parseInt(_.substr(K*2,2),16);if(Ci(Se))return K;p[T+K]=Se}return K}function he(p,_,T,L){return di(pe(_,p.length-T),p,T,L)}function Z(p,_,T,L){return di(ia(_),p,T,L)}function de(p,_,T,L){return di(Ss(_),p,T,L)}function ee(p,_,T,L){return di(Ln(_,p.length-T),p,T,L)}m.prototype.write=function(p,_,T,L){if(_===void 0)L="utf8",T=this.length,_=0;else if(T===void 0&&typeof _=="string")L=_,T=this.length,_=0;else if(isFinite(_))_=_>>>0,isFinite(T)?(T=T>>>0,L===void 0&&(L="utf8")):(L=T,T=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const U=this.length-_;if((T===void 0||T>U)&&(T=U),p.length>0&&(T<0||_<0)||_>this.length)throw new RangeError("Attempt to write outside buffer bounds");L||(L="utf8");let q=!1;for(;;)switch(L){case"hex":return be(this,p,_,T);case"utf8":case"utf-8":return he(this,p,_,T);case"ascii":case"latin1":case"binary":return Z(this,p,_,T);case"base64":return de(this,p,_,T);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ee(this,p,_,T);default:if(q)throw new TypeError("Unknown encoding: "+L);L=(""+L).toLowerCase(),q=!0}},m.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Xe(p,_,T){return _===0&&T===p.length?e.fromByteArray(p):e.fromByteArray(p.slice(_,T))}function Ye(p,_,T){T=Math.min(p.length,T);const L=[];let U=_;for(;U<T;){const q=p[U];let K=null,Se=q>239?4:q>223?3:q>191?2:1;if(U+Se<=T){let Ve,ke,Te,Ue;switch(Se){case 1:q<128&&(K=q);break;case 2:Ve=p[U+1],(Ve&192)===128&&(Ue=(q&31)<<6|Ve&63,Ue>127&&(K=Ue));break;case 3:Ve=p[U+1],ke=p[U+2],(Ve&192)===128&&(ke&192)===128&&(Ue=(q&15)<<12|(Ve&63)<<6|ke&63,Ue>2047&&(Ue<55296||Ue>57343)&&(K=Ue));break;case 4:Ve=p[U+1],ke=p[U+2],Te=p[U+3],(Ve&192)===128&&(ke&192)===128&&(Te&192)===128&&(Ue=(q&15)<<18|(Ve&63)<<12|(ke&63)<<6|Te&63,Ue>65535&&Ue<1114112&&(K=Ue))}}K===null?(K=65533,Se=1):K>65535&&(K-=65536,L.push(K>>>10&1023|55296),K=56320|K&1023),L.push(K),U+=Se}return He(L)}const $e=4096;function He(p){const _=p.length;if(_<=$e)return String.fromCharCode.apply(String,p);let T="",L=0;for(;L<_;)T+=String.fromCharCode.apply(String,p.slice(L,L+=$e));return T}function me(p,_,T){let L="";T=Math.min(p.length,T);for(let U=_;U<T;++U)L+=String.fromCharCode(p[U]&127);return L}function fe(p,_,T){let L="";T=Math.min(p.length,T);for(let U=_;U<T;++U)L+=String.fromCharCode(p[U]);return L}function mt(p,_,T){const L=p.length;(!_||_<0)&&(_=0),(!T||T<0||T>L)&&(T=L);let U="";for(let q=_;q<T;++q)U+=zi[p[q]];return U}function Et(p,_,T){const L=p.slice(_,T);let U="";for(let q=0;q<L.length-1;q+=2)U+=String.fromCharCode(L[q]+L[q+1]*256);return U}m.prototype.slice=function(p,_){const T=this.length;p=~~p,_=_===void 0?T:~~_,p<0?(p+=T,p<0&&(p=0)):p>T&&(p=T),_<0?(_+=T,_<0&&(_=0)):_>T&&(_=T),_<p&&(_=p);const L=this.subarray(p,_);return Object.setPrototypeOf(L,m.prototype),L};function we(p,_,T){if(p%1!==0||p<0)throw new RangeError("offset is not uint");if(p+_>T)throw new RangeError("Trying to access beyond buffer length")}m.prototype.readUintLE=m.prototype.readUIntLE=function(p,_,T){p=p>>>0,_=_>>>0,T||we(p,_,this.length);let L=this[p],U=1,q=0;for(;++q<_&&(U*=256);)L+=this[p+q]*U;return L},m.prototype.readUintBE=m.prototype.readUIntBE=function(p,_,T){p=p>>>0,_=_>>>0,T||we(p,_,this.length);let L=this[p+--_],U=1;for(;_>0&&(U*=256);)L+=this[p+--_]*U;return L},m.prototype.readUint8=m.prototype.readUInt8=function(p,_){return p=p>>>0,_||we(p,1,this.length),this[p]},m.prototype.readUint16LE=m.prototype.readUInt16LE=function(p,_){return p=p>>>0,_||we(p,2,this.length),this[p]|this[p+1]<<8},m.prototype.readUint16BE=m.prototype.readUInt16BE=function(p,_){return p=p>>>0,_||we(p,2,this.length),this[p]<<8|this[p+1]},m.prototype.readUint32LE=m.prototype.readUInt32LE=function(p,_){return p=p>>>0,_||we(p,4,this.length),(this[p]|this[p+1]<<8|this[p+2]<<16)+this[p+3]*16777216},m.prototype.readUint32BE=m.prototype.readUInt32BE=function(p,_){return p=p>>>0,_||we(p,4,this.length),this[p]*16777216+(this[p+1]<<16|this[p+2]<<8|this[p+3])},m.prototype.readBigUInt64LE=wt(function(p){p=p>>>0,Ot(p,"offset");const _=this[p],T=this[p+7];(_===void 0||T===void 0)&&ki(p,this.length-8);const L=_+this[++p]*2**8+this[++p]*2**16+this[++p]*2**24,U=this[++p]+this[++p]*2**8+this[++p]*2**16+T*2**24;return BigInt(L)+(BigInt(U)<<BigInt(32))}),m.prototype.readBigUInt64BE=wt(function(p){p=p>>>0,Ot(p,"offset");const _=this[p],T=this[p+7];(_===void 0||T===void 0)&&ki(p,this.length-8);const L=_*2**24+this[++p]*2**16+this[++p]*2**8+this[++p],U=this[++p]*2**24+this[++p]*2**16+this[++p]*2**8+T;return(BigInt(L)<<BigInt(32))+BigInt(U)}),m.prototype.readIntLE=function(p,_,T){p=p>>>0,_=_>>>0,T||we(p,_,this.length);let L=this[p],U=1,q=0;for(;++q<_&&(U*=256);)L+=this[p+q]*U;return U*=128,L>=U&&(L-=Math.pow(2,8*_)),L},m.prototype.readIntBE=function(p,_,T){p=p>>>0,_=_>>>0,T||we(p,_,this.length);let L=_,U=1,q=this[p+--L];for(;L>0&&(U*=256);)q+=this[p+--L]*U;return U*=128,q>=U&&(q-=Math.pow(2,8*_)),q},m.prototype.readInt8=function(p,_){return p=p>>>0,_||we(p,1,this.length),this[p]&128?(255-this[p]+1)*-1:this[p]},m.prototype.readInt16LE=function(p,_){p=p>>>0,_||we(p,2,this.length);const T=this[p]|this[p+1]<<8;return T&32768?T|4294901760:T},m.prototype.readInt16BE=function(p,_){p=p>>>0,_||we(p,2,this.length);const T=this[p+1]|this[p]<<8;return T&32768?T|4294901760:T},m.prototype.readInt32LE=function(p,_){return p=p>>>0,_||we(p,4,this.length),this[p]|this[p+1]<<8|this[p+2]<<16|this[p+3]<<24},m.prototype.readInt32BE=function(p,_){return p=p>>>0,_||we(p,4,this.length),this[p]<<24|this[p+1]<<16|this[p+2]<<8|this[p+3]},m.prototype.readBigInt64LE=wt(function(p){p=p>>>0,Ot(p,"offset");const _=this[p],T=this[p+7];(_===void 0||T===void 0)&&ki(p,this.length-8);const L=this[p+4]+this[p+5]*2**8+this[p+6]*2**16+(T<<24);return(BigInt(L)<<BigInt(32))+BigInt(_+this[++p]*2**8+this[++p]*2**16+this[++p]*2**24)}),m.prototype.readBigInt64BE=wt(function(p){p=p>>>0,Ot(p,"offset");const _=this[p],T=this[p+7];(_===void 0||T===void 0)&&ki(p,this.length-8);const L=(_<<24)+this[++p]*2**16+this[++p]*2**8+this[++p];return(BigInt(L)<<BigInt(32))+BigInt(this[++p]*2**24+this[++p]*2**16+this[++p]*2**8+T)}),m.prototype.readFloatLE=function(p,_){return p=p>>>0,_||we(p,4,this.length),t.read(this,p,!0,23,4)},m.prototype.readFloatBE=function(p,_){return p=p>>>0,_||we(p,4,this.length),t.read(this,p,!1,23,4)},m.prototype.readDoubleLE=function(p,_){return p=p>>>0,_||we(p,8,this.length),t.read(this,p,!0,52,8)},m.prototype.readDoubleBE=function(p,_){return p=p>>>0,_||we(p,8,this.length),t.read(this,p,!1,52,8)};function ue(p,_,T,L,U,q){if(!m.isBuffer(p))throw new TypeError('"buffer" argument must be a Buffer instance');if(_>U||_<q)throw new RangeError('"value" argument is out of bounds');if(T+L>p.length)throw new RangeError("Index out of range")}m.prototype.writeUintLE=m.prototype.writeUIntLE=function(p,_,T,L){if(p=+p,_=_>>>0,T=T>>>0,!L){const K=Math.pow(2,8*T)-1;ue(this,p,_,T,K,0)}let U=1,q=0;for(this[_]=p&255;++q<T&&(U*=256);)this[_+q]=p/U&255;return _+T},m.prototype.writeUintBE=m.prototype.writeUIntBE=function(p,_,T,L){if(p=+p,_=_>>>0,T=T>>>0,!L){const K=Math.pow(2,8*T)-1;ue(this,p,_,T,K,0)}let U=T-1,q=1;for(this[_+U]=p&255;--U>=0&&(q*=256);)this[_+U]=p/q&255;return _+T},m.prototype.writeUint8=m.prototype.writeUInt8=function(p,_,T){return p=+p,_=_>>>0,T||ue(this,p,_,1,255,0),this[_]=p&255,_+1},m.prototype.writeUint16LE=m.prototype.writeUInt16LE=function(p,_,T){return p=+p,_=_>>>0,T||ue(this,p,_,2,65535,0),this[_]=p&255,this[_+1]=p>>>8,_+2},m.prototype.writeUint16BE=m.prototype.writeUInt16BE=function(p,_,T){return p=+p,_=_>>>0,T||ue(this,p,_,2,65535,0),this[_]=p>>>8,this[_+1]=p&255,_+2},m.prototype.writeUint32LE=m.prototype.writeUInt32LE=function(p,_,T){return p=+p,_=_>>>0,T||ue(this,p,_,4,4294967295,0),this[_+3]=p>>>24,this[_+2]=p>>>16,this[_+1]=p>>>8,this[_]=p&255,_+4},m.prototype.writeUint32BE=m.prototype.writeUInt32BE=function(p,_,T){return p=+p,_=_>>>0,T||ue(this,p,_,4,4294967295,0),this[_]=p>>>24,this[_+1]=p>>>16,this[_+2]=p>>>8,this[_+3]=p&255,_+4};function Re(p,_,T,L,U){Dt(_,L,U,p,T,7);let q=Number(_&BigInt(4294967295));p[T++]=q,q=q>>8,p[T++]=q,q=q>>8,p[T++]=q,q=q>>8,p[T++]=q;let K=Number(_>>BigInt(32)&BigInt(4294967295));return p[T++]=K,K=K>>8,p[T++]=K,K=K>>8,p[T++]=K,K=K>>8,p[T++]=K,T}function Hi(p,_,T,L,U){Dt(_,L,U,p,T,7);let q=Number(_&BigInt(4294967295));p[T+7]=q,q=q>>8,p[T+6]=q,q=q>>8,p[T+5]=q,q=q>>8,p[T+4]=q;let K=Number(_>>BigInt(32)&BigInt(4294967295));return p[T+3]=K,K=K>>8,p[T+2]=K,K=K>>8,p[T+1]=K,K=K>>8,p[T]=K,T+8}m.prototype.writeBigUInt64LE=wt(function(p,_=0){return Re(this,p,_,BigInt(0),BigInt("0xffffffffffffffff"))}),m.prototype.writeBigUInt64BE=wt(function(p,_=0){return Hi(this,p,_,BigInt(0),BigInt("0xffffffffffffffff"))}),m.prototype.writeIntLE=function(p,_,T,L){if(p=+p,_=_>>>0,!L){const Se=Math.pow(2,8*T-1);ue(this,p,_,T,Se-1,-Se)}let U=0,q=1,K=0;for(this[_]=p&255;++U<T&&(q*=256);)p<0&&K===0&&this[_+U-1]!==0&&(K=1),this[_+U]=(p/q>>0)-K&255;return _+T},m.prototype.writeIntBE=function(p,_,T,L){if(p=+p,_=_>>>0,!L){const Se=Math.pow(2,8*T-1);ue(this,p,_,T,Se-1,-Se)}let U=T-1,q=1,K=0;for(this[_+U]=p&255;--U>=0&&(q*=256);)p<0&&K===0&&this[_+U+1]!==0&&(K=1),this[_+U]=(p/q>>0)-K&255;return _+T},m.prototype.writeInt8=function(p,_,T){return p=+p,_=_>>>0,T||ue(this,p,_,1,127,-128),p<0&&(p=255+p+1),this[_]=p&255,_+1},m.prototype.writeInt16LE=function(p,_,T){return p=+p,_=_>>>0,T||ue(this,p,_,2,32767,-32768),this[_]=p&255,this[_+1]=p>>>8,_+2},m.prototype.writeInt16BE=function(p,_,T){return p=+p,_=_>>>0,T||ue(this,p,_,2,32767,-32768),this[_]=p>>>8,this[_+1]=p&255,_+2},m.prototype.writeInt32LE=function(p,_,T){return p=+p,_=_>>>0,T||ue(this,p,_,4,2147483647,-2147483648),this[_]=p&255,this[_+1]=p>>>8,this[_+2]=p>>>16,this[_+3]=p>>>24,_+4},m.prototype.writeInt32BE=function(p,_,T){return p=+p,_=_>>>0,T||ue(this,p,_,4,2147483647,-2147483648),p<0&&(p=4294967295+p+1),this[_]=p>>>24,this[_+1]=p>>>16,this[_+2]=p>>>8,this[_+3]=p&255,_+4},m.prototype.writeBigInt64LE=wt(function(p,_=0){return Re(this,p,_,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),m.prototype.writeBigInt64BE=wt(function(p,_=0){return Hi(this,p,_,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function oi(p,_,T,L,U,q){if(T+L>p.length)throw new RangeError("Index out of range");if(T<0)throw new RangeError("Index out of range")}function li(p,_,T,L,U){return _=+_,T=T>>>0,U||oi(p,_,T,4),t.write(p,_,T,L,23,4),T+4}m.prototype.writeFloatLE=function(p,_,T){return li(this,p,_,!0,T)},m.prototype.writeFloatBE=function(p,_,T){return li(this,p,_,!1,T)};function Ei(p,_,T,L,U){return _=+_,T=T>>>0,U||oi(p,_,T,8),t.write(p,_,T,L,52,8),T+8}m.prototype.writeDoubleLE=function(p,_,T){return Ei(this,p,_,!0,T)},m.prototype.writeDoubleBE=function(p,_,T){return Ei(this,p,_,!1,T)},m.prototype.copy=function(p,_,T,L){if(!m.isBuffer(p))throw new TypeError("argument should be a Buffer");if(T||(T=0),!L&&L!==0&&(L=this.length),_>=p.length&&(_=p.length),_||(_=0),L>0&&L<T&&(L=T),L===T||p.length===0||this.length===0)return 0;if(_<0)throw new RangeError("targetStart out of bounds");if(T<0||T>=this.length)throw new RangeError("Index out of range");if(L<0)throw new RangeError("sourceEnd out of bounds");L>this.length&&(L=this.length),p.length-_<L-T&&(L=p.length-_+T);const U=L-T;return this===p&&typeof r.prototype.copyWithin=="function"?this.copyWithin(_,T,L):r.prototype.set.call(p,this.subarray(T,L),_),U},m.prototype.fill=function(p,_,T,L){if(typeof p=="string"){if(typeof _=="string"?(L=_,_=0,T=this.length):typeof T=="string"&&(L=T,T=this.length),L!==void 0&&typeof L!="string")throw new TypeError("encoding must be a string");if(typeof L=="string"&&!m.isEncoding(L))throw new TypeError("Unknown encoding: "+L);if(p.length===1){const q=p.charCodeAt(0);(L==="utf8"&&q<128||L==="latin1")&&(p=q)}}else typeof p=="number"?p=p&255:typeof p=="boolean"&&(p=Number(p));if(_<0||this.length<_||this.length<T)throw new RangeError("Out of range index");if(T<=_)return this;_=_>>>0,T=T===void 0?this.length:T>>>0,p||(p=0);let U;if(typeof p=="number")for(U=_;U<T;++U)this[U]=p;else{const q=m.isBuffer(p)?p:m.from(p,L),K=q.length;if(K===0)throw new TypeError('The value "'+p+'" is invalid for argument "value"');for(U=0;U<T-_;++U)this[U+_]=q[U%K]}return this};const yt={};function ui(p,_,T){yt[p]=class extends T{constructor(){super(),Object.defineProperty(this,"message",{value:_.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${p}]`,this.stack,delete this.name}get code(){return p}set code(L){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:L,writable:!0})}toString(){return`${this.name} [${p}]: ${this.message}`}}}ui("ERR_BUFFER_OUT_OF_BOUNDS",function(p){return p?`${p} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ui("ERR_INVALID_ARG_TYPE",function(p,_){return`The "${p}" argument must be of type number. Received type ${typeof _}`},TypeError),ui("ERR_OUT_OF_RANGE",function(p,_,T){let L=`The value of "${p}" is out of range.`,U=T;return Number.isInteger(T)&&Math.abs(T)>2**32?U=Ft(String(T)):typeof T=="bigint"&&(U=String(T),(T>BigInt(2)**BigInt(32)||T<-(BigInt(2)**BigInt(32)))&&(U=Ft(U)),U+="n"),L+=` It must be ${_}. Received ${U}`,L},RangeError);function Ft(p){let _="",T=p.length;const L=p[0]==="-"?1:0;for(;T>=L+4;T-=3)_=`_${p.slice(T-3,T)}${_}`;return`${p.slice(0,T)}${_}`}function wi(p,_,T){Ot(_,"offset"),(p[_]===void 0||p[_+T]===void 0)&&ki(_,p.length-(T+1))}function Dt(p,_,T,L,U,q){if(p>T||p<_){const K=typeof _=="bigint"?"n":"";let Se;throw _===0||_===BigInt(0)?Se=`>= 0${K} and < 2${K} ** ${(q+1)*8}${K}`:Se=`>= -(2${K} ** ${(q+1)*8-1}${K}) and < 2 ** ${(q+1)*8-1}${K}`,new yt.ERR_OUT_OF_RANGE("value",Se,p)}wi(L,U,q)}function Ot(p,_){if(typeof p!="number")throw new yt.ERR_INVALID_ARG_TYPE(_,"number",p)}function ki(p,_,T){throw Math.floor(p)!==p?(Ot(p,T),new yt.ERR_OUT_OF_RANGE("offset","an integer",p)):_<0?new yt.ERR_BUFFER_OUT_OF_BOUNDS:new yt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${_}`,p)}const jt=/[^+/0-9A-Za-z-_]/g;function Pn(p){if(p=p.split("=")[0],p=p.trim().replace(jt,""),p.length<2)return"";for(;p.length%4!==0;)p=p+"=";return p}function pe(p,_){_=_||1/0;let T;const L=p.length;let U=null;const q=[];for(let K=0;K<L;++K){if(T=p.charCodeAt(K),T>55295&&T<57344){if(!U){if(T>56319){(_-=3)>-1&&q.push(239,191,189);continue}else if(K+1===L){(_-=3)>-1&&q.push(239,191,189);continue}U=T;continue}if(T<56320){(_-=3)>-1&&q.push(239,191,189),U=T;continue}T=(U-55296<<10|T-56320)+65536}else U&&(_-=3)>-1&&q.push(239,191,189);if(U=null,T<128){if((_-=1)<0)break;q.push(T)}else if(T<2048){if((_-=2)<0)break;q.push(T>>6|192,T&63|128)}else if(T<65536){if((_-=3)<0)break;q.push(T>>12|224,T>>6&63|128,T&63|128)}else if(T<1114112){if((_-=4)<0)break;q.push(T>>18|240,T>>12&63|128,T>>6&63|128,T&63|128)}else throw new Error("Invalid code point")}return q}function ia(p){const _=[];for(let T=0;T<p.length;++T)_.push(p.charCodeAt(T)&255);return _}function Ln(p,_){let T,L,U;const q=[];for(let K=0;K<p.length&&!((_-=2)<0);++K)T=p.charCodeAt(K),L=T>>8,U=T%256,q.push(U),q.push(L);return q}function Ss(p){return e.toByteArray(Pn(p))}function di(p,_,T,L){let U;for(U=0;U<L&&!(U+T>=_.length||U>=p.length);++U)_[U+T]=p[U];return U}function ut(p,_){return p instanceof _||p!=null&&p.constructor!=null&&p.constructor.name!=null&&p.constructor.name===_.name}function Ci(p){return p!==p}const zi=function(){const p="0123456789abcdef",_=new Array(256);for(let T=0;T<16;++T){const L=T*16;for(let U=0;U<16;++U)_[L+U]=p[T]+p[U]}return _}();function wt(p){return typeof BigInt>"u"?Es:p}function Es(){throw new Error("BigInt not supported")}})(ah);const Q_=ah.Buffer;var J_=function(i){return x.atob?x.atob(i):Q_.from(i,"base64").toString("binary")};function lh(i){for(var e=J_(i),t=new Uint8Array(e.length),n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}/*! @name m3u8-parser @version 7.2.0 @license Apache-2.0 */class Z_ extends Io{constructor(){super(),this.buffer=""}push(e){let t;for(this.buffer+=e,t=this.buffer.indexOf(`
|
|
21
|
+
*/(function(i){const e=Rr,t=Io,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=m,i.SlowBuffer=P,i.INSPECT_MAX_BYTES=50;const s=2147483647;i.kMaxLength=s;const{Uint8Array:r,ArrayBuffer:a,SharedArrayBuffer:l}=globalThis;m.TYPED_ARRAY_SUPPORT=c(),!m.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{const p=new r(1),_={foo:function(){return 42}};return Object.setPrototypeOf(_,r.prototype),Object.setPrototypeOf(p,_),p.foo()===42}catch{return!1}}Object.defineProperty(m.prototype,"parent",{enumerable:!0,get:function(){if(m.isBuffer(this))return this.buffer}}),Object.defineProperty(m.prototype,"offset",{enumerable:!0,get:function(){if(m.isBuffer(this))return this.byteOffset}});function f(p){if(p>s)throw new RangeError('The value "'+p+'" is invalid for option "size"');const _=new r(p);return Object.setPrototypeOf(_,m.prototype),_}function m(p,_,T){if(typeof p=="number"){if(typeof _=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return A(p)}return b(p,_,T)}m.poolSize=8192;function b(p,_,T){if(typeof p=="string")return v(p,_);if(a.isView(p))return D(p);if(p==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof p);if(ut(p,a)||p&&ut(p.buffer,a)||typeof l<"u"&&(ut(p,l)||p&&ut(p.buffer,l)))return R(p,_,T);if(typeof p=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const L=p.valueOf&&p.valueOf();if(L!=null&&L!==p)return m.from(L,_,T);const U=N(p);if(U)return U;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof p[Symbol.toPrimitive]=="function")return m.from(p[Symbol.toPrimitive]("string"),_,T);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof p)}m.from=function(p,_,T){return b(p,_,T)},Object.setPrototypeOf(m.prototype,r.prototype),Object.setPrototypeOf(m,r);function C(p){if(typeof p!="number")throw new TypeError('"size" argument must be of type number');if(p<0)throw new RangeError('The value "'+p+'" is invalid for option "size"')}function w(p,_,T){return C(p),p<=0?f(p):_!==void 0?typeof T=="string"?f(p).fill(_,T):f(p).fill(_):f(p)}m.alloc=function(p,_,T){return w(p,_,T)};function A(p){return C(p),f(p<0?0:F(p)|0)}m.allocUnsafe=function(p){return A(p)},m.allocUnsafeSlow=function(p){return A(p)};function v(p,_){if((typeof _!="string"||_==="")&&(_="utf8"),!m.isEncoding(_))throw new TypeError("Unknown encoding: "+_);const T=$(p,_)|0;let L=f(T);const U=L.write(p,_);return U!==T&&(L=L.slice(0,U)),L}function M(p){const _=p.length<0?0:F(p.length)|0,T=f(_);for(let L=0;L<_;L+=1)T[L]=p[L]&255;return T}function D(p){if(ut(p,r)){const _=new r(p);return R(_.buffer,_.byteOffset,_.byteLength)}return M(p)}function R(p,_,T){if(_<0||p.byteLength<_)throw new RangeError('"offset" is outside of buffer bounds');if(p.byteLength<_+(T||0))throw new RangeError('"length" is outside of buffer bounds');let L;return _===void 0&&T===void 0?L=new r(p):T===void 0?L=new r(p,_):L=new r(p,_,T),Object.setPrototypeOf(L,m.prototype),L}function N(p){if(m.isBuffer(p)){const _=F(p.length)|0,T=f(_);return T.length===0||p.copy(T,0,0,_),T}if(p.length!==void 0)return typeof p.length!="number"||Ci(p.length)?f(0):M(p);if(p.type==="Buffer"&&Array.isArray(p.data))return M(p.data)}function F(p){if(p>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return p|0}function P(p){return+p!=p&&(p=0),m.alloc(+p)}m.isBuffer=function(p){return p!=null&&p._isBuffer===!0&&p!==m.prototype},m.compare=function(p,_){if(ut(p,r)&&(p=m.from(p,p.offset,p.byteLength)),ut(_,r)&&(_=m.from(_,_.offset,_.byteLength)),!m.isBuffer(p)||!m.isBuffer(_))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(p===_)return 0;let T=p.length,L=_.length;for(let U=0,q=Math.min(T,L);U<q;++U)if(p[U]!==_[U]){T=p[U],L=_[U];break}return T<L?-1:L<T?1:0},m.isEncoding=function(p){switch(String(p).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},m.concat=function(p,_){if(!Array.isArray(p))throw new TypeError('"list" argument must be an Array of Buffers');if(p.length===0)return m.alloc(0);let T;if(_===void 0)for(_=0,T=0;T<p.length;++T)_+=p[T].length;const L=m.allocUnsafe(_);let U=0;for(T=0;T<p.length;++T){let q=p[T];if(ut(q,r))U+q.length>L.length?(m.isBuffer(q)||(q=m.from(q)),q.copy(L,U)):r.prototype.set.call(L,q,U);else if(m.isBuffer(q))q.copy(L,U);else throw new TypeError('"list" argument must be an Array of Buffers');U+=q.length}return L};function $(p,_){if(m.isBuffer(p))return p.length;if(a.isView(p)||ut(p,a))return p.byteLength;if(typeof p!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof p);const T=p.length,L=arguments.length>2&&arguments[2]===!0;if(!L&&T===0)return 0;let U=!1;for(;;)switch(_){case"ascii":case"latin1":case"binary":return T;case"utf8":case"utf-8":return pe(p).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T*2;case"hex":return T>>>1;case"base64":return Es(p).length;default:if(U)return L?-1:pe(p).length;_=(""+_).toLowerCase(),U=!0}}m.byteLength=$;function Y(p,_,T){let L=!1;if((_===void 0||_<0)&&(_=0),_>this.length||((T===void 0||T>this.length)&&(T=this.length),T<=0)||(T>>>=0,_>>>=0,T<=_))return"";for(p||(p="utf8");;)switch(p){case"hex":return mt(this,_,T);case"utf8":case"utf-8":return Ye(this,_,T);case"ascii":return me(this,_,T);case"latin1":case"binary":return ge(this,_,T);case"base64":return Xe(this,_,T);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,_,T);default:if(L)throw new TypeError("Unknown encoding: "+p);p=(p+"").toLowerCase(),L=!0}}m.prototype._isBuffer=!0;function X(p,_,T){const L=p[_];p[_]=p[T],p[T]=L}m.prototype.swap16=function(){const p=this.length;if(p%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let _=0;_<p;_+=2)X(this,_,_+1);return this},m.prototype.swap32=function(){const p=this.length;if(p%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let _=0;_<p;_+=4)X(this,_,_+3),X(this,_+1,_+2);return this},m.prototype.swap64=function(){const p=this.length;if(p%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let _=0;_<p;_+=8)X(this,_,_+7),X(this,_+1,_+6),X(this,_+2,_+5),X(this,_+3,_+4);return this},m.prototype.toString=function(){const p=this.length;return p===0?"":arguments.length===0?Ye(this,0,p):Y.apply(this,arguments)},m.prototype.toLocaleString=m.prototype.toString,m.prototype.equals=function(p){if(!m.isBuffer(p))throw new TypeError("Argument must be a Buffer");return this===p?!0:m.compare(this,p)===0},m.prototype.inspect=function(){let p="";const _=i.INSPECT_MAX_BYTES;return p=this.toString("hex",0,_).replace(/(.{2})/g,"$1 ").trim(),this.length>_&&(p+=" ... "),"<Buffer "+p+">"},n&&(m.prototype[n]=m.prototype.inspect),m.prototype.compare=function(p,_,T,L,U){if(ut(p,r)&&(p=m.from(p,p.offset,p.byteLength)),!m.isBuffer(p))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof p);if(_===void 0&&(_=0),T===void 0&&(T=p?p.length:0),L===void 0&&(L=0),U===void 0&&(U=this.length),_<0||T>p.length||L<0||U>this.length)throw new RangeError("out of range index");if(L>=U&&_>=T)return 0;if(L>=U)return-1;if(_>=T)return 1;if(_>>>=0,T>>>=0,L>>>=0,U>>>=0,this===p)return 0;let q=U-L,K=T-_;const Se=Math.min(q,K),Ve=this.slice(L,U),ke=p.slice(_,T);for(let Te=0;Te<Se;++Te)if(Ve[Te]!==ke[Te]){q=Ve[Te],K=ke[Te];break}return q<K?-1:K<q?1:0};function re(p,_,T,L,U){if(p.length===0)return-1;if(typeof T=="string"?(L=T,T=0):T>2147483647?T=2147483647:T<-2147483648&&(T=-2147483648),T=+T,Ci(T)&&(T=U?0:p.length-1),T<0&&(T=p.length+T),T>=p.length){if(U)return-1;T=p.length-1}else if(T<0)if(U)T=0;else return-1;if(typeof _=="string"&&(_=m.from(_,L)),m.isBuffer(_))return _.length===0?-1:ce(p,_,T,L,U);if(typeof _=="number")return _=_&255,typeof r.prototype.indexOf=="function"?U?r.prototype.indexOf.call(p,_,T):r.prototype.lastIndexOf.call(p,_,T):ce(p,[_],T,L,U);throw new TypeError("val must be string, number or Buffer")}function ce(p,_,T,L,U){let q=1,K=p.length,Se=_.length;if(L!==void 0&&(L=String(L).toLowerCase(),L==="ucs2"||L==="ucs-2"||L==="utf16le"||L==="utf-16le")){if(p.length<2||_.length<2)return-1;q=2,K/=2,Se/=2,T/=2}function Ve(Te,Ue){return q===1?Te[Ue]:Te.readUInt16BE(Ue*q)}let ke;if(U){let Te=-1;for(ke=T;ke<K;ke++)if(Ve(p,ke)===Ve(_,Te===-1?0:ke-Te)){if(Te===-1&&(Te=ke),ke-Te+1===Se)return Te*q}else Te!==-1&&(ke-=ke-Te),Te=-1}else for(T+Se>K&&(T=K-Se),ke=T;ke>=0;ke--){let Te=!0;for(let Ue=0;Ue<Se;Ue++)if(Ve(p,ke+Ue)!==Ve(_,Ue)){Te=!1;break}if(Te)return ke}return-1}m.prototype.includes=function(p,_,T){return this.indexOf(p,_,T)!==-1},m.prototype.indexOf=function(p,_,T){return re(this,p,_,T,!0)},m.prototype.lastIndexOf=function(p,_,T){return re(this,p,_,T,!1)};function be(p,_,T,L){T=Number(T)||0;const U=p.length-T;L?(L=Number(L),L>U&&(L=U)):L=U;const q=_.length;L>q/2&&(L=q/2);let K;for(K=0;K<L;++K){const Se=parseInt(_.substr(K*2,2),16);if(Ci(Se))return K;p[T+K]=Se}return K}function he(p,_,T,L){return di(pe(_,p.length-T),p,T,L)}function Z(p,_,T,L){return di(ia(_),p,T,L)}function de(p,_,T,L){return di(Es(_),p,T,L)}function ee(p,_,T,L){return di(Ln(_,p.length-T),p,T,L)}m.prototype.write=function(p,_,T,L){if(_===void 0)L="utf8",T=this.length,_=0;else if(T===void 0&&typeof _=="string")L=_,T=this.length,_=0;else if(isFinite(_))_=_>>>0,isFinite(T)?(T=T>>>0,L===void 0&&(L="utf8")):(L=T,T=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const U=this.length-_;if((T===void 0||T>U)&&(T=U),p.length>0&&(T<0||_<0)||_>this.length)throw new RangeError("Attempt to write outside buffer bounds");L||(L="utf8");let q=!1;for(;;)switch(L){case"hex":return be(this,p,_,T);case"utf8":case"utf-8":return he(this,p,_,T);case"ascii":case"latin1":case"binary":return Z(this,p,_,T);case"base64":return de(this,p,_,T);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ee(this,p,_,T);default:if(q)throw new TypeError("Unknown encoding: "+L);L=(""+L).toLowerCase(),q=!0}},m.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Xe(p,_,T){return _===0&&T===p.length?e.fromByteArray(p):e.fromByteArray(p.slice(_,T))}function Ye(p,_,T){T=Math.min(p.length,T);const L=[];let U=_;for(;U<T;){const q=p[U];let K=null,Se=q>239?4:q>223?3:q>191?2:1;if(U+Se<=T){let Ve,ke,Te,Ue;switch(Se){case 1:q<128&&(K=q);break;case 2:Ve=p[U+1],(Ve&192)===128&&(Ue=(q&31)<<6|Ve&63,Ue>127&&(K=Ue));break;case 3:Ve=p[U+1],ke=p[U+2],(Ve&192)===128&&(ke&192)===128&&(Ue=(q&15)<<12|(Ve&63)<<6|ke&63,Ue>2047&&(Ue<55296||Ue>57343)&&(K=Ue));break;case 4:Ve=p[U+1],ke=p[U+2],Te=p[U+3],(Ve&192)===128&&(ke&192)===128&&(Te&192)===128&&(Ue=(q&15)<<18|(Ve&63)<<12|(ke&63)<<6|Te&63,Ue>65535&&Ue<1114112&&(K=Ue))}}K===null?(K=65533,Se=1):K>65535&&(K-=65536,L.push(K>>>10&1023|55296),K=56320|K&1023),L.push(K),U+=Se}return He(L)}const $e=4096;function He(p){const _=p.length;if(_<=$e)return String.fromCharCode.apply(String,p);let T="",L=0;for(;L<_;)T+=String.fromCharCode.apply(String,p.slice(L,L+=$e));return T}function me(p,_,T){let L="";T=Math.min(p.length,T);for(let U=_;U<T;++U)L+=String.fromCharCode(p[U]&127);return L}function ge(p,_,T){let L="";T=Math.min(p.length,T);for(let U=_;U<T;++U)L+=String.fromCharCode(p[U]);return L}function mt(p,_,T){const L=p.length;(!_||_<0)&&(_=0),(!T||T<0||T>L)&&(T=L);let U="";for(let q=_;q<T;++q)U+=zi[p[q]];return U}function Et(p,_,T){const L=p.slice(_,T);let U="";for(let q=0;q<L.length-1;q+=2)U+=String.fromCharCode(L[q]+L[q+1]*256);return U}m.prototype.slice=function(p,_){const T=this.length;p=~~p,_=_===void 0?T:~~_,p<0?(p+=T,p<0&&(p=0)):p>T&&(p=T),_<0?(_+=T,_<0&&(_=0)):_>T&&(_=T),_<p&&(_=p);const L=this.subarray(p,_);return Object.setPrototypeOf(L,m.prototype),L};function we(p,_,T){if(p%1!==0||p<0)throw new RangeError("offset is not uint");if(p+_>T)throw new RangeError("Trying to access beyond buffer length")}m.prototype.readUintLE=m.prototype.readUIntLE=function(p,_,T){p=p>>>0,_=_>>>0,T||we(p,_,this.length);let L=this[p],U=1,q=0;for(;++q<_&&(U*=256);)L+=this[p+q]*U;return L},m.prototype.readUintBE=m.prototype.readUIntBE=function(p,_,T){p=p>>>0,_=_>>>0,T||we(p,_,this.length);let L=this[p+--_],U=1;for(;_>0&&(U*=256);)L+=this[p+--_]*U;return L},m.prototype.readUint8=m.prototype.readUInt8=function(p,_){return p=p>>>0,_||we(p,1,this.length),this[p]},m.prototype.readUint16LE=m.prototype.readUInt16LE=function(p,_){return p=p>>>0,_||we(p,2,this.length),this[p]|this[p+1]<<8},m.prototype.readUint16BE=m.prototype.readUInt16BE=function(p,_){return p=p>>>0,_||we(p,2,this.length),this[p]<<8|this[p+1]},m.prototype.readUint32LE=m.prototype.readUInt32LE=function(p,_){return p=p>>>0,_||we(p,4,this.length),(this[p]|this[p+1]<<8|this[p+2]<<16)+this[p+3]*16777216},m.prototype.readUint32BE=m.prototype.readUInt32BE=function(p,_){return p=p>>>0,_||we(p,4,this.length),this[p]*16777216+(this[p+1]<<16|this[p+2]<<8|this[p+3])},m.prototype.readBigUInt64LE=wt(function(p){p=p>>>0,Ot(p,"offset");const _=this[p],T=this[p+7];(_===void 0||T===void 0)&&ki(p,this.length-8);const L=_+this[++p]*2**8+this[++p]*2**16+this[++p]*2**24,U=this[++p]+this[++p]*2**8+this[++p]*2**16+T*2**24;return BigInt(L)+(BigInt(U)<<BigInt(32))}),m.prototype.readBigUInt64BE=wt(function(p){p=p>>>0,Ot(p,"offset");const _=this[p],T=this[p+7];(_===void 0||T===void 0)&&ki(p,this.length-8);const L=_*2**24+this[++p]*2**16+this[++p]*2**8+this[++p],U=this[++p]*2**24+this[++p]*2**16+this[++p]*2**8+T;return(BigInt(L)<<BigInt(32))+BigInt(U)}),m.prototype.readIntLE=function(p,_,T){p=p>>>0,_=_>>>0,T||we(p,_,this.length);let L=this[p],U=1,q=0;for(;++q<_&&(U*=256);)L+=this[p+q]*U;return U*=128,L>=U&&(L-=Math.pow(2,8*_)),L},m.prototype.readIntBE=function(p,_,T){p=p>>>0,_=_>>>0,T||we(p,_,this.length);let L=_,U=1,q=this[p+--L];for(;L>0&&(U*=256);)q+=this[p+--L]*U;return U*=128,q>=U&&(q-=Math.pow(2,8*_)),q},m.prototype.readInt8=function(p,_){return p=p>>>0,_||we(p,1,this.length),this[p]&128?(255-this[p]+1)*-1:this[p]},m.prototype.readInt16LE=function(p,_){p=p>>>0,_||we(p,2,this.length);const T=this[p]|this[p+1]<<8;return T&32768?T|4294901760:T},m.prototype.readInt16BE=function(p,_){p=p>>>0,_||we(p,2,this.length);const T=this[p+1]|this[p]<<8;return T&32768?T|4294901760:T},m.prototype.readInt32LE=function(p,_){return p=p>>>0,_||we(p,4,this.length),this[p]|this[p+1]<<8|this[p+2]<<16|this[p+3]<<24},m.prototype.readInt32BE=function(p,_){return p=p>>>0,_||we(p,4,this.length),this[p]<<24|this[p+1]<<16|this[p+2]<<8|this[p+3]},m.prototype.readBigInt64LE=wt(function(p){p=p>>>0,Ot(p,"offset");const _=this[p],T=this[p+7];(_===void 0||T===void 0)&&ki(p,this.length-8);const L=this[p+4]+this[p+5]*2**8+this[p+6]*2**16+(T<<24);return(BigInt(L)<<BigInt(32))+BigInt(_+this[++p]*2**8+this[++p]*2**16+this[++p]*2**24)}),m.prototype.readBigInt64BE=wt(function(p){p=p>>>0,Ot(p,"offset");const _=this[p],T=this[p+7];(_===void 0||T===void 0)&&ki(p,this.length-8);const L=(_<<24)+this[++p]*2**16+this[++p]*2**8+this[++p];return(BigInt(L)<<BigInt(32))+BigInt(this[++p]*2**24+this[++p]*2**16+this[++p]*2**8+T)}),m.prototype.readFloatLE=function(p,_){return p=p>>>0,_||we(p,4,this.length),t.read(this,p,!0,23,4)},m.prototype.readFloatBE=function(p,_){return p=p>>>0,_||we(p,4,this.length),t.read(this,p,!1,23,4)},m.prototype.readDoubleLE=function(p,_){return p=p>>>0,_||we(p,8,this.length),t.read(this,p,!0,52,8)},m.prototype.readDoubleBE=function(p,_){return p=p>>>0,_||we(p,8,this.length),t.read(this,p,!1,52,8)};function le(p,_,T,L,U,q){if(!m.isBuffer(p))throw new TypeError('"buffer" argument must be a Buffer instance');if(_>U||_<q)throw new RangeError('"value" argument is out of bounds');if(T+L>p.length)throw new RangeError("Index out of range")}m.prototype.writeUintLE=m.prototype.writeUIntLE=function(p,_,T,L){if(p=+p,_=_>>>0,T=T>>>0,!L){const K=Math.pow(2,8*T)-1;le(this,p,_,T,K,0)}let U=1,q=0;for(this[_]=p&255;++q<T&&(U*=256);)this[_+q]=p/U&255;return _+T},m.prototype.writeUintBE=m.prototype.writeUIntBE=function(p,_,T,L){if(p=+p,_=_>>>0,T=T>>>0,!L){const K=Math.pow(2,8*T)-1;le(this,p,_,T,K,0)}let U=T-1,q=1;for(this[_+U]=p&255;--U>=0&&(q*=256);)this[_+U]=p/q&255;return _+T},m.prototype.writeUint8=m.prototype.writeUInt8=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,1,255,0),this[_]=p&255,_+1},m.prototype.writeUint16LE=m.prototype.writeUInt16LE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,2,65535,0),this[_]=p&255,this[_+1]=p>>>8,_+2},m.prototype.writeUint16BE=m.prototype.writeUInt16BE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,2,65535,0),this[_]=p>>>8,this[_+1]=p&255,_+2},m.prototype.writeUint32LE=m.prototype.writeUInt32LE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,4,4294967295,0),this[_+3]=p>>>24,this[_+2]=p>>>16,this[_+1]=p>>>8,this[_]=p&255,_+4},m.prototype.writeUint32BE=m.prototype.writeUInt32BE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,4,4294967295,0),this[_]=p>>>24,this[_+1]=p>>>16,this[_+2]=p>>>8,this[_+3]=p&255,_+4};function Re(p,_,T,L,U){Dt(_,L,U,p,T,7);let q=Number(_&BigInt(4294967295));p[T++]=q,q=q>>8,p[T++]=q,q=q>>8,p[T++]=q,q=q>>8,p[T++]=q;let K=Number(_>>BigInt(32)&BigInt(4294967295));return p[T++]=K,K=K>>8,p[T++]=K,K=K>>8,p[T++]=K,K=K>>8,p[T++]=K,T}function Hi(p,_,T,L,U){Dt(_,L,U,p,T,7);let q=Number(_&BigInt(4294967295));p[T+7]=q,q=q>>8,p[T+6]=q,q=q>>8,p[T+5]=q,q=q>>8,p[T+4]=q;let K=Number(_>>BigInt(32)&BigInt(4294967295));return p[T+3]=K,K=K>>8,p[T+2]=K,K=K>>8,p[T+1]=K,K=K>>8,p[T]=K,T+8}m.prototype.writeBigUInt64LE=wt(function(p,_=0){return Re(this,p,_,BigInt(0),BigInt("0xffffffffffffffff"))}),m.prototype.writeBigUInt64BE=wt(function(p,_=0){return Hi(this,p,_,BigInt(0),BigInt("0xffffffffffffffff"))}),m.prototype.writeIntLE=function(p,_,T,L){if(p=+p,_=_>>>0,!L){const Se=Math.pow(2,8*T-1);le(this,p,_,T,Se-1,-Se)}let U=0,q=1,K=0;for(this[_]=p&255;++U<T&&(q*=256);)p<0&&K===0&&this[_+U-1]!==0&&(K=1),this[_+U]=(p/q>>0)-K&255;return _+T},m.prototype.writeIntBE=function(p,_,T,L){if(p=+p,_=_>>>0,!L){const Se=Math.pow(2,8*T-1);le(this,p,_,T,Se-1,-Se)}let U=T-1,q=1,K=0;for(this[_+U]=p&255;--U>=0&&(q*=256);)p<0&&K===0&&this[_+U+1]!==0&&(K=1),this[_+U]=(p/q>>0)-K&255;return _+T},m.prototype.writeInt8=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,1,127,-128),p<0&&(p=255+p+1),this[_]=p&255,_+1},m.prototype.writeInt16LE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,2,32767,-32768),this[_]=p&255,this[_+1]=p>>>8,_+2},m.prototype.writeInt16BE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,2,32767,-32768),this[_]=p>>>8,this[_+1]=p&255,_+2},m.prototype.writeInt32LE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,4,2147483647,-2147483648),this[_]=p&255,this[_+1]=p>>>8,this[_+2]=p>>>16,this[_+3]=p>>>24,_+4},m.prototype.writeInt32BE=function(p,_,T){return p=+p,_=_>>>0,T||le(this,p,_,4,2147483647,-2147483648),p<0&&(p=4294967295+p+1),this[_]=p>>>24,this[_+1]=p>>>16,this[_+2]=p>>>8,this[_+3]=p&255,_+4},m.prototype.writeBigInt64LE=wt(function(p,_=0){return Re(this,p,_,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),m.prototype.writeBigInt64BE=wt(function(p,_=0){return Hi(this,p,_,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function oi(p,_,T,L,U,q){if(T+L>p.length)throw new RangeError("Index out of range");if(T<0)throw new RangeError("Index out of range")}function li(p,_,T,L,U){return _=+_,T=T>>>0,U||oi(p,_,T,4),t.write(p,_,T,L,23,4),T+4}m.prototype.writeFloatLE=function(p,_,T){return li(this,p,_,!0,T)},m.prototype.writeFloatBE=function(p,_,T){return li(this,p,_,!1,T)};function Ei(p,_,T,L,U){return _=+_,T=T>>>0,U||oi(p,_,T,8),t.write(p,_,T,L,52,8),T+8}m.prototype.writeDoubleLE=function(p,_,T){return Ei(this,p,_,!0,T)},m.prototype.writeDoubleBE=function(p,_,T){return Ei(this,p,_,!1,T)},m.prototype.copy=function(p,_,T,L){if(!m.isBuffer(p))throw new TypeError("argument should be a Buffer");if(T||(T=0),!L&&L!==0&&(L=this.length),_>=p.length&&(_=p.length),_||(_=0),L>0&&L<T&&(L=T),L===T||p.length===0||this.length===0)return 0;if(_<0)throw new RangeError("targetStart out of bounds");if(T<0||T>=this.length)throw new RangeError("Index out of range");if(L<0)throw new RangeError("sourceEnd out of bounds");L>this.length&&(L=this.length),p.length-_<L-T&&(L=p.length-_+T);const U=L-T;return this===p&&typeof r.prototype.copyWithin=="function"?this.copyWithin(_,T,L):r.prototype.set.call(p,this.subarray(T,L),_),U},m.prototype.fill=function(p,_,T,L){if(typeof p=="string"){if(typeof _=="string"?(L=_,_=0,T=this.length):typeof T=="string"&&(L=T,T=this.length),L!==void 0&&typeof L!="string")throw new TypeError("encoding must be a string");if(typeof L=="string"&&!m.isEncoding(L))throw new TypeError("Unknown encoding: "+L);if(p.length===1){const q=p.charCodeAt(0);(L==="utf8"&&q<128||L==="latin1")&&(p=q)}}else typeof p=="number"?p=p&255:typeof p=="boolean"&&(p=Number(p));if(_<0||this.length<_||this.length<T)throw new RangeError("Out of range index");if(T<=_)return this;_=_>>>0,T=T===void 0?this.length:T>>>0,p||(p=0);let U;if(typeof p=="number")for(U=_;U<T;++U)this[U]=p;else{const q=m.isBuffer(p)?p:m.from(p,L),K=q.length;if(K===0)throw new TypeError('The value "'+p+'" is invalid for argument "value"');for(U=0;U<T-_;++U)this[U+_]=q[U%K]}return this};const yt={};function ui(p,_,T){yt[p]=class extends T{constructor(){super(),Object.defineProperty(this,"message",{value:_.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${p}]`,this.stack,delete this.name}get code(){return p}set code(L){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:L,writable:!0})}toString(){return`${this.name} [${p}]: ${this.message}`}}}ui("ERR_BUFFER_OUT_OF_BOUNDS",function(p){return p?`${p} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ui("ERR_INVALID_ARG_TYPE",function(p,_){return`The "${p}" argument must be of type number. Received type ${typeof _}`},TypeError),ui("ERR_OUT_OF_RANGE",function(p,_,T){let L=`The value of "${p}" is out of range.`,U=T;return Number.isInteger(T)&&Math.abs(T)>2**32?U=Ft(String(T)):typeof T=="bigint"&&(U=String(T),(T>BigInt(2)**BigInt(32)||T<-(BigInt(2)**BigInt(32)))&&(U=Ft(U)),U+="n"),L+=` It must be ${_}. Received ${U}`,L},RangeError);function Ft(p){let _="",T=p.length;const L=p[0]==="-"?1:0;for(;T>=L+4;T-=3)_=`_${p.slice(T-3,T)}${_}`;return`${p.slice(0,T)}${_}`}function wi(p,_,T){Ot(_,"offset"),(p[_]===void 0||p[_+T]===void 0)&&ki(_,p.length-(T+1))}function Dt(p,_,T,L,U,q){if(p>T||p<_){const K=typeof _=="bigint"?"n":"";let Se;throw _===0||_===BigInt(0)?Se=`>= 0${K} and < 2${K} ** ${(q+1)*8}${K}`:Se=`>= -(2${K} ** ${(q+1)*8-1}${K}) and < 2 ** ${(q+1)*8-1}${K}`,new yt.ERR_OUT_OF_RANGE("value",Se,p)}wi(L,U,q)}function Ot(p,_){if(typeof p!="number")throw new yt.ERR_INVALID_ARG_TYPE(_,"number",p)}function ki(p,_,T){throw Math.floor(p)!==p?(Ot(p,T),new yt.ERR_OUT_OF_RANGE("offset","an integer",p)):_<0?new yt.ERR_BUFFER_OUT_OF_BOUNDS:new yt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${_}`,p)}const jt=/[^+/0-9A-Za-z-_]/g;function Pn(p){if(p=p.split("=")[0],p=p.trim().replace(jt,""),p.length<2)return"";for(;p.length%4!==0;)p=p+"=";return p}function pe(p,_){_=_||1/0;let T;const L=p.length;let U=null;const q=[];for(let K=0;K<L;++K){if(T=p.charCodeAt(K),T>55295&&T<57344){if(!U){if(T>56319){(_-=3)>-1&&q.push(239,191,189);continue}else if(K+1===L){(_-=3)>-1&&q.push(239,191,189);continue}U=T;continue}if(T<56320){(_-=3)>-1&&q.push(239,191,189),U=T;continue}T=(U-55296<<10|T-56320)+65536}else U&&(_-=3)>-1&&q.push(239,191,189);if(U=null,T<128){if((_-=1)<0)break;q.push(T)}else if(T<2048){if((_-=2)<0)break;q.push(T>>6|192,T&63|128)}else if(T<65536){if((_-=3)<0)break;q.push(T>>12|224,T>>6&63|128,T&63|128)}else if(T<1114112){if((_-=4)<0)break;q.push(T>>18|240,T>>12&63|128,T>>6&63|128,T&63|128)}else throw new Error("Invalid code point")}return q}function ia(p){const _=[];for(let T=0;T<p.length;++T)_.push(p.charCodeAt(T)&255);return _}function Ln(p,_){let T,L,U;const q=[];for(let K=0;K<p.length&&!((_-=2)<0);++K)T=p.charCodeAt(K),L=T>>8,U=T%256,q.push(U),q.push(L);return q}function Es(p){return e.toByteArray(Pn(p))}function di(p,_,T,L){let U;for(U=0;U<L&&!(U+T>=_.length||U>=p.length);++U)_[U+T]=p[U];return U}function ut(p,_){return p instanceof _||p!=null&&p.constructor!=null&&p.constructor.name!=null&&p.constructor.name===_.name}function Ci(p){return p!==p}const zi=function(){const p="0123456789abcdef",_=new Array(256);for(let T=0;T<16;++T){const L=T*16;for(let U=0;U<16;++U)_[L+U]=p[T]+p[U]}return _}();function wt(p){return typeof BigInt>"u"?ws:p}function ws(){throw new Error("BigInt not supported")}})(nh);const $_=nh.Buffer;var q_=function(i){return x.atob?x.atob(i):$_.from(i,"base64").toString("binary")};function rh(i){for(var e=q_(i),t=new Uint8Array(e.length),n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}/*! @name m3u8-parser @version 7.2.0 @license Apache-2.0 */class V_ extends Co{constructor(){super(),this.buffer=""}push(e){let t;for(this.buffer+=e,t=this.buffer.indexOf(`
|
|
22
22
|
`);t>-1;t=this.buffer.indexOf(`
|
|
23
|
-
`))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1)}}const e0=" ",xa=function(i){const e=/([0-9.]*)?@?([0-9.]*)?/.exec(i||""),t={};return e[1]&&(t.length=parseInt(e[1],10)),e[2]&&(t.offset=parseInt(e[2],10)),t},t0=function(){const i='(?:[^=]*)=(?:"[^"]*"|[^,]*)';return new RegExp("(?:^|,)("+i+")")},st=function(i){const e={};if(!i)return e;const t=i.split(t0());let n=t.length,s;for(;n--;)t[n]!==""&&(s=/([^=]*)=(.*)/.exec(t[n]).slice(1),s[0]=s[0].replace(/^\s+|\s+$/g,""),s[1]=s[1].replace(/^\s+|\s+$/g,""),s[1]=s[1].replace(/^['"](.*)['"]$/g,"$1"),e[s[0]]=s[1]);return e},vu=i=>{const e=i.split("x"),t={};return e[0]&&(t.width=parseInt(e[0],10)),e[1]&&(t.height=parseInt(e[1],10)),t};class i0 extends Io{constructor(){super(),this.customParsers=[],this.tagMappers=[]}push(e){let t,n;if(e=e.trim(),e.length!==0){if(e[0]!=="#"){this.trigger("data",{type:"uri",uri:e});return}this.tagMappers.reduce((s,r)=>{const a=r(e);return a===e?s:s.concat([a])},[e]).forEach(s=>{for(let r=0;r<this.customParsers.length;r++)if(this.customParsers[r].call(this,s))return;if(s.indexOf("#EXT")!==0){this.trigger("data",{type:"comment",text:s.slice(1)});return}if(s=s.replace("\r",""),t=/^#EXTM3U/.exec(s),t){this.trigger("data",{type:"tag",tagType:"m3u"});return}if(t=/^#EXTINF:([0-9\.]*)?,?(.*)?$/.exec(s),t){n={type:"tag",tagType:"inf"},t[1]&&(n.duration=parseFloat(t[1])),t[2]&&(n.title=t[2]),this.trigger("data",n);return}if(t=/^#EXT-X-TARGETDURATION:([0-9.]*)?/.exec(s),t){n={type:"tag",tagType:"targetduration"},t[1]&&(n.duration=parseInt(t[1],10)),this.trigger("data",n);return}if(t=/^#EXT-X-VERSION:([0-9.]*)?/.exec(s),t){n={type:"tag",tagType:"version"},t[1]&&(n.version=parseInt(t[1],10)),this.trigger("data",n);return}if(t=/^#EXT-X-MEDIA-SEQUENCE:(\-?[0-9.]*)?/.exec(s),t){n={type:"tag",tagType:"media-sequence"},t[1]&&(n.number=parseInt(t[1],10)),this.trigger("data",n);return}if(t=/^#EXT-X-DISCONTINUITY-SEQUENCE:(\-?[0-9.]*)?/.exec(s),t){n={type:"tag",tagType:"discontinuity-sequence"},t[1]&&(n.number=parseInt(t[1],10)),this.trigger("data",n);return}if(t=/^#EXT-X-PLAYLIST-TYPE:(.*)?$/.exec(s),t){n={type:"tag",tagType:"playlist-type"},t[1]&&(n.playlistType=t[1]),this.trigger("data",n);return}if(t=/^#EXT-X-BYTERANGE:(.*)?$/.exec(s),t){n=je(xa(t[1]),{type:"tag",tagType:"byterange"}),this.trigger("data",n);return}if(t=/^#EXT-X-ALLOW-CACHE:(YES|NO)?/.exec(s),t){n={type:"tag",tagType:"allow-cache"},t[1]&&(n.allowed=!/NO/.test(t[1])),this.trigger("data",n);return}if(t=/^#EXT-X-MAP:(.*)$/.exec(s),t){if(n={type:"tag",tagType:"map"},t[1]){const r=st(t[1]);r.URI&&(n.uri=r.URI),r.BYTERANGE&&(n.byterange=xa(r.BYTERANGE))}this.trigger("data",n);return}if(t=/^#EXT-X-STREAM-INF:(.*)$/.exec(s),t){n={type:"tag",tagType:"stream-inf"},t[1]&&(n.attributes=st(t[1]),n.attributes.RESOLUTION&&(n.attributes.RESOLUTION=vu(n.attributes.RESOLUTION)),n.attributes.BANDWIDTH&&(n.attributes.BANDWIDTH=parseInt(n.attributes.BANDWIDTH,10)),n.attributes["FRAME-RATE"]&&(n.attributes["FRAME-RATE"]=parseFloat(n.attributes["FRAME-RATE"])),n.attributes["PROGRAM-ID"]&&(n.attributes["PROGRAM-ID"]=parseInt(n.attributes["PROGRAM-ID"],10))),this.trigger("data",n);return}if(t=/^#EXT-X-MEDIA:(.*)$/.exec(s),t){n={type:"tag",tagType:"media"},t[1]&&(n.attributes=st(t[1])),this.trigger("data",n);return}if(t=/^#EXT-X-ENDLIST/.exec(s),t){this.trigger("data",{type:"tag",tagType:"endlist"});return}if(t=/^#EXT-X-DISCONTINUITY/.exec(s),t){this.trigger("data",{type:"tag",tagType:"discontinuity"});return}if(t=/^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(s),t){n={type:"tag",tagType:"program-date-time"},t[1]&&(n.dateTimeString=t[1],n.dateTimeObject=new Date(t[1])),this.trigger("data",n);return}if(t=/^#EXT-X-KEY:(.*)$/.exec(s),t){n={type:"tag",tagType:"key"},t[1]&&(n.attributes=st(t[1]),n.attributes.IV&&(n.attributes.IV.substring(0,2).toLowerCase()==="0x"&&(n.attributes.IV=n.attributes.IV.substring(2)),n.attributes.IV=n.attributes.IV.match(/.{8}/g),n.attributes.IV[0]=parseInt(n.attributes.IV[0],16),n.attributes.IV[1]=parseInt(n.attributes.IV[1],16),n.attributes.IV[2]=parseInt(n.attributes.IV[2],16),n.attributes.IV[3]=parseInt(n.attributes.IV[3],16),n.attributes.IV=new Uint32Array(n.attributes.IV))),this.trigger("data",n);return}if(t=/^#EXT-X-START:(.*)$/.exec(s),t){n={type:"tag",tagType:"start"},t[1]&&(n.attributes=st(t[1]),n.attributes["TIME-OFFSET"]=parseFloat(n.attributes["TIME-OFFSET"]),n.attributes.PRECISE=/YES/.test(n.attributes.PRECISE)),this.trigger("data",n);return}if(t=/^#EXT-X-CUE-OUT-CONT:(.*)?$/.exec(s),t){n={type:"tag",tagType:"cue-out-cont"},t[1]?n.data=t[1]:n.data="",this.trigger("data",n);return}if(t=/^#EXT-X-CUE-OUT:(.*)?$/.exec(s),t){n={type:"tag",tagType:"cue-out"},t[1]?n.data=t[1]:n.data="",this.trigger("data",n);return}if(t=/^#EXT-X-CUE-IN:?(.*)?$/.exec(s),t){n={type:"tag",tagType:"cue-in"},t[1]?n.data=t[1]:n.data="",this.trigger("data",n);return}if(t=/^#EXT-X-SKIP:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"skip"},n.attributes=st(t[1]),n.attributes.hasOwnProperty("SKIPPED-SEGMENTS")&&(n.attributes["SKIPPED-SEGMENTS"]=parseInt(n.attributes["SKIPPED-SEGMENTS"],10)),n.attributes.hasOwnProperty("RECENTLY-REMOVED-DATERANGES")&&(n.attributes["RECENTLY-REMOVED-DATERANGES"]=n.attributes["RECENTLY-REMOVED-DATERANGES"].split(e0)),this.trigger("data",n);return}if(t=/^#EXT-X-PART:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"part"},n.attributes=st(t[1]),["DURATION"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=parseFloat(n.attributes[r]))}),["INDEPENDENT","GAP"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=/YES/.test(n.attributes[r]))}),n.attributes.hasOwnProperty("BYTERANGE")&&(n.attributes.byterange=xa(n.attributes.BYTERANGE)),this.trigger("data",n);return}if(t=/^#EXT-X-SERVER-CONTROL:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"server-control"},n.attributes=st(t[1]),["CAN-SKIP-UNTIL","PART-HOLD-BACK","HOLD-BACK"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=parseFloat(n.attributes[r]))}),["CAN-SKIP-DATERANGES","CAN-BLOCK-RELOAD"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=/YES/.test(n.attributes[r]))}),this.trigger("data",n);return}if(t=/^#EXT-X-PART-INF:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"part-inf"},n.attributes=st(t[1]),["PART-TARGET"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=parseFloat(n.attributes[r]))}),this.trigger("data",n);return}if(t=/^#EXT-X-PRELOAD-HINT:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"preload-hint"},n.attributes=st(t[1]),["BYTERANGE-START","BYTERANGE-LENGTH"].forEach(function(r){if(n.attributes.hasOwnProperty(r)){n.attributes[r]=parseInt(n.attributes[r],10);const a=r==="BYTERANGE-LENGTH"?"length":"offset";n.attributes.byterange=n.attributes.byterange||{},n.attributes.byterange[a]=n.attributes[r],delete n.attributes[r]}}),this.trigger("data",n);return}if(t=/^#EXT-X-RENDITION-REPORT:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"rendition-report"},n.attributes=st(t[1]),["LAST-MSN","LAST-PART"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=parseInt(n.attributes[r],10))}),this.trigger("data",n);return}if(t=/^#EXT-X-DATERANGE:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"daterange"},n.attributes=st(t[1]),["ID","CLASS"].forEach(function(a){n.attributes.hasOwnProperty(a)&&(n.attributes[a]=String(n.attributes[a]))}),["START-DATE","END-DATE"].forEach(function(a){n.attributes.hasOwnProperty(a)&&(n.attributes[a]=new Date(n.attributes[a]))}),["DURATION","PLANNED-DURATION"].forEach(function(a){n.attributes.hasOwnProperty(a)&&(n.attributes[a]=parseFloat(n.attributes[a]))}),["END-ON-NEXT"].forEach(function(a){n.attributes.hasOwnProperty(a)&&(n.attributes[a]=/YES/i.test(n.attributes[a]))}),["SCTE35-CMD"," SCTE35-OUT","SCTE35-IN"].forEach(function(a){n.attributes.hasOwnProperty(a)&&(n.attributes[a]=n.attributes[a].toString(16))});const r=/^X-([A-Z]+-)+[A-Z]+$/;for(const a in n.attributes){if(!r.test(a))continue;const l=/[0-9A-Fa-f]{6}/g.test(n.attributes[a]),c=/^\d+(\.\d+)?$/.test(n.attributes[a]);n.attributes[a]=l?n.attributes[a].toString(16):c?parseFloat(n.attributes[a]):String(n.attributes[a])}this.trigger("data",n);return}if(t=/^#EXT-X-INDEPENDENT-SEGMENTS/.exec(s),t){this.trigger("data",{type:"tag",tagType:"independent-segments"});return}if(t=/^#EXT-X-I-FRAMES-ONLY/.exec(s),t){this.trigger("data",{type:"tag",tagType:"i-frames-only"});return}if(t=/^#EXT-X-CONTENT-STEERING:(.*)$/.exec(s),t){n={type:"tag",tagType:"content-steering"},n.attributes=st(t[1]),this.trigger("data",n);return}if(t=/^#EXT-X-I-FRAME-STREAM-INF:(.*)$/.exec(s),t){n={type:"tag",tagType:"i-frame-playlist"},n.attributes=st(t[1]),n.attributes.URI&&(n.uri=n.attributes.URI),n.attributes.BANDWIDTH&&(n.attributes.BANDWIDTH=parseInt(n.attributes.BANDWIDTH,10)),n.attributes.RESOLUTION&&(n.attributes.RESOLUTION=vu(n.attributes.RESOLUTION)),n.attributes["AVERAGE-BANDWIDTH"]&&(n.attributes["AVERAGE-BANDWIDTH"]=parseInt(n.attributes["AVERAGE-BANDWIDTH"],10)),n.attributes["FRAME-RATE"]&&(n.attributes["FRAME-RATE"]=parseFloat(n.attributes["FRAME-RATE"])),this.trigger("data",n);return}if(t=/^#EXT-X-DEFINE:(.*)$/.exec(s),t){n={type:"tag",tagType:"define"},n.attributes=st(t[1]),this.trigger("data",n);return}this.trigger("data",{type:"tag",data:s.slice(4)})})}}addParser({expression:e,customType:t,dataParser:n,segment:s}){typeof n!="function"&&(n=r=>r),this.customParsers.push(r=>{if(e.exec(r))return this.trigger("data",{type:"custom",data:n(r),customType:t,segment:s}),!0})}addTagMapper({expression:e,map:t}){const n=s=>e.test(s)?t(s):s;this.tagMappers.push(n)}}const n0=i=>i.toLowerCase().replace(/-(\w)/g,e=>e[1].toUpperCase()),fi=function(i){const e={};return Object.keys(i).forEach(function(t){e[n0(t)]=i[t]}),e},Aa=function(i){const{serverControl:e,targetDuration:t,partTargetDuration:n}=i;if(!e)return;const s="#EXT-X-SERVER-CONTROL",r="holdBack",a="partHoldBack",l=t&&t*3,c=n&&n*2;t&&!e.hasOwnProperty(r)&&(e[r]=l,this.trigger("info",{message:`${s} defaulting HOLD-BACK to targetDuration * 3 (${l}).`})),l&&e[r]<l&&(this.trigger("warn",{message:`${s} clamping HOLD-BACK (${e[r]}) to targetDuration * 3 (${l})`}),e[r]=l),n&&!e.hasOwnProperty(a)&&(e[a]=n*3,this.trigger("info",{message:`${s} defaulting PART-HOLD-BACK to partTargetDuration * 3 (${e[a]}).`})),n&&e[a]<c&&(this.trigger("warn",{message:`${s} clamping PART-HOLD-BACK (${e[a]}) to partTargetDuration * 2 (${c}).`}),e[a]=c)};class s0 extends Io{constructor(e={}){super(),this.lineStream=new Z_,this.parseStream=new i0,this.lineStream.pipe(this.parseStream),this.mainDefinitions=e.mainDefinitions||{},this.params=new URL(e.uri,"https://a.com").searchParams,this.lastProgramDateTime=null;const t=this,n=[];let s={},r,a,l=!1;const c=function(){},g={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},m="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";let b=0;this.manifest={allowCache:!0,discontinuityStarts:[],dateRanges:[],iFramePlaylists:[],segments:[]};let C=0,w=0;const A={};this.on("end",()=>{s.uri||!s.parts&&!s.preloadHints||(!s.map&&r&&(s.map=r),!s.key&&a&&(s.key=a),!s.timeline&&typeof b=="number"&&(s.timeline=b),this.manifest.preloadSegment=s)}),this.parseStream.on("data",function(v){let M,D;if(t.manifest.definitions){for(const R in t.manifest.definitions)if(v.uri&&(v.uri=v.uri.replace(`{$${R}}`,t.manifest.definitions[R])),v.attributes)for(const N in v.attributes)typeof v.attributes[N]=="string"&&(v.attributes[N]=v.attributes[N].replace(`{$${R}}`,t.manifest.definitions[R]))}({tag(){({version(){v.version&&(this.manifest.version=v.version)},"allow-cache"(){this.manifest.allowCache=v.allowed,"allowed"in v||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange(){const R={};"length"in v&&(s.byterange=R,R.length=v.length,"offset"in v||(v.offset=C)),"offset"in v&&(s.byterange=R,R.offset=v.offset),C=R.offset+R.length},endlist(){this.manifest.endList=!0},inf(){"mediaSequence"in this.manifest||(this.manifest.mediaSequence=0,this.trigger("info",{message:"defaulting media sequence to zero"})),"discontinuitySequence"in this.manifest||(this.manifest.discontinuitySequence=0,this.trigger("info",{message:"defaulting discontinuity sequence to zero"})),v.title&&(s.title=v.title),v.duration>0&&(s.duration=v.duration),v.duration===0&&(s.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=n},key(){if(!v.attributes){this.trigger("warn",{message:"ignoring key declaration without attribute list"});return}if(v.attributes.METHOD==="NONE"){a=null;return}if(!v.attributes.URI){this.trigger("warn",{message:"ignoring key declaration without URI"});return}if(v.attributes.KEYFORMAT==="com.apple.streamingkeydelivery"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.apple.fps.1_0"]={attributes:v.attributes};return}if(v.attributes.KEYFORMAT==="com.microsoft.playready"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.microsoft.playready"]={uri:v.attributes.URI};return}if(v.attributes.KEYFORMAT===m){if(["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(v.attributes.METHOD)===-1){this.trigger("warn",{message:"invalid key method provided for Widevine"});return}if(v.attributes.METHOD==="SAMPLE-AES-CENC"&&this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"}),v.attributes.URI.substring(0,23)!=="data:text/plain;base64,"){this.trigger("warn",{message:"invalid key URI provided for Widevine"});return}if(!(v.attributes.KEYID&&v.attributes.KEYID.substring(0,2)==="0x")){this.trigger("warn",{message:"invalid key ID provided for Widevine"});return}this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.widevine.alpha"]={attributes:{schemeIdUri:v.attributes.KEYFORMAT,keyId:v.attributes.KEYID.substring(2)},pssh:lh(v.attributes.URI.split(",")[1])};return}v.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),a={method:v.attributes.METHOD||"AES-128",uri:v.attributes.URI},typeof v.attributes.IV<"u"&&(a.iv=v.attributes.IV)},"media-sequence"(){if(!isFinite(v.number)){this.trigger("warn",{message:"ignoring invalid media sequence: "+v.number});return}this.manifest.mediaSequence=v.number},"discontinuity-sequence"(){if(!isFinite(v.number)){this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+v.number});return}this.manifest.discontinuitySequence=v.number,b=v.number},"playlist-type"(){if(!/VOD|EVENT/.test(v.playlistType)){this.trigger("warn",{message:"ignoring unknown playlist type: "+v.playlist});return}this.manifest.playlistType=v.playlistType},map(){r={},v.uri&&(r.uri=v.uri),v.byterange&&(r.byterange=v.byterange),a&&(r.key=a)},"stream-inf"(){if(this.manifest.playlists=n,this.manifest.mediaGroups=this.manifest.mediaGroups||g,!v.attributes){this.trigger("warn",{message:"ignoring empty stream-inf attributes"});return}s.attributes||(s.attributes={}),je(s.attributes,v.attributes)},media(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||g,!(v.attributes&&v.attributes.TYPE&&v.attributes["GROUP-ID"]&&v.attributes.NAME)){this.trigger("warn",{message:"ignoring incomplete or missing media group"});return}const R=this.manifest.mediaGroups[v.attributes.TYPE];R[v.attributes["GROUP-ID"]]=R[v.attributes["GROUP-ID"]]||{},M=R[v.attributes["GROUP-ID"]],D={default:/yes/i.test(v.attributes.DEFAULT)},D.default?D.autoselect=!0:D.autoselect=/yes/i.test(v.attributes.AUTOSELECT),v.attributes.LANGUAGE&&(D.language=v.attributes.LANGUAGE),v.attributes.URI&&(D.uri=v.attributes.URI),v.attributes["INSTREAM-ID"]&&(D.instreamId=v.attributes["INSTREAM-ID"]),v.attributes.CHARACTERISTICS&&(D.characteristics=v.attributes.CHARACTERISTICS),v.attributes.FORCED&&(D.forced=/yes/i.test(v.attributes.FORCED)),M[v.attributes.NAME]=D},discontinuity(){b+=1,s.discontinuity=!0,this.manifest.discontinuityStarts.push(n.length)},"program-date-time"(){typeof this.manifest.dateTimeString>"u"&&(this.manifest.dateTimeString=v.dateTimeString,this.manifest.dateTimeObject=v.dateTimeObject),s.dateTimeString=v.dateTimeString,s.dateTimeObject=v.dateTimeObject;const{lastProgramDateTime:R}=this;this.lastProgramDateTime=new Date(v.dateTimeString).getTime(),R===null&&this.manifest.segments.reduceRight((N,F)=>(F.programDateTime=N-F.duration*1e3,F.programDateTime),this.lastProgramDateTime)},targetduration(){if(!isFinite(v.duration)||v.duration<0){this.trigger("warn",{message:"ignoring invalid target duration: "+v.duration});return}this.manifest.targetDuration=v.duration,Aa.call(this,this.manifest)},start(){if(!v.attributes||isNaN(v.attributes["TIME-OFFSET"])){this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"});return}this.manifest.start={timeOffset:v.attributes["TIME-OFFSET"],precise:v.attributes.PRECISE}},"cue-out"(){s.cueOut=v.data},"cue-out-cont"(){s.cueOutCont=v.data},"cue-in"(){s.cueIn=v.data},skip(){this.manifest.skip=fi(v.attributes),this.warnOnMissingAttributes_("#EXT-X-SKIP",v.attributes,["SKIPPED-SEGMENTS"])},part(){l=!0;const R=this.manifest.segments.length,N=fi(v.attributes);s.parts=s.parts||[],s.parts.push(N),N.byterange&&(N.byterange.hasOwnProperty("offset")||(N.byterange.offset=w),w=N.byterange.offset+N.byterange.length);const F=s.parts.length-1;this.warnOnMissingAttributes_(`#EXT-X-PART #${F} for segment #${R}`,v.attributes,["URI","DURATION"]),this.manifest.renditionReports&&this.manifest.renditionReports.forEach((P,$)=>{P.hasOwnProperty("lastPart")||this.trigger("warn",{message:`#EXT-X-RENDITION-REPORT #${$} lacks required attribute(s): LAST-PART`})})},"server-control"(){const R=this.manifest.serverControl=fi(v.attributes);R.hasOwnProperty("canBlockReload")||(R.canBlockReload=!1,this.trigger("info",{message:"#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false"})),Aa.call(this,this.manifest),R.canSkipDateranges&&!R.hasOwnProperty("canSkipUntil")&&this.trigger("warn",{message:"#EXT-X-SERVER-CONTROL lacks required attribute CAN-SKIP-UNTIL which is required when CAN-SKIP-DATERANGES is set"})},"preload-hint"(){const R=this.manifest.segments.length,N=fi(v.attributes),F=N.type&&N.type==="PART";s.preloadHints=s.preloadHints||[],s.preloadHints.push(N),N.byterange&&(N.byterange.hasOwnProperty("offset")||(N.byterange.offset=F?w:0,F&&(w=N.byterange.offset+N.byterange.length)));const P=s.preloadHints.length-1;if(this.warnOnMissingAttributes_(`#EXT-X-PRELOAD-HINT #${P} for segment #${R}`,v.attributes,["TYPE","URI"]),!!N.type)for(let $=0;$<s.preloadHints.length-1;$++){const Y=s.preloadHints[$];Y.type&&Y.type===N.type&&this.trigger("warn",{message:`#EXT-X-PRELOAD-HINT #${P} for segment #${R} has the same TYPE ${N.type} as preload hint #${$}`})}},"rendition-report"(){const R=fi(v.attributes);this.manifest.renditionReports=this.manifest.renditionReports||[],this.manifest.renditionReports.push(R);const N=this.manifest.renditionReports.length-1,F=["LAST-MSN","URI"];l&&F.push("LAST-PART"),this.warnOnMissingAttributes_(`#EXT-X-RENDITION-REPORT #${N}`,v.attributes,F)},"part-inf"(){this.manifest.partInf=fi(v.attributes),this.warnOnMissingAttributes_("#EXT-X-PART-INF",v.attributes,["PART-TARGET"]),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),Aa.call(this,this.manifest)},daterange(){this.manifest.dateRanges.push(fi(v.attributes));const R=this.manifest.dateRanges.length-1;this.warnOnMissingAttributes_(`#EXT-X-DATERANGE #${R}`,v.attributes,["ID","START-DATE"]);const N=this.manifest.dateRanges[R];N.endDate&&N.startDate&&new Date(N.endDate)<new Date(N.startDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE END-DATE must be equal to or later than the value of the START-DATE"}),N.duration&&N.duration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE DURATION must not be negative"}),N.plannedDuration&&N.plannedDuration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE PLANNED-DURATION must not be negative"});const F=!!N.endOnNext;if(F&&!N.class&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must have a CLASS attribute"}),F&&(N.duration||N.endDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must not contain DURATION or END-DATE attributes"}),N.duration&&N.endDate){const P=N.startDate.getTime()+N.duration*1e3;this.manifest.dateRanges[R].endDate=new Date(P)}if(!A[N.id])A[N.id]=N;else{for(const $ in A[N.id])if(N[$]&&JSON.stringify(A[N.id][$])!==JSON.stringify(N[$])){this.trigger("warn",{message:"EXT-X-DATERANGE tags with the same ID in a playlist must have the same attributes values"});break}const P=this.manifest.dateRanges.findIndex($=>$.id===N.id);this.manifest.dateRanges[P]=je(this.manifest.dateRanges[P],N),A[N.id]=je(A[N.id],N),this.manifest.dateRanges.pop()}},"independent-segments"(){this.manifest.independentSegments=!0},"i-frames-only"(){this.manifest.iFramesOnly=!0,this.requiredCompatibilityversion(this.manifest.version,4)},"content-steering"(){this.manifest.contentSteering=fi(v.attributes),this.warnOnMissingAttributes_("#EXT-X-CONTENT-STEERING",v.attributes,["SERVER-URI"])},define(){this.manifest.definitions=this.manifest.definitions||{};const R=(N,F)=>{if(N in this.manifest.definitions){this.trigger("error",{message:`EXT-X-DEFINE: Duplicate name ${N}`});return}this.manifest.definitions[N]=F};if("QUERYPARAM"in v.attributes){if("NAME"in v.attributes||"IMPORT"in v.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}const N=this.params.get(v.attributes.QUERYPARAM);if(!N){this.trigger("error",{message:`EXT-X-DEFINE: No query param ${v.attributes.QUERYPARAM}`});return}R(v.attributes.QUERYPARAM,decodeURIComponent(N));return}if("NAME"in v.attributes){if("IMPORT"in v.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}if(!("VALUE"in v.attributes)||typeof v.attributes.VALUE!="string"){this.trigger("error",{message:`EXT-X-DEFINE: No value for ${v.attributes.NAME}`});return}R(v.attributes.NAME,v.attributes.VALUE);return}if("IMPORT"in v.attributes){if(!this.mainDefinitions[v.attributes.IMPORT]){this.trigger("error",{message:`EXT-X-DEFINE: No value ${v.attributes.IMPORT} to import, or IMPORT used on main playlist`});return}R(v.attributes.IMPORT,this.mainDefinitions[v.attributes.IMPORT]);return}this.trigger("error",{message:"EXT-X-DEFINE: No attribute"})},"i-frame-playlist"(){this.manifest.iFramePlaylists.push({attributes:v.attributes,uri:v.uri,timeline:b}),this.warnOnMissingAttributes_("#EXT-X-I-FRAME-STREAM-INF",v.attributes,["BANDWIDTH","URI"])}}[v.tagType]||c).call(t)},uri(){s.uri=v.uri,n.push(s),this.manifest.targetDuration&&!("duration"in s)&&(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),s.duration=this.manifest.targetDuration),a&&(s.key=a),s.timeline=b,r&&(s.map=r),w=0,this.lastProgramDateTime!==null&&(s.programDateTime=this.lastProgramDateTime,this.lastProgramDateTime+=s.duration*1e3),s={}},comment(){},custom(){v.segment?(s.custom=s.custom||{},s.custom[v.customType]=v.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[v.customType]=v.data)}})[v.type].call(t)})}requiredCompatibilityversion(e,t){(e<t||!e)&&this.trigger("warn",{message:`manifest must be at least version ${t}`})}warnOnMissingAttributes_(e,t,n){const s=[];n.forEach(function(r){t.hasOwnProperty(r)||s.push(r)}),s.length&&this.trigger("warn",{message:`${e} lacks required attribute(s): ${s.join(", ")}`})}push(e){this.lineStream.push(e)}end(){this.lineStream.push(`
|
|
24
|
-
`),this.manifest.dateRanges.length&&this.lastProgramDateTime===null&&this.trigger("warn",{message:"A playlist with EXT-X-DATERANGE tag must contain atleast one EXT-X-PROGRAM-DATE-TIME tag"}),this.lastProgramDateTime=null,this.trigger("end")}addParser(e){this.parseStream.addParser(e)}addTagMapper(e){this.parseStream.addTagMapper(e)}}var Ni={mp4:/^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/,webm:/^(vp0?[89]|av0?1|opus|vorbis)/,ogg:/^(vp0?[89]|theora|flac|opus|vorbis)/,video:/^(av0?1|avc0?[1234]|vp0?[89]|hvc1|hev1|theora|mp4v)/,audio:/^(mp4a|flac|vorbis|opus|ac-[34]|ec-3|alac|mp3|speex|aac)/,text:/^(stpp.ttml.im1t)/,muxerVideo:/^(avc0?1)/,muxerAudio:/^(mp4a)/,muxerText:/a^/},r0=["video","audio","text"],Su=["Video","Audio","Text"],uh=function(i){return i&&i.replace(/avc1\.(\d+)\.(\d+)/i,function(e,t,n){var s=("00"+Number(t).toString(16)).slice(-2),r=("00"+Number(n).toString(16)).slice(-2);return"avc1."+s+"00"+r})},Ht=function(i){i===void 0&&(i="");var e=i.split(","),t=[];return e.forEach(function(n){n=n.trim();var s;r0.forEach(function(r){var a=Ni[r].exec(n.toLowerCase());if(!(!a||a.length<=1)){s=r;var l=n.substring(0,a[1].length),c=n.replace(l,"");t.push({type:l,details:c,mediaType:r})}}),s||t.push({type:n,details:"",mediaType:"unknown"})}),t},a0=function(i,e){if(!i.mediaGroups.AUDIO||!e)return null;var t=i.mediaGroups.AUDIO[e];if(!t)return null;for(var n in t){var s=t[n];if(s.default&&s.playlists)return Ht(s.playlists[0].attributes.CODECS)}return null},dh=function(i){return i===void 0&&(i=""),Ni.audio.test(i.trim().toLowerCase())},o0=function(i){return i===void 0&&(i=""),Ni.text.test(i.trim().toLowerCase())},cn=function(i){if(!(!i||typeof i!="string")){var e=i.toLowerCase().split(",").map(function(s){return uh(s.trim())}),t="video";e.length===1&&dh(e[0])?t="audio":e.length===1&&o0(e[0])&&(t="application");var n="mp4";return e.every(function(s){return Ni.mp4.test(s)})?n="mp4":e.every(function(s){return Ni.webm.test(s)})?n="webm":e.every(function(s){return Ni.ogg.test(s)})&&(n="ogg"),t+"/"+n+';codecs="'+i+'"'}},rs=function(i,e){return i===void 0&&(i=""),e===void 0&&(e=!1),x.MediaSource&&x.MediaSource.isTypeSupported&&x.MediaSource.isTypeSupported(cn(i))||e&&x.ManagedMediaSource&&x.ManagedMediaSource.isTypeSupported&&x.ManagedMediaSource.isTypeSupported(cn(i))||!1},Pa=function(i){return i===void 0&&(i=""),i.toLowerCase().split(",").every(function(e){e=e.trim();for(var t=0;t<Su.length;t++){var n=Su[t];if(Ni["muxer"+n].test(e))return!0}return!1})},Eu="mp4a.40.2",l0="avc1.4d400d",u0=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i,d0=/^application\/dash\+xml/i,hh=function(i){return u0.test(i)?"hls":d0.test(i)?"dash":i==="application/vnd.videojs.vhs+json"?"vhs-json":null},h0=function(i){return i.toString(2).length},c0=function(i){return Math.ceil(h0(i)/8)},ch=function(i){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(i):i&&i.buffer instanceof ArrayBuffer},p0=function(i){return ch(i)},ie=function(i){return i instanceof Uint8Array?i:(!Array.isArray(i)&&!p0(i)&&!(i instanceof ArrayBuffer)&&(typeof i!="number"||typeof i=="number"&&i!==i?i=0:i=[i]),new Uint8Array(i&&i.buffer||i,i&&i.byteOffset||0,i&&i.byteLength||0))},Ke=x.BigInt||Number,Ga=[Ke("0x1"),Ke("0x100"),Ke("0x10000"),Ke("0x1000000"),Ke("0x100000000"),Ke("0x10000000000"),Ke("0x1000000000000"),Ke("0x100000000000000"),Ke("0x10000000000000000")];(function(){var i=new Uint16Array([65484]),e=new Uint8Array(i.buffer,i.byteOffset,i.byteLength);return e[0]===255?"big":e[0]===204?"little":"unknown"})();var f0=function(i,e){var t=e===void 0?{}:e,n=t.signed,s=n===void 0?!1:n,r=t.le,a=r===void 0?!1:r;i=ie(i);var l=a?"reduce":"reduceRight",c=i[l]?i[l]:Array.prototype[l],g=c.call(i,function(b,C,w){var A=a?w:Math.abs(w+1-i.length);return b+Ke(C)*Ga[A]},Ke(0));if(s){var m=Ga[i.length]/Ke(2)-Ke(1);g=Ke(g),g>m&&(g-=m,g-=m,g-=Ke(2))}return Number(g)},g0=function(i,e){var t={},n=t.le,s=n===void 0?!1:n;(typeof i!="bigint"&&typeof i!="number"||typeof i=="number"&&i!==i)&&(i=0),i=Ke(i);for(var r=c0(i),a=new Uint8Array(new ArrayBuffer(r)),l=0;l<r;l++){var c=s?l:Math.abs(l+1-a.length);a[c]=Number(i/Ga[l]&Ke(255)),i<0&&(a[c]=Math.abs(~a[c]),a[c]-=l===0?1:2)}return a},ph=function(i,e){if(typeof i!="string"&&i&&typeof i.toString=="function"&&(i=i.toString()),typeof i!="string")return new Uint8Array;e||(i=unescape(encodeURIComponent(i)));for(var t=new Uint8Array(i.length),n=0;n<i.length;n++)t[n]=i.charCodeAt(n);return t},m0=function(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];if(e=e.filter(function(a){return a&&(a.byteLength||a.length)&&typeof a!="string"}),e.length<=1)return ie(e[0]);var n=e.reduce(function(a,l,c){return a+(l.byteLength||l.length)},0),s=new Uint8Array(n),r=0;return e.forEach(function(a){a=ie(a),s.set(a,r),r+=a.byteLength}),s},Le=function(i,e,t){var n=t===void 0?{}:t,s=n.offset,r=s===void 0?0:s,a=n.mask,l=a===void 0?[]:a;i=ie(i),e=ie(e);var c=e.every?e.every:Array.prototype.every;return e.length&&i.length-r>=e.length&&c.call(e,function(g,m){var b=l[m]?l[m]&i[r+m]:i[r+m];return g===b})},y0=function(i,e,t){e.forEach(function(n){for(var s in i.mediaGroups[n])for(var r in i.mediaGroups[n][s]){var a=i.mediaGroups[n][s][r];t(a,n,s,r)}})};/*! @name mpd-parser @version 1.3.1 @license Apache-2.0 */const wu=i=>!!i&&typeof i=="object",Ge=(...i)=>i.reduce((e,t)=>(typeof t!="object"||Object.keys(t).forEach(n=>{Array.isArray(e[n])&&Array.isArray(t[n])?e[n]=e[n].concat(t[n]):wu(e[n])&&wu(t[n])?e[n]=Ge(e[n],t[n]):e[n]=t[n]}),e),{}),fh=i=>Object.keys(i).map(e=>i[e]),_0=(i,e)=>{const t=[];for(let n=i;n<e;n++)t.push(n);return t},pn=i=>i.reduce((e,t)=>e.concat(t),[]),gh=i=>{if(!i.length)return[];const e=[];for(let t=0;t<i.length;t++)e.push(i[t]);return e},b0=(i,e)=>i.reduce((t,n,s)=>(n[e]&&t.push(s),t),[]),T0=(i,e)=>fh(i.reduce((t,n)=>(n.forEach(s=>{t[e(s)]=s}),t),{}));var fn={INVALID_NUMBER_OF_PERIOD:"INVALID_NUMBER_OF_PERIOD",INVALID_NUMBER_OF_CONTENT_STEERING:"INVALID_NUMBER_OF_CONTENT_STEERING",DASH_EMPTY_MANIFEST:"DASH_EMPTY_MANIFEST",DASH_INVALID_XML:"DASH_INVALID_XML",NO_BASE_URL:"NO_BASE_URL",MISSING_SEGMENT_INFORMATION:"MISSING_SEGMENT_INFORMATION",SEGMENT_TIME_UNSPECIFIED:"SEGMENT_TIME_UNSPECIFIED",UNSUPPORTED_UTC_TIMING_SCHEME:"UNSUPPORTED_UTC_TIMING_SCHEME"};const hs=({baseUrl:i="",source:e="",range:t="",indexRange:n=""})=>{const s={uri:e,resolvedUri:Mr(i||"",e)};if(t||n){const r=(t||n).split("-");let a=x.BigInt?x.BigInt(r[0]):parseInt(r[0],10),l=x.BigInt?x.BigInt(r[1]):parseInt(r[1],10);a<Number.MAX_SAFE_INTEGER&&typeof a=="bigint"&&(a=Number(a)),l<Number.MAX_SAFE_INTEGER&&typeof l=="bigint"&&(l=Number(l));let c;typeof l=="bigint"||typeof a=="bigint"?c=x.BigInt(l)-x.BigInt(a)+x.BigInt(1):c=l-a+1,typeof c=="bigint"&&c<Number.MAX_SAFE_INTEGER&&(c=Number(c)),s.byterange={length:c,offset:a}}return s},v0=i=>{let e;return typeof i.offset=="bigint"||typeof i.length=="bigint"?e=x.BigInt(i.offset)+x.BigInt(i.length)-x.BigInt(1):e=i.offset+i.length-1,`${i.offset}-${e}`},ku=i=>(i&&typeof i!="number"&&(i=parseInt(i,10)),isNaN(i)?null:i),S0={static(i){const{duration:e,timescale:t=1,sourceDuration:n,periodDuration:s}=i,r=ku(i.endNumber),a=e/t;return typeof r=="number"?{start:0,end:r}:typeof s=="number"?{start:0,end:s/a}:{start:0,end:n/a}},dynamic(i){const{NOW:e,clientOffset:t,availabilityStartTime:n,timescale:s=1,duration:r,periodStart:a=0,minimumUpdatePeriod:l=0,timeShiftBufferDepth:c=1/0}=i,g=ku(i.endNumber),m=(e+t)/1e3,b=n+a,C=m+l-b,w=Math.ceil(C*s/r),A=Math.floor((m-b-c)*s/r),v=Math.floor((m-b)*s/r);return{start:Math.max(0,A),end:typeof g=="number"?g:Math.min(w,v)}}},E0=i=>e=>{const{duration:t,timescale:n=1,periodStart:s,startNumber:r=1}=i;return{number:r+e,duration:t/n,timeline:s,time:e*t}},Ao=i=>{const{type:e,duration:t,timescale:n=1,periodDuration:s,sourceDuration:r}=i,{start:a,end:l}=S0[e](i),c=_0(a,l).map(E0(i));if(e==="static"){const g=c.length-1,m=typeof s=="number"?s:r;c[g].duration=m-t/n*g}return c},mh=i=>{const{baseUrl:e,initialization:t={},sourceDuration:n,indexRange:s="",periodStart:r,presentationTime:a,number:l=0,duration:c}=i;if(!e)throw new Error(fn.NO_BASE_URL);const g=hs({baseUrl:e,source:t.sourceURL,range:t.range}),m=hs({baseUrl:e,source:e,indexRange:s});if(m.map=g,c){const b=Ao(i);b.length&&(m.duration=b[0].duration,m.timeline=b[0].timeline)}else n&&(m.duration=n,m.timeline=r);return m.presentationTime=a||r,m.number=l,[m]},Po=(i,e,t)=>{const n=i.sidx.map?i.sidx.map:null,s=i.sidx.duration,r=i.timeline||0,a=i.sidx.byterange,l=a.offset+a.length,c=e.timescale,g=e.references.filter(M=>M.referenceType!==1),m=[],b=i.endList?"static":"dynamic",C=i.sidx.timeline;let w=C,A=i.mediaSequence||0,v;typeof e.firstOffset=="bigint"?v=x.BigInt(l)+e.firstOffset:v=l+e.firstOffset;for(let M=0;M<g.length;M++){const D=e.references[M],R=D.referencedSize,N=D.subsegmentDuration;let F;typeof v=="bigint"?F=v+x.BigInt(R)-x.BigInt(1):F=v+R-1;const P=`${v}-${F}`,$=mh({baseUrl:t,timescale:c,timeline:r,periodStart:C,presentationTime:w,number:A,duration:N,sourceDuration:s,indexRange:P,type:b})[0];n&&($.map=n),m.push($),typeof v=="bigint"?v+=x.BigInt(R):v+=R,w+=N/c,A++}return i.segments=m,i},w0=["AUDIO","SUBTITLES"],k0=1/60,yh=i=>T0(i,({timeline:e})=>e).sort((e,t)=>e.timeline>t.timeline?1:-1),C0=(i,e)=>{for(let t=0;t<i.length;t++)if(i[t].attributes.NAME===e)return i[t];return null},Cu=i=>{let e=[];return y0(i,w0,(t,n,s,r)=>{e=e.concat(t.playlists||[])}),e},Iu=({playlist:i,mediaSequence:e})=>{i.mediaSequence=e,i.segments.forEach((t,n)=>{t.number=i.mediaSequence+n})},I0=({oldPlaylists:i,newPlaylists:e,timelineStarts:t})=>{e.forEach(n=>{n.discontinuitySequence=t.findIndex(function({timeline:l}){return l===n.timeline});const s=C0(i,n.attributes.NAME);if(!s||n.sidx)return;const r=n.segments[0],a=s.segments.findIndex(function(l){return Math.abs(l.presentationTime-r.presentationTime)<k0});if(a===-1){Iu({playlist:n,mediaSequence:s.mediaSequence+s.segments.length}),n.segments[0].discontinuity=!0,n.discontinuityStarts.unshift(0),(!s.segments.length&&n.timeline>s.timeline||s.segments.length&&n.timeline>s.segments[s.segments.length-1].timeline)&&n.discontinuitySequence--;return}s.segments[a].discontinuity&&!r.discontinuity&&(r.discontinuity=!0,n.discontinuityStarts.unshift(0),n.discontinuitySequence--),Iu({playlist:n,mediaSequence:s.segments[a].number})})},x0=({oldManifest:i,newManifest:e})=>{const t=i.playlists.concat(Cu(i)),n=e.playlists.concat(Cu(e));return e.timelineStarts=yh([i.timelineStarts,e.timelineStarts]),I0({oldPlaylists:t,newPlaylists:n,timelineStarts:e.timelineStarts}),e},Ur=i=>i&&i.uri+"-"+v0(i.byterange),La=i=>{const e=i.reduce(function(n,s){return n[s.attributes.baseUrl]||(n[s.attributes.baseUrl]=[]),n[s.attributes.baseUrl].push(s),n},{});let t=[];return Object.values(e).forEach(n=>{const s=fh(n.reduce((r,a)=>{const l=a.attributes.id+(a.attributes.lang||"");return r[l]?(a.segments&&(a.segments[0]&&(a.segments[0].discontinuity=!0),r[l].segments.push(...a.segments)),a.attributes.contentProtection&&(r[l].attributes.contentProtection=a.attributes.contentProtection)):(r[l]=a,r[l].attributes.timelineStarts=[]),r[l].attributes.timelineStarts.push({start:a.attributes.periodStart,timeline:a.attributes.periodStart}),r},{}));t=t.concat(s)}),t.map(n=>(n.discontinuityStarts=b0(n.segments||[],"discontinuity"),n))},Lo=(i,e)=>{const t=Ur(i.sidx),n=t&&e[t]&&e[t].sidx;return n&&Po(i,n,i.sidx.resolvedUri),i},A0=(i,e={})=>{if(!Object.keys(e).length)return i;for(const t in i)i[t]=Lo(i[t],e);return i},P0=({attributes:i,segments:e,sidx:t,mediaSequence:n,discontinuitySequence:s,discontinuityStarts:r},a)=>{const l={attributes:{NAME:i.id,BANDWIDTH:i.bandwidth,CODECS:i.codecs,"PROGRAM-ID":1},uri:"",endList:i.type==="static",timeline:i.periodStart,resolvedUri:i.baseUrl||"",targetDuration:i.duration,discontinuitySequence:s,discontinuityStarts:r,timelineStarts:i.timelineStarts,mediaSequence:n,segments:e};return i.contentProtection&&(l.contentProtection=i.contentProtection),i.serviceLocation&&(l.attributes.serviceLocation=i.serviceLocation),t&&(l.sidx=t),a&&(l.attributes.AUDIO="audio",l.attributes.SUBTITLES="subs"),l},L0=({attributes:i,segments:e,mediaSequence:t,discontinuityStarts:n,discontinuitySequence:s})=>{typeof e>"u"&&(e=[{uri:i.baseUrl,timeline:i.periodStart,resolvedUri:i.baseUrl||"",duration:i.sourceDuration,number:0}],i.duration=i.sourceDuration);const r={NAME:i.id,BANDWIDTH:i.bandwidth,"PROGRAM-ID":1};i.codecs&&(r.CODECS=i.codecs);const a={attributes:r,uri:"",endList:i.type==="static",timeline:i.periodStart,resolvedUri:i.baseUrl||"",targetDuration:i.duration,timelineStarts:i.timelineStarts,discontinuityStarts:n,discontinuitySequence:s,mediaSequence:t,segments:e};return i.serviceLocation&&(a.attributes.serviceLocation=i.serviceLocation),a},D0=(i,e={},t=!1)=>{let n;const s=i.reduce((r,a)=>{const l=a.attributes.role&&a.attributes.role.value||"",c=a.attributes.lang||"";let g=a.attributes.label||"main";if(c&&!a.attributes.label){const b=l?` (${l})`:"";g=`${a.attributes.lang}${b}`}r[g]||(r[g]={language:c,autoselect:!0,default:l==="main",playlists:[],uri:""});const m=Lo(P0(a,t),e);return r[g].playlists.push(m),typeof n>"u"&&l==="main"&&(n=a,n.default=!0),r},{});if(!n){const r=Object.keys(s)[0];s[r].default=!0}return s},O0=(i,e={})=>i.reduce((t,n)=>{const s=n.attributes.label||n.attributes.lang||"text",r=n.attributes.lang||"und";return t[s]||(t[s]={language:r,default:!1,autoselect:!1,playlists:[],uri:""}),t[s].playlists.push(Lo(L0(n),e)),t},{}),M0=i=>i.reduce((e,t)=>(t&&t.forEach(n=>{const{channel:s,language:r}=n;e[r]={autoselect:!1,default:!1,instreamId:s,language:r},n.hasOwnProperty("aspectRatio")&&(e[r].aspectRatio=n.aspectRatio),n.hasOwnProperty("easyReader")&&(e[r].easyReader=n.easyReader),n.hasOwnProperty("3D")&&(e[r]["3D"]=n["3D"])}),e),{}),R0=({attributes:i,segments:e,sidx:t,discontinuityStarts:n})=>{const s={attributes:{NAME:i.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:i.width,height:i.height},CODECS:i.codecs,BANDWIDTH:i.bandwidth,"PROGRAM-ID":1},uri:"",endList:i.type==="static",timeline:i.periodStart,resolvedUri:i.baseUrl||"",targetDuration:i.duration,discontinuityStarts:n,timelineStarts:i.timelineStarts,segments:e};return i.frameRate&&(s.attributes["FRAME-RATE"]=i.frameRate),i.contentProtection&&(s.contentProtection=i.contentProtection),i.serviceLocation&&(s.attributes.serviceLocation=i.serviceLocation),t&&(s.sidx=t),s},U0=({attributes:i})=>i.mimeType==="video/mp4"||i.mimeType==="video/webm"||i.contentType==="video",N0=({attributes:i})=>i.mimeType==="audio/mp4"||i.mimeType==="audio/webm"||i.contentType==="audio",B0=({attributes:i})=>i.mimeType==="text/vtt"||i.contentType==="text",F0=(i,e)=>{i.forEach(t=>{t.mediaSequence=0,t.discontinuitySequence=e.findIndex(function({timeline:n}){return n===t.timeline}),t.segments&&t.segments.forEach((n,s)=>{n.number=s})})},xu=i=>i?Object.keys(i).reduce((e,t)=>{const n=i[t];return e.concat(n.playlists)},[]):[],j0=({dashPlaylists:i,locations:e,contentSteering:t,sidxMapping:n={},previousManifest:s,eventStream:r})=>{if(!i.length)return{};const{sourceDuration:a,type:l,suggestedPresentationDelay:c,minimumUpdatePeriod:g}=i[0].attributes,m=La(i.filter(U0)).map(R0),b=La(i.filter(N0)),C=La(i.filter(B0)),w=i.map(F=>F.attributes.captionServices).filter(Boolean),A={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:"",duration:a,playlists:A0(m,n)};g>=0&&(A.minimumUpdatePeriod=g*1e3),e&&(A.locations=e),t&&(A.contentSteering=t),l==="dynamic"&&(A.suggestedPresentationDelay=c),r&&r.length>0&&(A.eventStream=r);const v=A.playlists.length===0,M=b.length?D0(b,n,v):null,D=C.length?O0(C,n):null,R=m.concat(xu(M),xu(D)),N=R.map(({timelineStarts:F})=>F);return A.timelineStarts=yh(N),F0(R,A.timelineStarts),M&&(A.mediaGroups.AUDIO.audio=M),D&&(A.mediaGroups.SUBTITLES.subs=D),w.length&&(A.mediaGroups["CLOSED-CAPTIONS"].cc=M0(w)),s?x0({oldManifest:s,newManifest:A}):A},$0=(i,e,t)=>{const{NOW:n,clientOffset:s,availabilityStartTime:r,timescale:a=1,periodStart:l=0,minimumUpdatePeriod:c=0}=i,g=(n+s)/1e3,m=r+l,b=g+c-m;return Math.ceil((b*a-e)/t)},_h=(i,e)=>{const{type:t,minimumUpdatePeriod:n=0,media:s="",sourceDuration:r,timescale:a=1,startNumber:l=1,periodStart:c}=i,g=[];let m=-1;for(let b=0;b<e.length;b++){const C=e[b],w=C.d,A=C.r||0,v=C.t||0;m<0&&(m=v),v&&v>m&&(m=v);let M;if(A<0){const N=b+1;N===e.length?t==="dynamic"&&n>0&&s.indexOf("$Number$")>0?M=$0(i,m,w):M=(r*a-m)/w:M=(e[N].t-m)/w}else M=A+1;const D=l+g.length+M;let R=l+g.length;for(;R<D;)g.push({number:R,duration:w/a,time:m,timeline:c}),m+=w,R++}return g},q0=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,V0=i=>(e,t,n,s)=>{if(e==="$$")return"$";if(typeof i[t]>"u")return e;const r=""+i[t];return t==="RepresentationID"||(n?s=parseInt(s,10):s=1,r.length>=s)?r:`${new Array(s-r.length+1).join("0")}${r}`},Au=(i,e)=>i.replace(q0,V0(e)),H0=(i,e)=>!i.duration&&!e?[{number:i.startNumber||1,duration:i.sourceDuration,time:0,timeline:i.periodStart}]:i.duration?Ao(i):_h(i,e),z0=(i,e)=>{const t={RepresentationID:i.id,Bandwidth:i.bandwidth||0},{initialization:n={sourceURL:"",range:""}}=i,s=hs({baseUrl:i.baseUrl,source:Au(n.sourceURL,t),range:n.range});return H0(i,e).map(r=>{t.Number=r.number,t.Time=r.time;const a=Au(i.media||"",t),l=i.timescale||1,c=i.presentationTimeOffset||0,g=i.periodStart+(r.time-c)/l;return{uri:a,timeline:r.timeline,duration:r.duration,resolvedUri:Mr(i.baseUrl||"",a),map:s,number:r.number,presentationTime:g}})},W0=(i,e)=>{const{baseUrl:t,initialization:n={}}=i,s=hs({baseUrl:t,source:n.sourceURL,range:n.range}),r=hs({baseUrl:t,source:e.media,range:e.mediaRange});return r.map=s,r},G0=(i,e)=>{const{duration:t,segmentUrls:n=[],periodStart:s}=i;if(!t&&!e||t&&e)throw new Error(fn.SEGMENT_TIME_UNSPECIFIED);const r=n.map(l=>W0(i,l));let a;return t&&(a=Ao(i)),e&&(a=_h(i,e)),a.map((l,c)=>{if(r[c]){const g=r[c],m=i.timescale||1,b=i.presentationTimeOffset||0;return g.timeline=l.timeline,g.duration=l.duration,g.number=l.number,g.presentationTime=s+(l.time-b)/m,g}}).filter(l=>l)},X0=({attributes:i,segmentInfo:e})=>{let t,n;e.template?(n=z0,t=Ge(i,e.template)):e.base?(n=mh,t=Ge(i,e.base)):e.list&&(n=G0,t=Ge(i,e.list));const s={attributes:i};if(!n)return s;const r=n(t,e.segmentTimeline);if(t.duration){const{duration:a,timescale:l=1}=t;t.duration=a/l}else r.length?t.duration=r.reduce((a,l)=>Math.max(a,Math.ceil(l.duration)),0):t.duration=0;return s.attributes=t,s.segments=r,e.base&&t.indexRange&&(s.sidx=r[0],s.segments=[]),s},K0=i=>i.map(X0),De=(i,e)=>gh(i.childNodes).filter(({tagName:t})=>t===e),ms=i=>i.textContent.trim(),Y0=i=>parseFloat(i.split("/").reduce((e,t)=>e/t)),Qi=i=>{const e=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(i);if(!e)return 0;const[t,n,s,r,a,l]=e.slice(1);return parseFloat(t||0)*31536e3+parseFloat(n||0)*2592e3+parseFloat(s||0)*86400+parseFloat(r||0)*3600+parseFloat(a||0)*60+parseFloat(l||0)},Q0=i=>(/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(i)&&(i+="Z"),Date.parse(i)),Pu={mediaPresentationDuration(i){return Qi(i)},availabilityStartTime(i){return Q0(i)/1e3},minimumUpdatePeriod(i){return Qi(i)},suggestedPresentationDelay(i){return Qi(i)},type(i){return i},timeShiftBufferDepth(i){return Qi(i)},start(i){return Qi(i)},width(i){return parseInt(i,10)},height(i){return parseInt(i,10)},bandwidth(i){return parseInt(i,10)},frameRate(i){return Y0(i)},startNumber(i){return parseInt(i,10)},timescale(i){return parseInt(i,10)},presentationTimeOffset(i){return parseInt(i,10)},duration(i){const e=parseInt(i,10);return isNaN(e)?Qi(i):e},d(i){return parseInt(i,10)},t(i){return parseInt(i,10)},r(i){return parseInt(i,10)},presentationTime(i){return parseInt(i,10)},DEFAULT(i){return i}},qe=i=>i&&i.attributes?gh(i.attributes).reduce((e,t)=>{const n=Pu[t.name]||Pu.DEFAULT;return e[t.name]=n(t.value),e},{}):{},J0={"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb":"com.adobe.primetime","urn:mpeg:dash:mp4protection:2011":"mp4protection"},Nr=(i,e)=>e.length?pn(i.map(function(t){return e.map(function(n){const s=ms(n),r=Mr(t.baseUrl,s),a=Ge(qe(n),{baseUrl:r});return r!==s&&!a.serviceLocation&&t.serviceLocation&&(a.serviceLocation=t.serviceLocation),a})})):i,Do=i=>{const e=De(i,"SegmentTemplate")[0],t=De(i,"SegmentList")[0],n=t&&De(t,"SegmentURL").map(b=>Ge({tag:"SegmentURL"},qe(b))),s=De(i,"SegmentBase")[0],r=t||e,a=r&&De(r,"SegmentTimeline")[0],l=t||s||e,c=l&&De(l,"Initialization")[0],g=e&&qe(e);g&&c?g.initialization=c&&qe(c):g&&g.initialization&&(g.initialization={sourceURL:g.initialization});const m={template:g,segmentTimeline:a&&De(a,"S").map(b=>qe(b)),list:t&&Ge(qe(t),{segmentUrls:n,initialization:qe(c)}),base:s&&Ge(qe(s),{initialization:qe(c)})};return Object.keys(m).forEach(b=>{m[b]||delete m[b]}),m},Z0=(i,e,t)=>n=>{const s=De(n,"BaseURL"),r=Nr(e,s),a=Ge(i,qe(n)),l=Do(n);return r.map(c=>({segmentInfo:Ge(t,l),attributes:Ge(a,c)}))},e1=i=>i.reduce((e,t)=>{const n=qe(t);n.schemeIdUri&&(n.schemeIdUri=n.schemeIdUri.toLowerCase());const s=J0[n.schemeIdUri];if(s){e[s]={attributes:n};const r=De(t,"cenc:pssh")[0];if(r){const a=ms(r);e[s].pssh=a&&lh(a)}}return e},{}),t1=i=>{if(i.schemeIdUri==="urn:scte:dash:cc:cea-608:2015")return(typeof i.value!="string"?[]:i.value.split(";")).map(e=>{let t,n;return n=e,/^CC\d=/.test(e)?[t,n]=e.split("="):/^CC\d$/.test(e)&&(t=e),{channel:t,language:n}});if(i.schemeIdUri==="urn:scte:dash:cc:cea-708:2015")return(typeof i.value!="string"?[]:i.value.split(";")).map(e=>{const t={channel:void 0,language:void 0,aspectRatio:1,easyReader:0,"3D":0};if(/=/.test(e)){const[n,s=""]=e.split("=");t.channel=n,t.language=e,s.split(",").forEach(r=>{const[a,l]=r.split(":");a==="lang"?t.language=l:a==="er"?t.easyReader=Number(l):a==="war"?t.aspectRatio=Number(l):a==="3D"&&(t["3D"]=Number(l))})}else t.language=e;return t.channel&&(t.channel="SERVICE"+t.channel),t})},i1=i=>pn(De(i.node,"EventStream").map(e=>{const t=qe(e),n=t.schemeIdUri;return De(e,"Event").map(s=>{const r=qe(s),a=r.presentationTime||0,l=t.timescale||1,c=r.duration||0,g=a/l+i.attributes.start;return{schemeIdUri:n,value:t.value,id:r.id,start:g,end:g+c/l,messageData:ms(s)||r.messageData,contentEncoding:t.contentEncoding,presentationTimeOffset:t.presentationTimeOffset||0}})})),n1=(i,e,t)=>n=>{const s=qe(n),r=Nr(e,De(n,"BaseURL")),a=De(n,"Role")[0],l={role:qe(a)};let c=Ge(i,s,l);const g=De(n,"Accessibility")[0],m=t1(qe(g));m&&(c=Ge(c,{captionServices:m}));const b=De(n,"Label")[0];if(b&&b.childNodes.length){const M=b.childNodes[0].nodeValue.trim();c=Ge(c,{label:M})}const C=e1(De(n,"ContentProtection"));Object.keys(C).length&&(c=Ge(c,{contentProtection:C}));const w=Do(n),A=De(n,"Representation"),v=Ge(t,w);return pn(A.map(Z0(c,r,v)))},s1=(i,e)=>(t,n)=>{const s=Nr(e,De(t.node,"BaseURL")),r=Ge(i,{periodStart:t.attributes.start});typeof t.attributes.duration=="number"&&(r.periodDuration=t.attributes.duration);const a=De(t.node,"AdaptationSet"),l=Do(t.node);return pn(a.map(n1(r,s,l)))},r1=(i,e)=>{if(i.length>1&&e({type:"warn",message:"The MPD manifest should contain no more than one ContentSteering tag"}),!i.length)return null;const t=Ge({serverURL:ms(i[0])},qe(i[0]));return t.queryBeforeStart=t.queryBeforeStart==="true",t},a1=({attributes:i,priorPeriodAttributes:e,mpdType:t})=>typeof i.start=="number"?i.start:e&&typeof e.start=="number"&&typeof e.duration=="number"?e.start+e.duration:!e&&t==="static"?0:null,o1=(i,e={})=>{const{manifestUri:t="",NOW:n=Date.now(),clientOffset:s=0,eventHandler:r=function(){}}=e,a=De(i,"Period");if(!a.length)throw new Error(fn.INVALID_NUMBER_OF_PERIOD);const l=De(i,"Location"),c=qe(i),g=Nr([{baseUrl:t}],De(i,"BaseURL")),m=De(i,"ContentSteering");c.type=c.type||"static",c.sourceDuration=c.mediaPresentationDuration||0,c.NOW=n,c.clientOffset=s,l.length&&(c.locations=l.map(ms));const b=[];return a.forEach((C,w)=>{const A=qe(C),v=b[w-1];A.start=a1({attributes:A,priorPeriodAttributes:v?v.attributes:null,mpdType:c.type}),b.push({node:C,attributes:A})}),{locations:c.locations,contentSteeringInfo:r1(m,r),representationInfo:pn(b.map(s1(c,g))),eventStream:pn(b.map(i1))}},bh=i=>{if(i==="")throw new Error(fn.DASH_EMPTY_MANIFEST);const e=new em.D;let t,n;try{t=e.parseFromString(i,"application/xml"),n=t&&t.documentElement.tagName==="MPD"?t.documentElement:null}catch{}if(!n||n&&n.getElementsByTagName("parsererror").length>0)throw new Error(fn.DASH_INVALID_XML);return n},l1=i=>{const e=De(i,"UTCTiming")[0];if(!e)return null;const t=qe(e);switch(t.schemeIdUri){case"urn:mpeg:dash:utc:http-head:2014":case"urn:mpeg:dash:utc:http-head:2012":t.method="HEAD";break;case"urn:mpeg:dash:utc:http-xsdate:2014":case"urn:mpeg:dash:utc:http-iso:2014":case"urn:mpeg:dash:utc:http-xsdate:2012":case"urn:mpeg:dash:utc:http-iso:2012":t.method="GET";break;case"urn:mpeg:dash:utc:direct:2014":case"urn:mpeg:dash:utc:direct:2012":t.method="DIRECT",t.value=Date.parse(t.value);break;case"urn:mpeg:dash:utc:http-ntp:2014":case"urn:mpeg:dash:utc:ntp:2014":case"urn:mpeg:dash:utc:sntp:2014":default:throw new Error(fn.UNSUPPORTED_UTC_TIMING_SCHEME)}return t},u1=(i,e={})=>{const t=o1(bh(i),e),n=K0(t.representationInfo);return j0({dashPlaylists:n,locations:t.locations,contentSteering:t.contentSteeringInfo,sidxMapping:e.sidxMapping,previousManifest:e.previousManifest,eventStream:t.eventStream})},d1=i=>l1(bh(i));var Th=Math.pow(2,32),h1=function(i){var e=new DataView(i.buffer,i.byteOffset,i.byteLength),t;return e.getBigUint64?(t=e.getBigUint64(0),t<Number.MAX_SAFE_INTEGER?Number(t):t):e.getUint32(0)*Th+e.getUint32(4)},c1={getUint64:h1,MAX_UINT32:Th},Lu=c1.getUint64,p1=function(i){var e=new DataView(i.buffer,i.byteOffset,i.byteLength),t={version:i[0],flags:new Uint8Array(i.subarray(1,4)),references:[],referenceId:e.getUint32(4),timescale:e.getUint32(8)},n=12;t.version===0?(t.earliestPresentationTime=e.getUint32(n),t.firstOffset=e.getUint32(n+4),n+=8):(t.earliestPresentationTime=Lu(i.subarray(n)),t.firstOffset=Lu(i.subarray(n+8)),n+=16),n+=2;var s=e.getUint16(n);for(n+=2;s>0;n+=12,s--)t.references.push({referenceType:(i[n]&128)>>>7,referencedSize:e.getUint32(n)&2147483647,subsegmentDuration:e.getUint32(n+4),startsWithSap:!!(i[n+8]&128),sapType:(i[n+8]&112)>>>4,sapDeltaTime:e.getUint32(n+8)&268435455});return t},f1=p1;const g1=gs(f1);var m1=ie([73,68,51]),y1=function(i,e){e===void 0&&(e=0),i=ie(i);var t=i[e+5],n=i[e+6]<<21|i[e+7]<<14|i[e+8]<<7|i[e+9],s=(t&16)>>4;return s?n+20:n+10},ts=function i(e,t){return t===void 0&&(t=0),e=ie(e),e.length-t<10||!Le(e,m1,{offset:t})?t:(t+=y1(e,t),i(e,t))},Du=function(i){return typeof i=="string"?ph(i):i},_1=function(i){return Array.isArray(i)?i.map(function(e){return Du(e)}):[Du(i)]},b1=function i(e,t,n){n===void 0&&(n=!1),t=_1(t),e=ie(e);var s=[];if(!t.length)return s;for(var r=0;r<e.length;){var a=(e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3])>>>0,l=e.subarray(r+4,r+8);if(a===0)break;var c=r+a;if(c>e.length){if(n)break;c=e.length}var g=e.subarray(r+8,c);Le(l,t[0])&&(t.length===1?s.push(g):s.push.apply(s,i(g,t.slice(1),n))),r=c}return s},Ys={EBML:ie([26,69,223,163]),DocType:ie([66,130]),Segment:ie([24,83,128,103]),SegmentInfo:ie([21,73,169,102]),Tracks:ie([22,84,174,107]),Track:ie([174]),TrackNumber:ie([215]),DefaultDuration:ie([35,227,131]),TrackEntry:ie([174]),TrackType:ie([131]),FlagDefault:ie([136]),CodecID:ie([134]),CodecPrivate:ie([99,162]),VideoTrack:ie([224]),AudioTrack:ie([225]),Cluster:ie([31,67,182,117]),Timestamp:ie([231]),TimestampScale:ie([42,215,177]),BlockGroup:ie([160]),BlockDuration:ie([155]),Block:ie([161]),SimpleBlock:ie([163])},Xa=[128,64,32,16,8,4,2,1],T1=function(i){for(var e=1,t=0;t<Xa.length&&!(i&Xa[t]);t++)e++;return e},ur=function(i,e,t,n){t===void 0&&(t=!0),n===void 0&&(n=!1);var s=T1(i[e]),r=i.subarray(e,e+s);return t&&(r=Array.prototype.slice.call(i,e,e+s),r[0]^=Xa[s-1]),{length:s,value:f0(r,{signed:n}),bytes:r}},Ou=function i(e){return typeof e=="string"?e.match(/.{1,2}/g).map(function(t){return i(t)}):typeof e=="number"?g0(e):e},v1=function(i){return Array.isArray(i)?i.map(function(e){return Ou(e)}):[Ou(i)]},S1=function i(e,t,n){if(n>=t.length)return t.length;var s=ur(t,n,!1);if(Le(e.bytes,s.bytes))return n;var r=ur(t,n+s.length);return i(e,t,n+r.length+r.value+s.length)},Mu=function i(e,t){t=v1(t),e=ie(e);var n=[];if(!t.length)return n;for(var s=0;s<e.length;){var r=ur(e,s,!1),a=ur(e,s+r.length),l=s+r.length+a.length;a.value===127&&(a.value=S1(r,e,l),a.value!==e.length&&(a.value-=l));var c=l+a.value>e.length?e.length:l+a.value,g=e.subarray(l,c);Le(t[0],r.bytes)&&(t.length===1?n.push(g):n=n.concat(i(g,t.slice(1))));var m=r.length+a.length+g.length;s+=m}return n},E1=ie([0,0,0,1]),w1=ie([0,0,1]),k1=ie([0,0,3]),C1=function(i){for(var e=[],t=1;t<i.length-2;)Le(i.subarray(t,t+3),k1)&&(e.push(t+2),t++),t++;if(e.length===0)return i;var n=i.length-e.length,s=new Uint8Array(n),r=0;for(t=0;t<n;r++,t++)r===e[0]&&(r++,e.shift()),s[t]=i[r];return s},vh=function(i,e,t,n){i=ie(i),t=[].concat(t);for(var s=0,r,a=0;s<i.length&&(a<n||r);){var l=void 0;if(Le(i.subarray(s),E1)?l=4:Le(i.subarray(s),w1)&&(l=3),!l){s++;continue}if(a++,r)return C1(i.subarray(r,s));var c=void 0;e==="h264"?c=i[s+l]&31:e==="h265"&&(c=i[s+l]>>1&63),t.indexOf(c)!==-1&&(r=s+l),s+=l+(e==="h264"?1:2)}return i.subarray(0,0)},I1=function(i,e,t){return vh(i,"h264",e,t)},x1=function(i,e,t){return vh(i,"h265",e,t)},rt={webm:ie([119,101,98,109]),matroska:ie([109,97,116,114,111,115,107,97]),flac:ie([102,76,97,67]),ogg:ie([79,103,103,83]),ac3:ie([11,119]),riff:ie([82,73,70,70]),avi:ie([65,86,73]),wav:ie([87,65,86,69]),"3gp":ie([102,116,121,112,51,103]),mp4:ie([102,116,121,112]),fmp4:ie([115,116,121,112]),mov:ie([102,116,121,112,113,116]),moov:ie([109,111,111,118]),moof:ie([109,111,111,102])},gn={aac:function(i){var e=ts(i);return Le(i,[255,16],{offset:e,mask:[255,22]})},mp3:function(i){var e=ts(i);return Le(i,[255,2],{offset:e,mask:[255,6]})},webm:function(i){var e=Mu(i,[Ys.EBML,Ys.DocType])[0];return Le(e,rt.webm)},mkv:function(i){var e=Mu(i,[Ys.EBML,Ys.DocType])[0];return Le(e,rt.matroska)},mp4:function(i){if(gn["3gp"](i)||gn.mov(i))return!1;if(Le(i,rt.mp4,{offset:4})||Le(i,rt.fmp4,{offset:4})||Le(i,rt.moof,{offset:4})||Le(i,rt.moov,{offset:4}))return!0},mov:function(i){return Le(i,rt.mov,{offset:4})},"3gp":function(i){return Le(i,rt["3gp"],{offset:4})},ac3:function(i){var e=ts(i);return Le(i,rt.ac3,{offset:e})},ts:function(i){if(i.length<189&&i.length>=1)return i[0]===71;for(var e=0;e+188<i.length&&e<188;){if(i[e]===71&&i[e+188]===71)return!0;e+=1}return!1},flac:function(i){var e=ts(i);return Le(i,rt.flac,{offset:e})},ogg:function(i){return Le(i,rt.ogg)},avi:function(i){return Le(i,rt.riff)&&Le(i,rt.avi,{offset:8})},wav:function(i){return Le(i,rt.riff)&&Le(i,rt.wav,{offset:8})},h264:function(i){return I1(i,7,3).length},h265:function(i){return x1(i,[32,33],3).length}},Ka=Object.keys(gn).filter(function(i){return i!=="ts"&&i!=="h264"&&i!=="h265"}).concat(["ts","h264","h265"]);Ka.forEach(function(i){var e=gn[i];gn[i]=function(t){return e(ie(t))}});var A1=gn,Oo=function(i){i=ie(i);for(var e=0;e<Ka.length;e++){var t=Ka[e];if(A1[t](i))return t}return""},P1=function(i){return b1(i,["moof"]).length>0},Mo=9e4,Ro,Uo,Br,No,Sh,Eh,wh;Ro=function(i){return i*Mo};Uo=function(i,e){return i*e};Br=function(i){return i/Mo};No=function(i,e){return i/e};Sh=function(i,e){return Ro(No(i,e))};Eh=function(i,e){return Uo(Br(i),e)};wh=function(i,e,t){return Br(t?i:i-e)};var Ri={ONE_SECOND_IN_TS:Mo,secondsToVideoTs:Ro,secondsToAudioTs:Uo,videoTsToSeconds:Br,audioTsToSeconds:No,audioTsToVideoTs:Sh,videoTsToAudioTs:Eh,metadataTsToSeconds:wh},Ya="8.21.0";const ii={},Ti=function(i,e){return ii[i]=ii[i]||[],e&&(ii[i]=ii[i].concat(e)),ii[i]},L1=function(i,e){Ti(i,e)},kh=function(i,e){const t=Ti(i).indexOf(e);return t<=-1?!1:(ii[i]=ii[i].slice(),ii[i].splice(t,1),!0)},D1=function(i,e){Ti(i,[].concat(e).map(t=>{const n=(...s)=>(kh(i,n),t(...s));return n}))},dr={prefixed:!0},ir=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror","fullscreen"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"]],Ru=ir[0];let is;for(let i=0;i<ir.length;i++)if(ir[i][1]in G){is=ir[i];break}if(is){for(let i=0;i<is.length;i++)dr[Ru[i]]=is[i];dr.prefixed=is[0]!==Ru[0]}let ct=[];const O1=(i,e,t)=>(n,s,r)=>{const a=e.levels[s],l=new RegExp(`^(${a})$`);let c=i;if(n!=="log"&&r.unshift(n.toUpperCase()+":"),t&&(c=`%c${i}`,r.unshift(t)),r.unshift(c+":"),ct){ct.push([].concat(r));const m=ct.length-1e3;ct.splice(0,m>0?m:0)}if(!x.console)return;let g=x.console[n];!g&&n==="debug"&&(g=x.console.info||x.console.log),!(!g||!a||!l.test(n))&&g[Array.isArray(r)?"apply":"call"](x.console,r)};function Qa(i,e=":",t=""){let n="info",s;function r(...a){s("log",n,a)}return s=O1(i,r,t),r.createLogger=(a,l,c)=>{const g=l!==void 0?l:e,m=c!==void 0?c:t,b=`${i} ${g} ${a}`;return Qa(b,g,m)},r.createNewLogger=(a,l,c)=>Qa(a,l,c),r.levels={all:"debug|log|warn|error",off:"",debug:"debug|log|warn|error",info:"log|warn|error",warn:"warn|error",error:"error",DEFAULT:n},r.level=a=>{if(typeof a=="string"){if(!r.levels.hasOwnProperty(a))throw new Error(`"${a}" in not a valid log level`);n=a}return n},r.history=()=>ct?[].concat(ct):[],r.history.filter=a=>(ct||[]).filter(l=>new RegExp(`.*${a}.*`).test(l[0])),r.history.clear=()=>{ct&&(ct.length=0)},r.history.disable=()=>{ct!==null&&(ct.length=0,ct=null)},r.history.enable=()=>{ct===null&&(ct=[])},r.error=(...a)=>s("error",n,a),r.warn=(...a)=>s("warn",n,a),r.debug=(...a)=>s("debug",n,a),r}const le=Qa("VIDEOJS"),Ch=le.createLogger,M1=Object.prototype.toString,Ih=function(i){return Qt(i)?Object.keys(i):[]};function sn(i,e){Ih(i).forEach(t=>e(i[t],t))}function xh(i,e,t=0){return Ih(i).reduce((n,s)=>e(n,i[s],s),t)}function Qt(i){return!!i&&typeof i=="object"}function mn(i){return Qt(i)&&M1.call(i)==="[object Object]"&&i.constructor===Object}function ve(...i){const e={};return i.forEach(t=>{t&&sn(t,(n,s)=>{if(!mn(n)){e[s]=n;return}mn(e[s])||(e[s]={}),e[s]=ve(e[s],n)})}),e}function Ah(i={}){const e=[];for(const t in i)if(i.hasOwnProperty(t)){const n=i[t];e.push(n)}return e}function Fr(i,e,t,n=!0){const s=a=>Object.defineProperty(i,e,{value:a,enumerable:!0,writable:!0}),r={configurable:!0,enumerable:!0,get(){const a=t();return s(a),a}};return n&&(r.set=s),Object.defineProperty(i,e,r)}var R1=Object.freeze({__proto__:null,each:sn,reduce:xh,isObject:Qt,isPlain:mn,merge:ve,values:Ah,defineLazyProperty:Fr});let Bo=!1,Ph=null,Nt=!1,Lh,Dh=!1,rn=!1,an=!1,Jt=!1,Fo=null,jr=null;const U1=!!(x.cast&&x.cast.framework&&x.cast.framework.CastReceiverContext);let Oh=null,hr=!1,$r=!1,cr=!1,qr=!1,pr=!1,fr=!1,gr=!1;const cs=!!(En()&&("ontouchstart"in x||x.navigator.maxTouchPoints||x.DocumentTouch&&x.document instanceof x.DocumentTouch)),gi=x.navigator&&x.navigator.userAgentData;gi&&gi.platform&&gi.brands&&(Nt=gi.platform==="Android",rn=!!gi.brands.find(i=>i.brand==="Microsoft Edge"),an=!!gi.brands.find(i=>i.brand==="Chromium"),Jt=!rn&&an,Fo=jr=(gi.brands.find(i=>i.brand==="Chromium")||{}).version||null,$r=gi.platform==="Windows");if(!an){const i=x.navigator&&x.navigator.userAgent||"";Bo=/iPod/i.test(i),Ph=function(){const e=i.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),Nt=/Android/i.test(i),Lh=function(){const e=i.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);return t&&n?parseFloat(e[1]+"."+e[2]):t||null}(),Dh=/Firefox/i.test(i),rn=/Edg/i.test(i),an=/Chrome/i.test(i)||/CriOS/i.test(i),Jt=!rn&&an,Fo=jr=function(){const e=i.match(/(Chrome|CriOS)\/(\d+)/);return e&&e[2]?parseFloat(e[2]):null}(),Oh=function(){const e=/MSIE\s(\d+)\.\d/.exec(i);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(i)&&/rv:11.0/.test(i)&&(t=11),t}(),pr=/Tizen/i.test(i),fr=/Web0S/i.test(i),gr=pr||fr,hr=/Safari/i.test(i)&&!Jt&&!Nt&&!rn&&!gr,$r=/Windows/i.test(i),cr=/iPad/i.test(i)||hr&&cs&&!/iPhone/i.test(i),qr=/iPhone/i.test(i)&&!cr}const Je=qr||cr||Bo,Vr=(hr||Je)&&!Jt;var Mh=Object.freeze({__proto__:null,get IS_IPOD(){return Bo},get IOS_VERSION(){return Ph},get IS_ANDROID(){return Nt},get ANDROID_VERSION(){return Lh},get IS_FIREFOX(){return Dh},get IS_EDGE(){return rn},get IS_CHROMIUM(){return an},get IS_CHROME(){return Jt},get CHROMIUM_VERSION(){return Fo},get CHROME_VERSION(){return jr},IS_CHROMECAST_RECEIVER:U1,get IE_VERSION(){return Oh},get IS_SAFARI(){return hr},get IS_WINDOWS(){return $r},get IS_IPAD(){return cr},get IS_IPHONE(){return qr},get IS_TIZEN(){return pr},get IS_WEBOS(){return fr},get IS_SMART_TV(){return gr},TOUCH_ENABLED:cs,IS_IOS:Je,IS_ANY_SAFARI:Vr});function Uu(i){return typeof i=="string"&&!!i.trim()}function N1(i){if(i.indexOf(" ")>=0)throw new Error("class has illegal whitespace characters")}function En(){return G===x.document}function wn(i){return Qt(i)&&i.nodeType===1}function Rh(){try{return x.parent!==x.self}catch{return!0}}function Uh(i){return function(e,t){if(!Uu(e))return G[i](null);Uu(t)&&(t=G.querySelector(t));const n=wn(t)?t:G;return n[i]&&n[i](e)}}function ne(i="div",e={},t={},n){const s=G.createElement(i);return Object.getOwnPropertyNames(e).forEach(function(r){const a=e[r];r==="textContent"?Si(s,a):(s[r]!==a||r==="tabIndex")&&(s[r]=a)}),Object.getOwnPropertyNames(t).forEach(function(r){s.setAttribute(r,t[r])}),n&&jo(s,n),s}function Si(i,e){return typeof i.textContent>"u"?i.innerText=e:i.textContent=e,i}function Ja(i,e){e.firstChild?e.insertBefore(i,e.firstChild):e.appendChild(i)}function as(i,e){return N1(e),i.classList.contains(e)}function Bi(i,...e){return i.classList.add(...e.reduce((t,n)=>t.concat(n.split(/\s+/)),[])),i}function Hr(i,...e){return i?(i.classList.remove(...e.reduce((t,n)=>t.concat(n.split(/\s+/)),[])),i):(le.warn("removeClass was called with an element that doesn't exist"),null)}function Nh(i,e,t){return typeof t=="function"&&(t=t(i,e)),typeof t!="boolean"&&(t=void 0),e.split(/\s+/).forEach(n=>i.classList.toggle(n,t)),i}function Bh(i,e){Object.getOwnPropertyNames(e).forEach(function(t){const n=e[t];n===null||typeof n>"u"||n===!1?i.removeAttribute(t):i.setAttribute(t,n===!0?"":n)})}function _i(i){const e={},t=["autoplay","controls","playsinline","loop","muted","default","defaultMuted"];if(i&&i.attributes&&i.attributes.length>0){const n=i.attributes;for(let s=n.length-1;s>=0;s--){const r=n[s].name;let a=n[s].value;t.includes(r)&&(a=a!==null),e[r]=a}}return e}function Fh(i,e){return i.getAttribute(e)}function yn(i,e,t){i.setAttribute(e,t)}function zr(i,e){i.removeAttribute(e)}function jh(){G.body.focus(),G.onselectstart=function(){return!1}}function $h(){G.onselectstart=function(){return!0}}function _n(i){if(i&&i.getBoundingClientRect&&i.parentNode){const e=i.getBoundingClientRect(),t={};return["bottom","height","left","right","top","width"].forEach(n=>{e[n]!==void 0&&(t[n]=e[n])}),t.height||(t.height=parseFloat(bn(i,"height"))),t.width||(t.width=parseFloat(bn(i,"width"))),t}}function ps(i){if(!i||i&&!i.offsetParent)return{left:0,top:0,width:0,height:0};const e=i.offsetWidth,t=i.offsetHeight;let n=0,s=0;for(;i.offsetParent&&i!==G[dr.fullscreenElement];)n+=i.offsetLeft,s+=i.offsetTop,i=i.offsetParent;return{left:n,top:s,width:e,height:t}}function Wr(i,e){const t={x:0,y:0};if(Je){let m=i;for(;m&&m.nodeName.toLowerCase()!=="html";){const b=bn(m,"transform");if(/^matrix/.test(b)){const C=b.slice(7,-1).split(/,\s/).map(Number);t.x+=C[4],t.y+=C[5]}else if(/^matrix3d/.test(b)){const C=b.slice(9,-1).split(/,\s/).map(Number);t.x+=C[12],t.y+=C[13]}if(m.assignedSlot&&m.assignedSlot.parentElement&&x.WebKitCSSMatrix){const C=x.getComputedStyle(m.assignedSlot.parentElement).transform,w=new x.WebKitCSSMatrix(C);t.x+=w.m41,t.y+=w.m42}m=m.parentNode||m.host}}const n={},s=ps(e.target),r=ps(i),a=r.width,l=r.height;let c=e.offsetY-(r.top-s.top),g=e.offsetX-(r.left-s.left);return e.changedTouches&&(g=e.changedTouches[0].pageX-r.left,c=e.changedTouches[0].pageY+r.top,Je&&(g-=t.x,c-=t.y)),n.y=1-Math.max(0,Math.min(1,c/l)),n.x=Math.max(0,Math.min(1,g/a)),n}function qh(i){return Qt(i)&&i.nodeType===3}function Gr(i){for(;i.firstChild;)i.removeChild(i.firstChild);return i}function Vh(i){return typeof i=="function"&&(i=i()),(Array.isArray(i)?i:[i]).map(e=>{if(typeof e=="function"&&(e=e()),wn(e)||qh(e))return e;if(typeof e=="string"&&/\S/.test(e))return G.createTextNode(e)}).filter(e=>e)}function jo(i,e){return Vh(e).forEach(t=>i.appendChild(t)),i}function Hh(i,e){return jo(Gr(i),e)}function fs(i){return i.button===void 0&&i.buttons===void 0||i.button===0&&i.buttons===void 0||i.type==="mouseup"&&i.button===0&&i.buttons===0||i.type==="mousedown"&&i.button===0&&i.buttons===0?!0:!(i.button!==0||i.buttons!==1)}const vi=Uh("querySelector"),zh=Uh("querySelectorAll");function bn(i,e){if(!i||!e)return"";if(typeof x.getComputedStyle=="function"){let t;try{t=x.getComputedStyle(i)}catch{return""}return t?t.getPropertyValue(e)||t[e]:""}return""}function Wh(i){[...G.styleSheets].forEach(e=>{try{const t=[...e.cssRules].map(s=>s.cssText).join(""),n=G.createElement("style");n.textContent=t,i.document.head.appendChild(n)}catch{const t=G.createElement("link");t.rel="stylesheet",t.type=e.type,t.media=e.media.mediaText,t.href=e.href,i.document.head.appendChild(t)}})}var Gh=Object.freeze({__proto__:null,isReal:En,isEl:wn,isInFrame:Rh,createEl:ne,textContent:Si,prependTo:Ja,hasClass:as,addClass:Bi,removeClass:Hr,toggleClass:Nh,setAttributes:Bh,getAttributes:_i,getAttribute:Fh,setAttribute:yn,removeAttribute:zr,blockTextSelection:jh,unblockTextSelection:$h,getBoundingClientRect:_n,findPosition:ps,getPointerPosition:Wr,isTextNode:qh,emptyEl:Gr,normalizeContent:Vh,appendContent:jo,insertContent:Hh,isSingleLeftClick:fs,$:vi,$$:zh,computedStyle:bn,copyStyleSheetsToWindow:Wh});let Xh=!1,Za;const B1=function(){if(Za.options.autoSetup===!1)return;const i=Array.prototype.slice.call(G.getElementsByTagName("video")),e=Array.prototype.slice.call(G.getElementsByTagName("audio")),t=Array.prototype.slice.call(G.getElementsByTagName("video-js")),n=i.concat(e,t);if(n&&n.length>0)for(let s=0,r=n.length;s<r;s++){const a=n[s];if(a&&a.getAttribute)a.player===void 0&&a.getAttribute("data-setup")!==null&&Za(a);else{eo(1);break}}else Xh||eo(1)};function eo(i,e){En()&&(e&&(Za=e),x.setTimeout(B1,i))}function to(){Xh=!0,x.removeEventListener("load",to)}En()&&(G.readyState==="complete"?to():x.addEventListener("load",to));const Kh=function(i){const e=G.createElement("style");return e.className=i,e},Yh=function(i,e){i.styleSheet?i.styleSheet.cssText=e:i.textContent=e};var lt=new WeakMap;const F1=3;let j1=F1;function At(){return j1++}function Nu(i,e){if(!lt.has(i))return;const t=lt.get(i);t.handlers[e].length===0&&(delete t.handlers[e],i.removeEventListener?i.removeEventListener(e,t.dispatcher,!1):i.detachEvent&&i.detachEvent("on"+e,t.dispatcher)),Object.getOwnPropertyNames(t.handlers).length<=0&&(delete t.handlers,delete t.dispatcher,delete t.disabled),Object.getOwnPropertyNames(t).length===0&<.delete(i)}function $o(i,e,t,n){t.forEach(function(s){i(e,s,n)})}function Xr(i){if(i.fixed_)return i;function e(){return!0}function t(){return!1}if(!i||!i.isPropagationStopped||!i.isImmediatePropagationStopped){const n=i||x.event;i={};const s=["layerX","layerY","keyLocation","path","webkitMovementX","webkitMovementY","mozPressure","mozInputSource"];for(const r in n)s.includes(r)||r==="returnValue"&&n.preventDefault||(i[r]=n[r]);if(i.target||(i.target=i.srcElement||G),i.relatedTarget||(i.relatedTarget=i.fromElement===i.target?i.toElement:i.fromElement),i.preventDefault=function(){n.preventDefault&&n.preventDefault(),i.returnValue=!1,n.returnValue=!1,i.defaultPrevented=!0},i.defaultPrevented=!1,i.stopPropagation=function(){n.stopPropagation&&n.stopPropagation(),i.cancelBubble=!0,n.cancelBubble=!0,i.isPropagationStopped=e},i.isPropagationStopped=t,i.stopImmediatePropagation=function(){n.stopImmediatePropagation&&n.stopImmediatePropagation(),i.isImmediatePropagationStopped=e,i.stopPropagation()},i.isImmediatePropagationStopped=t,i.clientX!==null&&i.clientX!==void 0){const r=G.documentElement,a=G.body;i.pageX=i.clientX+(r&&r.scrollLeft||a&&a.scrollLeft||0)-(r&&r.clientLeft||a&&a.clientLeft||0),i.pageY=i.clientY+(r&&r.scrollTop||a&&a.scrollTop||0)-(r&&r.clientTop||a&&a.clientTop||0)}i.which=i.charCode||i.keyCode,i.button!==null&&i.button!==void 0&&(i.button=i.button&1?0:i.button&4?1:i.button&2?2:0)}return i.fixed_=!0,i}let Qs;const $1=function(){if(typeof Qs!="boolean"){Qs=!1;try{const i=Object.defineProperty({},"passive",{get(){Qs=!0}});x.addEventListener("test",null,i),x.removeEventListener("test",null,i)}catch{}}return Qs},q1=["touchstart","touchmove"];function vt(i,e,t){if(Array.isArray(e))return $o(vt,i,e,t);lt.has(i)||lt.set(i,{});const n=lt.get(i);if(n.handlers||(n.handlers={}),n.handlers[e]||(n.handlers[e]=[]),t.guid||(t.guid=At()),n.handlers[e].push(t),n.dispatcher||(n.disabled=!1,n.dispatcher=function(s,r){if(n.disabled)return;s=Xr(s);const a=n.handlers[s.type];if(a){const l=a.slice(0);for(let c=0,g=l.length;c<g&&!s.isImmediatePropagationStopped();c++)try{l[c].call(i,s,r)}catch(m){le.error(m)}}}),n.handlers[e].length===1)if(i.addEventListener){let s=!1;$1()&&q1.indexOf(e)>-1&&(s={passive:!0}),i.addEventListener(e,n.dispatcher,s)}else i.attachEvent&&i.attachEvent("on"+e,n.dispatcher)}function Ze(i,e,t){if(!lt.has(i))return;const n=lt.get(i);if(!n.handlers)return;if(Array.isArray(e))return $o(Ze,i,e,t);const s=function(a,l){n.handlers[l]=[],Nu(a,l)};if(e===void 0){for(const a in n.handlers)Object.prototype.hasOwnProperty.call(n.handlers||{},a)&&s(i,a);return}const r=n.handlers[e];if(r){if(!t){s(i,e);return}if(t.guid)for(let a=0;a<r.length;a++)r[a].guid===t.guid&&r.splice(a--,1);Nu(i,e)}}function kn(i,e,t){const n=lt.has(i)?lt.get(i):{},s=i.parentNode||i.ownerDocument;if(typeof e=="string"?e={type:e,target:i}:e.target||(e.target=i),e=Xr(e),n.dispatcher&&n.dispatcher.call(i,e,t),s&&!e.isPropagationStopped()&&e.bubbles===!0)kn.call(null,s,e,t);else if(!s&&!e.defaultPrevented&&e.target&&e.target[e.type]){lt.has(e.target)||lt.set(e.target,{});const r=lt.get(e.target);e.target[e.type]&&(r.disabled=!0,typeof e.target[e.type]=="function"&&e.target[e.type](),r.disabled=!1)}return!e.defaultPrevented}function Kr(i,e,t){if(Array.isArray(e))return $o(Kr,i,e,t);const n=function(){Ze(i,e,n),t.apply(this,arguments)};n.guid=t.guid=t.guid||At(),vt(i,e,n)}function qo(i,e,t){const n=function(){Ze(i,e,n),t.apply(this,arguments)};n.guid=t.guid=t.guid||At(),vt(i,e,n)}var V1=Object.freeze({__proto__:null,fixEvent:Xr,on:vt,off:Ze,trigger:kn,one:Kr,any:qo});const Pt=30,Ce=function(i,e,t){e.guid||(e.guid=At());const n=e.bind(i);return n.guid=t?t+"_"+e.guid:e.guid,n},Zt=function(i,e){let t=x.performance.now();return function(...n){const s=x.performance.now();s-t>=e&&(i(...n),t=s)}},Qh=function(i,e,t,n=x){let s;const r=()=>{n.clearTimeout(s),s=null},a=function(){const l=this,c=arguments;let g=function(){s=null,g=null,t||i.apply(l,c)};!s&&t&&i.apply(l,c),n.clearTimeout(s),s=n.setTimeout(g,e)};return a.cancel=r,a};var H1=Object.freeze({__proto__:null,UPDATE_REFRESH_INTERVAL:Pt,bind_:Ce,throttle:Zt,debounce:Qh});let Kn;class St{on(e,t){const n=this.addEventListener;this.addEventListener=()=>{},vt(this,e,t),this.addEventListener=n}off(e,t){Ze(this,e,t)}one(e,t){const n=this.addEventListener;this.addEventListener=()=>{},Kr(this,e,t),this.addEventListener=n}any(e,t){const n=this.addEventListener;this.addEventListener=()=>{},qo(this,e,t),this.addEventListener=n}trigger(e){const t=e.type||e;typeof e=="string"&&(e={type:t}),e=Xr(e),this.allowedEvents_[t]&&this["on"+t]&&this["on"+t](e),kn(this,e)}queueTrigger(e){Kn||(Kn=new Map);const t=e.type||e;let n=Kn.get(this);n||(n=new Map,Kn.set(this,n));const s=n.get(t);n.delete(t),x.clearTimeout(s);const r=x.setTimeout(()=>{n.delete(t),n.size===0&&(n=null,Kn.delete(this)),this.trigger(e)},0);n.set(t,r)}}St.prototype.allowedEvents_={};St.prototype.addEventListener=St.prototype.on;St.prototype.removeEventListener=St.prototype.off;St.prototype.dispatchEvent=St.prototype.trigger;const Yr=i=>typeof i.name=="function"?i.name():typeof i.name=="string"?i.name:i.name_?i.name_:i.constructor&&i.constructor.name?i.constructor.name:typeof i,si=i=>i instanceof St||!!i.eventBusEl_&&["on","one","off","trigger"].every(e=>typeof i[e]=="function"),z1=(i,e)=>{si(i)?e():(i.eventedCallbacks||(i.eventedCallbacks=[]),i.eventedCallbacks.push(e))},io=i=>typeof i=="string"&&/\S/.test(i)||Array.isArray(i)&&!!i.length,mr=(i,e,t)=>{if(!i||!i.nodeName&&!si(i))throw new Error(`Invalid target for ${Yr(e)}#${t}; must be a DOM node or evented object.`)},Jh=(i,e,t)=>{if(!io(i))throw new Error(`Invalid event type for ${Yr(e)}#${t}; must be a non-empty string or array.`)},Zh=(i,e,t)=>{if(typeof i!="function")throw new Error(`Invalid listener for ${Yr(e)}#${t}; must be a function.`)},Da=(i,e,t)=>{const n=e.length<3||e[0]===i||e[0]===i.eventBusEl_;let s,r,a;return n?(s=i.eventBusEl_,e.length>=3&&e.shift(),[r,a]=e):(s=e[0],r=e[1],a=e[2]),mr(s,i,t),Jh(r,i,t),Zh(a,i,t),a=Ce(i,a),{isTargetingSelf:n,target:s,type:r,listener:a}},Di=(i,e,t,n)=>{mr(i,i,e),i.nodeName?V1[e](i,t,n):i[e](t,n)},W1={on(...i){const{isTargetingSelf:e,target:t,type:n,listener:s}=Da(this,i,"on");if(Di(t,"on",n,s),!e){const r=()=>this.off(t,n,s);r.guid=s.guid;const a=()=>this.off("dispose",r);a.guid=s.guid,Di(this,"on","dispose",r),Di(t,"on","dispose",a)}},one(...i){const{isTargetingSelf:e,target:t,type:n,listener:s}=Da(this,i,"one");if(e)Di(t,"one",n,s);else{const r=(...a)=>{this.off(t,n,r),s.apply(null,a)};r.guid=s.guid,Di(t,"one",n,r)}},any(...i){const{isTargetingSelf:e,target:t,type:n,listener:s}=Da(this,i,"any");if(e)Di(t,"any",n,s);else{const r=(...a)=>{this.off(t,n,r),s.apply(null,a)};r.guid=s.guid,Di(t,"any",n,r)}},off(i,e,t){if(!i||io(i))Ze(this.eventBusEl_,i,e);else{const n=i,s=e;mr(n,this,"off"),Jh(s,this,"off"),Zh(t,this,"off"),t=Ce(this,t),this.off("dispose",t),n.nodeName?(Ze(n,s,t),Ze(n,"dispose",t)):si(n)&&(n.off(s,t),n.off("dispose",t))}},trigger(i,e){mr(this.eventBusEl_,this,"trigger");const t=i&&typeof i!="string"?i.type:i;if(!io(t))throw new Error(`Invalid event type for ${Yr(this)}#trigger; must be a non-empty string or object with a type key that has a non-empty value.`);return kn(this.eventBusEl_,i,e)}};function Vo(i,e={}){const{eventBusKey:t}=e;if(t){if(!i[t].nodeName)throw new Error(`The eventBusKey "${t}" does not refer to an element.`);i.eventBusEl_=i[t]}else i.eventBusEl_=ne("span",{className:"vjs-event-bus"});return Object.assign(i,W1),i.eventedCallbacks&&i.eventedCallbacks.forEach(n=>{n()}),i.on("dispose",()=>{i.off(),[i,i.el_,i.eventBusEl_].forEach(function(n){n&<.has(n)&<.delete(n)}),x.setTimeout(()=>{i.eventBusEl_=null},0)}),i}const G1={state:{},setState(i){typeof i=="function"&&(i=i());let e;return sn(i,(t,n)=>{this.state[n]!==t&&(e=e||{},e[n]={from:this.state[n],to:t}),this.state[n]=t}),e&&si(this)&&this.trigger({changes:e,type:"statechanged"}),e}};function ec(i,e){return Object.assign(i,G1),i.state=Object.assign({},i.state,e),typeof i.handleStateChanged=="function"&&si(i)&&i.on("statechanged",i.handleStateChanged),i}const os=function(i){return typeof i!="string"?i:i.replace(/./,e=>e.toLowerCase())},Ne=function(i){return typeof i!="string"?i:i.replace(/./,e=>e.toUpperCase())},tc=function(i,e){return Ne(i)===Ne(e)};var X1=Object.freeze({__proto__:null,toLowerCase:os,toTitleCase:Ne,titleCaseEquals:tc});let H=class ht{constructor(e,t,n){if(!e&&this.play?this.player_=e=this:this.player_=e,this.isDisposed_=!1,this.parentComponent_=null,this.options_=ve({},this.options_),t=this.options_=ve(this.options_,t),this.id_=t.id||t.el&&t.el.id,!this.id_){const s=e&&e.id&&e.id()||"no_player";this.id_=`${s}_component_${At()}`}this.name_=t.name||null,t.el?this.el_=t.el:t.createEl!==!1&&(this.el_=this.createEl()),t.className&&this.el_&&t.className.split(" ").forEach(s=>this.addClass(s)),["on","off","one","any","trigger"].forEach(s=>{this[s]=void 0}),t.evented!==!1&&(Vo(this,{eventBusKey:this.el_?"el_":null}),this.handleLanguagechange=this.handleLanguagechange.bind(this),this.on(this.player_,"languagechange",this.handleLanguagechange)),ec(this,this.constructor.defaultState),this.children_=[],this.childIndex_={},this.childNameIndex_={},this.setTimeoutIds_=new Set,this.setIntervalIds_=new Set,this.rafIds_=new Set,this.namedRafs_=new Map,this.clearingTimersOnDispose_=!1,t.initChildren!==!1&&this.initChildren(),this.ready(n),t.reportTouchActivity!==!1&&this.enableTouchActivity()}dispose(e={}){if(!this.isDisposed_){if(this.readyQueue_&&(this.readyQueue_.length=0),this.trigger({type:"dispose",bubbles:!1}),this.isDisposed_=!0,this.children_)for(let t=this.children_.length-1;t>=0;t--)this.children_[t].dispose&&this.children_[t].dispose();this.children_=null,this.childIndex_=null,this.childNameIndex_=null,this.parentComponent_=null,this.el_&&(this.el_.parentNode&&(e.restoreEl?this.el_.parentNode.replaceChild(e.restoreEl,this.el_):this.el_.parentNode.removeChild(this.el_)),this.el_=null),this.player_=null}}isDisposed(){return!!this.isDisposed_}player(){return this.player_}options(e){return e?(this.options_=ve(this.options_,e),this.options_):this.options_}el(){return this.el_}createEl(e,t,n){return ne(e,t,n)}localize(e,t,n=e){const s=this.player_.language&&this.player_.language(),r=this.player_.languages&&this.player_.languages(),a=r&&r[s],l=s&&s.split("-")[0],c=r&&r[l];let g=n;return a&&a[e]?g=a[e]:c&&c[e]&&(g=c[e]),t&&(g=g.replace(/\{(\d+)\}/g,function(m,b){const C=t[b-1];let w=C;return typeof C>"u"&&(w=m),w})),g}handleLanguagechange(){}contentEl(){return this.contentEl_||this.el_}id(){return this.id_}name(){return this.name_}children(){return this.children_}getChildById(e){return this.childIndex_[e]}getChild(e){if(e)return this.childNameIndex_[e]}getDescendant(...e){e=e.reduce((n,s)=>n.concat(s),[]);let t=this;for(let n=0;n<e.length;n++)if(t=t.getChild(e[n]),!t||!t.getChild)return;return t}setIcon(e,t=this.el()){if(!this.player_.options_.experimentalSvgIcons)return;const n="http://www.w3.org/2000/svg",s=ne("span",{className:"vjs-icon-placeholder vjs-svg-icon"},{"aria-hidden":"true"}),r=G.createElementNS(n,"svg");r.setAttributeNS(null,"viewBox","0 0 512 512");const a=G.createElementNS(n,"use");return r.appendChild(a),a.setAttributeNS(null,"href",`#vjs-icon-${e}`),s.appendChild(r),this.iconIsSet_?t.replaceChild(s,t.querySelector(".vjs-icon-placeholder")):t.appendChild(s),this.iconIsSet_=!0,s}addChild(e,t={},n=this.children_.length){let s,r;if(typeof e=="string"){r=Ne(e);const a=t.componentClass||r;t.name=r;const l=ht.getComponent(a);if(!l)throw new Error(`Component ${a} does not exist`);if(typeof l!="function")return null;s=new l(this.player_||this,t)}else s=e;if(s.parentComponent_&&s.parentComponent_.removeChild(s),this.children_.splice(n,0,s),s.parentComponent_=this,typeof s.id=="function"&&(this.childIndex_[s.id()]=s),r=r||s.name&&Ne(s.name()),r&&(this.childNameIndex_[r]=s,this.childNameIndex_[os(r)]=s),typeof s.el=="function"&&s.el()){let a=null;this.children_[n+1]&&(this.children_[n+1].el_?a=this.children_[n+1].el_:wn(this.children_[n+1])&&(a=this.children_[n+1])),this.contentEl().insertBefore(s.el(),a)}return s}removeChild(e){if(typeof e=="string"&&(e=this.getChild(e)),!e||!this.children_)return;let t=!1;for(let s=this.children_.length-1;s>=0;s--)if(this.children_[s]===e){t=!0,this.children_.splice(s,1);break}if(!t)return;e.parentComponent_=null,this.childIndex_[e.id()]=null,this.childNameIndex_[Ne(e.name())]=null,this.childNameIndex_[os(e.name())]=null;const n=e.el();n&&n.parentNode===this.contentEl()&&this.contentEl().removeChild(e.el())}initChildren(){const e=this.options_.children;if(e){const t=this.options_,n=a=>{const l=a.name;let c=a.opts;if(t[l]!==void 0&&(c=t[l]),c===!1)return;c===!0&&(c={}),c.playerOptions=this.options_.playerOptions;const g=this.addChild(l,c);g&&(this[l]=g)};let s;const r=ht.getComponent("Tech");Array.isArray(e)?s=e:s=Object.keys(e),s.concat(Object.keys(this.options_).filter(function(a){return!s.some(function(l){return typeof l=="string"?a===l:a===l.name})})).map(a=>{let l,c;return typeof a=="string"?(l=a,c=e[l]||this.options_[l]||{}):(l=a.name,c=a),{name:l,opts:c}}).filter(a=>{const l=ht.getComponent(a.opts.componentClass||Ne(a.name));return l&&!r.isTech(l)}).forEach(n)}}buildCSSClass(){return""}ready(e,t=!1){if(e){if(!this.isReady_){this.readyQueue_=this.readyQueue_||[],this.readyQueue_.push(e);return}t?e.call(this):this.setTimeout(e,1)}}triggerReady(){this.isReady_=!0,this.setTimeout(function(){const e=this.readyQueue_;this.readyQueue_=[],e&&e.length>0&&e.forEach(function(t){t.call(this)},this),this.trigger("ready")},1)}$(e,t){return vi(e,t||this.contentEl())}$$(e,t){return zh(e,t||this.contentEl())}hasClass(e){return as(this.el_,e)}addClass(...e){Bi(this.el_,...e)}removeClass(...e){Hr(this.el_,...e)}toggleClass(e,t){Nh(this.el_,e,t)}show(){this.removeClass("vjs-hidden")}hide(){this.addClass("vjs-hidden")}lockShowing(){this.addClass("vjs-lock-showing")}unlockShowing(){this.removeClass("vjs-lock-showing")}getAttribute(e){return Fh(this.el_,e)}setAttribute(e,t){yn(this.el_,e,t)}removeAttribute(e){zr(this.el_,e)}width(e,t){return this.dimension("width",e,t)}height(e,t){return this.dimension("height",e,t)}dimensions(e,t){this.width(e,!0),this.height(t)}dimension(e,t,n){if(t!==void 0){(t===null||t!==t)&&(t=0),(""+t).indexOf("%")!==-1||(""+t).indexOf("px")!==-1?this.el_.style[e]=t:t==="auto"?this.el_.style[e]="":this.el_.style[e]=t+"px",n||this.trigger("componentresize");return}if(!this.el_)return 0;const s=this.el_.style[e],r=s.indexOf("px");return parseInt(r!==-1?s.slice(0,r):this.el_["offset"+Ne(e)],10)}currentDimension(e){let t=0;if(e!=="width"&&e!=="height")throw new Error("currentDimension only accepts width or height value");if(t=bn(this.el_,e),t=parseFloat(t),t===0||isNaN(t)){const n=`offset${Ne(e)}`;t=this.el_[n]}return t}currentDimensions(){return{width:this.currentDimension("width"),height:this.currentDimension("height")}}currentWidth(){return this.currentDimension("width")}currentHeight(){return this.currentDimension("height")}getPositions(){const e=this.el_.getBoundingClientRect(),t={x:e.x,y:e.y,width:e.width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left},n={x:e.left+e.width/2,y:e.top+e.height/2,width:0,height:0,top:e.top+e.height/2,right:e.left+e.width/2,bottom:e.top+e.height/2,left:e.left+e.width/2};return{boundingClientRect:t,center:n}}focus(){this.el_.focus()}blur(){this.el_.blur()}handleKeyDown(e){this.player_&&(e.key!=="Tab"&&!(this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled)&&e.stopPropagation(),this.player_.handleKeyDown(e))}handleKeyPress(e){this.handleKeyDown(e)}emitTapEvents(){let e=0,t=null;const n=10,s=200;let r;this.on("touchstart",function(l){l.touches.length===1&&(t={pageX:l.touches[0].pageX,pageY:l.touches[0].pageY},e=x.performance.now(),r=!0)}),this.on("touchmove",function(l){if(l.touches.length>1)r=!1;else if(t){const c=l.touches[0].pageX-t.pageX,g=l.touches[0].pageY-t.pageY;Math.sqrt(c*c+g*g)>n&&(r=!1)}});const a=function(){r=!1};this.on("touchleave",a),this.on("touchcancel",a),this.on("touchend",function(l){t=null,r===!0&&x.performance.now()-e<s&&(l.preventDefault(),this.trigger("tap"))})}enableTouchActivity(){if(!this.player()||!this.player().reportUserActivity)return;const e=Ce(this.player(),this.player().reportUserActivity);let t;this.on("touchstart",function(){e(),this.clearInterval(t),t=this.setInterval(e,250)});const n=function(s){e(),this.clearInterval(t)};this.on("touchmove",e),this.on("touchend",n),this.on("touchcancel",n)}setTimeout(e,t){var n;return e=Ce(this,e),this.clearTimersOnDispose_(),n=x.setTimeout(()=>{this.setTimeoutIds_.has(n)&&this.setTimeoutIds_.delete(n),e()},t),this.setTimeoutIds_.add(n),n}clearTimeout(e){return this.setTimeoutIds_.has(e)&&(this.setTimeoutIds_.delete(e),x.clearTimeout(e)),e}setInterval(e,t){e=Ce(this,e),this.clearTimersOnDispose_();const n=x.setInterval(e,t);return this.setIntervalIds_.add(n),n}clearInterval(e){return this.setIntervalIds_.has(e)&&(this.setIntervalIds_.delete(e),x.clearInterval(e)),e}requestAnimationFrame(e){this.clearTimersOnDispose_();var t;return e=Ce(this,e),t=x.requestAnimationFrame(()=>{this.rafIds_.has(t)&&this.rafIds_.delete(t),e()}),this.rafIds_.add(t),t}requestNamedAnimationFrame(e,t){this.namedRafs_.has(e)&&this.cancelNamedAnimationFrame(e),this.clearTimersOnDispose_(),t=Ce(this,t);const n=this.requestAnimationFrame(()=>{t(),this.namedRafs_.has(e)&&this.namedRafs_.delete(e)});return this.namedRafs_.set(e,n),e}cancelNamedAnimationFrame(e){this.namedRafs_.has(e)&&(this.cancelAnimationFrame(this.namedRafs_.get(e)),this.namedRafs_.delete(e))}cancelAnimationFrame(e){return this.rafIds_.has(e)&&(this.rafIds_.delete(e),x.cancelAnimationFrame(e)),e}clearTimersOnDispose_(){this.clearingTimersOnDispose_||(this.clearingTimersOnDispose_=!0,this.one("dispose",()=>{[["namedRafs_","cancelNamedAnimationFrame"],["rafIds_","cancelAnimationFrame"],["setTimeoutIds_","clearTimeout"],["setIntervalIds_","clearInterval"]].forEach(([e,t])=>{this[e].forEach((n,s)=>this[t](s))}),this.clearingTimersOnDispose_=!1}))}getIsDisabled(){return!!this.el_.disabled}getIsExpresslyInert(){return this.el_.inert&&!this.el_.ownerDocument.documentElement.inert}getIsFocusable(e){return(e||this.el_).tabIndex>=0&&!(this.getIsDisabled()||this.getIsExpresslyInert())}getIsAvailableToBeFocused(e){function t(r){const a=x.getComputedStyle(r,null),l=a.getPropertyValue("visibility");return a.getPropertyValue("display")!=="none"&&!["hidden","collapse"].includes(l)}function n(r){return!(!t(r.parentElement)||!t(r)||r.style.opacity==="0"||x.getComputedStyle(r).height==="0px"||x.getComputedStyle(r).width==="0px")}function s(r){if(r.offsetWidth+r.offsetHeight+r.getBoundingClientRect().height+r.getBoundingClientRect().width===0)return!1;const a={x:r.getBoundingClientRect().left+r.offsetWidth/2,y:r.getBoundingClientRect().top+r.offsetHeight/2};if(a.x<0||a.x>(G.documentElement.clientWidth||x.innerWidth)||a.y<0||a.y>(G.documentElement.clientHeight||x.innerHeight))return!1;let l=G.elementFromPoint(a.x,a.y);for(;l;){if(l===r)return!0;if(l.parentNode)l=l.parentNode;else return!1}}return e||(e=this.el()),!!(s(e)&&n(e)&&(!e.parentElement||e.tabIndex>=0))}static registerComponent(e,t){if(typeof e!="string"||!e)throw new Error(`Illegal component name, "${e}"; must be a non-empty string.`);const n=ht.getComponent("Tech"),s=n&&n.isTech(t),r=ht===t||ht.prototype.isPrototypeOf(t.prototype);if(s||!r){let l;throw s?l="techs must be registered using Tech.registerTech()":l="must be a Component subclass",new Error(`Illegal component, "${e}"; ${l}.`)}e=Ne(e),ht.components_||(ht.components_={});const a=ht.getComponent("Player");if(e==="Player"&&a&&a.players){const l=a.players,c=Object.keys(l);if(l&&c.length>0&&c.map(g=>l[g]).every(Boolean))throw new Error("Can not register Player component after player has been created.")}return ht.components_[e]=t,ht.components_[os(e)]=t,t}static getComponent(e){if(!(!e||!ht.components_))return ht.components_[e]}};H.registerComponent("Component",H);function K1(i,e,t){if(typeof e!="number"||e<0||e>t)throw new Error(`Failed to execute '${i}' on 'TimeRanges': The index provided (${e}) is non-numeric or out of bounds (0-${t}).`)}function Bu(i,e,t,n){return K1(i,n,t.length-1),t[n][e]}function Oa(i){let e;return i===void 0||i.length===0?e={length:0,start(){throw new Error("This TimeRanges object is empty")},end(){throw new Error("This TimeRanges object is empty")}}:e={length:i.length,start:Bu.bind(null,"start",0,i),end:Bu.bind(null,"end",1,i)},x.Symbol&&x.Symbol.iterator&&(e[x.Symbol.iterator]=()=>(i||[]).values()),e}function Ut(i,e){return Array.isArray(i)?Oa(i):i===void 0||e===void 0?Oa():Oa([[i,e]])}const ic=function(i,e){i=i<0?0:i;let t=Math.floor(i%60),n=Math.floor(i/60%60),s=Math.floor(i/3600);const r=Math.floor(e/60%60),a=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(s=n=t="-"),s=s>0||a>0?s+":":"",n=((s||r>=10)&&n<10?"0"+n:n)+":",t=t<10?"0"+t:t,s+n+t};let Ho=ic;function nc(i){Ho=i}function sc(){Ho=ic}function qi(i,e=i){return Ho(i,e)}var Y1=Object.freeze({__proto__:null,createTimeRanges:Ut,createTimeRange:Ut,setFormatTime:nc,resetFormatTime:sc,formatTime:qi});function rc(i,e){let t=0,n,s;if(!e)return 0;(!i||!i.length)&&(i=Ut(0,0));for(let r=0;r<i.length;r++)n=i.start(r),s=i.end(r),s>e&&(s=e),t+=s-n;return t/e}function Me(i){if(i instanceof Me)return i;typeof i=="number"?this.code=i:typeof i=="string"?this.message=i:Qt(i)&&(typeof i.code=="number"&&(this.code=i.code),Object.assign(this,i)),this.message||(this.message=Me.defaultMessages[this.code]||"")}Me.prototype.code=0;Me.prototype.message="";Me.prototype.status=null;Me.prototype.metadata=null;Me.errorTypes=["MEDIA_ERR_CUSTOM","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED","MEDIA_ERR_ENCRYPTED"];Me.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail part-way.",3:"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.",4:"The media could not be loaded, either because the server or network failed or because the format is not supported.",5:"The media is encrypted and we do not have the keys to decrypt it."};Me.MEDIA_ERR_CUSTOM=0;Me.prototype.MEDIA_ERR_CUSTOM=0;Me.MEDIA_ERR_ABORTED=1;Me.prototype.MEDIA_ERR_ABORTED=1;Me.MEDIA_ERR_NETWORK=2;Me.prototype.MEDIA_ERR_NETWORK=2;Me.MEDIA_ERR_DECODE=3;Me.prototype.MEDIA_ERR_DECODE=3;Me.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Me.prototype.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Me.MEDIA_ERR_ENCRYPTED=5;Me.prototype.MEDIA_ERR_ENCRYPTED=5;function ls(i){return i!=null&&typeof i.then=="function"}function Gt(i){ls(i)&&i.then(null,e=>{})}const no=function(i){return["kind","label","language","id","inBandMetadataTrackDispatchType","mode","src"].reduce((e,t,n)=>(i[t]&&(e[t]=i[t]),e),{cues:i.cues&&Array.prototype.map.call(i.cues,function(e){return{startTime:e.startTime,endTime:e.endTime,text:e.text,id:e.id}})})},Q1=function(i){const e=i.$$("track"),t=Array.prototype.map.call(e,n=>n.track);return Array.prototype.map.call(e,function(n){const s=no(n.track);return n.src&&(s.src=n.src),s}).concat(Array.prototype.filter.call(i.textTracks(),function(n){return t.indexOf(n)===-1}).map(no))},J1=function(i,e){return i.forEach(function(t){const n=e.addRemoteTextTrack(t).track;!t.src&&t.cues&&t.cues.forEach(s=>n.addCue(s))}),e.textTracks()};var Fu={textTracksToJson:Q1,jsonToTextTracks:J1,trackToJson_:no};const Ma="vjs-modal-dialog";class Cn extends H{constructor(e,t){super(e,t),this.handleKeyDown_=n=>this.handleKeyDown(n),this.close_=n=>this.close(n),this.opened_=this.hasBeenOpened_=this.hasBeenFilled_=!1,this.closeable(!this.options_.uncloseable),this.content(this.options_.content),this.contentEl_=ne("div",{className:`${Ma}-content`},{role:"document"}),this.descEl_=ne("p",{className:`${Ma}-description vjs-control-text`,id:this.el().getAttribute("aria-describedby")}),Si(this.descEl_,this.description()),this.el_.appendChild(this.descEl_),this.el_.appendChild(this.contentEl_)}createEl(){return super.createEl("div",{className:this.buildCSSClass(),tabIndex:-1},{"aria-describedby":`${this.id()}_description`,"aria-hidden":"true","aria-label":this.label(),role:"dialog","aria-live":"polite"})}dispose(){this.contentEl_=null,this.descEl_=null,this.previouslyActiveEl_=null,super.dispose()}buildCSSClass(){return`${Ma} vjs-hidden ${super.buildCSSClass()}`}label(){return this.localize(this.options_.label||"Modal Window")}description(){let e=this.options_.description||this.localize("This is a modal window.");return this.closeable()&&(e+=" "+this.localize("This modal can be closed by pressing the Escape key or activating the close button.")),e}open(){if(this.opened_){this.options_.fillAlways&&this.fill();return}const e=this.player();this.trigger("beforemodalopen"),this.opened_=!0,(this.options_.fillAlways||!this.hasBeenOpened_&&!this.hasBeenFilled_)&&this.fill(),this.wasPlaying_=!e.paused(),this.options_.pauseOnOpen&&this.wasPlaying_&&e.pause(),this.on("keydown",this.handleKeyDown_),this.hadControls_=e.controls(),e.controls(!1),this.show(),this.conditionalFocus_(),this.el().setAttribute("aria-hidden","false"),this.trigger("modalopen"),this.hasBeenOpened_=!0}opened(e){return typeof e=="boolean"&&this[e?"open":"close"](),this.opened_}close(){if(!this.opened_)return;const e=this.player();this.trigger("beforemodalclose"),this.opened_=!1,this.wasPlaying_&&this.options_.pauseOnOpen&&e.play(),this.off("keydown",this.handleKeyDown_),this.hadControls_&&e.controls(!0),this.hide(),this.el().setAttribute("aria-hidden","true"),this.trigger({type:"modalclose",bubbles:!0}),this.conditionalBlur_(),this.options_.temporary&&this.dispose()}closeable(e){if(typeof e=="boolean"){const t=this.closeable_=!!e;let n=this.getChild("closeButton");if(t&&!n){const s=this.contentEl_;this.contentEl_=this.el_,n=this.addChild("closeButton",{controlText:"Close Modal Dialog"}),this.contentEl_=s,this.on(n,"close",this.close_)}!t&&n&&(this.off(n,"close",this.close_),this.removeChild(n),n.dispose())}return this.closeable_}fill(){this.fillWith(this.content())}fillWith(e){const t=this.contentEl(),n=t.parentNode,s=t.nextSibling;this.trigger("beforemodalfill"),this.hasBeenFilled_=!0,n.removeChild(t),this.empty(),Hh(t,e),this.trigger("modalfill"),s?n.insertBefore(t,s):n.appendChild(t);const r=this.getChild("closeButton");r&&n.appendChild(r.el_),this.trigger("aftermodalfill")}empty(){this.trigger("beforemodalempty"),Gr(this.contentEl()),this.trigger("modalempty")}content(e){return typeof e<"u"&&(this.content_=e),this.content_}conditionalFocus_(){const e=G.activeElement,t=this.player_.el_;this.previouslyActiveEl_=null,(t.contains(e)||t===e)&&(this.previouslyActiveEl_=e,this.focus())}conditionalBlur_(){this.previouslyActiveEl_&&(this.previouslyActiveEl_.focus(),this.previouslyActiveEl_=null)}handleKeyDown(e){if(this.trigger({type:"modalKeydown",originalEvent:e,target:this,bubbles:!0}),e.stopPropagation(),e.key==="Escape"&&this.closeable()){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;const t=this.focusableEls_(),n=this.el_.querySelector(":focus");let s;for(let r=0;r<t.length;r++)if(n===t[r]){s=r;break}G.activeElement===this.el_&&(s=0),e.shiftKey&&s===0?(t[t.length-1].focus(),e.preventDefault()):!e.shiftKey&&s===t.length-1&&(t[0].focus(),e.preventDefault())}focusableEls_(){const e=this.el_.querySelectorAll("*");return Array.prototype.filter.call(e,t=>(t instanceof x.HTMLAnchorElement||t instanceof x.HTMLAreaElement)&&t.hasAttribute("href")||(t instanceof x.HTMLInputElement||t instanceof x.HTMLSelectElement||t instanceof x.HTMLTextAreaElement||t instanceof x.HTMLButtonElement)&&!t.hasAttribute("disabled")||t instanceof x.HTMLIFrameElement||t instanceof x.HTMLObjectElement||t instanceof x.HTMLEmbedElement||t.hasAttribute("tabindex")&&t.getAttribute("tabindex")!==-1||t.hasAttribute("contenteditable"))}}Cn.prototype.options_={pauseOnOpen:!0,temporary:!0};H.registerComponent("ModalDialog",Cn);class Tn extends St{constructor(e=[]){super(),this.tracks_=[],Object.defineProperty(this,"length",{get(){return this.tracks_.length}});for(let t=0;t<e.length;t++)this.addTrack(e[t])}addTrack(e){const t=this.tracks_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.tracks_[t]}}),this.tracks_.indexOf(e)===-1&&(this.tracks_.push(e),this.trigger({track:e,type:"addtrack",target:this})),e.labelchange_=()=>{this.trigger({track:e,type:"labelchange",target:this})},si(e)&&e.addEventListener("labelchange",e.labelchange_)}removeTrack(e){let t;for(let n=0,s=this.length;n<s;n++)if(this[n]===e){t=this[n],t.off&&t.off(),this.tracks_.splice(n,1);break}t&&this.trigger({track:t,type:"removetrack",target:this})}getTrackById(e){let t=null;for(let n=0,s=this.length;n<s;n++){const r=this[n];if(r.id===e){t=r;break}}return t}}Tn.prototype.allowedEvents_={change:"change",addtrack:"addtrack",removetrack:"removetrack",labelchange:"labelchange"};for(const i in Tn.prototype.allowedEvents_)Tn.prototype["on"+i]=null;const Ra=function(i,e){for(let t=0;t<i.length;t++)!Object.keys(i[t]).length||e.id===i[t].id||(i[t].enabled=!1)};class Z1 extends Tn{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].enabled){Ra(e,e[t]);break}super(e),this.changing_=!1}addTrack(e){e.enabled&&Ra(this,e),super.addTrack(e),e.addEventListener&&(e.enabledChange_=()=>{this.changing_||(this.changing_=!0,Ra(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("enabledchange",e.enabledChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.enabledChange_&&(e.removeEventListener("enabledchange",e.enabledChange_),e.enabledChange_=null)}}const Ua=function(i,e){for(let t=0;t<i.length;t++)!Object.keys(i[t]).length||e.id===i[t].id||(i[t].selected=!1)};class eb extends Tn{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].selected){Ua(e,e[t]);break}super(e),this.changing_=!1,Object.defineProperty(this,"selectedIndex",{get(){for(let t=0;t<this.length;t++)if(this[t].selected)return t;return-1},set(){}})}addTrack(e){e.selected&&Ua(this,e),super.addTrack(e),e.addEventListener&&(e.selectedChange_=()=>{this.changing_||(this.changing_=!0,Ua(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("selectedchange",e.selectedChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.selectedChange_&&(e.removeEventListener("selectedchange",e.selectedChange_),e.selectedChange_=null)}}class ac extends Tn{addTrack(e){super.addTrack(e),this.queueChange_||(this.queueChange_=()=>this.queueTrigger("change")),this.triggerSelectedlanguagechange||(this.triggerSelectedlanguagechange_=()=>this.trigger("selectedlanguagechange")),e.addEventListener("modechange",this.queueChange_),["metadata","chapters"].indexOf(e.kind)===-1&&e.addEventListener("modechange",this.triggerSelectedlanguagechange_)}removeTrack(e){super.removeTrack(e),e.removeEventListener&&(this.queueChange_&&e.removeEventListener("modechange",this.queueChange_),this.selectedlanguagechange_&&e.removeEventListener("modechange",this.triggerSelectedlanguagechange_))}}class tb{constructor(e=[]){this.trackElements_=[],Object.defineProperty(this,"length",{get(){return this.trackElements_.length}});for(let t=0,n=e.length;t<n;t++)this.addTrackElement_(e[t])}addTrackElement_(e){const t=this.trackElements_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.trackElements_[t]}}),this.trackElements_.indexOf(e)===-1&&this.trackElements_.push(e)}getTrackElementByTrack_(e){let t;for(let n=0,s=this.trackElements_.length;n<s;n++)if(e===this.trackElements_[n].track){t=this.trackElements_[n];break}return t}removeTrackElement_(e){for(let t=0,n=this.trackElements_.length;t<n;t++)if(e===this.trackElements_[t]){this.trackElements_[t].track&&typeof this.trackElements_[t].track.off=="function"&&this.trackElements_[t].track.off(),typeof this.trackElements_[t].off=="function"&&this.trackElements_[t].off(),this.trackElements_.splice(t,1);break}}}class yr{constructor(e){yr.prototype.setCues_.call(this,e),Object.defineProperty(this,"length",{get(){return this.length_}})}setCues_(e){const t=this.length||0;let n=0;const s=e.length;this.cues_=e,this.length_=e.length;const r=function(a){""+a in this||Object.defineProperty(this,""+a,{get(){return this.cues_[a]}})};if(t<s)for(n=t;n<s;n++)r.call(this,n)}getCueById(e){let t=null;for(let n=0,s=this.length;n<s;n++){const r=this[n];if(r.id===e){t=r;break}}return t}}const ib={alternative:"alternative",captions:"captions",main:"main",sign:"sign",subtitles:"subtitles",commentary:"commentary"},nb={alternative:"alternative",descriptions:"descriptions",main:"main","main-desc":"main-desc",translation:"translation",commentary:"commentary"},sb={subtitles:"subtitles",captions:"captions",descriptions:"descriptions",chapters:"chapters",metadata:"metadata"},ju={disabled:"disabled",hidden:"hidden",showing:"showing"};class zo extends St{constructor(e={}){super();const t={id:e.id||"vjs_track_"+At(),kind:e.kind||"",language:e.language||""};let n=e.label||"";for(const s in t)Object.defineProperty(this,s,{get(){return t[s]},set(){}});Object.defineProperty(this,"label",{get(){return n},set(s){s!==n&&(n=s,this.trigger("labelchange"))}})}}const Wo=function(i){return new URL(i,G.baseURI)},oc=function(i){return new URL(i,G.baseURI).href},Go=function(i){if(typeof i=="string"){const e=/^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/.exec(i);if(e)return e.pop().toLowerCase()}return""},Qr=function(i,e=x.location){return Wo(i).origin!==e.origin};var rb=Object.freeze({__proto__:null,parseUrl:Wo,getAbsoluteURL:oc,getFileExtension:Go,isCrossOrigin:Qr});const $u=function(i,e){const t=new x.WebVTT.Parser(x,x.vttjs,x.WebVTT.StringDecoder()),n=[];t.oncue=function(s){e.addCue(s)},t.onparsingerror=function(s){n.push(s)},t.onflush=function(){e.trigger({type:"loadeddata",target:e})},t.parse(i),n.length>0&&(x.console&&x.console.groupCollapsed&&x.console.groupCollapsed(`Text Track parsing errors for ${e.src}`),n.forEach(s=>le.error(s)),x.console&&x.console.groupEnd&&x.console.groupEnd()),t.flush()},qu=function(i,e){const t={uri:i},n=Qr(i);n&&(t.cors=n);const s=e.tech_.crossOrigin()==="use-credentials";s&&(t.withCredentials=s),ih(t,Ce(this,function(r,a,l){if(r)return le.error(r,a);e.loaded_=!0,typeof x.WebVTT!="function"?e.tech_&&e.tech_.any(["vttjsloaded","vttjserror"],c=>{if(c.type==="vttjserror"){le.error(`vttjs failed to load, stopping trying to process ${e.src}`);return}return $u(l,e)}):$u(l,e)}))};class ys extends zo{constructor(e={}){if(!e.tech)throw new Error("A tech was not provided.");const t=ve(e,{kind:sb[e.kind]||"subtitles",language:e.language||e.srclang||""});let n=ju[t.mode]||"disabled";const s=t.default;(t.kind==="metadata"||t.kind==="chapters")&&(n="hidden"),super(t),this.tech_=t.tech,this.cues_=[],this.activeCues_=[],this.preload_=this.tech_.preloadTextTracks!==!1;const r=new yr(this.cues_),a=new yr(this.activeCues_);let l=!1;this.timeupdateHandler=Ce(this,function(g={}){if(!this.tech_.isDisposed()){if(!this.tech_.isReady_){g.type!=="timeupdate"&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler));return}this.activeCues=this.activeCues,l&&(this.trigger("cuechange"),l=!1),g.type!=="timeupdate"&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler))}});const c=()=>{this.stopTracking()};this.tech_.one("dispose",c),n!=="disabled"&&this.startTracking(),Object.defineProperties(this,{default:{get(){return s},set(){}},mode:{get(){return n},set(g){ju[g]&&n!==g&&(n=g,!this.preload_&&n!=="disabled"&&this.cues.length===0&&qu(this.src,this),this.stopTracking(),n!=="disabled"&&this.startTracking(),this.trigger("modechange"))}},cues:{get(){return this.loaded_?r:null},set(){}},activeCues:{get(){if(!this.loaded_)return null;if(this.cues.length===0)return a;const g=this.tech_.currentTime(),m=[];for(let b=0,C=this.cues.length;b<C;b++){const w=this.cues[b];w.startTime<=g&&w.endTime>=g&&m.push(w)}if(l=!1,m.length!==this.activeCues_.length)l=!0;else for(let b=0;b<m.length;b++)this.activeCues_.indexOf(m[b])===-1&&(l=!0);return this.activeCues_=m,a.setCues_(this.activeCues_),a},set(){}}}),t.src?(this.src=t.src,this.preload_||(this.loaded_=!0),(this.preload_||t.kind!=="subtitles"&&t.kind!=="captions")&&qu(this.src,this)):this.loaded_=!0}startTracking(){this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler),this.tech_.on("timeupdate",this.timeupdateHandler)}stopTracking(){this.rvf_&&(this.tech_.cancelVideoFrameCallback(this.rvf_),this.rvf_=void 0),this.tech_.off("timeupdate",this.timeupdateHandler)}addCue(e){let t=e;if(!("getCueAsHTML"in t)){t=new x.vttjs.VTTCue(e.startTime,e.endTime,e.text);for(const s in e)s in t||(t[s]=e[s]);t.id=e.id,t.originalCue_=e}const n=this.tech_.textTracks();for(let s=0;s<n.length;s++)n[s]!==this&&n[s].removeCue(t);this.cues_.push(t),this.cues.setCues_(this.cues_)}removeCue(e){let t=this.cues_.length;for(;t--;){const n=this.cues_[t];if(n===e||n.originalCue_&&n.originalCue_===e){this.cues_.splice(t,1),this.cues.setCues_(this.cues_);break}}}}ys.prototype.allowedEvents_={cuechange:"cuechange"};class lc extends zo{constructor(e={}){const t=ve(e,{kind:nb[e.kind]||""});super(t);let n=!1;Object.defineProperty(this,"enabled",{get(){return n},set(s){typeof s!="boolean"||s===n||(n=s,this.trigger("enabledchange"))}}),t.enabled&&(this.enabled=t.enabled),this.loaded_=!0}}class uc extends zo{constructor(e={}){const t=ve(e,{kind:ib[e.kind]||""});super(t);let n=!1;Object.defineProperty(this,"selected",{get(){return n},set(s){typeof s!="boolean"||s===n||(n=s,this.trigger("selectedchange"))}}),t.selected&&(this.selected=t.selected)}}class ai extends St{constructor(e={}){super();let t;const n=new ys(e);this.kind=n.kind,this.src=n.src,this.srclang=n.language,this.label=n.label,this.default=n.default,Object.defineProperties(this,{readyState:{get(){return t}},track:{get(){return n}}}),t=ai.NONE,n.addEventListener("loadeddata",()=>{t=ai.LOADED,this.trigger({type:"load",target:this})})}}ai.prototype.allowedEvents_={load:"load"};ai.NONE=0;ai.LOADING=1;ai.LOADED=2;ai.ERROR=3;const xt={audio:{ListClass:Z1,TrackClass:lc,capitalName:"Audio"},video:{ListClass:eb,TrackClass:uc,capitalName:"Video"},text:{ListClass:ac,TrackClass:ys,capitalName:"Text"}};Object.keys(xt).forEach(function(i){xt[i].getterName=`${i}Tracks`,xt[i].privateName=`${i}Tracks_`});const vn={remoteText:{ListClass:ac,TrackClass:ys,capitalName:"RemoteText",getterName:"remoteTextTracks",privateName:"remoteTextTracks_"},remoteTextEl:{ListClass:tb,TrackClass:ai,capitalName:"RemoteTextTrackEls",getterName:"remoteTextTrackEls",privateName:"remoteTextTrackEls_"}},at=Object.assign({},xt,vn);vn.names=Object.keys(vn);xt.names=Object.keys(xt);at.names=[].concat(vn.names).concat(xt.names);function ab(i,e,t,n,s={}){const r=i.textTracks();s.kind=e,t&&(s.label=t),n&&(s.language=n),s.tech=i;const a=new at.text.TrackClass(s);return r.addTrack(a),a}class ae extends H{constructor(e={},t=function(){}){e.reportTouchActivity=!1,super(null,e,t),this.onDurationChange_=n=>this.onDurationChange(n),this.trackProgress_=n=>this.trackProgress(n),this.trackCurrentTime_=n=>this.trackCurrentTime(n),this.stopTrackingCurrentTime_=n=>this.stopTrackingCurrentTime(n),this.disposeSourceHandler_=n=>this.disposeSourceHandler(n),this.queuedHanders_=new Set,this.hasStarted_=!1,this.on("playing",function(){this.hasStarted_=!0}),this.on("loadstart",function(){this.hasStarted_=!1}),at.names.forEach(n=>{const s=at[n];e&&e[s.getterName]&&(this[s.privateName]=e[s.getterName])}),this.featuresProgressEvents||this.manualProgressOn(),this.featuresTimeupdateEvents||this.manualTimeUpdatesOn(),["Text","Audio","Video"].forEach(n=>{e[`native${n}Tracks`]===!1&&(this[`featuresNative${n}Tracks`]=!1)}),e.nativeCaptions===!1||e.nativeTextTracks===!1?this.featuresNativeTextTracks=!1:(e.nativeCaptions===!0||e.nativeTextTracks===!0)&&(this.featuresNativeTextTracks=!0),this.featuresNativeTextTracks||this.emulateTextTracks(),this.preloadTextTracks=e.preloadTextTracks!==!1,this.autoRemoteTextTracks_=new at.text.ListClass,this.initTrackListeners(),e.nativeControlsForTouch||this.emitTapEvents(),this.constructor&&(this.name_=this.constructor.name||"Unknown Tech")}triggerSourceset(e){this.isReady_||this.one("ready",()=>this.setTimeout(()=>this.triggerSourceset(e),1)),this.trigger({src:e,type:"sourceset"})}manualProgressOn(){this.on("durationchange",this.onDurationChange_),this.manualProgress=!0,this.one("ready",this.trackProgress_)}manualProgressOff(){this.manualProgress=!1,this.stopTrackingProgress(),this.off("durationchange",this.onDurationChange_)}trackProgress(e){this.stopTrackingProgress(),this.progressInterval=this.setInterval(Ce(this,function(){const t=this.bufferedPercent();this.bufferedPercent_!==t&&this.trigger("progress"),this.bufferedPercent_=t,t===1&&this.stopTrackingProgress()}),500)}onDurationChange(e){this.duration_=this.duration()}buffered(){return Ut(0,0)}bufferedPercent(){return rc(this.buffered(),this.duration_)}stopTrackingProgress(){this.clearInterval(this.progressInterval)}manualTimeUpdatesOn(){this.manualTimeUpdates=!0,this.on("play",this.trackCurrentTime_),this.on("pause",this.stopTrackingCurrentTime_)}manualTimeUpdatesOff(){this.manualTimeUpdates=!1,this.stopTrackingCurrentTime(),this.off("play",this.trackCurrentTime_),this.off("pause",this.stopTrackingCurrentTime_)}trackCurrentTime(){this.currentTimeInterval&&this.stopTrackingCurrentTime(),this.currentTimeInterval=this.setInterval(function(){this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})},250)}stopTrackingCurrentTime(){this.clearInterval(this.currentTimeInterval),this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}dispose(){this.clearTracks(xt.names),this.manualProgress&&this.manualProgressOff(),this.manualTimeUpdates&&this.manualTimeUpdatesOff(),super.dispose()}clearTracks(e){e=[].concat(e),e.forEach(t=>{const n=this[`${t}Tracks`]()||[];let s=n.length;for(;s--;){const r=n[s];t==="text"&&this.removeRemoteTextTrack(r),n.removeTrack(r)}})}cleanupAutoTextTracks(){const e=this.autoRemoteTextTracks_||[];let t=e.length;for(;t--;){const n=e[t];this.removeRemoteTextTrack(n)}}reset(){}crossOrigin(){}setCrossOrigin(){}error(e){return e!==void 0&&(this.error_=new Me(e),this.trigger("error")),this.error_}played(){return this.hasStarted_?Ut(0,0):Ut()}play(){}setScrubbing(e){}scrubbing(){}setCurrentTime(e){this.manualTimeUpdates&&this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}initTrackListeners(){xt.names.forEach(e=>{const t=xt[e],n=()=>{this.trigger(`${e}trackchange`)},s=this[t.getterName]();s.addEventListener("removetrack",n),s.addEventListener("addtrack",n),this.on("dispose",()=>{s.removeEventListener("removetrack",n),s.removeEventListener("addtrack",n)})})}addWebVttScript_(){if(!x.WebVTT)if(G.body.contains(this.el())){if(!this.options_["vtt.js"]&&mn(bu)&&Object.keys(bu).length>0){this.trigger("vttjsloaded");return}const e=G.createElement("script");e.src=this.options_["vtt.js"]||"https://vjs.zencdn.net/vttjs/0.14.1/vtt.min.js",e.onload=()=>{this.trigger("vttjsloaded")},e.onerror=()=>{this.trigger("vttjserror")},this.on("dispose",()=>{e.onload=null,e.onerror=null}),x.WebVTT=!0,this.el().parentNode.appendChild(e)}else this.ready(this.addWebVttScript_)}emulateTextTracks(){const e=this.textTracks(),t=this.remoteTextTracks(),n=l=>e.addTrack(l.track),s=l=>e.removeTrack(l.track);t.on("addtrack",n),t.on("removetrack",s),this.addWebVttScript_();const r=()=>this.trigger("texttrackchange"),a=()=>{r();for(let l=0;l<e.length;l++){const c=e[l];c.removeEventListener("cuechange",r),c.mode==="showing"&&c.addEventListener("cuechange",r)}};a(),e.addEventListener("change",a),e.addEventListener("addtrack",a),e.addEventListener("removetrack",a),this.on("dispose",function(){t.off("addtrack",n),t.off("removetrack",s),e.removeEventListener("change",a),e.removeEventListener("addtrack",a),e.removeEventListener("removetrack",a);for(let l=0;l<e.length;l++)e[l].removeEventListener("cuechange",r)})}addTextTrack(e,t,n){if(!e)throw new Error("TextTrack kind is required but was not provided");return ab(this,e,t,n)}createRemoteTextTrack(e){const t=ve(e,{tech:this});return new vn.remoteTextEl.TrackClass(t)}addRemoteTextTrack(e={},t){const n=this.createRemoteTextTrack(e);return typeof t!="boolean"&&(t=!1),this.remoteTextTrackEls().addTrackElement_(n),this.remoteTextTracks().addTrack(n.track),t===!1&&this.ready(()=>this.autoRemoteTextTracks_.addTrack(n.track)),n}removeRemoteTextTrack(e){const t=this.remoteTextTrackEls().getTrackElementByTrack_(e);this.remoteTextTrackEls().removeTrackElement_(t),this.remoteTextTracks().removeTrack(e),this.autoRemoteTextTracks_.removeTrack(e)}getVideoPlaybackQuality(){return{}}requestPictureInPicture(){return Promise.reject()}disablePictureInPicture(){return!0}setDisablePictureInPicture(){}requestVideoFrameCallback(e){const t=At();return!this.isReady_||this.paused()?(this.queuedHanders_.add(t),this.one("playing",()=>{this.queuedHanders_.has(t)&&(this.queuedHanders_.delete(t),e())})):this.requestNamedAnimationFrame(t,e),t}cancelVideoFrameCallback(e){this.queuedHanders_.has(e)?this.queuedHanders_.delete(e):this.cancelNamedAnimationFrame(e)}setPoster(){}playsinline(){}setPlaysinline(){}overrideNativeAudioTracks(e){}overrideNativeVideoTracks(e){}canPlayType(e){return""}static canPlayType(e){return""}static canPlaySource(e,t){return ae.canPlayType(e.type)}static isTech(e){return e.prototype instanceof ae||e instanceof ae||e===ae}static registerTech(e,t){if(ae.techs_||(ae.techs_={}),!ae.isTech(t))throw new Error(`Tech ${e} must be a Tech`);if(!ae.canPlayType)throw new Error("Techs must have a static canPlayType method on them");if(!ae.canPlaySource)throw new Error("Techs must have a static canPlaySource method on them");return e=Ne(e),ae.techs_[e]=t,ae.techs_[os(e)]=t,e!=="Tech"&&ae.defaultTechOrder_.push(e),t}static getTech(e){if(e){if(ae.techs_&&ae.techs_[e])return ae.techs_[e];if(e=Ne(e),x&&x.videojs&&x.videojs[e])return le.warn(`The ${e} tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)`),x.videojs[e]}}}at.names.forEach(function(i){const e=at[i];ae.prototype[e.getterName]=function(){return this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName]}});ae.prototype.featuresVolumeControl=!0;ae.prototype.featuresMuteControl=!0;ae.prototype.featuresFullscreenResize=!1;ae.prototype.featuresPlaybackRate=!1;ae.prototype.featuresProgressEvents=!1;ae.prototype.featuresSourceset=!1;ae.prototype.featuresTimeupdateEvents=!1;ae.prototype.featuresNativeTextTracks=!1;ae.prototype.featuresVideoFrameCallback=!1;ae.withSourceHandlers=function(i){i.registerSourceHandler=function(e,t){let n=i.sourceHandlers;n||(n=i.sourceHandlers=[]),t===void 0&&(t=n.length),n.splice(t,0,e)},i.canPlayType=function(e){const t=i.sourceHandlers||[];let n;for(let s=0;s<t.length;s++)if(n=t[s].canPlayType(e),n)return n;return""},i.selectSourceHandler=function(e,t){const n=i.sourceHandlers||[];let s;for(let r=0;r<n.length;r++)if(s=n[r].canHandleSource(e,t),s)return n[r];return null},i.canPlaySource=function(e,t){const n=i.selectSourceHandler(e,t);return n?n.canHandleSource(e,t):""},["seekable","seeking","duration"].forEach(function(e){const t=this[e];typeof t=="function"&&(this[e]=function(){return this.sourceHandler_&&this.sourceHandler_[e]?this.sourceHandler_[e].apply(this.sourceHandler_,arguments):t.apply(this,arguments)})},i.prototype),i.prototype.setSource=function(e){let t=i.selectSourceHandler(e,this.options_);t||(i.nativeSourceHandler?t=i.nativeSourceHandler:le.error("No source handler found for the current source.")),this.disposeSourceHandler(),this.off("dispose",this.disposeSourceHandler_),t!==i.nativeSourceHandler&&(this.currentSource_=e),this.sourceHandler_=t.handleSource(e,this,this.options_),this.one("dispose",this.disposeSourceHandler_)},i.prototype.disposeSourceHandler=function(){this.currentSource_&&(this.clearTracks(["audio","video"]),this.currentSource_=null),this.cleanupAutoTextTracks(),this.sourceHandler_&&(this.sourceHandler_.dispose&&this.sourceHandler_.dispose(),this.sourceHandler_=null)}};H.registerComponent("Tech",ae);ae.registerTech("Tech",ae);ae.defaultTechOrder_=[];const Fi={},_r={},br={};function ob(i,e){Fi[i]=Fi[i]||[],Fi[i].push(e)}function lb(i,e,t){i.setTimeout(()=>Oi(e,Fi[e.type],t,i),1)}function ub(i,e){i.forEach(t=>t.setTech&&t.setTech(e))}function db(i,e,t){return i.reduceRight(Xo(t),e[t]())}function hb(i,e,t,n){return e[t](i.reduce(Xo(t),n))}function Vu(i,e,t,n=null){const s="call"+Ne(t),r=i.reduce(Xo(s),n),a=r===br,l=a?null:e[t](r);return fb(i,t,l,a),l}const cb={buffered:1,currentTime:1,duration:1,muted:1,played:1,paused:1,seekable:1,volume:1,ended:1},pb={setCurrentTime:1,setMuted:1,setVolume:1},Hu={play:1,pause:1};function Xo(i){return(e,t)=>e===br?br:t[i]?t[i](e):e}function fb(i,e,t,n){for(let s=i.length-1;s>=0;s--){const r=i[s];r[e]&&r[e](n,t)}}function gb(i){_r.hasOwnProperty(i.id())&&delete _r[i.id()]}function mb(i,e){const t=_r[i.id()];let n=null;if(t==null)return n=e(i),_r[i.id()]=[[e,n]],n;for(let s=0;s<t.length;s++){const[r,a]=t[s];r===e&&(n=a)}return n===null&&(n=e(i),t.push([e,n])),n}function Oi(i={},e=[],t,n,s=[],r=!1){const[a,...l]=e;if(typeof a=="string")Oi(i,Fi[a],t,n,s,r);else if(a){const c=mb(n,a);if(!c.setSource)return s.push(c),Oi(i,l,t,n,s,r);c.setSource(Object.assign({},i),function(g,m){if(g)return Oi(i,l,t,n,s,r);s.push(c),Oi(m,i.type===m.type?l:Fi[m.type],t,n,s,r)})}else l.length?Oi(i,l,t,n,s,r):r?t(i,s):Oi(i,Fi["*"],t,n,s,!0)}const yb={opus:"video/ogg",ogv:"video/ogg",mp4:"video/mp4",mov:"video/mp4",m4v:"video/mp4",mkv:"video/x-matroska",m4a:"audio/mp4",mp3:"audio/mpeg",aac:"audio/aac",caf:"audio/x-caf",flac:"audio/flac",oga:"audio/ogg",wav:"audio/wav",m3u8:"application/x-mpegURL",mpd:"application/dash+xml",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",png:"image/png",svg:"image/svg+xml",webp:"image/webp"},Tr=function(i=""){const e=Go(i);return yb[e.toLowerCase()]||""},_b=(i,e)=>{if(!e)return"";if(i.cache_.source.src===e&&i.cache_.source.type)return i.cache_.source.type;const t=i.cache_.sources.filter(s=>s.src===e);if(t.length)return t[0].type;const n=i.$$("source");for(let s=0;s<n.length;s++){const r=n[s];if(r.type&&r.src&&r.src===e)return r.type}return Tr(e)},dc=function(i){if(Array.isArray(i)){let e=[];i.forEach(function(t){t=dc(t),Array.isArray(t)?e=e.concat(t):Qt(t)&&e.push(t)}),i=e}else typeof i=="string"&&i.trim()?i=[zu({src:i})]:Qt(i)&&typeof i.src=="string"&&i.src&&i.src.trim()?i=[zu(i)]:i=[];return i};function zu(i){if(!i.type){const e=Tr(i.src);e&&(i.type=e)}return i}var bb=`<svg xmlns="http://www.w3.org/2000/svg">
|
|
23
|
+
`))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1)}}const H_=" ",Ia=function(i){const e=/([0-9.]*)?@?([0-9.]*)?/.exec(i||""),t={};return e[1]&&(t.length=parseInt(e[1],10)),e[2]&&(t.offset=parseInt(e[2],10)),t},z_=function(){const i='(?:[^=]*)=(?:"[^"]*"|[^,]*)';return new RegExp("(?:^|,)("+i+")")},st=function(i){const e={};if(!i)return e;const t=i.split(z_());let n=t.length,s;for(;n--;)t[n]!==""&&(s=/([^=]*)=(.*)/.exec(t[n]).slice(1),s[0]=s[0].replace(/^\s+|\s+$/g,""),s[1]=s[1].replace(/^\s+|\s+$/g,""),s[1]=s[1].replace(/^['"](.*)['"]$/g,"$1"),e[s[0]]=s[1]);return e},bu=i=>{const e=i.split("x"),t={};return e[0]&&(t.width=parseInt(e[0],10)),e[1]&&(t.height=parseInt(e[1],10)),t};class W_ extends Co{constructor(){super(),this.customParsers=[],this.tagMappers=[]}push(e){let t,n;if(e=e.trim(),e.length!==0){if(e[0]!=="#"){this.trigger("data",{type:"uri",uri:e});return}this.tagMappers.reduce((s,r)=>{const a=r(e);return a===e?s:s.concat([a])},[e]).forEach(s=>{for(let r=0;r<this.customParsers.length;r++)if(this.customParsers[r].call(this,s))return;if(s.indexOf("#EXT")!==0){this.trigger("data",{type:"comment",text:s.slice(1)});return}if(s=s.replace("\r",""),t=/^#EXTM3U/.exec(s),t){this.trigger("data",{type:"tag",tagType:"m3u"});return}if(t=/^#EXTINF:([0-9\.]*)?,?(.*)?$/.exec(s),t){n={type:"tag",tagType:"inf"},t[1]&&(n.duration=parseFloat(t[1])),t[2]&&(n.title=t[2]),this.trigger("data",n);return}if(t=/^#EXT-X-TARGETDURATION:([0-9.]*)?/.exec(s),t){n={type:"tag",tagType:"targetduration"},t[1]&&(n.duration=parseInt(t[1],10)),this.trigger("data",n);return}if(t=/^#EXT-X-VERSION:([0-9.]*)?/.exec(s),t){n={type:"tag",tagType:"version"},t[1]&&(n.version=parseInt(t[1],10)),this.trigger("data",n);return}if(t=/^#EXT-X-MEDIA-SEQUENCE:(\-?[0-9.]*)?/.exec(s),t){n={type:"tag",tagType:"media-sequence"},t[1]&&(n.number=parseInt(t[1],10)),this.trigger("data",n);return}if(t=/^#EXT-X-DISCONTINUITY-SEQUENCE:(\-?[0-9.]*)?/.exec(s),t){n={type:"tag",tagType:"discontinuity-sequence"},t[1]&&(n.number=parseInt(t[1],10)),this.trigger("data",n);return}if(t=/^#EXT-X-PLAYLIST-TYPE:(.*)?$/.exec(s),t){n={type:"tag",tagType:"playlist-type"},t[1]&&(n.playlistType=t[1]),this.trigger("data",n);return}if(t=/^#EXT-X-BYTERANGE:(.*)?$/.exec(s),t){n=je(Ia(t[1]),{type:"tag",tagType:"byterange"}),this.trigger("data",n);return}if(t=/^#EXT-X-ALLOW-CACHE:(YES|NO)?/.exec(s),t){n={type:"tag",tagType:"allow-cache"},t[1]&&(n.allowed=!/NO/.test(t[1])),this.trigger("data",n);return}if(t=/^#EXT-X-MAP:(.*)$/.exec(s),t){if(n={type:"tag",tagType:"map"},t[1]){const r=st(t[1]);r.URI&&(n.uri=r.URI),r.BYTERANGE&&(n.byterange=Ia(r.BYTERANGE))}this.trigger("data",n);return}if(t=/^#EXT-X-STREAM-INF:(.*)$/.exec(s),t){n={type:"tag",tagType:"stream-inf"},t[1]&&(n.attributes=st(t[1]),n.attributes.RESOLUTION&&(n.attributes.RESOLUTION=bu(n.attributes.RESOLUTION)),n.attributes.BANDWIDTH&&(n.attributes.BANDWIDTH=parseInt(n.attributes.BANDWIDTH,10)),n.attributes["FRAME-RATE"]&&(n.attributes["FRAME-RATE"]=parseFloat(n.attributes["FRAME-RATE"])),n.attributes["PROGRAM-ID"]&&(n.attributes["PROGRAM-ID"]=parseInt(n.attributes["PROGRAM-ID"],10))),this.trigger("data",n);return}if(t=/^#EXT-X-MEDIA:(.*)$/.exec(s),t){n={type:"tag",tagType:"media"},t[1]&&(n.attributes=st(t[1])),this.trigger("data",n);return}if(t=/^#EXT-X-ENDLIST/.exec(s),t){this.trigger("data",{type:"tag",tagType:"endlist"});return}if(t=/^#EXT-X-DISCONTINUITY/.exec(s),t){this.trigger("data",{type:"tag",tagType:"discontinuity"});return}if(t=/^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(s),t){n={type:"tag",tagType:"program-date-time"},t[1]&&(n.dateTimeString=t[1],n.dateTimeObject=new Date(t[1])),this.trigger("data",n);return}if(t=/^#EXT-X-KEY:(.*)$/.exec(s),t){n={type:"tag",tagType:"key"},t[1]&&(n.attributes=st(t[1]),n.attributes.IV&&(n.attributes.IV.substring(0,2).toLowerCase()==="0x"&&(n.attributes.IV=n.attributes.IV.substring(2)),n.attributes.IV=n.attributes.IV.match(/.{8}/g),n.attributes.IV[0]=parseInt(n.attributes.IV[0],16),n.attributes.IV[1]=parseInt(n.attributes.IV[1],16),n.attributes.IV[2]=parseInt(n.attributes.IV[2],16),n.attributes.IV[3]=parseInt(n.attributes.IV[3],16),n.attributes.IV=new Uint32Array(n.attributes.IV))),this.trigger("data",n);return}if(t=/^#EXT-X-START:(.*)$/.exec(s),t){n={type:"tag",tagType:"start"},t[1]&&(n.attributes=st(t[1]),n.attributes["TIME-OFFSET"]=parseFloat(n.attributes["TIME-OFFSET"]),n.attributes.PRECISE=/YES/.test(n.attributes.PRECISE)),this.trigger("data",n);return}if(t=/^#EXT-X-CUE-OUT-CONT:(.*)?$/.exec(s),t){n={type:"tag",tagType:"cue-out-cont"},t[1]?n.data=t[1]:n.data="",this.trigger("data",n);return}if(t=/^#EXT-X-CUE-OUT:(.*)?$/.exec(s),t){n={type:"tag",tagType:"cue-out"},t[1]?n.data=t[1]:n.data="",this.trigger("data",n);return}if(t=/^#EXT-X-CUE-IN:?(.*)?$/.exec(s),t){n={type:"tag",tagType:"cue-in"},t[1]?n.data=t[1]:n.data="",this.trigger("data",n);return}if(t=/^#EXT-X-SKIP:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"skip"},n.attributes=st(t[1]),n.attributes.hasOwnProperty("SKIPPED-SEGMENTS")&&(n.attributes["SKIPPED-SEGMENTS"]=parseInt(n.attributes["SKIPPED-SEGMENTS"],10)),n.attributes.hasOwnProperty("RECENTLY-REMOVED-DATERANGES")&&(n.attributes["RECENTLY-REMOVED-DATERANGES"]=n.attributes["RECENTLY-REMOVED-DATERANGES"].split(H_)),this.trigger("data",n);return}if(t=/^#EXT-X-PART:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"part"},n.attributes=st(t[1]),["DURATION"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=parseFloat(n.attributes[r]))}),["INDEPENDENT","GAP"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=/YES/.test(n.attributes[r]))}),n.attributes.hasOwnProperty("BYTERANGE")&&(n.attributes.byterange=Ia(n.attributes.BYTERANGE)),this.trigger("data",n);return}if(t=/^#EXT-X-SERVER-CONTROL:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"server-control"},n.attributes=st(t[1]),["CAN-SKIP-UNTIL","PART-HOLD-BACK","HOLD-BACK"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=parseFloat(n.attributes[r]))}),["CAN-SKIP-DATERANGES","CAN-BLOCK-RELOAD"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=/YES/.test(n.attributes[r]))}),this.trigger("data",n);return}if(t=/^#EXT-X-PART-INF:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"part-inf"},n.attributes=st(t[1]),["PART-TARGET"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=parseFloat(n.attributes[r]))}),this.trigger("data",n);return}if(t=/^#EXT-X-PRELOAD-HINT:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"preload-hint"},n.attributes=st(t[1]),["BYTERANGE-START","BYTERANGE-LENGTH"].forEach(function(r){if(n.attributes.hasOwnProperty(r)){n.attributes[r]=parseInt(n.attributes[r],10);const a=r==="BYTERANGE-LENGTH"?"length":"offset";n.attributes.byterange=n.attributes.byterange||{},n.attributes.byterange[a]=n.attributes[r],delete n.attributes[r]}}),this.trigger("data",n);return}if(t=/^#EXT-X-RENDITION-REPORT:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"rendition-report"},n.attributes=st(t[1]),["LAST-MSN","LAST-PART"].forEach(function(r){n.attributes.hasOwnProperty(r)&&(n.attributes[r]=parseInt(n.attributes[r],10))}),this.trigger("data",n);return}if(t=/^#EXT-X-DATERANGE:(.*)$/.exec(s),t&&t[1]){n={type:"tag",tagType:"daterange"},n.attributes=st(t[1]),["ID","CLASS"].forEach(function(a){n.attributes.hasOwnProperty(a)&&(n.attributes[a]=String(n.attributes[a]))}),["START-DATE","END-DATE"].forEach(function(a){n.attributes.hasOwnProperty(a)&&(n.attributes[a]=new Date(n.attributes[a]))}),["DURATION","PLANNED-DURATION"].forEach(function(a){n.attributes.hasOwnProperty(a)&&(n.attributes[a]=parseFloat(n.attributes[a]))}),["END-ON-NEXT"].forEach(function(a){n.attributes.hasOwnProperty(a)&&(n.attributes[a]=/YES/i.test(n.attributes[a]))}),["SCTE35-CMD"," SCTE35-OUT","SCTE35-IN"].forEach(function(a){n.attributes.hasOwnProperty(a)&&(n.attributes[a]=n.attributes[a].toString(16))});const r=/^X-([A-Z]+-)+[A-Z]+$/;for(const a in n.attributes){if(!r.test(a))continue;const l=/[0-9A-Fa-f]{6}/g.test(n.attributes[a]),c=/^\d+(\.\d+)?$/.test(n.attributes[a]);n.attributes[a]=l?n.attributes[a].toString(16):c?parseFloat(n.attributes[a]):String(n.attributes[a])}this.trigger("data",n);return}if(t=/^#EXT-X-INDEPENDENT-SEGMENTS/.exec(s),t){this.trigger("data",{type:"tag",tagType:"independent-segments"});return}if(t=/^#EXT-X-I-FRAMES-ONLY/.exec(s),t){this.trigger("data",{type:"tag",tagType:"i-frames-only"});return}if(t=/^#EXT-X-CONTENT-STEERING:(.*)$/.exec(s),t){n={type:"tag",tagType:"content-steering"},n.attributes=st(t[1]),this.trigger("data",n);return}if(t=/^#EXT-X-I-FRAME-STREAM-INF:(.*)$/.exec(s),t){n={type:"tag",tagType:"i-frame-playlist"},n.attributes=st(t[1]),n.attributes.URI&&(n.uri=n.attributes.URI),n.attributes.BANDWIDTH&&(n.attributes.BANDWIDTH=parseInt(n.attributes.BANDWIDTH,10)),n.attributes.RESOLUTION&&(n.attributes.RESOLUTION=bu(n.attributes.RESOLUTION)),n.attributes["AVERAGE-BANDWIDTH"]&&(n.attributes["AVERAGE-BANDWIDTH"]=parseInt(n.attributes["AVERAGE-BANDWIDTH"],10)),n.attributes["FRAME-RATE"]&&(n.attributes["FRAME-RATE"]=parseFloat(n.attributes["FRAME-RATE"])),this.trigger("data",n);return}if(t=/^#EXT-X-DEFINE:(.*)$/.exec(s),t){n={type:"tag",tagType:"define"},n.attributes=st(t[1]),this.trigger("data",n);return}this.trigger("data",{type:"tag",data:s.slice(4)})})}}addParser({expression:e,customType:t,dataParser:n,segment:s}){typeof n!="function"&&(n=r=>r),this.customParsers.push(r=>{if(e.exec(r))return this.trigger("data",{type:"custom",data:n(r),customType:t,segment:s}),!0})}addTagMapper({expression:e,map:t}){const n=s=>e.test(s)?t(s):s;this.tagMappers.push(n)}}const G_=i=>i.toLowerCase().replace(/-(\w)/g,e=>e[1].toUpperCase()),gi=function(i){const e={};return Object.keys(i).forEach(function(t){e[G_(t)]=i[t]}),e},xa=function(i){const{serverControl:e,targetDuration:t,partTargetDuration:n}=i;if(!e)return;const s="#EXT-X-SERVER-CONTROL",r="holdBack",a="partHoldBack",l=t&&t*3,c=n&&n*2;t&&!e.hasOwnProperty(r)&&(e[r]=l,this.trigger("info",{message:`${s} defaulting HOLD-BACK to targetDuration * 3 (${l}).`})),l&&e[r]<l&&(this.trigger("warn",{message:`${s} clamping HOLD-BACK (${e[r]}) to targetDuration * 3 (${l})`}),e[r]=l),n&&!e.hasOwnProperty(a)&&(e[a]=n*3,this.trigger("info",{message:`${s} defaulting PART-HOLD-BACK to partTargetDuration * 3 (${e[a]}).`})),n&&e[a]<c&&(this.trigger("warn",{message:`${s} clamping PART-HOLD-BACK (${e[a]}) to partTargetDuration * 2 (${c}).`}),e[a]=c)};class X_ extends Co{constructor(e={}){super(),this.lineStream=new V_,this.parseStream=new W_,this.lineStream.pipe(this.parseStream),this.mainDefinitions=e.mainDefinitions||{},this.params=new URL(e.uri,"https://a.com").searchParams,this.lastProgramDateTime=null;const t=this,n=[];let s={},r,a,l=!1;const c=function(){},f={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},m="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";let b=0;this.manifest={allowCache:!0,discontinuityStarts:[],dateRanges:[],iFramePlaylists:[],segments:[]};let C=0,w=0;const A={};this.on("end",()=>{s.uri||!s.parts&&!s.preloadHints||(!s.map&&r&&(s.map=r),!s.key&&a&&(s.key=a),!s.timeline&&typeof b=="number"&&(s.timeline=b),this.manifest.preloadSegment=s)}),this.parseStream.on("data",function(v){let M,D;if(t.manifest.definitions){for(const R in t.manifest.definitions)if(v.uri&&(v.uri=v.uri.replace(`{$${R}}`,t.manifest.definitions[R])),v.attributes)for(const N in v.attributes)typeof v.attributes[N]=="string"&&(v.attributes[N]=v.attributes[N].replace(`{$${R}}`,t.manifest.definitions[R]))}({tag(){({version(){v.version&&(this.manifest.version=v.version)},"allow-cache"(){this.manifest.allowCache=v.allowed,"allowed"in v||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange(){const R={};"length"in v&&(s.byterange=R,R.length=v.length,"offset"in v||(v.offset=C)),"offset"in v&&(s.byterange=R,R.offset=v.offset),C=R.offset+R.length},endlist(){this.manifest.endList=!0},inf(){"mediaSequence"in this.manifest||(this.manifest.mediaSequence=0,this.trigger("info",{message:"defaulting media sequence to zero"})),"discontinuitySequence"in this.manifest||(this.manifest.discontinuitySequence=0,this.trigger("info",{message:"defaulting discontinuity sequence to zero"})),v.title&&(s.title=v.title),v.duration>0&&(s.duration=v.duration),v.duration===0&&(s.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=n},key(){if(!v.attributes){this.trigger("warn",{message:"ignoring key declaration without attribute list"});return}if(v.attributes.METHOD==="NONE"){a=null;return}if(!v.attributes.URI){this.trigger("warn",{message:"ignoring key declaration without URI"});return}if(v.attributes.KEYFORMAT==="com.apple.streamingkeydelivery"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.apple.fps.1_0"]={attributes:v.attributes};return}if(v.attributes.KEYFORMAT==="com.microsoft.playready"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.microsoft.playready"]={uri:v.attributes.URI};return}if(v.attributes.KEYFORMAT===m){if(["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(v.attributes.METHOD)===-1){this.trigger("warn",{message:"invalid key method provided for Widevine"});return}if(v.attributes.METHOD==="SAMPLE-AES-CENC"&&this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"}),v.attributes.URI.substring(0,23)!=="data:text/plain;base64,"){this.trigger("warn",{message:"invalid key URI provided for Widevine"});return}if(!(v.attributes.KEYID&&v.attributes.KEYID.substring(0,2)==="0x")){this.trigger("warn",{message:"invalid key ID provided for Widevine"});return}this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.widevine.alpha"]={attributes:{schemeIdUri:v.attributes.KEYFORMAT,keyId:v.attributes.KEYID.substring(2)},pssh:rh(v.attributes.URI.split(",")[1])};return}v.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),a={method:v.attributes.METHOD||"AES-128",uri:v.attributes.URI},typeof v.attributes.IV<"u"&&(a.iv=v.attributes.IV)},"media-sequence"(){if(!isFinite(v.number)){this.trigger("warn",{message:"ignoring invalid media sequence: "+v.number});return}this.manifest.mediaSequence=v.number},"discontinuity-sequence"(){if(!isFinite(v.number)){this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+v.number});return}this.manifest.discontinuitySequence=v.number,b=v.number},"playlist-type"(){if(!/VOD|EVENT/.test(v.playlistType)){this.trigger("warn",{message:"ignoring unknown playlist type: "+v.playlist});return}this.manifest.playlistType=v.playlistType},map(){r={},v.uri&&(r.uri=v.uri),v.byterange&&(r.byterange=v.byterange),a&&(r.key=a)},"stream-inf"(){if(this.manifest.playlists=n,this.manifest.mediaGroups=this.manifest.mediaGroups||f,!v.attributes){this.trigger("warn",{message:"ignoring empty stream-inf attributes"});return}s.attributes||(s.attributes={}),je(s.attributes,v.attributes)},media(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||f,!(v.attributes&&v.attributes.TYPE&&v.attributes["GROUP-ID"]&&v.attributes.NAME)){this.trigger("warn",{message:"ignoring incomplete or missing media group"});return}const R=this.manifest.mediaGroups[v.attributes.TYPE];R[v.attributes["GROUP-ID"]]=R[v.attributes["GROUP-ID"]]||{},M=R[v.attributes["GROUP-ID"]],D={default:/yes/i.test(v.attributes.DEFAULT)},D.default?D.autoselect=!0:D.autoselect=/yes/i.test(v.attributes.AUTOSELECT),v.attributes.LANGUAGE&&(D.language=v.attributes.LANGUAGE),v.attributes.URI&&(D.uri=v.attributes.URI),v.attributes["INSTREAM-ID"]&&(D.instreamId=v.attributes["INSTREAM-ID"]),v.attributes.CHARACTERISTICS&&(D.characteristics=v.attributes.CHARACTERISTICS),v.attributes.FORCED&&(D.forced=/yes/i.test(v.attributes.FORCED)),M[v.attributes.NAME]=D},discontinuity(){b+=1,s.discontinuity=!0,this.manifest.discontinuityStarts.push(n.length)},"program-date-time"(){typeof this.manifest.dateTimeString>"u"&&(this.manifest.dateTimeString=v.dateTimeString,this.manifest.dateTimeObject=v.dateTimeObject),s.dateTimeString=v.dateTimeString,s.dateTimeObject=v.dateTimeObject;const{lastProgramDateTime:R}=this;this.lastProgramDateTime=new Date(v.dateTimeString).getTime(),R===null&&this.manifest.segments.reduceRight((N,F)=>(F.programDateTime=N-F.duration*1e3,F.programDateTime),this.lastProgramDateTime)},targetduration(){if(!isFinite(v.duration)||v.duration<0){this.trigger("warn",{message:"ignoring invalid target duration: "+v.duration});return}this.manifest.targetDuration=v.duration,xa.call(this,this.manifest)},start(){if(!v.attributes||isNaN(v.attributes["TIME-OFFSET"])){this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"});return}this.manifest.start={timeOffset:v.attributes["TIME-OFFSET"],precise:v.attributes.PRECISE}},"cue-out"(){s.cueOut=v.data},"cue-out-cont"(){s.cueOutCont=v.data},"cue-in"(){s.cueIn=v.data},skip(){this.manifest.skip=gi(v.attributes),this.warnOnMissingAttributes_("#EXT-X-SKIP",v.attributes,["SKIPPED-SEGMENTS"])},part(){l=!0;const R=this.manifest.segments.length,N=gi(v.attributes);s.parts=s.parts||[],s.parts.push(N),N.byterange&&(N.byterange.hasOwnProperty("offset")||(N.byterange.offset=w),w=N.byterange.offset+N.byterange.length);const F=s.parts.length-1;this.warnOnMissingAttributes_(`#EXT-X-PART #${F} for segment #${R}`,v.attributes,["URI","DURATION"]),this.manifest.renditionReports&&this.manifest.renditionReports.forEach((P,$)=>{P.hasOwnProperty("lastPart")||this.trigger("warn",{message:`#EXT-X-RENDITION-REPORT #${$} lacks required attribute(s): LAST-PART`})})},"server-control"(){const R=this.manifest.serverControl=gi(v.attributes);R.hasOwnProperty("canBlockReload")||(R.canBlockReload=!1,this.trigger("info",{message:"#EXT-X-SERVER-CONTROL defaulting CAN-BLOCK-RELOAD to false"})),xa.call(this,this.manifest),R.canSkipDateranges&&!R.hasOwnProperty("canSkipUntil")&&this.trigger("warn",{message:"#EXT-X-SERVER-CONTROL lacks required attribute CAN-SKIP-UNTIL which is required when CAN-SKIP-DATERANGES is set"})},"preload-hint"(){const R=this.manifest.segments.length,N=gi(v.attributes),F=N.type&&N.type==="PART";s.preloadHints=s.preloadHints||[],s.preloadHints.push(N),N.byterange&&(N.byterange.hasOwnProperty("offset")||(N.byterange.offset=F?w:0,F&&(w=N.byterange.offset+N.byterange.length)));const P=s.preloadHints.length-1;if(this.warnOnMissingAttributes_(`#EXT-X-PRELOAD-HINT #${P} for segment #${R}`,v.attributes,["TYPE","URI"]),!!N.type)for(let $=0;$<s.preloadHints.length-1;$++){const Y=s.preloadHints[$];Y.type&&Y.type===N.type&&this.trigger("warn",{message:`#EXT-X-PRELOAD-HINT #${P} for segment #${R} has the same TYPE ${N.type} as preload hint #${$}`})}},"rendition-report"(){const R=gi(v.attributes);this.manifest.renditionReports=this.manifest.renditionReports||[],this.manifest.renditionReports.push(R);const N=this.manifest.renditionReports.length-1,F=["LAST-MSN","URI"];l&&F.push("LAST-PART"),this.warnOnMissingAttributes_(`#EXT-X-RENDITION-REPORT #${N}`,v.attributes,F)},"part-inf"(){this.manifest.partInf=gi(v.attributes),this.warnOnMissingAttributes_("#EXT-X-PART-INF",v.attributes,["PART-TARGET"]),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),xa.call(this,this.manifest)},daterange(){this.manifest.dateRanges.push(gi(v.attributes));const R=this.manifest.dateRanges.length-1;this.warnOnMissingAttributes_(`#EXT-X-DATERANGE #${R}`,v.attributes,["ID","START-DATE"]);const N=this.manifest.dateRanges[R];N.endDate&&N.startDate&&new Date(N.endDate)<new Date(N.startDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE END-DATE must be equal to or later than the value of the START-DATE"}),N.duration&&N.duration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE DURATION must not be negative"}),N.plannedDuration&&N.plannedDuration<0&&this.trigger("warn",{message:"EXT-X-DATERANGE PLANNED-DURATION must not be negative"});const F=!!N.endOnNext;if(F&&!N.class&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must have a CLASS attribute"}),F&&(N.duration||N.endDate)&&this.trigger("warn",{message:"EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must not contain DURATION or END-DATE attributes"}),N.duration&&N.endDate){const P=N.startDate.getTime()+N.duration*1e3;this.manifest.dateRanges[R].endDate=new Date(P)}if(!A[N.id])A[N.id]=N;else{for(const $ in A[N.id])if(N[$]&&JSON.stringify(A[N.id][$])!==JSON.stringify(N[$])){this.trigger("warn",{message:"EXT-X-DATERANGE tags with the same ID in a playlist must have the same attributes values"});break}const P=this.manifest.dateRanges.findIndex($=>$.id===N.id);this.manifest.dateRanges[P]=je(this.manifest.dateRanges[P],N),A[N.id]=je(A[N.id],N),this.manifest.dateRanges.pop()}},"independent-segments"(){this.manifest.independentSegments=!0},"i-frames-only"(){this.manifest.iFramesOnly=!0,this.requiredCompatibilityversion(this.manifest.version,4)},"content-steering"(){this.manifest.contentSteering=gi(v.attributes),this.warnOnMissingAttributes_("#EXT-X-CONTENT-STEERING",v.attributes,["SERVER-URI"])},define(){this.manifest.definitions=this.manifest.definitions||{};const R=(N,F)=>{if(N in this.manifest.definitions){this.trigger("error",{message:`EXT-X-DEFINE: Duplicate name ${N}`});return}this.manifest.definitions[N]=F};if("QUERYPARAM"in v.attributes){if("NAME"in v.attributes||"IMPORT"in v.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}const N=this.params.get(v.attributes.QUERYPARAM);if(!N){this.trigger("error",{message:`EXT-X-DEFINE: No query param ${v.attributes.QUERYPARAM}`});return}R(v.attributes.QUERYPARAM,decodeURIComponent(N));return}if("NAME"in v.attributes){if("IMPORT"in v.attributes){this.trigger("error",{message:"EXT-X-DEFINE: Invalid attributes"});return}if(!("VALUE"in v.attributes)||typeof v.attributes.VALUE!="string"){this.trigger("error",{message:`EXT-X-DEFINE: No value for ${v.attributes.NAME}`});return}R(v.attributes.NAME,v.attributes.VALUE);return}if("IMPORT"in v.attributes){if(!this.mainDefinitions[v.attributes.IMPORT]){this.trigger("error",{message:`EXT-X-DEFINE: No value ${v.attributes.IMPORT} to import, or IMPORT used on main playlist`});return}R(v.attributes.IMPORT,this.mainDefinitions[v.attributes.IMPORT]);return}this.trigger("error",{message:"EXT-X-DEFINE: No attribute"})},"i-frame-playlist"(){this.manifest.iFramePlaylists.push({attributes:v.attributes,uri:v.uri,timeline:b}),this.warnOnMissingAttributes_("#EXT-X-I-FRAME-STREAM-INF",v.attributes,["BANDWIDTH","URI"])}}[v.tagType]||c).call(t)},uri(){s.uri=v.uri,n.push(s),this.manifest.targetDuration&&!("duration"in s)&&(this.trigger("warn",{message:"defaulting segment duration to the target duration"}),s.duration=this.manifest.targetDuration),a&&(s.key=a),s.timeline=b,r&&(s.map=r),w=0,this.lastProgramDateTime!==null&&(s.programDateTime=this.lastProgramDateTime,this.lastProgramDateTime+=s.duration*1e3),s={}},comment(){},custom(){v.segment?(s.custom=s.custom||{},s.custom[v.customType]=v.data):(this.manifest.custom=this.manifest.custom||{},this.manifest.custom[v.customType]=v.data)}})[v.type].call(t)})}requiredCompatibilityversion(e,t){(e<t||!e)&&this.trigger("warn",{message:`manifest must be at least version ${t}`})}warnOnMissingAttributes_(e,t,n){const s=[];n.forEach(function(r){t.hasOwnProperty(r)||s.push(r)}),s.length&&this.trigger("warn",{message:`${e} lacks required attribute(s): ${s.join(", ")}`})}push(e){this.lineStream.push(e)}end(){this.lineStream.push(`
|
|
24
|
+
`),this.manifest.dateRanges.length&&this.lastProgramDateTime===null&&this.trigger("warn",{message:"A playlist with EXT-X-DATERANGE tag must contain atleast one EXT-X-PROGRAM-DATE-TIME tag"}),this.lastProgramDateTime=null,this.trigger("end")}addParser(e){this.parseStream.addParser(e)}addTagMapper(e){this.parseStream.addTagMapper(e)}}var Ni={mp4:/^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/,webm:/^(vp0?[89]|av0?1|opus|vorbis)/,ogg:/^(vp0?[89]|theora|flac|opus|vorbis)/,video:/^(av0?1|avc0?[1234]|vp0?[89]|hvc1|hev1|theora|mp4v)/,audio:/^(mp4a|flac|vorbis|opus|ac-[34]|ec-3|alac|mp3|speex|aac)/,text:/^(stpp.ttml.im1t)/,muxerVideo:/^(avc0?1)/,muxerAudio:/^(mp4a)/,muxerText:/a^/},K_=["video","audio","text"],Tu=["Video","Audio","Text"],ah=function(i){return i&&i.replace(/avc1\.(\d+)\.(\d+)/i,function(e,t,n){var s=("00"+Number(t).toString(16)).slice(-2),r=("00"+Number(n).toString(16)).slice(-2);return"avc1."+s+"00"+r})},Ht=function(i){i===void 0&&(i="");var e=i.split(","),t=[];return e.forEach(function(n){n=n.trim();var s;K_.forEach(function(r){var a=Ni[r].exec(n.toLowerCase());if(!(!a||a.length<=1)){s=r;var l=n.substring(0,a[1].length),c=n.replace(l,"");t.push({type:l,details:c,mediaType:r})}}),s||t.push({type:n,details:"",mediaType:"unknown"})}),t},Y_=function(i,e){if(!i.mediaGroups.AUDIO||!e)return null;var t=i.mediaGroups.AUDIO[e];if(!t)return null;for(var n in t){var s=t[n];if(s.default&&s.playlists)return Ht(s.playlists[0].attributes.CODECS)}return null},oh=function(i){return i===void 0&&(i=""),Ni.audio.test(i.trim().toLowerCase())},Q_=function(i){return i===void 0&&(i=""),Ni.text.test(i.trim().toLowerCase())},cn=function(i){if(!(!i||typeof i!="string")){var e=i.toLowerCase().split(",").map(function(s){return ah(s.trim())}),t="video";e.length===1&&oh(e[0])?t="audio":e.length===1&&Q_(e[0])&&(t="application");var n="mp4";return e.every(function(s){return Ni.mp4.test(s)})?n="mp4":e.every(function(s){return Ni.webm.test(s)})?n="webm":e.every(function(s){return Ni.ogg.test(s)})&&(n="ogg"),t+"/"+n+';codecs="'+i+'"'}},as=function(i,e){return i===void 0&&(i=""),e===void 0&&(e=!1),x.MediaSource&&x.MediaSource.isTypeSupported&&x.MediaSource.isTypeSupported(cn(i))||e&&x.ManagedMediaSource&&x.ManagedMediaSource.isTypeSupported&&x.ManagedMediaSource.isTypeSupported(cn(i))||!1},Aa=function(i){return i===void 0&&(i=""),i.toLowerCase().split(",").every(function(e){e=e.trim();for(var t=0;t<Tu.length;t++){var n=Tu[t];if(Ni["muxer"+n].test(e))return!0}return!1})},vu="mp4a.40.2",J_="avc1.4d400d",Z_=/^(audio|video|application)\/(x-|vnd\.apple\.)?mpegurl/i,e0=/^application\/dash\+xml/i,lh=function(i){return Z_.test(i)?"hls":e0.test(i)?"dash":i==="application/vnd.videojs.vhs+json"?"vhs-json":null},t0=function(i){return i.toString(2).length},i0=function(i){return Math.ceil(t0(i)/8)},uh=function(i){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(i):i&&i.buffer instanceof ArrayBuffer},n0=function(i){return uh(i)},ie=function(i){return i instanceof Uint8Array?i:(!Array.isArray(i)&&!n0(i)&&!(i instanceof ArrayBuffer)&&(typeof i!="number"||typeof i=="number"&&i!==i?i=0:i=[i]),new Uint8Array(i&&i.buffer||i,i&&i.byteOffset||0,i&&i.byteLength||0))},Ke=x.BigInt||Number,Wa=[Ke("0x1"),Ke("0x100"),Ke("0x10000"),Ke("0x1000000"),Ke("0x100000000"),Ke("0x10000000000"),Ke("0x1000000000000"),Ke("0x100000000000000"),Ke("0x10000000000000000")];(function(){var i=new Uint16Array([65484]),e=new Uint8Array(i.buffer,i.byteOffset,i.byteLength);return e[0]===255?"big":e[0]===204?"little":"unknown"})();var s0=function(i,e){var t=e===void 0?{}:e,n=t.signed,s=n===void 0?!1:n,r=t.le,a=r===void 0?!1:r;i=ie(i);var l=a?"reduce":"reduceRight",c=i[l]?i[l]:Array.prototype[l],f=c.call(i,function(b,C,w){var A=a?w:Math.abs(w+1-i.length);return b+Ke(C)*Wa[A]},Ke(0));if(s){var m=Wa[i.length]/Ke(2)-Ke(1);f=Ke(f),f>m&&(f-=m,f-=m,f-=Ke(2))}return Number(f)},r0=function(i,e){var t={},n=t.le,s=n===void 0?!1:n;(typeof i!="bigint"&&typeof i!="number"||typeof i=="number"&&i!==i)&&(i=0),i=Ke(i);for(var r=i0(i),a=new Uint8Array(new ArrayBuffer(r)),l=0;l<r;l++){var c=s?l:Math.abs(l+1-a.length);a[c]=Number(i/Wa[l]&Ke(255)),i<0&&(a[c]=Math.abs(~a[c]),a[c]-=l===0?1:2)}return a},dh=function(i,e){if(typeof i!="string"&&i&&typeof i.toString=="function"&&(i=i.toString()),typeof i!="string")return new Uint8Array;e||(i=unescape(encodeURIComponent(i)));for(var t=new Uint8Array(i.length),n=0;n<i.length;n++)t[n]=i.charCodeAt(n);return t},a0=function(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];if(e=e.filter(function(a){return a&&(a.byteLength||a.length)&&typeof a!="string"}),e.length<=1)return ie(e[0]);var n=e.reduce(function(a,l,c){return a+(l.byteLength||l.length)},0),s=new Uint8Array(n),r=0;return e.forEach(function(a){a=ie(a),s.set(a,r),r+=a.byteLength}),s},Le=function(i,e,t){var n=t===void 0?{}:t,s=n.offset,r=s===void 0?0:s,a=n.mask,l=a===void 0?[]:a;i=ie(i),e=ie(e);var c=e.every?e.every:Array.prototype.every;return e.length&&i.length-r>=e.length&&c.call(e,function(f,m){var b=l[m]?l[m]&i[r+m]:i[r+m];return f===b})},o0=function(i,e,t){e.forEach(function(n){for(var s in i.mediaGroups[n])for(var r in i.mediaGroups[n][s]){var a=i.mediaGroups[n][s][r];t(a,n,s,r)}})};/*! @name mpd-parser @version 1.3.1 @license Apache-2.0 */const Su=i=>!!i&&typeof i=="object",Ge=(...i)=>i.reduce((e,t)=>(typeof t!="object"||Object.keys(t).forEach(n=>{Array.isArray(e[n])&&Array.isArray(t[n])?e[n]=e[n].concat(t[n]):Su(e[n])&&Su(t[n])?e[n]=Ge(e[n],t[n]):e[n]=t[n]}),e),{}),hh=i=>Object.keys(i).map(e=>i[e]),l0=(i,e)=>{const t=[];for(let n=i;n<e;n++)t.push(n);return t},pn=i=>i.reduce((e,t)=>e.concat(t),[]),ch=i=>{if(!i.length)return[];const e=[];for(let t=0;t<i.length;t++)e.push(i[t]);return e},u0=(i,e)=>i.reduce((t,n,s)=>(n[e]&&t.push(s),t),[]),d0=(i,e)=>hh(i.reduce((t,n)=>(n.forEach(s=>{t[e(s)]=s}),t),{}));var gn={INVALID_NUMBER_OF_PERIOD:"INVALID_NUMBER_OF_PERIOD",INVALID_NUMBER_OF_CONTENT_STEERING:"INVALID_NUMBER_OF_CONTENT_STEERING",DASH_EMPTY_MANIFEST:"DASH_EMPTY_MANIFEST",DASH_INVALID_XML:"DASH_INVALID_XML",NO_BASE_URL:"NO_BASE_URL",MISSING_SEGMENT_INFORMATION:"MISSING_SEGMENT_INFORMATION",SEGMENT_TIME_UNSPECIFIED:"SEGMENT_TIME_UNSPECIFIED",UNSUPPORTED_UTC_TIMING_SCHEME:"UNSUPPORTED_UTC_TIMING_SCHEME"};const cs=({baseUrl:i="",source:e="",range:t="",indexRange:n=""})=>{const s={uri:e,resolvedUri:Mr(i||"",e)};if(t||n){const r=(t||n).split("-");let a=x.BigInt?x.BigInt(r[0]):parseInt(r[0],10),l=x.BigInt?x.BigInt(r[1]):parseInt(r[1],10);a<Number.MAX_SAFE_INTEGER&&typeof a=="bigint"&&(a=Number(a)),l<Number.MAX_SAFE_INTEGER&&typeof l=="bigint"&&(l=Number(l));let c;typeof l=="bigint"||typeof a=="bigint"?c=x.BigInt(l)-x.BigInt(a)+x.BigInt(1):c=l-a+1,typeof c=="bigint"&&c<Number.MAX_SAFE_INTEGER&&(c=Number(c)),s.byterange={length:c,offset:a}}return s},h0=i=>{let e;return typeof i.offset=="bigint"||typeof i.length=="bigint"?e=x.BigInt(i.offset)+x.BigInt(i.length)-x.BigInt(1):e=i.offset+i.length-1,`${i.offset}-${e}`},Eu=i=>(i&&typeof i!="number"&&(i=parseInt(i,10)),isNaN(i)?null:i),c0={static(i){const{duration:e,timescale:t=1,sourceDuration:n,periodDuration:s}=i,r=Eu(i.endNumber),a=e/t;return typeof r=="number"?{start:0,end:r}:typeof s=="number"?{start:0,end:s/a}:{start:0,end:n/a}},dynamic(i){const{NOW:e,clientOffset:t,availabilityStartTime:n,timescale:s=1,duration:r,periodStart:a=0,minimumUpdatePeriod:l=0,timeShiftBufferDepth:c=1/0}=i,f=Eu(i.endNumber),m=(e+t)/1e3,b=n+a,C=m+l-b,w=Math.ceil(C*s/r),A=Math.floor((m-b-c)*s/r),v=Math.floor((m-b)*s/r);return{start:Math.max(0,A),end:typeof f=="number"?f:Math.min(w,v)}}},p0=i=>e=>{const{duration:t,timescale:n=1,periodStart:s,startNumber:r=1}=i;return{number:r+e,duration:t/n,timeline:s,time:e*t}},xo=i=>{const{type:e,duration:t,timescale:n=1,periodDuration:s,sourceDuration:r}=i,{start:a,end:l}=c0[e](i),c=l0(a,l).map(p0(i));if(e==="static"){const f=c.length-1,m=typeof s=="number"?s:r;c[f].duration=m-t/n*f}return c},ph=i=>{const{baseUrl:e,initialization:t={},sourceDuration:n,indexRange:s="",periodStart:r,presentationTime:a,number:l=0,duration:c}=i;if(!e)throw new Error(gn.NO_BASE_URL);const f=cs({baseUrl:e,source:t.sourceURL,range:t.range}),m=cs({baseUrl:e,source:e,indexRange:s});if(m.map=f,c){const b=xo(i);b.length&&(m.duration=b[0].duration,m.timeline=b[0].timeline)}else n&&(m.duration=n,m.timeline=r);return m.presentationTime=a||r,m.number=l,[m]},Ao=(i,e,t)=>{const n=i.sidx.map?i.sidx.map:null,s=i.sidx.duration,r=i.timeline||0,a=i.sidx.byterange,l=a.offset+a.length,c=e.timescale,f=e.references.filter(M=>M.referenceType!==1),m=[],b=i.endList?"static":"dynamic",C=i.sidx.timeline;let w=C,A=i.mediaSequence||0,v;typeof e.firstOffset=="bigint"?v=x.BigInt(l)+e.firstOffset:v=l+e.firstOffset;for(let M=0;M<f.length;M++){const D=e.references[M],R=D.referencedSize,N=D.subsegmentDuration;let F;typeof v=="bigint"?F=v+x.BigInt(R)-x.BigInt(1):F=v+R-1;const P=`${v}-${F}`,$=ph({baseUrl:t,timescale:c,timeline:r,periodStart:C,presentationTime:w,number:A,duration:N,sourceDuration:s,indexRange:P,type:b})[0];n&&($.map=n),m.push($),typeof v=="bigint"?v+=x.BigInt(R):v+=R,w+=N/c,A++}return i.segments=m,i},g0=["AUDIO","SUBTITLES"],f0=1/60,gh=i=>d0(i,({timeline:e})=>e).sort((e,t)=>e.timeline>t.timeline?1:-1),m0=(i,e)=>{for(let t=0;t<i.length;t++)if(i[t].attributes.NAME===e)return i[t];return null},wu=i=>{let e=[];return o0(i,g0,(t,n,s,r)=>{e=e.concat(t.playlists||[])}),e},ku=({playlist:i,mediaSequence:e})=>{i.mediaSequence=e,i.segments.forEach((t,n)=>{t.number=i.mediaSequence+n})},y0=({oldPlaylists:i,newPlaylists:e,timelineStarts:t})=>{e.forEach(n=>{n.discontinuitySequence=t.findIndex(function({timeline:l}){return l===n.timeline});const s=m0(i,n.attributes.NAME);if(!s||n.sidx)return;const r=n.segments[0],a=s.segments.findIndex(function(l){return Math.abs(l.presentationTime-r.presentationTime)<f0});if(a===-1){ku({playlist:n,mediaSequence:s.mediaSequence+s.segments.length}),n.segments[0].discontinuity=!0,n.discontinuityStarts.unshift(0),(!s.segments.length&&n.timeline>s.timeline||s.segments.length&&n.timeline>s.segments[s.segments.length-1].timeline)&&n.discontinuitySequence--;return}s.segments[a].discontinuity&&!r.discontinuity&&(r.discontinuity=!0,n.discontinuityStarts.unshift(0),n.discontinuitySequence--),ku({playlist:n,mediaSequence:s.segments[a].number})})},_0=({oldManifest:i,newManifest:e})=>{const t=i.playlists.concat(wu(i)),n=e.playlists.concat(wu(e));return e.timelineStarts=gh([i.timelineStarts,e.timelineStarts]),y0({oldPlaylists:t,newPlaylists:n,timelineStarts:e.timelineStarts}),e},Ur=i=>i&&i.uri+"-"+h0(i.byterange),Pa=i=>{const e=i.reduce(function(n,s){return n[s.attributes.baseUrl]||(n[s.attributes.baseUrl]=[]),n[s.attributes.baseUrl].push(s),n},{});let t=[];return Object.values(e).forEach(n=>{const s=hh(n.reduce((r,a)=>{const l=a.attributes.id+(a.attributes.lang||"");return r[l]?(a.segments&&(a.segments[0]&&(a.segments[0].discontinuity=!0),r[l].segments.push(...a.segments)),a.attributes.contentProtection&&(r[l].attributes.contentProtection=a.attributes.contentProtection)):(r[l]=a,r[l].attributes.timelineStarts=[]),r[l].attributes.timelineStarts.push({start:a.attributes.periodStart,timeline:a.attributes.periodStart}),r},{}));t=t.concat(s)}),t.map(n=>(n.discontinuityStarts=u0(n.segments||[],"discontinuity"),n))},Po=(i,e)=>{const t=Ur(i.sidx),n=t&&e[t]&&e[t].sidx;return n&&Ao(i,n,i.sidx.resolvedUri),i},b0=(i,e={})=>{if(!Object.keys(e).length)return i;for(const t in i)i[t]=Po(i[t],e);return i},T0=({attributes:i,segments:e,sidx:t,mediaSequence:n,discontinuitySequence:s,discontinuityStarts:r},a)=>{const l={attributes:{NAME:i.id,BANDWIDTH:i.bandwidth,CODECS:i.codecs,"PROGRAM-ID":1},uri:"",endList:i.type==="static",timeline:i.periodStart,resolvedUri:i.baseUrl||"",targetDuration:i.duration,discontinuitySequence:s,discontinuityStarts:r,timelineStarts:i.timelineStarts,mediaSequence:n,segments:e};return i.contentProtection&&(l.contentProtection=i.contentProtection),i.serviceLocation&&(l.attributes.serviceLocation=i.serviceLocation),t&&(l.sidx=t),a&&(l.attributes.AUDIO="audio",l.attributes.SUBTITLES="subs"),l},v0=({attributes:i,segments:e,mediaSequence:t,discontinuityStarts:n,discontinuitySequence:s})=>{typeof e>"u"&&(e=[{uri:i.baseUrl,timeline:i.periodStart,resolvedUri:i.baseUrl||"",duration:i.sourceDuration,number:0}],i.duration=i.sourceDuration);const r={NAME:i.id,BANDWIDTH:i.bandwidth,"PROGRAM-ID":1};i.codecs&&(r.CODECS=i.codecs);const a={attributes:r,uri:"",endList:i.type==="static",timeline:i.periodStart,resolvedUri:i.baseUrl||"",targetDuration:i.duration,timelineStarts:i.timelineStarts,discontinuityStarts:n,discontinuitySequence:s,mediaSequence:t,segments:e};return i.serviceLocation&&(a.attributes.serviceLocation=i.serviceLocation),a},S0=(i,e={},t=!1)=>{let n;const s=i.reduce((r,a)=>{const l=a.attributes.role&&a.attributes.role.value||"",c=a.attributes.lang||"";let f=a.attributes.label||"main";if(c&&!a.attributes.label){const b=l?` (${l})`:"";f=`${a.attributes.lang}${b}`}r[f]||(r[f]={language:c,autoselect:!0,default:l==="main",playlists:[],uri:""});const m=Po(T0(a,t),e);return r[f].playlists.push(m),typeof n>"u"&&l==="main"&&(n=a,n.default=!0),r},{});if(!n){const r=Object.keys(s)[0];s[r].default=!0}return s},E0=(i,e={})=>i.reduce((t,n)=>{const s=n.attributes.label||n.attributes.lang||"text",r=n.attributes.lang||"und";return t[s]||(t[s]={language:r,default:!1,autoselect:!1,playlists:[],uri:""}),t[s].playlists.push(Po(v0(n),e)),t},{}),w0=i=>i.reduce((e,t)=>(t&&t.forEach(n=>{const{channel:s,language:r}=n;e[r]={autoselect:!1,default:!1,instreamId:s,language:r},n.hasOwnProperty("aspectRatio")&&(e[r].aspectRatio=n.aspectRatio),n.hasOwnProperty("easyReader")&&(e[r].easyReader=n.easyReader),n.hasOwnProperty("3D")&&(e[r]["3D"]=n["3D"])}),e),{}),k0=({attributes:i,segments:e,sidx:t,discontinuityStarts:n})=>{const s={attributes:{NAME:i.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:i.width,height:i.height},CODECS:i.codecs,BANDWIDTH:i.bandwidth,"PROGRAM-ID":1},uri:"",endList:i.type==="static",timeline:i.periodStart,resolvedUri:i.baseUrl||"",targetDuration:i.duration,discontinuityStarts:n,timelineStarts:i.timelineStarts,segments:e};return i.frameRate&&(s.attributes["FRAME-RATE"]=i.frameRate),i.contentProtection&&(s.contentProtection=i.contentProtection),i.serviceLocation&&(s.attributes.serviceLocation=i.serviceLocation),t&&(s.sidx=t),s},C0=({attributes:i})=>i.mimeType==="video/mp4"||i.mimeType==="video/webm"||i.contentType==="video",I0=({attributes:i})=>i.mimeType==="audio/mp4"||i.mimeType==="audio/webm"||i.contentType==="audio",x0=({attributes:i})=>i.mimeType==="text/vtt"||i.contentType==="text",A0=(i,e)=>{i.forEach(t=>{t.mediaSequence=0,t.discontinuitySequence=e.findIndex(function({timeline:n}){return n===t.timeline}),t.segments&&t.segments.forEach((n,s)=>{n.number=s})})},Cu=i=>i?Object.keys(i).reduce((e,t)=>{const n=i[t];return e.concat(n.playlists)},[]):[],P0=({dashPlaylists:i,locations:e,contentSteering:t,sidxMapping:n={},previousManifest:s,eventStream:r})=>{if(!i.length)return{};const{sourceDuration:a,type:l,suggestedPresentationDelay:c,minimumUpdatePeriod:f}=i[0].attributes,m=Pa(i.filter(C0)).map(k0),b=Pa(i.filter(I0)),C=Pa(i.filter(x0)),w=i.map(F=>F.attributes.captionServices).filter(Boolean),A={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:"",duration:a,playlists:b0(m,n)};f>=0&&(A.minimumUpdatePeriod=f*1e3),e&&(A.locations=e),t&&(A.contentSteering=t),l==="dynamic"&&(A.suggestedPresentationDelay=c),r&&r.length>0&&(A.eventStream=r);const v=A.playlists.length===0,M=b.length?S0(b,n,v):null,D=C.length?E0(C,n):null,R=m.concat(Cu(M),Cu(D)),N=R.map(({timelineStarts:F})=>F);return A.timelineStarts=gh(N),A0(R,A.timelineStarts),M&&(A.mediaGroups.AUDIO.audio=M),D&&(A.mediaGroups.SUBTITLES.subs=D),w.length&&(A.mediaGroups["CLOSED-CAPTIONS"].cc=w0(w)),s?_0({oldManifest:s,newManifest:A}):A},L0=(i,e,t)=>{const{NOW:n,clientOffset:s,availabilityStartTime:r,timescale:a=1,periodStart:l=0,minimumUpdatePeriod:c=0}=i,f=(n+s)/1e3,m=r+l,b=f+c-m;return Math.ceil((b*a-e)/t)},fh=(i,e)=>{const{type:t,minimumUpdatePeriod:n=0,media:s="",sourceDuration:r,timescale:a=1,startNumber:l=1,periodStart:c}=i,f=[];let m=-1;for(let b=0;b<e.length;b++){const C=e[b],w=C.d,A=C.r||0,v=C.t||0;m<0&&(m=v),v&&v>m&&(m=v);let M;if(A<0){const N=b+1;N===e.length?t==="dynamic"&&n>0&&s.indexOf("$Number$")>0?M=L0(i,m,w):M=(r*a-m)/w:M=(e[N].t-m)/w}else M=A+1;const D=l+f.length+M;let R=l+f.length;for(;R<D;)f.push({number:R,duration:w/a,time:m,timeline:c}),m+=w,R++}return f},D0=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,O0=i=>(e,t,n,s)=>{if(e==="$$")return"$";if(typeof i[t]>"u")return e;const r=""+i[t];return t==="RepresentationID"||(n?s=parseInt(s,10):s=1,r.length>=s)?r:`${new Array(s-r.length+1).join("0")}${r}`},Iu=(i,e)=>i.replace(D0,O0(e)),M0=(i,e)=>!i.duration&&!e?[{number:i.startNumber||1,duration:i.sourceDuration,time:0,timeline:i.periodStart}]:i.duration?xo(i):fh(i,e),R0=(i,e)=>{const t={RepresentationID:i.id,Bandwidth:i.bandwidth||0},{initialization:n={sourceURL:"",range:""}}=i,s=cs({baseUrl:i.baseUrl,source:Iu(n.sourceURL,t),range:n.range});return M0(i,e).map(r=>{t.Number=r.number,t.Time=r.time;const a=Iu(i.media||"",t),l=i.timescale||1,c=i.presentationTimeOffset||0,f=i.periodStart+(r.time-c)/l;return{uri:a,timeline:r.timeline,duration:r.duration,resolvedUri:Mr(i.baseUrl||"",a),map:s,number:r.number,presentationTime:f}})},U0=(i,e)=>{const{baseUrl:t,initialization:n={}}=i,s=cs({baseUrl:t,source:n.sourceURL,range:n.range}),r=cs({baseUrl:t,source:e.media,range:e.mediaRange});return r.map=s,r},N0=(i,e)=>{const{duration:t,segmentUrls:n=[],periodStart:s}=i;if(!t&&!e||t&&e)throw new Error(gn.SEGMENT_TIME_UNSPECIFIED);const r=n.map(l=>U0(i,l));let a;return t&&(a=xo(i)),e&&(a=fh(i,e)),a.map((l,c)=>{if(r[c]){const f=r[c],m=i.timescale||1,b=i.presentationTimeOffset||0;return f.timeline=l.timeline,f.duration=l.duration,f.number=l.number,f.presentationTime=s+(l.time-b)/m,f}}).filter(l=>l)},B0=({attributes:i,segmentInfo:e})=>{let t,n;e.template?(n=R0,t=Ge(i,e.template)):e.base?(n=ph,t=Ge(i,e.base)):e.list&&(n=N0,t=Ge(i,e.list));const s={attributes:i};if(!n)return s;const r=n(t,e.segmentTimeline);if(t.duration){const{duration:a,timescale:l=1}=t;t.duration=a/l}else r.length?t.duration=r.reduce((a,l)=>Math.max(a,Math.ceil(l.duration)),0):t.duration=0;return s.attributes=t,s.segments=r,e.base&&t.indexRange&&(s.sidx=r[0],s.segments=[]),s},F0=i=>i.map(B0),De=(i,e)=>ch(i.childNodes).filter(({tagName:t})=>t===e),ys=i=>i.textContent.trim(),j0=i=>parseFloat(i.split("/").reduce((e,t)=>e/t)),Qi=i=>{const e=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(i);if(!e)return 0;const[t,n,s,r,a,l]=e.slice(1);return parseFloat(t||0)*31536e3+parseFloat(n||0)*2592e3+parseFloat(s||0)*86400+parseFloat(r||0)*3600+parseFloat(a||0)*60+parseFloat(l||0)},$0=i=>(/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(i)&&(i+="Z"),Date.parse(i)),xu={mediaPresentationDuration(i){return Qi(i)},availabilityStartTime(i){return $0(i)/1e3},minimumUpdatePeriod(i){return Qi(i)},suggestedPresentationDelay(i){return Qi(i)},type(i){return i},timeShiftBufferDepth(i){return Qi(i)},start(i){return Qi(i)},width(i){return parseInt(i,10)},height(i){return parseInt(i,10)},bandwidth(i){return parseInt(i,10)},frameRate(i){return j0(i)},startNumber(i){return parseInt(i,10)},timescale(i){return parseInt(i,10)},presentationTimeOffset(i){return parseInt(i,10)},duration(i){const e=parseInt(i,10);return isNaN(e)?Qi(i):e},d(i){return parseInt(i,10)},t(i){return parseInt(i,10)},r(i){return parseInt(i,10)},presentationTime(i){return parseInt(i,10)},DEFAULT(i){return i}},qe=i=>i&&i.attributes?ch(i.attributes).reduce((e,t)=>{const n=xu[t.name]||xu.DEFAULT;return e[t.name]=n(t.value),e},{}):{},q0={"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb":"com.adobe.primetime","urn:mpeg:dash:mp4protection:2011":"mp4protection"},Nr=(i,e)=>e.length?pn(i.map(function(t){return e.map(function(n){const s=ys(n),r=Mr(t.baseUrl,s),a=Ge(qe(n),{baseUrl:r});return r!==s&&!a.serviceLocation&&t.serviceLocation&&(a.serviceLocation=t.serviceLocation),a})})):i,Lo=i=>{const e=De(i,"SegmentTemplate")[0],t=De(i,"SegmentList")[0],n=t&&De(t,"SegmentURL").map(b=>Ge({tag:"SegmentURL"},qe(b))),s=De(i,"SegmentBase")[0],r=t||e,a=r&&De(r,"SegmentTimeline")[0],l=t||s||e,c=l&&De(l,"Initialization")[0],f=e&&qe(e);f&&c?f.initialization=c&&qe(c):f&&f.initialization&&(f.initialization={sourceURL:f.initialization});const m={template:f,segmentTimeline:a&&De(a,"S").map(b=>qe(b)),list:t&&Ge(qe(t),{segmentUrls:n,initialization:qe(c)}),base:s&&Ge(qe(s),{initialization:qe(c)})};return Object.keys(m).forEach(b=>{m[b]||delete m[b]}),m},V0=(i,e,t)=>n=>{const s=De(n,"BaseURL"),r=Nr(e,s),a=Ge(i,qe(n)),l=Lo(n);return r.map(c=>({segmentInfo:Ge(t,l),attributes:Ge(a,c)}))},H0=i=>i.reduce((e,t)=>{const n=qe(t);n.schemeIdUri&&(n.schemeIdUri=n.schemeIdUri.toLowerCase());const s=q0[n.schemeIdUri];if(s){e[s]={attributes:n};const r=De(t,"cenc:pssh")[0];if(r){const a=ys(r);e[s].pssh=a&&rh(a)}}return e},{}),z0=i=>{if(i.schemeIdUri==="urn:scte:dash:cc:cea-608:2015")return(typeof i.value!="string"?[]:i.value.split(";")).map(e=>{let t,n;return n=e,/^CC\d=/.test(e)?[t,n]=e.split("="):/^CC\d$/.test(e)&&(t=e),{channel:t,language:n}});if(i.schemeIdUri==="urn:scte:dash:cc:cea-708:2015")return(typeof i.value!="string"?[]:i.value.split(";")).map(e=>{const t={channel:void 0,language:void 0,aspectRatio:1,easyReader:0,"3D":0};if(/=/.test(e)){const[n,s=""]=e.split("=");t.channel=n,t.language=e,s.split(",").forEach(r=>{const[a,l]=r.split(":");a==="lang"?t.language=l:a==="er"?t.easyReader=Number(l):a==="war"?t.aspectRatio=Number(l):a==="3D"&&(t["3D"]=Number(l))})}else t.language=e;return t.channel&&(t.channel="SERVICE"+t.channel),t})},W0=i=>pn(De(i.node,"EventStream").map(e=>{const t=qe(e),n=t.schemeIdUri;return De(e,"Event").map(s=>{const r=qe(s),a=r.presentationTime||0,l=t.timescale||1,c=r.duration||0,f=a/l+i.attributes.start;return{schemeIdUri:n,value:t.value,id:r.id,start:f,end:f+c/l,messageData:ys(s)||r.messageData,contentEncoding:t.contentEncoding,presentationTimeOffset:t.presentationTimeOffset||0}})})),G0=(i,e,t)=>n=>{const s=qe(n),r=Nr(e,De(n,"BaseURL")),a=De(n,"Role")[0],l={role:qe(a)};let c=Ge(i,s,l);const f=De(n,"Accessibility")[0],m=z0(qe(f));m&&(c=Ge(c,{captionServices:m}));const b=De(n,"Label")[0];if(b&&b.childNodes.length){const M=b.childNodes[0].nodeValue.trim();c=Ge(c,{label:M})}const C=H0(De(n,"ContentProtection"));Object.keys(C).length&&(c=Ge(c,{contentProtection:C}));const w=Lo(n),A=De(n,"Representation"),v=Ge(t,w);return pn(A.map(V0(c,r,v)))},X0=(i,e)=>(t,n)=>{const s=Nr(e,De(t.node,"BaseURL")),r=Ge(i,{periodStart:t.attributes.start});typeof t.attributes.duration=="number"&&(r.periodDuration=t.attributes.duration);const a=De(t.node,"AdaptationSet"),l=Lo(t.node);return pn(a.map(G0(r,s,l)))},K0=(i,e)=>{if(i.length>1&&e({type:"warn",message:"The MPD manifest should contain no more than one ContentSteering tag"}),!i.length)return null;const t=Ge({serverURL:ys(i[0])},qe(i[0]));return t.queryBeforeStart=t.queryBeforeStart==="true",t},Y0=({attributes:i,priorPeriodAttributes:e,mpdType:t})=>typeof i.start=="number"?i.start:e&&typeof e.start=="number"&&typeof e.duration=="number"?e.start+e.duration:!e&&t==="static"?0:null,Q0=(i,e={})=>{const{manifestUri:t="",NOW:n=Date.now(),clientOffset:s=0,eventHandler:r=function(){}}=e,a=De(i,"Period");if(!a.length)throw new Error(gn.INVALID_NUMBER_OF_PERIOD);const l=De(i,"Location"),c=qe(i),f=Nr([{baseUrl:t}],De(i,"BaseURL")),m=De(i,"ContentSteering");c.type=c.type||"static",c.sourceDuration=c.mediaPresentationDuration||0,c.NOW=n,c.clientOffset=s,l.length&&(c.locations=l.map(ys));const b=[];return a.forEach((C,w)=>{const A=qe(C),v=b[w-1];A.start=Y0({attributes:A,priorPeriodAttributes:v?v.attributes:null,mpdType:c.type}),b.push({node:C,attributes:A})}),{locations:c.locations,contentSteeringInfo:K0(m,r),representationInfo:pn(b.map(X0(c,f))),eventStream:pn(b.map(W0))}},mh=i=>{if(i==="")throw new Error(gn.DASH_EMPTY_MANIFEST);const e=new Qf.D;let t,n;try{t=e.parseFromString(i,"application/xml"),n=t&&t.documentElement.tagName==="MPD"?t.documentElement:null}catch{}if(!n||n&&n.getElementsByTagName("parsererror").length>0)throw new Error(gn.DASH_INVALID_XML);return n},J0=i=>{const e=De(i,"UTCTiming")[0];if(!e)return null;const t=qe(e);switch(t.schemeIdUri){case"urn:mpeg:dash:utc:http-head:2014":case"urn:mpeg:dash:utc:http-head:2012":t.method="HEAD";break;case"urn:mpeg:dash:utc:http-xsdate:2014":case"urn:mpeg:dash:utc:http-iso:2014":case"urn:mpeg:dash:utc:http-xsdate:2012":case"urn:mpeg:dash:utc:http-iso:2012":t.method="GET";break;case"urn:mpeg:dash:utc:direct:2014":case"urn:mpeg:dash:utc:direct:2012":t.method="DIRECT",t.value=Date.parse(t.value);break;case"urn:mpeg:dash:utc:http-ntp:2014":case"urn:mpeg:dash:utc:ntp:2014":case"urn:mpeg:dash:utc:sntp:2014":default:throw new Error(gn.UNSUPPORTED_UTC_TIMING_SCHEME)}return t},Z0=(i,e={})=>{const t=Q0(mh(i),e),n=F0(t.representationInfo);return P0({dashPlaylists:n,locations:t.locations,contentSteering:t.contentSteeringInfo,sidxMapping:e.sidxMapping,previousManifest:e.previousManifest,eventStream:t.eventStream})},e1=i=>J0(mh(i));var yh=Math.pow(2,32),t1=function(i){var e=new DataView(i.buffer,i.byteOffset,i.byteLength),t;return e.getBigUint64?(t=e.getBigUint64(0),t<Number.MAX_SAFE_INTEGER?Number(t):t):e.getUint32(0)*yh+e.getUint32(4)},i1={getUint64:t1,MAX_UINT32:yh},Au=i1.getUint64,n1=function(i){var e=new DataView(i.buffer,i.byteOffset,i.byteLength),t={version:i[0],flags:new Uint8Array(i.subarray(1,4)),references:[],referenceId:e.getUint32(4),timescale:e.getUint32(8)},n=12;t.version===0?(t.earliestPresentationTime=e.getUint32(n),t.firstOffset=e.getUint32(n+4),n+=8):(t.earliestPresentationTime=Au(i.subarray(n)),t.firstOffset=Au(i.subarray(n+8)),n+=16),n+=2;var s=e.getUint16(n);for(n+=2;s>0;n+=12,s--)t.references.push({referenceType:(i[n]&128)>>>7,referencedSize:e.getUint32(n)&2147483647,subsegmentDuration:e.getUint32(n+4),startsWithSap:!!(i[n+8]&128),sapType:(i[n+8]&112)>>>4,sapDeltaTime:e.getUint32(n+8)&268435455});return t},s1=n1;const r1=ms(s1);var a1=ie([73,68,51]),o1=function(i,e){e===void 0&&(e=0),i=ie(i);var t=i[e+5],n=i[e+6]<<21|i[e+7]<<14|i[e+8]<<7|i[e+9],s=(t&16)>>4;return s?n+20:n+10},is=function i(e,t){return t===void 0&&(t=0),e=ie(e),e.length-t<10||!Le(e,a1,{offset:t})?t:(t+=o1(e,t),i(e,t))},Pu=function(i){return typeof i=="string"?dh(i):i},l1=function(i){return Array.isArray(i)?i.map(function(e){return Pu(e)}):[Pu(i)]},u1=function i(e,t,n){n===void 0&&(n=!1),t=l1(t),e=ie(e);var s=[];if(!t.length)return s;for(var r=0;r<e.length;){var a=(e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3])>>>0,l=e.subarray(r+4,r+8);if(a===0)break;var c=r+a;if(c>e.length){if(n)break;c=e.length}var f=e.subarray(r+8,c);Le(l,t[0])&&(t.length===1?s.push(f):s.push.apply(s,i(f,t.slice(1),n))),r=c}return s},Qs={EBML:ie([26,69,223,163]),DocType:ie([66,130]),Segment:ie([24,83,128,103]),SegmentInfo:ie([21,73,169,102]),Tracks:ie([22,84,174,107]),Track:ie([174]),TrackNumber:ie([215]),DefaultDuration:ie([35,227,131]),TrackEntry:ie([174]),TrackType:ie([131]),FlagDefault:ie([136]),CodecID:ie([134]),CodecPrivate:ie([99,162]),VideoTrack:ie([224]),AudioTrack:ie([225]),Cluster:ie([31,67,182,117]),Timestamp:ie([231]),TimestampScale:ie([42,215,177]),BlockGroup:ie([160]),BlockDuration:ie([155]),Block:ie([161]),SimpleBlock:ie([163])},Ga=[128,64,32,16,8,4,2,1],d1=function(i){for(var e=1,t=0;t<Ga.length&&!(i&Ga[t]);t++)e++;return e},ur=function(i,e,t,n){t===void 0&&(t=!0),n===void 0&&(n=!1);var s=d1(i[e]),r=i.subarray(e,e+s);return t&&(r=Array.prototype.slice.call(i,e,e+s),r[0]^=Ga[s-1]),{length:s,value:s0(r,{signed:n}),bytes:r}},Lu=function i(e){return typeof e=="string"?e.match(/.{1,2}/g).map(function(t){return i(t)}):typeof e=="number"?r0(e):e},h1=function(i){return Array.isArray(i)?i.map(function(e){return Lu(e)}):[Lu(i)]},c1=function i(e,t,n){if(n>=t.length)return t.length;var s=ur(t,n,!1);if(Le(e.bytes,s.bytes))return n;var r=ur(t,n+s.length);return i(e,t,n+r.length+r.value+s.length)},Du=function i(e,t){t=h1(t),e=ie(e);var n=[];if(!t.length)return n;for(var s=0;s<e.length;){var r=ur(e,s,!1),a=ur(e,s+r.length),l=s+r.length+a.length;a.value===127&&(a.value=c1(r,e,l),a.value!==e.length&&(a.value-=l));var c=l+a.value>e.length?e.length:l+a.value,f=e.subarray(l,c);Le(t[0],r.bytes)&&(t.length===1?n.push(f):n=n.concat(i(f,t.slice(1))));var m=r.length+a.length+f.length;s+=m}return n},p1=ie([0,0,0,1]),g1=ie([0,0,1]),f1=ie([0,0,3]),m1=function(i){for(var e=[],t=1;t<i.length-2;)Le(i.subarray(t,t+3),f1)&&(e.push(t+2),t++),t++;if(e.length===0)return i;var n=i.length-e.length,s=new Uint8Array(n),r=0;for(t=0;t<n;r++,t++)r===e[0]&&(r++,e.shift()),s[t]=i[r];return s},_h=function(i,e,t,n){i=ie(i),t=[].concat(t);for(var s=0,r,a=0;s<i.length&&(a<n||r);){var l=void 0;if(Le(i.subarray(s),p1)?l=4:Le(i.subarray(s),g1)&&(l=3),!l){s++;continue}if(a++,r)return m1(i.subarray(r,s));var c=void 0;e==="h264"?c=i[s+l]&31:e==="h265"&&(c=i[s+l]>>1&63),t.indexOf(c)!==-1&&(r=s+l),s+=l+(e==="h264"?1:2)}return i.subarray(0,0)},y1=function(i,e,t){return _h(i,"h264",e,t)},_1=function(i,e,t){return _h(i,"h265",e,t)},rt={webm:ie([119,101,98,109]),matroska:ie([109,97,116,114,111,115,107,97]),flac:ie([102,76,97,67]),ogg:ie([79,103,103,83]),ac3:ie([11,119]),riff:ie([82,73,70,70]),avi:ie([65,86,73]),wav:ie([87,65,86,69]),"3gp":ie([102,116,121,112,51,103]),mp4:ie([102,116,121,112]),fmp4:ie([115,116,121,112]),mov:ie([102,116,121,112,113,116]),moov:ie([109,111,111,118]),moof:ie([109,111,111,102])},fn={aac:function(i){var e=is(i);return Le(i,[255,16],{offset:e,mask:[255,22]})},mp3:function(i){var e=is(i);return Le(i,[255,2],{offset:e,mask:[255,6]})},webm:function(i){var e=Du(i,[Qs.EBML,Qs.DocType])[0];return Le(e,rt.webm)},mkv:function(i){var e=Du(i,[Qs.EBML,Qs.DocType])[0];return Le(e,rt.matroska)},mp4:function(i){if(fn["3gp"](i)||fn.mov(i))return!1;if(Le(i,rt.mp4,{offset:4})||Le(i,rt.fmp4,{offset:4})||Le(i,rt.moof,{offset:4})||Le(i,rt.moov,{offset:4}))return!0},mov:function(i){return Le(i,rt.mov,{offset:4})},"3gp":function(i){return Le(i,rt["3gp"],{offset:4})},ac3:function(i){var e=is(i);return Le(i,rt.ac3,{offset:e})},ts:function(i){if(i.length<189&&i.length>=1)return i[0]===71;for(var e=0;e+188<i.length&&e<188;){if(i[e]===71&&i[e+188]===71)return!0;e+=1}return!1},flac:function(i){var e=is(i);return Le(i,rt.flac,{offset:e})},ogg:function(i){return Le(i,rt.ogg)},avi:function(i){return Le(i,rt.riff)&&Le(i,rt.avi,{offset:8})},wav:function(i){return Le(i,rt.riff)&&Le(i,rt.wav,{offset:8})},h264:function(i){return y1(i,7,3).length},h265:function(i){return _1(i,[32,33],3).length}},Xa=Object.keys(fn).filter(function(i){return i!=="ts"&&i!=="h264"&&i!=="h265"}).concat(["ts","h264","h265"]);Xa.forEach(function(i){var e=fn[i];fn[i]=function(t){return e(ie(t))}});var b1=fn,Do=function(i){i=ie(i);for(var e=0;e<Xa.length;e++){var t=Xa[e];if(b1[t](i))return t}return""},T1=function(i){return u1(i,["moof"]).length>0},Oo=9e4,Mo,Ro,Br,Uo,bh,Th,vh;Mo=function(i){return i*Oo};Ro=function(i,e){return i*e};Br=function(i){return i/Oo};Uo=function(i,e){return i/e};bh=function(i,e){return Mo(Uo(i,e))};Th=function(i,e){return Ro(Br(i),e)};vh=function(i,e,t){return Br(t?i:i-e)};var Ri={ONE_SECOND_IN_TS:Oo,secondsToVideoTs:Mo,secondsToAudioTs:Ro,videoTsToSeconds:Br,audioTsToSeconds:Uo,audioTsToVideoTs:bh,videoTsToAudioTs:Th,metadataTsToSeconds:vh},Ka="8.21.0";const ii={},Ti=function(i,e){return ii[i]=ii[i]||[],e&&(ii[i]=ii[i].concat(e)),ii[i]},v1=function(i,e){Ti(i,e)},Sh=function(i,e){const t=Ti(i).indexOf(e);return t<=-1?!1:(ii[i]=ii[i].slice(),ii[i].splice(t,1),!0)},S1=function(i,e){Ti(i,[].concat(e).map(t=>{const n=(...s)=>(Sh(i,n),t(...s));return n}))},dr={prefixed:!0},nr=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror","fullscreen"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"]],Ou=nr[0];let ns;for(let i=0;i<nr.length;i++)if(nr[i][1]in G){ns=nr[i];break}if(ns){for(let i=0;i<ns.length;i++)dr[Ou[i]]=ns[i];dr.prefixed=ns[0]!==Ou[0]}let ct=[];const E1=(i,e,t)=>(n,s,r)=>{const a=e.levels[s],l=new RegExp(`^(${a})$`);let c=i;if(n!=="log"&&r.unshift(n.toUpperCase()+":"),t&&(c=`%c${i}`,r.unshift(t)),r.unshift(c+":"),ct){ct.push([].concat(r));const m=ct.length-1e3;ct.splice(0,m>0?m:0)}if(!x.console)return;let f=x.console[n];!f&&n==="debug"&&(f=x.console.info||x.console.log),!(!f||!a||!l.test(n))&&f[Array.isArray(r)?"apply":"call"](x.console,r)};function Ya(i,e=":",t=""){let n="info",s;function r(...a){s("log",n,a)}return s=E1(i,r,t),r.createLogger=(a,l,c)=>{const f=l!==void 0?l:e,m=c!==void 0?c:t,b=`${i} ${f} ${a}`;return Ya(b,f,m)},r.createNewLogger=(a,l,c)=>Ya(a,l,c),r.levels={all:"debug|log|warn|error",off:"",debug:"debug|log|warn|error",info:"log|warn|error",warn:"warn|error",error:"error",DEFAULT:n},r.level=a=>{if(typeof a=="string"){if(!r.levels.hasOwnProperty(a))throw new Error(`"${a}" in not a valid log level`);n=a}return n},r.history=()=>ct?[].concat(ct):[],r.history.filter=a=>(ct||[]).filter(l=>new RegExp(`.*${a}.*`).test(l[0])),r.history.clear=()=>{ct&&(ct.length=0)},r.history.disable=()=>{ct!==null&&(ct.length=0,ct=null)},r.history.enable=()=>{ct===null&&(ct=[])},r.error=(...a)=>s("error",n,a),r.warn=(...a)=>s("warn",n,a),r.debug=(...a)=>s("debug",n,a),r}const oe=Ya("VIDEOJS"),Eh=oe.createLogger,w1=Object.prototype.toString,wh=function(i){return Qt(i)?Object.keys(i):[]};function sn(i,e){wh(i).forEach(t=>e(i[t],t))}function kh(i,e,t=0){return wh(i).reduce((n,s)=>e(n,i[s],s),t)}function Qt(i){return!!i&&typeof i=="object"}function mn(i){return Qt(i)&&w1.call(i)==="[object Object]"&&i.constructor===Object}function ve(...i){const e={};return i.forEach(t=>{t&&sn(t,(n,s)=>{if(!mn(n)){e[s]=n;return}mn(e[s])||(e[s]={}),e[s]=ve(e[s],n)})}),e}function Ch(i={}){const e=[];for(const t in i)if(i.hasOwnProperty(t)){const n=i[t];e.push(n)}return e}function Fr(i,e,t,n=!0){const s=a=>Object.defineProperty(i,e,{value:a,enumerable:!0,writable:!0}),r={configurable:!0,enumerable:!0,get(){const a=t();return s(a),a}};return n&&(r.set=s),Object.defineProperty(i,e,r)}var k1=Object.freeze({__proto__:null,each:sn,reduce:kh,isObject:Qt,isPlain:mn,merge:ve,values:Ch,defineLazyProperty:Fr});let No=!1,Ih=null,Nt=!1,xh,Ah=!1,rn=!1,an=!1,Jt=!1,Bo=null,jr=null;const C1=!!(x.cast&&x.cast.framework&&x.cast.framework.CastReceiverContext);let Ph=null,hr=!1,$r=!1,cr=!1,qr=!1,pr=!1,gr=!1,fr=!1;const ps=!!(En()&&("ontouchstart"in x||x.navigator.maxTouchPoints||x.DocumentTouch&&x.document instanceof x.DocumentTouch)),fi=x.navigator&&x.navigator.userAgentData;fi&&fi.platform&&fi.brands&&(Nt=fi.platform==="Android",rn=!!fi.brands.find(i=>i.brand==="Microsoft Edge"),an=!!fi.brands.find(i=>i.brand==="Chromium"),Jt=!rn&&an,Bo=jr=(fi.brands.find(i=>i.brand==="Chromium")||{}).version||null,$r=fi.platform==="Windows");if(!an){const i=x.navigator&&x.navigator.userAgent||"";No=/iPod/i.test(i),Ih=function(){const e=i.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),Nt=/Android/i.test(i),xh=function(){const e=i.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);return t&&n?parseFloat(e[1]+"."+e[2]):t||null}(),Ah=/Firefox/i.test(i),rn=/Edg/i.test(i),an=/Chrome/i.test(i)||/CriOS/i.test(i),Jt=!rn&&an,Bo=jr=function(){const e=i.match(/(Chrome|CriOS)\/(\d+)/);return e&&e[2]?parseFloat(e[2]):null}(),Ph=function(){const e=/MSIE\s(\d+)\.\d/.exec(i);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(i)&&/rv:11.0/.test(i)&&(t=11),t}(),pr=/Tizen/i.test(i),gr=/Web0S/i.test(i),fr=pr||gr,hr=/Safari/i.test(i)&&!Jt&&!Nt&&!rn&&!fr,$r=/Windows/i.test(i),cr=/iPad/i.test(i)||hr&&ps&&!/iPhone/i.test(i),qr=/iPhone/i.test(i)&&!cr}const Je=qr||cr||No,Vr=(hr||Je)&&!Jt;var Lh=Object.freeze({__proto__:null,get IS_IPOD(){return No},get IOS_VERSION(){return Ih},get IS_ANDROID(){return Nt},get ANDROID_VERSION(){return xh},get IS_FIREFOX(){return Ah},get IS_EDGE(){return rn},get IS_CHROMIUM(){return an},get IS_CHROME(){return Jt},get CHROMIUM_VERSION(){return Bo},get CHROME_VERSION(){return jr},IS_CHROMECAST_RECEIVER:C1,get IE_VERSION(){return Ph},get IS_SAFARI(){return hr},get IS_WINDOWS(){return $r},get IS_IPAD(){return cr},get IS_IPHONE(){return qr},get IS_TIZEN(){return pr},get IS_WEBOS(){return gr},get IS_SMART_TV(){return fr},TOUCH_ENABLED:ps,IS_IOS:Je,IS_ANY_SAFARI:Vr});function Mu(i){return typeof i=="string"&&!!i.trim()}function I1(i){if(i.indexOf(" ")>=0)throw new Error("class has illegal whitespace characters")}function En(){return G===x.document}function wn(i){return Qt(i)&&i.nodeType===1}function Dh(){try{return x.parent!==x.self}catch{return!0}}function Oh(i){return function(e,t){if(!Mu(e))return G[i](null);Mu(t)&&(t=G.querySelector(t));const n=wn(t)?t:G;return n[i]&&n[i](e)}}function ne(i="div",e={},t={},n){const s=G.createElement(i);return Object.getOwnPropertyNames(e).forEach(function(r){const a=e[r];r==="textContent"?Si(s,a):(s[r]!==a||r==="tabIndex")&&(s[r]=a)}),Object.getOwnPropertyNames(t).forEach(function(r){s.setAttribute(r,t[r])}),n&&Fo(s,n),s}function Si(i,e){return typeof i.textContent>"u"?i.innerText=e:i.textContent=e,i}function Qa(i,e){e.firstChild?e.insertBefore(i,e.firstChild):e.appendChild(i)}function os(i,e){return I1(e),i.classList.contains(e)}function Bi(i,...e){return i.classList.add(...e.reduce((t,n)=>t.concat(n.split(/\s+/)),[])),i}function Hr(i,...e){return i?(i.classList.remove(...e.reduce((t,n)=>t.concat(n.split(/\s+/)),[])),i):(oe.warn("removeClass was called with an element that doesn't exist"),null)}function Mh(i,e,t){return typeof t=="function"&&(t=t(i,e)),typeof t!="boolean"&&(t=void 0),e.split(/\s+/).forEach(n=>i.classList.toggle(n,t)),i}function Rh(i,e){Object.getOwnPropertyNames(e).forEach(function(t){const n=e[t];n===null||typeof n>"u"||n===!1?i.removeAttribute(t):i.setAttribute(t,n===!0?"":n)})}function _i(i){const e={},t=["autoplay","controls","playsinline","loop","muted","default","defaultMuted"];if(i&&i.attributes&&i.attributes.length>0){const n=i.attributes;for(let s=n.length-1;s>=0;s--){const r=n[s].name;let a=n[s].value;t.includes(r)&&(a=a!==null),e[r]=a}}return e}function Uh(i,e){return i.getAttribute(e)}function yn(i,e,t){i.setAttribute(e,t)}function zr(i,e){i.removeAttribute(e)}function Nh(){G.body.focus(),G.onselectstart=function(){return!1}}function Bh(){G.onselectstart=function(){return!0}}function _n(i){if(i&&i.getBoundingClientRect&&i.parentNode){const e=i.getBoundingClientRect(),t={};return["bottom","height","left","right","top","width"].forEach(n=>{e[n]!==void 0&&(t[n]=e[n])}),t.height||(t.height=parseFloat(bn(i,"height"))),t.width||(t.width=parseFloat(bn(i,"width"))),t}}function gs(i){if(!i||i&&!i.offsetParent)return{left:0,top:0,width:0,height:0};const e=i.offsetWidth,t=i.offsetHeight;let n=0,s=0;for(;i.offsetParent&&i!==G[dr.fullscreenElement];)n+=i.offsetLeft,s+=i.offsetTop,i=i.offsetParent;return{left:n,top:s,width:e,height:t}}function Wr(i,e){const t={x:0,y:0};if(Je){let m=i;for(;m&&m.nodeName.toLowerCase()!=="html";){const b=bn(m,"transform");if(/^matrix/.test(b)){const C=b.slice(7,-1).split(/,\s/).map(Number);t.x+=C[4],t.y+=C[5]}else if(/^matrix3d/.test(b)){const C=b.slice(9,-1).split(/,\s/).map(Number);t.x+=C[12],t.y+=C[13]}if(m.assignedSlot&&m.assignedSlot.parentElement&&x.WebKitCSSMatrix){const C=x.getComputedStyle(m.assignedSlot.parentElement).transform,w=new x.WebKitCSSMatrix(C);t.x+=w.m41,t.y+=w.m42}m=m.parentNode||m.host}}const n={},s=gs(e.target),r=gs(i),a=r.width,l=r.height;let c=e.offsetY-(r.top-s.top),f=e.offsetX-(r.left-s.left);return e.changedTouches&&(f=e.changedTouches[0].pageX-r.left,c=e.changedTouches[0].pageY+r.top,Je&&(f-=t.x,c-=t.y)),n.y=1-Math.max(0,Math.min(1,c/l)),n.x=Math.max(0,Math.min(1,f/a)),n}function Fh(i){return Qt(i)&&i.nodeType===3}function Gr(i){for(;i.firstChild;)i.removeChild(i.firstChild);return i}function jh(i){return typeof i=="function"&&(i=i()),(Array.isArray(i)?i:[i]).map(e=>{if(typeof e=="function"&&(e=e()),wn(e)||Fh(e))return e;if(typeof e=="string"&&/\S/.test(e))return G.createTextNode(e)}).filter(e=>e)}function Fo(i,e){return jh(e).forEach(t=>i.appendChild(t)),i}function $h(i,e){return Fo(Gr(i),e)}function fs(i){return i.button===void 0&&i.buttons===void 0||i.button===0&&i.buttons===void 0||i.type==="mouseup"&&i.button===0&&i.buttons===0||i.type==="mousedown"&&i.button===0&&i.buttons===0?!0:!(i.button!==0||i.buttons!==1)}const vi=Oh("querySelector"),qh=Oh("querySelectorAll");function bn(i,e){if(!i||!e)return"";if(typeof x.getComputedStyle=="function"){let t;try{t=x.getComputedStyle(i)}catch{return""}return t?t.getPropertyValue(e)||t[e]:""}return""}function Vh(i){[...G.styleSheets].forEach(e=>{try{const t=[...e.cssRules].map(s=>s.cssText).join(""),n=G.createElement("style");n.textContent=t,i.document.head.appendChild(n)}catch{const t=G.createElement("link");t.rel="stylesheet",t.type=e.type,t.media=e.media.mediaText,t.href=e.href,i.document.head.appendChild(t)}})}var Hh=Object.freeze({__proto__:null,isReal:En,isEl:wn,isInFrame:Dh,createEl:ne,textContent:Si,prependTo:Qa,hasClass:os,addClass:Bi,removeClass:Hr,toggleClass:Mh,setAttributes:Rh,getAttributes:_i,getAttribute:Uh,setAttribute:yn,removeAttribute:zr,blockTextSelection:Nh,unblockTextSelection:Bh,getBoundingClientRect:_n,findPosition:gs,getPointerPosition:Wr,isTextNode:Fh,emptyEl:Gr,normalizeContent:jh,appendContent:Fo,insertContent:$h,isSingleLeftClick:fs,$:vi,$$:qh,computedStyle:bn,copyStyleSheetsToWindow:Vh});let zh=!1,Ja;const x1=function(){if(Ja.options.autoSetup===!1)return;const i=Array.prototype.slice.call(G.getElementsByTagName("video")),e=Array.prototype.slice.call(G.getElementsByTagName("audio")),t=Array.prototype.slice.call(G.getElementsByTagName("video-js")),n=i.concat(e,t);if(n&&n.length>0)for(let s=0,r=n.length;s<r;s++){const a=n[s];if(a&&a.getAttribute)a.player===void 0&&a.getAttribute("data-setup")!==null&&Ja(a);else{Za(1);break}}else zh||Za(1)};function Za(i,e){En()&&(e&&(Ja=e),x.setTimeout(x1,i))}function eo(){zh=!0,x.removeEventListener("load",eo)}En()&&(G.readyState==="complete"?eo():x.addEventListener("load",eo));const Wh=function(i){const e=G.createElement("style");return e.className=i,e},Gh=function(i,e){i.styleSheet?i.styleSheet.cssText=e:i.textContent=e};var lt=new WeakMap;const A1=3;let P1=A1;function At(){return P1++}function Ru(i,e){if(!lt.has(i))return;const t=lt.get(i);t.handlers[e].length===0&&(delete t.handlers[e],i.removeEventListener?i.removeEventListener(e,t.dispatcher,!1):i.detachEvent&&i.detachEvent("on"+e,t.dispatcher)),Object.getOwnPropertyNames(t.handlers).length<=0&&(delete t.handlers,delete t.dispatcher,delete t.disabled),Object.getOwnPropertyNames(t).length===0&<.delete(i)}function jo(i,e,t,n){t.forEach(function(s){i(e,s,n)})}function Xr(i){if(i.fixed_)return i;function e(){return!0}function t(){return!1}if(!i||!i.isPropagationStopped||!i.isImmediatePropagationStopped){const n=i||x.event;i={};const s=["layerX","layerY","keyLocation","path","webkitMovementX","webkitMovementY","mozPressure","mozInputSource"];for(const r in n)s.includes(r)||r==="returnValue"&&n.preventDefault||(i[r]=n[r]);if(i.target||(i.target=i.srcElement||G),i.relatedTarget||(i.relatedTarget=i.fromElement===i.target?i.toElement:i.fromElement),i.preventDefault=function(){n.preventDefault&&n.preventDefault(),i.returnValue=!1,n.returnValue=!1,i.defaultPrevented=!0},i.defaultPrevented=!1,i.stopPropagation=function(){n.stopPropagation&&n.stopPropagation(),i.cancelBubble=!0,n.cancelBubble=!0,i.isPropagationStopped=e},i.isPropagationStopped=t,i.stopImmediatePropagation=function(){n.stopImmediatePropagation&&n.stopImmediatePropagation(),i.isImmediatePropagationStopped=e,i.stopPropagation()},i.isImmediatePropagationStopped=t,i.clientX!==null&&i.clientX!==void 0){const r=G.documentElement,a=G.body;i.pageX=i.clientX+(r&&r.scrollLeft||a&&a.scrollLeft||0)-(r&&r.clientLeft||a&&a.clientLeft||0),i.pageY=i.clientY+(r&&r.scrollTop||a&&a.scrollTop||0)-(r&&r.clientTop||a&&a.clientTop||0)}i.which=i.charCode||i.keyCode,i.button!==null&&i.button!==void 0&&(i.button=i.button&1?0:i.button&4?1:i.button&2?2:0)}return i.fixed_=!0,i}let Js;const L1=function(){if(typeof Js!="boolean"){Js=!1;try{const i=Object.defineProperty({},"passive",{get(){Js=!0}});x.addEventListener("test",null,i),x.removeEventListener("test",null,i)}catch{}}return Js},D1=["touchstart","touchmove"];function vt(i,e,t){if(Array.isArray(e))return jo(vt,i,e,t);lt.has(i)||lt.set(i,{});const n=lt.get(i);if(n.handlers||(n.handlers={}),n.handlers[e]||(n.handlers[e]=[]),t.guid||(t.guid=At()),n.handlers[e].push(t),n.dispatcher||(n.disabled=!1,n.dispatcher=function(s,r){if(n.disabled)return;s=Xr(s);const a=n.handlers[s.type];if(a){const l=a.slice(0);for(let c=0,f=l.length;c<f&&!s.isImmediatePropagationStopped();c++)try{l[c].call(i,s,r)}catch(m){oe.error(m)}}}),n.handlers[e].length===1)if(i.addEventListener){let s=!1;L1()&&D1.indexOf(e)>-1&&(s={passive:!0}),i.addEventListener(e,n.dispatcher,s)}else i.attachEvent&&i.attachEvent("on"+e,n.dispatcher)}function Ze(i,e,t){if(!lt.has(i))return;const n=lt.get(i);if(!n.handlers)return;if(Array.isArray(e))return jo(Ze,i,e,t);const s=function(a,l){n.handlers[l]=[],Ru(a,l)};if(e===void 0){for(const a in n.handlers)Object.prototype.hasOwnProperty.call(n.handlers||{},a)&&s(i,a);return}const r=n.handlers[e];if(r){if(!t){s(i,e);return}if(t.guid)for(let a=0;a<r.length;a++)r[a].guid===t.guid&&r.splice(a--,1);Ru(i,e)}}function kn(i,e,t){const n=lt.has(i)?lt.get(i):{},s=i.parentNode||i.ownerDocument;if(typeof e=="string"?e={type:e,target:i}:e.target||(e.target=i),e=Xr(e),n.dispatcher&&n.dispatcher.call(i,e,t),s&&!e.isPropagationStopped()&&e.bubbles===!0)kn.call(null,s,e,t);else if(!s&&!e.defaultPrevented&&e.target&&e.target[e.type]){lt.has(e.target)||lt.set(e.target,{});const r=lt.get(e.target);e.target[e.type]&&(r.disabled=!0,typeof e.target[e.type]=="function"&&e.target[e.type](),r.disabled=!1)}return!e.defaultPrevented}function Kr(i,e,t){if(Array.isArray(e))return jo(Kr,i,e,t);const n=function(){Ze(i,e,n),t.apply(this,arguments)};n.guid=t.guid=t.guid||At(),vt(i,e,n)}function $o(i,e,t){const n=function(){Ze(i,e,n),t.apply(this,arguments)};n.guid=t.guid=t.guid||At(),vt(i,e,n)}var O1=Object.freeze({__proto__:null,fixEvent:Xr,on:vt,off:Ze,trigger:kn,one:Kr,any:$o});const Pt=30,Ce=function(i,e,t){e.guid||(e.guid=At());const n=e.bind(i);return n.guid=t?t+"_"+e.guid:e.guid,n},Zt=function(i,e){let t=x.performance.now();return function(...n){const s=x.performance.now();s-t>=e&&(i(...n),t=s)}},Xh=function(i,e,t,n=x){let s;const r=()=>{n.clearTimeout(s),s=null},a=function(){const l=this,c=arguments;let f=function(){s=null,f=null,t||i.apply(l,c)};!s&&t&&i.apply(l,c),n.clearTimeout(s),s=n.setTimeout(f,e)};return a.cancel=r,a};var M1=Object.freeze({__proto__:null,UPDATE_REFRESH_INTERVAL:Pt,bind_:Ce,throttle:Zt,debounce:Xh});let Yn;class St{on(e,t){const n=this.addEventListener;this.addEventListener=()=>{},vt(this,e,t),this.addEventListener=n}off(e,t){Ze(this,e,t)}one(e,t){const n=this.addEventListener;this.addEventListener=()=>{},Kr(this,e,t),this.addEventListener=n}any(e,t){const n=this.addEventListener;this.addEventListener=()=>{},$o(this,e,t),this.addEventListener=n}trigger(e){const t=e.type||e;typeof e=="string"&&(e={type:t}),e=Xr(e),this.allowedEvents_[t]&&this["on"+t]&&this["on"+t](e),kn(this,e)}queueTrigger(e){Yn||(Yn=new Map);const t=e.type||e;let n=Yn.get(this);n||(n=new Map,Yn.set(this,n));const s=n.get(t);n.delete(t),x.clearTimeout(s);const r=x.setTimeout(()=>{n.delete(t),n.size===0&&(n=null,Yn.delete(this)),this.trigger(e)},0);n.set(t,r)}}St.prototype.allowedEvents_={};St.prototype.addEventListener=St.prototype.on;St.prototype.removeEventListener=St.prototype.off;St.prototype.dispatchEvent=St.prototype.trigger;const Yr=i=>typeof i.name=="function"?i.name():typeof i.name=="string"?i.name:i.name_?i.name_:i.constructor&&i.constructor.name?i.constructor.name:typeof i,si=i=>i instanceof St||!!i.eventBusEl_&&["on","one","off","trigger"].every(e=>typeof i[e]=="function"),R1=(i,e)=>{si(i)?e():(i.eventedCallbacks||(i.eventedCallbacks=[]),i.eventedCallbacks.push(e))},to=i=>typeof i=="string"&&/\S/.test(i)||Array.isArray(i)&&!!i.length,mr=(i,e,t)=>{if(!i||!i.nodeName&&!si(i))throw new Error(`Invalid target for ${Yr(e)}#${t}; must be a DOM node or evented object.`)},Kh=(i,e,t)=>{if(!to(i))throw new Error(`Invalid event type for ${Yr(e)}#${t}; must be a non-empty string or array.`)},Yh=(i,e,t)=>{if(typeof i!="function")throw new Error(`Invalid listener for ${Yr(e)}#${t}; must be a function.`)},La=(i,e,t)=>{const n=e.length<3||e[0]===i||e[0]===i.eventBusEl_;let s,r,a;return n?(s=i.eventBusEl_,e.length>=3&&e.shift(),[r,a]=e):(s=e[0],r=e[1],a=e[2]),mr(s,i,t),Kh(r,i,t),Yh(a,i,t),a=Ce(i,a),{isTargetingSelf:n,target:s,type:r,listener:a}},Di=(i,e,t,n)=>{mr(i,i,e),i.nodeName?O1[e](i,t,n):i[e](t,n)},U1={on(...i){const{isTargetingSelf:e,target:t,type:n,listener:s}=La(this,i,"on");if(Di(t,"on",n,s),!e){const r=()=>this.off(t,n,s);r.guid=s.guid;const a=()=>this.off("dispose",r);a.guid=s.guid,Di(this,"on","dispose",r),Di(t,"on","dispose",a)}},one(...i){const{isTargetingSelf:e,target:t,type:n,listener:s}=La(this,i,"one");if(e)Di(t,"one",n,s);else{const r=(...a)=>{this.off(t,n,r),s.apply(null,a)};r.guid=s.guid,Di(t,"one",n,r)}},any(...i){const{isTargetingSelf:e,target:t,type:n,listener:s}=La(this,i,"any");if(e)Di(t,"any",n,s);else{const r=(...a)=>{this.off(t,n,r),s.apply(null,a)};r.guid=s.guid,Di(t,"any",n,r)}},off(i,e,t){if(!i||to(i))Ze(this.eventBusEl_,i,e);else{const n=i,s=e;mr(n,this,"off"),Kh(s,this,"off"),Yh(t,this,"off"),t=Ce(this,t),this.off("dispose",t),n.nodeName?(Ze(n,s,t),Ze(n,"dispose",t)):si(n)&&(n.off(s,t),n.off("dispose",t))}},trigger(i,e){mr(this.eventBusEl_,this,"trigger");const t=i&&typeof i!="string"?i.type:i;if(!to(t))throw new Error(`Invalid event type for ${Yr(this)}#trigger; must be a non-empty string or object with a type key that has a non-empty value.`);return kn(this.eventBusEl_,i,e)}};function qo(i,e={}){const{eventBusKey:t}=e;if(t){if(!i[t].nodeName)throw new Error(`The eventBusKey "${t}" does not refer to an element.`);i.eventBusEl_=i[t]}else i.eventBusEl_=ne("span",{className:"vjs-event-bus"});return Object.assign(i,U1),i.eventedCallbacks&&i.eventedCallbacks.forEach(n=>{n()}),i.on("dispose",()=>{i.off(),[i,i.el_,i.eventBusEl_].forEach(function(n){n&<.has(n)&<.delete(n)}),x.setTimeout(()=>{i.eventBusEl_=null},0)}),i}const N1={state:{},setState(i){typeof i=="function"&&(i=i());let e;return sn(i,(t,n)=>{this.state[n]!==t&&(e=e||{},e[n]={from:this.state[n],to:t}),this.state[n]=t}),e&&si(this)&&this.trigger({changes:e,type:"statechanged"}),e}};function Qh(i,e){return Object.assign(i,N1),i.state=Object.assign({},i.state,e),typeof i.handleStateChanged=="function"&&si(i)&&i.on("statechanged",i.handleStateChanged),i}const ls=function(i){return typeof i!="string"?i:i.replace(/./,e=>e.toLowerCase())},Ne=function(i){return typeof i!="string"?i:i.replace(/./,e=>e.toUpperCase())},Jh=function(i,e){return Ne(i)===Ne(e)};var B1=Object.freeze({__proto__:null,toLowerCase:ls,toTitleCase:Ne,titleCaseEquals:Jh});let H=class ht{constructor(e,t,n){if(!e&&this.play?this.player_=e=this:this.player_=e,this.isDisposed_=!1,this.parentComponent_=null,this.options_=ve({},this.options_),t=this.options_=ve(this.options_,t),this.id_=t.id||t.el&&t.el.id,!this.id_){const s=e&&e.id&&e.id()||"no_player";this.id_=`${s}_component_${At()}`}this.name_=t.name||null,t.el?this.el_=t.el:t.createEl!==!1&&(this.el_=this.createEl()),t.className&&this.el_&&t.className.split(" ").forEach(s=>this.addClass(s)),["on","off","one","any","trigger"].forEach(s=>{this[s]=void 0}),t.evented!==!1&&(qo(this,{eventBusKey:this.el_?"el_":null}),this.handleLanguagechange=this.handleLanguagechange.bind(this),this.on(this.player_,"languagechange",this.handleLanguagechange)),Qh(this,this.constructor.defaultState),this.children_=[],this.childIndex_={},this.childNameIndex_={},this.setTimeoutIds_=new Set,this.setIntervalIds_=new Set,this.rafIds_=new Set,this.namedRafs_=new Map,this.clearingTimersOnDispose_=!1,t.initChildren!==!1&&this.initChildren(),this.ready(n),t.reportTouchActivity!==!1&&this.enableTouchActivity()}dispose(e={}){if(!this.isDisposed_){if(this.readyQueue_&&(this.readyQueue_.length=0),this.trigger({type:"dispose",bubbles:!1}),this.isDisposed_=!0,this.children_)for(let t=this.children_.length-1;t>=0;t--)this.children_[t].dispose&&this.children_[t].dispose();this.children_=null,this.childIndex_=null,this.childNameIndex_=null,this.parentComponent_=null,this.el_&&(this.el_.parentNode&&(e.restoreEl?this.el_.parentNode.replaceChild(e.restoreEl,this.el_):this.el_.parentNode.removeChild(this.el_)),this.el_=null),this.player_=null}}isDisposed(){return!!this.isDisposed_}player(){return this.player_}options(e){return e?(this.options_=ve(this.options_,e),this.options_):this.options_}el(){return this.el_}createEl(e,t,n){return ne(e,t,n)}localize(e,t,n=e){const s=this.player_.language&&this.player_.language(),r=this.player_.languages&&this.player_.languages(),a=r&&r[s],l=s&&s.split("-")[0],c=r&&r[l];let f=n;return a&&a[e]?f=a[e]:c&&c[e]&&(f=c[e]),t&&(f=f.replace(/\{(\d+)\}/g,function(m,b){const C=t[b-1];let w=C;return typeof C>"u"&&(w=m),w})),f}handleLanguagechange(){}contentEl(){return this.contentEl_||this.el_}id(){return this.id_}name(){return this.name_}children(){return this.children_}getChildById(e){return this.childIndex_[e]}getChild(e){if(e)return this.childNameIndex_[e]}getDescendant(...e){e=e.reduce((n,s)=>n.concat(s),[]);let t=this;for(let n=0;n<e.length;n++)if(t=t.getChild(e[n]),!t||!t.getChild)return;return t}setIcon(e,t=this.el()){if(!this.player_.options_.experimentalSvgIcons)return;const n="http://www.w3.org/2000/svg",s=ne("span",{className:"vjs-icon-placeholder vjs-svg-icon"},{"aria-hidden":"true"}),r=G.createElementNS(n,"svg");r.setAttributeNS(null,"viewBox","0 0 512 512");const a=G.createElementNS(n,"use");return r.appendChild(a),a.setAttributeNS(null,"href",`#vjs-icon-${e}`),s.appendChild(r),this.iconIsSet_?t.replaceChild(s,t.querySelector(".vjs-icon-placeholder")):t.appendChild(s),this.iconIsSet_=!0,s}addChild(e,t={},n=this.children_.length){let s,r;if(typeof e=="string"){r=Ne(e);const a=t.componentClass||r;t.name=r;const l=ht.getComponent(a);if(!l)throw new Error(`Component ${a} does not exist`);if(typeof l!="function")return null;s=new l(this.player_||this,t)}else s=e;if(s.parentComponent_&&s.parentComponent_.removeChild(s),this.children_.splice(n,0,s),s.parentComponent_=this,typeof s.id=="function"&&(this.childIndex_[s.id()]=s),r=r||s.name&&Ne(s.name()),r&&(this.childNameIndex_[r]=s,this.childNameIndex_[ls(r)]=s),typeof s.el=="function"&&s.el()){let a=null;this.children_[n+1]&&(this.children_[n+1].el_?a=this.children_[n+1].el_:wn(this.children_[n+1])&&(a=this.children_[n+1])),this.contentEl().insertBefore(s.el(),a)}return s}removeChild(e){if(typeof e=="string"&&(e=this.getChild(e)),!e||!this.children_)return;let t=!1;for(let s=this.children_.length-1;s>=0;s--)if(this.children_[s]===e){t=!0,this.children_.splice(s,1);break}if(!t)return;e.parentComponent_=null,this.childIndex_[e.id()]=null,this.childNameIndex_[Ne(e.name())]=null,this.childNameIndex_[ls(e.name())]=null;const n=e.el();n&&n.parentNode===this.contentEl()&&this.contentEl().removeChild(e.el())}initChildren(){const e=this.options_.children;if(e){const t=this.options_,n=a=>{const l=a.name;let c=a.opts;if(t[l]!==void 0&&(c=t[l]),c===!1)return;c===!0&&(c={}),c.playerOptions=this.options_.playerOptions;const f=this.addChild(l,c);f&&(this[l]=f)};let s;const r=ht.getComponent("Tech");Array.isArray(e)?s=e:s=Object.keys(e),s.concat(Object.keys(this.options_).filter(function(a){return!s.some(function(l){return typeof l=="string"?a===l:a===l.name})})).map(a=>{let l,c;return typeof a=="string"?(l=a,c=e[l]||this.options_[l]||{}):(l=a.name,c=a),{name:l,opts:c}}).filter(a=>{const l=ht.getComponent(a.opts.componentClass||Ne(a.name));return l&&!r.isTech(l)}).forEach(n)}}buildCSSClass(){return""}ready(e,t=!1){if(e){if(!this.isReady_){this.readyQueue_=this.readyQueue_||[],this.readyQueue_.push(e);return}t?e.call(this):this.setTimeout(e,1)}}triggerReady(){this.isReady_=!0,this.setTimeout(function(){const e=this.readyQueue_;this.readyQueue_=[],e&&e.length>0&&e.forEach(function(t){t.call(this)},this),this.trigger("ready")},1)}$(e,t){return vi(e,t||this.contentEl())}$$(e,t){return qh(e,t||this.contentEl())}hasClass(e){return os(this.el_,e)}addClass(...e){Bi(this.el_,...e)}removeClass(...e){Hr(this.el_,...e)}toggleClass(e,t){Mh(this.el_,e,t)}show(){this.removeClass("vjs-hidden")}hide(){this.addClass("vjs-hidden")}lockShowing(){this.addClass("vjs-lock-showing")}unlockShowing(){this.removeClass("vjs-lock-showing")}getAttribute(e){return Uh(this.el_,e)}setAttribute(e,t){yn(this.el_,e,t)}removeAttribute(e){zr(this.el_,e)}width(e,t){return this.dimension("width",e,t)}height(e,t){return this.dimension("height",e,t)}dimensions(e,t){this.width(e,!0),this.height(t)}dimension(e,t,n){if(t!==void 0){(t===null||t!==t)&&(t=0),(""+t).indexOf("%")!==-1||(""+t).indexOf("px")!==-1?this.el_.style[e]=t:t==="auto"?this.el_.style[e]="":this.el_.style[e]=t+"px",n||this.trigger("componentresize");return}if(!this.el_)return 0;const s=this.el_.style[e],r=s.indexOf("px");return parseInt(r!==-1?s.slice(0,r):this.el_["offset"+Ne(e)],10)}currentDimension(e){let t=0;if(e!=="width"&&e!=="height")throw new Error("currentDimension only accepts width or height value");if(t=bn(this.el_,e),t=parseFloat(t),t===0||isNaN(t)){const n=`offset${Ne(e)}`;t=this.el_[n]}return t}currentDimensions(){return{width:this.currentDimension("width"),height:this.currentDimension("height")}}currentWidth(){return this.currentDimension("width")}currentHeight(){return this.currentDimension("height")}getPositions(){const e=this.el_.getBoundingClientRect(),t={x:e.x,y:e.y,width:e.width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left},n={x:e.left+e.width/2,y:e.top+e.height/2,width:0,height:0,top:e.top+e.height/2,right:e.left+e.width/2,bottom:e.top+e.height/2,left:e.left+e.width/2};return{boundingClientRect:t,center:n}}focus(){this.el_.focus()}blur(){this.el_.blur()}handleKeyDown(e){this.player_&&(e.key!=="Tab"&&!(this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled)&&e.stopPropagation(),this.player_.handleKeyDown(e))}handleKeyPress(e){this.handleKeyDown(e)}emitTapEvents(){let e=0,t=null;const n=10,s=200;let r;this.on("touchstart",function(l){l.touches.length===1&&(t={pageX:l.touches[0].pageX,pageY:l.touches[0].pageY},e=x.performance.now(),r=!0)}),this.on("touchmove",function(l){if(l.touches.length>1)r=!1;else if(t){const c=l.touches[0].pageX-t.pageX,f=l.touches[0].pageY-t.pageY;Math.sqrt(c*c+f*f)>n&&(r=!1)}});const a=function(){r=!1};this.on("touchleave",a),this.on("touchcancel",a),this.on("touchend",function(l){t=null,r===!0&&x.performance.now()-e<s&&(l.preventDefault(),this.trigger("tap"))})}enableTouchActivity(){if(!this.player()||!this.player().reportUserActivity)return;const e=Ce(this.player(),this.player().reportUserActivity);let t;this.on("touchstart",function(){e(),this.clearInterval(t),t=this.setInterval(e,250)});const n=function(s){e(),this.clearInterval(t)};this.on("touchmove",e),this.on("touchend",n),this.on("touchcancel",n)}setTimeout(e,t){var n;return e=Ce(this,e),this.clearTimersOnDispose_(),n=x.setTimeout(()=>{this.setTimeoutIds_.has(n)&&this.setTimeoutIds_.delete(n),e()},t),this.setTimeoutIds_.add(n),n}clearTimeout(e){return this.setTimeoutIds_.has(e)&&(this.setTimeoutIds_.delete(e),x.clearTimeout(e)),e}setInterval(e,t){e=Ce(this,e),this.clearTimersOnDispose_();const n=x.setInterval(e,t);return this.setIntervalIds_.add(n),n}clearInterval(e){return this.setIntervalIds_.has(e)&&(this.setIntervalIds_.delete(e),x.clearInterval(e)),e}requestAnimationFrame(e){this.clearTimersOnDispose_();var t;return e=Ce(this,e),t=x.requestAnimationFrame(()=>{this.rafIds_.has(t)&&this.rafIds_.delete(t),e()}),this.rafIds_.add(t),t}requestNamedAnimationFrame(e,t){this.namedRafs_.has(e)&&this.cancelNamedAnimationFrame(e),this.clearTimersOnDispose_(),t=Ce(this,t);const n=this.requestAnimationFrame(()=>{t(),this.namedRafs_.has(e)&&this.namedRafs_.delete(e)});return this.namedRafs_.set(e,n),e}cancelNamedAnimationFrame(e){this.namedRafs_.has(e)&&(this.cancelAnimationFrame(this.namedRafs_.get(e)),this.namedRafs_.delete(e))}cancelAnimationFrame(e){return this.rafIds_.has(e)&&(this.rafIds_.delete(e),x.cancelAnimationFrame(e)),e}clearTimersOnDispose_(){this.clearingTimersOnDispose_||(this.clearingTimersOnDispose_=!0,this.one("dispose",()=>{[["namedRafs_","cancelNamedAnimationFrame"],["rafIds_","cancelAnimationFrame"],["setTimeoutIds_","clearTimeout"],["setIntervalIds_","clearInterval"]].forEach(([e,t])=>{this[e].forEach((n,s)=>this[t](s))}),this.clearingTimersOnDispose_=!1}))}getIsDisabled(){return!!this.el_.disabled}getIsExpresslyInert(){return this.el_.inert&&!this.el_.ownerDocument.documentElement.inert}getIsFocusable(e){return(e||this.el_).tabIndex>=0&&!(this.getIsDisabled()||this.getIsExpresslyInert())}getIsAvailableToBeFocused(e){function t(r){const a=x.getComputedStyle(r,null),l=a.getPropertyValue("visibility");return a.getPropertyValue("display")!=="none"&&!["hidden","collapse"].includes(l)}function n(r){return!(!t(r.parentElement)||!t(r)||r.style.opacity==="0"||x.getComputedStyle(r).height==="0px"||x.getComputedStyle(r).width==="0px")}function s(r){if(r.offsetWidth+r.offsetHeight+r.getBoundingClientRect().height+r.getBoundingClientRect().width===0)return!1;const a={x:r.getBoundingClientRect().left+r.offsetWidth/2,y:r.getBoundingClientRect().top+r.offsetHeight/2};if(a.x<0||a.x>(G.documentElement.clientWidth||x.innerWidth)||a.y<0||a.y>(G.documentElement.clientHeight||x.innerHeight))return!1;let l=G.elementFromPoint(a.x,a.y);for(;l;){if(l===r)return!0;if(l.parentNode)l=l.parentNode;else return!1}}return e||(e=this.el()),!!(s(e)&&n(e)&&(!e.parentElement||e.tabIndex>=0))}static registerComponent(e,t){if(typeof e!="string"||!e)throw new Error(`Illegal component name, "${e}"; must be a non-empty string.`);const n=ht.getComponent("Tech"),s=n&&n.isTech(t),r=ht===t||ht.prototype.isPrototypeOf(t.prototype);if(s||!r){let l;throw s?l="techs must be registered using Tech.registerTech()":l="must be a Component subclass",new Error(`Illegal component, "${e}"; ${l}.`)}e=Ne(e),ht.components_||(ht.components_={});const a=ht.getComponent("Player");if(e==="Player"&&a&&a.players){const l=a.players,c=Object.keys(l);if(l&&c.length>0&&c.map(f=>l[f]).every(Boolean))throw new Error("Can not register Player component after player has been created.")}return ht.components_[e]=t,ht.components_[ls(e)]=t,t}static getComponent(e){if(!(!e||!ht.components_))return ht.components_[e]}};H.registerComponent("Component",H);function F1(i,e,t){if(typeof e!="number"||e<0||e>t)throw new Error(`Failed to execute '${i}' on 'TimeRanges': The index provided (${e}) is non-numeric or out of bounds (0-${t}).`)}function Uu(i,e,t,n){return F1(i,n,t.length-1),t[n][e]}function Da(i){let e;return i===void 0||i.length===0?e={length:0,start(){throw new Error("This TimeRanges object is empty")},end(){throw new Error("This TimeRanges object is empty")}}:e={length:i.length,start:Uu.bind(null,"start",0,i),end:Uu.bind(null,"end",1,i)},x.Symbol&&x.Symbol.iterator&&(e[x.Symbol.iterator]=()=>(i||[]).values()),e}function Ut(i,e){return Array.isArray(i)?Da(i):i===void 0||e===void 0?Da():Da([[i,e]])}const Zh=function(i,e){i=i<0?0:i;let t=Math.floor(i%60),n=Math.floor(i/60%60),s=Math.floor(i/3600);const r=Math.floor(e/60%60),a=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(s=n=t="-"),s=s>0||a>0?s+":":"",n=((s||r>=10)&&n<10?"0"+n:n)+":",t=t<10?"0"+t:t,s+n+t};let Vo=Zh;function ec(i){Vo=i}function tc(){Vo=Zh}function qi(i,e=i){return Vo(i,e)}var j1=Object.freeze({__proto__:null,createTimeRanges:Ut,createTimeRange:Ut,setFormatTime:ec,resetFormatTime:tc,formatTime:qi});function ic(i,e){let t=0,n,s;if(!e)return 0;(!i||!i.length)&&(i=Ut(0,0));for(let r=0;r<i.length;r++)n=i.start(r),s=i.end(r),s>e&&(s=e),t+=s-n;return t/e}function Me(i){if(i instanceof Me)return i;typeof i=="number"?this.code=i:typeof i=="string"?this.message=i:Qt(i)&&(typeof i.code=="number"&&(this.code=i.code),Object.assign(this,i)),this.message||(this.message=Me.defaultMessages[this.code]||"")}Me.prototype.code=0;Me.prototype.message="";Me.prototype.status=null;Me.prototype.metadata=null;Me.errorTypes=["MEDIA_ERR_CUSTOM","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED","MEDIA_ERR_ENCRYPTED"];Me.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail part-way.",3:"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.",4:"The media could not be loaded, either because the server or network failed or because the format is not supported.",5:"The media is encrypted and we do not have the keys to decrypt it."};Me.MEDIA_ERR_CUSTOM=0;Me.prototype.MEDIA_ERR_CUSTOM=0;Me.MEDIA_ERR_ABORTED=1;Me.prototype.MEDIA_ERR_ABORTED=1;Me.MEDIA_ERR_NETWORK=2;Me.prototype.MEDIA_ERR_NETWORK=2;Me.MEDIA_ERR_DECODE=3;Me.prototype.MEDIA_ERR_DECODE=3;Me.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Me.prototype.MEDIA_ERR_SRC_NOT_SUPPORTED=4;Me.MEDIA_ERR_ENCRYPTED=5;Me.prototype.MEDIA_ERR_ENCRYPTED=5;function us(i){return i!=null&&typeof i.then=="function"}function Gt(i){us(i)&&i.then(null,e=>{})}const io=function(i){return["kind","label","language","id","inBandMetadataTrackDispatchType","mode","src"].reduce((e,t,n)=>(i[t]&&(e[t]=i[t]),e),{cues:i.cues&&Array.prototype.map.call(i.cues,function(e){return{startTime:e.startTime,endTime:e.endTime,text:e.text,id:e.id}})})},$1=function(i){const e=i.$$("track"),t=Array.prototype.map.call(e,n=>n.track);return Array.prototype.map.call(e,function(n){const s=io(n.track);return n.src&&(s.src=n.src),s}).concat(Array.prototype.filter.call(i.textTracks(),function(n){return t.indexOf(n)===-1}).map(io))},q1=function(i,e){return i.forEach(function(t){const n=e.addRemoteTextTrack(t).track;!t.src&&t.cues&&t.cues.forEach(s=>n.addCue(s))}),e.textTracks()};var Nu={textTracksToJson:$1,jsonToTextTracks:q1,trackToJson_:io};const Oa="vjs-modal-dialog";class Cn extends H{constructor(e,t){super(e,t),this.handleKeyDown_=n=>this.handleKeyDown(n),this.close_=n=>this.close(n),this.opened_=this.hasBeenOpened_=this.hasBeenFilled_=!1,this.closeable(!this.options_.uncloseable),this.content(this.options_.content),this.contentEl_=ne("div",{className:`${Oa}-content`},{role:"document"}),this.descEl_=ne("p",{className:`${Oa}-description vjs-control-text`,id:this.el().getAttribute("aria-describedby")}),Si(this.descEl_,this.description()),this.el_.appendChild(this.descEl_),this.el_.appendChild(this.contentEl_)}createEl(){return super.createEl("div",{className:this.buildCSSClass(),tabIndex:-1},{"aria-describedby":`${this.id()}_description`,"aria-hidden":"true","aria-label":this.label(),role:"dialog","aria-live":"polite"})}dispose(){this.contentEl_=null,this.descEl_=null,this.previouslyActiveEl_=null,super.dispose()}buildCSSClass(){return`${Oa} vjs-hidden ${super.buildCSSClass()}`}label(){return this.localize(this.options_.label||"Modal Window")}description(){let e=this.options_.description||this.localize("This is a modal window.");return this.closeable()&&(e+=" "+this.localize("This modal can be closed by pressing the Escape key or activating the close button.")),e}open(){if(this.opened_){this.options_.fillAlways&&this.fill();return}const e=this.player();this.trigger("beforemodalopen"),this.opened_=!0,(this.options_.fillAlways||!this.hasBeenOpened_&&!this.hasBeenFilled_)&&this.fill(),this.wasPlaying_=!e.paused(),this.options_.pauseOnOpen&&this.wasPlaying_&&e.pause(),this.on("keydown",this.handleKeyDown_),this.hadControls_=e.controls(),e.controls(!1),this.show(),this.conditionalFocus_(),this.el().setAttribute("aria-hidden","false"),this.trigger("modalopen"),this.hasBeenOpened_=!0}opened(e){return typeof e=="boolean"&&this[e?"open":"close"](),this.opened_}close(){if(!this.opened_)return;const e=this.player();this.trigger("beforemodalclose"),this.opened_=!1,this.wasPlaying_&&this.options_.pauseOnOpen&&e.play(),this.off("keydown",this.handleKeyDown_),this.hadControls_&&e.controls(!0),this.hide(),this.el().setAttribute("aria-hidden","true"),this.trigger({type:"modalclose",bubbles:!0}),this.conditionalBlur_(),this.options_.temporary&&this.dispose()}closeable(e){if(typeof e=="boolean"){const t=this.closeable_=!!e;let n=this.getChild("closeButton");if(t&&!n){const s=this.contentEl_;this.contentEl_=this.el_,n=this.addChild("closeButton",{controlText:"Close Modal Dialog"}),this.contentEl_=s,this.on(n,"close",this.close_)}!t&&n&&(this.off(n,"close",this.close_),this.removeChild(n),n.dispose())}return this.closeable_}fill(){this.fillWith(this.content())}fillWith(e){const t=this.contentEl(),n=t.parentNode,s=t.nextSibling;this.trigger("beforemodalfill"),this.hasBeenFilled_=!0,n.removeChild(t),this.empty(),$h(t,e),this.trigger("modalfill"),s?n.insertBefore(t,s):n.appendChild(t);const r=this.getChild("closeButton");r&&n.appendChild(r.el_),this.trigger("aftermodalfill")}empty(){this.trigger("beforemodalempty"),Gr(this.contentEl()),this.trigger("modalempty")}content(e){return typeof e<"u"&&(this.content_=e),this.content_}conditionalFocus_(){const e=G.activeElement,t=this.player_.el_;this.previouslyActiveEl_=null,(t.contains(e)||t===e)&&(this.previouslyActiveEl_=e,this.focus())}conditionalBlur_(){this.previouslyActiveEl_&&(this.previouslyActiveEl_.focus(),this.previouslyActiveEl_=null)}handleKeyDown(e){if(this.trigger({type:"modalKeydown",originalEvent:e,target:this,bubbles:!0}),e.stopPropagation(),e.key==="Escape"&&this.closeable()){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;const t=this.focusableEls_(),n=this.el_.querySelector(":focus");let s;for(let r=0;r<t.length;r++)if(n===t[r]){s=r;break}G.activeElement===this.el_&&(s=0),e.shiftKey&&s===0?(t[t.length-1].focus(),e.preventDefault()):!e.shiftKey&&s===t.length-1&&(t[0].focus(),e.preventDefault())}focusableEls_(){const e=this.el_.querySelectorAll("*");return Array.prototype.filter.call(e,t=>(t instanceof x.HTMLAnchorElement||t instanceof x.HTMLAreaElement)&&t.hasAttribute("href")||(t instanceof x.HTMLInputElement||t instanceof x.HTMLSelectElement||t instanceof x.HTMLTextAreaElement||t instanceof x.HTMLButtonElement)&&!t.hasAttribute("disabled")||t instanceof x.HTMLIFrameElement||t instanceof x.HTMLObjectElement||t instanceof x.HTMLEmbedElement||t.hasAttribute("tabindex")&&t.getAttribute("tabindex")!==-1||t.hasAttribute("contenteditable"))}}Cn.prototype.options_={pauseOnOpen:!0,temporary:!0};H.registerComponent("ModalDialog",Cn);class Tn extends St{constructor(e=[]){super(),this.tracks_=[],Object.defineProperty(this,"length",{get(){return this.tracks_.length}});for(let t=0;t<e.length;t++)this.addTrack(e[t])}addTrack(e){const t=this.tracks_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.tracks_[t]}}),this.tracks_.indexOf(e)===-1&&(this.tracks_.push(e),this.trigger({track:e,type:"addtrack",target:this})),e.labelchange_=()=>{this.trigger({track:e,type:"labelchange",target:this})},si(e)&&e.addEventListener("labelchange",e.labelchange_)}removeTrack(e){let t;for(let n=0,s=this.length;n<s;n++)if(this[n]===e){t=this[n],t.off&&t.off(),this.tracks_.splice(n,1);break}t&&this.trigger({track:t,type:"removetrack",target:this})}getTrackById(e){let t=null;for(let n=0,s=this.length;n<s;n++){const r=this[n];if(r.id===e){t=r;break}}return t}}Tn.prototype.allowedEvents_={change:"change",addtrack:"addtrack",removetrack:"removetrack",labelchange:"labelchange"};for(const i in Tn.prototype.allowedEvents_)Tn.prototype["on"+i]=null;const Ma=function(i,e){for(let t=0;t<i.length;t++)!Object.keys(i[t]).length||e.id===i[t].id||(i[t].enabled=!1)};class V1 extends Tn{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].enabled){Ma(e,e[t]);break}super(e),this.changing_=!1}addTrack(e){e.enabled&&Ma(this,e),super.addTrack(e),e.addEventListener&&(e.enabledChange_=()=>{this.changing_||(this.changing_=!0,Ma(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("enabledchange",e.enabledChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.enabledChange_&&(e.removeEventListener("enabledchange",e.enabledChange_),e.enabledChange_=null)}}const Ra=function(i,e){for(let t=0;t<i.length;t++)!Object.keys(i[t]).length||e.id===i[t].id||(i[t].selected=!1)};class H1 extends Tn{constructor(e=[]){for(let t=e.length-1;t>=0;t--)if(e[t].selected){Ra(e,e[t]);break}super(e),this.changing_=!1,Object.defineProperty(this,"selectedIndex",{get(){for(let t=0;t<this.length;t++)if(this[t].selected)return t;return-1},set(){}})}addTrack(e){e.selected&&Ra(this,e),super.addTrack(e),e.addEventListener&&(e.selectedChange_=()=>{this.changing_||(this.changing_=!0,Ra(this,e),this.changing_=!1,this.trigger("change"))},e.addEventListener("selectedchange",e.selectedChange_))}removeTrack(e){super.removeTrack(e),e.removeEventListener&&e.selectedChange_&&(e.removeEventListener("selectedchange",e.selectedChange_),e.selectedChange_=null)}}class nc extends Tn{addTrack(e){super.addTrack(e),this.queueChange_||(this.queueChange_=()=>this.queueTrigger("change")),this.triggerSelectedlanguagechange||(this.triggerSelectedlanguagechange_=()=>this.trigger("selectedlanguagechange")),e.addEventListener("modechange",this.queueChange_),["metadata","chapters"].indexOf(e.kind)===-1&&e.addEventListener("modechange",this.triggerSelectedlanguagechange_)}removeTrack(e){super.removeTrack(e),e.removeEventListener&&(this.queueChange_&&e.removeEventListener("modechange",this.queueChange_),this.selectedlanguagechange_&&e.removeEventListener("modechange",this.triggerSelectedlanguagechange_))}}class z1{constructor(e=[]){this.trackElements_=[],Object.defineProperty(this,"length",{get(){return this.trackElements_.length}});for(let t=0,n=e.length;t<n;t++)this.addTrackElement_(e[t])}addTrackElement_(e){const t=this.trackElements_.length;""+t in this||Object.defineProperty(this,t,{get(){return this.trackElements_[t]}}),this.trackElements_.indexOf(e)===-1&&this.trackElements_.push(e)}getTrackElementByTrack_(e){let t;for(let n=0,s=this.trackElements_.length;n<s;n++)if(e===this.trackElements_[n].track){t=this.trackElements_[n];break}return t}removeTrackElement_(e){for(let t=0,n=this.trackElements_.length;t<n;t++)if(e===this.trackElements_[t]){this.trackElements_[t].track&&typeof this.trackElements_[t].track.off=="function"&&this.trackElements_[t].track.off(),typeof this.trackElements_[t].off=="function"&&this.trackElements_[t].off(),this.trackElements_.splice(t,1);break}}}class yr{constructor(e){yr.prototype.setCues_.call(this,e),Object.defineProperty(this,"length",{get(){return this.length_}})}setCues_(e){const t=this.length||0;let n=0;const s=e.length;this.cues_=e,this.length_=e.length;const r=function(a){""+a in this||Object.defineProperty(this,""+a,{get(){return this.cues_[a]}})};if(t<s)for(n=t;n<s;n++)r.call(this,n)}getCueById(e){let t=null;for(let n=0,s=this.length;n<s;n++){const r=this[n];if(r.id===e){t=r;break}}return t}}const W1={alternative:"alternative",captions:"captions",main:"main",sign:"sign",subtitles:"subtitles",commentary:"commentary"},G1={alternative:"alternative",descriptions:"descriptions",main:"main","main-desc":"main-desc",translation:"translation",commentary:"commentary"},X1={subtitles:"subtitles",captions:"captions",descriptions:"descriptions",chapters:"chapters",metadata:"metadata"},Bu={disabled:"disabled",hidden:"hidden",showing:"showing"};class Ho extends St{constructor(e={}){super();const t={id:e.id||"vjs_track_"+At(),kind:e.kind||"",language:e.language||""};let n=e.label||"";for(const s in t)Object.defineProperty(this,s,{get(){return t[s]},set(){}});Object.defineProperty(this,"label",{get(){return n},set(s){s!==n&&(n=s,this.trigger("labelchange"))}})}}const zo=function(i){return new URL(i,G.baseURI)},sc=function(i){return new URL(i,G.baseURI).href},Wo=function(i){if(typeof i=="string"){const e=/^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/.exec(i);if(e)return e.pop().toLowerCase()}return""},Qr=function(i,e=x.location){return zo(i).origin!==e.origin};var K1=Object.freeze({__proto__:null,parseUrl:zo,getAbsoluteURL:sc,getFileExtension:Wo,isCrossOrigin:Qr});const Fu=function(i,e){const t=new x.WebVTT.Parser(x,x.vttjs,x.WebVTT.StringDecoder()),n=[];t.oncue=function(s){e.addCue(s)},t.onparsingerror=function(s){n.push(s)},t.onflush=function(){e.trigger({type:"loadeddata",target:e})},t.parse(i),n.length>0&&(x.console&&x.console.groupCollapsed&&x.console.groupCollapsed(`Text Track parsing errors for ${e.src}`),n.forEach(s=>oe.error(s)),x.console&&x.console.groupEnd&&x.console.groupEnd()),t.flush()},ju=function(i,e){const t={uri:i},n=Qr(i);n&&(t.cors=n);const s=e.tech_.crossOrigin()==="use-credentials";s&&(t.withCredentials=s),Zd(t,Ce(this,function(r,a,l){if(r)return oe.error(r,a);e.loaded_=!0,typeof x.WebVTT!="function"?e.tech_&&e.tech_.any(["vttjsloaded","vttjserror"],c=>{if(c.type==="vttjserror"){oe.error(`vttjs failed to load, stopping trying to process ${e.src}`);return}return Fu(l,e)}):Fu(l,e)}))};class _s extends Ho{constructor(e={}){if(!e.tech)throw new Error("A tech was not provided.");const t=ve(e,{kind:X1[e.kind]||"subtitles",language:e.language||e.srclang||""});let n=Bu[t.mode]||"disabled";const s=t.default;(t.kind==="metadata"||t.kind==="chapters")&&(n="hidden"),super(t),this.tech_=t.tech,this.cues_=[],this.activeCues_=[],this.preload_=this.tech_.preloadTextTracks!==!1;const r=new yr(this.cues_),a=new yr(this.activeCues_);let l=!1;this.timeupdateHandler=Ce(this,function(f={}){if(!this.tech_.isDisposed()){if(!this.tech_.isReady_){f.type!=="timeupdate"&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler));return}this.activeCues=this.activeCues,l&&(this.trigger("cuechange"),l=!1),f.type!=="timeupdate"&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler))}});const c=()=>{this.stopTracking()};this.tech_.one("dispose",c),n!=="disabled"&&this.startTracking(),Object.defineProperties(this,{default:{get(){return s},set(){}},mode:{get(){return n},set(f){Bu[f]&&n!==f&&(n=f,!this.preload_&&n!=="disabled"&&this.cues.length===0&&ju(this.src,this),this.stopTracking(),n!=="disabled"&&this.startTracking(),this.trigger("modechange"))}},cues:{get(){return this.loaded_?r:null},set(){}},activeCues:{get(){if(!this.loaded_)return null;if(this.cues.length===0)return a;const f=this.tech_.currentTime(),m=[];for(let b=0,C=this.cues.length;b<C;b++){const w=this.cues[b];w.startTime<=f&&w.endTime>=f&&m.push(w)}if(l=!1,m.length!==this.activeCues_.length)l=!0;else for(let b=0;b<m.length;b++)this.activeCues_.indexOf(m[b])===-1&&(l=!0);return this.activeCues_=m,a.setCues_(this.activeCues_),a},set(){}}}),t.src?(this.src=t.src,this.preload_||(this.loaded_=!0),(this.preload_||t.kind!=="subtitles"&&t.kind!=="captions")&&ju(this.src,this)):this.loaded_=!0}startTracking(){this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler),this.tech_.on("timeupdate",this.timeupdateHandler)}stopTracking(){this.rvf_&&(this.tech_.cancelVideoFrameCallback(this.rvf_),this.rvf_=void 0),this.tech_.off("timeupdate",this.timeupdateHandler)}addCue(e){let t=e;if(!("getCueAsHTML"in t)){t=new x.vttjs.VTTCue(e.startTime,e.endTime,e.text);for(const s in e)s in t||(t[s]=e[s]);t.id=e.id,t.originalCue_=e}const n=this.tech_.textTracks();for(let s=0;s<n.length;s++)n[s]!==this&&n[s].removeCue(t);this.cues_.push(t),this.cues.setCues_(this.cues_)}removeCue(e){let t=this.cues_.length;for(;t--;){const n=this.cues_[t];if(n===e||n.originalCue_&&n.originalCue_===e){this.cues_.splice(t,1),this.cues.setCues_(this.cues_);break}}}}_s.prototype.allowedEvents_={cuechange:"cuechange"};class rc extends Ho{constructor(e={}){const t=ve(e,{kind:G1[e.kind]||""});super(t);let n=!1;Object.defineProperty(this,"enabled",{get(){return n},set(s){typeof s!="boolean"||s===n||(n=s,this.trigger("enabledchange"))}}),t.enabled&&(this.enabled=t.enabled),this.loaded_=!0}}class ac extends Ho{constructor(e={}){const t=ve(e,{kind:W1[e.kind]||""});super(t);let n=!1;Object.defineProperty(this,"selected",{get(){return n},set(s){typeof s!="boolean"||s===n||(n=s,this.trigger("selectedchange"))}}),t.selected&&(this.selected=t.selected)}}class ai extends St{constructor(e={}){super();let t;const n=new _s(e);this.kind=n.kind,this.src=n.src,this.srclang=n.language,this.label=n.label,this.default=n.default,Object.defineProperties(this,{readyState:{get(){return t}},track:{get(){return n}}}),t=ai.NONE,n.addEventListener("loadeddata",()=>{t=ai.LOADED,this.trigger({type:"load",target:this})})}}ai.prototype.allowedEvents_={load:"load"};ai.NONE=0;ai.LOADING=1;ai.LOADED=2;ai.ERROR=3;const xt={audio:{ListClass:V1,TrackClass:rc,capitalName:"Audio"},video:{ListClass:H1,TrackClass:ac,capitalName:"Video"},text:{ListClass:nc,TrackClass:_s,capitalName:"Text"}};Object.keys(xt).forEach(function(i){xt[i].getterName=`${i}Tracks`,xt[i].privateName=`${i}Tracks_`});const vn={remoteText:{ListClass:nc,TrackClass:_s,capitalName:"RemoteText",getterName:"remoteTextTracks",privateName:"remoteTextTracks_"},remoteTextEl:{ListClass:z1,TrackClass:ai,capitalName:"RemoteTextTrackEls",getterName:"remoteTextTrackEls",privateName:"remoteTextTrackEls_"}},at=Object.assign({},xt,vn);vn.names=Object.keys(vn);xt.names=Object.keys(xt);at.names=[].concat(vn.names).concat(xt.names);function Y1(i,e,t,n,s={}){const r=i.textTracks();s.kind=e,t&&(s.label=t),n&&(s.language=n),s.tech=i;const a=new at.text.TrackClass(s);return r.addTrack(a),a}class ae extends H{constructor(e={},t=function(){}){e.reportTouchActivity=!1,super(null,e,t),this.onDurationChange_=n=>this.onDurationChange(n),this.trackProgress_=n=>this.trackProgress(n),this.trackCurrentTime_=n=>this.trackCurrentTime(n),this.stopTrackingCurrentTime_=n=>this.stopTrackingCurrentTime(n),this.disposeSourceHandler_=n=>this.disposeSourceHandler(n),this.queuedHanders_=new Set,this.hasStarted_=!1,this.on("playing",function(){this.hasStarted_=!0}),this.on("loadstart",function(){this.hasStarted_=!1}),at.names.forEach(n=>{const s=at[n];e&&e[s.getterName]&&(this[s.privateName]=e[s.getterName])}),this.featuresProgressEvents||this.manualProgressOn(),this.featuresTimeupdateEvents||this.manualTimeUpdatesOn(),["Text","Audio","Video"].forEach(n=>{e[`native${n}Tracks`]===!1&&(this[`featuresNative${n}Tracks`]=!1)}),e.nativeCaptions===!1||e.nativeTextTracks===!1?this.featuresNativeTextTracks=!1:(e.nativeCaptions===!0||e.nativeTextTracks===!0)&&(this.featuresNativeTextTracks=!0),this.featuresNativeTextTracks||this.emulateTextTracks(),this.preloadTextTracks=e.preloadTextTracks!==!1,this.autoRemoteTextTracks_=new at.text.ListClass,this.initTrackListeners(),e.nativeControlsForTouch||this.emitTapEvents(),this.constructor&&(this.name_=this.constructor.name||"Unknown Tech")}triggerSourceset(e){this.isReady_||this.one("ready",()=>this.setTimeout(()=>this.triggerSourceset(e),1)),this.trigger({src:e,type:"sourceset"})}manualProgressOn(){this.on("durationchange",this.onDurationChange_),this.manualProgress=!0,this.one("ready",this.trackProgress_)}manualProgressOff(){this.manualProgress=!1,this.stopTrackingProgress(),this.off("durationchange",this.onDurationChange_)}trackProgress(e){this.stopTrackingProgress(),this.progressInterval=this.setInterval(Ce(this,function(){const t=this.bufferedPercent();this.bufferedPercent_!==t&&this.trigger("progress"),this.bufferedPercent_=t,t===1&&this.stopTrackingProgress()}),500)}onDurationChange(e){this.duration_=this.duration()}buffered(){return Ut(0,0)}bufferedPercent(){return ic(this.buffered(),this.duration_)}stopTrackingProgress(){this.clearInterval(this.progressInterval)}manualTimeUpdatesOn(){this.manualTimeUpdates=!0,this.on("play",this.trackCurrentTime_),this.on("pause",this.stopTrackingCurrentTime_)}manualTimeUpdatesOff(){this.manualTimeUpdates=!1,this.stopTrackingCurrentTime(),this.off("play",this.trackCurrentTime_),this.off("pause",this.stopTrackingCurrentTime_)}trackCurrentTime(){this.currentTimeInterval&&this.stopTrackingCurrentTime(),this.currentTimeInterval=this.setInterval(function(){this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})},250)}stopTrackingCurrentTime(){this.clearInterval(this.currentTimeInterval),this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}dispose(){this.clearTracks(xt.names),this.manualProgress&&this.manualProgressOff(),this.manualTimeUpdates&&this.manualTimeUpdatesOff(),super.dispose()}clearTracks(e){e=[].concat(e),e.forEach(t=>{const n=this[`${t}Tracks`]()||[];let s=n.length;for(;s--;){const r=n[s];t==="text"&&this.removeRemoteTextTrack(r),n.removeTrack(r)}})}cleanupAutoTextTracks(){const e=this.autoRemoteTextTracks_||[];let t=e.length;for(;t--;){const n=e[t];this.removeRemoteTextTrack(n)}}reset(){}crossOrigin(){}setCrossOrigin(){}error(e){return e!==void 0&&(this.error_=new Me(e),this.trigger("error")),this.error_}played(){return this.hasStarted_?Ut(0,0):Ut()}play(){}setScrubbing(e){}scrubbing(){}setCurrentTime(e){this.manualTimeUpdates&&this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}initTrackListeners(){xt.names.forEach(e=>{const t=xt[e],n=()=>{this.trigger(`${e}trackchange`)},s=this[t.getterName]();s.addEventListener("removetrack",n),s.addEventListener("addtrack",n),this.on("dispose",()=>{s.removeEventListener("removetrack",n),s.removeEventListener("addtrack",n)})})}addWebVttScript_(){if(!x.WebVTT)if(G.body.contains(this.el())){if(!this.options_["vtt.js"]&&mn(yu)&&Object.keys(yu).length>0){this.trigger("vttjsloaded");return}const e=G.createElement("script");e.src=this.options_["vtt.js"]||"https://vjs.zencdn.net/vttjs/0.14.1/vtt.min.js",e.onload=()=>{this.trigger("vttjsloaded")},e.onerror=()=>{this.trigger("vttjserror")},this.on("dispose",()=>{e.onload=null,e.onerror=null}),x.WebVTT=!0,this.el().parentNode.appendChild(e)}else this.ready(this.addWebVttScript_)}emulateTextTracks(){const e=this.textTracks(),t=this.remoteTextTracks(),n=l=>e.addTrack(l.track),s=l=>e.removeTrack(l.track);t.on("addtrack",n),t.on("removetrack",s),this.addWebVttScript_();const r=()=>this.trigger("texttrackchange"),a=()=>{r();for(let l=0;l<e.length;l++){const c=e[l];c.removeEventListener("cuechange",r),c.mode==="showing"&&c.addEventListener("cuechange",r)}};a(),e.addEventListener("change",a),e.addEventListener("addtrack",a),e.addEventListener("removetrack",a),this.on("dispose",function(){t.off("addtrack",n),t.off("removetrack",s),e.removeEventListener("change",a),e.removeEventListener("addtrack",a),e.removeEventListener("removetrack",a);for(let l=0;l<e.length;l++)e[l].removeEventListener("cuechange",r)})}addTextTrack(e,t,n){if(!e)throw new Error("TextTrack kind is required but was not provided");return Y1(this,e,t,n)}createRemoteTextTrack(e){const t=ve(e,{tech:this});return new vn.remoteTextEl.TrackClass(t)}addRemoteTextTrack(e={},t){const n=this.createRemoteTextTrack(e);return typeof t!="boolean"&&(t=!1),this.remoteTextTrackEls().addTrackElement_(n),this.remoteTextTracks().addTrack(n.track),t===!1&&this.ready(()=>this.autoRemoteTextTracks_.addTrack(n.track)),n}removeRemoteTextTrack(e){const t=this.remoteTextTrackEls().getTrackElementByTrack_(e);this.remoteTextTrackEls().removeTrackElement_(t),this.remoteTextTracks().removeTrack(e),this.autoRemoteTextTracks_.removeTrack(e)}getVideoPlaybackQuality(){return{}}requestPictureInPicture(){return Promise.reject()}disablePictureInPicture(){return!0}setDisablePictureInPicture(){}requestVideoFrameCallback(e){const t=At();return!this.isReady_||this.paused()?(this.queuedHanders_.add(t),this.one("playing",()=>{this.queuedHanders_.has(t)&&(this.queuedHanders_.delete(t),e())})):this.requestNamedAnimationFrame(t,e),t}cancelVideoFrameCallback(e){this.queuedHanders_.has(e)?this.queuedHanders_.delete(e):this.cancelNamedAnimationFrame(e)}setPoster(){}playsinline(){}setPlaysinline(){}overrideNativeAudioTracks(e){}overrideNativeVideoTracks(e){}canPlayType(e){return""}static canPlayType(e){return""}static canPlaySource(e,t){return ae.canPlayType(e.type)}static isTech(e){return e.prototype instanceof ae||e instanceof ae||e===ae}static registerTech(e,t){if(ae.techs_||(ae.techs_={}),!ae.isTech(t))throw new Error(`Tech ${e} must be a Tech`);if(!ae.canPlayType)throw new Error("Techs must have a static canPlayType method on them");if(!ae.canPlaySource)throw new Error("Techs must have a static canPlaySource method on them");return e=Ne(e),ae.techs_[e]=t,ae.techs_[ls(e)]=t,e!=="Tech"&&ae.defaultTechOrder_.push(e),t}static getTech(e){if(e){if(ae.techs_&&ae.techs_[e])return ae.techs_[e];if(e=Ne(e),x&&x.videojs&&x.videojs[e])return oe.warn(`The ${e} tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)`),x.videojs[e]}}}at.names.forEach(function(i){const e=at[i];ae.prototype[e.getterName]=function(){return this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName]}});ae.prototype.featuresVolumeControl=!0;ae.prototype.featuresMuteControl=!0;ae.prototype.featuresFullscreenResize=!1;ae.prototype.featuresPlaybackRate=!1;ae.prototype.featuresProgressEvents=!1;ae.prototype.featuresSourceset=!1;ae.prototype.featuresTimeupdateEvents=!1;ae.prototype.featuresNativeTextTracks=!1;ae.prototype.featuresVideoFrameCallback=!1;ae.withSourceHandlers=function(i){i.registerSourceHandler=function(e,t){let n=i.sourceHandlers;n||(n=i.sourceHandlers=[]),t===void 0&&(t=n.length),n.splice(t,0,e)},i.canPlayType=function(e){const t=i.sourceHandlers||[];let n;for(let s=0;s<t.length;s++)if(n=t[s].canPlayType(e),n)return n;return""},i.selectSourceHandler=function(e,t){const n=i.sourceHandlers||[];let s;for(let r=0;r<n.length;r++)if(s=n[r].canHandleSource(e,t),s)return n[r];return null},i.canPlaySource=function(e,t){const n=i.selectSourceHandler(e,t);return n?n.canHandleSource(e,t):""},["seekable","seeking","duration"].forEach(function(e){const t=this[e];typeof t=="function"&&(this[e]=function(){return this.sourceHandler_&&this.sourceHandler_[e]?this.sourceHandler_[e].apply(this.sourceHandler_,arguments):t.apply(this,arguments)})},i.prototype),i.prototype.setSource=function(e){let t=i.selectSourceHandler(e,this.options_);t||(i.nativeSourceHandler?t=i.nativeSourceHandler:oe.error("No source handler found for the current source.")),this.disposeSourceHandler(),this.off("dispose",this.disposeSourceHandler_),t!==i.nativeSourceHandler&&(this.currentSource_=e),this.sourceHandler_=t.handleSource(e,this,this.options_),this.one("dispose",this.disposeSourceHandler_)},i.prototype.disposeSourceHandler=function(){this.currentSource_&&(this.clearTracks(["audio","video"]),this.currentSource_=null),this.cleanupAutoTextTracks(),this.sourceHandler_&&(this.sourceHandler_.dispose&&this.sourceHandler_.dispose(),this.sourceHandler_=null)}};H.registerComponent("Tech",ae);ae.registerTech("Tech",ae);ae.defaultTechOrder_=[];const Fi={},_r={},br={};function Q1(i,e){Fi[i]=Fi[i]||[],Fi[i].push(e)}function J1(i,e,t){i.setTimeout(()=>Oi(e,Fi[e.type],t,i),1)}function Z1(i,e){i.forEach(t=>t.setTech&&t.setTech(e))}function eb(i,e,t){return i.reduceRight(Go(t),e[t]())}function tb(i,e,t,n){return e[t](i.reduce(Go(t),n))}function $u(i,e,t,n=null){const s="call"+Ne(t),r=i.reduce(Go(s),n),a=r===br,l=a?null:e[t](r);return sb(i,t,l,a),l}const ib={buffered:1,currentTime:1,duration:1,muted:1,played:1,paused:1,seekable:1,volume:1,ended:1},nb={setCurrentTime:1,setMuted:1,setVolume:1},qu={play:1,pause:1};function Go(i){return(e,t)=>e===br?br:t[i]?t[i](e):e}function sb(i,e,t,n){for(let s=i.length-1;s>=0;s--){const r=i[s];r[e]&&r[e](n,t)}}function rb(i){_r.hasOwnProperty(i.id())&&delete _r[i.id()]}function ab(i,e){const t=_r[i.id()];let n=null;if(t==null)return n=e(i),_r[i.id()]=[[e,n]],n;for(let s=0;s<t.length;s++){const[r,a]=t[s];r===e&&(n=a)}return n===null&&(n=e(i),t.push([e,n])),n}function Oi(i={},e=[],t,n,s=[],r=!1){const[a,...l]=e;if(typeof a=="string")Oi(i,Fi[a],t,n,s,r);else if(a){const c=ab(n,a);if(!c.setSource)return s.push(c),Oi(i,l,t,n,s,r);c.setSource(Object.assign({},i),function(f,m){if(f)return Oi(i,l,t,n,s,r);s.push(c),Oi(m,i.type===m.type?l:Fi[m.type],t,n,s,r)})}else l.length?Oi(i,l,t,n,s,r):r?t(i,s):Oi(i,Fi["*"],t,n,s,!0)}const ob={opus:"video/ogg",ogv:"video/ogg",mp4:"video/mp4",mov:"video/mp4",m4v:"video/mp4",mkv:"video/x-matroska",m4a:"audio/mp4",mp3:"audio/mpeg",aac:"audio/aac",caf:"audio/x-caf",flac:"audio/flac",oga:"audio/ogg",wav:"audio/wav",m3u8:"application/x-mpegURL",mpd:"application/dash+xml",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",png:"image/png",svg:"image/svg+xml",webp:"image/webp"},Tr=function(i=""){const e=Wo(i);return ob[e.toLowerCase()]||""},lb=(i,e)=>{if(!e)return"";if(i.cache_.source.src===e&&i.cache_.source.type)return i.cache_.source.type;const t=i.cache_.sources.filter(s=>s.src===e);if(t.length)return t[0].type;const n=i.$$("source");for(let s=0;s<n.length;s++){const r=n[s];if(r.type&&r.src&&r.src===e)return r.type}return Tr(e)},oc=function(i){if(Array.isArray(i)){let e=[];i.forEach(function(t){t=oc(t),Array.isArray(t)?e=e.concat(t):Qt(t)&&e.push(t)}),i=e}else typeof i=="string"&&i.trim()?i=[Vu({src:i})]:Qt(i)&&typeof i.src=="string"&&i.src&&i.src.trim()?i=[Vu(i)]:i=[];return i};function Vu(i){if(!i.type){const e=Tr(i.src);e&&(i.type=e)}return i}var ub=`<svg xmlns="http://www.w3.org/2000/svg">
|
|
25
25
|
<defs>
|
|
26
26
|
<symbol viewBox="0 0 48 48" id="vjs-icon-play">
|
|
27
27
|
<path d="M16 10v28l22-14z"></path>
|
|
@@ -163,8 +163,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
163
163
|
<path d="M1664 896q0 209-103 385.5T1281.5 1561 896 1664q-111 0-218-32 59-93 78-164 9-34 54-211 20 39 73 67.5t114 28.5q121 0 216-68.5t147-188.5 52-270q0-114-59.5-214T1180 449t-255-63q-105 0-196 29t-154.5 77-109 110.5-67 129.5T377 866q0 104 40 183t117 111q30 12 38-20 2-7 8-31t8-30q6-23-11-43-51-61-51-151 0-151 104.5-259.5T904 517q151 0 235.5 82t84.5 213q0 170-68.5 289T980 1220q-61 0-98-43.5T859 1072q8-35 26.5-93.5t30-103T927 800q0-50-27-83t-77-33q-62 0-105 57t-43 142q0 73 25 122l-99 418q-17 70-13 177-206-91-333-281T128 896q0-209 103-385.5T510.5 231 896 128t385.5 103T1561 510.5 1664 896z"></path>
|
|
164
164
|
</symbol>
|
|
165
165
|
</defs>
|
|
166
|
-
</svg>`;const Wu=pr?10009:fr?461:8,Ji={codes:{play:415,pause:19,ff:417,rw:412,back:Wu},names:{415:"play",19:"pause",417:"ff",412:"rw",[Wu]:"back"},isEventKey(i,e){return e=e.toLowerCase(),!!(this.names[i.keyCode]&&this.names[i.keyCode]===e)},getEventName(i){if(this.names[i.keyCode])return this.names[i.keyCode];if(this.codes[i.code]){const e=this.codes[i.code];return this.names[e]}return null}},Gu=5;class Tb extends St{constructor(e){super(),this.player_=e,this.focusableComponents=[],this.isListening_=!1,this.isPaused_=!1,this.onKeyDown_=this.onKeyDown_.bind(this),this.lastFocusedComponent_=null}start(){this.isListening_||(this.player_.on("keydown",this.onKeyDown_),this.player_.on("modalKeydown",this.onKeyDown_),this.player_.on("loadedmetadata",()=>{this.focus(this.updateFocusableComponents()[0])}),this.player_.on("modalclose",()=>{this.refocusComponent()}),this.player_.on("focusin",this.handlePlayerFocus_.bind(this)),this.player_.on("focusout",this.handlePlayerBlur_.bind(this)),this.isListening_=!0,this.player_.errorDisplay&&this.player_.errorDisplay.on("aftermodalfill",()=>{this.updateFocusableComponents(),this.focusableComponents.length&&(this.focusableComponents.length>1?this.focusableComponents[1].focus():this.focusableComponents[0].focus())}))}stop(){this.player_.off("keydown",this.onKeyDown_),this.isListening_=!1}onKeyDown_(e){const t=e.originalEvent?e.originalEvent:e;if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key)){if(this.isPaused_)return;t.preventDefault();const n=t.key.substring(5).toLowerCase();this.move(n)}else if(Ji.isEventKey(t,"play")||Ji.isEventKey(t,"pause")||Ji.isEventKey(t,"ff")||Ji.isEventKey(t,"rw")){t.preventDefault();const n=Ji.getEventName(t);this.performMediaAction_(n)}else Ji.isEventKey(t,"Back")&&e.target&&typeof e.target.closeable=="function"&&e.target.closeable()&&(t.preventDefault(),e.target.close())}performMediaAction_(e){if(this.player_)switch(e){case"play":this.player_.paused()&&this.player_.play();break;case"pause":this.player_.paused()||this.player_.pause();break;case"ff":this.userSeek_(this.player_.currentTime()+Gu);break;case"rw":this.userSeek_(this.player_.currentTime()-Gu);break}}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}pause(){this.isPaused_=!0}resume(){this.isPaused_=!1}handlePlayerBlur_(e){const t=e.relatedTarget;let n=null;const s=this.getCurrentComponent(e.target);t&&(n=!!t.closest(".video-js"),t.classList.contains("vjs-text-track-settings")&&!this.isPaused_&&this.searchForTrackSelect_()),(!e.currentTarget.contains(e.relatedTarget)&&!n||!t)&&(s&&s.name()==="CloseButton"?this.refocusComponent():(this.pause(),s&&s.el()&&(this.lastFocusedComponent_=s)))}handlePlayerFocus_(){this.getCurrentComponent()&&this.getCurrentComponent().getIsFocusable()&&this.resume()}updateFocusableComponents(){const e=this.player_,t=[];function n(s){for(const r of s)r.hasOwnProperty("el_")&&r.getIsFocusable()&&r.getIsAvailableToBeFocused(r.el())&&t.push(r),r.hasOwnProperty("children_")&&r.children_.length>0&&n(r.children_)}return e.children_.forEach(s=>{if(s.hasOwnProperty("el_"))if(s.getIsFocusable&&s.getIsAvailableToBeFocused&&s.getIsFocusable()&&s.getIsAvailableToBeFocused(s.el())){t.push(s);return}else s.hasOwnProperty("children_")&&s.children_.length>0?n(s.children_):s.hasOwnProperty("items")&&s.items.length>0?n(s.items):this.findSuitableDOMChild(s)&&t.push(s);if(s.name_==="ErrorDisplay"&&s.opened_){const r=s.el_.querySelector(".vjs-errors-ok-button-container");r&&r.querySelectorAll("button").forEach((a,l)=>{t.push({name:()=>"ModalButton"+(l+1),el:()=>a,getPositions:()=>{const c=a.getBoundingClientRect(),g={x:c.x,y:c.y,width:c.width,height:c.height,top:c.top,right:c.right,bottom:c.bottom,left:c.left},m={x:c.left+c.width/2,y:c.top+c.height/2,width:0,height:0,top:c.top+c.height/2,right:c.left+c.width/2,bottom:c.top+c.height/2,left:c.left+c.width/2};return{boundingClientRect:g,center:m}},getIsAvailableToBeFocused:()=>!0,getIsFocusable:c=>!0,focus:()=>a.focus()})})}}),this.focusableComponents=t,this.focusableComponents}findSuitableDOMChild(e){function t(n){if(e.getIsFocusable(n)&&e.getIsAvailableToBeFocused(n))return n;for(let s=0;s<n.children.length;s++){const r=n.children[s],a=t(r);if(a)return a}return null}return e.el()?t(e.el()):null}getCurrentComponent(e){this.updateFocusableComponents();const t=e||document.activeElement;if(this.focusableComponents.length){for(const n of this.focusableComponents)if(n.el()===t)return n}}add(e){const t=[...this.focusableComponents];e.hasOwnProperty("el_")&&e.getIsFocusable()&&e.getIsAvailableToBeFocused(e.el())&&t.push(e),this.focusableComponents=t,this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents})}remove(e){for(let t=0;t<this.focusableComponents.length;t++)if(this.focusableComponents[t].name()===e.name()){this.focusableComponents.splice(t,1),this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents});return}}clear(){this.focusableComponents.length>0&&(this.focusableComponents=[],this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents}))}move(e){const t=this.getCurrentComponent();if(!t)return;const n=t.getPositions(),s=this.focusableComponents.filter(a=>a!==t&&this.isInDirection_(n.boundingClientRect,a.getPositions().boundingClientRect,e)),r=this.findBestCandidate_(n.center,s,e);r?this.focus(r):this.trigger({type:"endOfFocusableComponents",direction:e,focusedComponent:t})}findBestCandidate_(e,t,n){let s=1/0,r=null;for(const a of t){const l=a.getPositions().center,c=this.calculateDistance_(e,l,n);c<s&&(s=c,r=a)}return r}isInDirection_(e,t,n){switch(n){case"right":return t.left>=e.right;case"left":return t.right<=e.left;case"down":return t.top>=e.bottom;case"up":return t.bottom<=e.top;default:return!1}}refocusComponent(){if(this.lastFocusedComponent_){this.player_.userActive()||this.player_.userActive(!0),this.updateFocusableComponents();for(let e=0;e<this.focusableComponents.length;e++)if(this.focusableComponents[e].name()===this.lastFocusedComponent_.name()){this.focus(this.focusableComponents[e]);return}}else this.focus(this.updateFocusableComponents()[0])}focus(e){typeof e=="object"&&(e.getIsAvailableToBeFocused(e.el())?e.focus():this.findSuitableDOMChild(e)&&this.findSuitableDOMChild(e).focus())}calculateDistance_(e,t,n){const s=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y);let a;switch(n){case"right":case"left":a=s+r*100;break;case"up":a=r*2+s*.5;break;case"down":a=r*5+s;break;default:a=s+r}return a}searchForTrackSelect_(){const e=this;for(const t of e.updateFocusableComponents())if(t.constructor.name==="TextTrackSelect"){e.focus(t);break}}}class vb extends H{constructor(e,t,n){const s=ve({createEl:!1},t);if(super(e,s,n),!t.playerOptions.sources||t.playerOptions.sources.length===0)for(let r=0,a=t.playerOptions.techOrder;r<a.length;r++){const l=Ne(a[r]);let c=ae.getTech(l);if(l||(c=H.getComponent(l)),c&&c.isSupported()){e.loadTech_(l);break}}else e.src(t.playerOptions.sources)}}H.registerComponent("MediaLoader",vb);class Jr extends H{constructor(e,t){super(e,t),this.options_.controlText&&this.controlText(this.options_.controlText),this.handleMouseOver_=n=>this.handleMouseOver(n),this.handleMouseOut_=n=>this.handleMouseOut(n),this.handleClick_=n=>this.handleClick(n),this.handleKeyDown_=n=>this.handleKeyDown(n),this.emitTapEvents(),this.enable()}createEl(e="div",t={},n={}){t=Object.assign({className:this.buildCSSClass(),tabIndex:0},t),e==="button"&&le.error(`Creating a ClickableComponent with an HTML element of ${e} is not supported; use a Button instead.`),n=Object.assign({role:"button"},n),this.tabIndex_=t.tabIndex;const s=ne(e,t,n);return this.player_.options_.experimentalSvgIcons||s.appendChild(ne("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(s),s}dispose(){this.controlTextEl_=null,super.dispose()}createControlTextEl(e){return this.controlTextEl_=ne("span",{className:"vjs-control-text"},{"aria-live":"polite"}),e&&e.appendChild(this.controlTextEl_),this.controlText(this.controlText_,e),this.controlTextEl_}controlText(e,t=this.el()){if(e===void 0)return this.controlText_||"Need Text";const n=this.localize(e);this.controlText_=e,Si(this.controlTextEl_,n),!this.nonIconControl&&!this.player_.options_.noUITitleAttributes&&t.setAttribute("title",n)}buildCSSClass(){return`vjs-control vjs-button ${super.buildCSSClass()}`}enable(){this.enabled_||(this.enabled_=!0,this.removeClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","false"),typeof this.tabIndex_<"u"&&this.el_.setAttribute("tabIndex",this.tabIndex_),this.on(["tap","click"],this.handleClick_),this.on("keydown",this.handleKeyDown_))}disable(){this.enabled_=!1,this.addClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","true"),typeof this.tabIndex_<"u"&&this.el_.removeAttribute("tabIndex"),this.off("mouseover",this.handleMouseOver_),this.off("mouseout",this.handleMouseOut_),this.off(["tap","click"],this.handleClick_),this.off("keydown",this.handleKeyDown_)}handleLanguagechange(){this.controlText(this.controlText_)}handleClick(e){this.options_.clickHandler&&this.options_.clickHandler.call(this,arguments)}handleKeyDown(e){e.key===" "||e.key==="Enter"?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}}H.registerComponent("ClickableComponent",Jr);class so extends Jr{constructor(e,t){super(e,t),this.update(),this.update_=n=>this.update(n),e.on("posterchange",this.update_)}dispose(){this.player().off("posterchange",this.update_),super.dispose()}createEl(){return ne("div",{className:"vjs-poster"})}crossOrigin(e){if(typeof e>"u")return this.$("img")?this.$("img").crossOrigin:this.player_.tech_&&this.player_.tech_.isReady_?this.player_.crossOrigin():this.player_.options_.crossOrigin||this.player_.options_.crossorigin||null;if(e!==null&&e!=="anonymous"&&e!=="use-credentials"){this.player_.log.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`);return}this.$("img")&&(this.$("img").crossOrigin=e)}update(e){const t=this.player().poster();this.setSrc(t),t?this.show():this.hide()}setSrc(e){if(!e){this.el_.textContent="";return}this.$("img")||this.el_.appendChild(ne("picture",{className:"vjs-poster",tabIndex:-1},{},ne("img",{loading:"lazy",crossOrigin:this.crossOrigin()},{alt:""}))),this.$("img").src=e}handleClick(e){this.player_.controls()&&(this.player_.tech(!0)&&this.player_.tech(!0).focus(),this.player_.paused()?Gt(this.player_.play()):this.player_.pause())}}so.prototype.crossorigin=so.prototype.crossOrigin;H.registerComponent("PosterImage",so);const Ct="#222",Xu="#ccc",Sb={monospace:"monospace",sansSerif:"sans-serif",serif:"serif",monospaceSansSerif:'"Andale Mono", "Lucida Console", monospace',monospaceSerif:'"Courier New", monospace',proportionalSansSerif:"sans-serif",proportionalSerif:"serif",casual:'"Comic Sans MS", Impact, fantasy',script:'"Monotype Corsiva", cursive',smallcaps:'"Andale Mono", "Lucida Console", monospace, sans-serif'};function Na(i,e){let t;if(i.length===4)t=i[1]+i[1]+i[2]+i[2]+i[3]+i[3];else if(i.length===7)t=i.slice(1);else throw new Error("Invalid color code provided, "+i+"; must be formatted as e.g. #f0e or #f604e2.");return"rgba("+parseInt(t.slice(0,2),16)+","+parseInt(t.slice(2,4),16)+","+parseInt(t.slice(4,6),16)+","+e+")"}function Vt(i,e,t){try{i.style[e]=t}catch{return}}function Ku(i){return i?`${i}px`:""}class Eb extends H{constructor(e,t,n){super(e,t,n);const s=a=>this.updateDisplay(a),r=a=>{this.updateDisplayOverlay(),this.updateDisplay(a)};e.on("loadstart",a=>this.toggleDisplay(a)),e.on("texttrackchange",s),e.on("loadedmetadata",a=>{this.updateDisplayOverlay(),this.preselectTrack(a)}),e.ready(Ce(this,function(){if(e.tech_&&e.tech_.featuresNativeTextTracks){this.hide();return}e.on("fullscreenchange",r),e.on("playerresize",r);const a=x.screen.orientation||x,l=x.screen.orientation?"change":"orientationchange";a.addEventListener(l,r),e.on("dispose",()=>a.removeEventListener(l,r));const c=this.options_.playerOptions.tracks||[];for(let g=0;g<c.length;g++)this.player_.addRemoteTextTrack(c[g],!0);this.preselectTrack()}))}preselectTrack(){const e={captions:1,subtitles:1},t=this.player_.textTracks(),n=this.player_.cache_.selectedLanguage;let s,r,a;for(let l=0;l<t.length;l++){const c=t[l];n&&n.enabled&&n.language&&n.language===c.language&&c.kind in e?c.kind===n.kind?a=c:a||(a=c):n&&!n.enabled?(a=null,s=null,r=null):c.default&&(c.kind==="descriptions"&&!s?s=c:c.kind in e&&!r&&(r=c))}a?a.mode="showing":r?r.mode="showing":s&&(s.mode="showing")}toggleDisplay(){this.player_.tech_&&this.player_.tech_.featuresNativeTextTracks?this.hide():this.show()}createEl(){return super.createEl("div",{className:"vjs-text-track-display"},{translate:"yes","aria-live":"off","aria-atomic":"true"})}clearDisplay(){typeof x.WebVTT=="function"&&x.WebVTT.processCues(x,[],this.el_)}updateDisplay(){const e=this.player_.textTracks(),t=this.options_.allowMultipleShowingTracks;if(this.clearDisplay(),t){const a=[];for(let l=0;l<e.length;++l){const c=e[l];c.mode==="showing"&&a.push(c)}this.updateForTrack(a);return}let n=null,s=null,r=e.length;for(;r--;){const a=e[r];a.mode==="showing"&&(a.kind==="descriptions"?n=a:s=a)}if(s?(this.getAttribute("aria-live")!=="off"&&this.setAttribute("aria-live","off"),this.updateForTrack(s)):n&&(this.getAttribute("aria-live")!=="assertive"&&this.setAttribute("aria-live","assertive"),this.updateForTrack(n)),!x.CSS.supports("inset","10px")){const a=this.el_,l=a.querySelectorAll(".vjs-text-track-cue"),c=this.player_.controlBar.el_.getBoundingClientRect().height,g=this.player_.el_.getBoundingClientRect().height;a.style="",Vt(a,"position","relative"),Vt(a,"height",g-c+"px"),Vt(a,"top","unset"),gr?Vt(a,"bottom",g+"px"):Vt(a,"bottom","0px"),l.length>0&&l.forEach(m=>{if(m.style.inset){const b=m.style.inset.split(" ");b.length===3&&Object.assign(m.style,{top:b[0],right:b[1],bottom:b[2],left:"unset"})}})}}updateDisplayOverlay(){if(!this.player_.videoHeight()||!x.CSS.supports("inset-inline: 10px"))return;const e=this.player_.currentWidth(),t=this.player_.currentHeight(),n=e/t,s=this.player_.videoWidth()/this.player_.videoHeight();let r=0,a=0;Math.abs(n-s)>.1&&(n>s?r=Math.round((e-t*s)/2):a=Math.round((t-e/s)/2)),Vt(this.el_,"insetInline",Ku(r)),Vt(this.el_,"insetBlock",Ku(a))}updateDisplayState(e){const t=this.player_.textTrackSettings.getValues(),n=e.activeCues;let s=n.length;for(;s--;){const r=n[s];if(!r)continue;const a=r.displayState;if(t.color&&(a.firstChild.style.color=t.color),t.textOpacity&&Vt(a.firstChild,"color",Na(t.color||"#fff",t.textOpacity)),t.backgroundColor&&(a.firstChild.style.backgroundColor=t.backgroundColor),t.backgroundOpacity&&Vt(a.firstChild,"backgroundColor",Na(t.backgroundColor||"#000",t.backgroundOpacity)),t.windowColor&&(t.windowOpacity?Vt(a,"backgroundColor",Na(t.windowColor,t.windowOpacity)):a.style.backgroundColor=t.windowColor),t.edgeStyle&&(t.edgeStyle==="dropshadow"?a.firstChild.style.textShadow=`2px 2px 3px ${Ct}, 2px 2px 4px ${Ct}, 2px 2px 5px ${Ct}`:t.edgeStyle==="raised"?a.firstChild.style.textShadow=`1px 1px ${Ct}, 2px 2px ${Ct}, 3px 3px ${Ct}`:t.edgeStyle==="depressed"?a.firstChild.style.textShadow=`1px 1px ${Xu}, 0 1px ${Xu}, -1px -1px ${Ct}, 0 -1px ${Ct}`:t.edgeStyle==="uniform"&&(a.firstChild.style.textShadow=`0 0 4px ${Ct}, 0 0 4px ${Ct}, 0 0 4px ${Ct}, 0 0 4px ${Ct}`)),t.fontPercent&&t.fontPercent!==1){const l=x.parseFloat(a.style.fontSize);a.style.fontSize=l*t.fontPercent+"px",a.style.height="auto",a.style.top="auto"}t.fontFamily&&t.fontFamily!=="default"&&(t.fontFamily==="small-caps"?a.firstChild.style.fontVariant="small-caps":a.firstChild.style.fontFamily=Sb[t.fontFamily])}}updateForTrack(e){if(Array.isArray(e)||(e=[e]),typeof x.WebVTT!="function"||e.every(n=>!n.activeCues))return;const t=[];for(let n=0;n<e.length;++n){const s=e[n];for(let r=0;r<s.activeCues.length;++r)t.push(s.activeCues[r])}x.WebVTT.processCues(x,t,this.el_);for(let n=0;n<e.length;++n){const s=e[n];for(let r=0;r<s.activeCues.length;++r){const a=s.activeCues[r].displayState;Bi(a,"vjs-text-track-cue","vjs-text-track-cue-"+(s.language?s.language:n)),s.language&&yn(a,"lang",s.language)}this.player_.textTrackSettings&&this.updateDisplayState(s)}}}H.registerComponent("TextTrackDisplay",Eb);class wb extends H{createEl(){const e=this.player_.isAudio(),t=this.localize(e?"Audio Player":"Video Player"),n=ne("span",{className:"vjs-control-text",textContent:this.localize("{1} is loading.",[t])}),s=super.createEl("div",{className:"vjs-loading-spinner",dir:"ltr"});return s.appendChild(n),s}handleLanguagechange(){this.$(".vjs-control-text").textContent=this.localize("{1} is loading.",[this.player_.isAudio()?"Audio Player":"Video Player"])}}H.registerComponent("LoadingSpinner",wb);class et extends Jr{createEl(e,t={},n={}){e="button",t=Object.assign({className:this.buildCSSClass()},t),n=Object.assign({type:"button"},n);const s=ne(e,t,n);return this.player_.options_.experimentalSvgIcons||s.appendChild(ne("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(s),s}addChild(e,t={}){const n=this.constructor.name;return le.warn(`Adding an actionable (user controllable) child to a Button (${n}) is not supported; use a ClickableComponent instead.`),H.prototype.addChild.call(this,e,t)}enable(){super.enable(),this.el_.removeAttribute("disabled")}disable(){super.disable(),this.el_.setAttribute("disabled","disabled")}handleKeyDown(e){if(e.key===" "||e.key==="Enter"){e.stopPropagation();return}super.handleKeyDown(e)}}H.registerComponent("Button",et);class hc extends et{constructor(e,t){super(e,t),this.mouseused_=!1,this.setIcon("play"),this.on("mousedown",n=>this.handleMouseDown(n))}buildCSSClass(){return"vjs-big-play-button"}handleClick(e){const t=this.player_.play();if(this.mouseused_&&"clientX"in e&&"clientY"in e){Gt(t),this.player_.tech(!0)&&this.player_.tech(!0).focus();return}const n=this.player_.getChild("controlBar"),s=n&&n.getChild("playToggle");if(!s){this.player_.tech(!0).focus();return}const r=()=>s.focus();ls(t)?t.then(r,()=>{}):this.setTimeout(r,1)}handleKeyDown(e){this.mouseused_=!1,super.handleKeyDown(e)}handleMouseDown(e){this.mouseused_=!0}}hc.prototype.controlText_="Play Video";H.registerComponent("BigPlayButton",hc);class kb extends et{constructor(e,t){super(e,t),this.setIcon("cancel"),this.controlText(t&&t.controlText||this.localize("Close"))}buildCSSClass(){return`vjs-close-button ${super.buildCSSClass()}`}handleClick(e){this.trigger({type:"close",bubbles:!1})}handleKeyDown(e){e.key==="Escape"?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}}H.registerComponent("CloseButton",kb);class cc extends et{constructor(e,t={}){super(e,t),t.replay=t.replay===void 0||t.replay,this.setIcon("play"),this.on(e,"play",n=>this.handlePlay(n)),this.on(e,"pause",n=>this.handlePause(n)),t.replay&&this.on(e,"ended",n=>this.handleEnded(n))}buildCSSClass(){return`vjs-play-control ${super.buildCSSClass()}`}handleClick(e){this.player_.paused()?Gt(this.player_.play()):this.player_.pause()}handleSeeked(e){this.removeClass("vjs-ended"),this.player_.paused()?this.handlePause(e):this.handlePlay(e)}handlePlay(e){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.setIcon("pause"),this.controlText("Pause")}handlePause(e){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.setIcon("play"),this.controlText("Play")}handleEnded(e){this.removeClass("vjs-playing"),this.addClass("vjs-ended"),this.setIcon("replay"),this.controlText("Replay"),this.one(this.player_,"seeked",t=>this.handleSeeked(t))}}cc.prototype.controlText_="Play";H.registerComponent("PlayToggle",cc);class In extends H{constructor(e,t){super(e,t),this.on(e,["timeupdate","ended","seeking"],n=>this.update(n)),this.updateTextNode_()}createEl(){const e=this.buildCSSClass(),t=super.createEl("div",{className:`${e} vjs-time-control vjs-control`}),n=ne("span",{className:"vjs-control-text",textContent:`${this.localize(this.labelText_)} `},{role:"presentation"});return t.appendChild(n),this.contentEl_=ne("span",{className:`${e}-display`},{role:"presentation"}),t.appendChild(this.contentEl_),t}dispose(){this.contentEl_=null,this.textNode_=null,super.dispose()}update(e){!this.player_.options_.enableSmoothSeeking&&e.type==="seeking"||this.updateContent(e)}updateTextNode_(e=0){e=qi(e),this.formattedTime_!==e&&(this.formattedTime_=e,this.requestNamedAnimationFrame("TimeDisplay#updateTextNode_",()=>{if(!this.contentEl_)return;let t=this.textNode_;t&&this.contentEl_.firstChild!==t&&(t=null,le.warn("TimeDisplay#updateTextnode_: Prevented replacement of text node element since it was no longer a child of this node. Appending a new node instead.")),this.textNode_=G.createTextNode(this.formattedTime_),this.textNode_&&(t?this.contentEl_.replaceChild(this.textNode_,t):this.contentEl_.appendChild(this.textNode_))}))}updateContent(e){}}In.prototype.labelText_="Time";In.prototype.controlText_="Time";H.registerComponent("TimeDisplay",In);class Ko extends In{buildCSSClass(){return"vjs-current-time"}updateContent(e){let t;this.player_.ended()?t=this.player_.duration():t=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime(),this.updateTextNode_(t)}}Ko.prototype.labelText_="Current Time";Ko.prototype.controlText_="Current Time";H.registerComponent("CurrentTimeDisplay",Ko);let Yo=class extends In{constructor(e,t){super(e,t);const n=s=>this.updateContent(s);this.on(e,"durationchange",n),this.on(e,"loadstart",n),this.on(e,"loadedmetadata",n)}buildCSSClass(){return"vjs-duration"}updateContent(e){const t=this.player_.duration();this.updateTextNode_(t)}};Yo.prototype.labelText_="Duration";Yo.prototype.controlText_="Duration";H.registerComponent("DurationDisplay",Yo);class Cb extends H{createEl(){const e=super.createEl("div",{className:"vjs-time-control vjs-time-divider"},{"aria-hidden":!0}),t=super.createEl("div"),n=super.createEl("span",{textContent:"/"});return t.appendChild(n),e.appendChild(t),e}}H.registerComponent("TimeDivider",Cb);class Qo extends In{constructor(e,t){super(e,t),this.on(e,"durationchange",n=>this.updateContent(n))}buildCSSClass(){return"vjs-remaining-time"}createEl(){const e=super.createEl();return this.options_.displayNegative!==!1&&e.insertBefore(ne("span",{},{"aria-hidden":!0},"-"),this.contentEl_),e}updateContent(e){if(typeof this.player_.duration()!="number")return;let t;this.player_.ended()?t=0:this.player_.remainingTimeDisplay?t=this.player_.remainingTimeDisplay():t=this.player_.remainingTime(),this.updateTextNode_(t)}}Qo.prototype.labelText_="Remaining Time";Qo.prototype.controlText_="Remaining Time";H.registerComponent("RemainingTimeDisplay",Qo);class Ib extends H{constructor(e,t){super(e,t),this.updateShowing(),this.on(this.player(),"durationchange",n=>this.updateShowing(n))}createEl(){const e=super.createEl("div",{className:"vjs-live-control vjs-control"});return this.contentEl_=ne("div",{className:"vjs-live-display"},{"aria-live":"off"}),this.contentEl_.appendChild(ne("span",{className:"vjs-control-text",textContent:`${this.localize("Stream Type")} `})),this.contentEl_.appendChild(G.createTextNode(this.localize("LIVE"))),e.appendChild(this.contentEl_),e}dispose(){this.contentEl_=null,super.dispose()}updateShowing(e){this.player().duration()===1/0?this.show():this.hide()}}H.registerComponent("LiveDisplay",Ib);class pc extends et{constructor(e,t){super(e,t),this.updateLiveEdgeStatus(),this.player_.liveTracker&&(this.updateLiveEdgeStatusHandler_=n=>this.updateLiveEdgeStatus(n),this.on(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_))}createEl(){const e=super.createEl("button",{className:"vjs-seek-to-live-control vjs-control"});return this.setIcon("circle",e),this.textEl_=ne("span",{className:"vjs-seek-to-live-text",textContent:this.localize("LIVE")},{"aria-hidden":"true"}),e.appendChild(this.textEl_),e}updateLiveEdgeStatus(){!this.player_.liveTracker||this.player_.liveTracker.atLiveEdge()?(this.setAttribute("aria-disabled",!0),this.addClass("vjs-at-live-edge"),this.controlText("Seek to live, currently playing live")):(this.setAttribute("aria-disabled",!1),this.removeClass("vjs-at-live-edge"),this.controlText("Seek to live, currently behind live"))}handleClick(){this.player_.liveTracker.seekToLiveEdge()}dispose(){this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_),this.textEl_=null,super.dispose()}}pc.prototype.controlText_="Seek to live, currently playing live";H.registerComponent("SeekToLive",pc);function _s(i,e,t){return i=Number(i),Math.min(t,Math.max(e,isNaN(i)?e:i))}var xb=Object.freeze({__proto__:null,clamp:_s});class Jo extends H{constructor(e,t){super(e,t),this.handleMouseDown_=n=>this.handleMouseDown(n),this.handleMouseUp_=n=>this.handleMouseUp(n),this.handleKeyDown_=n=>this.handleKeyDown(n),this.handleClick_=n=>this.handleClick(n),this.handleMouseMove_=n=>this.handleMouseMove(n),this.update_=n=>this.update(n),this.bar=this.getChild(this.options_.barName),this.vertical(!!this.options_.vertical),this.enable()}enabled(){return this.enabled_}enable(){this.enabled()||(this.on("mousedown",this.handleMouseDown_),this.on("touchstart",this.handleMouseDown_),this.on("keydown",this.handleKeyDown_),this.on("click",this.handleClick_),this.on(this.player_,"controlsvisible",this.update),this.playerEvent&&this.on(this.player_,this.playerEvent,this.update),this.removeClass("disabled"),this.setAttribute("tabindex",0),this.enabled_=!0)}disable(){if(!this.enabled())return;const e=this.bar.el_.ownerDocument;this.off("mousedown",this.handleMouseDown_),this.off("touchstart",this.handleMouseDown_),this.off("keydown",this.handleKeyDown_),this.off("click",this.handleClick_),this.off(this.player_,"controlsvisible",this.update_),this.off(e,"mousemove",this.handleMouseMove_),this.off(e,"mouseup",this.handleMouseUp_),this.off(e,"touchmove",this.handleMouseMove_),this.off(e,"touchend",this.handleMouseUp_),this.removeAttribute("tabindex"),this.addClass("disabled"),this.playerEvent&&this.off(this.player_,this.playerEvent,this.update),this.enabled_=!1}createEl(e,t={},n={}){return t.className=t.className+" vjs-slider",t=Object.assign({tabIndex:0},t),n=Object.assign({role:"slider","aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100},n),super.createEl(e,t,n)}handleMouseDown(e){const t=this.bar.el_.ownerDocument;e.type==="mousedown"&&e.preventDefault(),e.type==="touchstart"&&!Jt&&e.preventDefault(),jh(),this.addClass("vjs-sliding"),this.trigger("slideractive"),this.on(t,"mousemove",this.handleMouseMove_),this.on(t,"mouseup",this.handleMouseUp_),this.on(t,"touchmove",this.handleMouseMove_),this.on(t,"touchend",this.handleMouseUp_),this.handleMouseMove(e,!0)}handleMouseMove(e){}handleMouseUp(e){const t=this.bar.el_.ownerDocument;$h(),this.removeClass("vjs-sliding"),this.trigger("sliderinactive"),this.off(t,"mousemove",this.handleMouseMove_),this.off(t,"mouseup",this.handleMouseUp_),this.off(t,"touchmove",this.handleMouseMove_),this.off(t,"touchend",this.handleMouseUp_),this.update()}update(){if(!this.el_||!this.bar)return;const e=this.getProgress();return e===this.progress_||(this.progress_=e,this.requestNamedAnimationFrame("Slider#update",()=>{const t=this.vertical()?"height":"width";this.bar.el().style[t]=(e*100).toFixed(2)+"%"})),e}getProgress(){return Number(_s(this.getPercent(),0,1).toFixed(4))}calculateDistance(e){const t=Wr(this.el_,e);return this.vertical()?t.y:t.x}handleKeyDown(e){const t=this.options_.playerOptions.spatialNavigation,n=t&&t.enabled,s=t&&t.horizontalSeek;n?s&&e.key==="ArrowLeft"||!s&&e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepBack()):s&&e.key==="ArrowRight"||!s&&e.key==="ArrowUp"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):super.handleKeyDown(e):e.key==="ArrowLeft"||e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepBack()):e.key==="ArrowUp"||e.key==="ArrowRight"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):super.handleKeyDown(e)}handleClick(e){e.stopPropagation(),e.preventDefault()}vertical(e){if(e===void 0)return this.vertical_||!1;this.vertical_=!!e,this.vertical_?this.addClass("vjs-slider-vertical"):this.addClass("vjs-slider-horizontal")}}H.registerComponent("Slider",Jo);const Ba=(i,e)=>_s(i/e*100,0,100).toFixed(2)+"%";class Ab extends H{constructor(e,t){super(e,t),this.partEls_=[],this.on(e,"progress",n=>this.update(n))}createEl(){const e=super.createEl("div",{className:"vjs-load-progress"}),t=ne("span",{className:"vjs-control-text"}),n=ne("span",{textContent:this.localize("Loaded")}),s=G.createTextNode(": ");return this.percentageEl_=ne("span",{className:"vjs-control-text-loaded-percentage",textContent:"0%"}),e.appendChild(t),t.appendChild(n),t.appendChild(s),t.appendChild(this.percentageEl_),e}dispose(){this.partEls_=null,this.percentageEl_=null,super.dispose()}update(e){this.requestNamedAnimationFrame("LoadProgressBar#update",()=>{const t=this.player_.liveTracker,n=this.player_.buffered(),s=t&&t.isLive()?t.seekableEnd():this.player_.duration(),r=this.player_.bufferedEnd(),a=this.partEls_,l=Ba(r,s);this.percent_!==l&&(this.el_.style.width=l,Si(this.percentageEl_,l),this.percent_=l);for(let c=0;c<n.length;c++){const g=n.start(c),m=n.end(c);let b=a[c];b||(b=this.el_.appendChild(ne()),a[c]=b),!(b.dataset.start===g&&b.dataset.end===m)&&(b.dataset.start=g,b.dataset.end=m,b.style.left=Ba(g,r),b.style.width=Ba(m-g,r))}for(let c=a.length;c>n.length;c--)this.el_.removeChild(a[c-1]);a.length=n.length})}}H.registerComponent("LoadProgressBar",Ab);class Pb extends H{constructor(e,t){super(e,t),this.update=Zt(Ce(this,this.update),Pt)}createEl(){return super.createEl("div",{className:"vjs-time-tooltip"},{"aria-hidden":"true"})}update(e,t,n){const s=ps(this.el_),r=_n(this.player_.el()),a=e.width*t;if(!r||!s)return;let l=e.left-r.left+a,c=e.width-a+(r.right-e.right);c||(c=e.width-a,l=a);let g=s.width/2;l<g?g+=g-l:c<g&&(g=c),g<0?g=0:g>s.width&&(g=s.width),g=Math.round(g),this.el_.style.right=`-${g}px`,this.write(n)}write(e){Si(this.el_,e)}updateTime(e,t,n,s){this.requestNamedAnimationFrame("TimeTooltip#updateTime",()=>{let r;const a=this.player_.duration();if(this.player_.liveTracker&&this.player_.liveTracker.isLive()){const l=this.player_.liveTracker.liveWindow(),c=l-t*l;r=(c<1?"":"-")+qi(c,l)}else r=qi(n,a);this.update(e,t,r),s&&s()})}}H.registerComponent("TimeTooltip",Pb);class Zo extends H{constructor(e,t){super(e,t),this.setIcon("circle"),this.update=Zt(Ce(this,this.update),Pt)}createEl(){return super.createEl("div",{className:"vjs-play-progress vjs-slider-bar"},{"aria-hidden":"true"})}update(e,t){const n=this.getChild("timeTooltip");if(!n)return;const s=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();n.updateTime(e,t,s)}}Zo.prototype.options_={children:[]};!Je&&!Nt&&Zo.prototype.options_.children.push("timeTooltip");H.registerComponent("PlayProgressBar",Zo);class fc extends H{constructor(e,t){super(e,t),this.update=Zt(Ce(this,this.update),Pt)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t){const n=t*this.player_.duration();this.getChild("timeTooltip").updateTime(e,t,n,()=>{this.el_.style.left=`${e.width*t}px`})}}fc.prototype.options_={children:["timeTooltip"]};H.registerComponent("MouseTimeDisplay",fc);const Js=5,Yu=12;class Zr extends Jo{constructor(e,t){t=ve(Zr.prototype.options_,t),t.children=[...t.children];const n=e.options_.disableSeekWhileScrubbingOnMobile&&(Je||Nt);(!Je&&!Nt||n)&&t.children.splice(1,0,"mouseTimeDisplay"),super(e,t),this.shouldDisableSeekWhileScrubbingOnMobile_=n,this.pendingSeekTime_=null,this.setEventHandlers_()}setEventHandlers_(){this.update_=Ce(this,this.update),this.update=Zt(this.update_,Pt),this.on(this.player_,["durationchange","timeupdate"],this.update),this.on(this.player_,["ended"],this.update_),this.player_.liveTracker&&this.on(this.player_.liveTracker,"liveedgechange",this.update),this.updateInterval=null,this.enableIntervalHandler_=e=>this.enableInterval_(e),this.disableIntervalHandler_=e=>this.disableInterval_(e),this.on(this.player_,["playing"],this.enableIntervalHandler_),this.on(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in G&&"visibilityState"in G&&this.on(G,"visibilitychange",this.toggleVisibility_)}toggleVisibility_(e){G.visibilityState==="hidden"?(this.cancelNamedAnimationFrame("SeekBar#update"),this.cancelNamedAnimationFrame("Slider#update"),this.disableInterval_(e)):(!this.player_.ended()&&!this.player_.paused()&&this.enableInterval_(),this.update())}enableInterval_(){this.updateInterval||(this.updateInterval=this.setInterval(this.update,Pt))}disableInterval_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&e&&e.type!=="ended"||this.updateInterval&&(this.clearInterval(this.updateInterval),this.updateInterval=null)}createEl(){return super.createEl("div",{className:"vjs-progress-holder"},{"aria-label":this.localize("Progress Bar")})}update(e){if(G.visibilityState==="hidden")return;const t=super.update();return this.requestNamedAnimationFrame("SeekBar#update",()=>{const n=this.player_.ended()?this.player_.duration():this.getCurrentTime_(),s=this.player_.liveTracker;let r=this.player_.duration();s&&s.isLive()&&(r=this.player_.liveTracker.liveCurrentTime()),this.percent_!==t&&(this.el_.setAttribute("aria-valuenow",(t*100).toFixed(2)),this.percent_=t),(this.currentTime_!==n||this.duration_!==r)&&(this.el_.setAttribute("aria-valuetext",this.localize("progress bar timing: currentTime={1} duration={2}",[qi(n,r),qi(r,r)],"{1} of {2}")),this.currentTime_=n,this.duration_=r),this.bar&&this.bar.update(_n(this.el()),this.getProgress())}),t}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}getCurrentTime_(){return this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime()}getPercent(){if(this.pendingSeekTime_)return this.pendingSeekTime_/this.player_.duration();const e=this.getCurrentTime_();let t;const n=this.player_.liveTracker;return n&&n.isLive()?(t=(e-n.seekableStart())/n.liveWindow(),n.atLiveEdge()&&(t=1)):t=e/this.player_.duration(),t}handleMouseDown(e){fs(e)&&(e.stopPropagation(),this.videoWasPlaying=!this.player_.paused(),this.shouldDisableSeekWhileScrubbingOnMobile_||this.player_.pause(),super.handleMouseDown(e))}handleMouseMove(e,t=!1){if(!fs(e)||isNaN(this.player_.duration()))return;!t&&!this.player_.scrubbing()&&this.player_.scrubbing(!0);let n;const s=this.calculateDistance(e),r=this.player_.liveTracker;if(!r||!r.isLive())n=s*this.player_.duration(),n===this.player_.duration()&&(n=n-.1);else{if(s>=.99){r.seekToLiveEdge();return}const a=r.seekableStart(),l=r.liveCurrentTime();if(n=a+s*r.liveWindow(),n>=l&&(n=l),n<=a&&(n=a+.1),n===1/0)return}this.shouldDisableSeekWhileScrubbingOnMobile_?this.pendingSeekTime_=n:this.userSeek_(n),this.player_.options_.enableSmoothSeeking&&this.update()}enable(){super.enable();const e=this.getChild("mouseTimeDisplay");e&&e.show()}disable(){super.disable();const e=this.getChild("mouseTimeDisplay");e&&e.hide()}handleMouseUp(e){super.handleMouseUp(e),e&&e.stopPropagation(),this.player_.scrubbing(!1),this.pendingSeekTime_&&(this.userSeek_(this.pendingSeekTime_),this.pendingSeekTime_=null),this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:!0}),this.videoWasPlaying?Gt(this.player_.play()):this.update_()}stepForward(){this.userSeek_(this.player_.currentTime()+Js)}stepBack(){this.userSeek_(this.player_.currentTime()-Js)}handleAction(e){this.player_.paused()?this.player_.play():this.player_.pause()}handleKeyDown(e){const t=this.player_.liveTracker;if(e.key===" "||e.key==="Enter")e.preventDefault(),e.stopPropagation(),this.handleAction(e);else if(e.key==="Home")e.preventDefault(),e.stopPropagation(),this.userSeek_(0);else if(e.key==="End")e.preventDefault(),e.stopPropagation(),t&&t.isLive()?this.userSeek_(t.liveCurrentTime()):this.userSeek_(this.player_.duration());else if(/^[0-9]$/.test(e.key)){e.preventDefault(),e.stopPropagation();const n=parseInt(e.key,10)*.1;t&&t.isLive()?this.userSeek_(t.seekableStart()+t.liveWindow()*n):this.userSeek_(this.player_.duration()*n)}else e.key==="PageDown"?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()-Js*Yu)):e.key==="PageUp"?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()+Js*Yu)):super.handleKeyDown(e)}dispose(){this.disableInterval_(),this.off(this.player_,["durationchange","timeupdate"],this.update),this.off(this.player_,["ended"],this.update_),this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.update),this.off(this.player_,["playing"],this.enableIntervalHandler_),this.off(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in G&&"visibilityState"in G&&this.off(G,"visibilitychange",this.toggleVisibility_),super.dispose()}}Zr.prototype.options_={children:["loadProgressBar","playProgressBar"],barName:"playProgressBar"};H.registerComponent("SeekBar",Zr);class gc extends H{constructor(e,t){super(e,t),this.handleMouseMove=Zt(Ce(this,this.handleMouseMove),Pt),this.throttledHandleMouseSeek=Zt(Ce(this,this.handleMouseSeek),Pt),this.handleMouseUpHandler_=n=>this.handleMouseUp(n),this.handleMouseDownHandler_=n=>this.handleMouseDown(n),this.enable()}createEl(){return super.createEl("div",{className:"vjs-progress-control vjs-control"})}handleMouseMove(e){const t=this.getChild("seekBar");if(!t)return;const n=t.getChild("playProgressBar"),s=t.getChild("mouseTimeDisplay");if(!n&&!s)return;const r=t.el(),a=ps(r);let l=Wr(r,e).x;l=_s(l,0,1),s&&s.update(a,l),n&&n.update(a,t.getProgress())}handleMouseSeek(e){const t=this.getChild("seekBar");t&&t.handleMouseMove(e)}enabled(){return this.enabled_}disable(){if(this.children().forEach(e=>e.disable&&e.disable()),!!this.enabled()&&(this.off(["mousedown","touchstart"],this.handleMouseDownHandler_),this.off(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeListenersAddedOnMousedownAndTouchstart(),this.addClass("disabled"),this.enabled_=!1,this.player_.scrubbing())){const e=this.getChild("seekBar");this.player_.scrubbing(!1),e.videoWasPlaying&&Gt(this.player_.play())}}enable(){this.children().forEach(e=>e.enable&&e.enable()),!this.enabled()&&(this.on(["mousedown","touchstart"],this.handleMouseDownHandler_),this.on(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeClass("disabled"),this.enabled_=!0)}removeListenersAddedOnMousedownAndTouchstart(){const e=this.el_.ownerDocument;this.off(e,"mousemove",this.throttledHandleMouseSeek),this.off(e,"touchmove",this.throttledHandleMouseSeek),this.off(e,"mouseup",this.handleMouseUpHandler_),this.off(e,"touchend",this.handleMouseUpHandler_)}handleMouseDown(e){const t=this.el_.ownerDocument,n=this.getChild("seekBar");n&&n.handleMouseDown(e),this.on(t,"mousemove",this.throttledHandleMouseSeek),this.on(t,"touchmove",this.throttledHandleMouseSeek),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const t=this.getChild("seekBar");t&&t.handleMouseUp(e),this.removeListenersAddedOnMousedownAndTouchstart()}}gc.prototype.options_={children:["seekBar"]};H.registerComponent("ProgressControl",gc);class mc extends et{constructor(e,t){super(e,t),this.setIcon("picture-in-picture-enter"),this.on(e,["enterpictureinpicture","leavepictureinpicture"],n=>this.handlePictureInPictureChange(n)),this.on(e,["disablepictureinpicturechanged","loadedmetadata"],n=>this.handlePictureInPictureEnabledChange(n)),this.on(e,["loadedmetadata","audioonlymodechange","audiopostermodechange"],()=>this.handlePictureInPictureAudioModeChange()),this.disable()}buildCSSClass(){return`vjs-picture-in-picture-control vjs-hidden ${super.buildCSSClass()}`}handlePictureInPictureAudioModeChange(){if(!(this.player_.currentType().substring(0,5)==="audio"||this.player_.audioPosterMode()||this.player_.audioOnlyMode())){this.show();return}this.player_.isInPictureInPicture()&&this.player_.exitPictureInPicture(),this.hide()}handlePictureInPictureEnabledChange(){G.pictureInPictureEnabled&&this.player_.disablePictureInPicture()===!1||this.player_.options_.enableDocumentPictureInPicture&&"documentPictureInPicture"in x?this.enable():this.disable()}handlePictureInPictureChange(e){this.player_.isInPictureInPicture()?(this.setIcon("picture-in-picture-exit"),this.controlText("Exit Picture-in-Picture")):(this.setIcon("picture-in-picture-enter"),this.controlText("Picture-in-Picture")),this.handlePictureInPictureEnabledChange()}handleClick(e){this.player_.isInPictureInPicture()?this.player_.exitPictureInPicture():this.player_.requestPictureInPicture()}show(){typeof G.exitPictureInPicture=="function"&&super.show()}}mc.prototype.controlText_="Picture-in-Picture";H.registerComponent("PictureInPictureToggle",mc);class yc extends et{constructor(e,t){super(e,t),this.setIcon("fullscreen-enter"),this.on(e,"fullscreenchange",n=>this.handleFullscreenChange(n)),G[e.fsApi_.fullscreenEnabled]===!1&&this.disable()}buildCSSClass(){return`vjs-fullscreen-control ${super.buildCSSClass()}`}handleFullscreenChange(e){this.player_.isFullscreen()?(this.controlText("Exit Fullscreen"),this.setIcon("fullscreen-exit")):(this.controlText("Fullscreen"),this.setIcon("fullscreen-enter"))}handleClick(e){this.player_.isFullscreen()?this.player_.exitFullscreen():this.player_.requestFullscreen()}}yc.prototype.controlText_="Fullscreen";H.registerComponent("FullscreenToggle",yc);const Lb=function(i,e){e.tech_&&!e.tech_.featuresVolumeControl&&i.addClass("vjs-hidden"),i.on(e,"loadstart",function(){e.tech_.featuresVolumeControl?i.removeClass("vjs-hidden"):i.addClass("vjs-hidden")})};class Db extends H{createEl(){const e=super.createEl("div",{className:"vjs-volume-level"});return this.setIcon("circle",e),e.appendChild(super.createEl("span",{className:"vjs-control-text"})),e}}H.registerComponent("VolumeLevel",Db);class Ob extends H{constructor(e,t){super(e,t),this.update=Zt(Ce(this,this.update),Pt)}createEl(){return super.createEl("div",{className:"vjs-volume-tooltip"},{"aria-hidden":"true"})}update(e,t,n,s){if(!n){const r=_n(this.el_),a=_n(this.player_.el()),l=e.width*t;if(!a||!r)return;const c=e.left-a.left+l,g=e.width-l+(a.right-e.right);let m=r.width/2;c<m?m+=m-c:g<m&&(m=g),m<0?m=0:m>r.width&&(m=r.width),this.el_.style.right=`-${m}px`}this.write(`${s}%`)}write(e){Si(this.el_,e)}updateVolume(e,t,n,s,r){this.requestNamedAnimationFrame("VolumeLevelTooltip#updateVolume",()=>{this.update(e,t,n,s.toFixed(0)),r&&r()})}}H.registerComponent("VolumeLevelTooltip",Ob);class _c extends H{constructor(e,t){super(e,t),this.update=Zt(Ce(this,this.update),Pt)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t,n){const s=100*t;this.getChild("volumeLevelTooltip").updateVolume(e,t,n,s,()=>{n?this.el_.style.bottom=`${e.height*t}px`:this.el_.style.left=`${e.width*t}px`})}}_c.prototype.options_={children:["volumeLevelTooltip"]};H.registerComponent("MouseVolumeLevelDisplay",_c);class ea extends Jo{constructor(e,t){super(e,t),this.on("slideractive",n=>this.updateLastVolume_(n)),this.on(e,"volumechange",n=>this.updateARIAAttributes(n)),e.ready(()=>this.updateARIAAttributes())}createEl(){return super.createEl("div",{className:"vjs-volume-bar vjs-slider-bar"},{"aria-label":this.localize("Volume Level"),"aria-live":"polite"})}handleMouseDown(e){fs(e)&&super.handleMouseDown(e)}handleMouseMove(e){const t=this.getChild("mouseVolumeLevelDisplay");if(t){const n=this.el(),s=_n(n),r=this.vertical();let a=Wr(n,e);a=r?a.y:a.x,a=_s(a,0,1),t.update(s,a,r)}fs(e)&&(this.checkMuted(),this.player_.volume(this.calculateDistance(e)))}checkMuted(){this.player_.muted()&&this.player_.muted(!1)}getPercent(){return this.player_.muted()?0:this.player_.volume()}stepForward(){this.checkMuted(),this.player_.volume(this.player_.volume()+.1)}stepBack(){this.checkMuted(),this.player_.volume(this.player_.volume()-.1)}updateARIAAttributes(e){const t=this.player_.muted()?0:this.volumeAsPercentage_();this.el_.setAttribute("aria-valuenow",t),this.el_.setAttribute("aria-valuetext",t+"%")}volumeAsPercentage_(){return Math.round(this.player_.volume()*100)}updateLastVolume_(){const e=this.player_.volume();this.one("sliderinactive",()=>{this.player_.volume()===0&&this.player_.lastVolume_(e)})}}ea.prototype.options_={children:["volumeLevel"],barName:"volumeLevel"};!Je&&!Nt&&ea.prototype.options_.children.splice(0,0,"mouseVolumeLevelDisplay");ea.prototype.playerEvent="volumechange";H.registerComponent("VolumeBar",ea);class bc extends H{constructor(e,t={}){t.vertical=t.vertical||!1,(typeof t.volumeBar>"u"||mn(t.volumeBar))&&(t.volumeBar=t.volumeBar||{},t.volumeBar.vertical=t.vertical),super(e,t),Lb(this,e),this.throttledHandleMouseMove=Zt(Ce(this,this.handleMouseMove),Pt),this.handleMouseUpHandler_=n=>this.handleMouseUp(n),this.on("mousedown",n=>this.handleMouseDown(n)),this.on("touchstart",n=>this.handleMouseDown(n)),this.on("mousemove",n=>this.handleMouseMove(n)),this.on(this.volumeBar,["focus","slideractive"],()=>{this.volumeBar.addClass("vjs-slider-active"),this.addClass("vjs-slider-active"),this.trigger("slideractive")}),this.on(this.volumeBar,["blur","sliderinactive"],()=>{this.volumeBar.removeClass("vjs-slider-active"),this.removeClass("vjs-slider-active"),this.trigger("sliderinactive")})}createEl(){let e="vjs-volume-horizontal";return this.options_.vertical&&(e="vjs-volume-vertical"),super.createEl("div",{className:`vjs-volume-control vjs-control ${e}`})}handleMouseDown(e){const t=this.el_.ownerDocument;this.on(t,"mousemove",this.throttledHandleMouseMove),this.on(t,"touchmove",this.throttledHandleMouseMove),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const t=this.el_.ownerDocument;this.off(t,"mousemove",this.throttledHandleMouseMove),this.off(t,"touchmove",this.throttledHandleMouseMove),this.off(t,"mouseup",this.handleMouseUpHandler_),this.off(t,"touchend",this.handleMouseUpHandler_)}handleMouseMove(e){this.volumeBar.handleMouseMove(e)}}bc.prototype.options_={children:["volumeBar"]};H.registerComponent("VolumeControl",bc);const Mb=function(i,e){e.tech_&&!e.tech_.featuresMuteControl&&i.addClass("vjs-hidden"),i.on(e,"loadstart",function(){e.tech_.featuresMuteControl?i.removeClass("vjs-hidden"):i.addClass("vjs-hidden")})};class Tc extends et{constructor(e,t){super(e,t),Mb(this,e),this.on(e,["loadstart","volumechange"],n=>this.update(n))}buildCSSClass(){return`vjs-mute-control ${super.buildCSSClass()}`}handleClick(e){const t=this.player_.volume(),n=this.player_.lastVolume_();if(t===0){const s=n<.1?.1:n;this.player_.volume(s),this.player_.muted(!1)}else this.player_.muted(!this.player_.muted())}update(e){this.updateIcon_(),this.updateControlText_()}updateIcon_(){const e=this.player_.volume();let t=3;this.setIcon("volume-high"),Je&&this.player_.tech_&&this.player_.tech_.el_&&this.player_.muted(this.player_.tech_.el_.muted),e===0||this.player_.muted()?(this.setIcon("volume-mute"),t=0):e<.33?(this.setIcon("volume-low"),t=1):e<.67&&(this.setIcon("volume-medium"),t=2),Hr(this.el_,[0,1,2,3].reduce((n,s)=>n+`${s?" ":""}vjs-vol-${s}`,"")),Bi(this.el_,`vjs-vol-${t}`)}updateControlText_(){const e=this.player_.muted()||this.player_.volume()===0?"Unmute":"Mute";this.controlText()!==e&&this.controlText(e)}}Tc.prototype.controlText_="Mute";H.registerComponent("MuteToggle",Tc);class vc extends H{constructor(e,t={}){typeof t.inline<"u"?t.inline=t.inline:t.inline=!0,(typeof t.volumeControl>"u"||mn(t.volumeControl))&&(t.volumeControl=t.volumeControl||{},t.volumeControl.vertical=!t.inline),super(e,t),this.handleKeyPressHandler_=n=>this.handleKeyPress(n),this.on(e,["loadstart"],n=>this.volumePanelState_(n)),this.on(this.muteToggle,"keyup",n=>this.handleKeyPress(n)),this.on(this.volumeControl,"keyup",n=>this.handleVolumeControlKeyUp(n)),this.on("keydown",n=>this.handleKeyPress(n)),this.on("mouseover",n=>this.handleMouseOver(n)),this.on("mouseout",n=>this.handleMouseOut(n)),this.on(this.volumeControl,["slideractive"],this.sliderActive_),this.on(this.volumeControl,["sliderinactive"],this.sliderInactive_)}sliderActive_(){this.addClass("vjs-slider-active")}sliderInactive_(){this.removeClass("vjs-slider-active")}volumePanelState_(){this.volumeControl.hasClass("vjs-hidden")&&this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-hidden"),this.volumeControl.hasClass("vjs-hidden")&&!this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-mute-toggle-only")}createEl(){let e="vjs-volume-panel-horizontal";return this.options_.inline||(e="vjs-volume-panel-vertical"),super.createEl("div",{className:`vjs-volume-panel vjs-control ${e}`})}dispose(){this.handleMouseOut(),super.dispose()}handleVolumeControlKeyUp(e){e.key==="Escape"&&this.muteToggle.focus()}handleMouseOver(e){this.addClass("vjs-hover"),vt(G,"keyup",this.handleKeyPressHandler_)}handleMouseOut(e){this.removeClass("vjs-hover"),Ze(G,"keyup",this.handleKeyPressHandler_)}handleKeyPress(e){e.key==="Escape"&&this.handleMouseOut()}}vc.prototype.options_={children:["muteToggle","volumeControl"]};H.registerComponent("VolumePanel",vc);class Sc extends et{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipForwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`forward-${this.skipTime}`),this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipForwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.forward}buildCSSClass(){return`vjs-skip-forward-${this.getSkipForwardTime()} ${super.buildCSSClass()}`}handleClick(e){if(isNaN(this.player_.duration()))return;const t=this.player_.currentTime(),n=this.player_.liveTracker,s=n&&n.isLive()?n.seekableEnd():this.player_.duration();let r;t+this.skipTime<=s?r=t+this.skipTime:r=s,this.player_.currentTime(r)}handleLanguagechange(){this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime]))}}Sc.prototype.controlText_="Skip Forward";H.registerComponent("SkipForward",Sc);class Ec extends et{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipBackwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`replay-${this.skipTime}`),this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipBackwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.backward}buildCSSClass(){return`vjs-skip-backward-${this.getSkipBackwardTime()} ${super.buildCSSClass()}`}handleClick(e){const t=this.player_.currentTime(),n=this.player_.liveTracker,s=n&&n.isLive()&&n.seekableStart();let r;s&&t-this.skipTime<=s?r=s:t>=this.skipTime?r=t-this.skipTime:r=0,this.player_.currentTime(r)}handleLanguagechange(){this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime]))}}Ec.prototype.controlText_="Skip Backward";H.registerComponent("SkipBackward",Ec);class wc extends H{constructor(e,t){super(e,t),t&&(this.menuButton_=t.menuButton),this.focusedChild_=-1,this.on("keydown",n=>this.handleKeyDown(n)),this.boundHandleBlur_=n=>this.handleBlur(n),this.boundHandleTapClick_=n=>this.handleTapClick(n)}addEventListenerForItem(e){e instanceof H&&(this.on(e,"blur",this.boundHandleBlur_),this.on(e,["tap","click"],this.boundHandleTapClick_))}removeEventListenerForItem(e){e instanceof H&&(this.off(e,"blur",this.boundHandleBlur_),this.off(e,["tap","click"],this.boundHandleTapClick_))}removeChild(e){typeof e=="string"&&(e=this.getChild(e)),this.removeEventListenerForItem(e),super.removeChild(e)}addItem(e){const t=this.addChild(e);t&&this.addEventListenerForItem(t)}createEl(){const e=this.options_.contentElType||"ul";this.contentEl_=ne(e,{className:"vjs-menu-content"}),this.contentEl_.setAttribute("role","menu");const t=super.createEl("div",{append:this.contentEl_,className:"vjs-menu"});return t.appendChild(this.contentEl_),vt(t,"click",function(n){n.preventDefault(),n.stopImmediatePropagation()}),t}dispose(){this.contentEl_=null,this.boundHandleBlur_=null,this.boundHandleTapClick_=null,super.dispose()}handleBlur(e){const t=e.relatedTarget||G.activeElement;if(!this.children().some(n=>n.el()===t)){const n=this.menuButton_;n&&n.buttonPressed_&&t!==n.el().firstChild&&n.unpressButton()}}handleTapClick(e){if(this.menuButton_){this.menuButton_.unpressButton();const t=this.children();if(!Array.isArray(t))return;const n=t.filter(s=>s.el()===e.target)[0];if(!n)return;n.name()!=="CaptionSettingsMenuItem"&&this.menuButton_.focus()}}handleKeyDown(e){e.key==="ArrowLeft"||e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(e.key==="ArrowRight"||e.key==="ArrowUp")&&(e.preventDefault(),e.stopPropagation(),this.stepBack())}stepForward(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_+1),this.focus(e)}stepBack(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_-1),this.focus(e)}focus(e=0){const t=this.children().slice();t.length&&t[0].hasClass("vjs-menu-title")&&t.shift(),t.length>0&&(e<0?e=0:e>=t.length&&(e=t.length-1),this.focusedChild_=e,t[e].el_.focus())}}H.registerComponent("Menu",wc);class el extends H{constructor(e,t={}){super(e,t),this.menuButton_=new et(e,t),this.menuButton_.controlText(this.controlText_),this.menuButton_.el_.setAttribute("aria-haspopup","true");const n=et.prototype.buildCSSClass();this.menuButton_.el_.className=this.buildCSSClass()+" "+n,this.menuButton_.removeClass("vjs-control"),this.addChild(this.menuButton_),this.update(),this.enabled_=!0;const s=r=>this.handleClick(r);this.handleMenuKeyUp_=r=>this.handleMenuKeyUp(r),this.on(this.menuButton_,"tap",s),this.on(this.menuButton_,"click",s),this.on(this.menuButton_,"keydown",r=>this.handleKeyDown(r)),this.on(this.menuButton_,"mouseenter",()=>{this.addClass("vjs-hover"),this.menu.show(),vt(G,"keyup",this.handleMenuKeyUp_)}),this.on("mouseleave",r=>this.handleMouseLeave(r)),this.on("keydown",r=>this.handleSubmenuKeyDown(r))}update(){const e=this.createMenu();this.menu&&(this.menu.dispose(),this.removeChild(this.menu)),this.menu=e,this.addChild(e),this.buttonPressed_=!1,this.menuButton_.el_.setAttribute("aria-expanded","false"),this.items&&this.items.length<=this.hideThreshold_?(this.hide(),this.menu.contentEl_.removeAttribute("role")):(this.show(),this.menu.contentEl_.setAttribute("role","menu"))}createMenu(){const e=new wc(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title){const t=ne("li",{className:"vjs-menu-title",textContent:Ne(this.options_.title),tabIndex:-1}),n=new H(this.player_,{el:t});e.addItem(n)}if(this.items=this.createItems(),this.items)for(let t=0;t<this.items.length;t++)e.addItem(this.items[t]);return e}createItems(){}createEl(){return super.createEl("div",{className:this.buildWrapperCSSClass()},{})}setIcon(e){super.setIcon(e,this.menuButton_.el_)}buildWrapperCSSClass(){let e="vjs-menu-button";this.options_.inline===!0?e+="-inline":e+="-popup";const t=et.prototype.buildCSSClass();return`vjs-menu-button ${e} ${t} ${super.buildCSSClass()}`}buildCSSClass(){let e="vjs-menu-button";return this.options_.inline===!0?e+="-inline":e+="-popup",`vjs-menu-button ${e} ${super.buildCSSClass()}`}controlText(e,t=this.menuButton_.el()){return this.menuButton_.controlText(e,t)}dispose(){this.handleMouseLeave(),super.dispose()}handleClick(e){this.buttonPressed_?this.unpressButton():this.pressButton()}handleMouseLeave(e){this.removeClass("vjs-hover"),Ze(G,"keyup",this.handleMenuKeyUp_)}focus(){this.menuButton_.focus()}blur(){this.menuButton_.blur()}handleKeyDown(e){e.key==="Escape"||e.key==="Tab"?(this.buttonPressed_&&this.unpressButton(),!e.key==="Tab"&&(e.preventDefault(),this.menuButton_.focus())):(e.key==="Up"||e.key==="Down"&&!(this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled))&&(this.buttonPressed_||(e.preventDefault(),this.pressButton()))}handleMenuKeyUp(e){(e.key==="Escape"||e.key==="Tab")&&this.removeClass("vjs-hover")}handleSubmenuKeyPress(e){this.handleSubmenuKeyDown(e)}handleSubmenuKeyDown(e){(e.key==="Escape"||e.key==="Tab")&&(this.buttonPressed_&&this.unpressButton(),!e.key==="Tab"&&(e.preventDefault(),this.menuButton_.focus()))}pressButton(){if(this.enabled_){if(this.buttonPressed_=!0,this.menu.show(),this.menu.lockShowing(),this.menuButton_.el_.setAttribute("aria-expanded","true"),Je&&Rh())return;this.menu.focus()}}unpressButton(){this.enabled_&&(this.buttonPressed_=!1,this.menu.unlockShowing(),this.menu.hide(),this.menuButton_.el_.setAttribute("aria-expanded","false"))}disable(){this.unpressButton(),this.enabled_=!1,this.addClass("vjs-disabled"),this.menuButton_.disable()}enable(){this.enabled_=!0,this.removeClass("vjs-disabled"),this.menuButton_.enable()}}H.registerComponent("MenuButton",el);class tl extends el{constructor(e,t){const n=t.tracks;if(super(e,t),this.items.length<=1&&this.hide(),!n)return;const s=Ce(this,this.update);n.addEventListener("removetrack",s),n.addEventListener("addtrack",s),n.addEventListener("labelchange",s),this.player_.on("ready",s),this.player_.on("dispose",function(){n.removeEventListener("removetrack",s),n.removeEventListener("addtrack",s),n.removeEventListener("labelchange",s)})}}H.registerComponent("TrackButton",tl);class bs extends Jr{constructor(e,t){super(e,t),this.selectable=t.selectable,this.isSelected_=t.selected||!1,this.multiSelectable=t.multiSelectable,this.selected(this.isSelected_),this.selectable?this.multiSelectable?this.el_.setAttribute("role","menuitemcheckbox"):this.el_.setAttribute("role","menuitemradio"):this.el_.setAttribute("role","menuitem")}createEl(e,t,n){this.nonIconControl=!0;const s=super.createEl("li",Object.assign({className:"vjs-menu-item",tabIndex:-1},t),n),r=ne("span",{className:"vjs-menu-item-text",textContent:this.localize(this.options_.label)});return this.player_.options_.experimentalSvgIcons?s.appendChild(r):s.replaceChild(r,s.querySelector(".vjs-icon-placeholder")),s}handleKeyDown(e){["Tab","Escape","ArrowUp","ArrowLeft","ArrowRight","ArrowDown"].includes(e.key)||super.handleKeyDown(e)}handleClick(e){this.selected(!0)}selected(e){this.selectable&&(e?(this.addClass("vjs-selected"),this.el_.setAttribute("aria-checked","true"),this.controlText(", selected"),this.isSelected_=!0):(this.removeClass("vjs-selected"),this.el_.setAttribute("aria-checked","false"),this.controlText(""),this.isSelected_=!1))}}H.registerComponent("MenuItem",bs);class Ts extends bs{constructor(e,t){const n=t.track,s=e.textTracks();t.label=n.label||n.language||"Unknown",t.selected=n.mode==="showing",super(e,t),this.track=n,this.kinds=(t.kinds||[t.kind||this.track.kind]).filter(Boolean);const r=(...l)=>{this.handleTracksChange.apply(this,l)},a=(...l)=>{this.handleSelectedLanguageChange.apply(this,l)};if(e.on(["loadstart","texttrackchange"],r),s.addEventListener("change",r),s.addEventListener("selectedlanguagechange",a),this.on("dispose",function(){e.off(["loadstart","texttrackchange"],r),s.removeEventListener("change",r),s.removeEventListener("selectedlanguagechange",a)}),s.onchange===void 0){let l;this.on(["tap","click"],function(){if(typeof x.Event!="object")try{l=new x.Event("change")}catch{}l||(l=G.createEvent("Event"),l.initEvent("change",!0,!0)),s.dispatchEvent(l)})}this.handleTracksChange()}handleClick(e){const t=this.track,n=this.player_.textTracks();if(super.handleClick(e),!!n)for(let s=0;s<n.length;s++){const r=n[s];this.kinds.indexOf(r.kind)!==-1&&(r===t?r.mode!=="showing"&&(r.mode="showing"):r.mode!=="disabled"&&(r.mode="disabled"))}}handleTracksChange(e){const t=this.track.mode==="showing";t!==this.isSelected_&&this.selected(t)}handleSelectedLanguageChange(e){if(this.track.mode==="showing"){const t=this.player_.cache_.selectedLanguage;if(t&&t.enabled&&t.language===this.track.language&&t.kind!==this.track.kind)return;this.player_.cache_.selectedLanguage={enabled:!0,language:this.track.language,kind:this.track.kind}}}dispose(){this.track=null,super.dispose()}}H.registerComponent("TextTrackMenuItem",Ts);class kc extends Ts{constructor(e,t){t.track={player:e,kind:t.kind,kinds:t.kinds,default:!1,mode:"disabled"},t.kinds||(t.kinds=[t.kind]),t.label?t.track.label=t.label:t.track.label=t.kinds.join(" and ")+" off",t.selectable=!0,t.multiSelectable=!1,super(e,t)}handleTracksChange(e){const t=this.player().textTracks();let n=!0;for(let s=0,r=t.length;s<r;s++){const a=t[s];if(this.options_.kinds.indexOf(a.kind)>-1&&a.mode==="showing"){n=!1;break}}n!==this.isSelected_&&this.selected(n)}handleSelectedLanguageChange(e){const t=this.player().textTracks();let n=!0;for(let s=0,r=t.length;s<r;s++){const a=t[s];if(["captions","descriptions","subtitles"].indexOf(a.kind)>-1&&a.mode==="showing"){n=!1;break}}n&&(this.player_.cache_.selectedLanguage={enabled:!1})}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.label),super.handleLanguagechange()}}H.registerComponent("OffTextTrackMenuItem",kc);class xn extends tl{constructor(e,t={}){t.tracks=e.textTracks(),super(e,t)}createItems(e=[],t=Ts){let n;this.label_&&(n=`${this.label_} off`),e.push(new kc(this.player_,{kinds:this.kinds_,kind:this.kind_,label:n})),this.hideThreshold_+=1;const s=this.player_.textTracks();Array.isArray(this.kinds_)||(this.kinds_=[this.kind_]);for(let r=0;r<s.length;r++){const a=s[r];if(this.kinds_.indexOf(a.kind)>-1){const l=new t(this.player_,{track:a,kinds:this.kinds_,kind:this.kind_,selectable:!0,multiSelectable:!1});l.addClass(`vjs-${a.kind}-menu-item`),e.push(l)}}return e}}H.registerComponent("TextTrackButton",xn);class Cc extends bs{constructor(e,t){const n=t.track,s=t.cue,r=e.currentTime();t.selectable=!0,t.multiSelectable=!1,t.label=s.text,t.selected=s.startTime<=r&&r<s.endTime,super(e,t),this.track=n,this.cue=s}handleClick(e){super.handleClick(),this.player_.currentTime(this.cue.startTime)}}H.registerComponent("ChaptersTrackMenuItem",Cc);class il extends xn{constructor(e,t,n){super(e,t,n),this.setIcon("chapters"),this.selectCurrentItem_=()=>{this.items.forEach(s=>{s.selected(this.track_.activeCues[0]===s.cue)})}}buildCSSClass(){return`vjs-chapters-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-chapters-button ${super.buildWrapperCSSClass()}`}update(e){if(e&&e.track&&e.track.kind!=="chapters")return;const t=this.findChaptersTrack();t!==this.track_?(this.setTrack(t),super.update()):(!this.items||t&&t.cues&&t.cues.length!==this.items.length)&&super.update()}setTrack(e){if(this.track_!==e){if(this.updateHandler_||(this.updateHandler_=this.update.bind(this)),this.track_){const t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);t&&t.removeEventListener("load",this.updateHandler_),this.track_.removeEventListener("cuechange",this.selectCurrentItem_),this.track_=null}if(this.track_=e,this.track_){this.track_.mode="hidden";const t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);t&&t.addEventListener("load",this.updateHandler_),this.track_.addEventListener("cuechange",this.selectCurrentItem_)}}}findChaptersTrack(){const e=this.player_.textTracks()||[];for(let t=e.length-1;t>=0;t--){const n=e[t];if(n.kind===this.kind_)return n}}getMenuCaption(){return this.track_&&this.track_.label?this.track_.label:this.localize(Ne(this.kind_))}createMenu(){return this.options_.title=this.getMenuCaption(),super.createMenu()}createItems(){const e=[];if(!this.track_)return e;const t=this.track_.cues;if(!t)return e;for(let n=0,s=t.length;n<s;n++){const r=t[n],a=new Cc(this.player_,{track:this.track_,cue:r});e.push(a)}return e}}il.prototype.kind_="chapters";il.prototype.controlText_="Chapters";H.registerComponent("ChaptersButton",il);class nl extends xn{constructor(e,t,n){super(e,t,n),this.setIcon("audio-description");const s=e.textTracks(),r=Ce(this,this.handleTracksChange);s.addEventListener("change",r),this.on("dispose",function(){s.removeEventListener("change",r)})}handleTracksChange(e){const t=this.player().textTracks();let n=!1;for(let s=0,r=t.length;s<r;s++){const a=t[s];if(a.kind!==this.kind_&&a.mode==="showing"){n=!0;break}}n?this.disable():this.enable()}buildCSSClass(){return`vjs-descriptions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-descriptions-button ${super.buildWrapperCSSClass()}`}}nl.prototype.kind_="descriptions";nl.prototype.controlText_="Descriptions";H.registerComponent("DescriptionsButton",nl);class sl extends xn{constructor(e,t,n){super(e,t,n),this.setIcon("subtitles")}buildCSSClass(){return`vjs-subtitles-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subtitles-button ${super.buildWrapperCSSClass()}`}}sl.prototype.kind_="subtitles";sl.prototype.controlText_="Subtitles";H.registerComponent("SubtitlesButton",sl);class rl extends Ts{constructor(e,t){t.track={player:e,kind:t.kind,label:t.kind+" settings",selectable:!1,default:!1,mode:"disabled"},t.selectable=!1,t.name="CaptionSettingsMenuItem",super(e,t),this.addClass("vjs-texttrack-settings"),this.controlText(", opens "+t.kind+" settings dialog")}handleClick(e){this.player().getChild("textTrackSettings").open()}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.kind+" settings"),super.handleLanguagechange()}}H.registerComponent("CaptionSettingsMenuItem",rl);class al extends xn{constructor(e,t,n){super(e,t,n),this.setIcon("captions")}buildCSSClass(){return`vjs-captions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-captions-button ${super.buildWrapperCSSClass()}`}createItems(){const e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings")&&(e.push(new rl(this.player_,{kind:this.kind_})),this.hideThreshold_+=1),super.createItems(e)}}al.prototype.kind_="captions";al.prototype.controlText_="Captions";H.registerComponent("CaptionsButton",al);class Ic extends Ts{createEl(e,t,n){const s=super.createEl(e,t,n),r=s.querySelector(".vjs-menu-item-text");return this.options_.track.kind==="captions"&&(this.player_.options_.experimentalSvgIcons?this.setIcon("captions",s):r.appendChild(ne("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(ne("span",{className:"vjs-control-text",textContent:` ${this.localize("Captions")}`}))),s}}H.registerComponent("SubsCapsMenuItem",Ic);class ol extends xn{constructor(e,t={}){super(e,t),this.label_="subtitles",this.setIcon("subtitles"),["en","en-us","en-ca","fr-ca"].indexOf(this.player_.language_)>-1&&(this.label_="captions",this.setIcon("captions")),this.menuButton_.controlText(Ne(this.label_))}buildCSSClass(){return`vjs-subs-caps-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subs-caps-button ${super.buildWrapperCSSClass()}`}createItems(){let e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings")&&(e.push(new rl(this.player_,{kind:this.label_})),this.hideThreshold_+=1),e=super.createItems(e,Ic),e}}ol.prototype.kinds_=["captions","subtitles"];ol.prototype.controlText_="Subtitles";H.registerComponent("SubsCapsButton",ol);class xc extends bs{constructor(e,t){const n=t.track,s=e.audioTracks();t.label=n.label||n.language||"Unknown",t.selected=n.enabled,super(e,t),this.track=n,this.addClass(`vjs-${n.kind}-menu-item`);const r=(...a)=>{this.handleTracksChange.apply(this,a)};s.addEventListener("change",r),this.on("dispose",()=>{s.removeEventListener("change",r)})}createEl(e,t,n){const s=super.createEl(e,t,n),r=s.querySelector(".vjs-menu-item-text");return["main-desc","descriptions"].indexOf(this.options_.track.kind)>=0&&(r.appendChild(ne("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(ne("span",{className:"vjs-control-text",textContent:" "+this.localize("Descriptions")}))),s}handleClick(e){if(super.handleClick(e),this.track.enabled=!0,this.player_.tech_.featuresNativeAudioTracks){const t=this.player_.audioTracks();for(let n=0;n<t.length;n++){const s=t[n];s!==this.track&&(s.enabled=s===this.track)}}}handleTracksChange(e){this.selected(this.track.enabled)}}H.registerComponent("AudioTrackMenuItem",xc);class Ac extends tl{constructor(e,t={}){t.tracks=e.audioTracks(),super(e,t),this.setIcon("audio")}buildCSSClass(){return`vjs-audio-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-audio-button ${super.buildWrapperCSSClass()}`}createItems(e=[]){this.hideThreshold_=1;const t=this.player_.audioTracks();for(let n=0;n<t.length;n++){const s=t[n];e.push(new xc(this.player_,{track:s,selectable:!0,multiSelectable:!1}))}return e}}Ac.prototype.controlText_="Audio Track";H.registerComponent("AudioTrackButton",Ac);class ll extends bs{constructor(e,t){const n=t.rate,s=parseFloat(n,10);t.label=n,t.selected=s===e.playbackRate(),t.selectable=!0,t.multiSelectable=!1,super(e,t),this.label=n,this.rate=s,this.on(e,"ratechange",r=>this.update(r))}handleClick(e){super.handleClick(),this.player().playbackRate(this.rate)}update(e){this.selected(this.player().playbackRate()===this.rate)}}ll.prototype.contentElType="button";H.registerComponent("PlaybackRateMenuItem",ll);class Pc extends el{constructor(e,t){super(e,t),this.menuButton_.el_.setAttribute("aria-describedby",this.labelElId_),this.updateVisibility(),this.updateLabel(),this.on(e,"loadstart",n=>this.updateVisibility(n)),this.on(e,"ratechange",n=>this.updateLabel(n)),this.on(e,"playbackrateschange",n=>this.handlePlaybackRateschange(n))}createEl(){const e=super.createEl();return this.labelElId_="vjs-playback-rate-value-label-"+this.id_,this.labelEl_=ne("div",{className:"vjs-playback-rate-value",id:this.labelElId_,textContent:"1x"}),e.appendChild(this.labelEl_),e}dispose(){this.labelEl_=null,super.dispose()}buildCSSClass(){return`vjs-playback-rate ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-playback-rate ${super.buildWrapperCSSClass()}`}createItems(){const e=this.playbackRates(),t=[];for(let n=e.length-1;n>=0;n--)t.push(new ll(this.player(),{rate:e[n]+"x"}));return t}handlePlaybackRateschange(e){this.update()}playbackRates(){const e=this.player();return e.playbackRates&&e.playbackRates()||[]}playbackRateSupported(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&this.playbackRates().length>0}updateVisibility(e){this.playbackRateSupported()?this.removeClass("vjs-hidden"):this.addClass("vjs-hidden")}updateLabel(e){this.playbackRateSupported()&&(this.labelEl_.textContent=this.player().playbackRate()+"x")}}Pc.prototype.controlText_="Playback Rate";H.registerComponent("PlaybackRateMenuButton",Pc);class Lc extends H{buildCSSClass(){return`vjs-spacer ${super.buildCSSClass()}`}createEl(e="div",t={},n={}){return t.className||(t.className=this.buildCSSClass()),super.createEl(e,t,n)}}H.registerComponent("Spacer",Lc);class Rb extends Lc{buildCSSClass(){return`vjs-custom-control-spacer ${super.buildCSSClass()}`}createEl(){return super.createEl("div",{className:this.buildCSSClass(),textContent:" "})}}H.registerComponent("CustomControlSpacer",Rb);class Dc extends H{createEl(){return super.createEl("div",{className:"vjs-control-bar",dir:"ltr"})}}Dc.prototype.options_={children:["playToggle","skipBackward","skipForward","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","liveDisplay","seekToLive","remainingTimeDisplay","customControlSpacer","playbackRateMenuButton","chaptersButton","descriptionsButton","subsCapsButton","audioTrackButton","pictureInPictureToggle","fullscreenToggle"]};H.registerComponent("ControlBar",Dc);class Oc extends Cn{constructor(e,t){super(e,t),this.on(e,"error",n=>{this.open(n)})}buildCSSClass(){return`vjs-error-display ${super.buildCSSClass()}`}content(){const e=this.player().error();return e?this.localize(e.message):""}}Oc.prototype.options_=Object.assign({},Cn.prototype.options_,{pauseOnOpen:!1,fillAlways:!0,temporary:!1,uncloseable:!0});H.registerComponent("ErrorDisplay",Oc);class Mc extends H{constructor(e,t={}){super(e,t),this.el_.setAttribute("aria-labelledby",this.selectLabelledbyIds)}createEl(){return this.selectLabelledbyIds=[this.options_.legendId,this.options_.labelId].join(" ").trim(),ne("select",{id:this.options_.id},{},this.options_.SelectOptions.map(e=>{const t=(this.options_.labelId?this.options_.labelId:`vjs-track-option-${At()}`)+"-"+e[1].replace(/\W+/g,""),n=ne("option",{id:t,value:this.localize(e[0]),textContent:this.localize(e[1])});return n.setAttribute("aria-labelledby",`${this.selectLabelledbyIds} ${t}`),n}))}}H.registerComponent("TextTrackSelect",Mc);class ji extends H{constructor(e,t={}){super(e,t);const n=ne("legend",{textContent:this.localize(this.options_.legendText),id:this.options_.legendId});this.el().appendChild(n);const s=this.options_.selects;for(const r of s){const a=this.options_.selectConfigs[r],l=a.className,c=a.id.replace("%s",this.options_.id_);let g=null;const m=`vjs_select_${At()}`;if(this.options_.type==="colors"){g=ne("span",{className:l});const C=ne("label",{id:c,className:"vjs-label",textContent:this.localize(a.label)});C.setAttribute("for",m),g.appendChild(C)}const b=new Mc(e,{SelectOptions:a.options,legendId:this.options_.legendId,id:m,labelId:c});this.addChild(b),this.options_.type==="colors"&&(g.appendChild(b.el()),this.el().appendChild(g))}}createEl(){return ne("fieldset",{className:this.options_.className})}}H.registerComponent("TextTrackFieldset",ji);class Rc extends H{constructor(e,t={}){super(e,t);const n=this.options_.textTrackComponentid,s=new ji(e,{id_:n,legendId:`captions-text-legend-${n}`,legendText:this.localize("Text"),className:"vjs-fg vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(s);const r=new ji(e,{id_:n,legendId:`captions-background-${n}`,legendText:this.localize("Text Background"),className:"vjs-bg vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(r);const a=new ji(e,{id_:n,legendId:`captions-window-${n}`,legendText:this.localize("Caption Area Background"),className:"vjs-window vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(a)}createEl(){return ne("div",{className:"vjs-track-settings-colors"})}}H.registerComponent("TextTrackSettingsColors",Rc);class Uc extends H{constructor(e,t={}){super(e,t);const n=this.options_.textTrackComponentid,s=new ji(e,{id_:n,legendId:`captions-font-size-${n}`,legendText:"Font Size",className:"vjs-font-percent vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(s);const r=new ji(e,{id_:n,legendId:`captions-edge-style-${n}`,legendText:this.localize("Text Edge Style"),className:"vjs-edge-style vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(r);const a=new ji(e,{id_:n,legendId:`captions-font-family-${n}`,legendText:this.localize("Font Family"),className:"vjs-font-family vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(a)}createEl(){return ne("div",{className:"vjs-track-settings-font"})}}H.registerComponent("TextTrackSettingsFont",Uc);class Nc extends H{constructor(e,t={}){super(e,t);const n=this.localize("restore all settings to the default values"),s=new et(e,{controlText:n,className:"vjs-default-button"});s.el().classList.remove("vjs-control","vjs-button"),s.el().textContent=this.localize("Reset"),this.addChild(s);const r=new et(e,{controlText:n,className:"vjs-done-button"});r.el().classList.remove("vjs-control","vjs-button"),r.el().textContent=this.localize("Done"),this.addChild(r)}createEl(){return ne("div",{className:"vjs-track-settings-controls"})}}H.registerComponent("TrackSettingsControls",Nc);const Fa="vjs-text-track-settings",Qu=["#000","Black"],Ju=["#00F","Blue"],Zu=["#0FF","Cyan"],ed=["#0F0","Green"],td=["#F0F","Magenta"],id=["#F00","Red"],nd=["#FFF","White"],sd=["#FF0","Yellow"],ja=["1","Opaque"],$a=["0.5","Semi-Transparent"],rd=["0","Transparent"],bi={backgroundColor:{selector:".vjs-bg-color > select",id:"captions-background-color-%s",label:"Color",options:[Qu,nd,id,ed,Ju,sd,td,Zu],className:"vjs-bg-color"},backgroundOpacity:{selector:".vjs-bg-opacity > select",id:"captions-background-opacity-%s",label:"Opacity",options:[ja,$a,rd],className:"vjs-bg-opacity vjs-opacity"},color:{selector:".vjs-text-color > select",id:"captions-foreground-color-%s",label:"Color",options:[nd,Qu,id,ed,Ju,sd,td,Zu],className:"vjs-text-color"},edgeStyle:{selector:".vjs-edge-style > select",id:"",label:"Text Edge Style",options:[["none","None"],["raised","Raised"],["depressed","Depressed"],["uniform","Uniform"],["dropshadow","Drop shadow"]]},fontFamily:{selector:".vjs-font-family > select",id:"",label:"Font Family",options:[["proportionalSansSerif","Proportional Sans-Serif"],["monospaceSansSerif","Monospace Sans-Serif"],["proportionalSerif","Proportional Serif"],["monospaceSerif","Monospace Serif"],["casual","Casual"],["script","Script"],["small-caps","Small Caps"]]},fontPercent:{selector:".vjs-font-percent > select",id:"",label:"Font Size",options:[["0.50","50%"],["0.75","75%"],["1.00","100%"],["1.25","125%"],["1.50","150%"],["1.75","175%"],["2.00","200%"],["3.00","300%"],["4.00","400%"]],default:2,parser:i=>i==="1.00"?null:Number(i)},textOpacity:{selector:".vjs-text-opacity > select",id:"captions-foreground-opacity-%s",label:"Opacity",options:[ja,$a],className:"vjs-text-opacity vjs-opacity"},windowColor:{selector:".vjs-window-color > select",id:"captions-window-color-%s",label:"Color",className:"vjs-window-color"},windowOpacity:{selector:".vjs-window-opacity > select",id:"captions-window-opacity-%s",label:"Opacity",options:[rd,$a,ja],className:"vjs-window-opacity vjs-opacity"}};bi.windowColor.options=bi.backgroundColor.options;function Bc(i,e){if(e&&(i=e(i)),i&&i!=="none")return i}function Ub(i,e){const t=i.options[i.options.selectedIndex].value;return Bc(t,e)}function Nb(i,e,t){if(e){for(let n=0;n<i.options.length;n++)if(Bc(i.options[n].value,t)===e){i.selectedIndex=n;break}}}class Bb extends Cn{constructor(e,t){t.temporary=!1,super(e,t),this.updateDisplay=this.updateDisplay.bind(this),this.fill(),this.hasBeenOpened_=this.hasBeenFilled_=!0,this.renderModalComponents(e),this.endDialog=ne("p",{className:"vjs-control-text",textContent:this.localize("End of dialog window.")}),this.el().appendChild(this.endDialog),this.setDefaults(),t.persistTextTrackSettings===void 0&&(this.options_.persistTextTrackSettings=this.options_.playerOptions.persistTextTrackSettings),this.bindFunctionsToSelectsAndButtons(),this.options_.persistTextTrackSettings&&this.restoreSettings()}renderModalComponents(e){const t=new Rc(e,{textTrackComponentid:this.id_,selectConfigs:bi,fieldSets:[["color","textOpacity"],["backgroundColor","backgroundOpacity"],["windowColor","windowOpacity"]]});this.addChild(t);const n=new Uc(e,{textTrackComponentid:this.id_,selectConfigs:bi,fieldSets:[["fontPercent"],["edgeStyle"],["fontFamily"]]});this.addChild(n);const s=new Nc(e);this.addChild(s)}bindFunctionsToSelectsAndButtons(){this.on(this.$(".vjs-done-button"),["click","tap"],()=>{this.saveSettings(),this.close()}),this.on(this.$(".vjs-default-button"),["click","tap"],()=>{this.setDefaults(),this.updateDisplay()}),sn(bi,e=>{this.on(this.$(e.selector),"change",this.updateDisplay)})}dispose(){this.endDialog=null,super.dispose()}label(){return this.localize("Caption Settings Dialog")}description(){return this.localize("Beginning of dialog window. Escape will cancel and close the window.")}buildCSSClass(){return super.buildCSSClass()+" vjs-text-track-settings"}getValues(){return xh(bi,(e,t,n)=>{const s=Ub(this.$(t.selector),t.parser);return s!==void 0&&(e[n]=s),e},{})}setValues(e){sn(bi,(t,n)=>{Nb(this.$(t.selector),e[n],t.parser)})}setDefaults(){sn(bi,e=>{const t=e.hasOwnProperty("default")?e.default:0;this.$(e.selector).selectedIndex=t})}restoreSettings(){let e;try{e=JSON.parse(x.localStorage.getItem(Fa))}catch(t){le.warn(t)}e&&this.setValues(e)}saveSettings(){if(!this.options_.persistTextTrackSettings)return;const e=this.getValues();try{Object.keys(e).length?x.localStorage.setItem(Fa,JSON.stringify(e)):x.localStorage.removeItem(Fa)}catch(t){le.warn(t)}}updateDisplay(){const e=this.player_.getChild("textTrackDisplay");e&&e.updateDisplay()}handleLanguagechange(){this.fill(),this.renderModalComponents(this.player_),this.bindFunctionsToSelectsAndButtons()}}H.registerComponent("TextTrackSettings",Bb);class Fb extends H{constructor(e,t){let n=t.ResizeObserver||x.ResizeObserver;t.ResizeObserver===null&&(n=!1);const s=ve({createEl:!n,reportTouchActivity:!1},t);super(e,s),this.ResizeObserver=t.ResizeObserver||x.ResizeObserver,this.loadListener_=null,this.resizeObserver_=null,this.debouncedHandler_=Qh(()=>{this.resizeHandler()},100,!1,this),n?(this.resizeObserver_=new this.ResizeObserver(this.debouncedHandler_),this.resizeObserver_.observe(e.el())):(this.loadListener_=()=>{if(!this.el_||!this.el_.contentWindow)return;const r=this.debouncedHandler_;let a=this.unloadListener_=function(){Ze(this,"resize",r),Ze(this,"unload",a),a=null};vt(this.el_.contentWindow,"unload",a),vt(this.el_.contentWindow,"resize",r)},this.one("load",this.loadListener_))}createEl(){return super.createEl("iframe",{className:"vjs-resize-manager",tabIndex:-1,title:this.localize("No content")},{"aria-hidden":"true"})}resizeHandler(){!this.player_||!this.player_.trigger||this.player_.trigger("playerresize")}dispose(){this.debouncedHandler_&&this.debouncedHandler_.cancel(),this.resizeObserver_&&(this.player_.el()&&this.resizeObserver_.unobserve(this.player_.el()),this.resizeObserver_.disconnect()),this.loadListener_&&this.off("load",this.loadListener_),this.el_&&this.el_.contentWindow&&this.unloadListener_&&this.unloadListener_.call(this.el_.contentWindow),this.ResizeObserver=null,this.resizeObserver=null,this.debouncedHandler_=null,this.loadListener_=null,super.dispose()}}H.registerComponent("ResizeManager",Fb);const jb={trackingThreshold:20,liveTolerance:15};class $b extends H{constructor(e,t){const n=ve(jb,t,{createEl:!1});super(e,n),this.trackLiveHandler_=()=>this.trackLive_(),this.handlePlay_=s=>this.handlePlay(s),this.handleFirstTimeupdate_=s=>this.handleFirstTimeupdate(s),this.handleSeeked_=s=>this.handleSeeked(s),this.seekToLiveEdge_=s=>this.seekToLiveEdge(s),this.reset_(),this.on(this.player_,"durationchange",s=>this.handleDurationchange(s)),this.on(this.player_,"canplay",()=>this.toggleTracking())}trackLive_(){const e=this.player_.seekable();if(!e||!e.length)return;const t=Number(x.performance.now().toFixed(4)),n=this.lastTime_===-1?0:(t-this.lastTime_)/1e3;this.lastTime_=t,this.pastSeekEnd_=this.pastSeekEnd()+n;const s=this.liveCurrentTime(),r=this.player_.currentTime();let a=this.player_.paused()||this.seekedBehindLive_||Math.abs(s-r)>this.options_.liveTolerance;(!this.timeupdateSeen_||s===1/0)&&(a=!1),a!==this.behindLiveEdge_&&(this.behindLiveEdge_=a,this.trigger("liveedgechange"))}handleDurationchange(){this.toggleTracking()}toggleTracking(){this.player_.duration()===1/0&&this.liveWindow()>=this.options_.trackingThreshold?(this.player_.options_.liveui&&this.player_.addClass("vjs-liveui"),this.startTracking()):(this.player_.removeClass("vjs-liveui"),this.stopTracking())}startTracking(){this.isTracking()||(this.timeupdateSeen_||(this.timeupdateSeen_=this.player_.hasStarted()),this.trackingInterval_=this.setInterval(this.trackLiveHandler_,Pt),this.trackLive_(),this.on(this.player_,["play","pause"],this.trackLiveHandler_),this.timeupdateSeen_?this.on(this.player_,"seeked",this.handleSeeked_):(this.one(this.player_,"play",this.handlePlay_),this.one(this.player_,"timeupdate",this.handleFirstTimeupdate_)))}handleFirstTimeupdate(){this.timeupdateSeen_=!0,this.on(this.player_,"seeked",this.handleSeeked_)}handleSeeked(){const e=Math.abs(this.liveCurrentTime()-this.player_.currentTime());this.seekedBehindLive_=this.nextSeekedFromUser_&&e>2,this.nextSeekedFromUser_=!1,this.trackLive_()}handlePlay(){this.one(this.player_,"timeupdate",this.seekToLiveEdge_)}reset_(){this.lastTime_=-1,this.pastSeekEnd_=0,this.lastSeekEnd_=-1,this.behindLiveEdge_=!0,this.timeupdateSeen_=!1,this.seekedBehindLive_=!1,this.nextSeekedFromUser_=!1,this.clearInterval(this.trackingInterval_),this.trackingInterval_=null,this.off(this.player_,["play","pause"],this.trackLiveHandler_),this.off(this.player_,"seeked",this.handleSeeked_),this.off(this.player_,"play",this.handlePlay_),this.off(this.player_,"timeupdate",this.handleFirstTimeupdate_),this.off(this.player_,"timeupdate",this.seekToLiveEdge_)}nextSeekedFromUser(){this.nextSeekedFromUser_=!0}stopTracking(){this.isTracking()&&(this.reset_(),this.trigger("liveedgechange"))}seekableEnd(){const e=this.player_.seekable(),t=[];let n=e?e.length:0;for(;n--;)t.push(e.end(n));return t.length?t.sort()[t.length-1]:1/0}seekableStart(){const e=this.player_.seekable(),t=[];let n=e?e.length:0;for(;n--;)t.push(e.start(n));return t.length?t.sort()[0]:0}liveWindow(){const e=this.liveCurrentTime();return e===1/0?0:e-this.seekableStart()}isLive(){return this.isTracking()}atLiveEdge(){return!this.behindLiveEdge()}liveCurrentTime(){return this.pastSeekEnd()+this.seekableEnd()}pastSeekEnd(){const e=this.seekableEnd();return this.lastSeekEnd_!==-1&&e!==this.lastSeekEnd_&&(this.pastSeekEnd_=0),this.lastSeekEnd_=e,this.pastSeekEnd_}behindLiveEdge(){return this.behindLiveEdge_}isTracking(){return typeof this.trackingInterval_=="number"}seekToLiveEdge(){this.seekedBehindLive_=!1,!this.atLiveEdge()&&(this.nextSeekedFromUser_=!1,this.player_.currentTime(this.liveCurrentTime()))}dispose(){this.stopTracking(),super.dispose()}}H.registerComponent("LiveTracker",$b);class qb extends H{constructor(e,t){super(e,t),this.on("statechanged",n=>this.updateDom_()),this.updateDom_()}createEl(){return this.els={title:ne("div",{className:"vjs-title-bar-title",id:`vjs-title-bar-title-${At()}`}),description:ne("div",{className:"vjs-title-bar-description",id:`vjs-title-bar-description-${At()}`})},ne("div",{className:"vjs-title-bar"},{},Ah(this.els))}updateDom_(){const e=this.player_.tech_,t=e&&e.el_,n={title:"aria-labelledby",description:"aria-describedby"};["title","description"].forEach(s=>{const r=this.state[s],a=this.els[s],l=n[s];Gr(a),r&&Si(a,r),t&&(t.removeAttribute(l),r&&t.setAttribute(l,a.id))}),this.state.title||this.state.description?this.show():this.hide()}update(e){this.setState(e)}dispose(){const e=this.player_.tech_,t=e&&e.el_;t&&(t.removeAttribute("aria-labelledby"),t.removeAttribute("aria-describedby")),super.dispose(),this.els=null}}H.registerComponent("TitleBar",qb);const Vb={initialDisplay:4e3,position:[],takeFocus:!1};class Hb extends et{constructor(e,t){t=ve(Vb,t),super(e,t),this.controlText(t.controlText),this.hide(),this.on(this.player_,["useractive","userinactive"],n=>{this.removeClass("force-display")})}buildCSSClass(){return`vjs-transient-button focus-visible ${this.options_.position.map(e=>`vjs-${e}`).join(" ")}`}createEl(){const e=ne("button",{},{type:"button",class:this.buildCSSClass()},ne("span"));return this.controlTextEl_=e.querySelector("span"),e}show(){super.show(),this.addClass("force-display"),this.options_.takeFocus&&this.el().focus({preventScroll:!0}),this.forceDisplayTimeout=this.player_.setTimeout(()=>{this.removeClass("force-display")},this.options_.initialDisplay)}hide(){this.removeClass("force-display"),super.hide()}dispose(){this.player_.clearTimeout(this.forceDisplayTimeout),super.dispose()}}H.registerComponent("TransientButton",Hb);const ro=i=>{const e=i.el();if(e.hasAttribute("src"))return i.triggerSourceset(e.src),!0;const t=i.$$("source"),n=[];let s="";if(!t.length)return!1;for(let r=0;r<t.length;r++){const a=t[r].src;a&&n.indexOf(a)===-1&&n.push(a)}return n.length?(n.length===1&&(s=n[0]),i.triggerSourceset(s),!0):!1},zb=Object.defineProperty({},"innerHTML",{get(){return this.cloneNode(!0).innerHTML},set(i){const e=G.createElement(this.nodeName.toLowerCase());e.innerHTML=i;const t=G.createDocumentFragment();for(;e.childNodes.length;)t.appendChild(e.childNodes[0]);return this.innerText="",x.Element.prototype.appendChild.call(this,t),this.innerHTML}}),Fc=(i,e)=>{let t={};for(let n=0;n<i.length&&(t=Object.getOwnPropertyDescriptor(i[n],e),!(t&&t.set&&t.get));n++);return t.enumerable=!0,t.configurable=!0,t},Wb=i=>Fc([i.el(),x.HTMLMediaElement.prototype,x.Element.prototype,zb],"innerHTML"),ad=function(i){const e=i.el();if(e.resetSourceWatch_)return;const t={},n=Wb(i),s=r=>(...a)=>{const l=r.apply(e,a);return ro(i),l};["append","appendChild","insertAdjacentHTML"].forEach(r=>{e[r]&&(t[r]=e[r],e[r]=s(t[r]))}),Object.defineProperty(e,"innerHTML",ve(n,{set:s(n.set)})),e.resetSourceWatch_=()=>{e.resetSourceWatch_=null,Object.keys(t).forEach(r=>{e[r]=t[r]}),Object.defineProperty(e,"innerHTML",n)},i.one("sourceset",e.resetSourceWatch_)},Gb=Object.defineProperty({},"src",{get(){return this.hasAttribute("src")?oc(x.Element.prototype.getAttribute.call(this,"src")):""},set(i){return x.Element.prototype.setAttribute.call(this,"src",i),i}}),Xb=i=>Fc([i.el(),x.HTMLMediaElement.prototype,Gb],"src"),Kb=function(i){if(!i.featuresSourceset)return;const e=i.el();if(e.resetSourceset_)return;const t=Xb(i),n=e.setAttribute,s=e.load;Object.defineProperty(e,"src",ve(t,{set:r=>{const a=t.set.call(e,r);return i.triggerSourceset(e.src),a}})),e.setAttribute=(r,a)=>{const l=n.call(e,r,a);return/src/i.test(r)&&i.triggerSourceset(e.src),l},e.load=()=>{const r=s.call(e);return ro(i)||(i.triggerSourceset(""),ad(i)),r},e.currentSrc?i.triggerSourceset(e.currentSrc):ro(i)||ad(i),e.resetSourceset_=()=>{e.resetSourceset_=null,e.load=s,e.setAttribute=n,Object.defineProperty(e,"src",t),e.resetSourceWatch_&&e.resetSourceWatch_()}};class J extends ae{constructor(e,t){super(e,t);const n=e.source;let s=!1;if(this.featuresVideoFrameCallback=this.featuresVideoFrameCallback&&this.el_.tagName==="VIDEO",n&&(this.el_.currentSrc!==n.src||e.tag&&e.tag.initNetworkState_===3)?this.setSource(n):this.handleLateInit_(this.el_),e.enableSourceset&&this.setupSourcesetHandling_(),this.isScrubbing_=!1,this.el_.hasChildNodes()){const r=this.el_.childNodes;let a=r.length;const l=[];for(;a--;){const c=r[a];c.nodeName.toLowerCase()==="track"&&(this.featuresNativeTextTracks?(this.remoteTextTrackEls().addTrackElement_(c),this.remoteTextTracks().addTrack(c.track),this.textTracks().addTrack(c.track),!s&&!this.el_.hasAttribute("crossorigin")&&Qr(c.src)&&(s=!0)):l.push(c))}for(let c=0;c<l.length;c++)this.el_.removeChild(l[c])}this.proxyNativeTracks_(),this.featuresNativeTextTracks&&s&&le.warn(`Text Tracks are being loaded from another origin but the crossorigin attribute isn't used.
|
|
167
|
-
This may prevent text tracks from loading.`),this.restoreMetadataTracksInIOSNativePlayer_(),(cs||qr)&&e.nativeControlsForTouch===!0&&this.setControls(!0),this.proxyWebkitFullscreen_(),this.triggerReady()}dispose(){this.el_&&this.el_.resetSourceset_&&this.el_.resetSourceset_(),J.disposeMediaElement(this.el_),this.options_=null,super.dispose()}setupSourcesetHandling_(){Kb(this)}restoreMetadataTracksInIOSNativePlayer_(){const e=this.textTracks();let t;const n=()=>{t=[];for(let r=0;r<e.length;r++){const a=e[r];a.kind==="metadata"&&t.push({track:a,storedMode:a.mode})}};n(),e.addEventListener("change",n),this.on("dispose",()=>e.removeEventListener("change",n));const s=()=>{for(let r=0;r<t.length;r++){const a=t[r];a.track.mode==="disabled"&&a.track.mode!==a.storedMode&&(a.track.mode=a.storedMode)}e.removeEventListener("change",s)};this.on("webkitbeginfullscreen",()=>{e.removeEventListener("change",n),e.removeEventListener("change",s),e.addEventListener("change",s)}),this.on("webkitendfullscreen",()=>{e.removeEventListener("change",n),e.addEventListener("change",n),e.removeEventListener("change",s)})}overrideNative_(e,t){if(t!==this[`featuresNative${e}Tracks`])return;const n=e.toLowerCase();this[`${n}TracksListeners_`]&&Object.keys(this[`${n}TracksListeners_`]).forEach(s=>{this.el()[`${n}Tracks`].removeEventListener(s,this[`${n}TracksListeners_`][s])}),this[`featuresNative${e}Tracks`]=!t,this[`${n}TracksListeners_`]=null,this.proxyNativeTracksForType_(n)}overrideNativeAudioTracks(e){this.overrideNative_("Audio",e)}overrideNativeVideoTracks(e){this.overrideNative_("Video",e)}proxyNativeTracksForType_(e){const t=xt[e],n=this.el()[t.getterName],s=this[t.getterName]();if(!this[`featuresNative${t.capitalName}Tracks`]||!n||!n.addEventListener)return;const r={change:l=>{const c={type:"change",target:s,currentTarget:s,srcElement:s};s.trigger(c),e==="text"&&this[vn.remoteText.getterName]().trigger(c)},addtrack(l){s.addTrack(l.track)},removetrack(l){s.removeTrack(l.track)}},a=function(){const l=[];for(let c=0;c<s.length;c++){let g=!1;for(let m=0;m<n.length;m++)if(n[m]===s[c]){g=!0;break}g||l.push(s[c])}for(;l.length;)s.removeTrack(l.shift())};this[t.getterName+"Listeners_"]=r,Object.keys(r).forEach(l=>{const c=r[l];n.addEventListener(l,c),this.on("dispose",g=>n.removeEventListener(l,c))}),this.on("loadstart",a),this.on("dispose",l=>this.off("loadstart",a))}proxyNativeTracks_(){xt.names.forEach(e=>{this.proxyNativeTracksForType_(e)})}createEl(){let e=this.options_.tag;if(!e||!(this.options_.playerElIngest||this.movingMediaElementInDOM)){if(e){const n=e.cloneNode(!0);e.parentNode&&e.parentNode.insertBefore(n,e),J.disposeMediaElement(e),e=n}else{e=G.createElement("video");const n=this.options_.tag&&_i(this.options_.tag),s=ve({},n);(!cs||this.options_.nativeControlsForTouch!==!0)&&delete s.controls,Bh(e,Object.assign(s,{id:this.options_.techId,class:"vjs-tech"}))}e.playerId=this.options_.playerId}typeof this.options_.preload<"u"&&yn(e,"preload",this.options_.preload),this.options_.disablePictureInPicture!==void 0&&(e.disablePictureInPicture=this.options_.disablePictureInPicture);const t=["loop","muted","playsinline","autoplay"];for(let n=0;n<t.length;n++){const s=t[n],r=this.options_[s];typeof r<"u"&&(r?yn(e,s,s):zr(e,s),e[s]=r)}return e}handleLateInit_(e){if(e.networkState===0||e.networkState===3)return;if(e.readyState===0){let n=!1;const s=function(){n=!0};this.on("loadstart",s);const r=function(){n||this.trigger("loadstart")};this.on("loadedmetadata",r),this.ready(function(){this.off("loadstart",s),this.off("loadedmetadata",r),n||this.trigger("loadstart")});return}const t=["loadstart"];t.push("loadedmetadata"),e.readyState>=2&&t.push("loadeddata"),e.readyState>=3&&t.push("canplay"),e.readyState>=4&&t.push("canplaythrough"),this.ready(function(){t.forEach(function(n){this.trigger(n)},this)})}setScrubbing(e){this.isScrubbing_=e}scrubbing(){return this.isScrubbing_}setCurrentTime(e){try{this.isScrubbing_&&this.el_.fastSeek&&Vr?this.el_.fastSeek(e):this.el_.currentTime=e}catch(t){le(t,"Video is not ready. (Video.js)")}}duration(){if(this.el_.duration===1/0&&Nt&&Jt&&this.el_.currentTime===0){const e=()=>{this.el_.currentTime>0&&(this.el_.duration===1/0&&this.trigger("durationchange"),this.off("timeupdate",e))};return this.on("timeupdate",e),NaN}return this.el_.duration||NaN}width(){return this.el_.offsetWidth}height(){return this.el_.offsetHeight}proxyWebkitFullscreen_(){if(!("webkitDisplayingFullscreen"in this.el_))return;const e=function(){this.trigger("fullscreenchange",{isFullscreen:!1}),this.el_.controls&&!this.options_.nativeControlsForTouch&&this.controls()&&(this.el_.controls=!1)},t=function(){"webkitPresentationMode"in this.el_&&this.el_.webkitPresentationMode!=="picture-in-picture"&&(this.one("webkitendfullscreen",e),this.trigger("fullscreenchange",{isFullscreen:!0,nativeIOSFullscreen:!0}))};this.on("webkitbeginfullscreen",t),this.on("dispose",()=>{this.off("webkitbeginfullscreen",t),this.off("webkitendfullscreen",e)})}supportsFullScreen(){return typeof this.el_.webkitEnterFullScreen=="function"}enterFullScreen(){const e=this.el_;if(e.paused&&e.networkState<=e.HAVE_METADATA)Gt(this.el_.play()),this.setTimeout(function(){e.pause();try{e.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}},0);else try{e.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}}exitFullScreen(){if(!this.el_.webkitDisplayingFullscreen){this.trigger("fullscreenerror",new Error("The video is not fullscreen"));return}this.el_.webkitExitFullScreen()}requestPictureInPicture(){return this.el_.requestPictureInPicture()}requestVideoFrameCallback(e){return this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.requestVideoFrameCallback(e):super.requestVideoFrameCallback(e)}cancelVideoFrameCallback(e){this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.cancelVideoFrameCallback(e):super.cancelVideoFrameCallback(e)}src(e){if(e===void 0)return this.el_.src;this.setSrc(e)}addSourceElement(e,t){if(!e)return le.error("Invalid source URL."),!1;const n={src:e};t&&(n.type=t);const s=ne("source",{},n);return this.el_.appendChild(s),!0}removeSourceElement(e){if(!e)return le.error("Source URL is required to remove the source element."),!1;const t=this.el_.querySelectorAll("source");for(const n of t)if(n.src===e)return this.el_.removeChild(n),!0;return le.warn(`No matching source element found with src: ${e}`),!1}reset(){J.resetMediaElement(this.el_)}currentSrc(){return this.currentSource_?this.currentSource_.src:this.el_.currentSrc}setControls(e){this.el_.controls=!!e}addTextTrack(e,t,n){return this.featuresNativeTextTracks?this.el_.addTextTrack(e,t,n):super.addTextTrack(e,t,n)}createRemoteTextTrack(e){if(!this.featuresNativeTextTracks)return super.createRemoteTextTrack(e);const t=G.createElement("track");return e.kind&&(t.kind=e.kind),e.label&&(t.label=e.label),(e.language||e.srclang)&&(t.srclang=e.language||e.srclang),e.default&&(t.default=e.default),e.id&&(t.id=e.id),e.src&&(t.src=e.src),t}addRemoteTextTrack(e,t){const n=super.addRemoteTextTrack(e,t);return this.featuresNativeTextTracks&&this.el().appendChild(n),n}removeRemoteTextTrack(e){if(super.removeRemoteTextTrack(e),this.featuresNativeTextTracks){const t=this.$$("track");let n=t.length;for(;n--;)(e===t[n]||e===t[n].track)&&this.el().removeChild(t[n])}}getVideoPlaybackQuality(){if(typeof this.el().getVideoPlaybackQuality=="function")return this.el().getVideoPlaybackQuality();const e={};return typeof this.el().webkitDroppedFrameCount<"u"&&typeof this.el().webkitDecodedFrameCount<"u"&&(e.droppedVideoFrames=this.el().webkitDroppedFrameCount,e.totalVideoFrames=this.el().webkitDecodedFrameCount),x.performance&&(e.creationTime=x.performance.now()),e}}Fr(J,"TEST_VID",function(){if(!En())return;const i=G.createElement("video"),e=G.createElement("track");return e.kind="captions",e.srclang="en",e.label="English",i.appendChild(e),i});J.isSupported=function(){try{J.TEST_VID.volume=.5}catch{return!1}return!!(J.TEST_VID&&J.TEST_VID.canPlayType)};J.canPlayType=function(i){return J.TEST_VID.canPlayType(i)};J.canPlaySource=function(i,e){return J.canPlayType(i.type)};J.canControlVolume=function(){try{const i=J.TEST_VID.volume;J.TEST_VID.volume=i/2+.1;const e=i!==J.TEST_VID.volume;return e&&Je?(x.setTimeout(()=>{J&&J.prototype&&(J.prototype.featuresVolumeControl=i!==J.TEST_VID.volume)}),!1):e}catch{return!1}};J.canMuteVolume=function(){try{const i=J.TEST_VID.muted;return J.TEST_VID.muted=!i,J.TEST_VID.muted?yn(J.TEST_VID,"muted","muted"):zr(J.TEST_VID,"muted","muted"),i!==J.TEST_VID.muted}catch{return!1}};J.canControlPlaybackRate=function(){if(Nt&&Jt&&jr<58)return!1;try{const i=J.TEST_VID.playbackRate;return J.TEST_VID.playbackRate=i/2+.1,i!==J.TEST_VID.playbackRate}catch{return!1}};J.canOverrideAttributes=function(){try{const i=()=>{};Object.defineProperty(G.createElement("video"),"src",{get:i,set:i}),Object.defineProperty(G.createElement("audio"),"src",{get:i,set:i}),Object.defineProperty(G.createElement("video"),"innerHTML",{get:i,set:i}),Object.defineProperty(G.createElement("audio"),"innerHTML",{get:i,set:i})}catch{return!1}return!0};J.supportsNativeTextTracks=function(){return Vr||Je&&Jt};J.supportsNativeVideoTracks=function(){return!!(J.TEST_VID&&J.TEST_VID.videoTracks)};J.supportsNativeAudioTracks=function(){return!!(J.TEST_VID&&J.TEST_VID.audioTracks)};J.Events=["loadstart","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","progress","play","pause","ratechange","resize","volumechange"];[["featuresMuteControl","canMuteVolume"],["featuresPlaybackRate","canControlPlaybackRate"],["featuresSourceset","canOverrideAttributes"],["featuresNativeTextTracks","supportsNativeTextTracks"],["featuresNativeVideoTracks","supportsNativeVideoTracks"],["featuresNativeAudioTracks","supportsNativeAudioTracks"]].forEach(function([i,e]){Fr(J.prototype,i,()=>J[e](),!0)});J.prototype.featuresVolumeControl=J.canControlVolume();J.prototype.movingMediaElementInDOM=!Je;J.prototype.featuresFullscreenResize=!0;J.prototype.featuresProgressEvents=!0;J.prototype.featuresTimeupdateEvents=!0;J.prototype.featuresVideoFrameCallback=!!(J.TEST_VID&&J.TEST_VID.requestVideoFrameCallback);J.disposeMediaElement=function(i){if(i){for(i.parentNode&&i.parentNode.removeChild(i);i.hasChildNodes();)i.removeChild(i.firstChild);i.removeAttribute("src"),typeof i.load=="function"&&function(){try{i.load()}catch{}}()}};J.resetMediaElement=function(i){if(!i)return;const e=i.querySelectorAll("source");let t=e.length;for(;t--;)i.removeChild(e[t]);i.removeAttribute("src"),typeof i.load=="function"&&function(){try{i.load()}catch{}}()};["muted","defaultMuted","autoplay","controls","loop","playsinline"].forEach(function(i){J.prototype[i]=function(){return this.el_[i]||this.el_.hasAttribute(i)}});["muted","defaultMuted","autoplay","loop","playsinline"].forEach(function(i){J.prototype["set"+Ne(i)]=function(e){this.el_[i]=e,e?this.el_.setAttribute(i,i):this.el_.removeAttribute(i)}});["paused","currentTime","buffered","volume","poster","preload","error","seeking","seekable","ended","playbackRate","defaultPlaybackRate","disablePictureInPicture","played","networkState","readyState","videoWidth","videoHeight","crossOrigin"].forEach(function(i){J.prototype[i]=function(){return this.el_[i]}});["volume","src","poster","preload","playbackRate","defaultPlaybackRate","disablePictureInPicture","crossOrigin"].forEach(function(i){J.prototype["set"+Ne(i)]=function(e){this.el_[i]=e}});["pause","load","play"].forEach(function(i){J.prototype[i]=function(){return this.el_[i]()}});ae.withSourceHandlers(J);J.nativeSourceHandler={};J.nativeSourceHandler.canPlayType=function(i){try{return J.TEST_VID.canPlayType(i)}catch{return""}};J.nativeSourceHandler.canHandleSource=function(i,e){if(i.type)return J.nativeSourceHandler.canPlayType(i.type);if(i.src){const t=Go(i.src);return J.nativeSourceHandler.canPlayType(`video/${t}`)}return""};J.nativeSourceHandler.handleSource=function(i,e,t){e.setSrc(i.src)};J.nativeSourceHandler.dispose=function(){};J.registerSourceHandler(J.nativeSourceHandler);ae.registerTech("Html5",J);const jc=["progress","abort","suspend","emptied","stalled","loadedmetadata","loadeddata","timeupdate","resize","volumechange","texttrackchange"],qa={canplay:"CanPlay",canplaythrough:"CanPlayThrough",playing:"Playing",seeked:"Seeked"},ao=["tiny","xsmall","small","medium","large","xlarge","huge"],nr={};ao.forEach(i=>{const e=i.charAt(0)==="x"?`x-${i.substring(1)}`:i;nr[i]=`vjs-layout-${e}`});const Yb={tiny:210,xsmall:320,small:425,medium:768,large:1440,xlarge:2560,huge:1/0};class Ae extends H{constructor(e,t,n){if(e.id=e.id||t.id||`vjs_video_${At()}`,t=Object.assign(Ae.getTagSettings(e),t),t.initChildren=!1,t.createEl=!1,t.evented=!1,t.reportTouchActivity=!1,!t.language){const a=e.closest("[lang]");a&&(t.language=a.getAttribute("lang"))}if(super(null,t,n),this.boundDocumentFullscreenChange_=a=>this.documentFullscreenChange_(a),this.boundFullWindowOnEscKey_=a=>this.fullWindowOnEscKey(a),this.boundUpdateStyleEl_=a=>this.updateStyleEl_(a),this.boundApplyInitTime_=a=>this.applyInitTime_(a),this.boundUpdateCurrentBreakpoint_=a=>this.updateCurrentBreakpoint_(a),this.boundHandleTechClick_=a=>this.handleTechClick_(a),this.boundHandleTechDoubleClick_=a=>this.handleTechDoubleClick_(a),this.boundHandleTechTouchStart_=a=>this.handleTechTouchStart_(a),this.boundHandleTechTouchMove_=a=>this.handleTechTouchMove_(a),this.boundHandleTechTouchEnd_=a=>this.handleTechTouchEnd_(a),this.boundHandleTechTap_=a=>this.handleTechTap_(a),this.boundUpdatePlayerHeightOnAudioOnlyMode_=a=>this.updatePlayerHeightOnAudioOnlyMode_(a),this.isFullscreen_=!1,this.log=Ch(this.id_),this.fsApi_=dr,this.isPosterFromTech_=!1,this.queuedCallbacks_=[],this.isReady_=!1,this.hasStarted_=!1,this.userActive_=!1,this.debugEnabled_=!1,this.audioOnlyMode_=!1,this.audioPosterMode_=!1,this.audioOnlyCache_={controlBarHeight:null,playerHeight:null,hiddenChildren:[]},!this.options_||!this.options_.techOrder||!this.options_.techOrder.length)throw new Error("No techOrder specified. Did you overwrite videojs.options instead of just changing the properties you want to override?");if(this.tag=e,this.tagAttributes=e&&_i(e),this.language(this.options_.language),t.languages){const a={};Object.getOwnPropertyNames(t.languages).forEach(function(l){a[l.toLowerCase()]=t.languages[l]}),this.languages_=a}else this.languages_=Ae.prototype.options_.languages;this.resetCache_(),this.poster_=t.poster||"",this.controls_=!!t.controls,e.controls=!1,e.removeAttribute("controls"),this.changingSrc_=!1,this.playCallbacks_=[],this.playTerminatedQueue_=[],e.hasAttribute("autoplay")?this.autoplay(!0):this.autoplay(this.options_.autoplay),t.plugins&&Object.keys(t.plugins).forEach(a=>{if(typeof this[a]!="function")throw new Error(`plugin "${a}" does not exist`)}),this.scrubbing_=!1,this.el_=this.createEl(),Vo(this,{eventBusKey:"el_"}),this.fsApi_.requestFullscreen&&(vt(G,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),this.on(this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_)),this.fluid_&&this.on(["playerreset","resize"],this.boundUpdateStyleEl_);const s=ve(this.options_);if(t.plugins&&Object.keys(t.plugins).forEach(a=>{this[a](t.plugins[a])}),t.debug&&this.debug(!0),this.options_.playerOptions=s,this.middleware_=[],this.playbackRates(t.playbackRates),t.experimentalSvgIcons){const a=new x.DOMParser().parseFromString(bb,"image/svg+xml");if(a.querySelector("parsererror"))le.warn("Failed to load SVG Icons. Falling back to Font Icons."),this.options_.experimentalSvgIcons=null;else{const l=a.documentElement;l.style.display="none",this.el_.appendChild(l),this.addClass("vjs-svg-icons-enabled")}}this.initChildren(),this.isAudio(e.nodeName.toLowerCase()==="audio"),this.controls()?this.addClass("vjs-controls-enabled"):this.addClass("vjs-controls-disabled"),this.el_.setAttribute("role","region"),this.isAudio()?this.el_.setAttribute("aria-label",this.localize("Audio Player")):this.el_.setAttribute("aria-label",this.localize("Video Player")),this.isAudio()&&this.addClass("vjs-audio"),t.spatialNavigation&&t.spatialNavigation.enabled&&(this.spatialNavigation=new Tb(this),this.addClass("vjs-spatial-navigation-enabled")),cs&&this.addClass("vjs-touch-enabled"),Je||this.addClass("vjs-workinghover"),Ae.players[this.id_]=this;const r=Ya.split(".")[0];this.addClass(`vjs-v${r}`),this.userActive(!0),this.reportUserActivity(),this.one("play",a=>this.listenForUserActivity_(a)),this.on("keydown",a=>this.handleKeyDown(a)),this.on("languagechange",a=>this.handleLanguagechange(a)),this.breakpoints(this.options_.breakpoints),this.responsive(this.options_.responsive),this.on("ready",()=>{this.audioPosterMode(this.options_.audioPosterMode),this.audioOnlyMode(this.options_.audioOnlyMode)})}dispose(){this.trigger("dispose"),this.off("dispose"),Ze(G,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),Ze(G,"keydown",this.boundFullWindowOnEscKey_),this.styleEl_&&this.styleEl_.parentNode&&(this.styleEl_.parentNode.removeChild(this.styleEl_),this.styleEl_=null),Ae.players[this.id_]=null,this.tag&&this.tag.player&&(this.tag.player=null),this.el_&&this.el_.player&&(this.el_.player=null),this.tech_&&(this.tech_.dispose(),this.isPosterFromTech_=!1,this.poster_=""),this.playerElIngest_&&(this.playerElIngest_=null),this.tag&&(this.tag=null),gb(this),at.names.forEach(e=>{const t=at[e],n=this[t.getterName]();n&&n.off&&n.off()}),super.dispose({restoreEl:this.options_.restoreEl})}createEl(){let e=this.tag,t,n=this.playerElIngest_=e.parentNode&&e.parentNode.hasAttribute&&e.parentNode.hasAttribute("data-vjs-player");const s=this.tag.tagName.toLowerCase()==="video-js";n?t=this.el_=e.parentNode:s||(t=this.el_=super.createEl("div"));const r=_i(e);if(s){for(t=this.el_=e,e=this.tag=G.createElement("video");t.children.length;)e.appendChild(t.firstChild);as(t,"video-js")||Bi(t,"video-js"),t.appendChild(e),n=this.playerElIngest_=t,Object.keys(t).forEach(c=>{try{e[c]=t[c]}catch{}})}e.setAttribute("tabindex","-1"),r.tabindex="-1",Jt&&$r&&(e.setAttribute("role","application"),r.role="application"),e.removeAttribute("width"),e.removeAttribute("height"),"width"in r&&delete r.width,"height"in r&&delete r.height,Object.getOwnPropertyNames(r).forEach(function(c){s&&c==="class"||t.setAttribute(c,r[c]),s&&e.setAttribute(c,r[c])}),e.playerId=e.id,e.id+="_html5_api",e.className="vjs-tech",e.player=t.player=this,this.addClass("vjs-paused");const a=["IS_SMART_TV","IS_TIZEN","IS_WEBOS","IS_ANDROID","IS_IPAD","IS_IPHONE","IS_CHROMECAST_RECEIVER"].filter(c=>Mh[c]).map(c=>"vjs-device-"+c.substring(3).toLowerCase().replace(/\_/g,"-"));if(this.addClass(...a),x.VIDEOJS_NO_DYNAMIC_STYLE!==!0){this.styleEl_=Kh("vjs-styles-dimensions");const c=vi(".vjs-styles-defaults"),g=vi("head");g.insertBefore(this.styleEl_,c?c.nextSibling:g.firstChild)}this.fill_=!1,this.fluid_=!1,this.width(this.options_.width),this.height(this.options_.height),this.fill(this.options_.fill),this.fluid(this.options_.fluid),this.aspectRatio(this.options_.aspectRatio),this.crossOrigin(this.options_.crossOrigin||this.options_.crossorigin);const l=e.getElementsByTagName("a");for(let c=0;c<l.length;c++){const g=l.item(c);Bi(g,"vjs-hidden"),g.setAttribute("hidden","hidden")}return e.initNetworkState_=e.networkState,e.parentNode&&!n&&e.parentNode.insertBefore(t,e),Ja(e,t),this.children_.unshift(e),this.el_.setAttribute("lang",this.language_),this.el_.setAttribute("translate","no"),this.el_=t,t}crossOrigin(e){if(typeof e>"u")return this.techGet_("crossOrigin");if(e!==null&&e!=="anonymous"&&e!=="use-credentials"){le.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`);return}this.techCall_("setCrossOrigin",e),this.posterImage&&this.posterImage.crossOrigin(e)}width(e){return this.dimension("width",e)}height(e){return this.dimension("height",e)}dimension(e,t){const n=e+"_";if(t===void 0)return this[n]||0;if(t===""||t==="auto"){this[n]=void 0,this.updateStyleEl_();return}const s=parseFloat(t);if(isNaN(s)){le.error(`Improper value "${t}" supplied for for ${e}`);return}this[n]=s,this.updateStyleEl_()}fluid(e){if(e===void 0)return!!this.fluid_;this.fluid_=!!e,si(this)&&this.off(["playerreset","resize"],this.boundUpdateStyleEl_),e?(this.addClass("vjs-fluid"),this.fill(!1),z1(this,()=>{this.on(["playerreset","resize"],this.boundUpdateStyleEl_)})):this.removeClass("vjs-fluid"),this.updateStyleEl_()}fill(e){if(e===void 0)return!!this.fill_;this.fill_=!!e,e?(this.addClass("vjs-fill"),this.fluid(!1)):this.removeClass("vjs-fill")}aspectRatio(e){if(e===void 0)return this.aspectRatio_;if(!/^\d+\:\d+$/.test(e))throw new Error("Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.");this.aspectRatio_=e,this.fluid(!0),this.updateStyleEl_()}updateStyleEl_(){if(x.VIDEOJS_NO_DYNAMIC_STYLE===!0){const l=typeof this.width_=="number"?this.width_:this.options_.width,c=typeof this.height_=="number"?this.height_:this.options_.height,g=this.tech_&&this.tech_.el();g&&(l>=0&&(g.width=l),c>=0&&(g.height=c));return}let e,t,n,s;this.aspectRatio_!==void 0&&this.aspectRatio_!=="auto"?n=this.aspectRatio_:this.videoWidth()>0?n=this.videoWidth()+":"+this.videoHeight():n="16:9";const r=n.split(":"),a=r[1]/r[0];this.width_!==void 0?e=this.width_:this.height_!==void 0?e=this.height_/a:e=this.videoWidth()||300,this.height_!==void 0?t=this.height_:t=e*a,/^[^a-zA-Z]/.test(this.id())?s="dimensions-"+this.id():s=this.id()+"-dimensions",this.addClass(s),Yh(this.styleEl_,`
|
|
166
|
+
</svg>`;const Hu=pr?10009:gr?461:8,Ji={codes:{play:415,pause:19,ff:417,rw:412,back:Hu},names:{415:"play",19:"pause",417:"ff",412:"rw",[Hu]:"back"},isEventKey(i,e){return e=e.toLowerCase(),!!(this.names[i.keyCode]&&this.names[i.keyCode]===e)},getEventName(i){if(this.names[i.keyCode])return this.names[i.keyCode];if(this.codes[i.code]){const e=this.codes[i.code];return this.names[e]}return null}},zu=5;class db extends St{constructor(e){super(),this.player_=e,this.focusableComponents=[],this.isListening_=!1,this.isPaused_=!1,this.onKeyDown_=this.onKeyDown_.bind(this),this.lastFocusedComponent_=null}start(){this.isListening_||(this.player_.on("keydown",this.onKeyDown_),this.player_.on("modalKeydown",this.onKeyDown_),this.player_.on("loadedmetadata",()=>{this.focus(this.updateFocusableComponents()[0])}),this.player_.on("modalclose",()=>{this.refocusComponent()}),this.player_.on("focusin",this.handlePlayerFocus_.bind(this)),this.player_.on("focusout",this.handlePlayerBlur_.bind(this)),this.isListening_=!0,this.player_.errorDisplay&&this.player_.errorDisplay.on("aftermodalfill",()=>{this.updateFocusableComponents(),this.focusableComponents.length&&(this.focusableComponents.length>1?this.focusableComponents[1].focus():this.focusableComponents[0].focus())}))}stop(){this.player_.off("keydown",this.onKeyDown_),this.isListening_=!1}onKeyDown_(e){const t=e.originalEvent?e.originalEvent:e;if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(t.key)){if(this.isPaused_)return;t.preventDefault();const n=t.key.substring(5).toLowerCase();this.move(n)}else if(Ji.isEventKey(t,"play")||Ji.isEventKey(t,"pause")||Ji.isEventKey(t,"ff")||Ji.isEventKey(t,"rw")){t.preventDefault();const n=Ji.getEventName(t);this.performMediaAction_(n)}else Ji.isEventKey(t,"Back")&&e.target&&typeof e.target.closeable=="function"&&e.target.closeable()&&(t.preventDefault(),e.target.close())}performMediaAction_(e){if(this.player_)switch(e){case"play":this.player_.paused()&&this.player_.play();break;case"pause":this.player_.paused()||this.player_.pause();break;case"ff":this.userSeek_(this.player_.currentTime()+zu);break;case"rw":this.userSeek_(this.player_.currentTime()-zu);break}}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}pause(){this.isPaused_=!0}resume(){this.isPaused_=!1}handlePlayerBlur_(e){const t=e.relatedTarget;let n=null;const s=this.getCurrentComponent(e.target);t&&(n=!!t.closest(".video-js"),t.classList.contains("vjs-text-track-settings")&&!this.isPaused_&&this.searchForTrackSelect_()),(!e.currentTarget.contains(e.relatedTarget)&&!n||!t)&&(s&&s.name()==="CloseButton"?this.refocusComponent():(this.pause(),s&&s.el()&&(this.lastFocusedComponent_=s)))}handlePlayerFocus_(){this.getCurrentComponent()&&this.getCurrentComponent().getIsFocusable()&&this.resume()}updateFocusableComponents(){const e=this.player_,t=[];function n(s){for(const r of s)r.hasOwnProperty("el_")&&r.getIsFocusable()&&r.getIsAvailableToBeFocused(r.el())&&t.push(r),r.hasOwnProperty("children_")&&r.children_.length>0&&n(r.children_)}return e.children_.forEach(s=>{if(s.hasOwnProperty("el_"))if(s.getIsFocusable&&s.getIsAvailableToBeFocused&&s.getIsFocusable()&&s.getIsAvailableToBeFocused(s.el())){t.push(s);return}else s.hasOwnProperty("children_")&&s.children_.length>0?n(s.children_):s.hasOwnProperty("items")&&s.items.length>0?n(s.items):this.findSuitableDOMChild(s)&&t.push(s);if(s.name_==="ErrorDisplay"&&s.opened_){const r=s.el_.querySelector(".vjs-errors-ok-button-container");r&&r.querySelectorAll("button").forEach((a,l)=>{t.push({name:()=>"ModalButton"+(l+1),el:()=>a,getPositions:()=>{const c=a.getBoundingClientRect(),f={x:c.x,y:c.y,width:c.width,height:c.height,top:c.top,right:c.right,bottom:c.bottom,left:c.left},m={x:c.left+c.width/2,y:c.top+c.height/2,width:0,height:0,top:c.top+c.height/2,right:c.left+c.width/2,bottom:c.top+c.height/2,left:c.left+c.width/2};return{boundingClientRect:f,center:m}},getIsAvailableToBeFocused:()=>!0,getIsFocusable:c=>!0,focus:()=>a.focus()})})}}),this.focusableComponents=t,this.focusableComponents}findSuitableDOMChild(e){function t(n){if(e.getIsFocusable(n)&&e.getIsAvailableToBeFocused(n))return n;for(let s=0;s<n.children.length;s++){const r=n.children[s],a=t(r);if(a)return a}return null}return e.el()?t(e.el()):null}getCurrentComponent(e){this.updateFocusableComponents();const t=e||document.activeElement;if(this.focusableComponents.length){for(const n of this.focusableComponents)if(n.el()===t)return n}}add(e){const t=[...this.focusableComponents];e.hasOwnProperty("el_")&&e.getIsFocusable()&&e.getIsAvailableToBeFocused(e.el())&&t.push(e),this.focusableComponents=t,this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents})}remove(e){for(let t=0;t<this.focusableComponents.length;t++)if(this.focusableComponents[t].name()===e.name()){this.focusableComponents.splice(t,1),this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents});return}}clear(){this.focusableComponents.length>0&&(this.focusableComponents=[],this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents}))}move(e){const t=this.getCurrentComponent();if(!t)return;const n=t.getPositions(),s=this.focusableComponents.filter(a=>a!==t&&this.isInDirection_(n.boundingClientRect,a.getPositions().boundingClientRect,e)),r=this.findBestCandidate_(n.center,s,e);r?this.focus(r):this.trigger({type:"endOfFocusableComponents",direction:e,focusedComponent:t})}findBestCandidate_(e,t,n){let s=1/0,r=null;for(const a of t){const l=a.getPositions().center,c=this.calculateDistance_(e,l,n);c<s&&(s=c,r=a)}return r}isInDirection_(e,t,n){switch(n){case"right":return t.left>=e.right;case"left":return t.right<=e.left;case"down":return t.top>=e.bottom;case"up":return t.bottom<=e.top;default:return!1}}refocusComponent(){if(this.lastFocusedComponent_){this.player_.userActive()||this.player_.userActive(!0),this.updateFocusableComponents();for(let e=0;e<this.focusableComponents.length;e++)if(this.focusableComponents[e].name()===this.lastFocusedComponent_.name()){this.focus(this.focusableComponents[e]);return}}else this.focus(this.updateFocusableComponents()[0])}focus(e){typeof e=="object"&&(e.getIsAvailableToBeFocused(e.el())?e.focus():this.findSuitableDOMChild(e)&&this.findSuitableDOMChild(e).focus())}calculateDistance_(e,t,n){const s=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y);let a;switch(n){case"right":case"left":a=s+r*100;break;case"up":a=r*2+s*.5;break;case"down":a=r*5+s;break;default:a=s+r}return a}searchForTrackSelect_(){const e=this;for(const t of e.updateFocusableComponents())if(t.constructor.name==="TextTrackSelect"){e.focus(t);break}}}class hb extends H{constructor(e,t,n){const s=ve({createEl:!1},t);if(super(e,s,n),!t.playerOptions.sources||t.playerOptions.sources.length===0)for(let r=0,a=t.playerOptions.techOrder;r<a.length;r++){const l=Ne(a[r]);let c=ae.getTech(l);if(l||(c=H.getComponent(l)),c&&c.isSupported()){e.loadTech_(l);break}}else e.src(t.playerOptions.sources)}}H.registerComponent("MediaLoader",hb);class Jr extends H{constructor(e,t){super(e,t),this.options_.controlText&&this.controlText(this.options_.controlText),this.handleMouseOver_=n=>this.handleMouseOver(n),this.handleMouseOut_=n=>this.handleMouseOut(n),this.handleClick_=n=>this.handleClick(n),this.handleKeyDown_=n=>this.handleKeyDown(n),this.emitTapEvents(),this.enable()}createEl(e="div",t={},n={}){t=Object.assign({className:this.buildCSSClass(),tabIndex:0},t),e==="button"&&oe.error(`Creating a ClickableComponent with an HTML element of ${e} is not supported; use a Button instead.`),n=Object.assign({role:"button"},n),this.tabIndex_=t.tabIndex;const s=ne(e,t,n);return this.player_.options_.experimentalSvgIcons||s.appendChild(ne("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(s),s}dispose(){this.controlTextEl_=null,super.dispose()}createControlTextEl(e){return this.controlTextEl_=ne("span",{className:"vjs-control-text"},{"aria-live":"polite"}),e&&e.appendChild(this.controlTextEl_),this.controlText(this.controlText_,e),this.controlTextEl_}controlText(e,t=this.el()){if(e===void 0)return this.controlText_||"Need Text";const n=this.localize(e);this.controlText_=e,Si(this.controlTextEl_,n),!this.nonIconControl&&!this.player_.options_.noUITitleAttributes&&t.setAttribute("title",n)}buildCSSClass(){return`vjs-control vjs-button ${super.buildCSSClass()}`}enable(){this.enabled_||(this.enabled_=!0,this.removeClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","false"),typeof this.tabIndex_<"u"&&this.el_.setAttribute("tabIndex",this.tabIndex_),this.on(["tap","click"],this.handleClick_),this.on("keydown",this.handleKeyDown_))}disable(){this.enabled_=!1,this.addClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","true"),typeof this.tabIndex_<"u"&&this.el_.removeAttribute("tabIndex"),this.off("mouseover",this.handleMouseOver_),this.off("mouseout",this.handleMouseOut_),this.off(["tap","click"],this.handleClick_),this.off("keydown",this.handleKeyDown_)}handleLanguagechange(){this.controlText(this.controlText_)}handleClick(e){this.options_.clickHandler&&this.options_.clickHandler.call(this,arguments)}handleKeyDown(e){e.key===" "||e.key==="Enter"?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}}H.registerComponent("ClickableComponent",Jr);class no extends Jr{constructor(e,t){super(e,t),this.update(),this.update_=n=>this.update(n),e.on("posterchange",this.update_)}dispose(){this.player().off("posterchange",this.update_),super.dispose()}createEl(){return ne("div",{className:"vjs-poster"})}crossOrigin(e){if(typeof e>"u")return this.$("img")?this.$("img").crossOrigin:this.player_.tech_&&this.player_.tech_.isReady_?this.player_.crossOrigin():this.player_.options_.crossOrigin||this.player_.options_.crossorigin||null;if(e!==null&&e!=="anonymous"&&e!=="use-credentials"){this.player_.log.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`);return}this.$("img")&&(this.$("img").crossOrigin=e)}update(e){const t=this.player().poster();this.setSrc(t),t?this.show():this.hide()}setSrc(e){if(!e){this.el_.textContent="";return}this.$("img")||this.el_.appendChild(ne("picture",{className:"vjs-poster",tabIndex:-1},{},ne("img",{loading:"lazy",crossOrigin:this.crossOrigin()},{alt:""}))),this.$("img").src=e}handleClick(e){this.player_.controls()&&(this.player_.tech(!0)&&this.player_.tech(!0).focus(),this.player_.paused()?Gt(this.player_.play()):this.player_.pause())}}no.prototype.crossorigin=no.prototype.crossOrigin;H.registerComponent("PosterImage",no);const Ct="#222",Wu="#ccc",cb={monospace:"monospace",sansSerif:"sans-serif",serif:"serif",monospaceSansSerif:'"Andale Mono", "Lucida Console", monospace',monospaceSerif:'"Courier New", monospace',proportionalSansSerif:"sans-serif",proportionalSerif:"serif",casual:'"Comic Sans MS", Impact, fantasy',script:'"Monotype Corsiva", cursive',smallcaps:'"Andale Mono", "Lucida Console", monospace, sans-serif'};function Ua(i,e){let t;if(i.length===4)t=i[1]+i[1]+i[2]+i[2]+i[3]+i[3];else if(i.length===7)t=i.slice(1);else throw new Error("Invalid color code provided, "+i+"; must be formatted as e.g. #f0e or #f604e2.");return"rgba("+parseInt(t.slice(0,2),16)+","+parseInt(t.slice(2,4),16)+","+parseInt(t.slice(4,6),16)+","+e+")"}function Vt(i,e,t){try{i.style[e]=t}catch{return}}function Gu(i){return i?`${i}px`:""}class pb extends H{constructor(e,t,n){super(e,t,n);const s=a=>this.updateDisplay(a),r=a=>{this.updateDisplayOverlay(),this.updateDisplay(a)};e.on("loadstart",a=>this.toggleDisplay(a)),e.on("texttrackchange",s),e.on("loadedmetadata",a=>{this.updateDisplayOverlay(),this.preselectTrack(a)}),e.ready(Ce(this,function(){if(e.tech_&&e.tech_.featuresNativeTextTracks){this.hide();return}e.on("fullscreenchange",r),e.on("playerresize",r);const a=x.screen.orientation||x,l=x.screen.orientation?"change":"orientationchange";a.addEventListener(l,r),e.on("dispose",()=>a.removeEventListener(l,r));const c=this.options_.playerOptions.tracks||[];for(let f=0;f<c.length;f++)this.player_.addRemoteTextTrack(c[f],!0);this.preselectTrack()}))}preselectTrack(){const e={captions:1,subtitles:1},t=this.player_.textTracks(),n=this.player_.cache_.selectedLanguage;let s,r,a;for(let l=0;l<t.length;l++){const c=t[l];n&&n.enabled&&n.language&&n.language===c.language&&c.kind in e?c.kind===n.kind?a=c:a||(a=c):n&&!n.enabled?(a=null,s=null,r=null):c.default&&(c.kind==="descriptions"&&!s?s=c:c.kind in e&&!r&&(r=c))}a?a.mode="showing":r?r.mode="showing":s&&(s.mode="showing")}toggleDisplay(){this.player_.tech_&&this.player_.tech_.featuresNativeTextTracks?this.hide():this.show()}createEl(){return super.createEl("div",{className:"vjs-text-track-display"},{translate:"yes","aria-live":"off","aria-atomic":"true"})}clearDisplay(){typeof x.WebVTT=="function"&&x.WebVTT.processCues(x,[],this.el_)}updateDisplay(){const e=this.player_.textTracks(),t=this.options_.allowMultipleShowingTracks;if(this.clearDisplay(),t){const a=[];for(let l=0;l<e.length;++l){const c=e[l];c.mode==="showing"&&a.push(c)}this.updateForTrack(a);return}let n=null,s=null,r=e.length;for(;r--;){const a=e[r];a.mode==="showing"&&(a.kind==="descriptions"?n=a:s=a)}if(s?(this.getAttribute("aria-live")!=="off"&&this.setAttribute("aria-live","off"),this.updateForTrack(s)):n&&(this.getAttribute("aria-live")!=="assertive"&&this.setAttribute("aria-live","assertive"),this.updateForTrack(n)),!x.CSS.supports("inset","10px")){const a=this.el_,l=a.querySelectorAll(".vjs-text-track-cue"),c=this.player_.controlBar.el_.getBoundingClientRect().height,f=this.player_.el_.getBoundingClientRect().height;a.style="",Vt(a,"position","relative"),Vt(a,"height",f-c+"px"),Vt(a,"top","unset"),fr?Vt(a,"bottom",f+"px"):Vt(a,"bottom","0px"),l.length>0&&l.forEach(m=>{if(m.style.inset){const b=m.style.inset.split(" ");b.length===3&&Object.assign(m.style,{top:b[0],right:b[1],bottom:b[2],left:"unset"})}})}}updateDisplayOverlay(){if(!this.player_.videoHeight()||!x.CSS.supports("inset-inline: 10px"))return;const e=this.player_.currentWidth(),t=this.player_.currentHeight(),n=e/t,s=this.player_.videoWidth()/this.player_.videoHeight();let r=0,a=0;Math.abs(n-s)>.1&&(n>s?r=Math.round((e-t*s)/2):a=Math.round((t-e/s)/2)),Vt(this.el_,"insetInline",Gu(r)),Vt(this.el_,"insetBlock",Gu(a))}updateDisplayState(e){const t=this.player_.textTrackSettings.getValues(),n=e.activeCues;let s=n.length;for(;s--;){const r=n[s];if(!r)continue;const a=r.displayState;if(t.color&&(a.firstChild.style.color=t.color),t.textOpacity&&Vt(a.firstChild,"color",Ua(t.color||"#fff",t.textOpacity)),t.backgroundColor&&(a.firstChild.style.backgroundColor=t.backgroundColor),t.backgroundOpacity&&Vt(a.firstChild,"backgroundColor",Ua(t.backgroundColor||"#000",t.backgroundOpacity)),t.windowColor&&(t.windowOpacity?Vt(a,"backgroundColor",Ua(t.windowColor,t.windowOpacity)):a.style.backgroundColor=t.windowColor),t.edgeStyle&&(t.edgeStyle==="dropshadow"?a.firstChild.style.textShadow=`2px 2px 3px ${Ct}, 2px 2px 4px ${Ct}, 2px 2px 5px ${Ct}`:t.edgeStyle==="raised"?a.firstChild.style.textShadow=`1px 1px ${Ct}, 2px 2px ${Ct}, 3px 3px ${Ct}`:t.edgeStyle==="depressed"?a.firstChild.style.textShadow=`1px 1px ${Wu}, 0 1px ${Wu}, -1px -1px ${Ct}, 0 -1px ${Ct}`:t.edgeStyle==="uniform"&&(a.firstChild.style.textShadow=`0 0 4px ${Ct}, 0 0 4px ${Ct}, 0 0 4px ${Ct}, 0 0 4px ${Ct}`)),t.fontPercent&&t.fontPercent!==1){const l=x.parseFloat(a.style.fontSize);a.style.fontSize=l*t.fontPercent+"px",a.style.height="auto",a.style.top="auto"}t.fontFamily&&t.fontFamily!=="default"&&(t.fontFamily==="small-caps"?a.firstChild.style.fontVariant="small-caps":a.firstChild.style.fontFamily=cb[t.fontFamily])}}updateForTrack(e){if(Array.isArray(e)||(e=[e]),typeof x.WebVTT!="function"||e.every(n=>!n.activeCues))return;const t=[];for(let n=0;n<e.length;++n){const s=e[n];for(let r=0;r<s.activeCues.length;++r)t.push(s.activeCues[r])}x.WebVTT.processCues(x,t,this.el_);for(let n=0;n<e.length;++n){const s=e[n];for(let r=0;r<s.activeCues.length;++r){const a=s.activeCues[r].displayState;Bi(a,"vjs-text-track-cue","vjs-text-track-cue-"+(s.language?s.language:n)),s.language&&yn(a,"lang",s.language)}this.player_.textTrackSettings&&this.updateDisplayState(s)}}}H.registerComponent("TextTrackDisplay",pb);class gb extends H{createEl(){const e=this.player_.isAudio(),t=this.localize(e?"Audio Player":"Video Player"),n=ne("span",{className:"vjs-control-text",textContent:this.localize("{1} is loading.",[t])}),s=super.createEl("div",{className:"vjs-loading-spinner",dir:"ltr"});return s.appendChild(n),s}handleLanguagechange(){this.$(".vjs-control-text").textContent=this.localize("{1} is loading.",[this.player_.isAudio()?"Audio Player":"Video Player"])}}H.registerComponent("LoadingSpinner",gb);class et extends Jr{createEl(e,t={},n={}){e="button",t=Object.assign({className:this.buildCSSClass()},t),n=Object.assign({type:"button"},n);const s=ne(e,t,n);return this.player_.options_.experimentalSvgIcons||s.appendChild(ne("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(s),s}addChild(e,t={}){const n=this.constructor.name;return oe.warn(`Adding an actionable (user controllable) child to a Button (${n}) is not supported; use a ClickableComponent instead.`),H.prototype.addChild.call(this,e,t)}enable(){super.enable(),this.el_.removeAttribute("disabled")}disable(){super.disable(),this.el_.setAttribute("disabled","disabled")}handleKeyDown(e){if(e.key===" "||e.key==="Enter"){e.stopPropagation();return}super.handleKeyDown(e)}}H.registerComponent("Button",et);class lc extends et{constructor(e,t){super(e,t),this.mouseused_=!1,this.setIcon("play"),this.on("mousedown",n=>this.handleMouseDown(n))}buildCSSClass(){return"vjs-big-play-button"}handleClick(e){const t=this.player_.play();if(this.mouseused_&&"clientX"in e&&"clientY"in e){Gt(t),this.player_.tech(!0)&&this.player_.tech(!0).focus();return}const n=this.player_.getChild("controlBar"),s=n&&n.getChild("playToggle");if(!s){this.player_.tech(!0).focus();return}const r=()=>s.focus();us(t)?t.then(r,()=>{}):this.setTimeout(r,1)}handleKeyDown(e){this.mouseused_=!1,super.handleKeyDown(e)}handleMouseDown(e){this.mouseused_=!0}}lc.prototype.controlText_="Play Video";H.registerComponent("BigPlayButton",lc);class fb extends et{constructor(e,t){super(e,t),this.setIcon("cancel"),this.controlText(t&&t.controlText||this.localize("Close"))}buildCSSClass(){return`vjs-close-button ${super.buildCSSClass()}`}handleClick(e){this.trigger({type:"close",bubbles:!1})}handleKeyDown(e){e.key==="Escape"?(e.preventDefault(),e.stopPropagation(),this.trigger("click")):super.handleKeyDown(e)}}H.registerComponent("CloseButton",fb);class uc extends et{constructor(e,t={}){super(e,t),t.replay=t.replay===void 0||t.replay,this.setIcon("play"),this.on(e,"play",n=>this.handlePlay(n)),this.on(e,"pause",n=>this.handlePause(n)),t.replay&&this.on(e,"ended",n=>this.handleEnded(n))}buildCSSClass(){return`vjs-play-control ${super.buildCSSClass()}`}handleClick(e){this.player_.paused()?Gt(this.player_.play()):this.player_.pause()}handleSeeked(e){this.removeClass("vjs-ended"),this.player_.paused()?this.handlePause(e):this.handlePlay(e)}handlePlay(e){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.setIcon("pause"),this.controlText("Pause")}handlePause(e){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.setIcon("play"),this.controlText("Play")}handleEnded(e){this.removeClass("vjs-playing"),this.addClass("vjs-ended"),this.setIcon("replay"),this.controlText("Replay"),this.one(this.player_,"seeked",t=>this.handleSeeked(t))}}uc.prototype.controlText_="Play";H.registerComponent("PlayToggle",uc);class In extends H{constructor(e,t){super(e,t),this.on(e,["timeupdate","ended","seeking"],n=>this.update(n)),this.updateTextNode_()}createEl(){const e=this.buildCSSClass(),t=super.createEl("div",{className:`${e} vjs-time-control vjs-control`}),n=ne("span",{className:"vjs-control-text",textContent:`${this.localize(this.labelText_)} `},{role:"presentation"});return t.appendChild(n),this.contentEl_=ne("span",{className:`${e}-display`},{role:"presentation"}),t.appendChild(this.contentEl_),t}dispose(){this.contentEl_=null,this.textNode_=null,super.dispose()}update(e){!this.player_.options_.enableSmoothSeeking&&e.type==="seeking"||this.updateContent(e)}updateTextNode_(e=0){e=qi(e),this.formattedTime_!==e&&(this.formattedTime_=e,this.requestNamedAnimationFrame("TimeDisplay#updateTextNode_",()=>{if(!this.contentEl_)return;let t=this.textNode_;t&&this.contentEl_.firstChild!==t&&(t=null,oe.warn("TimeDisplay#updateTextnode_: Prevented replacement of text node element since it was no longer a child of this node. Appending a new node instead.")),this.textNode_=G.createTextNode(this.formattedTime_),this.textNode_&&(t?this.contentEl_.replaceChild(this.textNode_,t):this.contentEl_.appendChild(this.textNode_))}))}updateContent(e){}}In.prototype.labelText_="Time";In.prototype.controlText_="Time";H.registerComponent("TimeDisplay",In);class Xo extends In{buildCSSClass(){return"vjs-current-time"}updateContent(e){let t;this.player_.ended()?t=this.player_.duration():t=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime(),this.updateTextNode_(t)}}Xo.prototype.labelText_="Current Time";Xo.prototype.controlText_="Current Time";H.registerComponent("CurrentTimeDisplay",Xo);let Ko=class extends In{constructor(e,t){super(e,t);const n=s=>this.updateContent(s);this.on(e,"durationchange",n),this.on(e,"loadstart",n),this.on(e,"loadedmetadata",n)}buildCSSClass(){return"vjs-duration"}updateContent(e){const t=this.player_.duration();this.updateTextNode_(t)}};Ko.prototype.labelText_="Duration";Ko.prototype.controlText_="Duration";H.registerComponent("DurationDisplay",Ko);class mb extends H{createEl(){const e=super.createEl("div",{className:"vjs-time-control vjs-time-divider"},{"aria-hidden":!0}),t=super.createEl("div"),n=super.createEl("span",{textContent:"/"});return t.appendChild(n),e.appendChild(t),e}}H.registerComponent("TimeDivider",mb);class Yo extends In{constructor(e,t){super(e,t),this.on(e,"durationchange",n=>this.updateContent(n))}buildCSSClass(){return"vjs-remaining-time"}createEl(){const e=super.createEl();return this.options_.displayNegative!==!1&&e.insertBefore(ne("span",{},{"aria-hidden":!0},"-"),this.contentEl_),e}updateContent(e){if(typeof this.player_.duration()!="number")return;let t;this.player_.ended()?t=0:this.player_.remainingTimeDisplay?t=this.player_.remainingTimeDisplay():t=this.player_.remainingTime(),this.updateTextNode_(t)}}Yo.prototype.labelText_="Remaining Time";Yo.prototype.controlText_="Remaining Time";H.registerComponent("RemainingTimeDisplay",Yo);class yb extends H{constructor(e,t){super(e,t),this.updateShowing(),this.on(this.player(),"durationchange",n=>this.updateShowing(n))}createEl(){const e=super.createEl("div",{className:"vjs-live-control vjs-control"});return this.contentEl_=ne("div",{className:"vjs-live-display"},{"aria-live":"off"}),this.contentEl_.appendChild(ne("span",{className:"vjs-control-text",textContent:`${this.localize("Stream Type")} `})),this.contentEl_.appendChild(G.createTextNode(this.localize("LIVE"))),e.appendChild(this.contentEl_),e}dispose(){this.contentEl_=null,super.dispose()}updateShowing(e){this.player().duration()===1/0?this.show():this.hide()}}H.registerComponent("LiveDisplay",yb);class dc extends et{constructor(e,t){super(e,t),this.updateLiveEdgeStatus(),this.player_.liveTracker&&(this.updateLiveEdgeStatusHandler_=n=>this.updateLiveEdgeStatus(n),this.on(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_))}createEl(){const e=super.createEl("button",{className:"vjs-seek-to-live-control vjs-control"});return this.setIcon("circle",e),this.textEl_=ne("span",{className:"vjs-seek-to-live-text",textContent:this.localize("LIVE")},{"aria-hidden":"true"}),e.appendChild(this.textEl_),e}updateLiveEdgeStatus(){!this.player_.liveTracker||this.player_.liveTracker.atLiveEdge()?(this.setAttribute("aria-disabled",!0),this.addClass("vjs-at-live-edge"),this.controlText("Seek to live, currently playing live")):(this.setAttribute("aria-disabled",!1),this.removeClass("vjs-at-live-edge"),this.controlText("Seek to live, currently behind live"))}handleClick(){this.player_.liveTracker.seekToLiveEdge()}dispose(){this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_),this.textEl_=null,super.dispose()}}dc.prototype.controlText_="Seek to live, currently playing live";H.registerComponent("SeekToLive",dc);function bs(i,e,t){return i=Number(i),Math.min(t,Math.max(e,isNaN(i)?e:i))}var _b=Object.freeze({__proto__:null,clamp:bs});class Qo extends H{constructor(e,t){super(e,t),this.handleMouseDown_=n=>this.handleMouseDown(n),this.handleMouseUp_=n=>this.handleMouseUp(n),this.handleKeyDown_=n=>this.handleKeyDown(n),this.handleClick_=n=>this.handleClick(n),this.handleMouseMove_=n=>this.handleMouseMove(n),this.update_=n=>this.update(n),this.bar=this.getChild(this.options_.barName),this.vertical(!!this.options_.vertical),this.enable()}enabled(){return this.enabled_}enable(){this.enabled()||(this.on("mousedown",this.handleMouseDown_),this.on("touchstart",this.handleMouseDown_),this.on("keydown",this.handleKeyDown_),this.on("click",this.handleClick_),this.on(this.player_,"controlsvisible",this.update),this.playerEvent&&this.on(this.player_,this.playerEvent,this.update),this.removeClass("disabled"),this.setAttribute("tabindex",0),this.enabled_=!0)}disable(){if(!this.enabled())return;const e=this.bar.el_.ownerDocument;this.off("mousedown",this.handleMouseDown_),this.off("touchstart",this.handleMouseDown_),this.off("keydown",this.handleKeyDown_),this.off("click",this.handleClick_),this.off(this.player_,"controlsvisible",this.update_),this.off(e,"mousemove",this.handleMouseMove_),this.off(e,"mouseup",this.handleMouseUp_),this.off(e,"touchmove",this.handleMouseMove_),this.off(e,"touchend",this.handleMouseUp_),this.removeAttribute("tabindex"),this.addClass("disabled"),this.playerEvent&&this.off(this.player_,this.playerEvent,this.update),this.enabled_=!1}createEl(e,t={},n={}){return t.className=t.className+" vjs-slider",t=Object.assign({tabIndex:0},t),n=Object.assign({role:"slider","aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100},n),super.createEl(e,t,n)}handleMouseDown(e){const t=this.bar.el_.ownerDocument;e.type==="mousedown"&&e.preventDefault(),e.type==="touchstart"&&!Jt&&e.preventDefault(),Nh(),this.addClass("vjs-sliding"),this.trigger("slideractive"),this.on(t,"mousemove",this.handleMouseMove_),this.on(t,"mouseup",this.handleMouseUp_),this.on(t,"touchmove",this.handleMouseMove_),this.on(t,"touchend",this.handleMouseUp_),this.handleMouseMove(e,!0)}handleMouseMove(e){}handleMouseUp(e){const t=this.bar.el_.ownerDocument;Bh(),this.removeClass("vjs-sliding"),this.trigger("sliderinactive"),this.off(t,"mousemove",this.handleMouseMove_),this.off(t,"mouseup",this.handleMouseUp_),this.off(t,"touchmove",this.handleMouseMove_),this.off(t,"touchend",this.handleMouseUp_),this.update()}update(){if(!this.el_||!this.bar)return;const e=this.getProgress();return e===this.progress_||(this.progress_=e,this.requestNamedAnimationFrame("Slider#update",()=>{const t=this.vertical()?"height":"width";this.bar.el().style[t]=(e*100).toFixed(2)+"%"})),e}getProgress(){return Number(bs(this.getPercent(),0,1).toFixed(4))}calculateDistance(e){const t=Wr(this.el_,e);return this.vertical()?t.y:t.x}handleKeyDown(e){const t=this.options_.playerOptions.spatialNavigation,n=t&&t.enabled,s=t&&t.horizontalSeek;n?s&&e.key==="ArrowLeft"||!s&&e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepBack()):s&&e.key==="ArrowRight"||!s&&e.key==="ArrowUp"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):super.handleKeyDown(e):e.key==="ArrowLeft"||e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepBack()):e.key==="ArrowUp"||e.key==="ArrowRight"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):super.handleKeyDown(e)}handleClick(e){e.stopPropagation(),e.preventDefault()}vertical(e){if(e===void 0)return this.vertical_||!1;this.vertical_=!!e,this.vertical_?this.addClass("vjs-slider-vertical"):this.addClass("vjs-slider-horizontal")}}H.registerComponent("Slider",Qo);const Na=(i,e)=>bs(i/e*100,0,100).toFixed(2)+"%";class bb extends H{constructor(e,t){super(e,t),this.partEls_=[],this.on(e,"progress",n=>this.update(n))}createEl(){const e=super.createEl("div",{className:"vjs-load-progress"}),t=ne("span",{className:"vjs-control-text"}),n=ne("span",{textContent:this.localize("Loaded")}),s=G.createTextNode(": ");return this.percentageEl_=ne("span",{className:"vjs-control-text-loaded-percentage",textContent:"0%"}),e.appendChild(t),t.appendChild(n),t.appendChild(s),t.appendChild(this.percentageEl_),e}dispose(){this.partEls_=null,this.percentageEl_=null,super.dispose()}update(e){this.requestNamedAnimationFrame("LoadProgressBar#update",()=>{const t=this.player_.liveTracker,n=this.player_.buffered(),s=t&&t.isLive()?t.seekableEnd():this.player_.duration(),r=this.player_.bufferedEnd(),a=this.partEls_,l=Na(r,s);this.percent_!==l&&(this.el_.style.width=l,Si(this.percentageEl_,l),this.percent_=l);for(let c=0;c<n.length;c++){const f=n.start(c),m=n.end(c);let b=a[c];b||(b=this.el_.appendChild(ne()),a[c]=b),!(b.dataset.start===f&&b.dataset.end===m)&&(b.dataset.start=f,b.dataset.end=m,b.style.left=Na(f,r),b.style.width=Na(m-f,r))}for(let c=a.length;c>n.length;c--)this.el_.removeChild(a[c-1]);a.length=n.length})}}H.registerComponent("LoadProgressBar",bb);class Tb extends H{constructor(e,t){super(e,t),this.update=Zt(Ce(this,this.update),Pt)}createEl(){return super.createEl("div",{className:"vjs-time-tooltip"},{"aria-hidden":"true"})}update(e,t,n){const s=gs(this.el_),r=_n(this.player_.el()),a=e.width*t;if(!r||!s)return;let l=e.left-r.left+a,c=e.width-a+(r.right-e.right);c||(c=e.width-a,l=a);let f=s.width/2;l<f?f+=f-l:c<f&&(f=c),f<0?f=0:f>s.width&&(f=s.width),f=Math.round(f),this.el_.style.right=`-${f}px`,this.write(n)}write(e){Si(this.el_,e)}updateTime(e,t,n,s){this.requestNamedAnimationFrame("TimeTooltip#updateTime",()=>{let r;const a=this.player_.duration();if(this.player_.liveTracker&&this.player_.liveTracker.isLive()){const l=this.player_.liveTracker.liveWindow(),c=l-t*l;r=(c<1?"":"-")+qi(c,l)}else r=qi(n,a);this.update(e,t,r),s&&s()})}}H.registerComponent("TimeTooltip",Tb);class Jo extends H{constructor(e,t){super(e,t),this.setIcon("circle"),this.update=Zt(Ce(this,this.update),Pt)}createEl(){return super.createEl("div",{className:"vjs-play-progress vjs-slider-bar"},{"aria-hidden":"true"})}update(e,t){const n=this.getChild("timeTooltip");if(!n)return;const s=this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();n.updateTime(e,t,s)}}Jo.prototype.options_={children:[]};!Je&&!Nt&&Jo.prototype.options_.children.push("timeTooltip");H.registerComponent("PlayProgressBar",Jo);class hc extends H{constructor(e,t){super(e,t),this.update=Zt(Ce(this,this.update),Pt)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t){const n=t*this.player_.duration();this.getChild("timeTooltip").updateTime(e,t,n,()=>{this.el_.style.left=`${e.width*t}px`})}}hc.prototype.options_={children:["timeTooltip"]};H.registerComponent("MouseTimeDisplay",hc);const Zs=5,Xu=12;class Zr extends Qo{constructor(e,t){t=ve(Zr.prototype.options_,t),t.children=[...t.children];const n=e.options_.disableSeekWhileScrubbingOnMobile&&(Je||Nt);(!Je&&!Nt||n)&&t.children.splice(1,0,"mouseTimeDisplay"),super(e,t),this.shouldDisableSeekWhileScrubbingOnMobile_=n,this.pendingSeekTime_=null,this.setEventHandlers_()}setEventHandlers_(){this.update_=Ce(this,this.update),this.update=Zt(this.update_,Pt),this.on(this.player_,["durationchange","timeupdate"],this.update),this.on(this.player_,["ended"],this.update_),this.player_.liveTracker&&this.on(this.player_.liveTracker,"liveedgechange",this.update),this.updateInterval=null,this.enableIntervalHandler_=e=>this.enableInterval_(e),this.disableIntervalHandler_=e=>this.disableInterval_(e),this.on(this.player_,["playing"],this.enableIntervalHandler_),this.on(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in G&&"visibilityState"in G&&this.on(G,"visibilitychange",this.toggleVisibility_)}toggleVisibility_(e){G.visibilityState==="hidden"?(this.cancelNamedAnimationFrame("SeekBar#update"),this.cancelNamedAnimationFrame("Slider#update"),this.disableInterval_(e)):(!this.player_.ended()&&!this.player_.paused()&&this.enableInterval_(),this.update())}enableInterval_(){this.updateInterval||(this.updateInterval=this.setInterval(this.update,Pt))}disableInterval_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&e&&e.type!=="ended"||this.updateInterval&&(this.clearInterval(this.updateInterval),this.updateInterval=null)}createEl(){return super.createEl("div",{className:"vjs-progress-holder"},{"aria-label":this.localize("Progress Bar")})}update(e){if(G.visibilityState==="hidden")return;const t=super.update();return this.requestNamedAnimationFrame("SeekBar#update",()=>{const n=this.player_.ended()?this.player_.duration():this.getCurrentTime_(),s=this.player_.liveTracker;let r=this.player_.duration();s&&s.isLive()&&(r=this.player_.liveTracker.liveCurrentTime()),this.percent_!==t&&(this.el_.setAttribute("aria-valuenow",(t*100).toFixed(2)),this.percent_=t),(this.currentTime_!==n||this.duration_!==r)&&(this.el_.setAttribute("aria-valuetext",this.localize("progress bar timing: currentTime={1} duration={2}",[qi(n,r),qi(r,r)],"{1} of {2}")),this.currentTime_=n,this.duration_=r),this.bar&&this.bar.update(_n(this.el()),this.getProgress())}),t}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}getCurrentTime_(){return this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime()}getPercent(){if(this.pendingSeekTime_)return this.pendingSeekTime_/this.player_.duration();const e=this.getCurrentTime_();let t;const n=this.player_.liveTracker;return n&&n.isLive()?(t=(e-n.seekableStart())/n.liveWindow(),n.atLiveEdge()&&(t=1)):t=e/this.player_.duration(),t}handleMouseDown(e){fs(e)&&(e.stopPropagation(),this.videoWasPlaying=!this.player_.paused(),this.shouldDisableSeekWhileScrubbingOnMobile_||this.player_.pause(),super.handleMouseDown(e))}handleMouseMove(e,t=!1){if(!fs(e)||isNaN(this.player_.duration()))return;!t&&!this.player_.scrubbing()&&this.player_.scrubbing(!0);let n;const s=this.calculateDistance(e),r=this.player_.liveTracker;if(!r||!r.isLive())n=s*this.player_.duration(),n===this.player_.duration()&&(n=n-.1);else{if(s>=.99){r.seekToLiveEdge();return}const a=r.seekableStart(),l=r.liveCurrentTime();if(n=a+s*r.liveWindow(),n>=l&&(n=l),n<=a&&(n=a+.1),n===1/0)return}this.shouldDisableSeekWhileScrubbingOnMobile_?this.pendingSeekTime_=n:this.userSeek_(n),this.player_.options_.enableSmoothSeeking&&this.update()}enable(){super.enable();const e=this.getChild("mouseTimeDisplay");e&&e.show()}disable(){super.disable();const e=this.getChild("mouseTimeDisplay");e&&e.hide()}handleMouseUp(e){super.handleMouseUp(e),e&&e.stopPropagation(),this.player_.scrubbing(!1),this.pendingSeekTime_&&(this.userSeek_(this.pendingSeekTime_),this.pendingSeekTime_=null),this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:!0}),this.videoWasPlaying?Gt(this.player_.play()):this.update_()}stepForward(){this.userSeek_(this.player_.currentTime()+Zs)}stepBack(){this.userSeek_(this.player_.currentTime()-Zs)}handleAction(e){this.player_.paused()?this.player_.play():this.player_.pause()}handleKeyDown(e){const t=this.player_.liveTracker;if(e.key===" "||e.key==="Enter")e.preventDefault(),e.stopPropagation(),this.handleAction(e);else if(e.key==="Home")e.preventDefault(),e.stopPropagation(),this.userSeek_(0);else if(e.key==="End")e.preventDefault(),e.stopPropagation(),t&&t.isLive()?this.userSeek_(t.liveCurrentTime()):this.userSeek_(this.player_.duration());else if(/^[0-9]$/.test(e.key)){e.preventDefault(),e.stopPropagation();const n=parseInt(e.key,10)*.1;t&&t.isLive()?this.userSeek_(t.seekableStart()+t.liveWindow()*n):this.userSeek_(this.player_.duration()*n)}else e.key==="PageDown"?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()-Zs*Xu)):e.key==="PageUp"?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()+Zs*Xu)):super.handleKeyDown(e)}dispose(){this.disableInterval_(),this.off(this.player_,["durationchange","timeupdate"],this.update),this.off(this.player_,["ended"],this.update_),this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.update),this.off(this.player_,["playing"],this.enableIntervalHandler_),this.off(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in G&&"visibilityState"in G&&this.off(G,"visibilitychange",this.toggleVisibility_),super.dispose()}}Zr.prototype.options_={children:["loadProgressBar","playProgressBar"],barName:"playProgressBar"};H.registerComponent("SeekBar",Zr);class cc extends H{constructor(e,t){super(e,t),this.handleMouseMove=Zt(Ce(this,this.handleMouseMove),Pt),this.throttledHandleMouseSeek=Zt(Ce(this,this.handleMouseSeek),Pt),this.handleMouseUpHandler_=n=>this.handleMouseUp(n),this.handleMouseDownHandler_=n=>this.handleMouseDown(n),this.enable()}createEl(){return super.createEl("div",{className:"vjs-progress-control vjs-control"})}handleMouseMove(e){const t=this.getChild("seekBar");if(!t)return;const n=t.getChild("playProgressBar"),s=t.getChild("mouseTimeDisplay");if(!n&&!s)return;const r=t.el(),a=gs(r);let l=Wr(r,e).x;l=bs(l,0,1),s&&s.update(a,l),n&&n.update(a,t.getProgress())}handleMouseSeek(e){const t=this.getChild("seekBar");t&&t.handleMouseMove(e)}enabled(){return this.enabled_}disable(){if(this.children().forEach(e=>e.disable&&e.disable()),!!this.enabled()&&(this.off(["mousedown","touchstart"],this.handleMouseDownHandler_),this.off(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeListenersAddedOnMousedownAndTouchstart(),this.addClass("disabled"),this.enabled_=!1,this.player_.scrubbing())){const e=this.getChild("seekBar");this.player_.scrubbing(!1),e.videoWasPlaying&&Gt(this.player_.play())}}enable(){this.children().forEach(e=>e.enable&&e.enable()),!this.enabled()&&(this.on(["mousedown","touchstart"],this.handleMouseDownHandler_),this.on(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeClass("disabled"),this.enabled_=!0)}removeListenersAddedOnMousedownAndTouchstart(){const e=this.el_.ownerDocument;this.off(e,"mousemove",this.throttledHandleMouseSeek),this.off(e,"touchmove",this.throttledHandleMouseSeek),this.off(e,"mouseup",this.handleMouseUpHandler_),this.off(e,"touchend",this.handleMouseUpHandler_)}handleMouseDown(e){const t=this.el_.ownerDocument,n=this.getChild("seekBar");n&&n.handleMouseDown(e),this.on(t,"mousemove",this.throttledHandleMouseSeek),this.on(t,"touchmove",this.throttledHandleMouseSeek),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const t=this.getChild("seekBar");t&&t.handleMouseUp(e),this.removeListenersAddedOnMousedownAndTouchstart()}}cc.prototype.options_={children:["seekBar"]};H.registerComponent("ProgressControl",cc);class pc extends et{constructor(e,t){super(e,t),this.setIcon("picture-in-picture-enter"),this.on(e,["enterpictureinpicture","leavepictureinpicture"],n=>this.handlePictureInPictureChange(n)),this.on(e,["disablepictureinpicturechanged","loadedmetadata"],n=>this.handlePictureInPictureEnabledChange(n)),this.on(e,["loadedmetadata","audioonlymodechange","audiopostermodechange"],()=>this.handlePictureInPictureAudioModeChange()),this.disable()}buildCSSClass(){return`vjs-picture-in-picture-control vjs-hidden ${super.buildCSSClass()}`}handlePictureInPictureAudioModeChange(){if(!(this.player_.currentType().substring(0,5)==="audio"||this.player_.audioPosterMode()||this.player_.audioOnlyMode())){this.show();return}this.player_.isInPictureInPicture()&&this.player_.exitPictureInPicture(),this.hide()}handlePictureInPictureEnabledChange(){G.pictureInPictureEnabled&&this.player_.disablePictureInPicture()===!1||this.player_.options_.enableDocumentPictureInPicture&&"documentPictureInPicture"in x?this.enable():this.disable()}handlePictureInPictureChange(e){this.player_.isInPictureInPicture()?(this.setIcon("picture-in-picture-exit"),this.controlText("Exit Picture-in-Picture")):(this.setIcon("picture-in-picture-enter"),this.controlText("Picture-in-Picture")),this.handlePictureInPictureEnabledChange()}handleClick(e){this.player_.isInPictureInPicture()?this.player_.exitPictureInPicture():this.player_.requestPictureInPicture()}show(){typeof G.exitPictureInPicture=="function"&&super.show()}}pc.prototype.controlText_="Picture-in-Picture";H.registerComponent("PictureInPictureToggle",pc);class gc extends et{constructor(e,t){super(e,t),this.setIcon("fullscreen-enter"),this.on(e,"fullscreenchange",n=>this.handleFullscreenChange(n)),G[e.fsApi_.fullscreenEnabled]===!1&&this.disable()}buildCSSClass(){return`vjs-fullscreen-control ${super.buildCSSClass()}`}handleFullscreenChange(e){this.player_.isFullscreen()?(this.controlText("Exit Fullscreen"),this.setIcon("fullscreen-exit")):(this.controlText("Fullscreen"),this.setIcon("fullscreen-enter"))}handleClick(e){this.player_.isFullscreen()?this.player_.exitFullscreen():this.player_.requestFullscreen()}}gc.prototype.controlText_="Fullscreen";H.registerComponent("FullscreenToggle",gc);const vb=function(i,e){e.tech_&&!e.tech_.featuresVolumeControl&&i.addClass("vjs-hidden"),i.on(e,"loadstart",function(){e.tech_.featuresVolumeControl?i.removeClass("vjs-hidden"):i.addClass("vjs-hidden")})};class Sb extends H{createEl(){const e=super.createEl("div",{className:"vjs-volume-level"});return this.setIcon("circle",e),e.appendChild(super.createEl("span",{className:"vjs-control-text"})),e}}H.registerComponent("VolumeLevel",Sb);class Eb extends H{constructor(e,t){super(e,t),this.update=Zt(Ce(this,this.update),Pt)}createEl(){return super.createEl("div",{className:"vjs-volume-tooltip"},{"aria-hidden":"true"})}update(e,t,n,s){if(!n){const r=_n(this.el_),a=_n(this.player_.el()),l=e.width*t;if(!a||!r)return;const c=e.left-a.left+l,f=e.width-l+(a.right-e.right);let m=r.width/2;c<m?m+=m-c:f<m&&(m=f),m<0?m=0:m>r.width&&(m=r.width),this.el_.style.right=`-${m}px`}this.write(`${s}%`)}write(e){Si(this.el_,e)}updateVolume(e,t,n,s,r){this.requestNamedAnimationFrame("VolumeLevelTooltip#updateVolume",()=>{this.update(e,t,n,s.toFixed(0)),r&&r()})}}H.registerComponent("VolumeLevelTooltip",Eb);class fc extends H{constructor(e,t){super(e,t),this.update=Zt(Ce(this,this.update),Pt)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(e,t,n){const s=100*t;this.getChild("volumeLevelTooltip").updateVolume(e,t,n,s,()=>{n?this.el_.style.bottom=`${e.height*t}px`:this.el_.style.left=`${e.width*t}px`})}}fc.prototype.options_={children:["volumeLevelTooltip"]};H.registerComponent("MouseVolumeLevelDisplay",fc);class ea extends Qo{constructor(e,t){super(e,t),this.on("slideractive",n=>this.updateLastVolume_(n)),this.on(e,"volumechange",n=>this.updateARIAAttributes(n)),e.ready(()=>this.updateARIAAttributes())}createEl(){return super.createEl("div",{className:"vjs-volume-bar vjs-slider-bar"},{"aria-label":this.localize("Volume Level"),"aria-live":"polite"})}handleMouseDown(e){fs(e)&&super.handleMouseDown(e)}handleMouseMove(e){const t=this.getChild("mouseVolumeLevelDisplay");if(t){const n=this.el(),s=_n(n),r=this.vertical();let a=Wr(n,e);a=r?a.y:a.x,a=bs(a,0,1),t.update(s,a,r)}fs(e)&&(this.checkMuted(),this.player_.volume(this.calculateDistance(e)))}checkMuted(){this.player_.muted()&&this.player_.muted(!1)}getPercent(){return this.player_.muted()?0:this.player_.volume()}stepForward(){this.checkMuted(),this.player_.volume(this.player_.volume()+.1)}stepBack(){this.checkMuted(),this.player_.volume(this.player_.volume()-.1)}updateARIAAttributes(e){const t=this.player_.muted()?0:this.volumeAsPercentage_();this.el_.setAttribute("aria-valuenow",t),this.el_.setAttribute("aria-valuetext",t+"%")}volumeAsPercentage_(){return Math.round(this.player_.volume()*100)}updateLastVolume_(){const e=this.player_.volume();this.one("sliderinactive",()=>{this.player_.volume()===0&&this.player_.lastVolume_(e)})}}ea.prototype.options_={children:["volumeLevel"],barName:"volumeLevel"};!Je&&!Nt&&ea.prototype.options_.children.splice(0,0,"mouseVolumeLevelDisplay");ea.prototype.playerEvent="volumechange";H.registerComponent("VolumeBar",ea);class mc extends H{constructor(e,t={}){t.vertical=t.vertical||!1,(typeof t.volumeBar>"u"||mn(t.volumeBar))&&(t.volumeBar=t.volumeBar||{},t.volumeBar.vertical=t.vertical),super(e,t),vb(this,e),this.throttledHandleMouseMove=Zt(Ce(this,this.handleMouseMove),Pt),this.handleMouseUpHandler_=n=>this.handleMouseUp(n),this.on("mousedown",n=>this.handleMouseDown(n)),this.on("touchstart",n=>this.handleMouseDown(n)),this.on("mousemove",n=>this.handleMouseMove(n)),this.on(this.volumeBar,["focus","slideractive"],()=>{this.volumeBar.addClass("vjs-slider-active"),this.addClass("vjs-slider-active"),this.trigger("slideractive")}),this.on(this.volumeBar,["blur","sliderinactive"],()=>{this.volumeBar.removeClass("vjs-slider-active"),this.removeClass("vjs-slider-active"),this.trigger("sliderinactive")})}createEl(){let e="vjs-volume-horizontal";return this.options_.vertical&&(e="vjs-volume-vertical"),super.createEl("div",{className:`vjs-volume-control vjs-control ${e}`})}handleMouseDown(e){const t=this.el_.ownerDocument;this.on(t,"mousemove",this.throttledHandleMouseMove),this.on(t,"touchmove",this.throttledHandleMouseMove),this.on(t,"mouseup",this.handleMouseUpHandler_),this.on(t,"touchend",this.handleMouseUpHandler_)}handleMouseUp(e){const t=this.el_.ownerDocument;this.off(t,"mousemove",this.throttledHandleMouseMove),this.off(t,"touchmove",this.throttledHandleMouseMove),this.off(t,"mouseup",this.handleMouseUpHandler_),this.off(t,"touchend",this.handleMouseUpHandler_)}handleMouseMove(e){this.volumeBar.handleMouseMove(e)}}mc.prototype.options_={children:["volumeBar"]};H.registerComponent("VolumeControl",mc);const wb=function(i,e){e.tech_&&!e.tech_.featuresMuteControl&&i.addClass("vjs-hidden"),i.on(e,"loadstart",function(){e.tech_.featuresMuteControl?i.removeClass("vjs-hidden"):i.addClass("vjs-hidden")})};class yc extends et{constructor(e,t){super(e,t),wb(this,e),this.on(e,["loadstart","volumechange"],n=>this.update(n))}buildCSSClass(){return`vjs-mute-control ${super.buildCSSClass()}`}handleClick(e){const t=this.player_.volume(),n=this.player_.lastVolume_();if(t===0){const s=n<.1?.1:n;this.player_.volume(s),this.player_.muted(!1)}else this.player_.muted(!this.player_.muted())}update(e){this.updateIcon_(),this.updateControlText_()}updateIcon_(){const e=this.player_.volume();let t=3;this.setIcon("volume-high"),Je&&this.player_.tech_&&this.player_.tech_.el_&&this.player_.muted(this.player_.tech_.el_.muted),e===0||this.player_.muted()?(this.setIcon("volume-mute"),t=0):e<.33?(this.setIcon("volume-low"),t=1):e<.67&&(this.setIcon("volume-medium"),t=2),Hr(this.el_,[0,1,2,3].reduce((n,s)=>n+`${s?" ":""}vjs-vol-${s}`,"")),Bi(this.el_,`vjs-vol-${t}`)}updateControlText_(){const e=this.player_.muted()||this.player_.volume()===0?"Unmute":"Mute";this.controlText()!==e&&this.controlText(e)}}yc.prototype.controlText_="Mute";H.registerComponent("MuteToggle",yc);class _c extends H{constructor(e,t={}){typeof t.inline<"u"?t.inline=t.inline:t.inline=!0,(typeof t.volumeControl>"u"||mn(t.volumeControl))&&(t.volumeControl=t.volumeControl||{},t.volumeControl.vertical=!t.inline),super(e,t),this.handleKeyPressHandler_=n=>this.handleKeyPress(n),this.on(e,["loadstart"],n=>this.volumePanelState_(n)),this.on(this.muteToggle,"keyup",n=>this.handleKeyPress(n)),this.on(this.volumeControl,"keyup",n=>this.handleVolumeControlKeyUp(n)),this.on("keydown",n=>this.handleKeyPress(n)),this.on("mouseover",n=>this.handleMouseOver(n)),this.on("mouseout",n=>this.handleMouseOut(n)),this.on(this.volumeControl,["slideractive"],this.sliderActive_),this.on(this.volumeControl,["sliderinactive"],this.sliderInactive_)}sliderActive_(){this.addClass("vjs-slider-active")}sliderInactive_(){this.removeClass("vjs-slider-active")}volumePanelState_(){this.volumeControl.hasClass("vjs-hidden")&&this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-hidden"),this.volumeControl.hasClass("vjs-hidden")&&!this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-mute-toggle-only")}createEl(){let e="vjs-volume-panel-horizontal";return this.options_.inline||(e="vjs-volume-panel-vertical"),super.createEl("div",{className:`vjs-volume-panel vjs-control ${e}`})}dispose(){this.handleMouseOut(),super.dispose()}handleVolumeControlKeyUp(e){e.key==="Escape"&&this.muteToggle.focus()}handleMouseOver(e){this.addClass("vjs-hover"),vt(G,"keyup",this.handleKeyPressHandler_)}handleMouseOut(e){this.removeClass("vjs-hover"),Ze(G,"keyup",this.handleKeyPressHandler_)}handleKeyPress(e){e.key==="Escape"&&this.handleMouseOut()}}_c.prototype.options_={children:["muteToggle","volumeControl"]};H.registerComponent("VolumePanel",_c);class bc extends et{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipForwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`forward-${this.skipTime}`),this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipForwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.forward}buildCSSClass(){return`vjs-skip-forward-${this.getSkipForwardTime()} ${super.buildCSSClass()}`}handleClick(e){if(isNaN(this.player_.duration()))return;const t=this.player_.currentTime(),n=this.player_.liveTracker,s=n&&n.isLive()?n.seekableEnd():this.player_.duration();let r;t+this.skipTime<=s?r=t+this.skipTime:r=s,this.player_.currentTime(r)}handleLanguagechange(){this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime]))}}bc.prototype.controlText_="Skip Forward";H.registerComponent("SkipForward",bc);class Tc extends et{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipBackwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`replay-${this.skipTime}`),this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipBackwardTime(){const e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.backward}buildCSSClass(){return`vjs-skip-backward-${this.getSkipBackwardTime()} ${super.buildCSSClass()}`}handleClick(e){const t=this.player_.currentTime(),n=this.player_.liveTracker,s=n&&n.isLive()&&n.seekableStart();let r;s&&t-this.skipTime<=s?r=s:t>=this.skipTime?r=t-this.skipTime:r=0,this.player_.currentTime(r)}handleLanguagechange(){this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime]))}}Tc.prototype.controlText_="Skip Backward";H.registerComponent("SkipBackward",Tc);class vc extends H{constructor(e,t){super(e,t),t&&(this.menuButton_=t.menuButton),this.focusedChild_=-1,this.on("keydown",n=>this.handleKeyDown(n)),this.boundHandleBlur_=n=>this.handleBlur(n),this.boundHandleTapClick_=n=>this.handleTapClick(n)}addEventListenerForItem(e){e instanceof H&&(this.on(e,"blur",this.boundHandleBlur_),this.on(e,["tap","click"],this.boundHandleTapClick_))}removeEventListenerForItem(e){e instanceof H&&(this.off(e,"blur",this.boundHandleBlur_),this.off(e,["tap","click"],this.boundHandleTapClick_))}removeChild(e){typeof e=="string"&&(e=this.getChild(e)),this.removeEventListenerForItem(e),super.removeChild(e)}addItem(e){const t=this.addChild(e);t&&this.addEventListenerForItem(t)}createEl(){const e=this.options_.contentElType||"ul";this.contentEl_=ne(e,{className:"vjs-menu-content"}),this.contentEl_.setAttribute("role","menu");const t=super.createEl("div",{append:this.contentEl_,className:"vjs-menu"});return t.appendChild(this.contentEl_),vt(t,"click",function(n){n.preventDefault(),n.stopImmediatePropagation()}),t}dispose(){this.contentEl_=null,this.boundHandleBlur_=null,this.boundHandleTapClick_=null,super.dispose()}handleBlur(e){const t=e.relatedTarget||G.activeElement;if(!this.children().some(n=>n.el()===t)){const n=this.menuButton_;n&&n.buttonPressed_&&t!==n.el().firstChild&&n.unpressButton()}}handleTapClick(e){if(this.menuButton_){this.menuButton_.unpressButton();const t=this.children();if(!Array.isArray(t))return;const n=t.filter(s=>s.el()===e.target)[0];if(!n)return;n.name()!=="CaptionSettingsMenuItem"&&this.menuButton_.focus()}}handleKeyDown(e){e.key==="ArrowLeft"||e.key==="ArrowDown"?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(e.key==="ArrowRight"||e.key==="ArrowUp")&&(e.preventDefault(),e.stopPropagation(),this.stepBack())}stepForward(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_+1),this.focus(e)}stepBack(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_-1),this.focus(e)}focus(e=0){const t=this.children().slice();t.length&&t[0].hasClass("vjs-menu-title")&&t.shift(),t.length>0&&(e<0?e=0:e>=t.length&&(e=t.length-1),this.focusedChild_=e,t[e].el_.focus())}}H.registerComponent("Menu",vc);class Zo extends H{constructor(e,t={}){super(e,t),this.menuButton_=new et(e,t),this.menuButton_.controlText(this.controlText_),this.menuButton_.el_.setAttribute("aria-haspopup","true");const n=et.prototype.buildCSSClass();this.menuButton_.el_.className=this.buildCSSClass()+" "+n,this.menuButton_.removeClass("vjs-control"),this.addChild(this.menuButton_),this.update(),this.enabled_=!0;const s=r=>this.handleClick(r);this.handleMenuKeyUp_=r=>this.handleMenuKeyUp(r),this.on(this.menuButton_,"tap",s),this.on(this.menuButton_,"click",s),this.on(this.menuButton_,"keydown",r=>this.handleKeyDown(r)),this.on(this.menuButton_,"mouseenter",()=>{this.addClass("vjs-hover"),this.menu.show(),vt(G,"keyup",this.handleMenuKeyUp_)}),this.on("mouseleave",r=>this.handleMouseLeave(r)),this.on("keydown",r=>this.handleSubmenuKeyDown(r))}update(){const e=this.createMenu();this.menu&&(this.menu.dispose(),this.removeChild(this.menu)),this.menu=e,this.addChild(e),this.buttonPressed_=!1,this.menuButton_.el_.setAttribute("aria-expanded","false"),this.items&&this.items.length<=this.hideThreshold_?(this.hide(),this.menu.contentEl_.removeAttribute("role")):(this.show(),this.menu.contentEl_.setAttribute("role","menu"))}createMenu(){const e=new vc(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title){const t=ne("li",{className:"vjs-menu-title",textContent:Ne(this.options_.title),tabIndex:-1}),n=new H(this.player_,{el:t});e.addItem(n)}if(this.items=this.createItems(),this.items)for(let t=0;t<this.items.length;t++)e.addItem(this.items[t]);return e}createItems(){}createEl(){return super.createEl("div",{className:this.buildWrapperCSSClass()},{})}setIcon(e){super.setIcon(e,this.menuButton_.el_)}buildWrapperCSSClass(){let e="vjs-menu-button";this.options_.inline===!0?e+="-inline":e+="-popup";const t=et.prototype.buildCSSClass();return`vjs-menu-button ${e} ${t} ${super.buildCSSClass()}`}buildCSSClass(){let e="vjs-menu-button";return this.options_.inline===!0?e+="-inline":e+="-popup",`vjs-menu-button ${e} ${super.buildCSSClass()}`}controlText(e,t=this.menuButton_.el()){return this.menuButton_.controlText(e,t)}dispose(){this.handleMouseLeave(),super.dispose()}handleClick(e){this.buttonPressed_?this.unpressButton():this.pressButton()}handleMouseLeave(e){this.removeClass("vjs-hover"),Ze(G,"keyup",this.handleMenuKeyUp_)}focus(){this.menuButton_.focus()}blur(){this.menuButton_.blur()}handleKeyDown(e){e.key==="Escape"||e.key==="Tab"?(this.buttonPressed_&&this.unpressButton(),!e.key==="Tab"&&(e.preventDefault(),this.menuButton_.focus())):(e.key==="Up"||e.key==="Down"&&!(this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled))&&(this.buttonPressed_||(e.preventDefault(),this.pressButton()))}handleMenuKeyUp(e){(e.key==="Escape"||e.key==="Tab")&&this.removeClass("vjs-hover")}handleSubmenuKeyPress(e){this.handleSubmenuKeyDown(e)}handleSubmenuKeyDown(e){(e.key==="Escape"||e.key==="Tab")&&(this.buttonPressed_&&this.unpressButton(),!e.key==="Tab"&&(e.preventDefault(),this.menuButton_.focus()))}pressButton(){if(this.enabled_){if(this.buttonPressed_=!0,this.menu.show(),this.menu.lockShowing(),this.menuButton_.el_.setAttribute("aria-expanded","true"),Je&&Dh())return;this.menu.focus()}}unpressButton(){this.enabled_&&(this.buttonPressed_=!1,this.menu.unlockShowing(),this.menu.hide(),this.menuButton_.el_.setAttribute("aria-expanded","false"))}disable(){this.unpressButton(),this.enabled_=!1,this.addClass("vjs-disabled"),this.menuButton_.disable()}enable(){this.enabled_=!0,this.removeClass("vjs-disabled"),this.menuButton_.enable()}}H.registerComponent("MenuButton",Zo);class el extends Zo{constructor(e,t){const n=t.tracks;if(super(e,t),this.items.length<=1&&this.hide(),!n)return;const s=Ce(this,this.update);n.addEventListener("removetrack",s),n.addEventListener("addtrack",s),n.addEventListener("labelchange",s),this.player_.on("ready",s),this.player_.on("dispose",function(){n.removeEventListener("removetrack",s),n.removeEventListener("addtrack",s),n.removeEventListener("labelchange",s)})}}H.registerComponent("TrackButton",el);class Ts extends Jr{constructor(e,t){super(e,t),this.selectable=t.selectable,this.isSelected_=t.selected||!1,this.multiSelectable=t.multiSelectable,this.selected(this.isSelected_),this.selectable?this.multiSelectable?this.el_.setAttribute("role","menuitemcheckbox"):this.el_.setAttribute("role","menuitemradio"):this.el_.setAttribute("role","menuitem")}createEl(e,t,n){this.nonIconControl=!0;const s=super.createEl("li",Object.assign({className:"vjs-menu-item",tabIndex:-1},t),n),r=ne("span",{className:"vjs-menu-item-text",textContent:this.localize(this.options_.label)});return this.player_.options_.experimentalSvgIcons?s.appendChild(r):s.replaceChild(r,s.querySelector(".vjs-icon-placeholder")),s}handleKeyDown(e){["Tab","Escape","ArrowUp","ArrowLeft","ArrowRight","ArrowDown"].includes(e.key)||super.handleKeyDown(e)}handleClick(e){this.selected(!0)}selected(e){this.selectable&&(e?(this.addClass("vjs-selected"),this.el_.setAttribute("aria-checked","true"),this.controlText(", selected"),this.isSelected_=!0):(this.removeClass("vjs-selected"),this.el_.setAttribute("aria-checked","false"),this.controlText(""),this.isSelected_=!1))}}H.registerComponent("MenuItem",Ts);class vs extends Ts{constructor(e,t){const n=t.track,s=e.textTracks();t.label=n.label||n.language||"Unknown",t.selected=n.mode==="showing",super(e,t),this.track=n,this.kinds=(t.kinds||[t.kind||this.track.kind]).filter(Boolean);const r=(...l)=>{this.handleTracksChange.apply(this,l)},a=(...l)=>{this.handleSelectedLanguageChange.apply(this,l)};if(e.on(["loadstart","texttrackchange"],r),s.addEventListener("change",r),s.addEventListener("selectedlanguagechange",a),this.on("dispose",function(){e.off(["loadstart","texttrackchange"],r),s.removeEventListener("change",r),s.removeEventListener("selectedlanguagechange",a)}),s.onchange===void 0){let l;this.on(["tap","click"],function(){if(typeof x.Event!="object")try{l=new x.Event("change")}catch{}l||(l=G.createEvent("Event"),l.initEvent("change",!0,!0)),s.dispatchEvent(l)})}this.handleTracksChange()}handleClick(e){const t=this.track,n=this.player_.textTracks();if(super.handleClick(e),!!n)for(let s=0;s<n.length;s++){const r=n[s];this.kinds.indexOf(r.kind)!==-1&&(r===t?r.mode!=="showing"&&(r.mode="showing"):r.mode!=="disabled"&&(r.mode="disabled"))}}handleTracksChange(e){const t=this.track.mode==="showing";t!==this.isSelected_&&this.selected(t)}handleSelectedLanguageChange(e){if(this.track.mode==="showing"){const t=this.player_.cache_.selectedLanguage;if(t&&t.enabled&&t.language===this.track.language&&t.kind!==this.track.kind)return;this.player_.cache_.selectedLanguage={enabled:!0,language:this.track.language,kind:this.track.kind}}}dispose(){this.track=null,super.dispose()}}H.registerComponent("TextTrackMenuItem",vs);class Sc extends vs{constructor(e,t){t.track={player:e,kind:t.kind,kinds:t.kinds,default:!1,mode:"disabled"},t.kinds||(t.kinds=[t.kind]),t.label?t.track.label=t.label:t.track.label=t.kinds.join(" and ")+" off",t.selectable=!0,t.multiSelectable=!1,super(e,t)}handleTracksChange(e){const t=this.player().textTracks();let n=!0;for(let s=0,r=t.length;s<r;s++){const a=t[s];if(this.options_.kinds.indexOf(a.kind)>-1&&a.mode==="showing"){n=!1;break}}n!==this.isSelected_&&this.selected(n)}handleSelectedLanguageChange(e){const t=this.player().textTracks();let n=!0;for(let s=0,r=t.length;s<r;s++){const a=t[s];if(["captions","descriptions","subtitles"].indexOf(a.kind)>-1&&a.mode==="showing"){n=!1;break}}n&&(this.player_.cache_.selectedLanguage={enabled:!1})}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.label),super.handleLanguagechange()}}H.registerComponent("OffTextTrackMenuItem",Sc);class xn extends el{constructor(e,t={}){t.tracks=e.textTracks(),super(e,t)}createItems(e=[],t=vs){let n;this.label_&&(n=`${this.label_} off`),e.push(new Sc(this.player_,{kinds:this.kinds_,kind:this.kind_,label:n})),this.hideThreshold_+=1;const s=this.player_.textTracks();Array.isArray(this.kinds_)||(this.kinds_=[this.kind_]);for(let r=0;r<s.length;r++){const a=s[r];if(this.kinds_.indexOf(a.kind)>-1){const l=new t(this.player_,{track:a,kinds:this.kinds_,kind:this.kind_,selectable:!0,multiSelectable:!1});l.addClass(`vjs-${a.kind}-menu-item`),e.push(l)}}return e}}H.registerComponent("TextTrackButton",xn);class Ec extends Ts{constructor(e,t){const n=t.track,s=t.cue,r=e.currentTime();t.selectable=!0,t.multiSelectable=!1,t.label=s.text,t.selected=s.startTime<=r&&r<s.endTime,super(e,t),this.track=n,this.cue=s}handleClick(e){super.handleClick(),this.player_.currentTime(this.cue.startTime)}}H.registerComponent("ChaptersTrackMenuItem",Ec);class tl extends xn{constructor(e,t,n){super(e,t,n),this.setIcon("chapters"),this.selectCurrentItem_=()=>{this.items.forEach(s=>{s.selected(this.track_.activeCues[0]===s.cue)})}}buildCSSClass(){return`vjs-chapters-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-chapters-button ${super.buildWrapperCSSClass()}`}update(e){if(e&&e.track&&e.track.kind!=="chapters")return;const t=this.findChaptersTrack();t!==this.track_?(this.setTrack(t),super.update()):(!this.items||t&&t.cues&&t.cues.length!==this.items.length)&&super.update()}setTrack(e){if(this.track_!==e){if(this.updateHandler_||(this.updateHandler_=this.update.bind(this)),this.track_){const t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);t&&t.removeEventListener("load",this.updateHandler_),this.track_.removeEventListener("cuechange",this.selectCurrentItem_),this.track_=null}if(this.track_=e,this.track_){this.track_.mode="hidden";const t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);t&&t.addEventListener("load",this.updateHandler_),this.track_.addEventListener("cuechange",this.selectCurrentItem_)}}}findChaptersTrack(){const e=this.player_.textTracks()||[];for(let t=e.length-1;t>=0;t--){const n=e[t];if(n.kind===this.kind_)return n}}getMenuCaption(){return this.track_&&this.track_.label?this.track_.label:this.localize(Ne(this.kind_))}createMenu(){return this.options_.title=this.getMenuCaption(),super.createMenu()}createItems(){const e=[];if(!this.track_)return e;const t=this.track_.cues;if(!t)return e;for(let n=0,s=t.length;n<s;n++){const r=t[n],a=new Ec(this.player_,{track:this.track_,cue:r});e.push(a)}return e}}tl.prototype.kind_="chapters";tl.prototype.controlText_="Chapters";H.registerComponent("ChaptersButton",tl);class il extends xn{constructor(e,t,n){super(e,t,n),this.setIcon("audio-description");const s=e.textTracks(),r=Ce(this,this.handleTracksChange);s.addEventListener("change",r),this.on("dispose",function(){s.removeEventListener("change",r)})}handleTracksChange(e){const t=this.player().textTracks();let n=!1;for(let s=0,r=t.length;s<r;s++){const a=t[s];if(a.kind!==this.kind_&&a.mode==="showing"){n=!0;break}}n?this.disable():this.enable()}buildCSSClass(){return`vjs-descriptions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-descriptions-button ${super.buildWrapperCSSClass()}`}}il.prototype.kind_="descriptions";il.prototype.controlText_="Descriptions";H.registerComponent("DescriptionsButton",il);class nl extends xn{constructor(e,t,n){super(e,t,n),this.setIcon("subtitles")}buildCSSClass(){return`vjs-subtitles-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subtitles-button ${super.buildWrapperCSSClass()}`}}nl.prototype.kind_="subtitles";nl.prototype.controlText_="Subtitles";H.registerComponent("SubtitlesButton",nl);class sl extends vs{constructor(e,t){t.track={player:e,kind:t.kind,label:t.kind+" settings",selectable:!1,default:!1,mode:"disabled"},t.selectable=!1,t.name="CaptionSettingsMenuItem",super(e,t),this.addClass("vjs-texttrack-settings"),this.controlText(", opens "+t.kind+" settings dialog")}handleClick(e){this.player().getChild("textTrackSettings").open()}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.kind+" settings"),super.handleLanguagechange()}}H.registerComponent("CaptionSettingsMenuItem",sl);class rl extends xn{constructor(e,t,n){super(e,t,n),this.setIcon("captions")}buildCSSClass(){return`vjs-captions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-captions-button ${super.buildWrapperCSSClass()}`}createItems(){const e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings")&&(e.push(new sl(this.player_,{kind:this.kind_})),this.hideThreshold_+=1),super.createItems(e)}}rl.prototype.kind_="captions";rl.prototype.controlText_="Captions";H.registerComponent("CaptionsButton",rl);class wc extends vs{createEl(e,t,n){const s=super.createEl(e,t,n),r=s.querySelector(".vjs-menu-item-text");return this.options_.track.kind==="captions"&&(this.player_.options_.experimentalSvgIcons?this.setIcon("captions",s):r.appendChild(ne("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(ne("span",{className:"vjs-control-text",textContent:` ${this.localize("Captions")}`}))),s}}H.registerComponent("SubsCapsMenuItem",wc);class al extends xn{constructor(e,t={}){super(e,t),this.label_="subtitles",this.setIcon("subtitles"),["en","en-us","en-ca","fr-ca"].indexOf(this.player_.language_)>-1&&(this.label_="captions",this.setIcon("captions")),this.menuButton_.controlText(Ne(this.label_))}buildCSSClass(){return`vjs-subs-caps-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subs-caps-button ${super.buildWrapperCSSClass()}`}createItems(){let e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild("textTrackSettings")&&(e.push(new sl(this.player_,{kind:this.label_})),this.hideThreshold_+=1),e=super.createItems(e,wc),e}}al.prototype.kinds_=["captions","subtitles"];al.prototype.controlText_="Subtitles";H.registerComponent("SubsCapsButton",al);class kc extends Ts{constructor(e,t){const n=t.track,s=e.audioTracks();t.label=n.label||n.language||"Unknown",t.selected=n.enabled,super(e,t),this.track=n,this.addClass(`vjs-${n.kind}-menu-item`);const r=(...a)=>{this.handleTracksChange.apply(this,a)};s.addEventListener("change",r),this.on("dispose",()=>{s.removeEventListener("change",r)})}createEl(e,t,n){const s=super.createEl(e,t,n),r=s.querySelector(".vjs-menu-item-text");return["main-desc","descriptions"].indexOf(this.options_.track.kind)>=0&&(r.appendChild(ne("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(ne("span",{className:"vjs-control-text",textContent:" "+this.localize("Descriptions")}))),s}handleClick(e){if(super.handleClick(e),this.track.enabled=!0,this.player_.tech_.featuresNativeAudioTracks){const t=this.player_.audioTracks();for(let n=0;n<t.length;n++){const s=t[n];s!==this.track&&(s.enabled=s===this.track)}}}handleTracksChange(e){this.selected(this.track.enabled)}}H.registerComponent("AudioTrackMenuItem",kc);class Cc extends el{constructor(e,t={}){t.tracks=e.audioTracks(),super(e,t),this.setIcon("audio")}buildCSSClass(){return`vjs-audio-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-audio-button ${super.buildWrapperCSSClass()}`}createItems(e=[]){this.hideThreshold_=1;const t=this.player_.audioTracks();for(let n=0;n<t.length;n++){const s=t[n];e.push(new kc(this.player_,{track:s,selectable:!0,multiSelectable:!1}))}return e}}Cc.prototype.controlText_="Audio Track";H.registerComponent("AudioTrackButton",Cc);class ol extends Ts{constructor(e,t){const n=t.rate,s=parseFloat(n,10);t.label=n,t.selected=s===e.playbackRate(),t.selectable=!0,t.multiSelectable=!1,super(e,t),this.label=n,this.rate=s,this.on(e,"ratechange",r=>this.update(r))}handleClick(e){super.handleClick(),this.player().playbackRate(this.rate)}update(e){this.selected(this.player().playbackRate()===this.rate)}}ol.prototype.contentElType="button";H.registerComponent("PlaybackRateMenuItem",ol);class Ic extends Zo{constructor(e,t){super(e,t),this.menuButton_.el_.setAttribute("aria-describedby",this.labelElId_),this.updateVisibility(),this.updateLabel(),this.on(e,"loadstart",n=>this.updateVisibility(n)),this.on(e,"ratechange",n=>this.updateLabel(n)),this.on(e,"playbackrateschange",n=>this.handlePlaybackRateschange(n))}createEl(){const e=super.createEl();return this.labelElId_="vjs-playback-rate-value-label-"+this.id_,this.labelEl_=ne("div",{className:"vjs-playback-rate-value",id:this.labelElId_,textContent:"1x"}),e.appendChild(this.labelEl_),e}dispose(){this.labelEl_=null,super.dispose()}buildCSSClass(){return`vjs-playback-rate ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-playback-rate ${super.buildWrapperCSSClass()}`}createItems(){const e=this.playbackRates(),t=[];for(let n=e.length-1;n>=0;n--)t.push(new ol(this.player(),{rate:e[n]+"x"}));return t}handlePlaybackRateschange(e){this.update()}playbackRates(){const e=this.player();return e.playbackRates&&e.playbackRates()||[]}playbackRateSupported(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&this.playbackRates().length>0}updateVisibility(e){this.playbackRateSupported()?this.removeClass("vjs-hidden"):this.addClass("vjs-hidden")}updateLabel(e){this.playbackRateSupported()&&(this.labelEl_.textContent=this.player().playbackRate()+"x")}}Ic.prototype.controlText_="Playback Rate";H.registerComponent("PlaybackRateMenuButton",Ic);class xc extends H{buildCSSClass(){return`vjs-spacer ${super.buildCSSClass()}`}createEl(e="div",t={},n={}){return t.className||(t.className=this.buildCSSClass()),super.createEl(e,t,n)}}H.registerComponent("Spacer",xc);class kb extends xc{buildCSSClass(){return`vjs-custom-control-spacer ${super.buildCSSClass()}`}createEl(){return super.createEl("div",{className:this.buildCSSClass(),textContent:" "})}}H.registerComponent("CustomControlSpacer",kb);class Ac extends H{createEl(){return super.createEl("div",{className:"vjs-control-bar",dir:"ltr"})}}Ac.prototype.options_={children:["playToggle","skipBackward","skipForward","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","liveDisplay","seekToLive","remainingTimeDisplay","customControlSpacer","playbackRateMenuButton","chaptersButton","descriptionsButton","subsCapsButton","audioTrackButton","pictureInPictureToggle","fullscreenToggle"]};H.registerComponent("ControlBar",Ac);class Pc extends Cn{constructor(e,t){super(e,t),this.on(e,"error",n=>{this.open(n)})}buildCSSClass(){return`vjs-error-display ${super.buildCSSClass()}`}content(){const e=this.player().error();return e?this.localize(e.message):""}}Pc.prototype.options_=Object.assign({},Cn.prototype.options_,{pauseOnOpen:!1,fillAlways:!0,temporary:!1,uncloseable:!0});H.registerComponent("ErrorDisplay",Pc);class Lc extends H{constructor(e,t={}){super(e,t),this.el_.setAttribute("aria-labelledby",this.selectLabelledbyIds)}createEl(){return this.selectLabelledbyIds=[this.options_.legendId,this.options_.labelId].join(" ").trim(),ne("select",{id:this.options_.id},{},this.options_.SelectOptions.map(e=>{const t=(this.options_.labelId?this.options_.labelId:`vjs-track-option-${At()}`)+"-"+e[1].replace(/\W+/g,""),n=ne("option",{id:t,value:this.localize(e[0]),textContent:this.localize(e[1])});return n.setAttribute("aria-labelledby",`${this.selectLabelledbyIds} ${t}`),n}))}}H.registerComponent("TextTrackSelect",Lc);class ji extends H{constructor(e,t={}){super(e,t);const n=ne("legend",{textContent:this.localize(this.options_.legendText),id:this.options_.legendId});this.el().appendChild(n);const s=this.options_.selects;for(const r of s){const a=this.options_.selectConfigs[r],l=a.className,c=a.id.replace("%s",this.options_.id_);let f=null;const m=`vjs_select_${At()}`;if(this.options_.type==="colors"){f=ne("span",{className:l});const C=ne("label",{id:c,className:"vjs-label",textContent:this.localize(a.label)});C.setAttribute("for",m),f.appendChild(C)}const b=new Lc(e,{SelectOptions:a.options,legendId:this.options_.legendId,id:m,labelId:c});this.addChild(b),this.options_.type==="colors"&&(f.appendChild(b.el()),this.el().appendChild(f))}}createEl(){return ne("fieldset",{className:this.options_.className})}}H.registerComponent("TextTrackFieldset",ji);class Dc extends H{constructor(e,t={}){super(e,t);const n=this.options_.textTrackComponentid,s=new ji(e,{id_:n,legendId:`captions-text-legend-${n}`,legendText:this.localize("Text"),className:"vjs-fg vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(s);const r=new ji(e,{id_:n,legendId:`captions-background-${n}`,legendText:this.localize("Text Background"),className:"vjs-bg vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(r);const a=new ji(e,{id_:n,legendId:`captions-window-${n}`,legendText:this.localize("Caption Area Background"),className:"vjs-window vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(a)}createEl(){return ne("div",{className:"vjs-track-settings-colors"})}}H.registerComponent("TextTrackSettingsColors",Dc);class Oc extends H{constructor(e,t={}){super(e,t);const n=this.options_.textTrackComponentid,s=new ji(e,{id_:n,legendId:`captions-font-size-${n}`,legendText:"Font Size",className:"vjs-font-percent vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(s);const r=new ji(e,{id_:n,legendId:`captions-edge-style-${n}`,legendText:this.localize("Text Edge Style"),className:"vjs-edge-style vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(r);const a=new ji(e,{id_:n,legendId:`captions-font-family-${n}`,legendText:this.localize("Font Family"),className:"vjs-font-family vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(a)}createEl(){return ne("div",{className:"vjs-track-settings-font"})}}H.registerComponent("TextTrackSettingsFont",Oc);class Mc extends H{constructor(e,t={}){super(e,t);const n=this.localize("restore all settings to the default values"),s=new et(e,{controlText:n,className:"vjs-default-button"});s.el().classList.remove("vjs-control","vjs-button"),s.el().textContent=this.localize("Reset"),this.addChild(s);const r=new et(e,{controlText:n,className:"vjs-done-button"});r.el().classList.remove("vjs-control","vjs-button"),r.el().textContent=this.localize("Done"),this.addChild(r)}createEl(){return ne("div",{className:"vjs-track-settings-controls"})}}H.registerComponent("TrackSettingsControls",Mc);const Ba="vjs-text-track-settings",Ku=["#000","Black"],Yu=["#00F","Blue"],Qu=["#0FF","Cyan"],Ju=["#0F0","Green"],Zu=["#F0F","Magenta"],ed=["#F00","Red"],td=["#FFF","White"],id=["#FF0","Yellow"],Fa=["1","Opaque"],ja=["0.5","Semi-Transparent"],nd=["0","Transparent"],bi={backgroundColor:{selector:".vjs-bg-color > select",id:"captions-background-color-%s",label:"Color",options:[Ku,td,ed,Ju,Yu,id,Zu,Qu],className:"vjs-bg-color"},backgroundOpacity:{selector:".vjs-bg-opacity > select",id:"captions-background-opacity-%s",label:"Opacity",options:[Fa,ja,nd],className:"vjs-bg-opacity vjs-opacity"},color:{selector:".vjs-text-color > select",id:"captions-foreground-color-%s",label:"Color",options:[td,Ku,ed,Ju,Yu,id,Zu,Qu],className:"vjs-text-color"},edgeStyle:{selector:".vjs-edge-style > select",id:"",label:"Text Edge Style",options:[["none","None"],["raised","Raised"],["depressed","Depressed"],["uniform","Uniform"],["dropshadow","Drop shadow"]]},fontFamily:{selector:".vjs-font-family > select",id:"",label:"Font Family",options:[["proportionalSansSerif","Proportional Sans-Serif"],["monospaceSansSerif","Monospace Sans-Serif"],["proportionalSerif","Proportional Serif"],["monospaceSerif","Monospace Serif"],["casual","Casual"],["script","Script"],["small-caps","Small Caps"]]},fontPercent:{selector:".vjs-font-percent > select",id:"",label:"Font Size",options:[["0.50","50%"],["0.75","75%"],["1.00","100%"],["1.25","125%"],["1.50","150%"],["1.75","175%"],["2.00","200%"],["3.00","300%"],["4.00","400%"]],default:2,parser:i=>i==="1.00"?null:Number(i)},textOpacity:{selector:".vjs-text-opacity > select",id:"captions-foreground-opacity-%s",label:"Opacity",options:[Fa,ja],className:"vjs-text-opacity vjs-opacity"},windowColor:{selector:".vjs-window-color > select",id:"captions-window-color-%s",label:"Color",className:"vjs-window-color"},windowOpacity:{selector:".vjs-window-opacity > select",id:"captions-window-opacity-%s",label:"Opacity",options:[nd,ja,Fa],className:"vjs-window-opacity vjs-opacity"}};bi.windowColor.options=bi.backgroundColor.options;function Rc(i,e){if(e&&(i=e(i)),i&&i!=="none")return i}function Cb(i,e){const t=i.options[i.options.selectedIndex].value;return Rc(t,e)}function Ib(i,e,t){if(e){for(let n=0;n<i.options.length;n++)if(Rc(i.options[n].value,t)===e){i.selectedIndex=n;break}}}class xb extends Cn{constructor(e,t){t.temporary=!1,super(e,t),this.updateDisplay=this.updateDisplay.bind(this),this.fill(),this.hasBeenOpened_=this.hasBeenFilled_=!0,this.renderModalComponents(e),this.endDialog=ne("p",{className:"vjs-control-text",textContent:this.localize("End of dialog window.")}),this.el().appendChild(this.endDialog),this.setDefaults(),t.persistTextTrackSettings===void 0&&(this.options_.persistTextTrackSettings=this.options_.playerOptions.persistTextTrackSettings),this.bindFunctionsToSelectsAndButtons(),this.options_.persistTextTrackSettings&&this.restoreSettings()}renderModalComponents(e){const t=new Dc(e,{textTrackComponentid:this.id_,selectConfigs:bi,fieldSets:[["color","textOpacity"],["backgroundColor","backgroundOpacity"],["windowColor","windowOpacity"]]});this.addChild(t);const n=new Oc(e,{textTrackComponentid:this.id_,selectConfigs:bi,fieldSets:[["fontPercent"],["edgeStyle"],["fontFamily"]]});this.addChild(n);const s=new Mc(e);this.addChild(s)}bindFunctionsToSelectsAndButtons(){this.on(this.$(".vjs-done-button"),["click","tap"],()=>{this.saveSettings(),this.close()}),this.on(this.$(".vjs-default-button"),["click","tap"],()=>{this.setDefaults(),this.updateDisplay()}),sn(bi,e=>{this.on(this.$(e.selector),"change",this.updateDisplay)})}dispose(){this.endDialog=null,super.dispose()}label(){return this.localize("Caption Settings Dialog")}description(){return this.localize("Beginning of dialog window. Escape will cancel and close the window.")}buildCSSClass(){return super.buildCSSClass()+" vjs-text-track-settings"}getValues(){return kh(bi,(e,t,n)=>{const s=Cb(this.$(t.selector),t.parser);return s!==void 0&&(e[n]=s),e},{})}setValues(e){sn(bi,(t,n)=>{Ib(this.$(t.selector),e[n],t.parser)})}setDefaults(){sn(bi,e=>{const t=e.hasOwnProperty("default")?e.default:0;this.$(e.selector).selectedIndex=t})}restoreSettings(){let e;try{e=JSON.parse(x.localStorage.getItem(Ba))}catch(t){oe.warn(t)}e&&this.setValues(e)}saveSettings(){if(!this.options_.persistTextTrackSettings)return;const e=this.getValues();try{Object.keys(e).length?x.localStorage.setItem(Ba,JSON.stringify(e)):x.localStorage.removeItem(Ba)}catch(t){oe.warn(t)}}updateDisplay(){const e=this.player_.getChild("textTrackDisplay");e&&e.updateDisplay()}handleLanguagechange(){this.fill(),this.renderModalComponents(this.player_),this.bindFunctionsToSelectsAndButtons()}}H.registerComponent("TextTrackSettings",xb);class Ab extends H{constructor(e,t){let n=t.ResizeObserver||x.ResizeObserver;t.ResizeObserver===null&&(n=!1);const s=ve({createEl:!n,reportTouchActivity:!1},t);super(e,s),this.ResizeObserver=t.ResizeObserver||x.ResizeObserver,this.loadListener_=null,this.resizeObserver_=null,this.debouncedHandler_=Xh(()=>{this.resizeHandler()},100,!1,this),n?(this.resizeObserver_=new this.ResizeObserver(this.debouncedHandler_),this.resizeObserver_.observe(e.el())):(this.loadListener_=()=>{if(!this.el_||!this.el_.contentWindow)return;const r=this.debouncedHandler_;let a=this.unloadListener_=function(){Ze(this,"resize",r),Ze(this,"unload",a),a=null};vt(this.el_.contentWindow,"unload",a),vt(this.el_.contentWindow,"resize",r)},this.one("load",this.loadListener_))}createEl(){return super.createEl("iframe",{className:"vjs-resize-manager",tabIndex:-1,title:this.localize("No content")},{"aria-hidden":"true"})}resizeHandler(){!this.player_||!this.player_.trigger||this.player_.trigger("playerresize")}dispose(){this.debouncedHandler_&&this.debouncedHandler_.cancel(),this.resizeObserver_&&(this.player_.el()&&this.resizeObserver_.unobserve(this.player_.el()),this.resizeObserver_.disconnect()),this.loadListener_&&this.off("load",this.loadListener_),this.el_&&this.el_.contentWindow&&this.unloadListener_&&this.unloadListener_.call(this.el_.contentWindow),this.ResizeObserver=null,this.resizeObserver=null,this.debouncedHandler_=null,this.loadListener_=null,super.dispose()}}H.registerComponent("ResizeManager",Ab);const Pb={trackingThreshold:20,liveTolerance:15};class Lb extends H{constructor(e,t){const n=ve(Pb,t,{createEl:!1});super(e,n),this.trackLiveHandler_=()=>this.trackLive_(),this.handlePlay_=s=>this.handlePlay(s),this.handleFirstTimeupdate_=s=>this.handleFirstTimeupdate(s),this.handleSeeked_=s=>this.handleSeeked(s),this.seekToLiveEdge_=s=>this.seekToLiveEdge(s),this.reset_(),this.on(this.player_,"durationchange",s=>this.handleDurationchange(s)),this.on(this.player_,"canplay",()=>this.toggleTracking())}trackLive_(){const e=this.player_.seekable();if(!e||!e.length)return;const t=Number(x.performance.now().toFixed(4)),n=this.lastTime_===-1?0:(t-this.lastTime_)/1e3;this.lastTime_=t,this.pastSeekEnd_=this.pastSeekEnd()+n;const s=this.liveCurrentTime(),r=this.player_.currentTime();let a=this.player_.paused()||this.seekedBehindLive_||Math.abs(s-r)>this.options_.liveTolerance;(!this.timeupdateSeen_||s===1/0)&&(a=!1),a!==this.behindLiveEdge_&&(this.behindLiveEdge_=a,this.trigger("liveedgechange"))}handleDurationchange(){this.toggleTracking()}toggleTracking(){this.player_.duration()===1/0&&this.liveWindow()>=this.options_.trackingThreshold?(this.player_.options_.liveui&&this.player_.addClass("vjs-liveui"),this.startTracking()):(this.player_.removeClass("vjs-liveui"),this.stopTracking())}startTracking(){this.isTracking()||(this.timeupdateSeen_||(this.timeupdateSeen_=this.player_.hasStarted()),this.trackingInterval_=this.setInterval(this.trackLiveHandler_,Pt),this.trackLive_(),this.on(this.player_,["play","pause"],this.trackLiveHandler_),this.timeupdateSeen_?this.on(this.player_,"seeked",this.handleSeeked_):(this.one(this.player_,"play",this.handlePlay_),this.one(this.player_,"timeupdate",this.handleFirstTimeupdate_)))}handleFirstTimeupdate(){this.timeupdateSeen_=!0,this.on(this.player_,"seeked",this.handleSeeked_)}handleSeeked(){const e=Math.abs(this.liveCurrentTime()-this.player_.currentTime());this.seekedBehindLive_=this.nextSeekedFromUser_&&e>2,this.nextSeekedFromUser_=!1,this.trackLive_()}handlePlay(){this.one(this.player_,"timeupdate",this.seekToLiveEdge_)}reset_(){this.lastTime_=-1,this.pastSeekEnd_=0,this.lastSeekEnd_=-1,this.behindLiveEdge_=!0,this.timeupdateSeen_=!1,this.seekedBehindLive_=!1,this.nextSeekedFromUser_=!1,this.clearInterval(this.trackingInterval_),this.trackingInterval_=null,this.off(this.player_,["play","pause"],this.trackLiveHandler_),this.off(this.player_,"seeked",this.handleSeeked_),this.off(this.player_,"play",this.handlePlay_),this.off(this.player_,"timeupdate",this.handleFirstTimeupdate_),this.off(this.player_,"timeupdate",this.seekToLiveEdge_)}nextSeekedFromUser(){this.nextSeekedFromUser_=!0}stopTracking(){this.isTracking()&&(this.reset_(),this.trigger("liveedgechange"))}seekableEnd(){const e=this.player_.seekable(),t=[];let n=e?e.length:0;for(;n--;)t.push(e.end(n));return t.length?t.sort()[t.length-1]:1/0}seekableStart(){const e=this.player_.seekable(),t=[];let n=e?e.length:0;for(;n--;)t.push(e.start(n));return t.length?t.sort()[0]:0}liveWindow(){const e=this.liveCurrentTime();return e===1/0?0:e-this.seekableStart()}isLive(){return this.isTracking()}atLiveEdge(){return!this.behindLiveEdge()}liveCurrentTime(){return this.pastSeekEnd()+this.seekableEnd()}pastSeekEnd(){const e=this.seekableEnd();return this.lastSeekEnd_!==-1&&e!==this.lastSeekEnd_&&(this.pastSeekEnd_=0),this.lastSeekEnd_=e,this.pastSeekEnd_}behindLiveEdge(){return this.behindLiveEdge_}isTracking(){return typeof this.trackingInterval_=="number"}seekToLiveEdge(){this.seekedBehindLive_=!1,!this.atLiveEdge()&&(this.nextSeekedFromUser_=!1,this.player_.currentTime(this.liveCurrentTime()))}dispose(){this.stopTracking(),super.dispose()}}H.registerComponent("LiveTracker",Lb);class Db extends H{constructor(e,t){super(e,t),this.on("statechanged",n=>this.updateDom_()),this.updateDom_()}createEl(){return this.els={title:ne("div",{className:"vjs-title-bar-title",id:`vjs-title-bar-title-${At()}`}),description:ne("div",{className:"vjs-title-bar-description",id:`vjs-title-bar-description-${At()}`})},ne("div",{className:"vjs-title-bar"},{},Ch(this.els))}updateDom_(){const e=this.player_.tech_,t=e&&e.el_,n={title:"aria-labelledby",description:"aria-describedby"};["title","description"].forEach(s=>{const r=this.state[s],a=this.els[s],l=n[s];Gr(a),r&&Si(a,r),t&&(t.removeAttribute(l),r&&t.setAttribute(l,a.id))}),this.state.title||this.state.description?this.show():this.hide()}update(e){this.setState(e)}dispose(){const e=this.player_.tech_,t=e&&e.el_;t&&(t.removeAttribute("aria-labelledby"),t.removeAttribute("aria-describedby")),super.dispose(),this.els=null}}H.registerComponent("TitleBar",Db);const Ob={initialDisplay:4e3,position:[],takeFocus:!1};class Mb extends et{constructor(e,t){t=ve(Ob,t),super(e,t),this.controlText(t.controlText),this.hide(),this.on(this.player_,["useractive","userinactive"],n=>{this.removeClass("force-display")})}buildCSSClass(){return`vjs-transient-button focus-visible ${this.options_.position.map(e=>`vjs-${e}`).join(" ")}`}createEl(){const e=ne("button",{},{type:"button",class:this.buildCSSClass()},ne("span"));return this.controlTextEl_=e.querySelector("span"),e}show(){super.show(),this.addClass("force-display"),this.options_.takeFocus&&this.el().focus({preventScroll:!0}),this.forceDisplayTimeout=this.player_.setTimeout(()=>{this.removeClass("force-display")},this.options_.initialDisplay)}hide(){this.removeClass("force-display"),super.hide()}dispose(){this.player_.clearTimeout(this.forceDisplayTimeout),super.dispose()}}H.registerComponent("TransientButton",Mb);const so=i=>{const e=i.el();if(e.hasAttribute("src"))return i.triggerSourceset(e.src),!0;const t=i.$$("source"),n=[];let s="";if(!t.length)return!1;for(let r=0;r<t.length;r++){const a=t[r].src;a&&n.indexOf(a)===-1&&n.push(a)}return n.length?(n.length===1&&(s=n[0]),i.triggerSourceset(s),!0):!1},Rb=Object.defineProperty({},"innerHTML",{get(){return this.cloneNode(!0).innerHTML},set(i){const e=G.createElement(this.nodeName.toLowerCase());e.innerHTML=i;const t=G.createDocumentFragment();for(;e.childNodes.length;)t.appendChild(e.childNodes[0]);return this.innerText="",x.Element.prototype.appendChild.call(this,t),this.innerHTML}}),Uc=(i,e)=>{let t={};for(let n=0;n<i.length&&(t=Object.getOwnPropertyDescriptor(i[n],e),!(t&&t.set&&t.get));n++);return t.enumerable=!0,t.configurable=!0,t},Ub=i=>Uc([i.el(),x.HTMLMediaElement.prototype,x.Element.prototype,Rb],"innerHTML"),sd=function(i){const e=i.el();if(e.resetSourceWatch_)return;const t={},n=Ub(i),s=r=>(...a)=>{const l=r.apply(e,a);return so(i),l};["append","appendChild","insertAdjacentHTML"].forEach(r=>{e[r]&&(t[r]=e[r],e[r]=s(t[r]))}),Object.defineProperty(e,"innerHTML",ve(n,{set:s(n.set)})),e.resetSourceWatch_=()=>{e.resetSourceWatch_=null,Object.keys(t).forEach(r=>{e[r]=t[r]}),Object.defineProperty(e,"innerHTML",n)},i.one("sourceset",e.resetSourceWatch_)},Nb=Object.defineProperty({},"src",{get(){return this.hasAttribute("src")?sc(x.Element.prototype.getAttribute.call(this,"src")):""},set(i){return x.Element.prototype.setAttribute.call(this,"src",i),i}}),Bb=i=>Uc([i.el(),x.HTMLMediaElement.prototype,Nb],"src"),Fb=function(i){if(!i.featuresSourceset)return;const e=i.el();if(e.resetSourceset_)return;const t=Bb(i),n=e.setAttribute,s=e.load;Object.defineProperty(e,"src",ve(t,{set:r=>{const a=t.set.call(e,r);return i.triggerSourceset(e.src),a}})),e.setAttribute=(r,a)=>{const l=n.call(e,r,a);return/src/i.test(r)&&i.triggerSourceset(e.src),l},e.load=()=>{const r=s.call(e);return so(i)||(i.triggerSourceset(""),sd(i)),r},e.currentSrc?i.triggerSourceset(e.currentSrc):so(i)||sd(i),e.resetSourceset_=()=>{e.resetSourceset_=null,e.load=s,e.setAttribute=n,Object.defineProperty(e,"src",t),e.resetSourceWatch_&&e.resetSourceWatch_()}};class J extends ae{constructor(e,t){super(e,t);const n=e.source;let s=!1;if(this.featuresVideoFrameCallback=this.featuresVideoFrameCallback&&this.el_.tagName==="VIDEO",n&&(this.el_.currentSrc!==n.src||e.tag&&e.tag.initNetworkState_===3)?this.setSource(n):this.handleLateInit_(this.el_),e.enableSourceset&&this.setupSourcesetHandling_(),this.isScrubbing_=!1,this.el_.hasChildNodes()){const r=this.el_.childNodes;let a=r.length;const l=[];for(;a--;){const c=r[a];c.nodeName.toLowerCase()==="track"&&(this.featuresNativeTextTracks?(this.remoteTextTrackEls().addTrackElement_(c),this.remoteTextTracks().addTrack(c.track),this.textTracks().addTrack(c.track),!s&&!this.el_.hasAttribute("crossorigin")&&Qr(c.src)&&(s=!0)):l.push(c))}for(let c=0;c<l.length;c++)this.el_.removeChild(l[c])}this.proxyNativeTracks_(),this.featuresNativeTextTracks&&s&&oe.warn(`Text Tracks are being loaded from another origin but the crossorigin attribute isn't used.
|
|
167
|
+
This may prevent text tracks from loading.`),this.restoreMetadataTracksInIOSNativePlayer_(),(ps||qr)&&e.nativeControlsForTouch===!0&&this.setControls(!0),this.proxyWebkitFullscreen_(),this.triggerReady()}dispose(){this.el_&&this.el_.resetSourceset_&&this.el_.resetSourceset_(),J.disposeMediaElement(this.el_),this.options_=null,super.dispose()}setupSourcesetHandling_(){Fb(this)}restoreMetadataTracksInIOSNativePlayer_(){const e=this.textTracks();let t;const n=()=>{t=[];for(let r=0;r<e.length;r++){const a=e[r];a.kind==="metadata"&&t.push({track:a,storedMode:a.mode})}};n(),e.addEventListener("change",n),this.on("dispose",()=>e.removeEventListener("change",n));const s=()=>{for(let r=0;r<t.length;r++){const a=t[r];a.track.mode==="disabled"&&a.track.mode!==a.storedMode&&(a.track.mode=a.storedMode)}e.removeEventListener("change",s)};this.on("webkitbeginfullscreen",()=>{e.removeEventListener("change",n),e.removeEventListener("change",s),e.addEventListener("change",s)}),this.on("webkitendfullscreen",()=>{e.removeEventListener("change",n),e.addEventListener("change",n),e.removeEventListener("change",s)})}overrideNative_(e,t){if(t!==this[`featuresNative${e}Tracks`])return;const n=e.toLowerCase();this[`${n}TracksListeners_`]&&Object.keys(this[`${n}TracksListeners_`]).forEach(s=>{this.el()[`${n}Tracks`].removeEventListener(s,this[`${n}TracksListeners_`][s])}),this[`featuresNative${e}Tracks`]=!t,this[`${n}TracksListeners_`]=null,this.proxyNativeTracksForType_(n)}overrideNativeAudioTracks(e){this.overrideNative_("Audio",e)}overrideNativeVideoTracks(e){this.overrideNative_("Video",e)}proxyNativeTracksForType_(e){const t=xt[e],n=this.el()[t.getterName],s=this[t.getterName]();if(!this[`featuresNative${t.capitalName}Tracks`]||!n||!n.addEventListener)return;const r={change:l=>{const c={type:"change",target:s,currentTarget:s,srcElement:s};s.trigger(c),e==="text"&&this[vn.remoteText.getterName]().trigger(c)},addtrack(l){s.addTrack(l.track)},removetrack(l){s.removeTrack(l.track)}},a=function(){const l=[];for(let c=0;c<s.length;c++){let f=!1;for(let m=0;m<n.length;m++)if(n[m]===s[c]){f=!0;break}f||l.push(s[c])}for(;l.length;)s.removeTrack(l.shift())};this[t.getterName+"Listeners_"]=r,Object.keys(r).forEach(l=>{const c=r[l];n.addEventListener(l,c),this.on("dispose",f=>n.removeEventListener(l,c))}),this.on("loadstart",a),this.on("dispose",l=>this.off("loadstart",a))}proxyNativeTracks_(){xt.names.forEach(e=>{this.proxyNativeTracksForType_(e)})}createEl(){let e=this.options_.tag;if(!e||!(this.options_.playerElIngest||this.movingMediaElementInDOM)){if(e){const n=e.cloneNode(!0);e.parentNode&&e.parentNode.insertBefore(n,e),J.disposeMediaElement(e),e=n}else{e=G.createElement("video");const n=this.options_.tag&&_i(this.options_.tag),s=ve({},n);(!ps||this.options_.nativeControlsForTouch!==!0)&&delete s.controls,Rh(e,Object.assign(s,{id:this.options_.techId,class:"vjs-tech"}))}e.playerId=this.options_.playerId}typeof this.options_.preload<"u"&&yn(e,"preload",this.options_.preload),this.options_.disablePictureInPicture!==void 0&&(e.disablePictureInPicture=this.options_.disablePictureInPicture);const t=["loop","muted","playsinline","autoplay"];for(let n=0;n<t.length;n++){const s=t[n],r=this.options_[s];typeof r<"u"&&(r?yn(e,s,s):zr(e,s),e[s]=r)}return e}handleLateInit_(e){if(e.networkState===0||e.networkState===3)return;if(e.readyState===0){let n=!1;const s=function(){n=!0};this.on("loadstart",s);const r=function(){n||this.trigger("loadstart")};this.on("loadedmetadata",r),this.ready(function(){this.off("loadstart",s),this.off("loadedmetadata",r),n||this.trigger("loadstart")});return}const t=["loadstart"];t.push("loadedmetadata"),e.readyState>=2&&t.push("loadeddata"),e.readyState>=3&&t.push("canplay"),e.readyState>=4&&t.push("canplaythrough"),this.ready(function(){t.forEach(function(n){this.trigger(n)},this)})}setScrubbing(e){this.isScrubbing_=e}scrubbing(){return this.isScrubbing_}setCurrentTime(e){try{this.isScrubbing_&&this.el_.fastSeek&&Vr?this.el_.fastSeek(e):this.el_.currentTime=e}catch(t){oe(t,"Video is not ready. (Video.js)")}}duration(){if(this.el_.duration===1/0&&Nt&&Jt&&this.el_.currentTime===0){const e=()=>{this.el_.currentTime>0&&(this.el_.duration===1/0&&this.trigger("durationchange"),this.off("timeupdate",e))};return this.on("timeupdate",e),NaN}return this.el_.duration||NaN}width(){return this.el_.offsetWidth}height(){return this.el_.offsetHeight}proxyWebkitFullscreen_(){if(!("webkitDisplayingFullscreen"in this.el_))return;const e=function(){this.trigger("fullscreenchange",{isFullscreen:!1}),this.el_.controls&&!this.options_.nativeControlsForTouch&&this.controls()&&(this.el_.controls=!1)},t=function(){"webkitPresentationMode"in this.el_&&this.el_.webkitPresentationMode!=="picture-in-picture"&&(this.one("webkitendfullscreen",e),this.trigger("fullscreenchange",{isFullscreen:!0,nativeIOSFullscreen:!0}))};this.on("webkitbeginfullscreen",t),this.on("dispose",()=>{this.off("webkitbeginfullscreen",t),this.off("webkitendfullscreen",e)})}supportsFullScreen(){return typeof this.el_.webkitEnterFullScreen=="function"}enterFullScreen(){const e=this.el_;if(e.paused&&e.networkState<=e.HAVE_METADATA)Gt(this.el_.play()),this.setTimeout(function(){e.pause();try{e.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}},0);else try{e.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}}exitFullScreen(){if(!this.el_.webkitDisplayingFullscreen){this.trigger("fullscreenerror",new Error("The video is not fullscreen"));return}this.el_.webkitExitFullScreen()}requestPictureInPicture(){return this.el_.requestPictureInPicture()}requestVideoFrameCallback(e){return this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.requestVideoFrameCallback(e):super.requestVideoFrameCallback(e)}cancelVideoFrameCallback(e){this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.cancelVideoFrameCallback(e):super.cancelVideoFrameCallback(e)}src(e){if(e===void 0)return this.el_.src;this.setSrc(e)}addSourceElement(e,t){if(!e)return oe.error("Invalid source URL."),!1;const n={src:e};t&&(n.type=t);const s=ne("source",{},n);return this.el_.appendChild(s),!0}removeSourceElement(e){if(!e)return oe.error("Source URL is required to remove the source element."),!1;const t=this.el_.querySelectorAll("source");for(const n of t)if(n.src===e)return this.el_.removeChild(n),!0;return oe.warn(`No matching source element found with src: ${e}`),!1}reset(){J.resetMediaElement(this.el_)}currentSrc(){return this.currentSource_?this.currentSource_.src:this.el_.currentSrc}setControls(e){this.el_.controls=!!e}addTextTrack(e,t,n){return this.featuresNativeTextTracks?this.el_.addTextTrack(e,t,n):super.addTextTrack(e,t,n)}createRemoteTextTrack(e){if(!this.featuresNativeTextTracks)return super.createRemoteTextTrack(e);const t=G.createElement("track");return e.kind&&(t.kind=e.kind),e.label&&(t.label=e.label),(e.language||e.srclang)&&(t.srclang=e.language||e.srclang),e.default&&(t.default=e.default),e.id&&(t.id=e.id),e.src&&(t.src=e.src),t}addRemoteTextTrack(e,t){const n=super.addRemoteTextTrack(e,t);return this.featuresNativeTextTracks&&this.el().appendChild(n),n}removeRemoteTextTrack(e){if(super.removeRemoteTextTrack(e),this.featuresNativeTextTracks){const t=this.$$("track");let n=t.length;for(;n--;)(e===t[n]||e===t[n].track)&&this.el().removeChild(t[n])}}getVideoPlaybackQuality(){if(typeof this.el().getVideoPlaybackQuality=="function")return this.el().getVideoPlaybackQuality();const e={};return typeof this.el().webkitDroppedFrameCount<"u"&&typeof this.el().webkitDecodedFrameCount<"u"&&(e.droppedVideoFrames=this.el().webkitDroppedFrameCount,e.totalVideoFrames=this.el().webkitDecodedFrameCount),x.performance&&(e.creationTime=x.performance.now()),e}}Fr(J,"TEST_VID",function(){if(!En())return;const i=G.createElement("video"),e=G.createElement("track");return e.kind="captions",e.srclang="en",e.label="English",i.appendChild(e),i});J.isSupported=function(){try{J.TEST_VID.volume=.5}catch{return!1}return!!(J.TEST_VID&&J.TEST_VID.canPlayType)};J.canPlayType=function(i){return J.TEST_VID.canPlayType(i)};J.canPlaySource=function(i,e){return J.canPlayType(i.type)};J.canControlVolume=function(){try{const i=J.TEST_VID.volume;J.TEST_VID.volume=i/2+.1;const e=i!==J.TEST_VID.volume;return e&&Je?(x.setTimeout(()=>{J&&J.prototype&&(J.prototype.featuresVolumeControl=i!==J.TEST_VID.volume)}),!1):e}catch{return!1}};J.canMuteVolume=function(){try{const i=J.TEST_VID.muted;return J.TEST_VID.muted=!i,J.TEST_VID.muted?yn(J.TEST_VID,"muted","muted"):zr(J.TEST_VID,"muted","muted"),i!==J.TEST_VID.muted}catch{return!1}};J.canControlPlaybackRate=function(){if(Nt&&Jt&&jr<58)return!1;try{const i=J.TEST_VID.playbackRate;return J.TEST_VID.playbackRate=i/2+.1,i!==J.TEST_VID.playbackRate}catch{return!1}};J.canOverrideAttributes=function(){try{const i=()=>{};Object.defineProperty(G.createElement("video"),"src",{get:i,set:i}),Object.defineProperty(G.createElement("audio"),"src",{get:i,set:i}),Object.defineProperty(G.createElement("video"),"innerHTML",{get:i,set:i}),Object.defineProperty(G.createElement("audio"),"innerHTML",{get:i,set:i})}catch{return!1}return!0};J.supportsNativeTextTracks=function(){return Vr||Je&&Jt};J.supportsNativeVideoTracks=function(){return!!(J.TEST_VID&&J.TEST_VID.videoTracks)};J.supportsNativeAudioTracks=function(){return!!(J.TEST_VID&&J.TEST_VID.audioTracks)};J.Events=["loadstart","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","progress","play","pause","ratechange","resize","volumechange"];[["featuresMuteControl","canMuteVolume"],["featuresPlaybackRate","canControlPlaybackRate"],["featuresSourceset","canOverrideAttributes"],["featuresNativeTextTracks","supportsNativeTextTracks"],["featuresNativeVideoTracks","supportsNativeVideoTracks"],["featuresNativeAudioTracks","supportsNativeAudioTracks"]].forEach(function([i,e]){Fr(J.prototype,i,()=>J[e](),!0)});J.prototype.featuresVolumeControl=J.canControlVolume();J.prototype.movingMediaElementInDOM=!Je;J.prototype.featuresFullscreenResize=!0;J.prototype.featuresProgressEvents=!0;J.prototype.featuresTimeupdateEvents=!0;J.prototype.featuresVideoFrameCallback=!!(J.TEST_VID&&J.TEST_VID.requestVideoFrameCallback);J.disposeMediaElement=function(i){if(i){for(i.parentNode&&i.parentNode.removeChild(i);i.hasChildNodes();)i.removeChild(i.firstChild);i.removeAttribute("src"),typeof i.load=="function"&&function(){try{i.load()}catch{}}()}};J.resetMediaElement=function(i){if(!i)return;const e=i.querySelectorAll("source");let t=e.length;for(;t--;)i.removeChild(e[t]);i.removeAttribute("src"),typeof i.load=="function"&&function(){try{i.load()}catch{}}()};["muted","defaultMuted","autoplay","controls","loop","playsinline"].forEach(function(i){J.prototype[i]=function(){return this.el_[i]||this.el_.hasAttribute(i)}});["muted","defaultMuted","autoplay","loop","playsinline"].forEach(function(i){J.prototype["set"+Ne(i)]=function(e){this.el_[i]=e,e?this.el_.setAttribute(i,i):this.el_.removeAttribute(i)}});["paused","currentTime","buffered","volume","poster","preload","error","seeking","seekable","ended","playbackRate","defaultPlaybackRate","disablePictureInPicture","played","networkState","readyState","videoWidth","videoHeight","crossOrigin"].forEach(function(i){J.prototype[i]=function(){return this.el_[i]}});["volume","src","poster","preload","playbackRate","defaultPlaybackRate","disablePictureInPicture","crossOrigin"].forEach(function(i){J.prototype["set"+Ne(i)]=function(e){this.el_[i]=e}});["pause","load","play"].forEach(function(i){J.prototype[i]=function(){return this.el_[i]()}});ae.withSourceHandlers(J);J.nativeSourceHandler={};J.nativeSourceHandler.canPlayType=function(i){try{return J.TEST_VID.canPlayType(i)}catch{return""}};J.nativeSourceHandler.canHandleSource=function(i,e){if(i.type)return J.nativeSourceHandler.canPlayType(i.type);if(i.src){const t=Wo(i.src);return J.nativeSourceHandler.canPlayType(`video/${t}`)}return""};J.nativeSourceHandler.handleSource=function(i,e,t){e.setSrc(i.src)};J.nativeSourceHandler.dispose=function(){};J.registerSourceHandler(J.nativeSourceHandler);ae.registerTech("Html5",J);const Nc=["progress","abort","suspend","emptied","stalled","loadedmetadata","loadeddata","timeupdate","resize","volumechange","texttrackchange"],$a={canplay:"CanPlay",canplaythrough:"CanPlayThrough",playing:"Playing",seeked:"Seeked"},ro=["tiny","xsmall","small","medium","large","xlarge","huge"],sr={};ro.forEach(i=>{const e=i.charAt(0)==="x"?`x-${i.substring(1)}`:i;sr[i]=`vjs-layout-${e}`});const jb={tiny:210,xsmall:320,small:425,medium:768,large:1440,xlarge:2560,huge:1/0};class Ae extends H{constructor(e,t,n){if(e.id=e.id||t.id||`vjs_video_${At()}`,t=Object.assign(Ae.getTagSettings(e),t),t.initChildren=!1,t.createEl=!1,t.evented=!1,t.reportTouchActivity=!1,!t.language){const a=e.closest("[lang]");a&&(t.language=a.getAttribute("lang"))}if(super(null,t,n),this.boundDocumentFullscreenChange_=a=>this.documentFullscreenChange_(a),this.boundFullWindowOnEscKey_=a=>this.fullWindowOnEscKey(a),this.boundUpdateStyleEl_=a=>this.updateStyleEl_(a),this.boundApplyInitTime_=a=>this.applyInitTime_(a),this.boundUpdateCurrentBreakpoint_=a=>this.updateCurrentBreakpoint_(a),this.boundHandleTechClick_=a=>this.handleTechClick_(a),this.boundHandleTechDoubleClick_=a=>this.handleTechDoubleClick_(a),this.boundHandleTechTouchStart_=a=>this.handleTechTouchStart_(a),this.boundHandleTechTouchMove_=a=>this.handleTechTouchMove_(a),this.boundHandleTechTouchEnd_=a=>this.handleTechTouchEnd_(a),this.boundHandleTechTap_=a=>this.handleTechTap_(a),this.boundUpdatePlayerHeightOnAudioOnlyMode_=a=>this.updatePlayerHeightOnAudioOnlyMode_(a),this.isFullscreen_=!1,this.log=Eh(this.id_),this.fsApi_=dr,this.isPosterFromTech_=!1,this.queuedCallbacks_=[],this.isReady_=!1,this.hasStarted_=!1,this.userActive_=!1,this.debugEnabled_=!1,this.audioOnlyMode_=!1,this.audioPosterMode_=!1,this.audioOnlyCache_={controlBarHeight:null,playerHeight:null,hiddenChildren:[]},!this.options_||!this.options_.techOrder||!this.options_.techOrder.length)throw new Error("No techOrder specified. Did you overwrite videojs.options instead of just changing the properties you want to override?");if(this.tag=e,this.tagAttributes=e&&_i(e),this.language(this.options_.language),t.languages){const a={};Object.getOwnPropertyNames(t.languages).forEach(function(l){a[l.toLowerCase()]=t.languages[l]}),this.languages_=a}else this.languages_=Ae.prototype.options_.languages;this.resetCache_(),this.poster_=t.poster||"",this.controls_=!!t.controls,e.controls=!1,e.removeAttribute("controls"),this.changingSrc_=!1,this.playCallbacks_=[],this.playTerminatedQueue_=[],e.hasAttribute("autoplay")?this.autoplay(!0):this.autoplay(this.options_.autoplay),t.plugins&&Object.keys(t.plugins).forEach(a=>{if(typeof this[a]!="function")throw new Error(`plugin "${a}" does not exist`)}),this.scrubbing_=!1,this.el_=this.createEl(),qo(this,{eventBusKey:"el_"}),this.fsApi_.requestFullscreen&&(vt(G,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),this.on(this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_)),this.fluid_&&this.on(["playerreset","resize"],this.boundUpdateStyleEl_);const s=ve(this.options_);if(t.plugins&&Object.keys(t.plugins).forEach(a=>{this[a](t.plugins[a])}),t.debug&&this.debug(!0),this.options_.playerOptions=s,this.middleware_=[],this.playbackRates(t.playbackRates),t.experimentalSvgIcons){const a=new x.DOMParser().parseFromString(ub,"image/svg+xml");if(a.querySelector("parsererror"))oe.warn("Failed to load SVG Icons. Falling back to Font Icons."),this.options_.experimentalSvgIcons=null;else{const l=a.documentElement;l.style.display="none",this.el_.appendChild(l),this.addClass("vjs-svg-icons-enabled")}}this.initChildren(),this.isAudio(e.nodeName.toLowerCase()==="audio"),this.controls()?this.addClass("vjs-controls-enabled"):this.addClass("vjs-controls-disabled"),this.el_.setAttribute("role","region"),this.isAudio()?this.el_.setAttribute("aria-label",this.localize("Audio Player")):this.el_.setAttribute("aria-label",this.localize("Video Player")),this.isAudio()&&this.addClass("vjs-audio"),t.spatialNavigation&&t.spatialNavigation.enabled&&(this.spatialNavigation=new db(this),this.addClass("vjs-spatial-navigation-enabled")),ps&&this.addClass("vjs-touch-enabled"),Je||this.addClass("vjs-workinghover"),Ae.players[this.id_]=this;const r=Ka.split(".")[0];this.addClass(`vjs-v${r}`),this.userActive(!0),this.reportUserActivity(),this.one("play",a=>this.listenForUserActivity_(a)),this.on("keydown",a=>this.handleKeyDown(a)),this.on("languagechange",a=>this.handleLanguagechange(a)),this.breakpoints(this.options_.breakpoints),this.responsive(this.options_.responsive),this.on("ready",()=>{this.audioPosterMode(this.options_.audioPosterMode),this.audioOnlyMode(this.options_.audioOnlyMode)})}dispose(){this.trigger("dispose"),this.off("dispose"),Ze(G,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),Ze(G,"keydown",this.boundFullWindowOnEscKey_),this.styleEl_&&this.styleEl_.parentNode&&(this.styleEl_.parentNode.removeChild(this.styleEl_),this.styleEl_=null),Ae.players[this.id_]=null,this.tag&&this.tag.player&&(this.tag.player=null),this.el_&&this.el_.player&&(this.el_.player=null),this.tech_&&(this.tech_.dispose(),this.isPosterFromTech_=!1,this.poster_=""),this.playerElIngest_&&(this.playerElIngest_=null),this.tag&&(this.tag=null),rb(this),at.names.forEach(e=>{const t=at[e],n=this[t.getterName]();n&&n.off&&n.off()}),super.dispose({restoreEl:this.options_.restoreEl})}createEl(){let e=this.tag,t,n=this.playerElIngest_=e.parentNode&&e.parentNode.hasAttribute&&e.parentNode.hasAttribute("data-vjs-player");const s=this.tag.tagName.toLowerCase()==="video-js";n?t=this.el_=e.parentNode:s||(t=this.el_=super.createEl("div"));const r=_i(e);if(s){for(t=this.el_=e,e=this.tag=G.createElement("video");t.children.length;)e.appendChild(t.firstChild);os(t,"video-js")||Bi(t,"video-js"),t.appendChild(e),n=this.playerElIngest_=t,Object.keys(t).forEach(c=>{try{e[c]=t[c]}catch{}})}e.setAttribute("tabindex","-1"),r.tabindex="-1",Jt&&$r&&(e.setAttribute("role","application"),r.role="application"),e.removeAttribute("width"),e.removeAttribute("height"),"width"in r&&delete r.width,"height"in r&&delete r.height,Object.getOwnPropertyNames(r).forEach(function(c){s&&c==="class"||t.setAttribute(c,r[c]),s&&e.setAttribute(c,r[c])}),e.playerId=e.id,e.id+="_html5_api",e.className="vjs-tech",e.player=t.player=this,this.addClass("vjs-paused");const a=["IS_SMART_TV","IS_TIZEN","IS_WEBOS","IS_ANDROID","IS_IPAD","IS_IPHONE","IS_CHROMECAST_RECEIVER"].filter(c=>Lh[c]).map(c=>"vjs-device-"+c.substring(3).toLowerCase().replace(/\_/g,"-"));if(this.addClass(...a),x.VIDEOJS_NO_DYNAMIC_STYLE!==!0){this.styleEl_=Wh("vjs-styles-dimensions");const c=vi(".vjs-styles-defaults"),f=vi("head");f.insertBefore(this.styleEl_,c?c.nextSibling:f.firstChild)}this.fill_=!1,this.fluid_=!1,this.width(this.options_.width),this.height(this.options_.height),this.fill(this.options_.fill),this.fluid(this.options_.fluid),this.aspectRatio(this.options_.aspectRatio),this.crossOrigin(this.options_.crossOrigin||this.options_.crossorigin);const l=e.getElementsByTagName("a");for(let c=0;c<l.length;c++){const f=l.item(c);Bi(f,"vjs-hidden"),f.setAttribute("hidden","hidden")}return e.initNetworkState_=e.networkState,e.parentNode&&!n&&e.parentNode.insertBefore(t,e),Qa(e,t),this.children_.unshift(e),this.el_.setAttribute("lang",this.language_),this.el_.setAttribute("translate","no"),this.el_=t,t}crossOrigin(e){if(typeof e>"u")return this.techGet_("crossOrigin");if(e!==null&&e!=="anonymous"&&e!=="use-credentials"){oe.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`);return}this.techCall_("setCrossOrigin",e),this.posterImage&&this.posterImage.crossOrigin(e)}width(e){return this.dimension("width",e)}height(e){return this.dimension("height",e)}dimension(e,t){const n=e+"_";if(t===void 0)return this[n]||0;if(t===""||t==="auto"){this[n]=void 0,this.updateStyleEl_();return}const s=parseFloat(t);if(isNaN(s)){oe.error(`Improper value "${t}" supplied for for ${e}`);return}this[n]=s,this.updateStyleEl_()}fluid(e){if(e===void 0)return!!this.fluid_;this.fluid_=!!e,si(this)&&this.off(["playerreset","resize"],this.boundUpdateStyleEl_),e?(this.addClass("vjs-fluid"),this.fill(!1),R1(this,()=>{this.on(["playerreset","resize"],this.boundUpdateStyleEl_)})):this.removeClass("vjs-fluid"),this.updateStyleEl_()}fill(e){if(e===void 0)return!!this.fill_;this.fill_=!!e,e?(this.addClass("vjs-fill"),this.fluid(!1)):this.removeClass("vjs-fill")}aspectRatio(e){if(e===void 0)return this.aspectRatio_;if(!/^\d+\:\d+$/.test(e))throw new Error("Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.");this.aspectRatio_=e,this.fluid(!0),this.updateStyleEl_()}updateStyleEl_(){if(x.VIDEOJS_NO_DYNAMIC_STYLE===!0){const l=typeof this.width_=="number"?this.width_:this.options_.width,c=typeof this.height_=="number"?this.height_:this.options_.height,f=this.tech_&&this.tech_.el();f&&(l>=0&&(f.width=l),c>=0&&(f.height=c));return}let e,t,n,s;this.aspectRatio_!==void 0&&this.aspectRatio_!=="auto"?n=this.aspectRatio_:this.videoWidth()>0?n=this.videoWidth()+":"+this.videoHeight():n="16:9";const r=n.split(":"),a=r[1]/r[0];this.width_!==void 0?e=this.width_:this.height_!==void 0?e=this.height_/a:e=this.videoWidth()||300,this.height_!==void 0?t=this.height_:t=e*a,/^[^a-zA-Z]/.test(this.id())?s="dimensions-"+this.id():s=this.id()+"-dimensions",this.addClass(s),Gh(this.styleEl_,`
|
|
168
168
|
.${s} {
|
|
169
169
|
width: ${e}px;
|
|
170
170
|
height: ${t}px;
|
|
@@ -173,9 +173,9 @@ This may prevent text tracks from loading.`),this.restoreMetadataTracksInIOSNati
|
|
|
173
173
|
.${s}.vjs-fluid:not(.vjs-audio-only-mode) {
|
|
174
174
|
padding-top: ${a*100}%;
|
|
175
175
|
}
|
|
176
|
-
`)}loadTech_(e,t){this.tech_&&this.unloadTech_();const n=Ne(e),s=e.charAt(0).toLowerCase()+e.slice(1);n!=="Html5"&&this.tag&&(ae.getTech("Html5").disposeMediaElement(this.tag),this.tag.player=null,this.tag=null),this.techName_=n,this.isReady_=!1;let r=this.autoplay();(typeof this.autoplay()=="string"||this.autoplay()===!0&&this.options_.normalizeAutoplay)&&(r=!1);const a={source:t,autoplay:r,nativeControlsForTouch:this.options_.nativeControlsForTouch,playerId:this.id(),techId:`${this.id()}_${s}_api`,playsinline:this.options_.playsinline,preload:this.options_.preload,loop:this.options_.loop,disablePictureInPicture:this.options_.disablePictureInPicture,muted:this.options_.muted,poster:this.poster(),language:this.language(),playerElIngest:this.playerElIngest_||!1,"vtt.js":this.options_["vtt.js"],canOverridePoster:!!this.options_.techCanOverridePoster,enableSourceset:this.options_.enableSourceset};at.names.forEach(c=>{const
|
|
176
|
+
`)}loadTech_(e,t){this.tech_&&this.unloadTech_();const n=Ne(e),s=e.charAt(0).toLowerCase()+e.slice(1);n!=="Html5"&&this.tag&&(ae.getTech("Html5").disposeMediaElement(this.tag),this.tag.player=null,this.tag=null),this.techName_=n,this.isReady_=!1;let r=this.autoplay();(typeof this.autoplay()=="string"||this.autoplay()===!0&&this.options_.normalizeAutoplay)&&(r=!1);const a={source:t,autoplay:r,nativeControlsForTouch:this.options_.nativeControlsForTouch,playerId:this.id(),techId:`${this.id()}_${s}_api`,playsinline:this.options_.playsinline,preload:this.options_.preload,loop:this.options_.loop,disablePictureInPicture:this.options_.disablePictureInPicture,muted:this.options_.muted,poster:this.poster(),language:this.language(),playerElIngest:this.playerElIngest_||!1,"vtt.js":this.options_["vtt.js"],canOverridePoster:!!this.options_.techCanOverridePoster,enableSourceset:this.options_.enableSourceset};at.names.forEach(c=>{const f=at[c];a[f.getterName]=this[f.privateName]}),Object.assign(a,this.options_[n]),Object.assign(a,this.options_[s]),Object.assign(a,this.options_[e.toLowerCase()]),this.tag&&(a.tag=this.tag),t&&t.src===this.cache_.src&&this.cache_.currentTime>0&&(a.startTime=this.cache_.currentTime);const l=ae.getTech(e);if(!l)throw new Error(`No Tech named '${n}' exists! '${n}' should be registered using videojs.registerTech()'`);this.tech_=new l(a),this.tech_.ready(Ce(this,this.handleTechReady_),!0),Nu.jsonToTextTracks(this.textTracksJson_||[],this.tech_),Nc.forEach(c=>{this.on(this.tech_,c,f=>this[`handleTech${Ne(c)}_`](f))}),Object.keys($a).forEach(c=>{this.on(this.tech_,c,f=>{if(this.tech_.playbackRate()===0&&this.tech_.seeking()){this.queuedCallbacks_.push({callback:this[`handleTech${$a[c]}_`].bind(this),event:f});return}this[`handleTech${$a[c]}_`](f)})}),this.on(this.tech_,"loadstart",c=>this.handleTechLoadStart_(c)),this.on(this.tech_,"sourceset",c=>this.handleTechSourceset_(c)),this.on(this.tech_,"waiting",c=>this.handleTechWaiting_(c)),this.on(this.tech_,"ended",c=>this.handleTechEnded_(c)),this.on(this.tech_,"seeking",c=>this.handleTechSeeking_(c)),this.on(this.tech_,"play",c=>this.handleTechPlay_(c)),this.on(this.tech_,"pause",c=>this.handleTechPause_(c)),this.on(this.tech_,"durationchange",c=>this.handleTechDurationChange_(c)),this.on(this.tech_,"fullscreenchange",(c,f)=>this.handleTechFullscreenChange_(c,f)),this.on(this.tech_,"fullscreenerror",(c,f)=>this.handleTechFullscreenError_(c,f)),this.on(this.tech_,"enterpictureinpicture",c=>this.handleTechEnterPictureInPicture_(c)),this.on(this.tech_,"leavepictureinpicture",c=>this.handleTechLeavePictureInPicture_(c)),this.on(this.tech_,"error",c=>this.handleTechError_(c)),this.on(this.tech_,"posterchange",c=>this.handleTechPosterChange_(c)),this.on(this.tech_,"textdata",c=>this.handleTechTextData_(c)),this.on(this.tech_,"ratechange",c=>this.handleTechRateChange_(c)),this.on(this.tech_,"loadedmetadata",this.boundUpdateStyleEl_),this.usingNativeControls(this.techGet_("controls")),this.controls()&&!this.usingNativeControls()&&this.addTechControlsListeners_(),this.tech_.el().parentNode!==this.el()&&(n!=="Html5"||!this.tag)&&Qa(this.tech_.el(),this.el()),this.tag&&(this.tag.player=null,this.tag=null)}unloadTech_(){at.names.forEach(e=>{const t=at[e];this[t.privateName]=this[t.getterName]()}),this.textTracksJson_=Nu.textTracksToJson(this.tech_),this.isReady_=!1,this.tech_.dispose(),this.tech_=!1,this.isPosterFromTech_&&(this.poster_="",this.trigger("posterchange")),this.isPosterFromTech_=!1}tech(e){return e===void 0&&oe.warn(`Using the tech directly can be dangerous. I hope you know what you're doing.
|
|
177
177
|
See https://github.com/videojs/video.js/issues/2617 for more info.
|
|
178
|
-
`),this.tech_}version(){return{"video.js":Ya}}addTechControlsListeners_(){this.removeTechControlsListeners_(),this.on(this.tech_,"click",this.boundHandleTechClick_),this.on(this.tech_,"dblclick",this.boundHandleTechDoubleClick_),this.on(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.on(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.on(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.on(this.tech_,"tap",this.boundHandleTechTap_)}removeTechControlsListeners_(){this.off(this.tech_,"tap",this.boundHandleTechTap_),this.off(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.off(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.off(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.off(this.tech_,"click",this.boundHandleTechClick_),this.off(this.tech_,"dblclick",this.boundHandleTechDoubleClick_)}handleTechReady_(){this.triggerReady(),this.cache_.volume&&this.techCall_("setVolume",this.cache_.volume),this.handleTechPosterChange_(),this.handleTechDurationChange_()}handleTechLoadStart_(){this.removeClass("vjs-ended","vjs-seeking"),this.error(null),this.handleTechDurationChange_(),this.paused()?(this.hasStarted(!1),this.trigger("loadstart")):this.trigger("loadstart"),this.manualAutoplay_(this.autoplay()===!0&&this.options_.normalizeAutoplay?"play":this.autoplay())}manualAutoplay_(e){if(!this.tech_||typeof e!="string")return;const t=()=>{const s=this.muted();this.muted(!0);const r=()=>{this.muted(s)};this.playTerminatedQueue_.push(r);const a=this.play();if(ls(a))return a.catch(l=>{throw r(),new Error(`Rejection at manualAutoplay. Restoring muted value. ${l||""}`)})};let n;if(e==="any"&&!this.muted()?(n=this.play(),ls(n)&&(n=n.catch(t))):e==="muted"&&!this.muted()?n=t():n=this.play(),!!ls(n))return n.then(()=>{this.trigger({type:"autoplay-success",autoplay:e})}).catch(()=>{this.trigger({type:"autoplay-failure",autoplay:e})})}updateSourceCaches_(e=""){let t=e,n="";typeof t!="string"&&(t=e.src,n=e.type),this.cache_.source=this.cache_.source||{},this.cache_.sources=this.cache_.sources||[],t&&!n&&(n=_b(this,t)),this.cache_.source=ve({},e,{src:t,type:n});const s=this.cache_.sources.filter(c=>c.src&&c.src===t),r=[],a=this.$$("source"),l=[];for(let c=0;c<a.length;c++){const g=_i(a[c]);r.push(g),g.src&&g.src===t&&l.push(g.src)}l.length&&!s.length?this.cache_.sources=r:s.length||(this.cache_.sources=[this.cache_.source]),this.cache_.src=t}handleTechSourceset_(e){if(!this.changingSrc_){let t=r=>this.updateSourceCaches_(r);const n=this.currentSource().src,s=e.src;n&&!/^blob:/.test(n)&&/^blob:/.test(s)&&(!this.lastSource_||this.lastSource_.tech!==s&&this.lastSource_.player!==n)&&(t=()=>{}),t(s),e.src||this.tech_.any(["sourceset","loadstart"],r=>{if(r.type==="sourceset")return;const a=this.techGet_("currentSrc");this.lastSource_.tech=a,this.updateSourceCaches_(a)})}this.lastSource_={player:this.currentSource().src,tech:e.src},this.trigger({src:e.src,type:"sourceset"})}hasStarted(e){if(e===void 0)return this.hasStarted_;e!==this.hasStarted_&&(this.hasStarted_=e,this.hasStarted_?this.addClass("vjs-has-started"):this.removeClass("vjs-has-started"))}handleTechPlay_(){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.hasStarted(!0),this.trigger("play")}handleTechRateChange_(){this.tech_.playbackRate()>0&&this.cache_.lastPlaybackRate===0&&(this.queuedCallbacks_.forEach(e=>e.callback(e.event)),this.queuedCallbacks_=[]),this.cache_.lastPlaybackRate=this.tech_.playbackRate(),this.trigger("ratechange")}handleTechWaiting_(){this.addClass("vjs-waiting"),this.trigger("waiting");const e=this.currentTime(),t=()=>{e!==this.currentTime()&&(this.removeClass("vjs-waiting"),this.off("timeupdate",t))};this.on("timeupdate",t)}handleTechCanPlay_(){this.removeClass("vjs-waiting"),this.trigger("canplay")}handleTechCanPlayThrough_(){this.removeClass("vjs-waiting"),this.trigger("canplaythrough")}handleTechPlaying_(){this.removeClass("vjs-waiting"),this.trigger("playing")}handleTechSeeking_(){this.addClass("vjs-seeking"),this.trigger("seeking")}handleTechSeeked_(){this.removeClass("vjs-seeking","vjs-ended"),this.trigger("seeked")}handleTechPause_(){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.trigger("pause")}handleTechEnded_(){this.addClass("vjs-ended"),this.removeClass("vjs-waiting"),this.options_.loop?(this.currentTime(0),this.play()):this.paused()||this.pause(),this.trigger("ended")}handleTechDurationChange_(){this.duration(this.techGet_("duration"))}handleTechClick_(e){this.controls_&&(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.click===void 0||this.options_.userActions.click!==!1)&&(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.click=="function"?this.options_.userActions.click.call(this,e):this.paused()?Gt(this.play()):this.pause())}handleTechDoubleClick_(e){this.controls_&&(Array.prototype.some.call(this.$$(".vjs-control-bar, .vjs-modal-dialog"),t=>t.contains(e.target))||(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.doubleClick===void 0||this.options_.userActions.doubleClick!==!1)&&(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.doubleClick=="function"?this.options_.userActions.doubleClick.call(this,e):this.isInPictureInPicture()&&!G.pictureInPictureElement?this.exitPictureInPicture():this.isFullscreen()?this.exitFullscreen():this.requestFullscreen()))}handleTechTap_(){this.userActive(!this.userActive())}handleTechTouchStart_(){this.userWasActive=this.userActive()}handleTechTouchMove_(){this.userWasActive&&this.reportUserActivity()}handleTechTouchEnd_(e){e.cancelable&&e.preventDefault()}toggleFullscreenClass_(){this.isFullscreen()?this.addClass("vjs-fullscreen"):this.removeClass("vjs-fullscreen")}documentFullscreenChange_(e){const t=e.target.player;if(t&&t!==this)return;const n=this.el();let s=G[this.fsApi_.fullscreenElement]===n;!s&&n.matches&&(s=n.matches(":"+this.fsApi_.fullscreen)),this.isFullscreen(s)}handleTechFullscreenChange_(e,t){t&&(t.nativeIOSFullscreen&&(this.addClass("vjs-ios-native-fs"),this.tech_.one("webkitendfullscreen",()=>{this.removeClass("vjs-ios-native-fs")})),this.isFullscreen(t.isFullscreen))}handleTechFullscreenError_(e,t){this.trigger("fullscreenerror",t)}togglePictureInPictureClass_(){this.isInPictureInPicture()?this.addClass("vjs-picture-in-picture"):this.removeClass("vjs-picture-in-picture")}handleTechEnterPictureInPicture_(e){this.isInPictureInPicture(!0)}handleTechLeavePictureInPicture_(e){this.isInPictureInPicture(!1)}handleTechError_(){const e=this.tech_.error();e&&this.error(e)}handleTechTextData_(){let e=null;arguments.length>1&&(e=arguments[1]),this.trigger("textdata",e)}getCache(){return this.cache_}resetCache_(){this.cache_={currentTime:0,initTime:0,inactivityTimeout:this.options_.inactivityTimeout,duration:NaN,lastVolume:1,lastPlaybackRate:this.defaultPlaybackRate(),media:null,src:"",source:{},sources:[],playbackRates:[],volume:1}}techCall_(e,t){this.ready(function(){if(e in pb)return hb(this.middleware_,this.tech_,e,t);if(e in Hu)return Vu(this.middleware_,this.tech_,e,t);try{this.tech_&&this.tech_[e](t)}catch(n){throw le(n),n}},!0)}techGet_(e){if(!(!this.tech_||!this.tech_.isReady_)){if(e in cb)return db(this.middleware_,this.tech_,e);if(e in Hu)return Vu(this.middleware_,this.tech_,e);try{return this.tech_[e]()}catch(t){throw this.tech_[e]===void 0?(le(`Video.js: ${e} method not defined for ${this.techName_} playback technology.`,t),t):t.name==="TypeError"?(le(`Video.js: ${e} unavailable on ${this.techName_} playback technology element.`,t),this.tech_.isReady_=!1,t):(le(t),t)}}}play(){return new Promise(e=>{this.play_(e)})}play_(e=Gt){this.playCallbacks_.push(e);const t=!!(!this.changingSrc_&&(this.src()||this.currentSrc())),n=!!(Vr||Je);if(this.waitToPlay_&&(this.off(["ready","loadstart"],this.waitToPlay_),this.waitToPlay_=null),!this.isReady_||!t){this.waitToPlay_=r=>{this.play_()},this.one(["ready","loadstart"],this.waitToPlay_),!t&&n&&this.load();return}const s=this.techGet_("play");n&&this.hasClass("vjs-ended")&&this.resetProgressBar_(),s===null?this.runPlayTerminatedQueue_():this.runPlayCallbacks_(s)}runPlayTerminatedQueue_(){const e=this.playTerminatedQueue_.slice(0);this.playTerminatedQueue_=[],e.forEach(function(t){t()})}runPlayCallbacks_(e){const t=this.playCallbacks_.slice(0);this.playCallbacks_=[],this.playTerminatedQueue_=[],t.forEach(function(n){n(e)})}pause(){this.techCall_("pause")}paused(){return this.techGet_("paused")!==!1}played(){return this.techGet_("played")||Ut(0,0)}scrubbing(e){if(typeof e>"u")return this.scrubbing_;this.scrubbing_=!!e,this.techCall_("setScrubbing",this.scrubbing_),e?this.addClass("vjs-scrubbing"):this.removeClass("vjs-scrubbing")}currentTime(e){if(e===void 0)return this.cache_.currentTime=this.techGet_("currentTime")||0,this.cache_.currentTime;if(e<0&&(e=0),!this.isReady_||this.changingSrc_||!this.tech_||!this.tech_.isReady_){this.cache_.initTime=e,this.off("canplay",this.boundApplyInitTime_),this.one("canplay",this.boundApplyInitTime_);return}this.techCall_("setCurrentTime",e),this.cache_.initTime=0,isFinite(e)&&(this.cache_.currentTime=Number(e))}applyInitTime_(){this.currentTime(this.cache_.initTime)}duration(e){if(e===void 0)return this.cache_.duration!==void 0?this.cache_.duration:NaN;e=parseFloat(e),e<0&&(e=1/0),e!==this.cache_.duration&&(this.cache_.duration=e,e===1/0?this.addClass("vjs-live"):this.removeClass("vjs-live"),isNaN(e)||this.trigger("durationchange"))}remainingTime(){return this.duration()-this.currentTime()}remainingTimeDisplay(){return Math.floor(this.duration())-Math.floor(this.currentTime())}buffered(){let e=this.techGet_("buffered");return(!e||!e.length)&&(e=Ut(0,0)),e}seekable(){let e=this.techGet_("seekable");return(!e||!e.length)&&(e=Ut(0,0)),e}seeking(){return this.techGet_("seeking")}ended(){return this.techGet_("ended")}networkState(){return this.techGet_("networkState")}readyState(){return this.techGet_("readyState")}bufferedPercent(){return rc(this.buffered(),this.duration())}bufferedEnd(){const e=this.buffered(),t=this.duration();let n=e.end(e.length-1);return n>t&&(n=t),n}volume(e){let t;if(e!==void 0){t=Math.max(0,Math.min(1,e)),this.cache_.volume=t,this.techCall_("setVolume",t),t>0&&this.lastVolume_(t);return}return t=parseFloat(this.techGet_("volume")),isNaN(t)?1:t}muted(e){if(e!==void 0){this.techCall_("setMuted",e);return}return this.techGet_("muted")||!1}defaultMuted(e){return e!==void 0&&this.techCall_("setDefaultMuted",e),this.techGet_("defaultMuted")||!1}lastVolume_(e){if(e!==void 0&&e!==0){this.cache_.lastVolume=e;return}return this.cache_.lastVolume}supportsFullScreen(){return this.techGet_("supportsFullScreen")||!1}isFullscreen(e){if(e!==void 0){const t=this.isFullscreen_;this.isFullscreen_=!!e,this.isFullscreen_!==t&&this.fsApi_.prefixed&&this.trigger("fullscreenchange"),this.toggleFullscreenClass_();return}return this.isFullscreen_}requestFullscreen(e){this.isInPictureInPicture()&&this.exitPictureInPicture();const t=this;return new Promise((n,s)=>{function r(){t.off("fullscreenerror",l),t.off("fullscreenchange",a)}function a(){r(),n()}function l(g,m){r(),s(m)}t.one("fullscreenchange",a),t.one("fullscreenerror",l);const c=t.requestFullscreenHelper_(e);c&&(c.then(r,r),c.then(n,s))})}requestFullscreenHelper_(e){let t;if(this.fsApi_.prefixed||(t=this.options_.fullscreen&&this.options_.fullscreen.options||{},e!==void 0&&(t=e)),this.fsApi_.requestFullscreen){const n=this.el_[this.fsApi_.requestFullscreen](t);return n&&n.then(()=>this.isFullscreen(!0),()=>this.isFullscreen(!1)),n}else this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow?this.techCall_("enterFullScreen"):this.enterFullWindow()}exitFullscreen(){const e=this;return new Promise((t,n)=>{function s(){e.off("fullscreenerror",a),e.off("fullscreenchange",r)}function r(){s(),t()}function a(c,g){s(),n(g)}e.one("fullscreenchange",r),e.one("fullscreenerror",a);const l=e.exitFullscreenHelper_();l&&(l.then(s,s),l.then(t,n))})}exitFullscreenHelper_(){if(this.fsApi_.requestFullscreen){const e=G[this.fsApi_.exitFullscreen]();return e&&Gt(e.then(()=>this.isFullscreen(!1))),e}else this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow?this.techCall_("exitFullScreen"):this.exitFullWindow()}enterFullWindow(){this.isFullscreen(!0),this.isFullWindow=!0,this.docOrigOverflow=G.documentElement.style.overflow,vt(G,"keydown",this.boundFullWindowOnEscKey_),G.documentElement.style.overflow="hidden",Bi(G.body,"vjs-full-window"),this.trigger("enterFullWindow")}fullWindowOnEscKey(e){e.key==="Escape"&&this.isFullscreen()===!0&&(this.isFullWindow?this.exitFullWindow():this.exitFullscreen())}exitFullWindow(){this.isFullscreen(!1),this.isFullWindow=!1,Ze(G,"keydown",this.boundFullWindowOnEscKey_),G.documentElement.style.overflow=this.docOrigOverflow,Hr(G.body,"vjs-full-window"),this.trigger("exitFullWindow")}disablePictureInPicture(e){if(e===void 0)return this.techGet_("disablePictureInPicture");this.techCall_("setDisablePictureInPicture",e),this.options_.disablePictureInPicture=e,this.trigger("disablepictureinpicturechanged")}isInPictureInPicture(e){if(e!==void 0){this.isInPictureInPicture_=!!e,this.togglePictureInPictureClass_();return}return!!this.isInPictureInPicture_}requestPictureInPicture(){if(this.options_.enableDocumentPictureInPicture&&x.documentPictureInPicture){const e=G.createElement(this.el().tagName);return e.classList=this.el().classList,e.classList.add("vjs-pip-container"),this.posterImage&&e.appendChild(this.posterImage.el().cloneNode(!0)),this.titleBar&&e.appendChild(this.titleBar.el().cloneNode(!0)),e.appendChild(ne("p",{className:"vjs-pip-text"},{},this.localize("Playing in picture-in-picture"))),x.documentPictureInPicture.requestWindow({width:this.videoWidth(),height:this.videoHeight()}).then(t=>(Wh(t),this.el_.parentNode.insertBefore(e,this.el_),t.document.body.appendChild(this.el_),t.document.body.classList.add("vjs-pip-window"),this.player_.isInPictureInPicture(!0),this.player_.trigger({type:"enterpictureinpicture",pipWindow:t}),t.addEventListener("pagehide",n=>{const s=n.target.querySelector(".video-js");e.parentNode.replaceChild(s,e),this.player_.isInPictureInPicture(!1),this.player_.trigger("leavepictureinpicture")}),t))}return"pictureInPictureEnabled"in G&&this.disablePictureInPicture()===!1?this.techGet_("requestPictureInPicture"):Promise.reject("No PiP mode is available")}exitPictureInPicture(){if(x.documentPictureInPicture&&x.documentPictureInPicture.window)return x.documentPictureInPicture.window.close(),Promise.resolve();if("pictureInPictureEnabled"in G)return G.exitPictureInPicture()}handleKeyDown(e){const{userActions:t}=this.options_;!t||!t.hotkeys||(n=>{const s=n.tagName.toLowerCase();return n.isContentEditable?!0:s==="input"?["button","checkbox","hidden","radio","reset","submit"].indexOf(n.type)===-1:["textarea"].indexOf(s)!==-1})(this.el_.ownerDocument.activeElement)||(typeof t.hotkeys=="function"?t.hotkeys.call(this,e):this.handleHotkeys(e))}handleHotkeys(e){const t=this.options_.userActions?this.options_.userActions.hotkeys:{},{fullscreenKey:n=a=>e.key.toLowerCase()==="f",muteKey:s=a=>e.key.toLowerCase()==="m",playPauseKey:r=a=>e.key.toLowerCase()==="k"||e.key.toLowerCase()===" "}=t;if(n.call(this,e)){e.preventDefault(),e.stopPropagation();const a=H.getComponent("FullscreenToggle");G[this.fsApi_.fullscreenEnabled]!==!1&&a.prototype.handleClick.call(this,e)}else s.call(this,e)?(e.preventDefault(),e.stopPropagation(),H.getComponent("MuteToggle").prototype.handleClick.call(this,e)):r.call(this,e)&&(e.preventDefault(),e.stopPropagation(),H.getComponent("PlayToggle").prototype.handleClick.call(this,e))}canPlayType(e){let t;for(let n=0,s=this.options_.techOrder;n<s.length;n++){const r=s[n];let a=ae.getTech(r);if(a||(a=H.getComponent(r)),!a){le.error(`The "${r}" tech is undefined. Skipped browser support check for that tech.`);continue}if(a.isSupported()&&(t=a.canPlayType(e),t))return t}return""}selectSource(e){const t=this.options_.techOrder.map(l=>[l,ae.getTech(l)]).filter(([l,c])=>c?c.isSupported():(le.error(`The "${l}" tech is undefined. Skipped browser support check for that tech.`),!1)),n=function(l,c,g){let m;return l.some(b=>c.some(C=>{if(m=g(b,C),m)return!0})),m};let s;const r=l=>(c,g)=>l(g,c),a=([l,c],g)=>{if(c.canPlaySource(g,this.options_[l.toLowerCase()]))return{source:g,tech:l}};return this.options_.sourceOrder?s=n(e,t,r(a)):s=n(t,e,a),s||!1}handleSrc_(e,t){if(typeof e>"u")return this.cache_.src||"";this.resetRetryOnError_&&this.resetRetryOnError_();const n=dc(e);if(!n.length){this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0);return}if(this.changingSrc_=!0,t||(this.cache_.sources=n),this.updateSourceCaches_(n[0]),lb(this,n[0],(s,r)=>{if(this.middleware_=r,t||(this.cache_.sources=n),this.updateSourceCaches_(s),this.src_(s)){if(n.length>1)return this.handleSrc_(n.slice(1));this.changingSrc_=!1,this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0),this.triggerReady();return}ub(r,this.tech_)}),n.length>1){const s=()=>{this.error(null),this.handleSrc_(n.slice(1),!0)},r=()=>{this.off("error",s)};this.one("error",s),this.one("playing",r),this.resetRetryOnError_=()=>{this.off("error",s),this.off("playing",r)}}}src(e){return this.handleSrc_(e,!1)}src_(e){const t=this.selectSource([e]);return t?tc(t.tech,this.techName_)?(this.ready(function(){this.tech_.constructor.prototype.hasOwnProperty("setSource")?this.techCall_("setSource",e):this.techCall_("src",e.src),this.changingSrc_=!1},!0),!1):(this.changingSrc_=!0,this.loadTech_(t.tech,t.source),this.tech_.ready(()=>{this.changingSrc_=!1}),!1):!0}addSourceElement(e,t){return this.tech_?this.tech_.addSourceElement(e,t):!1}removeSourceElement(e){return this.tech_?this.tech_.removeSourceElement(e):!1}load(){if(this.tech_&&this.tech_.vhs){this.src(this.currentSource());return}this.techCall_("load")}reset(){if(this.paused())this.doReset_();else{const e=this.play();Gt(e.then(()=>this.doReset_()))}}doReset_(){this.tech_&&this.tech_.clearTracks("text"),this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.resetCache_(),this.poster(""),this.loadTech_(this.options_.techOrder[0],null),this.techCall_("reset"),this.resetControlBarUI_(),this.error(null),this.titleBar&&this.titleBar.update({title:void 0,description:void 0}),si(this)&&this.trigger("playerreset")}resetControlBarUI_(){this.resetProgressBar_(),this.resetPlaybackRate_(),this.resetVolumeBar_()}resetProgressBar_(){this.currentTime(0);const{currentTimeDisplay:e,durationDisplay:t,progressControl:n,remainingTimeDisplay:s}=this.controlBar||{},{seekBar:r}=n||{};e&&e.updateContent(),t&&t.updateContent(),s&&s.updateContent(),r&&(r.update(),r.loadProgressBar&&r.loadProgressBar.update())}resetPlaybackRate_(){this.playbackRate(this.defaultPlaybackRate()),this.handleTechRateChange_()}resetVolumeBar_(){this.volume(1),this.trigger("volumechange")}currentSources(){const e=this.currentSource(),t=[];return Object.keys(e).length!==0&&t.push(e),this.cache_.sources||t}currentSource(){return this.cache_.source||{}}currentSrc(){return this.currentSource()&&this.currentSource().src||""}currentType(){return this.currentSource()&&this.currentSource().type||""}preload(e){if(e!==void 0){this.techCall_("setPreload",e),this.options_.preload=e;return}return this.techGet_("preload")}autoplay(e){if(e===void 0)return this.options_.autoplay||!1;let t;typeof e=="string"&&/(any|play|muted)/.test(e)||e===!0&&this.options_.normalizeAutoplay?(this.options_.autoplay=e,this.manualAutoplay_(typeof e=="string"?e:"play"),t=!1):e?this.options_.autoplay=!0:this.options_.autoplay=!1,t=typeof t>"u"?this.options_.autoplay:t,this.tech_&&this.techCall_("setAutoplay",t)}playsinline(e){return e!==void 0&&(this.techCall_("setPlaysinline",e),this.options_.playsinline=e),this.techGet_("playsinline")}loop(e){if(e!==void 0){this.techCall_("setLoop",e),this.options_.loop=e;return}return this.techGet_("loop")}poster(e){if(e===void 0)return this.poster_;e||(e=""),e!==this.poster_&&(this.poster_=e,this.techCall_("setPoster",e),this.isPosterFromTech_=!1,this.trigger("posterchange"))}handleTechPosterChange_(){if((!this.poster_||this.options_.techCanOverridePoster)&&this.tech_&&this.tech_.poster){const e=this.tech_.poster()||"";e!==this.poster_&&(this.poster_=e,this.isPosterFromTech_=!0,this.trigger("posterchange"))}}controls(e){if(e===void 0)return!!this.controls_;e=!!e,this.controls_!==e&&(this.controls_=e,this.usingNativeControls()&&this.techCall_("setControls",e),this.controls_?(this.removeClass("vjs-controls-disabled"),this.addClass("vjs-controls-enabled"),this.trigger("controlsenabled"),this.usingNativeControls()||this.addTechControlsListeners_()):(this.removeClass("vjs-controls-enabled"),this.addClass("vjs-controls-disabled"),this.trigger("controlsdisabled"),this.usingNativeControls()||this.removeTechControlsListeners_()))}usingNativeControls(e){if(e===void 0)return!!this.usingNativeControls_;e=!!e,this.usingNativeControls_!==e&&(this.usingNativeControls_=e,this.usingNativeControls_?(this.addClass("vjs-using-native-controls"),this.trigger("usingnativecontrols")):(this.removeClass("vjs-using-native-controls"),this.trigger("usingcustomcontrols")))}error(e){if(e===void 0)return this.error_||null;if(Ti("beforeerror").forEach(t=>{const n=t(this,e);if(!(Qt(n)&&!Array.isArray(n)||typeof n=="string"||typeof n=="number"||n===null)){this.log.error("please return a value that MediaError expects in beforeerror hooks");return}e=n}),this.options_.suppressNotSupportedError&&e&&e.code===4){const t=function(){this.error(e)};this.options_.suppressNotSupportedError=!1,this.any(["click","touchstart"],t),this.one("loadstart",function(){this.off(["click","touchstart"],t)});return}if(e===null){this.error_=null,this.removeClass("vjs-error"),this.errorDisplay&&this.errorDisplay.close();return}this.error_=new Me(e),this.addClass("vjs-error"),le.error(`(CODE:${this.error_.code} ${Me.errorTypes[this.error_.code]})`,this.error_.message,this.error_),this.trigger("error"),Ti("error").forEach(t=>t(this,this.error_))}reportUserActivity(e){this.userActivity_=!0}userActive(e){if(e===void 0)return this.userActive_;if(e=!!e,e!==this.userActive_){if(this.userActive_=e,this.userActive_){this.userActivity_=!0,this.removeClass("vjs-user-inactive"),this.addClass("vjs-user-active"),this.trigger("useractive");return}this.tech_&&this.tech_.one("mousemove",function(t){t.stopPropagation(),t.preventDefault()}),this.userActivity_=!1,this.removeClass("vjs-user-active"),this.addClass("vjs-user-inactive"),this.trigger("userinactive")}}listenForUserActivity_(){let e,t,n;const s=Ce(this,this.reportUserActivity),r=function(b){(b.screenX!==t||b.screenY!==n)&&(t=b.screenX,n=b.screenY,s())},a=function(){s(),this.clearInterval(e),e=this.setInterval(s,250)},l=function(b){s(),this.clearInterval(e)};this.on("mousedown",a),this.on("mousemove",r),this.on("mouseup",l),this.on("mouseleave",l);const c=this.getChild("controlBar");c&&!Je&&!Nt&&(c.on("mouseenter",function(b){this.player().options_.inactivityTimeout!==0&&(this.player().cache_.inactivityTimeout=this.player().options_.inactivityTimeout),this.player().options_.inactivityTimeout=0}),c.on("mouseleave",function(b){this.player().options_.inactivityTimeout=this.player().cache_.inactivityTimeout})),this.on("keydown",s),this.on("keyup",s);let g;const m=function(){if(!this.userActivity_)return;this.userActivity_=!1,this.userActive(!0),this.clearTimeout(g);const b=this.options_.inactivityTimeout;b<=0||(g=this.setTimeout(function(){this.userActivity_||this.userActive(!1)},b))};this.setInterval(m,250)}playbackRate(e){if(e!==void 0){this.techCall_("setPlaybackRate",e);return}return this.tech_&&this.tech_.featuresPlaybackRate?this.cache_.lastPlaybackRate||this.techGet_("playbackRate"):1}defaultPlaybackRate(e){return e!==void 0?this.techCall_("setDefaultPlaybackRate",e):this.tech_&&this.tech_.featuresPlaybackRate?this.techGet_("defaultPlaybackRate"):1}isAudio(e){if(e!==void 0){this.isAudio_=!!e;return}return!!this.isAudio_}updatePlayerHeightOnAudioOnlyMode_(){const e=this.getChild("ControlBar");!e||this.audioOnlyCache_.controlBarHeight===e.currentHeight()||(this.audioOnlyCache_.controlBarHeight=e.currentHeight(),this.height(this.audioOnlyCache_.controlBarHeight))}enableAudioOnlyUI_(){this.addClass("vjs-audio-only-mode");const e=this.children(),t=this.getChild("ControlBar"),n=t&&t.currentHeight();e.forEach(s=>{s!==t&&s.el_&&!s.hasClass("vjs-hidden")&&(s.hide(),this.audioOnlyCache_.hiddenChildren.push(s))}),this.audioOnlyCache_.playerHeight=this.currentHeight(),this.audioOnlyCache_.controlBarHeight=n,this.on("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.height(n),this.trigger("audioonlymodechange")}disableAudioOnlyUI_(){this.removeClass("vjs-audio-only-mode"),this.off("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.audioOnlyCache_.hiddenChildren.forEach(e=>e.show()),this.height(this.audioOnlyCache_.playerHeight),this.trigger("audioonlymodechange")}audioOnlyMode(e){if(typeof e!="boolean"||e===this.audioOnlyMode_)return this.audioOnlyMode_;if(this.audioOnlyMode_=e,e){const t=[];return this.isInPictureInPicture()&&t.push(this.exitPictureInPicture()),this.isFullscreen()&&t.push(this.exitFullscreen()),this.audioPosterMode()&&t.push(this.audioPosterMode(!1)),Promise.all(t).then(()=>this.enableAudioOnlyUI_())}return Promise.resolve().then(()=>this.disableAudioOnlyUI_())}enablePosterModeUI_(){(this.tech_&&this.tech_).hide(),this.addClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}disablePosterModeUI_(){(this.tech_&&this.tech_).show(),this.removeClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}audioPosterMode(e){return typeof e!="boolean"||e===this.audioPosterMode_?this.audioPosterMode_:(this.audioPosterMode_=e,e?this.audioOnlyMode()?this.audioOnlyMode(!1).then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.disablePosterModeUI_()}))}addTextTrack(e,t,n){if(this.tech_)return this.tech_.addTextTrack(e,t,n)}addRemoteTextTrack(e,t){if(this.tech_)return this.tech_.addRemoteTextTrack(e,t)}removeRemoteTextTrack(e={}){let{track:t}=e;if(t||(t=e),this.tech_)return this.tech_.removeRemoteTextTrack(t)}getVideoPlaybackQuality(){return this.techGet_("getVideoPlaybackQuality")}videoWidth(){return this.tech_&&this.tech_.videoWidth&&this.tech_.videoWidth()||0}videoHeight(){return this.tech_&&this.tech_.videoHeight&&this.tech_.videoHeight()||0}language(e){if(e===void 0)return this.language_;this.language_!==String(e).toLowerCase()&&(this.language_=String(e).toLowerCase(),si(this)&&this.trigger("languagechange"))}languages(){return ve(Ae.prototype.options_.languages,this.languages_)}toJSON(){const e=ve(this.options_),t=e.tracks;e.tracks=[];for(let n=0;n<t.length;n++){let s=t[n];s=ve(s),s.player=void 0,e.tracks[n]=s}return e}createModal(e,t){t=t||{},t.content=e||"";const n=new Cn(this,t);return this.addChild(n),n.on("dispose",()=>{this.removeChild(n)}),n.open(),n}updateCurrentBreakpoint_(){if(!this.responsive())return;const e=this.currentBreakpoint(),t=this.currentWidth();for(let n=0;n<ao.length;n++){const s=ao[n],r=this.breakpoints_[s];if(t<=r){if(e===s)return;e&&this.removeClass(nr[e]),this.addClass(nr[s]),this.breakpoint_=s;break}}}removeCurrentBreakpoint_(){const e=this.currentBreakpointClass();this.breakpoint_="",e&&this.removeClass(e)}breakpoints(e){return e===void 0?Object.assign(this.breakpoints_):(this.breakpoint_="",this.breakpoints_=Object.assign({},Yb,e),this.updateCurrentBreakpoint_(),Object.assign(this.breakpoints_))}responsive(e){if(e===void 0)return this.responsive_;e=!!e;const t=this.responsive_;if(e!==t)return this.responsive_=e,e?(this.on("playerresize",this.boundUpdateCurrentBreakpoint_),this.updateCurrentBreakpoint_()):(this.off("playerresize",this.boundUpdateCurrentBreakpoint_),this.removeCurrentBreakpoint_()),e}currentBreakpoint(){return this.breakpoint_}currentBreakpointClass(){return nr[this.breakpoint_]||""}loadMedia(e,t){if(!e||typeof e!="object")return;const n=this.crossOrigin();this.reset(),this.cache_.media=ve(e);const{artist:s,artwork:r,description:a,poster:l,src:c,textTracks:g,title:m}=this.cache_.media;!r&&l&&(this.cache_.media.artwork=[{src:l,type:Tr(l)}]),n&&this.crossOrigin(n),c&&this.src(c),l&&this.poster(l),Array.isArray(g)&&g.forEach(b=>this.addRemoteTextTrack(b,!1)),this.titleBar&&this.titleBar.update({title:m,description:a||s||""}),this.ready(t)}getMedia(){if(!this.cache_.media){const e=this.poster(),t=this.currentSources(),n=Array.prototype.map.call(this.remoteTextTracks(),r=>({kind:r.kind,label:r.label,language:r.language,src:r.src})),s={src:t,textTracks:n};return e&&(s.poster=e,s.artwork=[{src:s.poster,type:Tr(s.poster)}]),s}return ve(this.cache_.media)}static getTagSettings(e){const t={sources:[],tracks:[]},n=_i(e),s=n["data-setup"];if(as(e,"vjs-fill")&&(n.fill=!0),as(e,"vjs-fluid")&&(n.fluid=!0),s!==null)try{Object.assign(n,JSON.parse(s||"{}"))}catch(r){le.error("data-setup",r)}if(Object.assign(t,n),e.hasChildNodes()){const r=e.childNodes;for(let a=0,l=r.length;a<l;a++){const c=r[a],g=c.nodeName.toLowerCase();g==="source"?t.sources.push(_i(c)):g==="track"&&t.tracks.push(_i(c))}}return t}debug(e){if(e===void 0)return this.debugEnabled_;e?(this.trigger("debugon"),this.previousLogLevel_=this.log.level,this.log.level("debug"),this.debugEnabled_=!0):(this.trigger("debugoff"),this.log.level(this.previousLogLevel_),this.previousLogLevel_=void 0,this.debugEnabled_=!1)}playbackRates(e){if(e===void 0)return this.cache_.playbackRates;Array.isArray(e)&&e.every(t=>typeof t=="number")&&(this.cache_.playbackRates=e,this.trigger("playbackrateschange"))}}at.names.forEach(function(i){const e=at[i];Ae.prototype[e.getterName]=function(){return this.tech_?this.tech_[e.getterName]():(this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName])}});Ae.prototype.crossorigin=Ae.prototype.crossOrigin;Ae.players={};const Yn=x.navigator;Ae.prototype.options_={techOrder:ae.defaultTechOrder_,html5:{},enableSourceset:!0,inactivityTimeout:2e3,playbackRates:[],liveui:!1,children:["mediaLoader","posterImage","titleBar","textTrackDisplay","loadingSpinner","bigPlayButton","liveTracker","controlBar","errorDisplay","textTrackSettings","resizeManager"],language:Yn&&(Yn.languages&&Yn.languages[0]||Yn.userLanguage||Yn.language)||"en",languages:{},notSupportedMessage:"No compatible source was found for this media.",normalizeAutoplay:!1,fullscreen:{options:{navigationUI:"hide"}},breakpoints:{},responsive:!1,audioOnlyMode:!1,audioPosterMode:!1,spatialNavigation:{enabled:!1,horizontalSeek:!1},enableSmoothSeeking:!1,disableSeekWhileScrubbingOnMobile:!1};jc.forEach(function(i){Ae.prototype[`handleTech${Ne(i)}_`]=function(){return this.trigger(i)}});H.registerComponent("Player",Ae);const vr="plugin",on="activePlugins_",en={},Sr=i=>en.hasOwnProperty(i),sr=i=>Sr(i)?en[i]:void 0,$c=(i,e)=>{i[on]=i[on]||{},i[on][e]=!0},Er=(i,e,t)=>{const n=(t?"before":"")+"pluginsetup";i.trigger(n,e),i.trigger(n+":"+e.name,e)},Qb=function(i,e){const t=function(){Er(this,{name:i,plugin:e,instance:null},!0);const n=e.apply(this,arguments);return $c(this,i),Er(this,{name:i,plugin:e,instance:n}),n};return Object.keys(e).forEach(function(n){t[n]=e[n]}),t},od=(i,e)=>(e.prototype.name=i,function(...t){Er(this,{name:i,plugin:e,instance:null},!0);const n=new e(this,...t);return this[i]=()=>n,Er(this,n.getEventHash()),n});class gt{constructor(e){if(this.constructor===gt)throw new Error("Plugin must be sub-classed; not directly instantiated.");this.player=e,this.log||(this.log=this.player.log.createLogger(this.name)),Vo(this),delete this.trigger,ec(this,this.constructor.defaultState),$c(e,this.name),this.dispose=this.dispose.bind(this),e.on("dispose",this.dispose)}version(){return this.constructor.VERSION}getEventHash(e={}){return e.name=this.name,e.plugin=this.constructor,e.instance=this,e}trigger(e,t={}){return kn(this.eventBusEl_,e,this.getEventHash(t))}handleStateChanged(e){}dispose(){const{name:e,player:t}=this;this.trigger("dispose"),this.off(),t.off("dispose",this.dispose),t[on][e]=!1,this.player=this.state=null,t[e]=od(e,en[e])}static isBasic(e){const t=typeof e=="string"?sr(e):e;return typeof t=="function"&&!gt.prototype.isPrototypeOf(t.prototype)}static registerPlugin(e,t){if(typeof e!="string")throw new Error(`Illegal plugin name, "${e}", must be a string, was ${typeof e}.`);if(Sr(e))le.warn(`A plugin named "${e}" already exists. You may want to avoid re-registering plugins!`);else if(Ae.prototype.hasOwnProperty(e))throw new Error(`Illegal plugin name, "${e}", cannot share a name with an existing player method!`);if(typeof t!="function")throw new Error(`Illegal plugin for "${e}", must be a function, was ${typeof t}.`);return en[e]=t,e!==vr&&(gt.isBasic(t)?Ae.prototype[e]=Qb(e,t):Ae.prototype[e]=od(e,t)),t}static deregisterPlugin(e){if(e===vr)throw new Error("Cannot de-register base plugin.");Sr(e)&&(delete en[e],delete Ae.prototype[e])}static getPlugins(e=Object.keys(en)){let t;return e.forEach(n=>{const s=sr(n);s&&(t=t||{},t[n]=s)}),t}static getPluginVersion(e){const t=sr(e);return t&&t.VERSION||""}}gt.getPlugin=sr;gt.BASE_PLUGIN_NAME=vr;gt.registerPlugin(vr,gt);Ae.prototype.usingPlugin=function(i){return!!this[on]&&this[on][i]===!0};Ae.prototype.hasPlugin=function(i){return!!Sr(i)};function Jb(i,e){let t=!1;return function(...n){return t||le.warn(i),t=!0,e.apply(this,n)}}function Bt(i,e,t,n){return Jb(`${e} is deprecated and will be removed in ${i}.0; please use ${t} instead.`,n)}var Zb={NetworkBadStatus:"networkbadstatus",NetworkRequestFailed:"networkrequestfailed",NetworkRequestAborted:"networkrequestaborted",NetworkRequestTimeout:"networkrequesttimeout",NetworkBodyParserFailed:"networkbodyparserfailed",StreamingHlsPlaylistParserError:"streaminghlsplaylistparsererror",StreamingDashManifestParserError:"streamingdashmanifestparsererror",StreamingContentSteeringParserError:"streamingcontentsteeringparsererror",StreamingVttParserError:"streamingvttparsererror",StreamingFailedToSelectNextSegment:"streamingfailedtoselectnextsegment",StreamingFailedToDecryptSegment:"streamingfailedtodecryptsegment",StreamingFailedToTransmuxSegment:"streamingfailedtotransmuxsegment",StreamingFailedToAppendSegment:"streamingfailedtoappendsegment",StreamingCodecsChangeError:"streamingcodecschangeerror"};const qc=i=>i.indexOf("#")===0?i.slice(1):i;function B(i,e,t){let n=B.getPlayer(i);if(n)return e&&le.warn(`Player "${i}" is already initialised. Options will not be applied.`),t&&n.ready(t),n;const s=typeof i=="string"?vi("#"+qc(i)):i;if(!wn(s))throw new TypeError("The element or ID supplied is not valid. (videojs)");const r="getRootNode"in s&&s.getRootNode()instanceof x.ShadowRoot?s.getRootNode():s.ownerDocument.body;(!s.ownerDocument.defaultView||!r.contains(s))&&le.warn("The element supplied is not included in the DOM"),e=e||{},e.restoreEl===!0&&(e.restoreEl=(s.parentNode&&s.parentNode.hasAttribute&&s.parentNode.hasAttribute("data-vjs-player")?s.parentNode:s).cloneNode(!0)),Ti("beforesetup").forEach(l=>{const c=l(s,ve(e));if(!Qt(c)||Array.isArray(c)){le.error("please return an object in beforesetup hooks");return}e=ve(e,c)});const a=H.getComponent("Player");return n=new a(s,e,t),Ti("setup").forEach(l=>l(n)),n}B.hooks_=ii;B.hooks=Ti;B.hook=L1;B.hookOnce=D1;B.removeHook=kh;if(x.VIDEOJS_NO_DYNAMIC_STYLE!==!0&&En()){let i=vi(".vjs-styles-defaults");if(!i){i=Kh("vjs-styles-defaults");const e=vi("head");e&&e.insertBefore(i,e.firstChild),Yh(i,`
|
|
178
|
+
`),this.tech_}version(){return{"video.js":Ka}}addTechControlsListeners_(){this.removeTechControlsListeners_(),this.on(this.tech_,"click",this.boundHandleTechClick_),this.on(this.tech_,"dblclick",this.boundHandleTechDoubleClick_),this.on(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.on(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.on(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.on(this.tech_,"tap",this.boundHandleTechTap_)}removeTechControlsListeners_(){this.off(this.tech_,"tap",this.boundHandleTechTap_),this.off(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.off(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.off(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.off(this.tech_,"click",this.boundHandleTechClick_),this.off(this.tech_,"dblclick",this.boundHandleTechDoubleClick_)}handleTechReady_(){this.triggerReady(),this.cache_.volume&&this.techCall_("setVolume",this.cache_.volume),this.handleTechPosterChange_(),this.handleTechDurationChange_()}handleTechLoadStart_(){this.removeClass("vjs-ended","vjs-seeking"),this.error(null),this.handleTechDurationChange_(),this.paused()?(this.hasStarted(!1),this.trigger("loadstart")):this.trigger("loadstart"),this.manualAutoplay_(this.autoplay()===!0&&this.options_.normalizeAutoplay?"play":this.autoplay())}manualAutoplay_(e){if(!this.tech_||typeof e!="string")return;const t=()=>{const s=this.muted();this.muted(!0);const r=()=>{this.muted(s)};this.playTerminatedQueue_.push(r);const a=this.play();if(us(a))return a.catch(l=>{throw r(),new Error(`Rejection at manualAutoplay. Restoring muted value. ${l||""}`)})};let n;if(e==="any"&&!this.muted()?(n=this.play(),us(n)&&(n=n.catch(t))):e==="muted"&&!this.muted()?n=t():n=this.play(),!!us(n))return n.then(()=>{this.trigger({type:"autoplay-success",autoplay:e})}).catch(()=>{this.trigger({type:"autoplay-failure",autoplay:e})})}updateSourceCaches_(e=""){let t=e,n="";typeof t!="string"&&(t=e.src,n=e.type),this.cache_.source=this.cache_.source||{},this.cache_.sources=this.cache_.sources||[],t&&!n&&(n=lb(this,t)),this.cache_.source=ve({},e,{src:t,type:n});const s=this.cache_.sources.filter(c=>c.src&&c.src===t),r=[],a=this.$$("source"),l=[];for(let c=0;c<a.length;c++){const f=_i(a[c]);r.push(f),f.src&&f.src===t&&l.push(f.src)}l.length&&!s.length?this.cache_.sources=r:s.length||(this.cache_.sources=[this.cache_.source]),this.cache_.src=t}handleTechSourceset_(e){if(!this.changingSrc_){let t=r=>this.updateSourceCaches_(r);const n=this.currentSource().src,s=e.src;n&&!/^blob:/.test(n)&&/^blob:/.test(s)&&(!this.lastSource_||this.lastSource_.tech!==s&&this.lastSource_.player!==n)&&(t=()=>{}),t(s),e.src||this.tech_.any(["sourceset","loadstart"],r=>{if(r.type==="sourceset")return;const a=this.techGet_("currentSrc");this.lastSource_.tech=a,this.updateSourceCaches_(a)})}this.lastSource_={player:this.currentSource().src,tech:e.src},this.trigger({src:e.src,type:"sourceset"})}hasStarted(e){if(e===void 0)return this.hasStarted_;e!==this.hasStarted_&&(this.hasStarted_=e,this.hasStarted_?this.addClass("vjs-has-started"):this.removeClass("vjs-has-started"))}handleTechPlay_(){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.hasStarted(!0),this.trigger("play")}handleTechRateChange_(){this.tech_.playbackRate()>0&&this.cache_.lastPlaybackRate===0&&(this.queuedCallbacks_.forEach(e=>e.callback(e.event)),this.queuedCallbacks_=[]),this.cache_.lastPlaybackRate=this.tech_.playbackRate(),this.trigger("ratechange")}handleTechWaiting_(){this.addClass("vjs-waiting"),this.trigger("waiting");const e=this.currentTime(),t=()=>{e!==this.currentTime()&&(this.removeClass("vjs-waiting"),this.off("timeupdate",t))};this.on("timeupdate",t)}handleTechCanPlay_(){this.removeClass("vjs-waiting"),this.trigger("canplay")}handleTechCanPlayThrough_(){this.removeClass("vjs-waiting"),this.trigger("canplaythrough")}handleTechPlaying_(){this.removeClass("vjs-waiting"),this.trigger("playing")}handleTechSeeking_(){this.addClass("vjs-seeking"),this.trigger("seeking")}handleTechSeeked_(){this.removeClass("vjs-seeking","vjs-ended"),this.trigger("seeked")}handleTechPause_(){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.trigger("pause")}handleTechEnded_(){this.addClass("vjs-ended"),this.removeClass("vjs-waiting"),this.options_.loop?(this.currentTime(0),this.play()):this.paused()||this.pause(),this.trigger("ended")}handleTechDurationChange_(){this.duration(this.techGet_("duration"))}handleTechClick_(e){this.controls_&&(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.click===void 0||this.options_.userActions.click!==!1)&&(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.click=="function"?this.options_.userActions.click.call(this,e):this.paused()?Gt(this.play()):this.pause())}handleTechDoubleClick_(e){this.controls_&&(Array.prototype.some.call(this.$$(".vjs-control-bar, .vjs-modal-dialog"),t=>t.contains(e.target))||(this.options_===void 0||this.options_.userActions===void 0||this.options_.userActions.doubleClick===void 0||this.options_.userActions.doubleClick!==!1)&&(this.options_!==void 0&&this.options_.userActions!==void 0&&typeof this.options_.userActions.doubleClick=="function"?this.options_.userActions.doubleClick.call(this,e):this.isInPictureInPicture()&&!G.pictureInPictureElement?this.exitPictureInPicture():this.isFullscreen()?this.exitFullscreen():this.requestFullscreen()))}handleTechTap_(){this.userActive(!this.userActive())}handleTechTouchStart_(){this.userWasActive=this.userActive()}handleTechTouchMove_(){this.userWasActive&&this.reportUserActivity()}handleTechTouchEnd_(e){e.cancelable&&e.preventDefault()}toggleFullscreenClass_(){this.isFullscreen()?this.addClass("vjs-fullscreen"):this.removeClass("vjs-fullscreen")}documentFullscreenChange_(e){const t=e.target.player;if(t&&t!==this)return;const n=this.el();let s=G[this.fsApi_.fullscreenElement]===n;!s&&n.matches&&(s=n.matches(":"+this.fsApi_.fullscreen)),this.isFullscreen(s)}handleTechFullscreenChange_(e,t){t&&(t.nativeIOSFullscreen&&(this.addClass("vjs-ios-native-fs"),this.tech_.one("webkitendfullscreen",()=>{this.removeClass("vjs-ios-native-fs")})),this.isFullscreen(t.isFullscreen))}handleTechFullscreenError_(e,t){this.trigger("fullscreenerror",t)}togglePictureInPictureClass_(){this.isInPictureInPicture()?this.addClass("vjs-picture-in-picture"):this.removeClass("vjs-picture-in-picture")}handleTechEnterPictureInPicture_(e){this.isInPictureInPicture(!0)}handleTechLeavePictureInPicture_(e){this.isInPictureInPicture(!1)}handleTechError_(){const e=this.tech_.error();e&&this.error(e)}handleTechTextData_(){let e=null;arguments.length>1&&(e=arguments[1]),this.trigger("textdata",e)}getCache(){return this.cache_}resetCache_(){this.cache_={currentTime:0,initTime:0,inactivityTimeout:this.options_.inactivityTimeout,duration:NaN,lastVolume:1,lastPlaybackRate:this.defaultPlaybackRate(),media:null,src:"",source:{},sources:[],playbackRates:[],volume:1}}techCall_(e,t){this.ready(function(){if(e in nb)return tb(this.middleware_,this.tech_,e,t);if(e in qu)return $u(this.middleware_,this.tech_,e,t);try{this.tech_&&this.tech_[e](t)}catch(n){throw oe(n),n}},!0)}techGet_(e){if(!(!this.tech_||!this.tech_.isReady_)){if(e in ib)return eb(this.middleware_,this.tech_,e);if(e in qu)return $u(this.middleware_,this.tech_,e);try{return this.tech_[e]()}catch(t){throw this.tech_[e]===void 0?(oe(`Video.js: ${e} method not defined for ${this.techName_} playback technology.`,t),t):t.name==="TypeError"?(oe(`Video.js: ${e} unavailable on ${this.techName_} playback technology element.`,t),this.tech_.isReady_=!1,t):(oe(t),t)}}}play(){return new Promise(e=>{this.play_(e)})}play_(e=Gt){this.playCallbacks_.push(e);const t=!!(!this.changingSrc_&&(this.src()||this.currentSrc())),n=!!(Vr||Je);if(this.waitToPlay_&&(this.off(["ready","loadstart"],this.waitToPlay_),this.waitToPlay_=null),!this.isReady_||!t){this.waitToPlay_=r=>{this.play_()},this.one(["ready","loadstart"],this.waitToPlay_),!t&&n&&this.load();return}const s=this.techGet_("play");n&&this.hasClass("vjs-ended")&&this.resetProgressBar_(),s===null?this.runPlayTerminatedQueue_():this.runPlayCallbacks_(s)}runPlayTerminatedQueue_(){const e=this.playTerminatedQueue_.slice(0);this.playTerminatedQueue_=[],e.forEach(function(t){t()})}runPlayCallbacks_(e){const t=this.playCallbacks_.slice(0);this.playCallbacks_=[],this.playTerminatedQueue_=[],t.forEach(function(n){n(e)})}pause(){this.techCall_("pause")}paused(){return this.techGet_("paused")!==!1}played(){return this.techGet_("played")||Ut(0,0)}scrubbing(e){if(typeof e>"u")return this.scrubbing_;this.scrubbing_=!!e,this.techCall_("setScrubbing",this.scrubbing_),e?this.addClass("vjs-scrubbing"):this.removeClass("vjs-scrubbing")}currentTime(e){if(e===void 0)return this.cache_.currentTime=this.techGet_("currentTime")||0,this.cache_.currentTime;if(e<0&&(e=0),!this.isReady_||this.changingSrc_||!this.tech_||!this.tech_.isReady_){this.cache_.initTime=e,this.off("canplay",this.boundApplyInitTime_),this.one("canplay",this.boundApplyInitTime_);return}this.techCall_("setCurrentTime",e),this.cache_.initTime=0,isFinite(e)&&(this.cache_.currentTime=Number(e))}applyInitTime_(){this.currentTime(this.cache_.initTime)}duration(e){if(e===void 0)return this.cache_.duration!==void 0?this.cache_.duration:NaN;e=parseFloat(e),e<0&&(e=1/0),e!==this.cache_.duration&&(this.cache_.duration=e,e===1/0?this.addClass("vjs-live"):this.removeClass("vjs-live"),isNaN(e)||this.trigger("durationchange"))}remainingTime(){return this.duration()-this.currentTime()}remainingTimeDisplay(){return Math.floor(this.duration())-Math.floor(this.currentTime())}buffered(){let e=this.techGet_("buffered");return(!e||!e.length)&&(e=Ut(0,0)),e}seekable(){let e=this.techGet_("seekable");return(!e||!e.length)&&(e=Ut(0,0)),e}seeking(){return this.techGet_("seeking")}ended(){return this.techGet_("ended")}networkState(){return this.techGet_("networkState")}readyState(){return this.techGet_("readyState")}bufferedPercent(){return ic(this.buffered(),this.duration())}bufferedEnd(){const e=this.buffered(),t=this.duration();let n=e.end(e.length-1);return n>t&&(n=t),n}volume(e){let t;if(e!==void 0){t=Math.max(0,Math.min(1,e)),this.cache_.volume=t,this.techCall_("setVolume",t),t>0&&this.lastVolume_(t);return}return t=parseFloat(this.techGet_("volume")),isNaN(t)?1:t}muted(e){if(e!==void 0){this.techCall_("setMuted",e);return}return this.techGet_("muted")||!1}defaultMuted(e){return e!==void 0&&this.techCall_("setDefaultMuted",e),this.techGet_("defaultMuted")||!1}lastVolume_(e){if(e!==void 0&&e!==0){this.cache_.lastVolume=e;return}return this.cache_.lastVolume}supportsFullScreen(){return this.techGet_("supportsFullScreen")||!1}isFullscreen(e){if(e!==void 0){const t=this.isFullscreen_;this.isFullscreen_=!!e,this.isFullscreen_!==t&&this.fsApi_.prefixed&&this.trigger("fullscreenchange"),this.toggleFullscreenClass_();return}return this.isFullscreen_}requestFullscreen(e){this.isInPictureInPicture()&&this.exitPictureInPicture();const t=this;return new Promise((n,s)=>{function r(){t.off("fullscreenerror",l),t.off("fullscreenchange",a)}function a(){r(),n()}function l(f,m){r(),s(m)}t.one("fullscreenchange",a),t.one("fullscreenerror",l);const c=t.requestFullscreenHelper_(e);c&&(c.then(r,r),c.then(n,s))})}requestFullscreenHelper_(e){let t;if(this.fsApi_.prefixed||(t=this.options_.fullscreen&&this.options_.fullscreen.options||{},e!==void 0&&(t=e)),this.fsApi_.requestFullscreen){const n=this.el_[this.fsApi_.requestFullscreen](t);return n&&n.then(()=>this.isFullscreen(!0),()=>this.isFullscreen(!1)),n}else this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow?this.techCall_("enterFullScreen"):this.enterFullWindow()}exitFullscreen(){const e=this;return new Promise((t,n)=>{function s(){e.off("fullscreenerror",a),e.off("fullscreenchange",r)}function r(){s(),t()}function a(c,f){s(),n(f)}e.one("fullscreenchange",r),e.one("fullscreenerror",a);const l=e.exitFullscreenHelper_();l&&(l.then(s,s),l.then(t,n))})}exitFullscreenHelper_(){if(this.fsApi_.requestFullscreen){const e=G[this.fsApi_.exitFullscreen]();return e&&Gt(e.then(()=>this.isFullscreen(!1))),e}else this.tech_.supportsFullScreen()&&!this.options_.preferFullWindow?this.techCall_("exitFullScreen"):this.exitFullWindow()}enterFullWindow(){this.isFullscreen(!0),this.isFullWindow=!0,this.docOrigOverflow=G.documentElement.style.overflow,vt(G,"keydown",this.boundFullWindowOnEscKey_),G.documentElement.style.overflow="hidden",Bi(G.body,"vjs-full-window"),this.trigger("enterFullWindow")}fullWindowOnEscKey(e){e.key==="Escape"&&this.isFullscreen()===!0&&(this.isFullWindow?this.exitFullWindow():this.exitFullscreen())}exitFullWindow(){this.isFullscreen(!1),this.isFullWindow=!1,Ze(G,"keydown",this.boundFullWindowOnEscKey_),G.documentElement.style.overflow=this.docOrigOverflow,Hr(G.body,"vjs-full-window"),this.trigger("exitFullWindow")}disablePictureInPicture(e){if(e===void 0)return this.techGet_("disablePictureInPicture");this.techCall_("setDisablePictureInPicture",e),this.options_.disablePictureInPicture=e,this.trigger("disablepictureinpicturechanged")}isInPictureInPicture(e){if(e!==void 0){this.isInPictureInPicture_=!!e,this.togglePictureInPictureClass_();return}return!!this.isInPictureInPicture_}requestPictureInPicture(){if(this.options_.enableDocumentPictureInPicture&&x.documentPictureInPicture){const e=G.createElement(this.el().tagName);return e.classList=this.el().classList,e.classList.add("vjs-pip-container"),this.posterImage&&e.appendChild(this.posterImage.el().cloneNode(!0)),this.titleBar&&e.appendChild(this.titleBar.el().cloneNode(!0)),e.appendChild(ne("p",{className:"vjs-pip-text"},{},this.localize("Playing in picture-in-picture"))),x.documentPictureInPicture.requestWindow({width:this.videoWidth(),height:this.videoHeight()}).then(t=>(Vh(t),this.el_.parentNode.insertBefore(e,this.el_),t.document.body.appendChild(this.el_),t.document.body.classList.add("vjs-pip-window"),this.player_.isInPictureInPicture(!0),this.player_.trigger({type:"enterpictureinpicture",pipWindow:t}),t.addEventListener("pagehide",n=>{const s=n.target.querySelector(".video-js");e.parentNode.replaceChild(s,e),this.player_.isInPictureInPicture(!1),this.player_.trigger("leavepictureinpicture")}),t))}return"pictureInPictureEnabled"in G&&this.disablePictureInPicture()===!1?this.techGet_("requestPictureInPicture"):Promise.reject("No PiP mode is available")}exitPictureInPicture(){if(x.documentPictureInPicture&&x.documentPictureInPicture.window)return x.documentPictureInPicture.window.close(),Promise.resolve();if("pictureInPictureEnabled"in G)return G.exitPictureInPicture()}handleKeyDown(e){const{userActions:t}=this.options_;!t||!t.hotkeys||(n=>{const s=n.tagName.toLowerCase();return n.isContentEditable?!0:s==="input"?["button","checkbox","hidden","radio","reset","submit"].indexOf(n.type)===-1:["textarea"].indexOf(s)!==-1})(this.el_.ownerDocument.activeElement)||(typeof t.hotkeys=="function"?t.hotkeys.call(this,e):this.handleHotkeys(e))}handleHotkeys(e){const t=this.options_.userActions?this.options_.userActions.hotkeys:{},{fullscreenKey:n=a=>e.key.toLowerCase()==="f",muteKey:s=a=>e.key.toLowerCase()==="m",playPauseKey:r=a=>e.key.toLowerCase()==="k"||e.key.toLowerCase()===" "}=t;if(n.call(this,e)){e.preventDefault(),e.stopPropagation();const a=H.getComponent("FullscreenToggle");G[this.fsApi_.fullscreenEnabled]!==!1&&a.prototype.handleClick.call(this,e)}else s.call(this,e)?(e.preventDefault(),e.stopPropagation(),H.getComponent("MuteToggle").prototype.handleClick.call(this,e)):r.call(this,e)&&(e.preventDefault(),e.stopPropagation(),H.getComponent("PlayToggle").prototype.handleClick.call(this,e))}canPlayType(e){let t;for(let n=0,s=this.options_.techOrder;n<s.length;n++){const r=s[n];let a=ae.getTech(r);if(a||(a=H.getComponent(r)),!a){oe.error(`The "${r}" tech is undefined. Skipped browser support check for that tech.`);continue}if(a.isSupported()&&(t=a.canPlayType(e),t))return t}return""}selectSource(e){const t=this.options_.techOrder.map(l=>[l,ae.getTech(l)]).filter(([l,c])=>c?c.isSupported():(oe.error(`The "${l}" tech is undefined. Skipped browser support check for that tech.`),!1)),n=function(l,c,f){let m;return l.some(b=>c.some(C=>{if(m=f(b,C),m)return!0})),m};let s;const r=l=>(c,f)=>l(f,c),a=([l,c],f)=>{if(c.canPlaySource(f,this.options_[l.toLowerCase()]))return{source:f,tech:l}};return this.options_.sourceOrder?s=n(e,t,r(a)):s=n(t,e,a),s||!1}handleSrc_(e,t){if(typeof e>"u")return this.cache_.src||"";this.resetRetryOnError_&&this.resetRetryOnError_();const n=oc(e);if(!n.length){this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0);return}if(this.changingSrc_=!0,t||(this.cache_.sources=n),this.updateSourceCaches_(n[0]),J1(this,n[0],(s,r)=>{if(this.middleware_=r,t||(this.cache_.sources=n),this.updateSourceCaches_(s),this.src_(s)){if(n.length>1)return this.handleSrc_(n.slice(1));this.changingSrc_=!1,this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0),this.triggerReady();return}Z1(r,this.tech_)}),n.length>1){const s=()=>{this.error(null),this.handleSrc_(n.slice(1),!0)},r=()=>{this.off("error",s)};this.one("error",s),this.one("playing",r),this.resetRetryOnError_=()=>{this.off("error",s),this.off("playing",r)}}}src(e){return this.handleSrc_(e,!1)}src_(e){const t=this.selectSource([e]);return t?Jh(t.tech,this.techName_)?(this.ready(function(){this.tech_.constructor.prototype.hasOwnProperty("setSource")?this.techCall_("setSource",e):this.techCall_("src",e.src),this.changingSrc_=!1},!0),!1):(this.changingSrc_=!0,this.loadTech_(t.tech,t.source),this.tech_.ready(()=>{this.changingSrc_=!1}),!1):!0}addSourceElement(e,t){return this.tech_?this.tech_.addSourceElement(e,t):!1}removeSourceElement(e){return this.tech_?this.tech_.removeSourceElement(e):!1}load(){if(this.tech_&&this.tech_.vhs){this.src(this.currentSource());return}this.techCall_("load")}reset(){if(this.paused())this.doReset_();else{const e=this.play();Gt(e.then(()=>this.doReset_()))}}doReset_(){this.tech_&&this.tech_.clearTracks("text"),this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.resetCache_(),this.poster(""),this.loadTech_(this.options_.techOrder[0],null),this.techCall_("reset"),this.resetControlBarUI_(),this.error(null),this.titleBar&&this.titleBar.update({title:void 0,description:void 0}),si(this)&&this.trigger("playerreset")}resetControlBarUI_(){this.resetProgressBar_(),this.resetPlaybackRate_(),this.resetVolumeBar_()}resetProgressBar_(){this.currentTime(0);const{currentTimeDisplay:e,durationDisplay:t,progressControl:n,remainingTimeDisplay:s}=this.controlBar||{},{seekBar:r}=n||{};e&&e.updateContent(),t&&t.updateContent(),s&&s.updateContent(),r&&(r.update(),r.loadProgressBar&&r.loadProgressBar.update())}resetPlaybackRate_(){this.playbackRate(this.defaultPlaybackRate()),this.handleTechRateChange_()}resetVolumeBar_(){this.volume(1),this.trigger("volumechange")}currentSources(){const e=this.currentSource(),t=[];return Object.keys(e).length!==0&&t.push(e),this.cache_.sources||t}currentSource(){return this.cache_.source||{}}currentSrc(){return this.currentSource()&&this.currentSource().src||""}currentType(){return this.currentSource()&&this.currentSource().type||""}preload(e){if(e!==void 0){this.techCall_("setPreload",e),this.options_.preload=e;return}return this.techGet_("preload")}autoplay(e){if(e===void 0)return this.options_.autoplay||!1;let t;typeof e=="string"&&/(any|play|muted)/.test(e)||e===!0&&this.options_.normalizeAutoplay?(this.options_.autoplay=e,this.manualAutoplay_(typeof e=="string"?e:"play"),t=!1):e?this.options_.autoplay=!0:this.options_.autoplay=!1,t=typeof t>"u"?this.options_.autoplay:t,this.tech_&&this.techCall_("setAutoplay",t)}playsinline(e){return e!==void 0&&(this.techCall_("setPlaysinline",e),this.options_.playsinline=e),this.techGet_("playsinline")}loop(e){if(e!==void 0){this.techCall_("setLoop",e),this.options_.loop=e;return}return this.techGet_("loop")}poster(e){if(e===void 0)return this.poster_;e||(e=""),e!==this.poster_&&(this.poster_=e,this.techCall_("setPoster",e),this.isPosterFromTech_=!1,this.trigger("posterchange"))}handleTechPosterChange_(){if((!this.poster_||this.options_.techCanOverridePoster)&&this.tech_&&this.tech_.poster){const e=this.tech_.poster()||"";e!==this.poster_&&(this.poster_=e,this.isPosterFromTech_=!0,this.trigger("posterchange"))}}controls(e){if(e===void 0)return!!this.controls_;e=!!e,this.controls_!==e&&(this.controls_=e,this.usingNativeControls()&&this.techCall_("setControls",e),this.controls_?(this.removeClass("vjs-controls-disabled"),this.addClass("vjs-controls-enabled"),this.trigger("controlsenabled"),this.usingNativeControls()||this.addTechControlsListeners_()):(this.removeClass("vjs-controls-enabled"),this.addClass("vjs-controls-disabled"),this.trigger("controlsdisabled"),this.usingNativeControls()||this.removeTechControlsListeners_()))}usingNativeControls(e){if(e===void 0)return!!this.usingNativeControls_;e=!!e,this.usingNativeControls_!==e&&(this.usingNativeControls_=e,this.usingNativeControls_?(this.addClass("vjs-using-native-controls"),this.trigger("usingnativecontrols")):(this.removeClass("vjs-using-native-controls"),this.trigger("usingcustomcontrols")))}error(e){if(e===void 0)return this.error_||null;if(Ti("beforeerror").forEach(t=>{const n=t(this,e);if(!(Qt(n)&&!Array.isArray(n)||typeof n=="string"||typeof n=="number"||n===null)){this.log.error("please return a value that MediaError expects in beforeerror hooks");return}e=n}),this.options_.suppressNotSupportedError&&e&&e.code===4){const t=function(){this.error(e)};this.options_.suppressNotSupportedError=!1,this.any(["click","touchstart"],t),this.one("loadstart",function(){this.off(["click","touchstart"],t)});return}if(e===null){this.error_=null,this.removeClass("vjs-error"),this.errorDisplay&&this.errorDisplay.close();return}this.error_=new Me(e),this.addClass("vjs-error"),oe.error(`(CODE:${this.error_.code} ${Me.errorTypes[this.error_.code]})`,this.error_.message,this.error_),this.trigger("error"),Ti("error").forEach(t=>t(this,this.error_))}reportUserActivity(e){this.userActivity_=!0}userActive(e){if(e===void 0)return this.userActive_;if(e=!!e,e!==this.userActive_){if(this.userActive_=e,this.userActive_){this.userActivity_=!0,this.removeClass("vjs-user-inactive"),this.addClass("vjs-user-active"),this.trigger("useractive");return}this.tech_&&this.tech_.one("mousemove",function(t){t.stopPropagation(),t.preventDefault()}),this.userActivity_=!1,this.removeClass("vjs-user-active"),this.addClass("vjs-user-inactive"),this.trigger("userinactive")}}listenForUserActivity_(){let e,t,n;const s=Ce(this,this.reportUserActivity),r=function(b){(b.screenX!==t||b.screenY!==n)&&(t=b.screenX,n=b.screenY,s())},a=function(){s(),this.clearInterval(e),e=this.setInterval(s,250)},l=function(b){s(),this.clearInterval(e)};this.on("mousedown",a),this.on("mousemove",r),this.on("mouseup",l),this.on("mouseleave",l);const c=this.getChild("controlBar");c&&!Je&&!Nt&&(c.on("mouseenter",function(b){this.player().options_.inactivityTimeout!==0&&(this.player().cache_.inactivityTimeout=this.player().options_.inactivityTimeout),this.player().options_.inactivityTimeout=0}),c.on("mouseleave",function(b){this.player().options_.inactivityTimeout=this.player().cache_.inactivityTimeout})),this.on("keydown",s),this.on("keyup",s);let f;const m=function(){if(!this.userActivity_)return;this.userActivity_=!1,this.userActive(!0),this.clearTimeout(f);const b=this.options_.inactivityTimeout;b<=0||(f=this.setTimeout(function(){this.userActivity_||this.userActive(!1)},b))};this.setInterval(m,250)}playbackRate(e){if(e!==void 0){this.techCall_("setPlaybackRate",e);return}return this.tech_&&this.tech_.featuresPlaybackRate?this.cache_.lastPlaybackRate||this.techGet_("playbackRate"):1}defaultPlaybackRate(e){return e!==void 0?this.techCall_("setDefaultPlaybackRate",e):this.tech_&&this.tech_.featuresPlaybackRate?this.techGet_("defaultPlaybackRate"):1}isAudio(e){if(e!==void 0){this.isAudio_=!!e;return}return!!this.isAudio_}updatePlayerHeightOnAudioOnlyMode_(){const e=this.getChild("ControlBar");!e||this.audioOnlyCache_.controlBarHeight===e.currentHeight()||(this.audioOnlyCache_.controlBarHeight=e.currentHeight(),this.height(this.audioOnlyCache_.controlBarHeight))}enableAudioOnlyUI_(){this.addClass("vjs-audio-only-mode");const e=this.children(),t=this.getChild("ControlBar"),n=t&&t.currentHeight();e.forEach(s=>{s!==t&&s.el_&&!s.hasClass("vjs-hidden")&&(s.hide(),this.audioOnlyCache_.hiddenChildren.push(s))}),this.audioOnlyCache_.playerHeight=this.currentHeight(),this.audioOnlyCache_.controlBarHeight=n,this.on("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.height(n),this.trigger("audioonlymodechange")}disableAudioOnlyUI_(){this.removeClass("vjs-audio-only-mode"),this.off("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.audioOnlyCache_.hiddenChildren.forEach(e=>e.show()),this.height(this.audioOnlyCache_.playerHeight),this.trigger("audioonlymodechange")}audioOnlyMode(e){if(typeof e!="boolean"||e===this.audioOnlyMode_)return this.audioOnlyMode_;if(this.audioOnlyMode_=e,e){const t=[];return this.isInPictureInPicture()&&t.push(this.exitPictureInPicture()),this.isFullscreen()&&t.push(this.exitFullscreen()),this.audioPosterMode()&&t.push(this.audioPosterMode(!1)),Promise.all(t).then(()=>this.enableAudioOnlyUI_())}return Promise.resolve().then(()=>this.disableAudioOnlyUI_())}enablePosterModeUI_(){(this.tech_&&this.tech_).hide(),this.addClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}disablePosterModeUI_(){(this.tech_&&this.tech_).show(),this.removeClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}audioPosterMode(e){return typeof e!="boolean"||e===this.audioPosterMode_?this.audioPosterMode_:(this.audioPosterMode_=e,e?this.audioOnlyMode()?this.audioOnlyMode(!1).then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.disablePosterModeUI_()}))}addTextTrack(e,t,n){if(this.tech_)return this.tech_.addTextTrack(e,t,n)}addRemoteTextTrack(e,t){if(this.tech_)return this.tech_.addRemoteTextTrack(e,t)}removeRemoteTextTrack(e={}){let{track:t}=e;if(t||(t=e),this.tech_)return this.tech_.removeRemoteTextTrack(t)}getVideoPlaybackQuality(){return this.techGet_("getVideoPlaybackQuality")}videoWidth(){return this.tech_&&this.tech_.videoWidth&&this.tech_.videoWidth()||0}videoHeight(){return this.tech_&&this.tech_.videoHeight&&this.tech_.videoHeight()||0}language(e){if(e===void 0)return this.language_;this.language_!==String(e).toLowerCase()&&(this.language_=String(e).toLowerCase(),si(this)&&this.trigger("languagechange"))}languages(){return ve(Ae.prototype.options_.languages,this.languages_)}toJSON(){const e=ve(this.options_),t=e.tracks;e.tracks=[];for(let n=0;n<t.length;n++){let s=t[n];s=ve(s),s.player=void 0,e.tracks[n]=s}return e}createModal(e,t){t=t||{},t.content=e||"";const n=new Cn(this,t);return this.addChild(n),n.on("dispose",()=>{this.removeChild(n)}),n.open(),n}updateCurrentBreakpoint_(){if(!this.responsive())return;const e=this.currentBreakpoint(),t=this.currentWidth();for(let n=0;n<ro.length;n++){const s=ro[n],r=this.breakpoints_[s];if(t<=r){if(e===s)return;e&&this.removeClass(sr[e]),this.addClass(sr[s]),this.breakpoint_=s;break}}}removeCurrentBreakpoint_(){const e=this.currentBreakpointClass();this.breakpoint_="",e&&this.removeClass(e)}breakpoints(e){return e===void 0?Object.assign(this.breakpoints_):(this.breakpoint_="",this.breakpoints_=Object.assign({},jb,e),this.updateCurrentBreakpoint_(),Object.assign(this.breakpoints_))}responsive(e){if(e===void 0)return this.responsive_;e=!!e;const t=this.responsive_;if(e!==t)return this.responsive_=e,e?(this.on("playerresize",this.boundUpdateCurrentBreakpoint_),this.updateCurrentBreakpoint_()):(this.off("playerresize",this.boundUpdateCurrentBreakpoint_),this.removeCurrentBreakpoint_()),e}currentBreakpoint(){return this.breakpoint_}currentBreakpointClass(){return sr[this.breakpoint_]||""}loadMedia(e,t){if(!e||typeof e!="object")return;const n=this.crossOrigin();this.reset(),this.cache_.media=ve(e);const{artist:s,artwork:r,description:a,poster:l,src:c,textTracks:f,title:m}=this.cache_.media;!r&&l&&(this.cache_.media.artwork=[{src:l,type:Tr(l)}]),n&&this.crossOrigin(n),c&&this.src(c),l&&this.poster(l),Array.isArray(f)&&f.forEach(b=>this.addRemoteTextTrack(b,!1)),this.titleBar&&this.titleBar.update({title:m,description:a||s||""}),this.ready(t)}getMedia(){if(!this.cache_.media){const e=this.poster(),t=this.currentSources(),n=Array.prototype.map.call(this.remoteTextTracks(),r=>({kind:r.kind,label:r.label,language:r.language,src:r.src})),s={src:t,textTracks:n};return e&&(s.poster=e,s.artwork=[{src:s.poster,type:Tr(s.poster)}]),s}return ve(this.cache_.media)}static getTagSettings(e){const t={sources:[],tracks:[]},n=_i(e),s=n["data-setup"];if(os(e,"vjs-fill")&&(n.fill=!0),os(e,"vjs-fluid")&&(n.fluid=!0),s!==null)try{Object.assign(n,JSON.parse(s||"{}"))}catch(r){oe.error("data-setup",r)}if(Object.assign(t,n),e.hasChildNodes()){const r=e.childNodes;for(let a=0,l=r.length;a<l;a++){const c=r[a],f=c.nodeName.toLowerCase();f==="source"?t.sources.push(_i(c)):f==="track"&&t.tracks.push(_i(c))}}return t}debug(e){if(e===void 0)return this.debugEnabled_;e?(this.trigger("debugon"),this.previousLogLevel_=this.log.level,this.log.level("debug"),this.debugEnabled_=!0):(this.trigger("debugoff"),this.log.level(this.previousLogLevel_),this.previousLogLevel_=void 0,this.debugEnabled_=!1)}playbackRates(e){if(e===void 0)return this.cache_.playbackRates;Array.isArray(e)&&e.every(t=>typeof t=="number")&&(this.cache_.playbackRates=e,this.trigger("playbackrateschange"))}}at.names.forEach(function(i){const e=at[i];Ae.prototype[e.getterName]=function(){return this.tech_?this.tech_[e.getterName]():(this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName])}});Ae.prototype.crossorigin=Ae.prototype.crossOrigin;Ae.players={};const Qn=x.navigator;Ae.prototype.options_={techOrder:ae.defaultTechOrder_,html5:{},enableSourceset:!0,inactivityTimeout:2e3,playbackRates:[],liveui:!1,children:["mediaLoader","posterImage","titleBar","textTrackDisplay","loadingSpinner","bigPlayButton","liveTracker","controlBar","errorDisplay","textTrackSettings","resizeManager"],language:Qn&&(Qn.languages&&Qn.languages[0]||Qn.userLanguage||Qn.language)||"en",languages:{},notSupportedMessage:"No compatible source was found for this media.",normalizeAutoplay:!1,fullscreen:{options:{navigationUI:"hide"}},breakpoints:{},responsive:!1,audioOnlyMode:!1,audioPosterMode:!1,spatialNavigation:{enabled:!1,horizontalSeek:!1},enableSmoothSeeking:!1,disableSeekWhileScrubbingOnMobile:!1};Nc.forEach(function(i){Ae.prototype[`handleTech${Ne(i)}_`]=function(){return this.trigger(i)}});H.registerComponent("Player",Ae);const vr="plugin",on="activePlugins_",en={},Sr=i=>en.hasOwnProperty(i),rr=i=>Sr(i)?en[i]:void 0,Bc=(i,e)=>{i[on]=i[on]||{},i[on][e]=!0},Er=(i,e,t)=>{const n=(t?"before":"")+"pluginsetup";i.trigger(n,e),i.trigger(n+":"+e.name,e)},$b=function(i,e){const t=function(){Er(this,{name:i,plugin:e,instance:null},!0);const n=e.apply(this,arguments);return Bc(this,i),Er(this,{name:i,plugin:e,instance:n}),n};return Object.keys(e).forEach(function(n){t[n]=e[n]}),t},rd=(i,e)=>(e.prototype.name=i,function(...t){Er(this,{name:i,plugin:e,instance:null},!0);const n=new e(this,...t);return this[i]=()=>n,Er(this,n.getEventHash()),n});class ft{constructor(e){if(this.constructor===ft)throw new Error("Plugin must be sub-classed; not directly instantiated.");this.player=e,this.log||(this.log=this.player.log.createLogger(this.name)),qo(this),delete this.trigger,Qh(this,this.constructor.defaultState),Bc(e,this.name),this.dispose=this.dispose.bind(this),e.on("dispose",this.dispose)}version(){return this.constructor.VERSION}getEventHash(e={}){return e.name=this.name,e.plugin=this.constructor,e.instance=this,e}trigger(e,t={}){return kn(this.eventBusEl_,e,this.getEventHash(t))}handleStateChanged(e){}dispose(){const{name:e,player:t}=this;this.trigger("dispose"),this.off(),t.off("dispose",this.dispose),t[on][e]=!1,this.player=this.state=null,t[e]=rd(e,en[e])}static isBasic(e){const t=typeof e=="string"?rr(e):e;return typeof t=="function"&&!ft.prototype.isPrototypeOf(t.prototype)}static registerPlugin(e,t){if(typeof e!="string")throw new Error(`Illegal plugin name, "${e}", must be a string, was ${typeof e}.`);if(Sr(e))oe.warn(`A plugin named "${e}" already exists. You may want to avoid re-registering plugins!`);else if(Ae.prototype.hasOwnProperty(e))throw new Error(`Illegal plugin name, "${e}", cannot share a name with an existing player method!`);if(typeof t!="function")throw new Error(`Illegal plugin for "${e}", must be a function, was ${typeof t}.`);return en[e]=t,e!==vr&&(ft.isBasic(t)?Ae.prototype[e]=$b(e,t):Ae.prototype[e]=rd(e,t)),t}static deregisterPlugin(e){if(e===vr)throw new Error("Cannot de-register base plugin.");Sr(e)&&(delete en[e],delete Ae.prototype[e])}static getPlugins(e=Object.keys(en)){let t;return e.forEach(n=>{const s=rr(n);s&&(t=t||{},t[n]=s)}),t}static getPluginVersion(e){const t=rr(e);return t&&t.VERSION||""}}ft.getPlugin=rr;ft.BASE_PLUGIN_NAME=vr;ft.registerPlugin(vr,ft);Ae.prototype.usingPlugin=function(i){return!!this[on]&&this[on][i]===!0};Ae.prototype.hasPlugin=function(i){return!!Sr(i)};function qb(i,e){let t=!1;return function(...n){return t||oe.warn(i),t=!0,e.apply(this,n)}}function Bt(i,e,t,n){return qb(`${e} is deprecated and will be removed in ${i}.0; please use ${t} instead.`,n)}var Vb={NetworkBadStatus:"networkbadstatus",NetworkRequestFailed:"networkrequestfailed",NetworkRequestAborted:"networkrequestaborted",NetworkRequestTimeout:"networkrequesttimeout",NetworkBodyParserFailed:"networkbodyparserfailed",StreamingHlsPlaylistParserError:"streaminghlsplaylistparsererror",StreamingDashManifestParserError:"streamingdashmanifestparsererror",StreamingContentSteeringParserError:"streamingcontentsteeringparsererror",StreamingVttParserError:"streamingvttparsererror",StreamingFailedToSelectNextSegment:"streamingfailedtoselectnextsegment",StreamingFailedToDecryptSegment:"streamingfailedtodecryptsegment",StreamingFailedToTransmuxSegment:"streamingfailedtotransmuxsegment",StreamingFailedToAppendSegment:"streamingfailedtoappendsegment",StreamingCodecsChangeError:"streamingcodecschangeerror"};const Fc=i=>i.indexOf("#")===0?i.slice(1):i;function B(i,e,t){let n=B.getPlayer(i);if(n)return e&&oe.warn(`Player "${i}" is already initialised. Options will not be applied.`),t&&n.ready(t),n;const s=typeof i=="string"?vi("#"+Fc(i)):i;if(!wn(s))throw new TypeError("The element or ID supplied is not valid. (videojs)");const r="getRootNode"in s&&s.getRootNode()instanceof x.ShadowRoot?s.getRootNode():s.ownerDocument.body;(!s.ownerDocument.defaultView||!r.contains(s))&&oe.warn("The element supplied is not included in the DOM"),e=e||{},e.restoreEl===!0&&(e.restoreEl=(s.parentNode&&s.parentNode.hasAttribute&&s.parentNode.hasAttribute("data-vjs-player")?s.parentNode:s).cloneNode(!0)),Ti("beforesetup").forEach(l=>{const c=l(s,ve(e));if(!Qt(c)||Array.isArray(c)){oe.error("please return an object in beforesetup hooks");return}e=ve(e,c)});const a=H.getComponent("Player");return n=new a(s,e,t),Ti("setup").forEach(l=>l(n)),n}B.hooks_=ii;B.hooks=Ti;B.hook=v1;B.hookOnce=S1;B.removeHook=Sh;if(x.VIDEOJS_NO_DYNAMIC_STYLE!==!0&&En()){let i=vi(".vjs-styles-defaults");if(!i){i=Wh("vjs-styles-defaults");const e=vi("head");e&&e.insertBefore(i,e.firstChild),Gh(i,`
|
|
179
179
|
.video-js {
|
|
180
180
|
width: 300px;
|
|
181
181
|
height: 150px;
|
|
@@ -184,15 +184,15 @@ See https://github.com/videojs/video.js/issues/2617 for more info.
|
|
|
184
184
|
.vjs-fluid:not(.vjs-audio-only-mode) {
|
|
185
185
|
padding-top: 56.25%
|
|
186
186
|
}
|
|
187
|
-
`)}}
|
|
187
|
+
`)}}Za(1,B);B.VERSION=Ka;B.options=Ae.prototype.options_;B.getPlayers=()=>Ae.players;B.getPlayer=i=>{const e=Ae.players;let t;if(typeof i=="string"){const n=Fc(i),s=e[n];if(s)return s;t=vi("#"+n)}else t=i;if(wn(t)){const{player:n,playerId:s}=t;if(n||e[s])return n||e[s]}};B.getAllPlayers=()=>Object.keys(Ae.players).map(i=>Ae.players[i]).filter(Boolean);B.players=Ae.players;B.getComponent=H.getComponent;B.registerComponent=(i,e)=>(ae.isTech(e)&&oe.warn(`The ${i} tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)`),H.registerComponent.call(H,i,e));B.getTech=ae.getTech;B.registerTech=ae.registerTech;B.use=Q1;Object.defineProperty(B,"middleware",{value:{},writeable:!1,enumerable:!0});Object.defineProperty(B.middleware,"TERMINATOR",{value:br,writeable:!1,enumerable:!0});B.browser=Lh;B.obj=k1;B.mergeOptions=Bt(9,"videojs.mergeOptions","videojs.obj.merge",ve);B.defineLazyProperty=Bt(9,"videojs.defineLazyProperty","videojs.obj.defineLazyProperty",Fr);B.bind=Bt(9,"videojs.bind","native Function.prototype.bind",Ce);B.registerPlugin=ft.registerPlugin;B.deregisterPlugin=ft.deregisterPlugin;B.plugin=(i,e)=>(oe.warn("videojs.plugin() is deprecated; use videojs.registerPlugin() instead"),ft.registerPlugin(i,e));B.getPlugins=ft.getPlugins;B.getPlugin=ft.getPlugin;B.getPluginVersion=ft.getPluginVersion;B.addLanguage=function(i,e){return i=(""+i).toLowerCase(),B.options.languages=ve(B.options.languages,{[i]:e}),B.options.languages[i]};B.log=oe;B.createLogger=Eh;B.time=j1;B.createTimeRange=Bt(9,"videojs.createTimeRange","videojs.time.createTimeRanges",Ut);B.createTimeRanges=Bt(9,"videojs.createTimeRanges","videojs.time.createTimeRanges",Ut);B.formatTime=Bt(9,"videojs.formatTime","videojs.time.formatTime",qi);B.setFormatTime=Bt(9,"videojs.setFormatTime","videojs.time.setFormatTime",ec);B.resetFormatTime=Bt(9,"videojs.resetFormatTime","videojs.time.resetFormatTime",tc);B.parseUrl=Bt(9,"videojs.parseUrl","videojs.url.parseUrl",zo);B.isCrossOrigin=Bt(9,"videojs.isCrossOrigin","videojs.url.isCrossOrigin",Qr);B.EventTarget=St;B.any=$o;B.on=vt;B.one=Kr;B.off=Ze;B.trigger=kn;B.xhr=Zd;B.TextTrack=_s;B.AudioTrack=rc;B.VideoTrack=ac;["isEl","isTextNode","createEl","hasClass","addClass","removeClass","toggleClass","setAttributes","getAttributes","emptyEl","appendContent","insertContent"].forEach(i=>{B[i]=function(){return oe.warn(`videojs.${i}() is deprecated; use videojs.dom.${i}() instead`),Hh[i].apply(null,arguments)}});B.computedStyle=Bt(9,"videojs.computedStyle","videojs.dom.computedStyle",bn);B.dom=Hh;B.fn=M1;B.num=_b;B.str=B1;B.url=K1;B.Error=Vb;/*! @name videojs-contrib-quality-levels @version 4.1.0 @license Apache-2.0 */class Hb{constructor(e){let t=this;return t.id=e.id,t.label=t.id,t.width=e.width,t.height=e.height,t.bitrate=e.bandwidth,t.frameRate=e.frameRate,t.enabled_=e.enabled,Object.defineProperty(t,"enabled",{get(){return t.enabled_()},set(n){t.enabled_(n)}}),t}}class wr extends B.EventTarget{constructor(){super();let e=this;return e.levels_=[],e.selectedIndex_=-1,Object.defineProperty(e,"selectedIndex",{get(){return e.selectedIndex_}}),Object.defineProperty(e,"length",{get(){return e.levels_.length}}),e[Symbol.iterator]=()=>e.levels_.values(),e}addQualityLevel(e){let t=this.getQualityLevelById(e.id);if(t)return t;const n=this.levels_.length;return t=new Hb(e),""+n in this||Object.defineProperty(this,n,{get(){return this.levels_[n]}}),this.levels_.push(t),this.trigger({qualityLevel:t,type:"addqualitylevel"}),t}removeQualityLevel(e){let t=null;for(let n=0,s=this.length;n<s;n++)if(this[n]===e){t=this.levels_.splice(n,1)[0],this.selectedIndex_===n?this.selectedIndex_=-1:this.selectedIndex_>n&&this.selectedIndex_--;break}return t&&this.trigger({qualityLevel:e,type:"removequalitylevel"}),t}getQualityLevelById(e){for(let t=0,n=this.length;t<n;t++){const s=this[t];if(s.id===e)return s}return null}dispose(){this.selectedIndex_=-1,this.levels_.length=0}}wr.prototype.allowedEvents_={change:"change",addqualitylevel:"addqualitylevel",removequalitylevel:"removequalitylevel"};for(const i in wr.prototype.allowedEvents_)wr.prototype["on"+i]=null;var jc="4.1.0";const zb=function(i,e){const t=i.qualityLevels,n=new wr,s=function(){n.dispose(),i.qualityLevels=t,i.off("dispose",s)};return i.on("dispose",s),i.qualityLevels=()=>n,i.qualityLevels.VERSION=jc,n},$c=function(i){return zb(this,B.obj.merge({},i))};B.registerPlugin("qualityLevels",$c);$c.VERSION=jc;/*! @name @videojs/http-streaming @version 3.16.2 @license Apache-2.0 */const pt=Mr,kr=(i,e)=>e&&e.responseURL&&i!==e.responseURL?e.responseURL:i,Lt=i=>B.log.debug?B.log.debug.bind(B,"VHS:",`${i} >`):function(){};function fe(...i){const e=B.obj||B;return(e.merge||e.mergeOptions).apply(e,i)}function tt(...i){const e=B.time||B;return(e.createTimeRanges||e.createTimeRanges).apply(e,i)}function Wb(i){if(i.length===0)return"Buffered Ranges are empty";let e=`Buffered Ranges:
|
|
188
188
|
`;for(let t=0;t<i.length;t++){const n=i.start(t),s=i.end(t);e+=`${n} --> ${s}. Duration (${s-n})
|
|
189
|
-
`}return e}const Xt=1/30,Kt=Xt*3,zc=function(i,e){const t=[];let n;if(i&&i.length)for(n=0;n<i.length;n++)e(i.start(n),i.end(n))&&t.push([i.start(n),i.end(n)]);return tt(t)},tn=function(i,e){return zc(i,function(t,n){return t-Kt<=e&&n+Kt>=e})},Zs=function(i,e){return zc(i,function(t){return t-Xt>=e})},nT=function(i){if(i.length<2)return tt();const e=[];for(let t=1;t<i.length;t++){const n=i.end(t-1),s=i.start(t);e.push([n,s])}return tt(e)},sT=function(i,e){let t=null,n=null,s=0;const r=[],a=[];if(!i||!i.length||!e||!e.length)return tt();let l=i.length;for(;l--;)r.push({time:i.start(l),type:"start"}),r.push({time:i.end(l),type:"end"});for(l=e.length;l--;)r.push({time:e.start(l),type:"start"}),r.push({time:e.end(l),type:"end"});for(r.sort(function(c,g){return c.time-g.time}),l=0;l<r.length;l++)r[l].type==="start"?(s++,s===2&&(t=r[l].time)):r[l].type==="end"&&(s--,s===1&&(n=r[l].time)),t!==null&&n!==null&&(a.push([t,n]),t=null,n=null);return tt(a)},Wc=i=>{const e=[];if(!i||!i.length)return"";for(let t=0;t<i.length;t++)e.push(i.start(t)+" => "+i.end(t));return e.join(", ")},rT=function(i,e,t=1){return((i.length?i.end(i.length-1):0)-e)/t},Ui=i=>{const e=[];for(let t=0;t<i.length;t++)e.push({start:i.start(t),end:i.end(t)});return e},aT=function(i,e){if(i===e)return!1;if(!i&&e||!e&&i||i.length!==e.length)return!0;for(let t=0;t<i.length;t++)if(i.start(t)!==e.start(t)||i.end(t)!==e.end(t))return!0;return!1},Va=function(i){if(!(!i||!i.length||!i.end))return i.end(i.length-1)},ul=function(i,e){let t=0;if(!i||!i.length)return t;for(let n=0;n<i.length;n++){const s=i.start(n),r=i.end(n);if(!(e>r)){if(e>s&&e<=r){t+=r-e;continue}t+=r-s}}return t},dl=(i,e)=>{if(!e.preload)return e.duration;let t=0;return(e.parts||[]).forEach(function(n){t+=n.duration}),(e.preloadHints||[]).forEach(function(n){n.type==="PART"&&(t+=i.partTargetDuration)}),t},oo=i=>(i.segments||[]).reduce((e,t,n)=>(t.parts?t.parts.forEach(function(s,r){e.push({duration:s.duration,segmentIndex:n,partIndex:r,part:s,segment:t})}):e.push({duration:t.duration,segmentIndex:n,partIndex:null,segment:t,part:null}),e),[]),Gc=i=>{const e=i.segments&&i.segments.length&&i.segments[i.segments.length-1];return e&&e.parts||[]},Xc=({preloadSegment:i})=>{if(!i)return;const{parts:e,preloadHints:t}=i;let n=(t||[]).reduce((s,r)=>s+(r.type==="PART"?1:0),0);return n+=e&&e.length?e.length:0,n},Kc=(i,e)=>{if(e.endList)return 0;if(i&&i.suggestedPresentationDelay)return i.suggestedPresentationDelay;const t=Gc(e).length>0;return t&&e.serverControl&&e.serverControl.partHoldBack?e.serverControl.partHoldBack:t&&e.partTargetDuration?e.partTargetDuration*3:e.serverControl&&e.serverControl.holdBack?e.serverControl.holdBack:e.targetDuration?e.targetDuration*3:0},oT=function(i,e){let t=0,n=e-i.mediaSequence,s=i.segments[n];if(s){if(typeof s.start<"u")return{result:s.start,precise:!0};if(typeof s.end<"u")return{result:s.end-s.duration,precise:!0}}for(;n--;){if(s=i.segments[n],typeof s.end<"u")return{result:t+s.end,precise:!0};if(t+=dl(i,s),typeof s.start<"u")return{result:t+s.start,precise:!0}}return{result:t,precise:!1}},lT=function(i,e){let t=0,n,s=e-i.mediaSequence;for(;s<i.segments.length;s++){if(n=i.segments[s],typeof n.start<"u")return{result:n.start-t,precise:!0};if(t+=dl(i,n),typeof n.end<"u")return{result:n.end-t,precise:!0}}return{result:-1,precise:!1}},Yc=function(i,e,t){if(typeof e>"u"&&(e=i.mediaSequence+i.segments.length),e<i.mediaSequence)return 0;const n=oT(i,e);if(n.precise)return n.result;const s=lT(i,e);return s.precise?s.result:n.result+t},Qc=function(i,e,t){if(!i)return 0;if(typeof t!="number"&&(t=0),typeof e>"u"){if(i.totalDuration)return i.totalDuration;if(!i.endList)return x.Infinity}return Yc(i,e,t)},us=function({defaultDuration:i,durationList:e,startIndex:t,endIndex:n}){let s=0;if(t>n&&([t,n]=[n,t]),t<0){for(let r=t;r<Math.min(0,n);r++)s+=i;t=0}for(let r=t;r<n;r++)s+=e[r].duration;return s},Jc=function(i,e,t,n){if(!i||!i.segments)return null;if(i.endList)return Qc(i);if(e===null)return null;e=e||0;let s=Yc(i,i.mediaSequence+i.segments.length,e);return t&&(n=typeof n=="number"?n:Kc(null,i),s-=n),Math.max(0,s)},uT=function(i,e,t){const n=e||0;let s=Jc(i,e,!0,t);return s===null?tt():(s<n&&(s=n),tt(n,s))},dT=function({playlist:i,currentTime:e,startingSegmentIndex:t,startingPartIndex:n,startTime:s,exactManifestTimings:r}){let a=e-s;const l=oo(i);let c=0;for(let g=0;g<l.length;g++){const m=l[g];if(t===m.segmentIndex&&!(typeof n=="number"&&typeof m.partIndex=="number"&&n!==m.partIndex)){c=g;break}}if(a<0){if(c>0)for(let g=c-1;g>=0;g--){const m=l[g];if(a+=m.duration,r){if(a<0)continue}else if(a+Xt<=0)continue;return{partIndex:m.partIndex,segmentIndex:m.segmentIndex,startTime:s-us({defaultDuration:i.targetDuration,durationList:l,startIndex:c,endIndex:g})}}return{partIndex:l[0]&&l[0].partIndex||null,segmentIndex:l[0]&&l[0].segmentIndex||0,startTime:e}}if(c<0){for(let g=c;g<0;g++)if(a-=i.targetDuration,a<0)return{partIndex:l[0]&&l[0].partIndex||null,segmentIndex:l[0]&&l[0].segmentIndex||0,startTime:e};c=0}for(let g=c;g<l.length;g++){const m=l[g];a-=m.duration;const b=m.duration>Xt,C=a===0,w=b&&a+Xt>=0;if(!((C||w)&&g!==l.length-1)){if(r){if(a>0)continue}else if(a-Xt>=0)continue;return{partIndex:m.partIndex,segmentIndex:m.segmentIndex,startTime:s+us({defaultDuration:i.targetDuration,durationList:l,startIndex:c,endIndex:g})}}}return{segmentIndex:l[l.length-1].segmentIndex,partIndex:l[l.length-1].partIndex,startTime:e}},Zc=function(i){return i.excludeUntil&&i.excludeUntil>Date.now()},hl=function(i){return i.excludeUntil&&i.excludeUntil===1/0},ta=function(i){const e=Zc(i);return!i.disabled&&!e},hT=function(i){return i.disabled},cT=function(i){for(let e=0;e<i.segments.length;e++)if(i.segments[e].key)return!0;return!1},ep=function(i,e){return e.attributes&&e.attributes[i]},pT=function(i,e,t,n=0){return ep("BANDWIDTH",t)?(i*t.attributes.BANDWIDTH-n*8)/e:NaN},lo=(i,e)=>{if(i.playlists.length===1)return!0;const t=e.attributes.BANDWIDTH||Number.MAX_VALUE;return i.playlists.filter(n=>ta(n)?(n.attributes.BANDWIDTH||0)<t:!1).length===0},cl=(i,e)=>!i&&!e||!i&&e||i&&!e?!1:!!(i===e||i.id&&e.id&&i.id===e.id||i.resolvedUri&&e.resolvedUri&&i.resolvedUri===e.resolvedUri||i.uri&&e.uri&&i.uri===e.uri),ld=function(i,e){const t=i&&i.mediaGroups&&i.mediaGroups.AUDIO||{};let n=!1;for(const s in t){for(const r in t[s])if(n=e(t[s][r]),n)break;if(n)break}return!!n},vs=i=>{if(!i||!i.playlists||!i.playlists.length)return ld(i,e=>e.playlists&&e.playlists.length||e.uri);for(let e=0;e<i.playlists.length;e++){const t=i.playlists[e],n=t.attributes&&t.attributes.CODECS;if(!(n&&n.split(",").every(s=>dh(s))||ld(i,s=>cl(t,s))))return!1}return!0};var ft={liveEdgeDelay:Kc,duration:Qc,seekable:uT,getMediaInfoForTime:dT,isEnabled:ta,isDisabled:hT,isExcluded:Zc,isIncompatible:hl,playlistEnd:Jc,isAes:cT,hasAttribute:ep,estimateSegmentRequestTime:pT,isLowestEnabledRendition:lo,isAudioOnly:vs,playlistMatch:cl,segmentDurationWithParts:dl};const{log:tp}=B,ln=(i,e)=>`${i}-${e}`,ip=(i,e,t)=>`placeholder-uri-${i}-${e}-${t}`,fT=({onwarn:i,oninfo:e,manifestString:t,customTagParsers:n=[],customTagMappers:s=[],llhls:r})=>{const a=new s0;i&&a.on("warn",i),e&&a.on("info",e),n.forEach(g=>a.addParser(g)),s.forEach(g=>a.addTagMapper(g)),a.push(t),a.end();const l=a.manifest;if(r||(["preloadSegment","skip","serverControl","renditionReports","partInf","partTargetDuration"].forEach(function(g){l.hasOwnProperty(g)&&delete l[g]}),l.segments&&l.segments.forEach(function(g){["parts","preloadHints"].forEach(function(m){g.hasOwnProperty(m)&&delete g[m]})})),!l.targetDuration){let g=10;l.segments&&l.segments.length&&(g=l.segments.reduce((m,b)=>Math.max(m,b.duration),0)),i&&i({message:`manifest has no targetDuration defaulting to ${g}`}),l.targetDuration=g}const c=Gc(l);if(c.length&&!l.partTargetDuration){const g=c.reduce((m,b)=>Math.max(m,b.duration),0);i&&(i({message:`manifest has no partTargetDuration defaulting to ${g}`}),tp.error("LL-HLS manifest has parts but lacks required #EXT-X-PART-INF:PART-TARGET value. See https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-09#section-4.4.3.7. Playback is not guaranteed.")),l.partTargetDuration=g}return l},An=(i,e)=>{i.mediaGroups&&["AUDIO","SUBTITLES"].forEach(t=>{if(i.mediaGroups[t])for(const n in i.mediaGroups[t])for(const s in i.mediaGroups[t][n]){const r=i.mediaGroups[t][n][s];e(r,t,n,s)}})},np=({playlist:i,uri:e,id:t})=>{i.id=t,i.playlistErrors_=0,e&&(i.uri=e),i.attributes=i.attributes||{}},gT=i=>{let e=i.playlists.length;for(;e--;){const t=i.playlists[e];np({playlist:t,id:ln(e,t.uri)}),t.resolvedUri=pt(i.uri,t.uri),i.playlists[t.id]=t,i.playlists[t.uri]=t,t.attributes.BANDWIDTH||tp.warn("Invalid playlist STREAM-INF detected. Missing BANDWIDTH attribute.")}},mT=i=>{An(i,e=>{e.uri&&(e.resolvedUri=pt(i.uri,e.uri))})},yT=(i,e)=>{const t=ln(0,e),n={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:x.location.href,resolvedUri:x.location.href,playlists:[{uri:e,id:t,resolvedUri:e,attributes:{}}]};return n.playlists[t]=n.playlists[0],n.playlists[e]=n.playlists[0],n},sp=(i,e,t=ip)=>{i.uri=e;for(let s=0;s<i.playlists.length;s++)if(!i.playlists[s].uri){const r=`placeholder-uri-${s}`;i.playlists[s].uri=r}const n=vs(i);An(i,(s,r,a,l)=>{if(!s.playlists||!s.playlists.length){if(n&&r==="AUDIO"&&!s.uri)for(let c=0;c<i.playlists.length;c++){const g=i.playlists[c];if(g.attributes&&g.attributes.AUDIO&&g.attributes.AUDIO===a)return}s.playlists=[je({},s)]}s.playlists.forEach(function(c,g){const m=t(r,a,l,c),b=ln(g,m);c.uri?c.resolvedUri=c.resolvedUri||pt(i.uri,c.uri):(c.uri=g===0?m:b,c.resolvedUri=c.uri),c.id=c.id||b,c.attributes=c.attributes||{},i.playlists[c.id]=c,i.playlists[c.uri]=c})}),gT(i),mT(i)};class ud{constructor(){this.offset_=null,this.pendingDateRanges_=new Map,this.processedDateRanges_=new Map}setOffset(e=[]){if(this.offset_!==null||!e.length)return;const[t]=e;t.programDateTime!==void 0&&(this.offset_=t.programDateTime/1e3)}setPendingDateRanges(e=[]){if(!e.length)return;const[t]=e,n=t.startDate.getTime();this.trimProcessedDateRanges_(n),this.pendingDateRanges_=e.reduce((s,r)=>(s.set(r.id,r),s),new Map)}processDateRange(e){this.pendingDateRanges_.delete(e.id),this.processedDateRanges_.set(e.id,e)}getDateRangesToProcess(){if(this.offset_===null)return[];const e={},t=[];this.pendingDateRanges_.forEach((n,s)=>{if(!this.processedDateRanges_.has(s)&&(n.startTime=n.startDate.getTime()/1e3-this.offset_,n.processDateRange=()=>this.processDateRange(n),t.push(n),!!n.class))if(e[n.class]){const r=e[n.class].push(n);n.classListIndex=r-1}else e[n.class]=[n],n.classListIndex=0});for(const n of t){const s=e[n.class]||[];n.endDate?n.endTime=n.endDate.getTime()/1e3-this.offset_:n.endOnNext&&s[n.classListIndex+1]?n.endTime=s[n.classListIndex+1].startTime:n.duration?n.endTime=n.startTime+n.duration:n.plannedDuration?n.endTime=n.startTime+n.plannedDuration:n.endTime=n.startTime}return t}trimProcessedDateRanges_(e){new Map(this.processedDateRanges_).forEach((t,n)=>{t.startDate.getTime()<e&&this.processedDateRanges_.delete(n)})}}const rp=22,$i=({requestType:i,request:e,error:t,parseFailure:n})=>{const s=e.status<200||e.status>299,r=e.status>=400&&e.status<=499,a={uri:e.uri,requestType:i},l=s&&!r||n;if(t&&r)a.error=je({},t),a.errorType=B.Error.NetworkRequestFailed;else if(e.aborted)a.errorType=B.Error.NetworkRequestAborted;else if(e.timedout)a.erroType=B.Error.NetworkRequestTimeout;else if(l){const c=n?B.Error.NetworkBodyParserFailed:B.Error.NetworkBadStatus;a.errorType=c,a.status=e.status,a.headers=e.headers}return a},{EventTarget:_T}=B,bT=(i,e)=>{if(e.endList||!e.serverControl)return i;const t={};if(e.serverControl.canBlockReload){const{preloadSegment:n}=e;let s=e.mediaSequence+e.segments.length;if(n){const r=n.parts||[],a=Xc(e)-1;a>-1&&a!==r.length-1&&(t._HLS_part=a),(a>-1||r.length)&&s--}t._HLS_msn=s}if(e.serverControl&&e.serverControl.canSkipUntil&&(t._HLS_skip=e.serverControl.canSkipDateranges?"v2":"YES"),Object.keys(t).length){const n=new x.URL(i);["_HLS_skip","_HLS_msn","_HLS_part"].forEach(function(s){t.hasOwnProperty(s)&&n.searchParams.set(s,t[s])}),i=n.toString()}return i},TT=(i,e)=>{if(!i)return e;const t=ge(i,e);if(i.preloadHints&&!e.preloadHints&&delete t.preloadHints,i.parts&&!e.parts)delete t.parts;else if(i.parts&&e.parts)for(let n=0;n<e.parts.length;n++)i.parts&&i.parts[n]&&(t.parts[n]=ge(i.parts[n],e.parts[n]));return!i.skipped&&e.skipped&&(t.skipped=!1),i.preload&&!e.preload&&(t.preload=!1),t},vT=(i,e,t)=>{const n=i.slice(),s=e.slice();t=t||0;const r=[];let a;for(let l=0;l<s.length;l++){const c=n[l+t],g=s[l];c?(a=c.map||a,r.push(TT(c,g))):(a&&!g.map&&(g.map=a),r.push(g))}return r},ap=(i,e)=>{!i.resolvedUri&&i.uri&&(i.resolvedUri=pt(e,i.uri)),i.key&&!i.key.resolvedUri&&(i.key.resolvedUri=pt(e,i.key.uri)),i.map&&!i.map.resolvedUri&&(i.map.resolvedUri=pt(e,i.map.uri)),i.map&&i.map.key&&!i.map.key.resolvedUri&&(i.map.key.resolvedUri=pt(e,i.map.key.uri)),i.parts&&i.parts.length&&i.parts.forEach(t=>{t.resolvedUri||(t.resolvedUri=pt(e,t.uri))}),i.preloadHints&&i.preloadHints.length&&i.preloadHints.forEach(t=>{t.resolvedUri||(t.resolvedUri=pt(e,t.uri))})},op=function(i){const e=i.segments||[],t=i.preloadSegment;if(t&&t.parts&&t.parts.length){if(t.preloadHints){for(let n=0;n<t.preloadHints.length;n++)if(t.preloadHints[n].type==="MAP")return e}t.duration=i.targetDuration,t.preload=!0,e.push(t)}return e},lp=(i,e)=>i===e||i.segments&&e.segments&&i.segments.length===e.segments.length&&i.endList===e.endList&&i.mediaSequence===e.mediaSequence&&i.preloadSegment===e.preloadSegment,uo=(i,e,t=lp)=>{const n=ge(i,{}),s=n.playlists[e.id];if(!s||t(s,e))return null;e.segments=op(e);const r=ge(s,e);if(r.preloadSegment&&!e.preloadSegment&&delete r.preloadSegment,s.segments){if(e.skip){e.segments=e.segments||[];for(let a=0;a<e.skip.skippedSegments;a++)e.segments.unshift({skipped:!0})}r.segments=vT(s.segments,e.segments,e.mediaSequence-s.mediaSequence)}r.segments.forEach(a=>{ap(a,r.resolvedUri)});for(let a=0;a<n.playlists.length;a++)n.playlists[a].id===e.id&&(n.playlists[a]=r);return n.playlists[e.id]=r,n.playlists[e.uri]=r,An(i,(a,l,c,g)=>{if(a.playlists)for(let m=0;m<a.playlists.length;m++)e.id===a.playlists[m].id&&(a.playlists[m]=r)}),n},ho=(i,e)=>{const t=i.segments||[],n=t[t.length-1],s=n&&n.parts&&n.parts[n.parts.length-1],r=s&&s.duration||n&&n.duration;return e&&r?r*1e3:(i.partTargetDuration||i.targetDuration||10)*500},dd=(i,e,t)=>{if(!i)return;const n=[];return i.forEach(s=>{if(!s.attributes)return;const{BANDWIDTH:r,RESOLUTION:a,CODECS:l}=s.attributes;n.push({id:s.id,bandwidth:r,resolution:a,codecs:l})}),{type:e,isLive:t,renditions:n}};class nn extends _T{constructor(e,t,n={}){if(super(),!e)throw new Error("A non-empty playlist URL or object is required");this.logger_=Lt("PlaylistLoader");const{withCredentials:s=!1}=n;this.src=e,this.vhs_=t,this.withCredentials=s,this.addDateRangesToTextTrack_=n.addDateRangesToTextTrack;const r=t.options_;this.customTagParsers=r&&r.customTagParsers||[],this.customTagMappers=r&&r.customTagMappers||[],this.llhls=r&&r.llhls,this.dateRangesStorage_=new ud,this.state="HAVE_NOTHING",this.handleMediaupdatetimeout_=this.handleMediaupdatetimeout_.bind(this),this.on("mediaupdatetimeout",this.handleMediaupdatetimeout_),this.on("loadedplaylist",this.handleLoadedPlaylist_.bind(this))}handleLoadedPlaylist_(){const e=this.media();if(!e)return;this.dateRangesStorage_.setOffset(e.segments),this.dateRangesStorage_.setPendingDateRanges(e.dateRanges);const t=this.dateRangesStorage_.getDateRangesToProcess();!t.length||!this.addDateRangesToTextTrack_||this.addDateRangesToTextTrack_(t)}handleMediaupdatetimeout_(){if(this.state!=="HAVE_METADATA")return;const e=this.media();let t=pt(this.main.uri,e.uri);this.llhls&&(t=bT(t,e)),this.state="HAVE_CURRENT_METADATA",this.request=this.vhs_.xhr({uri:t,withCredentials:this.withCredentials,requestType:"hls-playlist"},(n,s)=>{if(this.request){if(n)return this.playlistRequestError(this.request,this.media(),"HAVE_METADATA");this.haveMetadata({playlistString:this.request.responseText,url:this.media().uri,id:this.media().id})}})}playlistRequestError(e,t,n){const{uri:s,id:r}=t;this.request=null,n&&(this.state=n),this.error={playlist:this.main.playlists[r],status:e.status,message:`HLS playlist request error at URL: ${s}.`,responseText:e.responseText,code:e.status>=500?4:2,metadata:$i({requestType:e.requestType,request:e,error:e.error})},this.trigger("error")}parseManifest_({url:e,manifestString:t}){try{return fT({onwarn:({message:n})=>this.logger_(`m3u8-parser warn for ${e}: ${n}`),oninfo:({message:n})=>this.logger_(`m3u8-parser info for ${e}: ${n}`),manifestString:t,customTagParsers:this.customTagParsers,customTagMappers:this.customTagMappers,llhls:this.llhls})}catch(n){this.error=n,this.error.metadata={errorType:B.Error.StreamingHlsPlaylistParserError,error:n}}}haveMetadata({playlistString:e,playlistObject:t,url:n,id:s}){this.request=null,this.state="HAVE_METADATA";const r={playlistInfo:{type:"media",uri:n}};this.trigger({type:"playlistparsestart",metadata:r});const a=t||this.parseManifest_({url:n,manifestString:e});a.lastRequest=Date.now(),np({playlist:a,uri:n,id:s});const l=uo(this.main,a);this.targetDuration=a.partTargetDuration||a.targetDuration,this.pendingMedia_=null,l?(this.main=l,this.media_=this.main.playlists[s]):this.trigger("playlistunchanged"),this.updateMediaUpdateTimeout_(ho(this.media(),!!l)),r.parsedPlaylist=dd(this.main.playlists,r.playlistInfo.type,!this.media_.endList),this.trigger({type:"playlistparsecomplete",metadata:r}),this.trigger("loadedplaylist")}dispose(){this.trigger("dispose"),this.stopRequest(),x.clearTimeout(this.mediaUpdateTimeout),x.clearTimeout(this.finalRenditionTimeout),this.dateRangesStorage_=new ud,this.off()}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e,t){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);if(typeof e=="string"){if(!this.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.main.playlists[e]}if(x.clearTimeout(this.finalRenditionTimeout),t){const l=(e.partTargetDuration||e.targetDuration)/2*1e3||5e3;this.finalRenditionTimeout=x.setTimeout(this.media.bind(this,e,!1),l);return}const n=this.state,s=!this.media_||e.id!==this.media_.id,r=this.main.playlists[e.id];if(r&&r.endList||e.endList&&e.segments.length){this.request&&(this.request.onreadystatechange=null,this.request.abort(),this.request=null),this.state="HAVE_METADATA",this.media_=e,s&&(this.trigger("mediachanging"),n==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange"));return}if(this.updateMediaUpdateTimeout_(ho(e,!0)),!s)return;if(this.state="SWITCHING_MEDIA",this.request){if(e.resolvedUri===this.request.url)return;this.request.onreadystatechange=null,this.request.abort(),this.request=null}this.media_&&this.trigger("mediachanging"),this.pendingMedia_=e;const a={playlistInfo:{type:"media",uri:e.uri}};this.trigger({type:"playlistrequeststart",metadata:a}),this.request=this.vhs_.xhr({uri:e.resolvedUri,withCredentials:this.withCredentials,requestType:"hls-playlist"},(l,c)=>{if(this.request){if(e.lastRequest=Date.now(),e.resolvedUri=kr(e.resolvedUri,c),l)return this.playlistRequestError(this.request,e,n);this.trigger({type:"playlistrequestcomplete",metadata:a}),this.haveMetadata({playlistString:c.responseText,url:e.uri,id:e.id}),n==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange")}})}pause(){this.mediaUpdateTimeout&&(x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),this.stopRequest(),this.state==="HAVE_NOTHING"&&(this.started=!1),this.state==="SWITCHING_MEDIA"?this.media_?this.state="HAVE_METADATA":this.state="HAVE_MAIN_MANIFEST":this.state==="HAVE_CURRENT_METADATA"&&(this.state="HAVE_METADATA")}load(e){this.mediaUpdateTimeout&&(x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null);const t=this.media();if(e){const n=t?(t.partTargetDuration||t.targetDuration)/2*1e3:5e3;this.mediaUpdateTimeout=x.setTimeout(()=>{this.mediaUpdateTimeout=null,this.load()},n);return}if(!this.started){this.start();return}t&&!t.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist")}updateMediaUpdateTimeout_(e){this.mediaUpdateTimeout&&(x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),!(!this.media()||this.media().endList)&&(this.mediaUpdateTimeout=x.setTimeout(()=>{this.mediaUpdateTimeout=null,this.trigger("mediaupdatetimeout"),this.updateMediaUpdateTimeout_(e)},e))}start(){if(this.started=!0,typeof this.src=="object"){this.src.uri||(this.src.uri=x.location.href),this.src.resolvedUri=this.src.uri,setTimeout(()=>{this.setupInitialPlaylist(this.src)},0);return}const e={playlistInfo:{type:"multivariant",uri:this.src}};this.trigger({type:"playlistrequeststart",metadata:e}),this.request=this.vhs_.xhr({uri:this.src,withCredentials:this.withCredentials,requestType:"hls-playlist"},(t,n)=>{if(!this.request)return;if(this.request=null,t)return this.error={status:n.status,message:`HLS playlist request error at URL: ${this.src}.`,responseText:n.responseText,code:2,metadata:$i({requestType:n.requestType,request:n,error:t})},this.state==="HAVE_NOTHING"&&(this.started=!1),this.trigger("error");this.trigger({type:"playlistrequestcomplete",metadata:e}),this.src=kr(this.src,n),this.trigger({type:"playlistparsestart",metadata:e});const s=this.parseManifest_({manifestString:n.responseText,url:this.src});e.parsedPlaylist=dd(s.playlists,e.playlistInfo.type,!1),this.trigger({type:"playlistparsecomplete",metadata:e}),this.setupInitialPlaylist(s)})}srcUri(){return typeof this.src=="string"?this.src:this.src.uri}setupInitialPlaylist(e){if(this.state="HAVE_MAIN_MANIFEST",e.playlists){this.main=e,sp(this.main,this.srcUri()),e.playlists.forEach(n=>{n.segments=op(n),n.segments.forEach(s=>{ap(s,n.resolvedUri)})}),this.trigger("loadedplaylist"),this.request||this.media(this.main.playlists[0]);return}const t=this.srcUri()||x.location.href;this.main=yT(e,t),this.haveMetadata({playlistObject:e,url:t,id:this.main.playlists[0].id}),this.trigger("loadedmetadata")}updateOrDeleteClone(e,t){const n=this.main,s=e.ID;let r=n.playlists.length;for(;r--;){const a=n.playlists[r];if(a.attributes["PATHWAY-ID"]===s){const l=a.resolvedUri,c=a.id;if(t){const g=this.createCloneURI_(a.resolvedUri,e),m=ln(s,g),b=this.createCloneAttributes_(s,a.attributes),C=this.createClonePlaylist_(a,m,e,b);n.playlists[r]=C,n.playlists[m]=C,n.playlists[g]=C}else n.playlists.splice(r,1);delete n.playlists[c],delete n.playlists[l]}}this.updateOrDeleteCloneMedia(e,t)}updateOrDeleteCloneMedia(e,t){const n=this.main,s=e.ID;["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(r=>{if(!(!n.mediaGroups[r]||!n.mediaGroups[r][s])){for(const a in n.mediaGroups[r])if(a===s){for(const l in n.mediaGroups[r][a])n.mediaGroups[r][a][l].playlists.forEach((c,g)=>{const m=n.playlists[c.id],b=m.id,C=m.resolvedUri;delete n.playlists[b],delete n.playlists[C]});delete n.mediaGroups[r][a]}}}),t&&this.createClonedMediaGroups_(e)}addClonePathway(e,t={}){const n=this.main,s=n.playlists.length,r=this.createCloneURI_(t.resolvedUri,e),a=ln(e.ID,r),l=this.createCloneAttributes_(e.ID,t.attributes),c=this.createClonePlaylist_(t,a,e,l);n.playlists[s]=c,n.playlists[a]=c,n.playlists[r]=c,this.createClonedMediaGroups_(e)}createClonedMediaGroups_(e){const t=e.ID,n=e["BASE-ID"],s=this.main;["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(r=>{if(!(!s.mediaGroups[r]||s.mediaGroups[r][t]))for(const a in s.mediaGroups[r]){if(a===n)s.mediaGroups[r][t]={};else continue;for(const l in s.mediaGroups[r][a]){const c=s.mediaGroups[r][a][l];s.mediaGroups[r][t][l]=je({},c);const g=s.mediaGroups[r][t][l],m=this.createCloneURI_(c.resolvedUri,e);g.resolvedUri=m,g.uri=m,g.playlists=[],c.playlists.forEach((b,C)=>{const w=s.playlists[b.id],A=ip(r,t,l),v=ln(t,A);if(w&&!s.playlists[v]){const M=this.createClonePlaylist_(w,v,e),D=M.resolvedUri;s.playlists[v]=M,s.playlists[D]=M}g.playlists[C]=this.createClonePlaylist_(b,v,e)})}}})}createClonePlaylist_(e,t,n,s){const r=this.createCloneURI_(e.resolvedUri,n),a={resolvedUri:r,uri:r,id:t};return e.segments&&(a.segments=[]),s&&(a.attributes=s),ge(e,a)}createCloneURI_(e,t){const n=new URL(e);n.hostname=t["URI-REPLACEMENT"].HOST;const s=t["URI-REPLACEMENT"].PARAMS;for(const r of Object.keys(s))n.searchParams.set(r,s[r]);return n.href}createCloneAttributes_(e,t){const n={"PATHWAY-ID":e};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(s=>{t[s]&&(n[s]=e)}),n}getKeyIdSet(e){if(e.contentProtection){const t=new Set;for(const n in e.contentProtection){const s=e.contentProtection[n].attributes.keyId;s&&t.add(s.toLowerCase())}return t}}}const co=function(i,e,t,n){const s=i.responseType==="arraybuffer"?i.response:i.responseText;!e&&s&&(i.responseTime=Date.now(),i.roundTripTime=i.responseTime-i.requestTime,i.bytesReceived=s.byteLength||s.length,i.bandwidth||(i.bandwidth=Math.floor(i.bytesReceived/i.roundTripTime*8*1e3))),t.headers&&(i.responseHeaders=t.headers),e&&e.code==="ETIMEDOUT"&&(i.timedout=!0),!e&&!i.aborted&&t.statusCode!==200&&t.statusCode!==206&&t.statusCode!==0&&(e=new Error("XHR Failed with a response of: "+(i&&(s||i.responseText)))),n(e,i)},ST=(i,e)=>{if(!i||!i.size)return;let t=e;return i.forEach(n=>{t=n(t)}),t},ET=(i,e,t,n)=>{!i||!i.size||i.forEach(s=>{s(e,t,n)})},up=function(){const i=function e(t,n){t=ge({timeout:45e3},t);const s=e.beforeRequest||B.Vhs.xhr.beforeRequest,r=e._requestCallbackSet||B.Vhs.xhr._requestCallbackSet||new Set,a=e._responseCallbackSet||B.Vhs.xhr._responseCallbackSet;s&&typeof s=="function"&&(B.log.warn("beforeRequest is deprecated, use onRequest instead."),r.add(s));const l=B.Vhs.xhr.original===!0?B.xhr:B.Vhs.xhr,c=ST(r,t);r.delete(s);const g=l(c||t,function(b,C){return ET(a,g,b,C),co(g,b,C,n)}),m=g.abort;return g.abort=function(){return g.aborted=!0,m.apply(g,arguments)},g.uri=t.uri,g.requestType=t.requestType,g.requestTime=Date.now(),g};return i.original=!0,i},wT=function(i){let e;const t=i.offset;return typeof i.offset=="bigint"||typeof i.length=="bigint"?e=x.BigInt(i.offset)+x.BigInt(i.length)-x.BigInt(1):e=i.offset+i.length-1,"bytes="+t+"-"+e},po=function(i){const e={};return i.byterange&&(e.Range=wT(i.byterange)),e},kT=function(i,e){return i.start(e)+"-"+i.end(e)},CT=function(i,e){const t=i.toString(16);return"00".substring(0,2-t.length)+t+(e%2?" ":"")},IT=function(i){return i>=32&&i<126?String.fromCharCode(i):"."},dp=function(i){const e={};return Object.keys(i).forEach(t=>{const n=i[t];ch(n)?e[t]={bytes:n.buffer,byteOffset:n.byteOffset,byteLength:n.byteLength}:e[t]=n}),e},Cr=function(i){const e=i.byterange||{length:1/0,offset:0};return[e.length,e.offset,i.resolvedUri].join(",")},hp=function(i){return i.resolvedUri},cp=i=>{const e=Array.prototype.slice.call(i),t=16;let n="",s,r;for(let a=0;a<e.length/t;a++)s=e.slice(a*t,a*t+t).map(CT).join(""),r=e.slice(a*t,a*t+t).map(IT).join(""),n+=s+" "+r+`
|
|
190
|
-
`;return n},xT=({bytes:i})=>cp(i),AT=i=>{let e="",t;for(t=0;t<i.length;t++)e+=kT(i,t)+" ";return e};var PT=Object.freeze({__proto__:null,createTransferableMessage:dp,initSegmentId:Cr,segmentKeyId:hp,hexDump:cp,tagDump:xT,textRanges:AT});const pp=.25,LT=(i,e)=>{if(!e.dateTimeObject)return null;const t=e.videoTimingInfo.transmuxerPrependedSeconds,n=e.videoTimingInfo.transmuxedPresentationStart+t,s=i-n;return new Date(e.dateTimeObject.getTime()+s*1e3)},DT=i=>i.transmuxedPresentationEnd-i.transmuxedPresentationStart-i.transmuxerPrependedSeconds,OT=(i,e)=>{let t;try{t=new Date(i)}catch{return null}if(!e||!e.segments||e.segments.length===0)return null;let n=e.segments[0];if(t<new Date(n.dateTimeObject))return null;for(let c=0;c<e.segments.length-1;c++){n=e.segments[c];const g=new Date(e.segments[c+1].dateTimeObject);if(t<g)break}const s=e.segments[e.segments.length-1],r=s.dateTimeObject,a=s.videoTimingInfo?DT(s.videoTimingInfo):s.duration+s.duration*pp,l=new Date(r.getTime()+a*1e3);return t>l?null:(t>new Date(r)&&(n=s),{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:ft.duration(e,e.mediaSequence+e.segments.indexOf(n)),type:n.videoTimingInfo?"accurate":"estimate"})},MT=(i,e)=>{if(!e||!e.segments||e.segments.length===0)return null;let t=0,n;for(let r=0;r<e.segments.length&&(n=e.segments[r],t=n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationEnd:t+n.duration,!(i<=t));r++);const s=e.segments[e.segments.length-1];if(s.videoTimingInfo&&s.videoTimingInfo.transmuxedPresentationEnd<i)return null;if(i>t){if(i>t+s.duration*pp)return null;n=s}return{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:t-n.duration,type:n.videoTimingInfo?"accurate":"estimate"}},RT=(i,e)=>{let t,n;try{t=new Date(i),n=new Date(e)}catch{}const s=t.getTime();return(n.getTime()-s)/1e3},UT=i=>{if(!i.segments||i.segments.length===0)return!1;for(let e=0;e<i.segments.length;e++)if(!i.segments[e].dateTimeObject)return!1;return!0},NT=({playlist:i,time:e=void 0,callback:t})=>{if(!t)throw new Error("getProgramTime: callback must be provided");if(!i||e===void 0)return t({message:"getProgramTime: playlist and time must be provided"});const n=MT(e,i);if(!n)return t({message:"valid programTime was not found"});if(n.type==="estimate")return t({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:n.estimatedStart});const s={mediaSeconds:e},r=LT(e,n.segment);return r&&(s.programDateTime=r.toISOString()),t(null,s)},fp=({programTime:i,playlist:e,retryCount:t=2,seekTo:n,pauseAfterSeek:s=!0,tech:r,callback:a})=>{if(!a)throw new Error("seekToProgramTime: callback must be provided");if(typeof i>"u"||!e||!n)return a({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!e.endList&&!r.hasStarted_)return a({message:"player must be playing a live stream to start buffering"});if(!UT(e))return a({message:"programDateTime tags must be provided in the manifest "+e.resolvedUri});const l=OT(i,e);if(!l)return a({message:`${i} was not found in the stream`});const c=l.segment,g=RT(c.dateTimeObject,i);if(l.type==="estimate"){if(t===0)return a({message:`${i} is not buffered yet. Try again`});n(l.estimatedStart+g),r.one("seeked",()=>{fp({programTime:i,playlist:e,retryCount:t-1,seekTo:n,pauseAfterSeek:s,tech:r,callback:a})});return}const m=c.start+g,b=()=>a(null,r.currentTime());r.one("seeked",b),s&&r.pause(),n(m)},Ha=(i,e)=>{if(i.readyState===4)return e()},BT=(i,e,t,n)=>{let s=[],r,a=!1;const l=function(m,b,C,w){return b.abort(),a=!0,t(m,b,C,w)},c=function(m,b){if(a)return;if(m)return m.metadata=$i({requestType:n,request:b,error:m}),l(m,b,"",s);const C=b.responseText.substring(s&&s.byteLength||0,b.responseText.length);if(s=m0(s,ph(C,!0)),r=r||ts(s),s.length<10||r&&s.length<r+2)return Ha(b,()=>l(m,b,"",s));const w=Oo(s);return w==="ts"&&s.length<188?Ha(b,()=>l(m,b,"",s)):!w&&s.length<376?Ha(b,()=>l(m,b,"",s)):l(null,b,w,s)},g=e({uri:i,beforeSend(m){m.overrideMimeType("text/plain; charset=x-user-defined"),m.addEventListener("progress",function({total:b,loaded:C}){return co(m,null,{statusCode:m.status},c)})}},function(m,b){return co(g,m,b,c)});return g},{EventTarget:FT}=B,hd=function(i,e){if(!lp(i,e)||i.sidx&&e.sidx&&(i.sidx.offset!==e.sidx.offset||i.sidx.length!==e.sidx.length)||!i.sidx&&e.sidx||i.sidx&&!e.sidx||i.segments&&!e.segments||!i.segments&&e.segments)return!1;if(!i.segments&&!e.segments)return!0;for(let t=0;t<i.segments.length;t++){const n=i.segments[t],s=e.segments[t];if(n.uri!==s.uri)return!1;if(!n.byterange&&!s.byterange)continue;const r=n.byterange,a=s.byterange;if(r&&!a||!r&&a||r.offset!==a.offset||r.length!==a.length)return!1}return!0},jT=(i,e,t,n)=>{const s=n.attributes.NAME||t;return`placeholder-uri-${i}-${e}-${s}`},$T=({mainXml:i,srcUrl:e,clientOffset:t,sidxMapping:n,previousManifest:s})=>{const r=u1(i,{manifestUri:e,clientOffset:t,sidxMapping:n,previousManifest:s});return sp(r,e,jT),r},qT=(i,e)=>{An(i,(t,n,s,r)=>{(!e.mediaGroups[n][s]||!(r in e.mediaGroups[n][s]))&&delete i.mediaGroups[n][s][r]})},VT=(i,e,t)=>{let n=!0,s=ge(i,{duration:e.duration,minimumUpdatePeriod:e.minimumUpdatePeriod,timelineStarts:e.timelineStarts});for(let r=0;r<e.playlists.length;r++){const a=e.playlists[r];if(a.sidx){const c=Ur(a.sidx);t&&t[c]&&t[c].sidx&&Po(a,t[c].sidx,a.sidx.resolvedUri)}const l=uo(s,a,hd);l&&(s=l,n=!1)}return An(e,(r,a,l,c)=>{if(r.playlists&&r.playlists.length){const g=r.playlists[0].id,m=uo(s,r.playlists[0],hd);m&&(s=m,c in s.mediaGroups[a][l]||(s.mediaGroups[a][l][c]=r),s.mediaGroups[a][l][c].playlists[0]=s.playlists[g],n=!1)}}),qT(s,e),e.minimumUpdatePeriod!==i.minimumUpdatePeriod&&(n=!1),n?null:s},HT=(i,e)=>(!i.map&&!e.map||!!(i.map&&e.map&&i.map.byterange.offset===e.map.byterange.offset&&i.map.byterange.length===e.map.byterange.length))&&i.uri===e.uri&&i.byterange.offset===e.byterange.offset&&i.byterange.length===e.byterange.length,cd=(i,e)=>{const t={};for(const n in i){const s=i[n].sidx;if(s){const r=Ur(s);if(!e[r])break;const a=e[r].sidxInfo;HT(a,s)&&(t[r]=e[r])}}return t},zT=(i,e)=>{let t=cd(i.playlists,e);return An(i,(n,s,r,a)=>{if(n.playlists&&n.playlists.length){const l=n.playlists;t=ge(t,cd(l,e))}}),t};class fo extends FT{constructor(e,t,n={},s){super(),this.isPaused_=!0,this.mainPlaylistLoader_=s||this,s||(this.isMain_=!0);const{withCredentials:r=!1}=n;if(this.vhs_=t,this.withCredentials=r,this.addMetadataToTextTrack=n.addMetadataToTextTrack,!e)throw new Error("A non-empty playlist URL or object is required");this.on("minimumUpdatePeriod",()=>{this.refreshXml_()}),this.on("mediaupdatetimeout",()=>{this.refreshMedia_(this.media().id)}),this.state="HAVE_NOTHING",this.loadedPlaylists_={},this.logger_=Lt("DashPlaylistLoader"),this.isMain_?(this.mainPlaylistLoader_.srcUrl=e,this.mainPlaylistLoader_.sidxMapping_={}):this.childPlaylist_=e}get isPaused(){return this.isPaused_}requestErrored_(e,t,n){if(!this.request)return!0;if(this.request=null,e)return this.error=typeof e=="object"&&!(e instanceof Error)?e:{status:t.status,message:"DASH request error at URL: "+t.uri,response:t.response,code:2,metadata:e.metadata},n&&(this.state=n),this.trigger("error"),!0}addSidxSegments_(e,t,n){const s=e.sidx&&Ur(e.sidx);if(!e.sidx||!s||this.mainPlaylistLoader_.sidxMapping_[s]){x.clearTimeout(this.mediaRequest_),this.mediaRequest_=x.setTimeout(()=>n(!1),0);return}const r=kr(e.sidx.resolvedUri),a=(c,g)=>{if(this.requestErrored_(c,g,t))return;const m=this.mainPlaylistLoader_.sidxMapping_,{requestType:b}=g;let C;try{C=g1(ie(g.response).subarray(8))}catch(w){w.metadata=$i({requestType:b,request:g,parseFailure:!0}),this.requestErrored_(w,g,t);return}return m[s]={sidxInfo:e.sidx,sidx:C},Po(e,C,e.sidx.resolvedUri),n(!0)},l="dash-sidx";this.request=BT(r,this.vhs_.xhr,(c,g,m,b)=>{if(c)return a(c,g);if(!m||m!=="mp4"){const A=m||"unknown";return a({status:g.status,message:`Unsupported ${A} container type for sidx segment at URL: ${r}`,response:"",playlist:e,internal:!0,playlistExclusionDuration:1/0,code:2},g)}const{offset:C,length:w}=e.sidx.byterange;if(b.length>=w+C)return a(c,{response:b.subarray(C,C+w),status:g.status,uri:g.uri});this.request=this.vhs_.xhr({uri:r,responseType:"arraybuffer",requestType:"dash-sidx",headers:po({byterange:e.sidx.byterange})},a)},l)}dispose(){this.isPaused_=!0,this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},x.clearTimeout(this.minimumUpdatePeriodTimeout_),x.clearTimeout(this.mediaRequest_),x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.mediaRequest_=null,this.minimumUpdatePeriodTimeout_=null,this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.off()}hasPendingRequest(){return this.request||this.mediaRequest_}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);const t=this.state;if(typeof e=="string"){if(!this.mainPlaylistLoader_.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.mainPlaylistLoader_.main.playlists[e]}const n=!this.media_||e.id!==this.media_.id;if(n&&this.loadedPlaylists_[e.id]&&this.loadedPlaylists_[e.id].endList){this.state="HAVE_METADATA",this.media_=e,n&&(this.trigger("mediachanging"),this.trigger("mediachange"));return}n&&(this.media_&&this.trigger("mediachanging"),this.addSidxSegments_(e,t,s=>{this.haveMetadata({startingState:t,playlist:e})}))}haveMetadata({startingState:e,playlist:t}){this.state="HAVE_METADATA",this.loadedPlaylists_[t.id]=t,x.clearTimeout(this.mediaRequest_),this.mediaRequest_=null,this.refreshMedia_(t.id),e==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange")}pause(){this.isPaused_=!0,this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.stopRequest(),x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.isMain_&&(x.clearTimeout(this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_),this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_=null),this.state==="HAVE_NOTHING"&&(this.started=!1)}load(e){this.isPaused_=!1,x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;const t=this.media();if(e){const n=t?t.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=x.setTimeout(()=>this.load(),n);return}if(!this.started){this.start();return}t&&!t.endList?(this.isMain_&&!this.minimumUpdatePeriodTimeout_&&(this.trigger("minimumUpdatePeriod"),this.updateMinimumUpdatePeriodTimeout_()),this.trigger("mediaupdatetimeout")):this.trigger("loadedplaylist")}start(){if(this.started=!0,!this.isMain_){x.clearTimeout(this.mediaRequest_),this.mediaRequest_=x.setTimeout(()=>this.haveMain_(),0);return}this.requestMain_((e,t)=>{this.haveMain_(),!this.hasPendingRequest()&&!this.media_&&this.media(this.mainPlaylistLoader_.main.playlists[0])})}requestMain_(e){const t={manifestInfo:{uri:this.mainPlaylistLoader_.srcUrl}};this.trigger({type:"manifestrequeststart",metadata:t}),this.request=this.vhs_.xhr({uri:this.mainPlaylistLoader_.srcUrl,withCredentials:this.withCredentials,requestType:"dash-manifest"},(n,s)=>{if(n){const{requestType:a}=s;n.metadata=$i({requestType:a,request:s,error:n})}if(this.requestErrored_(n,s)){this.state==="HAVE_NOTHING"&&(this.started=!1);return}this.trigger({type:"manifestrequestcomplete",metadata:t});const r=s.responseText!==this.mainPlaylistLoader_.mainXml_;if(this.mainPlaylistLoader_.mainXml_=s.responseText,s.responseHeaders&&s.responseHeaders.date?this.mainLoaded_=Date.parse(s.responseHeaders.date):this.mainLoaded_=Date.now(),this.mainPlaylistLoader_.srcUrl=kr(this.mainPlaylistLoader_.srcUrl,s),r){this.handleMain_(),this.syncClientServerClock_(()=>e(s,r));return}return e(s,r)})}syncClientServerClock_(e){const t=d1(this.mainPlaylistLoader_.mainXml_);if(t===null)return this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e();if(t.method==="DIRECT")return this.mainPlaylistLoader_.clientOffset_=t.value-Date.now(),e();this.request=this.vhs_.xhr({uri:pt(this.mainPlaylistLoader_.srcUrl,t.value),method:t.method,withCredentials:this.withCredentials,requestType:"dash-clock-sync"},(n,s)=>{if(!this.request)return;if(n){const{requestType:a}=s;return this.error.metadata=$i({requestType:a,request:s,error:n}),this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e()}let r;t.method==="HEAD"?!s.responseHeaders||!s.responseHeaders.date?r=this.mainLoaded_:r=Date.parse(s.responseHeaders.date):r=Date.parse(s.responseText),this.mainPlaylistLoader_.clientOffset_=r-Date.now(),e()})}haveMain_(){this.state="HAVE_MAIN_MANIFEST",this.isMain_?this.trigger("loadedplaylist"):this.media_||this.media(this.childPlaylist_)}handleMain_(){x.clearTimeout(this.mediaRequest_),this.mediaRequest_=null;const e=this.mainPlaylistLoader_.main,t={manifestInfo:{uri:this.mainPlaylistLoader_.srcUrl}};this.trigger({type:"manifestparsestart",metadata:t});let n;try{n=$T({mainXml:this.mainPlaylistLoader_.mainXml_,srcUrl:this.mainPlaylistLoader_.srcUrl,clientOffset:this.mainPlaylistLoader_.clientOffset_,sidxMapping:this.mainPlaylistLoader_.sidxMapping_,previousManifest:e})}catch(r){this.error=r,this.error.metadata={errorType:B.Error.StreamingDashManifestParserError,error:r},this.trigger("error")}e&&(n=VT(e,n,this.mainPlaylistLoader_.sidxMapping_)),this.mainPlaylistLoader_.main=n||e;const s=this.mainPlaylistLoader_.main.locations&&this.mainPlaylistLoader_.main.locations[0];if(s&&s!==this.mainPlaylistLoader_.srcUrl&&(this.mainPlaylistLoader_.srcUrl=s),(!e||n&&n.minimumUpdatePeriod!==e.minimumUpdatePeriod)&&this.updateMinimumUpdatePeriodTimeout_(),this.addEventStreamToMetadataTrack_(n),n){const{duration:r,endList:a}=n,l=[];n.playlists.forEach(g=>{l.push({id:g.id,bandwidth:g.attributes.BANDWIDTH,resolution:g.attributes.RESOLUTION,codecs:g.attributes.CODECS})});const c={duration:r,isLive:!a,renditions:l};t.parsedManifest=c,this.trigger({type:"manifestparsecomplete",metadata:t})}return!!n}updateMinimumUpdatePeriodTimeout_(){const e=this.mainPlaylistLoader_;e.createMupOnMedia_&&(e.off("loadedmetadata",e.createMupOnMedia_),e.createMupOnMedia_=null),e.minimumUpdatePeriodTimeout_&&(x.clearTimeout(e.minimumUpdatePeriodTimeout_),e.minimumUpdatePeriodTimeout_=null);let t=e.main&&e.main.minimumUpdatePeriod;if(t===0&&(e.media()?t=e.media().targetDuration*1e3:(e.createMupOnMedia_=e.updateMinimumUpdatePeriodTimeout_,e.one("loadedmetadata",e.createMupOnMedia_))),typeof t!="number"||t<=0){t<0&&this.logger_(`found invalid minimumUpdatePeriod of ${t}, not setting a timeout`);return}this.createMUPTimeout_(t)}createMUPTimeout_(e){const t=this.mainPlaylistLoader_;t.minimumUpdatePeriodTimeout_=x.setTimeout(()=>{t.minimumUpdatePeriodTimeout_=null,t.trigger("minimumUpdatePeriod"),t.createMUPTimeout_(e)},e)}refreshXml_(){this.requestMain_((e,t)=>{t&&(this.media_&&(this.media_=this.mainPlaylistLoader_.main.playlists[this.media_.id]),this.mainPlaylistLoader_.sidxMapping_=zT(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.sidxMapping_),this.addSidxSegments_(this.media(),this.state,n=>{this.refreshMedia_(this.media().id)}))})}refreshMedia_(e){if(!e)throw new Error("refreshMedia_ must take a media id");this.media_&&this.isMain_&&this.handleMain_();const t=this.mainPlaylistLoader_.main.playlists,n=!this.media_||this.media_!==t[e];if(n?this.media_=t[e]:this.trigger("playlistunchanged"),!this.mediaUpdateTimeout){const s=()=>{this.media().endList||(this.mediaUpdateTimeout=x.setTimeout(()=>{this.trigger("mediaupdatetimeout"),s()},ho(this.media(),!!n)))};s()}this.trigger("loadedplaylist")}addEventStreamToMetadataTrack_(e){if(e&&this.mainPlaylistLoader_.main.eventStream){const t=this.mainPlaylistLoader_.main.eventStream.map(n=>({cueTime:n.start,frames:[{data:n.messageData}]}));this.addMetadataToTextTrack("EventStream",t,this.mainPlaylistLoader_.main.duration)}}getKeyIdSet(e){if(e.contentProtection){const t=new Set;for(const n in e.contentProtection){const s=e.contentProtection[n].attributes["cenc:default_KID"];s&&t.add(s.replace(/-/g,"").toLowerCase())}return t}}}var We={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,BACK_BUFFER_LENGTH:30,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:16,BUFFER_LOW_WATER_LINE_RATE:1,BUFFER_HIGH_WATER_LINE:30};const WT=i=>{const e=new Uint8Array(new ArrayBuffer(i.length));for(let t=0;t<i.length;t++)e[t]=i.charCodeAt(t);return e.buffer},gp=function(i){return i.on=i.addEventListener,i.off=i.removeEventListener,i},GT=function(i){try{return URL.createObjectURL(new Blob([i],{type:"application/javascript"}))}catch{const e=new BlobBuilder;return e.append(i),URL.createObjectURL(e.getBlob())}},mp=function(i){return function(){const e=GT(i),t=gp(new Worker(e));t.objURL=e;const n=t.terminate;return t.on=t.addEventListener,t.off=t.removeEventListener,t.terminate=function(){return URL.revokeObjectURL(e),n.call(this)},t}},yp=function(i){return`var browserWorkerPolyFill = ${gp.toString()};
|
|
189
|
+
`}return e}const Xt=1/30,Kt=Xt*3,qc=function(i,e){const t=[];let n;if(i&&i.length)for(n=0;n<i.length;n++)e(i.start(n),i.end(n))&&t.push([i.start(n),i.end(n)]);return tt(t)},tn=function(i,e){return qc(i,function(t,n){return t-Kt<=e&&n+Kt>=e})},er=function(i,e){return qc(i,function(t){return t-Xt>=e})},Gb=function(i){if(i.length<2)return tt();const e=[];for(let t=1;t<i.length;t++){const n=i.end(t-1),s=i.start(t);e.push([n,s])}return tt(e)},Xb=function(i,e){let t=null,n=null,s=0;const r=[],a=[];if(!i||!i.length||!e||!e.length)return tt();let l=i.length;for(;l--;)r.push({time:i.start(l),type:"start"}),r.push({time:i.end(l),type:"end"});for(l=e.length;l--;)r.push({time:e.start(l),type:"start"}),r.push({time:e.end(l),type:"end"});for(r.sort(function(c,f){return c.time-f.time}),l=0;l<r.length;l++)r[l].type==="start"?(s++,s===2&&(t=r[l].time)):r[l].type==="end"&&(s--,s===1&&(n=r[l].time)),t!==null&&n!==null&&(a.push([t,n]),t=null,n=null);return tt(a)},Vc=i=>{const e=[];if(!i||!i.length)return"";for(let t=0;t<i.length;t++)e.push(i.start(t)+" => "+i.end(t));return e.join(", ")},Kb=function(i,e,t=1){return((i.length?i.end(i.length-1):0)-e)/t},Ui=i=>{const e=[];for(let t=0;t<i.length;t++)e.push({start:i.start(t),end:i.end(t)});return e},Yb=function(i,e){if(i===e)return!1;if(!i&&e||!e&&i||i.length!==e.length)return!0;for(let t=0;t<i.length;t++)if(i.start(t)!==e.start(t)||i.end(t)!==e.end(t))return!0;return!1},qa=function(i){if(!(!i||!i.length||!i.end))return i.end(i.length-1)},ll=function(i,e){let t=0;if(!i||!i.length)return t;for(let n=0;n<i.length;n++){const s=i.start(n),r=i.end(n);if(!(e>r)){if(e>s&&e<=r){t+=r-e;continue}t+=r-s}}return t},ul=(i,e)=>{if(!e.preload)return e.duration;let t=0;return(e.parts||[]).forEach(function(n){t+=n.duration}),(e.preloadHints||[]).forEach(function(n){n.type==="PART"&&(t+=i.partTargetDuration)}),t},ao=i=>(i.segments||[]).reduce((e,t,n)=>(t.parts?t.parts.forEach(function(s,r){e.push({duration:s.duration,segmentIndex:n,partIndex:r,part:s,segment:t})}):e.push({duration:t.duration,segmentIndex:n,partIndex:null,segment:t,part:null}),e),[]),Hc=i=>{const e=i.segments&&i.segments.length&&i.segments[i.segments.length-1];return e&&e.parts||[]},zc=({preloadSegment:i})=>{if(!i)return;const{parts:e,preloadHints:t}=i;let n=(t||[]).reduce((s,r)=>s+(r.type==="PART"?1:0),0);return n+=e&&e.length?e.length:0,n},Wc=(i,e)=>{if(e.endList)return 0;if(i&&i.suggestedPresentationDelay)return i.suggestedPresentationDelay;const t=Hc(e).length>0;return t&&e.serverControl&&e.serverControl.partHoldBack?e.serverControl.partHoldBack:t&&e.partTargetDuration?e.partTargetDuration*3:e.serverControl&&e.serverControl.holdBack?e.serverControl.holdBack:e.targetDuration?e.targetDuration*3:0},Qb=function(i,e){let t=0,n=e-i.mediaSequence,s=i.segments[n];if(s){if(typeof s.start<"u")return{result:s.start,precise:!0};if(typeof s.end<"u")return{result:s.end-s.duration,precise:!0}}for(;n--;){if(s=i.segments[n],typeof s.end<"u")return{result:t+s.end,precise:!0};if(t+=ul(i,s),typeof s.start<"u")return{result:t+s.start,precise:!0}}return{result:t,precise:!1}},Jb=function(i,e){let t=0,n,s=e-i.mediaSequence;for(;s<i.segments.length;s++){if(n=i.segments[s],typeof n.start<"u")return{result:n.start-t,precise:!0};if(t+=ul(i,n),typeof n.end<"u")return{result:n.end-t,precise:!0}}return{result:-1,precise:!1}},Gc=function(i,e,t){if(typeof e>"u"&&(e=i.mediaSequence+i.segments.length),e<i.mediaSequence)return 0;const n=Qb(i,e);if(n.precise)return n.result;const s=Jb(i,e);return s.precise?s.result:n.result+t},Xc=function(i,e,t){if(!i)return 0;if(typeof t!="number"&&(t=0),typeof e>"u"){if(i.totalDuration)return i.totalDuration;if(!i.endList)return x.Infinity}return Gc(i,e,t)},ds=function({defaultDuration:i,durationList:e,startIndex:t,endIndex:n}){let s=0;if(t>n&&([t,n]=[n,t]),t<0){for(let r=t;r<Math.min(0,n);r++)s+=i;t=0}for(let r=t;r<n;r++)s+=e[r].duration;return s},Kc=function(i,e,t,n){if(!i||!i.segments)return null;if(i.endList)return Xc(i);if(e===null)return null;e=e||0;let s=Gc(i,i.mediaSequence+i.segments.length,e);return t&&(n=typeof n=="number"?n:Wc(null,i),s-=n),Math.max(0,s)},Zb=function(i,e,t){const n=e||0;let s=Kc(i,e,!0,t);return s===null?tt():(s<n&&(s=n),tt(n,s))},eT=function({playlist:i,currentTime:e,startingSegmentIndex:t,startingPartIndex:n,startTime:s,exactManifestTimings:r}){let a=e-s;const l=ao(i);let c=0;for(let f=0;f<l.length;f++){const m=l[f];if(t===m.segmentIndex&&!(typeof n=="number"&&typeof m.partIndex=="number"&&n!==m.partIndex)){c=f;break}}if(a<0){if(c>0)for(let f=c-1;f>=0;f--){const m=l[f];if(a+=m.duration,r){if(a<0)continue}else if(a+Xt<=0)continue;return{partIndex:m.partIndex,segmentIndex:m.segmentIndex,startTime:s-ds({defaultDuration:i.targetDuration,durationList:l,startIndex:c,endIndex:f})}}return{partIndex:l[0]&&l[0].partIndex||null,segmentIndex:l[0]&&l[0].segmentIndex||0,startTime:e}}if(c<0){for(let f=c;f<0;f++)if(a-=i.targetDuration,a<0)return{partIndex:l[0]&&l[0].partIndex||null,segmentIndex:l[0]&&l[0].segmentIndex||0,startTime:e};c=0}for(let f=c;f<l.length;f++){const m=l[f];a-=m.duration;const b=m.duration>Xt,C=a===0,w=b&&a+Xt>=0;if(!((C||w)&&f!==l.length-1)){if(r){if(a>0)continue}else if(a-Xt>=0)continue;return{partIndex:m.partIndex,segmentIndex:m.segmentIndex,startTime:s+ds({defaultDuration:i.targetDuration,durationList:l,startIndex:c,endIndex:f})}}}return{segmentIndex:l[l.length-1].segmentIndex,partIndex:l[l.length-1].partIndex,startTime:e}},Yc=function(i){return i.excludeUntil&&i.excludeUntil>Date.now()},dl=function(i){return i.excludeUntil&&i.excludeUntil===1/0},ta=function(i){const e=Yc(i);return!i.disabled&&!e},tT=function(i){return i.disabled},iT=function(i){for(let e=0;e<i.segments.length;e++)if(i.segments[e].key)return!0;return!1},Qc=function(i,e){return e.attributes&&e.attributes[i]},nT=function(i,e,t,n=0){return Qc("BANDWIDTH",t)?(i*t.attributes.BANDWIDTH-n*8)/e:NaN},oo=(i,e)=>{if(i.playlists.length===1)return!0;const t=e.attributes.BANDWIDTH||Number.MAX_VALUE;return i.playlists.filter(n=>ta(n)?(n.attributes.BANDWIDTH||0)<t:!1).length===0},hl=(i,e)=>!i&&!e||!i&&e||i&&!e?!1:!!(i===e||i.id&&e.id&&i.id===e.id||i.resolvedUri&&e.resolvedUri&&i.resolvedUri===e.resolvedUri||i.uri&&e.uri&&i.uri===e.uri),ad=function(i,e){const t=i&&i.mediaGroups&&i.mediaGroups.AUDIO||{};let n=!1;for(const s in t){for(const r in t[s])if(n=e(t[s][r]),n)break;if(n)break}return!!n},Ss=i=>{if(!i||!i.playlists||!i.playlists.length)return ad(i,e=>e.playlists&&e.playlists.length||e.uri);for(let e=0;e<i.playlists.length;e++){const t=i.playlists[e],n=t.attributes&&t.attributes.CODECS;if(!(n&&n.split(",").every(s=>oh(s))||ad(i,s=>hl(t,s))))return!1}return!0};var gt={liveEdgeDelay:Wc,duration:Xc,seekable:Zb,getMediaInfoForTime:eT,isEnabled:ta,isDisabled:tT,isExcluded:Yc,isIncompatible:dl,playlistEnd:Kc,isAes:iT,hasAttribute:Qc,estimateSegmentRequestTime:nT,isLowestEnabledRendition:oo,isAudioOnly:Ss,playlistMatch:hl,segmentDurationWithParts:ul};const{log:Jc}=B,ln=(i,e)=>`${i}-${e}`,Zc=(i,e,t)=>`placeholder-uri-${i}-${e}-${t}`,sT=({onwarn:i,oninfo:e,manifestString:t,customTagParsers:n=[],customTagMappers:s=[],llhls:r})=>{const a=new X_;i&&a.on("warn",i),e&&a.on("info",e),n.forEach(f=>a.addParser(f)),s.forEach(f=>a.addTagMapper(f)),a.push(t),a.end();const l=a.manifest;if(r||(["preloadSegment","skip","serverControl","renditionReports","partInf","partTargetDuration"].forEach(function(f){l.hasOwnProperty(f)&&delete l[f]}),l.segments&&l.segments.forEach(function(f){["parts","preloadHints"].forEach(function(m){f.hasOwnProperty(m)&&delete f[m]})})),!l.targetDuration){let f=10;l.segments&&l.segments.length&&(f=l.segments.reduce((m,b)=>Math.max(m,b.duration),0)),i&&i({message:`manifest has no targetDuration defaulting to ${f}`}),l.targetDuration=f}const c=Hc(l);if(c.length&&!l.partTargetDuration){const f=c.reduce((m,b)=>Math.max(m,b.duration),0);i&&(i({message:`manifest has no partTargetDuration defaulting to ${f}`}),Jc.error("LL-HLS manifest has parts but lacks required #EXT-X-PART-INF:PART-TARGET value. See https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis-09#section-4.4.3.7. Playback is not guaranteed.")),l.partTargetDuration=f}return l},An=(i,e)=>{i.mediaGroups&&["AUDIO","SUBTITLES"].forEach(t=>{if(i.mediaGroups[t])for(const n in i.mediaGroups[t])for(const s in i.mediaGroups[t][n]){const r=i.mediaGroups[t][n][s];e(r,t,n,s)}})},ep=({playlist:i,uri:e,id:t})=>{i.id=t,i.playlistErrors_=0,e&&(i.uri=e),i.attributes=i.attributes||{}},rT=i=>{let e=i.playlists.length;for(;e--;){const t=i.playlists[e];ep({playlist:t,id:ln(e,t.uri)}),t.resolvedUri=pt(i.uri,t.uri),i.playlists[t.id]=t,i.playlists[t.uri]=t,t.attributes.BANDWIDTH||Jc.warn("Invalid playlist STREAM-INF detected. Missing BANDWIDTH attribute.")}},aT=i=>{An(i,e=>{e.uri&&(e.resolvedUri=pt(i.uri,e.uri))})},oT=(i,e)=>{const t=ln(0,e),n={mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:x.location.href,resolvedUri:x.location.href,playlists:[{uri:e,id:t,resolvedUri:e,attributes:{}}]};return n.playlists[t]=n.playlists[0],n.playlists[e]=n.playlists[0],n},tp=(i,e,t=Zc)=>{i.uri=e;for(let s=0;s<i.playlists.length;s++)if(!i.playlists[s].uri){const r=`placeholder-uri-${s}`;i.playlists[s].uri=r}const n=Ss(i);An(i,(s,r,a,l)=>{if(!s.playlists||!s.playlists.length){if(n&&r==="AUDIO"&&!s.uri)for(let c=0;c<i.playlists.length;c++){const f=i.playlists[c];if(f.attributes&&f.attributes.AUDIO&&f.attributes.AUDIO===a)return}s.playlists=[je({},s)]}s.playlists.forEach(function(c,f){const m=t(r,a,l,c),b=ln(f,m);c.uri?c.resolvedUri=c.resolvedUri||pt(i.uri,c.uri):(c.uri=f===0?m:b,c.resolvedUri=c.uri),c.id=c.id||b,c.attributes=c.attributes||{},i.playlists[c.id]=c,i.playlists[c.uri]=c})}),rT(i),aT(i)};class od{constructor(){this.offset_=null,this.pendingDateRanges_=new Map,this.processedDateRanges_=new Map}setOffset(e=[]){if(this.offset_!==null||!e.length)return;const[t]=e;t.programDateTime!==void 0&&(this.offset_=t.programDateTime/1e3)}setPendingDateRanges(e=[]){if(!e.length)return;const[t]=e,n=t.startDate.getTime();this.trimProcessedDateRanges_(n),this.pendingDateRanges_=e.reduce((s,r)=>(s.set(r.id,r),s),new Map)}processDateRange(e){this.pendingDateRanges_.delete(e.id),this.processedDateRanges_.set(e.id,e)}getDateRangesToProcess(){if(this.offset_===null)return[];const e={},t=[];this.pendingDateRanges_.forEach((n,s)=>{if(!this.processedDateRanges_.has(s)&&(n.startTime=n.startDate.getTime()/1e3-this.offset_,n.processDateRange=()=>this.processDateRange(n),t.push(n),!!n.class))if(e[n.class]){const r=e[n.class].push(n);n.classListIndex=r-1}else e[n.class]=[n],n.classListIndex=0});for(const n of t){const s=e[n.class]||[];n.endDate?n.endTime=n.endDate.getTime()/1e3-this.offset_:n.endOnNext&&s[n.classListIndex+1]?n.endTime=s[n.classListIndex+1].startTime:n.duration?n.endTime=n.startTime+n.duration:n.plannedDuration?n.endTime=n.startTime+n.plannedDuration:n.endTime=n.startTime}return t}trimProcessedDateRanges_(e){new Map(this.processedDateRanges_).forEach((t,n)=>{t.startDate.getTime()<e&&this.processedDateRanges_.delete(n)})}}const ip=22,$i=({requestType:i,request:e,error:t,parseFailure:n})=>{const s=e.status<200||e.status>299,r=e.status>=400&&e.status<=499,a={uri:e.uri,requestType:i},l=s&&!r||n;if(t&&r)a.error=je({},t),a.errorType=B.Error.NetworkRequestFailed;else if(e.aborted)a.errorType=B.Error.NetworkRequestAborted;else if(e.timedout)a.erroType=B.Error.NetworkRequestTimeout;else if(l){const c=n?B.Error.NetworkBodyParserFailed:B.Error.NetworkBadStatus;a.errorType=c,a.status=e.status,a.headers=e.headers}return a},{EventTarget:lT}=B,uT=(i,e)=>{if(e.endList||!e.serverControl)return i;const t={};if(e.serverControl.canBlockReload){const{preloadSegment:n}=e;let s=e.mediaSequence+e.segments.length;if(n){const r=n.parts||[],a=zc(e)-1;a>-1&&a!==r.length-1&&(t._HLS_part=a),(a>-1||r.length)&&s--}t._HLS_msn=s}if(e.serverControl&&e.serverControl.canSkipUntil&&(t._HLS_skip=e.serverControl.canSkipDateranges?"v2":"YES"),Object.keys(t).length){const n=new x.URL(i);["_HLS_skip","_HLS_msn","_HLS_part"].forEach(function(s){t.hasOwnProperty(s)&&n.searchParams.set(s,t[s])}),i=n.toString()}return i},dT=(i,e)=>{if(!i)return e;const t=fe(i,e);if(i.preloadHints&&!e.preloadHints&&delete t.preloadHints,i.parts&&!e.parts)delete t.parts;else if(i.parts&&e.parts)for(let n=0;n<e.parts.length;n++)i.parts&&i.parts[n]&&(t.parts[n]=fe(i.parts[n],e.parts[n]));return!i.skipped&&e.skipped&&(t.skipped=!1),i.preload&&!e.preload&&(t.preload=!1),t},hT=(i,e,t)=>{const n=i.slice(),s=e.slice();t=t||0;const r=[];let a;for(let l=0;l<s.length;l++){const c=n[l+t],f=s[l];c?(a=c.map||a,r.push(dT(c,f))):(a&&!f.map&&(f.map=a),r.push(f))}return r},np=(i,e)=>{!i.resolvedUri&&i.uri&&(i.resolvedUri=pt(e,i.uri)),i.key&&!i.key.resolvedUri&&(i.key.resolvedUri=pt(e,i.key.uri)),i.map&&!i.map.resolvedUri&&(i.map.resolvedUri=pt(e,i.map.uri)),i.map&&i.map.key&&!i.map.key.resolvedUri&&(i.map.key.resolvedUri=pt(e,i.map.key.uri)),i.parts&&i.parts.length&&i.parts.forEach(t=>{t.resolvedUri||(t.resolvedUri=pt(e,t.uri))}),i.preloadHints&&i.preloadHints.length&&i.preloadHints.forEach(t=>{t.resolvedUri||(t.resolvedUri=pt(e,t.uri))})},sp=function(i){const e=i.segments||[],t=i.preloadSegment;if(t&&t.parts&&t.parts.length){if(t.preloadHints){for(let n=0;n<t.preloadHints.length;n++)if(t.preloadHints[n].type==="MAP")return e}t.duration=i.targetDuration,t.preload=!0,e.push(t)}return e},rp=(i,e)=>i===e||i.segments&&e.segments&&i.segments.length===e.segments.length&&i.endList===e.endList&&i.mediaSequence===e.mediaSequence&&i.preloadSegment===e.preloadSegment,lo=(i,e,t=rp)=>{const n=fe(i,{}),s=n.playlists[e.id];if(!s||t(s,e))return null;e.segments=sp(e);const r=fe(s,e);if(r.preloadSegment&&!e.preloadSegment&&delete r.preloadSegment,s.segments){if(e.skip){e.segments=e.segments||[];for(let a=0;a<e.skip.skippedSegments;a++)e.segments.unshift({skipped:!0})}r.segments=hT(s.segments,e.segments,e.mediaSequence-s.mediaSequence)}r.segments.forEach(a=>{np(a,r.resolvedUri)});for(let a=0;a<n.playlists.length;a++)n.playlists[a].id===e.id&&(n.playlists[a]=r);return n.playlists[e.id]=r,n.playlists[e.uri]=r,An(i,(a,l,c,f)=>{if(a.playlists)for(let m=0;m<a.playlists.length;m++)e.id===a.playlists[m].id&&(a.playlists[m]=r)}),n},uo=(i,e)=>{const t=i.segments||[],n=t[t.length-1],s=n&&n.parts&&n.parts[n.parts.length-1],r=s&&s.duration||n&&n.duration;return e&&r?r*1e3:(i.partTargetDuration||i.targetDuration||10)*500},ld=(i,e,t)=>{if(!i)return;const n=[];return i.forEach(s=>{if(!s.attributes)return;const{BANDWIDTH:r,RESOLUTION:a,CODECS:l}=s.attributes;n.push({id:s.id,bandwidth:r,resolution:a,codecs:l})}),{type:e,isLive:t,renditions:n}};class nn extends lT{constructor(e,t,n={}){if(super(),!e)throw new Error("A non-empty playlist URL or object is required");this.logger_=Lt("PlaylistLoader");const{withCredentials:s=!1}=n;this.src=e,this.vhs_=t,this.withCredentials=s,this.addDateRangesToTextTrack_=n.addDateRangesToTextTrack;const r=t.options_;this.customTagParsers=r&&r.customTagParsers||[],this.customTagMappers=r&&r.customTagMappers||[],this.llhls=r&&r.llhls,this.dateRangesStorage_=new od,this.state="HAVE_NOTHING",this.handleMediaupdatetimeout_=this.handleMediaupdatetimeout_.bind(this),this.on("mediaupdatetimeout",this.handleMediaupdatetimeout_),this.on("loadedplaylist",this.handleLoadedPlaylist_.bind(this))}handleLoadedPlaylist_(){const e=this.media();if(!e)return;this.dateRangesStorage_.setOffset(e.segments),this.dateRangesStorage_.setPendingDateRanges(e.dateRanges);const t=this.dateRangesStorage_.getDateRangesToProcess();!t.length||!this.addDateRangesToTextTrack_||this.addDateRangesToTextTrack_(t)}handleMediaupdatetimeout_(){if(this.state!=="HAVE_METADATA")return;const e=this.media();let t=pt(this.main.uri,e.uri);this.llhls&&(t=uT(t,e)),this.state="HAVE_CURRENT_METADATA",this.request=this.vhs_.xhr({uri:t,withCredentials:this.withCredentials,requestType:"hls-playlist"},(n,s)=>{if(this.request){if(n)return this.playlistRequestError(this.request,this.media(),"HAVE_METADATA");this.haveMetadata({playlistString:this.request.responseText,url:this.media().uri,id:this.media().id})}})}playlistRequestError(e,t,n){const{uri:s,id:r}=t;this.request=null,n&&(this.state=n),this.error={playlist:this.main.playlists[r],status:e.status,message:`HLS playlist request error at URL: ${s}.`,responseText:e.responseText,code:e.status>=500?4:2,metadata:$i({requestType:e.requestType,request:e,error:e.error})},this.trigger("error")}parseManifest_({url:e,manifestString:t}){try{return sT({onwarn:({message:n})=>this.logger_(`m3u8-parser warn for ${e}: ${n}`),oninfo:({message:n})=>this.logger_(`m3u8-parser info for ${e}: ${n}`),manifestString:t,customTagParsers:this.customTagParsers,customTagMappers:this.customTagMappers,llhls:this.llhls})}catch(n){this.error=n,this.error.metadata={errorType:B.Error.StreamingHlsPlaylistParserError,error:n}}}haveMetadata({playlistString:e,playlistObject:t,url:n,id:s}){this.request=null,this.state="HAVE_METADATA";const r={playlistInfo:{type:"media",uri:n}};this.trigger({type:"playlistparsestart",metadata:r});const a=t||this.parseManifest_({url:n,manifestString:e});a.lastRequest=Date.now(),ep({playlist:a,uri:n,id:s});const l=lo(this.main,a);this.targetDuration=a.partTargetDuration||a.targetDuration,this.pendingMedia_=null,l?(this.main=l,this.media_=this.main.playlists[s]):this.trigger("playlistunchanged"),this.updateMediaUpdateTimeout_(uo(this.media(),!!l)),r.parsedPlaylist=ld(this.main.playlists,r.playlistInfo.type,!this.media_.endList),this.trigger({type:"playlistparsecomplete",metadata:r}),this.trigger("loadedplaylist")}dispose(){this.trigger("dispose"),this.stopRequest(),x.clearTimeout(this.mediaUpdateTimeout),x.clearTimeout(this.finalRenditionTimeout),this.dateRangesStorage_=new od,this.off()}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e,t){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);if(typeof e=="string"){if(!this.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.main.playlists[e]}if(x.clearTimeout(this.finalRenditionTimeout),t){const l=(e.partTargetDuration||e.targetDuration)/2*1e3||5e3;this.finalRenditionTimeout=x.setTimeout(this.media.bind(this,e,!1),l);return}const n=this.state,s=!this.media_||e.id!==this.media_.id,r=this.main.playlists[e.id];if(r&&r.endList||e.endList&&e.segments.length){this.request&&(this.request.onreadystatechange=null,this.request.abort(),this.request=null),this.state="HAVE_METADATA",this.media_=e,s&&(this.trigger("mediachanging"),n==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange"));return}if(this.updateMediaUpdateTimeout_(uo(e,!0)),!s)return;if(this.state="SWITCHING_MEDIA",this.request){if(e.resolvedUri===this.request.url)return;this.request.onreadystatechange=null,this.request.abort(),this.request=null}this.media_&&this.trigger("mediachanging"),this.pendingMedia_=e;const a={playlistInfo:{type:"media",uri:e.uri}};this.trigger({type:"playlistrequeststart",metadata:a}),this.request=this.vhs_.xhr({uri:e.resolvedUri,withCredentials:this.withCredentials,requestType:"hls-playlist"},(l,c)=>{if(this.request){if(e.lastRequest=Date.now(),e.resolvedUri=kr(e.resolvedUri,c),l)return this.playlistRequestError(this.request,e,n);this.trigger({type:"playlistrequestcomplete",metadata:a}),this.haveMetadata({playlistString:c.responseText,url:e.uri,id:e.id}),n==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange")}})}pause(){this.mediaUpdateTimeout&&(x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),this.stopRequest(),this.state==="HAVE_NOTHING"&&(this.started=!1),this.state==="SWITCHING_MEDIA"?this.media_?this.state="HAVE_METADATA":this.state="HAVE_MAIN_MANIFEST":this.state==="HAVE_CURRENT_METADATA"&&(this.state="HAVE_METADATA")}load(e){this.mediaUpdateTimeout&&(x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null);const t=this.media();if(e){const n=t?(t.partTargetDuration||t.targetDuration)/2*1e3:5e3;this.mediaUpdateTimeout=x.setTimeout(()=>{this.mediaUpdateTimeout=null,this.load()},n);return}if(!this.started){this.start();return}t&&!t.endList?this.trigger("mediaupdatetimeout"):this.trigger("loadedplaylist")}updateMediaUpdateTimeout_(e){this.mediaUpdateTimeout&&(x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null),!(!this.media()||this.media().endList)&&(this.mediaUpdateTimeout=x.setTimeout(()=>{this.mediaUpdateTimeout=null,this.trigger("mediaupdatetimeout"),this.updateMediaUpdateTimeout_(e)},e))}start(){if(this.started=!0,typeof this.src=="object"){this.src.uri||(this.src.uri=x.location.href),this.src.resolvedUri=this.src.uri,setTimeout(()=>{this.setupInitialPlaylist(this.src)},0);return}const e={playlistInfo:{type:"multivariant",uri:this.src}};this.trigger({type:"playlistrequeststart",metadata:e}),this.request=this.vhs_.xhr({uri:this.src,withCredentials:this.withCredentials,requestType:"hls-playlist"},(t,n)=>{if(!this.request)return;if(this.request=null,t)return this.error={status:n.status,message:`HLS playlist request error at URL: ${this.src}.`,responseText:n.responseText,code:2,metadata:$i({requestType:n.requestType,request:n,error:t})},this.state==="HAVE_NOTHING"&&(this.started=!1),this.trigger("error");this.trigger({type:"playlistrequestcomplete",metadata:e}),this.src=kr(this.src,n),this.trigger({type:"playlistparsestart",metadata:e});const s=this.parseManifest_({manifestString:n.responseText,url:this.src});e.parsedPlaylist=ld(s.playlists,e.playlistInfo.type,!1),this.trigger({type:"playlistparsecomplete",metadata:e}),this.setupInitialPlaylist(s)})}srcUri(){return typeof this.src=="string"?this.src:this.src.uri}setupInitialPlaylist(e){if(this.state="HAVE_MAIN_MANIFEST",e.playlists){this.main=e,tp(this.main,this.srcUri()),e.playlists.forEach(n=>{n.segments=sp(n),n.segments.forEach(s=>{np(s,n.resolvedUri)})}),this.trigger("loadedplaylist"),this.request||this.media(this.main.playlists[0]);return}const t=this.srcUri()||x.location.href;this.main=oT(e,t),this.haveMetadata({playlistObject:e,url:t,id:this.main.playlists[0].id}),this.trigger("loadedmetadata")}updateOrDeleteClone(e,t){const n=this.main,s=e.ID;let r=n.playlists.length;for(;r--;){const a=n.playlists[r];if(a.attributes["PATHWAY-ID"]===s){const l=a.resolvedUri,c=a.id;if(t){const f=this.createCloneURI_(a.resolvedUri,e),m=ln(s,f),b=this.createCloneAttributes_(s,a.attributes),C=this.createClonePlaylist_(a,m,e,b);n.playlists[r]=C,n.playlists[m]=C,n.playlists[f]=C}else n.playlists.splice(r,1);delete n.playlists[c],delete n.playlists[l]}}this.updateOrDeleteCloneMedia(e,t)}updateOrDeleteCloneMedia(e,t){const n=this.main,s=e.ID;["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(r=>{if(!(!n.mediaGroups[r]||!n.mediaGroups[r][s])){for(const a in n.mediaGroups[r])if(a===s){for(const l in n.mediaGroups[r][a])n.mediaGroups[r][a][l].playlists.forEach((c,f)=>{const m=n.playlists[c.id],b=m.id,C=m.resolvedUri;delete n.playlists[b],delete n.playlists[C]});delete n.mediaGroups[r][a]}}}),t&&this.createClonedMediaGroups_(e)}addClonePathway(e,t={}){const n=this.main,s=n.playlists.length,r=this.createCloneURI_(t.resolvedUri,e),a=ln(e.ID,r),l=this.createCloneAttributes_(e.ID,t.attributes),c=this.createClonePlaylist_(t,a,e,l);n.playlists[s]=c,n.playlists[a]=c,n.playlists[r]=c,this.createClonedMediaGroups_(e)}createClonedMediaGroups_(e){const t=e.ID,n=e["BASE-ID"],s=this.main;["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(r=>{if(!(!s.mediaGroups[r]||s.mediaGroups[r][t]))for(const a in s.mediaGroups[r]){if(a===n)s.mediaGroups[r][t]={};else continue;for(const l in s.mediaGroups[r][a]){const c=s.mediaGroups[r][a][l];s.mediaGroups[r][t][l]=je({},c);const f=s.mediaGroups[r][t][l],m=this.createCloneURI_(c.resolvedUri,e);f.resolvedUri=m,f.uri=m,f.playlists=[],c.playlists.forEach((b,C)=>{const w=s.playlists[b.id],A=Zc(r,t,l),v=ln(t,A);if(w&&!s.playlists[v]){const M=this.createClonePlaylist_(w,v,e),D=M.resolvedUri;s.playlists[v]=M,s.playlists[D]=M}f.playlists[C]=this.createClonePlaylist_(b,v,e)})}}})}createClonePlaylist_(e,t,n,s){const r=this.createCloneURI_(e.resolvedUri,n),a={resolvedUri:r,uri:r,id:t};return e.segments&&(a.segments=[]),s&&(a.attributes=s),fe(e,a)}createCloneURI_(e,t){const n=new URL(e);n.hostname=t["URI-REPLACEMENT"].HOST;const s=t["URI-REPLACEMENT"].PARAMS;for(const r of Object.keys(s))n.searchParams.set(r,s[r]);return n.href}createCloneAttributes_(e,t){const n={"PATHWAY-ID":e};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(s=>{t[s]&&(n[s]=e)}),n}getKeyIdSet(e){if(e.contentProtection){const t=new Set;for(const n in e.contentProtection){const s=e.contentProtection[n].attributes.keyId;s&&t.add(s.toLowerCase())}return t}}}const ho=function(i,e,t,n){const s=i.responseType==="arraybuffer"?i.response:i.responseText;!e&&s&&(i.responseTime=Date.now(),i.roundTripTime=i.responseTime-i.requestTime,i.bytesReceived=s.byteLength||s.length,i.bandwidth||(i.bandwidth=Math.floor(i.bytesReceived/i.roundTripTime*8*1e3))),t.headers&&(i.responseHeaders=t.headers),e&&e.code==="ETIMEDOUT"&&(i.timedout=!0),!e&&!i.aborted&&t.statusCode!==200&&t.statusCode!==206&&t.statusCode!==0&&(e=new Error("XHR Failed with a response of: "+(i&&(s||i.responseText)))),n(e,i)},cT=(i,e)=>{if(!i||!i.size)return;let t=e;return i.forEach(n=>{t=n(t)}),t},pT=(i,e,t,n)=>{!i||!i.size||i.forEach(s=>{s(e,t,n)})},ap=function(){const i=function e(t,n){t=fe({timeout:45e3},t);const s=e.beforeRequest||B.Vhs.xhr.beforeRequest,r=e._requestCallbackSet||B.Vhs.xhr._requestCallbackSet||new Set,a=e._responseCallbackSet||B.Vhs.xhr._responseCallbackSet;s&&typeof s=="function"&&(B.log.warn("beforeRequest is deprecated, use onRequest instead."),r.add(s));const l=B.Vhs.xhr.original===!0?B.xhr:B.Vhs.xhr,c=cT(r,t);r.delete(s);const f=l(c||t,function(b,C){return pT(a,f,b,C),ho(f,b,C,n)}),m=f.abort;return f.abort=function(){return f.aborted=!0,m.apply(f,arguments)},f.uri=t.uri,f.requestType=t.requestType,f.requestTime=Date.now(),f};return i.original=!0,i},gT=function(i){let e;const t=i.offset;return typeof i.offset=="bigint"||typeof i.length=="bigint"?e=x.BigInt(i.offset)+x.BigInt(i.length)-x.BigInt(1):e=i.offset+i.length-1,"bytes="+t+"-"+e},co=function(i){const e={};return i.byterange&&(e.Range=gT(i.byterange)),e},fT=function(i,e){return i.start(e)+"-"+i.end(e)},mT=function(i,e){const t=i.toString(16);return"00".substring(0,2-t.length)+t+(e%2?" ":"")},yT=function(i){return i>=32&&i<126?String.fromCharCode(i):"."},op=function(i){const e={};return Object.keys(i).forEach(t=>{const n=i[t];uh(n)?e[t]={bytes:n.buffer,byteOffset:n.byteOffset,byteLength:n.byteLength}:e[t]=n}),e},Cr=function(i){const e=i.byterange||{length:1/0,offset:0};return[e.length,e.offset,i.resolvedUri].join(",")},lp=function(i){return i.resolvedUri},up=i=>{const e=Array.prototype.slice.call(i),t=16;let n="",s,r;for(let a=0;a<e.length/t;a++)s=e.slice(a*t,a*t+t).map(mT).join(""),r=e.slice(a*t,a*t+t).map(yT).join(""),n+=s+" "+r+`
|
|
190
|
+
`;return n},_T=({bytes:i})=>up(i),bT=i=>{let e="",t;for(t=0;t<i.length;t++)e+=fT(i,t)+" ";return e};var TT=Object.freeze({__proto__:null,createTransferableMessage:op,initSegmentId:Cr,segmentKeyId:lp,hexDump:up,tagDump:_T,textRanges:bT});const dp=.25,vT=(i,e)=>{if(!e.dateTimeObject)return null;const t=e.videoTimingInfo.transmuxerPrependedSeconds,n=e.videoTimingInfo.transmuxedPresentationStart+t,s=i-n;return new Date(e.dateTimeObject.getTime()+s*1e3)},ST=i=>i.transmuxedPresentationEnd-i.transmuxedPresentationStart-i.transmuxerPrependedSeconds,ET=(i,e)=>{let t;try{t=new Date(i)}catch{return null}if(!e||!e.segments||e.segments.length===0)return null;let n=e.segments[0];if(t<new Date(n.dateTimeObject))return null;for(let c=0;c<e.segments.length-1;c++){n=e.segments[c];const f=new Date(e.segments[c+1].dateTimeObject);if(t<f)break}const s=e.segments[e.segments.length-1],r=s.dateTimeObject,a=s.videoTimingInfo?ST(s.videoTimingInfo):s.duration+s.duration*dp,l=new Date(r.getTime()+a*1e3);return t>l?null:(t>new Date(r)&&(n=s),{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:gt.duration(e,e.mediaSequence+e.segments.indexOf(n)),type:n.videoTimingInfo?"accurate":"estimate"})},wT=(i,e)=>{if(!e||!e.segments||e.segments.length===0)return null;let t=0,n;for(let r=0;r<e.segments.length&&(n=e.segments[r],t=n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationEnd:t+n.duration,!(i<=t));r++);const s=e.segments[e.segments.length-1];if(s.videoTimingInfo&&s.videoTimingInfo.transmuxedPresentationEnd<i)return null;if(i>t){if(i>t+s.duration*dp)return null;n=s}return{segment:n,estimatedStart:n.videoTimingInfo?n.videoTimingInfo.transmuxedPresentationStart:t-n.duration,type:n.videoTimingInfo?"accurate":"estimate"}},kT=(i,e)=>{let t,n;try{t=new Date(i),n=new Date(e)}catch{}const s=t.getTime();return(n.getTime()-s)/1e3},CT=i=>{if(!i.segments||i.segments.length===0)return!1;for(let e=0;e<i.segments.length;e++)if(!i.segments[e].dateTimeObject)return!1;return!0},IT=({playlist:i,time:e=void 0,callback:t})=>{if(!t)throw new Error("getProgramTime: callback must be provided");if(!i||e===void 0)return t({message:"getProgramTime: playlist and time must be provided"});const n=wT(e,i);if(!n)return t({message:"valid programTime was not found"});if(n.type==="estimate")return t({message:"Accurate programTime could not be determined. Please seek to e.seekTime and try again",seekTime:n.estimatedStart});const s={mediaSeconds:e},r=vT(e,n.segment);return r&&(s.programDateTime=r.toISOString()),t(null,s)},hp=({programTime:i,playlist:e,retryCount:t=2,seekTo:n,pauseAfterSeek:s=!0,tech:r,callback:a})=>{if(!a)throw new Error("seekToProgramTime: callback must be provided");if(typeof i>"u"||!e||!n)return a({message:"seekToProgramTime: programTime, seekTo and playlist must be provided"});if(!e.endList&&!r.hasStarted_)return a({message:"player must be playing a live stream to start buffering"});if(!CT(e))return a({message:"programDateTime tags must be provided in the manifest "+e.resolvedUri});const l=ET(i,e);if(!l)return a({message:`${i} was not found in the stream`});const c=l.segment,f=kT(c.dateTimeObject,i);if(l.type==="estimate"){if(t===0)return a({message:`${i} is not buffered yet. Try again`});n(l.estimatedStart+f),r.one("seeked",()=>{hp({programTime:i,playlist:e,retryCount:t-1,seekTo:n,pauseAfterSeek:s,tech:r,callback:a})});return}const m=c.start+f,b=()=>a(null,r.currentTime());r.one("seeked",b),s&&r.pause(),n(m)},Va=(i,e)=>{if(i.readyState===4)return e()},xT=(i,e,t,n)=>{let s=[],r,a=!1;const l=function(m,b,C,w){return b.abort(),a=!0,t(m,b,C,w)},c=function(m,b){if(a)return;if(m)return m.metadata=$i({requestType:n,request:b,error:m}),l(m,b,"",s);const C=b.responseText.substring(s&&s.byteLength||0,b.responseText.length);if(s=a0(s,dh(C,!0)),r=r||is(s),s.length<10||r&&s.length<r+2)return Va(b,()=>l(m,b,"",s));const w=Do(s);return w==="ts"&&s.length<188?Va(b,()=>l(m,b,"",s)):!w&&s.length<376?Va(b,()=>l(m,b,"",s)):l(null,b,w,s)},f=e({uri:i,beforeSend(m){m.overrideMimeType("text/plain; charset=x-user-defined"),m.addEventListener("progress",function({total:b,loaded:C}){return ho(m,null,{statusCode:m.status},c)})}},function(m,b){return ho(f,m,b,c)});return f},{EventTarget:AT}=B,ud=function(i,e){if(!rp(i,e)||i.sidx&&e.sidx&&(i.sidx.offset!==e.sidx.offset||i.sidx.length!==e.sidx.length)||!i.sidx&&e.sidx||i.sidx&&!e.sidx||i.segments&&!e.segments||!i.segments&&e.segments)return!1;if(!i.segments&&!e.segments)return!0;for(let t=0;t<i.segments.length;t++){const n=i.segments[t],s=e.segments[t];if(n.uri!==s.uri)return!1;if(!n.byterange&&!s.byterange)continue;const r=n.byterange,a=s.byterange;if(r&&!a||!r&&a||r.offset!==a.offset||r.length!==a.length)return!1}return!0},PT=(i,e,t,n)=>{const s=n.attributes.NAME||t;return`placeholder-uri-${i}-${e}-${s}`},LT=({mainXml:i,srcUrl:e,clientOffset:t,sidxMapping:n,previousManifest:s})=>{const r=Z0(i,{manifestUri:e,clientOffset:t,sidxMapping:n,previousManifest:s});return tp(r,e,PT),r},DT=(i,e)=>{An(i,(t,n,s,r)=>{(!e.mediaGroups[n][s]||!(r in e.mediaGroups[n][s]))&&delete i.mediaGroups[n][s][r]})},OT=(i,e,t)=>{let n=!0,s=fe(i,{duration:e.duration,minimumUpdatePeriod:e.minimumUpdatePeriod,timelineStarts:e.timelineStarts});for(let r=0;r<e.playlists.length;r++){const a=e.playlists[r];if(a.sidx){const c=Ur(a.sidx);t&&t[c]&&t[c].sidx&&Ao(a,t[c].sidx,a.sidx.resolvedUri)}const l=lo(s,a,ud);l&&(s=l,n=!1)}return An(e,(r,a,l,c)=>{if(r.playlists&&r.playlists.length){const f=r.playlists[0].id,m=lo(s,r.playlists[0],ud);m&&(s=m,c in s.mediaGroups[a][l]||(s.mediaGroups[a][l][c]=r),s.mediaGroups[a][l][c].playlists[0]=s.playlists[f],n=!1)}}),DT(s,e),e.minimumUpdatePeriod!==i.minimumUpdatePeriod&&(n=!1),n?null:s},MT=(i,e)=>(!i.map&&!e.map||!!(i.map&&e.map&&i.map.byterange.offset===e.map.byterange.offset&&i.map.byterange.length===e.map.byterange.length))&&i.uri===e.uri&&i.byterange.offset===e.byterange.offset&&i.byterange.length===e.byterange.length,dd=(i,e)=>{const t={};for(const n in i){const s=i[n].sidx;if(s){const r=Ur(s);if(!e[r])break;const a=e[r].sidxInfo;MT(a,s)&&(t[r]=e[r])}}return t},RT=(i,e)=>{let t=dd(i.playlists,e);return An(i,(n,s,r,a)=>{if(n.playlists&&n.playlists.length){const l=n.playlists;t=fe(t,dd(l,e))}}),t};class po extends AT{constructor(e,t,n={},s){super(),this.isPaused_=!0,this.mainPlaylistLoader_=s||this,s||(this.isMain_=!0);const{withCredentials:r=!1}=n;if(this.vhs_=t,this.withCredentials=r,this.addMetadataToTextTrack=n.addMetadataToTextTrack,!e)throw new Error("A non-empty playlist URL or object is required");this.on("minimumUpdatePeriod",()=>{this.refreshXml_()}),this.on("mediaupdatetimeout",()=>{this.refreshMedia_(this.media().id)}),this.state="HAVE_NOTHING",this.loadedPlaylists_={},this.logger_=Lt("DashPlaylistLoader"),this.isMain_?(this.mainPlaylistLoader_.srcUrl=e,this.mainPlaylistLoader_.sidxMapping_={}):this.childPlaylist_=e}get isPaused(){return this.isPaused_}requestErrored_(e,t,n){if(!this.request)return!0;if(this.request=null,e)return this.error=typeof e=="object"&&!(e instanceof Error)?e:{status:t.status,message:"DASH request error at URL: "+t.uri,response:t.response,code:2,metadata:e.metadata},n&&(this.state=n),this.trigger("error"),!0}addSidxSegments_(e,t,n){const s=e.sidx&&Ur(e.sidx);if(!e.sidx||!s||this.mainPlaylistLoader_.sidxMapping_[s]){x.clearTimeout(this.mediaRequest_),this.mediaRequest_=x.setTimeout(()=>n(!1),0);return}const r=kr(e.sidx.resolvedUri),a=(c,f)=>{if(this.requestErrored_(c,f,t))return;const m=this.mainPlaylistLoader_.sidxMapping_,{requestType:b}=f;let C;try{C=r1(ie(f.response).subarray(8))}catch(w){w.metadata=$i({requestType:b,request:f,parseFailure:!0}),this.requestErrored_(w,f,t);return}return m[s]={sidxInfo:e.sidx,sidx:C},Ao(e,C,e.sidx.resolvedUri),n(!0)},l="dash-sidx";this.request=xT(r,this.vhs_.xhr,(c,f,m,b)=>{if(c)return a(c,f);if(!m||m!=="mp4"){const A=m||"unknown";return a({status:f.status,message:`Unsupported ${A} container type for sidx segment at URL: ${r}`,response:"",playlist:e,internal:!0,playlistExclusionDuration:1/0,code:2},f)}const{offset:C,length:w}=e.sidx.byterange;if(b.length>=w+C)return a(c,{response:b.subarray(C,C+w),status:f.status,uri:f.uri});this.request=this.vhs_.xhr({uri:r,responseType:"arraybuffer",requestType:"dash-sidx",headers:co({byterange:e.sidx.byterange})},a)},l)}dispose(){this.isPaused_=!0,this.trigger("dispose"),this.stopRequest(),this.loadedPlaylists_={},x.clearTimeout(this.minimumUpdatePeriodTimeout_),x.clearTimeout(this.mediaRequest_),x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.mediaRequest_=null,this.minimumUpdatePeriodTimeout_=null,this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.off()}hasPendingRequest(){return this.request||this.mediaRequest_}stopRequest(){if(this.request){const e=this.request;this.request=null,e.onreadystatechange=null,e.abort()}}media(e){if(!e)return this.media_;if(this.state==="HAVE_NOTHING")throw new Error("Cannot switch media playlist from "+this.state);const t=this.state;if(typeof e=="string"){if(!this.mainPlaylistLoader_.main.playlists[e])throw new Error("Unknown playlist URI: "+e);e=this.mainPlaylistLoader_.main.playlists[e]}const n=!this.media_||e.id!==this.media_.id;if(n&&this.loadedPlaylists_[e.id]&&this.loadedPlaylists_[e.id].endList){this.state="HAVE_METADATA",this.media_=e,n&&(this.trigger("mediachanging"),this.trigger("mediachange"));return}n&&(this.media_&&this.trigger("mediachanging"),this.addSidxSegments_(e,t,s=>{this.haveMetadata({startingState:t,playlist:e})}))}haveMetadata({startingState:e,playlist:t}){this.state="HAVE_METADATA",this.loadedPlaylists_[t.id]=t,x.clearTimeout(this.mediaRequest_),this.mediaRequest_=null,this.refreshMedia_(t.id),e==="HAVE_MAIN_MANIFEST"?this.trigger("loadedmetadata"):this.trigger("mediachange")}pause(){this.isPaused_=!0,this.mainPlaylistLoader_.createMupOnMedia_&&(this.off("loadedmetadata",this.mainPlaylistLoader_.createMupOnMedia_),this.mainPlaylistLoader_.createMupOnMedia_=null),this.stopRequest(),x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null,this.isMain_&&(x.clearTimeout(this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_),this.mainPlaylistLoader_.minimumUpdatePeriodTimeout_=null),this.state==="HAVE_NOTHING"&&(this.started=!1)}load(e){this.isPaused_=!1,x.clearTimeout(this.mediaUpdateTimeout),this.mediaUpdateTimeout=null;const t=this.media();if(e){const n=t?t.targetDuration/2*1e3:5e3;this.mediaUpdateTimeout=x.setTimeout(()=>this.load(),n);return}if(!this.started){this.start();return}t&&!t.endList?(this.isMain_&&!this.minimumUpdatePeriodTimeout_&&(this.trigger("minimumUpdatePeriod"),this.updateMinimumUpdatePeriodTimeout_()),this.trigger("mediaupdatetimeout")):this.trigger("loadedplaylist")}start(){if(this.started=!0,!this.isMain_){x.clearTimeout(this.mediaRequest_),this.mediaRequest_=x.setTimeout(()=>this.haveMain_(),0);return}this.requestMain_((e,t)=>{this.haveMain_(),!this.hasPendingRequest()&&!this.media_&&this.media(this.mainPlaylistLoader_.main.playlists[0])})}requestMain_(e){const t={manifestInfo:{uri:this.mainPlaylistLoader_.srcUrl}};this.trigger({type:"manifestrequeststart",metadata:t}),this.request=this.vhs_.xhr({uri:this.mainPlaylistLoader_.srcUrl,withCredentials:this.withCredentials,requestType:"dash-manifest"},(n,s)=>{if(n){const{requestType:a}=s;n.metadata=$i({requestType:a,request:s,error:n})}if(this.requestErrored_(n,s)){this.state==="HAVE_NOTHING"&&(this.started=!1);return}this.trigger({type:"manifestrequestcomplete",metadata:t});const r=s.responseText!==this.mainPlaylistLoader_.mainXml_;if(this.mainPlaylistLoader_.mainXml_=s.responseText,s.responseHeaders&&s.responseHeaders.date?this.mainLoaded_=Date.parse(s.responseHeaders.date):this.mainLoaded_=Date.now(),this.mainPlaylistLoader_.srcUrl=kr(this.mainPlaylistLoader_.srcUrl,s),r){this.handleMain_(),this.syncClientServerClock_(()=>e(s,r));return}return e(s,r)})}syncClientServerClock_(e){const t=e1(this.mainPlaylistLoader_.mainXml_);if(t===null)return this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e();if(t.method==="DIRECT")return this.mainPlaylistLoader_.clientOffset_=t.value-Date.now(),e();this.request=this.vhs_.xhr({uri:pt(this.mainPlaylistLoader_.srcUrl,t.value),method:t.method,withCredentials:this.withCredentials,requestType:"dash-clock-sync"},(n,s)=>{if(!this.request)return;if(n){const{requestType:a}=s;return this.error.metadata=$i({requestType:a,request:s,error:n}),this.mainPlaylistLoader_.clientOffset_=this.mainLoaded_-Date.now(),e()}let r;t.method==="HEAD"?!s.responseHeaders||!s.responseHeaders.date?r=this.mainLoaded_:r=Date.parse(s.responseHeaders.date):r=Date.parse(s.responseText),this.mainPlaylistLoader_.clientOffset_=r-Date.now(),e()})}haveMain_(){this.state="HAVE_MAIN_MANIFEST",this.isMain_?this.trigger("loadedplaylist"):this.media_||this.media(this.childPlaylist_)}handleMain_(){x.clearTimeout(this.mediaRequest_),this.mediaRequest_=null;const e=this.mainPlaylistLoader_.main,t={manifestInfo:{uri:this.mainPlaylistLoader_.srcUrl}};this.trigger({type:"manifestparsestart",metadata:t});let n;try{n=LT({mainXml:this.mainPlaylistLoader_.mainXml_,srcUrl:this.mainPlaylistLoader_.srcUrl,clientOffset:this.mainPlaylistLoader_.clientOffset_,sidxMapping:this.mainPlaylistLoader_.sidxMapping_,previousManifest:e})}catch(r){this.error=r,this.error.metadata={errorType:B.Error.StreamingDashManifestParserError,error:r},this.trigger("error")}e&&(n=OT(e,n,this.mainPlaylistLoader_.sidxMapping_)),this.mainPlaylistLoader_.main=n||e;const s=this.mainPlaylistLoader_.main.locations&&this.mainPlaylistLoader_.main.locations[0];if(s&&s!==this.mainPlaylistLoader_.srcUrl&&(this.mainPlaylistLoader_.srcUrl=s),(!e||n&&n.minimumUpdatePeriod!==e.minimumUpdatePeriod)&&this.updateMinimumUpdatePeriodTimeout_(),this.addEventStreamToMetadataTrack_(n),n){const{duration:r,endList:a}=n,l=[];n.playlists.forEach(f=>{l.push({id:f.id,bandwidth:f.attributes.BANDWIDTH,resolution:f.attributes.RESOLUTION,codecs:f.attributes.CODECS})});const c={duration:r,isLive:!a,renditions:l};t.parsedManifest=c,this.trigger({type:"manifestparsecomplete",metadata:t})}return!!n}updateMinimumUpdatePeriodTimeout_(){const e=this.mainPlaylistLoader_;e.createMupOnMedia_&&(e.off("loadedmetadata",e.createMupOnMedia_),e.createMupOnMedia_=null),e.minimumUpdatePeriodTimeout_&&(x.clearTimeout(e.minimumUpdatePeriodTimeout_),e.minimumUpdatePeriodTimeout_=null);let t=e.main&&e.main.minimumUpdatePeriod;if(t===0&&(e.media()?t=e.media().targetDuration*1e3:(e.createMupOnMedia_=e.updateMinimumUpdatePeriodTimeout_,e.one("loadedmetadata",e.createMupOnMedia_))),typeof t!="number"||t<=0){t<0&&this.logger_(`found invalid minimumUpdatePeriod of ${t}, not setting a timeout`);return}this.createMUPTimeout_(t)}createMUPTimeout_(e){const t=this.mainPlaylistLoader_;t.minimumUpdatePeriodTimeout_=x.setTimeout(()=>{t.minimumUpdatePeriodTimeout_=null,t.trigger("minimumUpdatePeriod"),t.createMUPTimeout_(e)},e)}refreshXml_(){this.requestMain_((e,t)=>{t&&(this.media_&&(this.media_=this.mainPlaylistLoader_.main.playlists[this.media_.id]),this.mainPlaylistLoader_.sidxMapping_=RT(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.sidxMapping_),this.addSidxSegments_(this.media(),this.state,n=>{this.refreshMedia_(this.media().id)}))})}refreshMedia_(e){if(!e)throw new Error("refreshMedia_ must take a media id");this.media_&&this.isMain_&&this.handleMain_();const t=this.mainPlaylistLoader_.main.playlists,n=!this.media_||this.media_!==t[e];if(n?this.media_=t[e]:this.trigger("playlistunchanged"),!this.mediaUpdateTimeout){const s=()=>{this.media().endList||(this.mediaUpdateTimeout=x.setTimeout(()=>{this.trigger("mediaupdatetimeout"),s()},uo(this.media(),!!n)))};s()}this.trigger("loadedplaylist")}addEventStreamToMetadataTrack_(e){if(e&&this.mainPlaylistLoader_.main.eventStream){const t=this.mainPlaylistLoader_.main.eventStream.map(n=>({cueTime:n.start,frames:[{data:n.messageData}]}));this.addMetadataToTextTrack("EventStream",t,this.mainPlaylistLoader_.main.duration)}}getKeyIdSet(e){if(e.contentProtection){const t=new Set;for(const n in e.contentProtection){const s=e.contentProtection[n].attributes["cenc:default_KID"];s&&t.add(s.replace(/-/g,"").toLowerCase())}return t}}}var We={GOAL_BUFFER_LENGTH:30,MAX_GOAL_BUFFER_LENGTH:60,BACK_BUFFER_LENGTH:30,GOAL_BUFFER_LENGTH_RATE:1,INITIAL_BANDWIDTH:4194304,BANDWIDTH_VARIANCE:1.2,BUFFER_LOW_WATER_LINE:0,MAX_BUFFER_LOW_WATER_LINE:30,EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:16,BUFFER_LOW_WATER_LINE_RATE:1,BUFFER_HIGH_WATER_LINE:30};const UT=i=>{const e=new Uint8Array(new ArrayBuffer(i.length));for(let t=0;t<i.length;t++)e[t]=i.charCodeAt(t);return e.buffer},cp=function(i){return i.on=i.addEventListener,i.off=i.removeEventListener,i},NT=function(i){try{return URL.createObjectURL(new Blob([i],{type:"application/javascript"}))}catch{const e=new BlobBuilder;return e.append(i),URL.createObjectURL(e.getBlob())}},pp=function(i){return function(){const e=NT(i),t=cp(new Worker(e));t.objURL=e;const n=t.terminate;return t.on=t.addEventListener,t.off=t.removeEventListener,t.terminate=function(){return URL.revokeObjectURL(e),n.call(this)},t}},gp=function(i){return`var browserWorkerPolyFill = ${cp.toString()};
|
|
191
191
|
browserWorkerPolyFill(self);
|
|
192
|
-
`+i},_p=function(i){return i.toString().replace(/^function.+?{/,"").slice(0,-1)},XT=yp(_p(function(){var i=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof or<"u"?or:typeof self<"u"?self:{},e=function(){this.init=function(){var o={};this.on=function(u,d){o[u]||(o[u]=[]),o[u]=o[u].concat(d)},this.off=function(u,d){var h;return o[u]?(h=o[u].indexOf(d),o[u]=o[u].slice(),o[u].splice(h,1),h>-1):!1},this.trigger=function(u){var d,h,f,y;if(d=o[u],!!d)if(arguments.length===2)for(f=d.length,h=0;h<f;++h)d[h].call(this,arguments[1]);else{for(y=[],h=arguments.length,h=1;h<arguments.length;++h)y.push(arguments[h]);for(f=d.length,h=0;h<f;++h)d[h].apply(this,y)}},this.dispose=function(){o={}}}};e.prototype.pipe=function(o){return this.on("data",function(u){o.push(u)}),this.on("done",function(u){o.flush(u)}),this.on("partialdone",function(u){o.partialFlush(u)}),this.on("endedtimeline",function(u){o.endTimeline(u)}),this.on("reset",function(u){o.reset(u)}),o},e.prototype.push=function(o){this.trigger("data",o)},e.prototype.flush=function(o){this.trigger("done",o)},e.prototype.partialFlush=function(o){this.trigger("partialdone",o)},e.prototype.endTimeline=function(o){this.trigger("endedtimeline",o)},e.prototype.reset=function(o){this.trigger("reset",o)};var t=e,n=Math.pow(2,32),s=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d;return u.getBigUint64?(d=u.getBigUint64(0),d<Number.MAX_SAFE_INTEGER?Number(d):d):u.getUint32(0)*n+u.getUint32(4)},r={getUint64:s,MAX_UINT32:n},a=r.MAX_UINT32,l,c,g,m,b,C,w,A,v,M,D,R,N,F,P,$,Y,X,re,ce,be,he,Z,de,ee,Xe,Ye,$e,He,me,fe,mt,Et,we,ue,Re;(function(){var o;if(Z={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},!(typeof Uint8Array>"u")){for(o in Z)Z.hasOwnProperty(o)&&(Z[o]=[o.charCodeAt(0),o.charCodeAt(1),o.charCodeAt(2),o.charCodeAt(3)]);de=new Uint8Array([105,115,111,109]),Xe=new Uint8Array([97,118,99,49]),ee=new Uint8Array([0,0,0,1]),Ye=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]),$e=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]),He={video:Ye,audio:$e},mt=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),fe=new Uint8Array([0,0,0,0,0,0,0,0]),Et=new Uint8Array([0,0,0,0,0,0,0,0]),we=Et,ue=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Re=Et,me=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}})(),l=function(o){var u=[],d=0,h,f,y;for(h=1;h<arguments.length;h++)u.push(arguments[h]);for(h=u.length;h--;)d+=u[h].byteLength;for(f=new Uint8Array(d+8),y=new DataView(f.buffer,f.byteOffset,f.byteLength),y.setUint32(0,f.byteLength),f.set(o,4),h=0,d=8;h<u.length;h++)f.set(u[h],d),d+=u[h].byteLength;return f},c=function(){return l(Z.dinf,l(Z.dref,mt))},g=function(o){return l(Z.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,o.audioobjecttype<<3|o.samplingfrequencyindex>>>1,o.samplingfrequencyindex<<7|o.channelcount<<3,6,1,2]))},m=function(){return l(Z.ftyp,de,ee,de,Xe)},$=function(o){return l(Z.hdlr,He[o])},b=function(o){return l(Z.mdat,o)},P=function(o){var u=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,o.duration>>>24&255,o.duration>>>16&255,o.duration>>>8&255,o.duration&255,85,196,0,0]);return o.samplerate&&(u[12]=o.samplerate>>>24&255,u[13]=o.samplerate>>>16&255,u[14]=o.samplerate>>>8&255,u[15]=o.samplerate&255),l(Z.mdhd,u)},F=function(o){return l(Z.mdia,P(o),$(o.type),w(o))},C=function(o){return l(Z.mfhd,new Uint8Array([0,0,0,0,(o&4278190080)>>24,(o&16711680)>>16,(o&65280)>>8,o&255]))},w=function(o){return l(Z.minf,o.type==="video"?l(Z.vmhd,me):l(Z.smhd,fe),c(),X(o))},A=function(o,u){for(var d=[],h=u.length;h--;)d[h]=ce(u[h]);return l.apply(null,[Z.moof,C(o)].concat(d))},v=function(o){for(var u=o.length,d=[];u--;)d[u]=R(o[u]);return l.apply(null,[Z.moov,D(4294967295)].concat(d).concat(M(o)))},M=function(o){for(var u=o.length,d=[];u--;)d[u]=be(o[u]);return l.apply(null,[Z.mvex].concat(d))},D=function(o){var u=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(o&4278190080)>>24,(o&16711680)>>16,(o&65280)>>8,o&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return l(Z.mvhd,u)},Y=function(o){var u=o.samples||[],d=new Uint8Array(4+u.length),h,f;for(f=0;f<u.length;f++)h=u[f].flags,d[f+4]=h.dependsOn<<4|h.isDependedOn<<2|h.hasRedundancy;return l(Z.sdtp,d)},X=function(o){return l(Z.stbl,re(o),l(Z.stts,Re),l(Z.stsc,we),l(Z.stsz,ue),l(Z.stco,Et))},function(){var o,u;re=function(d){return l(Z.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),d.type==="video"?o(d):u(d))},o=function(d){var h=d.sps||[],f=d.pps||[],y=[],S=[],E,k;for(E=0;E<h.length;E++)y.push((h[E].byteLength&65280)>>>8),y.push(h[E].byteLength&255),y=y.concat(Array.prototype.slice.call(h[E]));for(E=0;E<f.length;E++)S.push((f[E].byteLength&65280)>>>8),S.push(f[E].byteLength&255),S=S.concat(Array.prototype.slice.call(f[E]));if(k=[Z.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,(d.width&65280)>>8,d.width&255,(d.height&65280)>>8,d.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l(Z.avcC,new Uint8Array([1,d.profileIdc,d.profileCompatibility,d.levelIdc,255].concat([h.length],y,[f.length],S))),l(Z.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],d.sarRatio){var I=d.sarRatio[0],O=d.sarRatio[1];k.push(l(Z.pasp,new Uint8Array([(I&4278190080)>>24,(I&16711680)>>16,(I&65280)>>8,I&255,(O&4278190080)>>24,(O&16711680)>>16,(O&65280)>>8,O&255])))}return l.apply(null,k)},u=function(d){return l(Z.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(d.channelcount&65280)>>8,d.channelcount&255,(d.samplesize&65280)>>8,d.samplesize&255,0,0,0,0,(d.samplerate&65280)>>8,d.samplerate&255,0,0]),g(d))}}(),N=function(o){var u=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(o.id&4278190080)>>24,(o.id&16711680)>>16,(o.id&65280)>>8,o.id&255,0,0,0,0,(o.duration&4278190080)>>24,(o.duration&16711680)>>16,(o.duration&65280)>>8,o.duration&255,0,0,0,0,0,0,0,0,0,0,0,0,1,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,(o.width&65280)>>8,o.width&255,0,0,(o.height&65280)>>8,o.height&255,0,0]);return l(Z.tkhd,u)},ce=function(o){var u,d,h,f,y,S,E;return u=l(Z.tfhd,new Uint8Array([0,0,0,58,(o.id&4278190080)>>24,(o.id&16711680)>>16,(o.id&65280)>>8,o.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),S=Math.floor(o.baseMediaDecodeTime/a),E=Math.floor(o.baseMediaDecodeTime%a),d=l(Z.tfdt,new Uint8Array([1,0,0,0,S>>>24&255,S>>>16&255,S>>>8&255,S&255,E>>>24&255,E>>>16&255,E>>>8&255,E&255])),y=92,o.type==="audio"?(h=he(o,y),l(Z.traf,u,d,h)):(f=Y(o),h=he(o,f.length+y),l(Z.traf,u,d,h,f))},R=function(o){return o.duration=o.duration||4294967295,l(Z.trak,N(o),F(o))},be=function(o){var u=new Uint8Array([0,0,0,0,(o.id&4278190080)>>24,(o.id&16711680)>>16,(o.id&65280)>>8,o.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return o.type!=="video"&&(u[u.length-1]=0),l(Z.trex,u)},function(){var o,u,d;d=function(h,f){var y=0,S=0,E=0,k=0;return h.length&&(h[0].duration!==void 0&&(y=1),h[0].size!==void 0&&(S=2),h[0].flags!==void 0&&(E=4),h[0].compositionTimeOffset!==void 0&&(k=8)),[0,0,y|S|E|k,1,(h.length&4278190080)>>>24,(h.length&16711680)>>>16,(h.length&65280)>>>8,h.length&255,(f&4278190080)>>>24,(f&16711680)>>>16,(f&65280)>>>8,f&255]},u=function(h,f){var y,S,E,k,I,O;for(k=h.samples||[],f+=20+16*k.length,E=d(k,f),S=new Uint8Array(E.length+k.length*16),S.set(E),y=E.length,O=0;O<k.length;O++)I=k[O],S[y++]=(I.duration&4278190080)>>>24,S[y++]=(I.duration&16711680)>>>16,S[y++]=(I.duration&65280)>>>8,S[y++]=I.duration&255,S[y++]=(I.size&4278190080)>>>24,S[y++]=(I.size&16711680)>>>16,S[y++]=(I.size&65280)>>>8,S[y++]=I.size&255,S[y++]=I.flags.isLeading<<2|I.flags.dependsOn,S[y++]=I.flags.isDependedOn<<6|I.flags.hasRedundancy<<4|I.flags.paddingValue<<1|I.flags.isNonSyncSample,S[y++]=I.flags.degradationPriority&61440,S[y++]=I.flags.degradationPriority&15,S[y++]=(I.compositionTimeOffset&4278190080)>>>24,S[y++]=(I.compositionTimeOffset&16711680)>>>16,S[y++]=(I.compositionTimeOffset&65280)>>>8,S[y++]=I.compositionTimeOffset&255;return l(Z.trun,S)},o=function(h,f){var y,S,E,k,I,O;for(k=h.samples||[],f+=20+8*k.length,E=d(k,f),y=new Uint8Array(E.length+k.length*8),y.set(E),S=E.length,O=0;O<k.length;O++)I=k[O],y[S++]=(I.duration&4278190080)>>>24,y[S++]=(I.duration&16711680)>>>16,y[S++]=(I.duration&65280)>>>8,y[S++]=I.duration&255,y[S++]=(I.size&4278190080)>>>24,y[S++]=(I.size&16711680)>>>16,y[S++]=(I.size&65280)>>>8,y[S++]=I.size&255;return l(Z.trun,y)},he=function(h,f){return h.type==="audio"?o(h,f):u(h,f)}}();var Hi={ftyp:m,mdat:b,moof:A,moov:v,initSegment:function(o){var u=m(),d=v(o),h;return h=new Uint8Array(u.byteLength+d.byteLength),h.set(u),h.set(d,u.byteLength),h}},oi=function(o){var u,d,h=[],f=[];for(f.byteLength=0,f.nalCount=0,f.duration=0,h.byteLength=0,u=0;u<o.length;u++)d=o[u],d.nalUnitType==="access_unit_delimiter_rbsp"?(h.length&&(h.duration=d.dts-h.dts,f.byteLength+=h.byteLength,f.nalCount+=h.length,f.duration+=h.duration,f.push(h)),h=[d],h.byteLength=d.data.byteLength,h.pts=d.pts,h.dts=d.dts):(d.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"&&(h.keyFrame=!0),h.duration=d.dts-h.dts,h.byteLength+=d.data.byteLength,h.push(d));return f.length&&(!h.duration||h.duration<=0)&&(h.duration=f[f.length-1].duration),f.byteLength+=h.byteLength,f.nalCount+=h.length,f.duration+=h.duration,f.push(h),f},li=function(o){var u,d,h=[],f=[];for(h.byteLength=0,h.nalCount=0,h.duration=0,h.pts=o[0].pts,h.dts=o[0].dts,f.byteLength=0,f.nalCount=0,f.duration=0,f.pts=o[0].pts,f.dts=o[0].dts,u=0;u<o.length;u++)d=o[u],d.keyFrame?(h.length&&(f.push(h),f.byteLength+=h.byteLength,f.nalCount+=h.nalCount,f.duration+=h.duration),h=[d],h.nalCount=d.length,h.byteLength=d.byteLength,h.pts=d.pts,h.dts=d.dts,h.duration=d.duration):(h.duration+=d.duration,h.nalCount+=d.length,h.byteLength+=d.byteLength,h.push(d));return f.length&&h.duration<=0&&(h.duration=f[f.length-1].duration),f.byteLength+=h.byteLength,f.nalCount+=h.nalCount,f.duration+=h.duration,f.push(h),f},Ei=function(o){var u;return!o[0][0].keyFrame&&o.length>1&&(u=o.shift(),o.byteLength-=u.byteLength,o.nalCount-=u.nalCount,o[0][0].dts=u.dts,o[0][0].pts=u.pts,o[0][0].duration+=u.duration),o},yt=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},ui=function(o,u){var d=yt();return d.dataOffset=u,d.compositionTimeOffset=o.pts-o.dts,d.duration=o.duration,d.size=4*o.length,d.size+=o.byteLength,o.keyFrame&&(d.flags.dependsOn=2,d.flags.isNonSyncSample=0),d},Ft=function(o,u){var d,h,f,y,S,E=u||0,k=[];for(d=0;d<o.length;d++)for(y=o[d],h=0;h<y.length;h++)S=y[h],f=ui(S,E),E+=f.size,k.push(f);return k},wi=function(o){var u,d,h,f,y,S,E=0,k=o.byteLength,I=o.nalCount,O=k+4*I,j=new Uint8Array(O),Q=new DataView(j.buffer);for(u=0;u<o.length;u++)for(f=o[u],d=0;d<f.length;d++)for(y=f[d],h=0;h<y.length;h++)S=y[h],Q.setUint32(E,S.data.byteLength),E+=4,j.set(S.data,E),E+=S.data.byteLength;return j},Dt=function(o,u){var d,h=u||0,f=[];return d=ui(o,h),f.push(d),f},Ot=function(o){var u,d,h=0,f=o.byteLength,y=o.length,S=f+4*y,E=new Uint8Array(S),k=new DataView(E.buffer);for(u=0;u<o.length;u++)d=o[u],k.setUint32(h,d.data.byteLength),h+=4,E.set(d.data,h),h+=d.data.byteLength;return E},ki={groupNalsIntoFrames:oi,groupFramesIntoGops:li,extendFirstKeyFrame:Ei,generateSampleTable:Ft,concatenateNalData:wi,generateSampleTableForFrame:Dt,concatenateNalDataForFrame:Ot},jt=[33,16,5,32,164,27],Pn=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],pe=function(o){for(var u=[];o--;)u.push(0);return u},ia=function(o){return Object.keys(o).reduce(function(u,d){return u[d]=new Uint8Array(o[d].reduce(function(h,f){return h.concat(f)},[])),u},{})},Ln,Ss=function(){if(!Ln){var o={96e3:[jt,[227,64],pe(154),[56]],88200:[jt,[231],pe(170),[56]],64e3:[jt,[248,192],pe(240),[56]],48e3:[jt,[255,192],pe(268),[55,148,128],pe(54),[112]],44100:[jt,[255,192],pe(268),[55,163,128],pe(84),[112]],32e3:[jt,[255,192],pe(268),[55,234],pe(226),[112]],24e3:[jt,[255,192],pe(268),[55,255,128],pe(268),[111,112],pe(126),[224]],16e3:[jt,[255,192],pe(268),[55,255,128],pe(268),[111,255],pe(269),[223,108],pe(195),[1,192]],12e3:[Pn,pe(268),[3,127,248],pe(268),[6,255,240],pe(268),[13,255,224],pe(268),[27,253,128],pe(259),[56]],11025:[Pn,pe(268),[3,127,248],pe(268),[6,255,240],pe(268),[13,255,224],pe(268),[27,255,192],pe(268),[55,175,128],pe(108),[112]],8e3:[Pn,pe(268),[3,121,16],pe(47),[7]]};Ln=ia(o)}return Ln},di=9e4,ut,Ci,zi,wt,Es,p,_;ut=function(o){return o*di},Ci=function(o,u){return o*u},zi=function(o){return o/di},wt=function(o,u){return o/u},Es=function(o,u){return ut(wt(o,u))},p=function(o,u){return Ci(zi(o),u)},_=function(o,u,d){return zi(d?o:o-u)};var T={ONE_SECOND_IN_TS:di,secondsToVideoTs:ut,secondsToAudioTs:Ci,videoTsToSeconds:zi,audioTsToSeconds:wt,audioTsToVideoTs:Es,videoTsToAudioTs:p,metadataTsToSeconds:_},L=Ss,U=T,q=function(o){var u,d,h=0;for(u=0;u<o.length;u++)d=o[u],h+=d.data.byteLength;return h},K=function(o,u,d,h){var f,y=0,S=0,E=0,k=0,I,O,j;if(u.length&&(f=U.audioTsToVideoTs(o.baseMediaDecodeTime,o.samplerate),y=Math.ceil(U.ONE_SECOND_IN_TS/(o.samplerate/1024)),d&&h&&(S=f-Math.max(d,h),E=Math.floor(S/y),k=E*y),!(E<1||k>U.ONE_SECOND_IN_TS/2))){for(I=L()[o.samplerate],I||(I=u[0].data),O=0;O<E;O++)j=u[0],u.splice(0,0,{data:I,dts:j.dts-y,pts:j.pts-y});return o.baseMediaDecodeTime-=Math.floor(U.videoTsToAudioTs(k,o.samplerate)),k}},Se=function(o,u,d){return u.minSegmentDts>=d?o:(u.minSegmentDts=1/0,o.filter(function(h){return h.dts>=d?(u.minSegmentDts=Math.min(u.minSegmentDts,h.dts),u.minSegmentPts=u.minSegmentDts,!0):!1}))},Ve=function(o){var u,d,h=[];for(u=0;u<o.length;u++)d=o[u],h.push({size:d.data.byteLength,duration:1024});return h},ke=function(o){var u,d,h=0,f=new Uint8Array(q(o));for(u=0;u<o.length;u++)d=o[u],f.set(d.data,h),h+=d.data.byteLength;return f},Te={prefixWithSilence:K,trimAdtsFramesByEarliestDts:Se,generateSampleTable:Ve,concatenateFrameData:ke},Ue=T.ONE_SECOND_IN_TS,Xp=function(o,u){typeof u.pts=="number"&&(o.timelineStartInfo.pts===void 0&&(o.timelineStartInfo.pts=u.pts),o.minSegmentPts===void 0?o.minSegmentPts=u.pts:o.minSegmentPts=Math.min(o.minSegmentPts,u.pts),o.maxSegmentPts===void 0?o.maxSegmentPts=u.pts:o.maxSegmentPts=Math.max(o.maxSegmentPts,u.pts)),typeof u.dts=="number"&&(o.timelineStartInfo.dts===void 0&&(o.timelineStartInfo.dts=u.dts),o.minSegmentDts===void 0?o.minSegmentDts=u.dts:o.minSegmentDts=Math.min(o.minSegmentDts,u.dts),o.maxSegmentDts===void 0?o.maxSegmentDts=u.dts:o.maxSegmentDts=Math.max(o.maxSegmentDts,u.dts))},Kp=function(o){delete o.minSegmentDts,delete o.maxSegmentDts,delete o.minSegmentPts,delete o.maxSegmentPts},Yp=function(o,u){var d,h,f=o.minSegmentDts;return u||(f-=o.timelineStartInfo.dts),d=o.timelineStartInfo.baseMediaDecodeTime,d+=f,d=Math.max(0,d),o.type==="audio"&&(h=o.samplerate/Ue,d*=h,d=Math.floor(d)),d},Qp={clearDtsInfo:Kp,calculateTrackBaseMediaDecodeTime:Yp,collectDtsInfo:Xp},gl=4,Jp=128,Zp=function(o){for(var u=0,d={payloadType:-1,payloadSize:0},h=0,f=0;u<o.byteLength&&o[u]!==Jp;){for(;o[u]===255;)h+=255,u++;for(h+=o[u++];o[u]===255;)f+=255,u++;if(f+=o[u++],!d.payload&&h===gl){var y=String.fromCharCode(o[u+3],o[u+4],o[u+5],o[u+6]);if(y==="GA94"){d.payloadType=h,d.payloadSize=f,d.payload=o.subarray(u,u+f);break}else d.payload=void 0}u+=f,h=0,f=0}return d},ef=function(o){return o.payload[0]!==181||(o.payload[1]<<8|o.payload[2])!==49||String.fromCharCode(o.payload[3],o.payload[4],o.payload[5],o.payload[6])!=="GA94"||o.payload[7]!==3?null:o.payload.subarray(8,o.payload.length-1)},tf=function(o,u){var d=[],h,f,y,S;if(!(u[0]&64))return d;for(f=u[0]&31,h=0;h<f;h++)y=h*3,S={type:u[y+2]&3,pts:o},u[y+2]&4&&(S.ccData=u[y+3]<<8|u[y+4],d.push(S));return d},nf=function(o){for(var u=o.byteLength,d=[],h=1,f,y;h<u-2;)o[h]===0&&o[h+1]===0&&o[h+2]===3?(d.push(h+2),h+=2):h++;if(d.length===0)return o;f=u-d.length,y=new Uint8Array(f);var S=0;for(h=0;h<f;S++,h++)S===d[0]&&(S++,d.shift()),y[h]=o[S];return y},ml={parseSei:Zp,parseUserData:ef,parseCaptionPackets:tf,discardEmulationPreventionBytes:nf,USER_DATA_REGISTERED_ITU_T_T35:gl},na=t,ws=ml,dt=function(o){o=o||{},dt.prototype.init.call(this),this.parse708captions_=typeof o.parse708captions=="boolean"?o.parse708captions:!0,this.captionPackets_=[],this.ccStreams_=[new Pe(0,0),new Pe(0,1),new Pe(1,0),new Pe(1,1)],this.parse708captions_&&(this.cc708Stream_=new Ee({captionServices:o.captionServices})),this.reset(),this.ccStreams_.forEach(function(u){u.on("data",this.trigger.bind(this,"data")),u.on("partialdone",this.trigger.bind(this,"partialdone")),u.on("done",this.trigger.bind(this,"done"))},this),this.parse708captions_&&(this.cc708Stream_.on("data",this.trigger.bind(this,"data")),this.cc708Stream_.on("partialdone",this.trigger.bind(this,"partialdone")),this.cc708Stream_.on("done",this.trigger.bind(this,"done")))};dt.prototype=new na,dt.prototype.push=function(o){var u,d,h;if(o.nalUnitType==="sei_rbsp"&&(u=ws.parseSei(o.escapedRBSP),!!u.payload&&u.payloadType===ws.USER_DATA_REGISTERED_ITU_T_T35&&(d=ws.parseUserData(u),!!d))){if(o.dts<this.latestDts_){this.ignoreNextEqualDts_=!0;return}else if(o.dts===this.latestDts_&&this.ignoreNextEqualDts_){this.numSameDts_--,this.numSameDts_||(this.ignoreNextEqualDts_=!1);return}h=ws.parseCaptionPackets(o.pts,d),this.captionPackets_=this.captionPackets_.concat(h),this.latestDts_!==o.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=o.dts}},dt.prototype.flushCCStreams=function(o){this.ccStreams_.forEach(function(u){return o==="flush"?u.flush():u.partialFlush()},this)},dt.prototype.flushStream=function(o){if(!this.captionPackets_.length){this.flushCCStreams(o);return}this.captionPackets_.forEach(function(u,d){u.presortIndex=d}),this.captionPackets_.sort(function(u,d){return u.pts===d.pts?u.presortIndex-d.presortIndex:u.pts-d.pts}),this.captionPackets_.forEach(function(u){u.type<2?this.dispatchCea608Packet(u):this.dispatchCea708Packet(u)},this),this.captionPackets_.length=0,this.flushCCStreams(o)},dt.prototype.flush=function(){return this.flushStream("flush")},dt.prototype.partialFlush=function(){return this.flushStream("partialFlush")},dt.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(o){o.reset()})},dt.prototype.dispatchCea608Packet=function(o){this.setsTextOrXDSActive(o)?this.activeCea608Channel_[o.type]=null:this.setsChannel1Active(o)?this.activeCea608Channel_[o.type]=0:this.setsChannel2Active(o)&&(this.activeCea608Channel_[o.type]=1),this.activeCea608Channel_[o.type]!==null&&this.ccStreams_[(o.type<<1)+this.activeCea608Channel_[o.type]].push(o)},dt.prototype.setsChannel1Active=function(o){return(o.ccData&30720)===4096},dt.prototype.setsChannel2Active=function(o){return(o.ccData&30720)===6144},dt.prototype.setsTextOrXDSActive=function(o){return(o.ccData&28928)===256||(o.ccData&30974)===4138||(o.ccData&30974)===6186},dt.prototype.dispatchCea708Packet=function(o){this.parse708captions_&&this.cc708Stream_.push(o)};var sf={127:9834,4128:32,4129:160,4133:8230,4138:352,4140:338,4144:9608,4145:8216,4146:8217,4147:8220,4148:8221,4149:8226,4153:8482,4154:353,4156:339,4157:8480,4159:376,4214:8539,4215:8540,4216:8541,4217:8542,4218:9168,4219:9124,4220:9123,4221:9135,4222:9126,4223:9121,4256:12600},rf=function(o){var u=sf[o]||o;return o&4096&&o===u?"":String.fromCharCode(u)},ks=function(o){return 32<=o&&o<=127||160<=o&&o<=255},ei=function(o){this.windowNum=o,this.reset()};ei.prototype.reset=function(){this.clearText(),this.pendingNewLine=!1,this.winAttr={},this.penAttr={},this.penLoc={},this.penColor={},this.visible=0,this.rowLock=0,this.columnLock=0,this.priority=0,this.relativePositioning=0,this.anchorVertical=0,this.anchorHorizontal=0,this.anchorPoint=0,this.rowCount=1,this.virtualRowCount=this.rowCount+1,this.columnCount=41,this.windowStyle=0,this.penStyle=0},ei.prototype.getText=function(){return this.rows.join(`
|
|
193
|
-
`)},ei.prototype.clearText=function(){this.rows=[""],this.rowIdx=0},ei.prototype.newLine=function(o){for(this.rows.length>=this.virtualRowCount&&typeof this.beforeRowOverflow=="function"&&this.beforeRowOverflow(o),this.rows.length>0&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--},ei.prototype.isEmpty=function(){return this.rows.length===0?!0:this.rows.length===1?this.rows[0]==="":!1},ei.prototype.addText=function(o){this.rows[this.rowIdx]+=o},ei.prototype.backspace=function(){if(!this.isEmpty()){var o=this.rows[this.rowIdx];this.rows[this.rowIdx]=o.substr(0,o.length-1)}};var
|
|
192
|
+
`+i},fp=function(i){return i.toString().replace(/^function.+?{/,"").slice(0,-1)},BT=gp(fp(function(){var i=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof ar<"u"?ar:typeof self<"u"?self:{},e=function(){this.init=function(){var o={};this.on=function(u,d){o[u]||(o[u]=[]),o[u]=o[u].concat(d)},this.off=function(u,d){var h;return o[u]?(h=o[u].indexOf(d),o[u]=o[u].slice(),o[u].splice(h,1),h>-1):!1},this.trigger=function(u){var d,h,g,y;if(d=o[u],!!d)if(arguments.length===2)for(g=d.length,h=0;h<g;++h)d[h].call(this,arguments[1]);else{for(y=[],h=arguments.length,h=1;h<arguments.length;++h)y.push(arguments[h]);for(g=d.length,h=0;h<g;++h)d[h].apply(this,y)}},this.dispose=function(){o={}}}};e.prototype.pipe=function(o){return this.on("data",function(u){o.push(u)}),this.on("done",function(u){o.flush(u)}),this.on("partialdone",function(u){o.partialFlush(u)}),this.on("endedtimeline",function(u){o.endTimeline(u)}),this.on("reset",function(u){o.reset(u)}),o},e.prototype.push=function(o){this.trigger("data",o)},e.prototype.flush=function(o){this.trigger("done",o)},e.prototype.partialFlush=function(o){this.trigger("partialdone",o)},e.prototype.endTimeline=function(o){this.trigger("endedtimeline",o)},e.prototype.reset=function(o){this.trigger("reset",o)};var t=e,n=Math.pow(2,32),s=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d;return u.getBigUint64?(d=u.getBigUint64(0),d<Number.MAX_SAFE_INTEGER?Number(d):d):u.getUint32(0)*n+u.getUint32(4)},r={getUint64:s,MAX_UINT32:n},a=r.MAX_UINT32,l,c,f,m,b,C,w,A,v,M,D,R,N,F,P,$,Y,X,re,ce,be,he,Z,de,ee,Xe,Ye,$e,He,me,ge,mt,Et,we,le,Re;(function(){var o;if(Z={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},!(typeof Uint8Array>"u")){for(o in Z)Z.hasOwnProperty(o)&&(Z[o]=[o.charCodeAt(0),o.charCodeAt(1),o.charCodeAt(2),o.charCodeAt(3)]);de=new Uint8Array([105,115,111,109]),Xe=new Uint8Array([97,118,99,49]),ee=new Uint8Array([0,0,0,1]),Ye=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]),$e=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]),He={video:Ye,audio:$e},mt=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),ge=new Uint8Array([0,0,0,0,0,0,0,0]),Et=new Uint8Array([0,0,0,0,0,0,0,0]),we=Et,le=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Re=Et,me=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}})(),l=function(o){var u=[],d=0,h,g,y;for(h=1;h<arguments.length;h++)u.push(arguments[h]);for(h=u.length;h--;)d+=u[h].byteLength;for(g=new Uint8Array(d+8),y=new DataView(g.buffer,g.byteOffset,g.byteLength),y.setUint32(0,g.byteLength),g.set(o,4),h=0,d=8;h<u.length;h++)g.set(u[h],d),d+=u[h].byteLength;return g},c=function(){return l(Z.dinf,l(Z.dref,mt))},f=function(o){return l(Z.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,o.audioobjecttype<<3|o.samplingfrequencyindex>>>1,o.samplingfrequencyindex<<7|o.channelcount<<3,6,1,2]))},m=function(){return l(Z.ftyp,de,ee,de,Xe)},$=function(o){return l(Z.hdlr,He[o])},b=function(o){return l(Z.mdat,o)},P=function(o){var u=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,o.duration>>>24&255,o.duration>>>16&255,o.duration>>>8&255,o.duration&255,85,196,0,0]);return o.samplerate&&(u[12]=o.samplerate>>>24&255,u[13]=o.samplerate>>>16&255,u[14]=o.samplerate>>>8&255,u[15]=o.samplerate&255),l(Z.mdhd,u)},F=function(o){return l(Z.mdia,P(o),$(o.type),w(o))},C=function(o){return l(Z.mfhd,new Uint8Array([0,0,0,0,(o&4278190080)>>24,(o&16711680)>>16,(o&65280)>>8,o&255]))},w=function(o){return l(Z.minf,o.type==="video"?l(Z.vmhd,me):l(Z.smhd,ge),c(),X(o))},A=function(o,u){for(var d=[],h=u.length;h--;)d[h]=ce(u[h]);return l.apply(null,[Z.moof,C(o)].concat(d))},v=function(o){for(var u=o.length,d=[];u--;)d[u]=R(o[u]);return l.apply(null,[Z.moov,D(4294967295)].concat(d).concat(M(o)))},M=function(o){for(var u=o.length,d=[];u--;)d[u]=be(o[u]);return l.apply(null,[Z.mvex].concat(d))},D=function(o){var u=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(o&4278190080)>>24,(o&16711680)>>16,(o&65280)>>8,o&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return l(Z.mvhd,u)},Y=function(o){var u=o.samples||[],d=new Uint8Array(4+u.length),h,g;for(g=0;g<u.length;g++)h=u[g].flags,d[g+4]=h.dependsOn<<4|h.isDependedOn<<2|h.hasRedundancy;return l(Z.sdtp,d)},X=function(o){return l(Z.stbl,re(o),l(Z.stts,Re),l(Z.stsc,we),l(Z.stsz,le),l(Z.stco,Et))},function(){var o,u;re=function(d){return l(Z.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),d.type==="video"?o(d):u(d))},o=function(d){var h=d.sps||[],g=d.pps||[],y=[],S=[],E,k;for(E=0;E<h.length;E++)y.push((h[E].byteLength&65280)>>>8),y.push(h[E].byteLength&255),y=y.concat(Array.prototype.slice.call(h[E]));for(E=0;E<g.length;E++)S.push((g[E].byteLength&65280)>>>8),S.push(g[E].byteLength&255),S=S.concat(Array.prototype.slice.call(g[E]));if(k=[Z.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,(d.width&65280)>>8,d.width&255,(d.height&65280)>>8,d.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l(Z.avcC,new Uint8Array([1,d.profileIdc,d.profileCompatibility,d.levelIdc,255].concat([h.length],y,[g.length],S))),l(Z.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],d.sarRatio){var I=d.sarRatio[0],O=d.sarRatio[1];k.push(l(Z.pasp,new Uint8Array([(I&4278190080)>>24,(I&16711680)>>16,(I&65280)>>8,I&255,(O&4278190080)>>24,(O&16711680)>>16,(O&65280)>>8,O&255])))}return l.apply(null,k)},u=function(d){return l(Z.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(d.channelcount&65280)>>8,d.channelcount&255,(d.samplesize&65280)>>8,d.samplesize&255,0,0,0,0,(d.samplerate&65280)>>8,d.samplerate&255,0,0]),f(d))}}(),N=function(o){var u=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(o.id&4278190080)>>24,(o.id&16711680)>>16,(o.id&65280)>>8,o.id&255,0,0,0,0,(o.duration&4278190080)>>24,(o.duration&16711680)>>16,(o.duration&65280)>>8,o.duration&255,0,0,0,0,0,0,0,0,0,0,0,0,1,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,(o.width&65280)>>8,o.width&255,0,0,(o.height&65280)>>8,o.height&255,0,0]);return l(Z.tkhd,u)},ce=function(o){var u,d,h,g,y,S,E;return u=l(Z.tfhd,new Uint8Array([0,0,0,58,(o.id&4278190080)>>24,(o.id&16711680)>>16,(o.id&65280)>>8,o.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),S=Math.floor(o.baseMediaDecodeTime/a),E=Math.floor(o.baseMediaDecodeTime%a),d=l(Z.tfdt,new Uint8Array([1,0,0,0,S>>>24&255,S>>>16&255,S>>>8&255,S&255,E>>>24&255,E>>>16&255,E>>>8&255,E&255])),y=92,o.type==="audio"?(h=he(o,y),l(Z.traf,u,d,h)):(g=Y(o),h=he(o,g.length+y),l(Z.traf,u,d,h,g))},R=function(o){return o.duration=o.duration||4294967295,l(Z.trak,N(o),F(o))},be=function(o){var u=new Uint8Array([0,0,0,0,(o.id&4278190080)>>24,(o.id&16711680)>>16,(o.id&65280)>>8,o.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return o.type!=="video"&&(u[u.length-1]=0),l(Z.trex,u)},function(){var o,u,d;d=function(h,g){var y=0,S=0,E=0,k=0;return h.length&&(h[0].duration!==void 0&&(y=1),h[0].size!==void 0&&(S=2),h[0].flags!==void 0&&(E=4),h[0].compositionTimeOffset!==void 0&&(k=8)),[0,0,y|S|E|k,1,(h.length&4278190080)>>>24,(h.length&16711680)>>>16,(h.length&65280)>>>8,h.length&255,(g&4278190080)>>>24,(g&16711680)>>>16,(g&65280)>>>8,g&255]},u=function(h,g){var y,S,E,k,I,O;for(k=h.samples||[],g+=20+16*k.length,E=d(k,g),S=new Uint8Array(E.length+k.length*16),S.set(E),y=E.length,O=0;O<k.length;O++)I=k[O],S[y++]=(I.duration&4278190080)>>>24,S[y++]=(I.duration&16711680)>>>16,S[y++]=(I.duration&65280)>>>8,S[y++]=I.duration&255,S[y++]=(I.size&4278190080)>>>24,S[y++]=(I.size&16711680)>>>16,S[y++]=(I.size&65280)>>>8,S[y++]=I.size&255,S[y++]=I.flags.isLeading<<2|I.flags.dependsOn,S[y++]=I.flags.isDependedOn<<6|I.flags.hasRedundancy<<4|I.flags.paddingValue<<1|I.flags.isNonSyncSample,S[y++]=I.flags.degradationPriority&61440,S[y++]=I.flags.degradationPriority&15,S[y++]=(I.compositionTimeOffset&4278190080)>>>24,S[y++]=(I.compositionTimeOffset&16711680)>>>16,S[y++]=(I.compositionTimeOffset&65280)>>>8,S[y++]=I.compositionTimeOffset&255;return l(Z.trun,S)},o=function(h,g){var y,S,E,k,I,O;for(k=h.samples||[],g+=20+8*k.length,E=d(k,g),y=new Uint8Array(E.length+k.length*8),y.set(E),S=E.length,O=0;O<k.length;O++)I=k[O],y[S++]=(I.duration&4278190080)>>>24,y[S++]=(I.duration&16711680)>>>16,y[S++]=(I.duration&65280)>>>8,y[S++]=I.duration&255,y[S++]=(I.size&4278190080)>>>24,y[S++]=(I.size&16711680)>>>16,y[S++]=(I.size&65280)>>>8,y[S++]=I.size&255;return l(Z.trun,y)},he=function(h,g){return h.type==="audio"?o(h,g):u(h,g)}}();var Hi={ftyp:m,mdat:b,moof:A,moov:v,initSegment:function(o){var u=m(),d=v(o),h;return h=new Uint8Array(u.byteLength+d.byteLength),h.set(u),h.set(d,u.byteLength),h}},oi=function(o){var u,d,h=[],g=[];for(g.byteLength=0,g.nalCount=0,g.duration=0,h.byteLength=0,u=0;u<o.length;u++)d=o[u],d.nalUnitType==="access_unit_delimiter_rbsp"?(h.length&&(h.duration=d.dts-h.dts,g.byteLength+=h.byteLength,g.nalCount+=h.length,g.duration+=h.duration,g.push(h)),h=[d],h.byteLength=d.data.byteLength,h.pts=d.pts,h.dts=d.dts):(d.nalUnitType==="slice_layer_without_partitioning_rbsp_idr"&&(h.keyFrame=!0),h.duration=d.dts-h.dts,h.byteLength+=d.data.byteLength,h.push(d));return g.length&&(!h.duration||h.duration<=0)&&(h.duration=g[g.length-1].duration),g.byteLength+=h.byteLength,g.nalCount+=h.length,g.duration+=h.duration,g.push(h),g},li=function(o){var u,d,h=[],g=[];for(h.byteLength=0,h.nalCount=0,h.duration=0,h.pts=o[0].pts,h.dts=o[0].dts,g.byteLength=0,g.nalCount=0,g.duration=0,g.pts=o[0].pts,g.dts=o[0].dts,u=0;u<o.length;u++)d=o[u],d.keyFrame?(h.length&&(g.push(h),g.byteLength+=h.byteLength,g.nalCount+=h.nalCount,g.duration+=h.duration),h=[d],h.nalCount=d.length,h.byteLength=d.byteLength,h.pts=d.pts,h.dts=d.dts,h.duration=d.duration):(h.duration+=d.duration,h.nalCount+=d.length,h.byteLength+=d.byteLength,h.push(d));return g.length&&h.duration<=0&&(h.duration=g[g.length-1].duration),g.byteLength+=h.byteLength,g.nalCount+=h.nalCount,g.duration+=h.duration,g.push(h),g},Ei=function(o){var u;return!o[0][0].keyFrame&&o.length>1&&(u=o.shift(),o.byteLength-=u.byteLength,o.nalCount-=u.nalCount,o[0][0].dts=u.dts,o[0][0].pts=u.pts,o[0][0].duration+=u.duration),o},yt=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},ui=function(o,u){var d=yt();return d.dataOffset=u,d.compositionTimeOffset=o.pts-o.dts,d.duration=o.duration,d.size=4*o.length,d.size+=o.byteLength,o.keyFrame&&(d.flags.dependsOn=2,d.flags.isNonSyncSample=0),d},Ft=function(o,u){var d,h,g,y,S,E=u||0,k=[];for(d=0;d<o.length;d++)for(y=o[d],h=0;h<y.length;h++)S=y[h],g=ui(S,E),E+=g.size,k.push(g);return k},wi=function(o){var u,d,h,g,y,S,E=0,k=o.byteLength,I=o.nalCount,O=k+4*I,j=new Uint8Array(O),Q=new DataView(j.buffer);for(u=0;u<o.length;u++)for(g=o[u],d=0;d<g.length;d++)for(y=g[d],h=0;h<y.length;h++)S=y[h],Q.setUint32(E,S.data.byteLength),E+=4,j.set(S.data,E),E+=S.data.byteLength;return j},Dt=function(o,u){var d,h=u||0,g=[];return d=ui(o,h),g.push(d),g},Ot=function(o){var u,d,h=0,g=o.byteLength,y=o.length,S=g+4*y,E=new Uint8Array(S),k=new DataView(E.buffer);for(u=0;u<o.length;u++)d=o[u],k.setUint32(h,d.data.byteLength),h+=4,E.set(d.data,h),h+=d.data.byteLength;return E},ki={groupNalsIntoFrames:oi,groupFramesIntoGops:li,extendFirstKeyFrame:Ei,generateSampleTable:Ft,concatenateNalData:wi,generateSampleTableForFrame:Dt,concatenateNalDataForFrame:Ot},jt=[33,16,5,32,164,27],Pn=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],pe=function(o){for(var u=[];o--;)u.push(0);return u},ia=function(o){return Object.keys(o).reduce(function(u,d){return u[d]=new Uint8Array(o[d].reduce(function(h,g){return h.concat(g)},[])),u},{})},Ln,Es=function(){if(!Ln){var o={96e3:[jt,[227,64],pe(154),[56]],88200:[jt,[231],pe(170),[56]],64e3:[jt,[248,192],pe(240),[56]],48e3:[jt,[255,192],pe(268),[55,148,128],pe(54),[112]],44100:[jt,[255,192],pe(268),[55,163,128],pe(84),[112]],32e3:[jt,[255,192],pe(268),[55,234],pe(226),[112]],24e3:[jt,[255,192],pe(268),[55,255,128],pe(268),[111,112],pe(126),[224]],16e3:[jt,[255,192],pe(268),[55,255,128],pe(268),[111,255],pe(269),[223,108],pe(195),[1,192]],12e3:[Pn,pe(268),[3,127,248],pe(268),[6,255,240],pe(268),[13,255,224],pe(268),[27,253,128],pe(259),[56]],11025:[Pn,pe(268),[3,127,248],pe(268),[6,255,240],pe(268),[13,255,224],pe(268),[27,255,192],pe(268),[55,175,128],pe(108),[112]],8e3:[Pn,pe(268),[3,121,16],pe(47),[7]]};Ln=ia(o)}return Ln},di=9e4,ut,Ci,zi,wt,ws,p,_;ut=function(o){return o*di},Ci=function(o,u){return o*u},zi=function(o){return o/di},wt=function(o,u){return o/u},ws=function(o,u){return ut(wt(o,u))},p=function(o,u){return Ci(zi(o),u)},_=function(o,u,d){return zi(d?o:o-u)};var T={ONE_SECOND_IN_TS:di,secondsToVideoTs:ut,secondsToAudioTs:Ci,videoTsToSeconds:zi,audioTsToSeconds:wt,audioTsToVideoTs:ws,videoTsToAudioTs:p,metadataTsToSeconds:_},L=Es,U=T,q=function(o){var u,d,h=0;for(u=0;u<o.length;u++)d=o[u],h+=d.data.byteLength;return h},K=function(o,u,d,h){var g,y=0,S=0,E=0,k=0,I,O,j;if(u.length&&(g=U.audioTsToVideoTs(o.baseMediaDecodeTime,o.samplerate),y=Math.ceil(U.ONE_SECOND_IN_TS/(o.samplerate/1024)),d&&h&&(S=g-Math.max(d,h),E=Math.floor(S/y),k=E*y),!(E<1||k>U.ONE_SECOND_IN_TS/2))){for(I=L()[o.samplerate],I||(I=u[0].data),O=0;O<E;O++)j=u[0],u.splice(0,0,{data:I,dts:j.dts-y,pts:j.pts-y});return o.baseMediaDecodeTime-=Math.floor(U.videoTsToAudioTs(k,o.samplerate)),k}},Se=function(o,u,d){return u.minSegmentDts>=d?o:(u.minSegmentDts=1/0,o.filter(function(h){return h.dts>=d?(u.minSegmentDts=Math.min(u.minSegmentDts,h.dts),u.minSegmentPts=u.minSegmentDts,!0):!1}))},Ve=function(o){var u,d,h=[];for(u=0;u<o.length;u++)d=o[u],h.push({size:d.data.byteLength,duration:1024});return h},ke=function(o){var u,d,h=0,g=new Uint8Array(q(o));for(u=0;u<o.length;u++)d=o[u],g.set(d.data,h),h+=d.data.byteLength;return g},Te={prefixWithSilence:K,trimAdtsFramesByEarliestDts:Se,generateSampleTable:Ve,concatenateFrameData:ke},Ue=T.ONE_SECOND_IN_TS,zp=function(o,u){typeof u.pts=="number"&&(o.timelineStartInfo.pts===void 0&&(o.timelineStartInfo.pts=u.pts),o.minSegmentPts===void 0?o.minSegmentPts=u.pts:o.minSegmentPts=Math.min(o.minSegmentPts,u.pts),o.maxSegmentPts===void 0?o.maxSegmentPts=u.pts:o.maxSegmentPts=Math.max(o.maxSegmentPts,u.pts)),typeof u.dts=="number"&&(o.timelineStartInfo.dts===void 0&&(o.timelineStartInfo.dts=u.dts),o.minSegmentDts===void 0?o.minSegmentDts=u.dts:o.minSegmentDts=Math.min(o.minSegmentDts,u.dts),o.maxSegmentDts===void 0?o.maxSegmentDts=u.dts:o.maxSegmentDts=Math.max(o.maxSegmentDts,u.dts))},Wp=function(o){delete o.minSegmentDts,delete o.maxSegmentDts,delete o.minSegmentPts,delete o.maxSegmentPts},Gp=function(o,u){var d,h,g=o.minSegmentDts;return u||(g-=o.timelineStartInfo.dts),d=o.timelineStartInfo.baseMediaDecodeTime,d+=g,d=Math.max(0,d),o.type==="audio"&&(h=o.samplerate/Ue,d*=h,d=Math.floor(d)),d},Xp={clearDtsInfo:Wp,calculateTrackBaseMediaDecodeTime:Gp,collectDtsInfo:zp},gl=4,Kp=128,Yp=function(o){for(var u=0,d={payloadType:-1,payloadSize:0},h=0,g=0;u<o.byteLength&&o[u]!==Kp;){for(;o[u]===255;)h+=255,u++;for(h+=o[u++];o[u]===255;)g+=255,u++;if(g+=o[u++],!d.payload&&h===gl){var y=String.fromCharCode(o[u+3],o[u+4],o[u+5],o[u+6]);if(y==="GA94"){d.payloadType=h,d.payloadSize=g,d.payload=o.subarray(u,u+g);break}else d.payload=void 0}u+=g,h=0,g=0}return d},Qp=function(o){return o.payload[0]!==181||(o.payload[1]<<8|o.payload[2])!==49||String.fromCharCode(o.payload[3],o.payload[4],o.payload[5],o.payload[6])!=="GA94"||o.payload[7]!==3?null:o.payload.subarray(8,o.payload.length-1)},Jp=function(o,u){var d=[],h,g,y,S;if(!(u[0]&64))return d;for(g=u[0]&31,h=0;h<g;h++)y=h*3,S={type:u[y+2]&3,pts:o},u[y+2]&4&&(S.ccData=u[y+3]<<8|u[y+4],d.push(S));return d},Zp=function(o){for(var u=o.byteLength,d=[],h=1,g,y;h<u-2;)o[h]===0&&o[h+1]===0&&o[h+2]===3?(d.push(h+2),h+=2):h++;if(d.length===0)return o;g=u-d.length,y=new Uint8Array(g);var S=0;for(h=0;h<g;S++,h++)S===d[0]&&(S++,d.shift()),y[h]=o[S];return y},fl={parseSei:Yp,parseUserData:Qp,parseCaptionPackets:Jp,discardEmulationPreventionBytes:Zp,USER_DATA_REGISTERED_ITU_T_T35:gl},na=t,ks=fl,dt=function(o){o=o||{},dt.prototype.init.call(this),this.parse708captions_=typeof o.parse708captions=="boolean"?o.parse708captions:!0,this.captionPackets_=[],this.ccStreams_=[new Pe(0,0),new Pe(0,1),new Pe(1,0),new Pe(1,1)],this.parse708captions_&&(this.cc708Stream_=new Ee({captionServices:o.captionServices})),this.reset(),this.ccStreams_.forEach(function(u){u.on("data",this.trigger.bind(this,"data")),u.on("partialdone",this.trigger.bind(this,"partialdone")),u.on("done",this.trigger.bind(this,"done"))},this),this.parse708captions_&&(this.cc708Stream_.on("data",this.trigger.bind(this,"data")),this.cc708Stream_.on("partialdone",this.trigger.bind(this,"partialdone")),this.cc708Stream_.on("done",this.trigger.bind(this,"done")))};dt.prototype=new na,dt.prototype.push=function(o){var u,d,h;if(o.nalUnitType==="sei_rbsp"&&(u=ks.parseSei(o.escapedRBSP),!!u.payload&&u.payloadType===ks.USER_DATA_REGISTERED_ITU_T_T35&&(d=ks.parseUserData(u),!!d))){if(o.dts<this.latestDts_){this.ignoreNextEqualDts_=!0;return}else if(o.dts===this.latestDts_&&this.ignoreNextEqualDts_){this.numSameDts_--,this.numSameDts_||(this.ignoreNextEqualDts_=!1);return}h=ks.parseCaptionPackets(o.pts,d),this.captionPackets_=this.captionPackets_.concat(h),this.latestDts_!==o.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=o.dts}},dt.prototype.flushCCStreams=function(o){this.ccStreams_.forEach(function(u){return o==="flush"?u.flush():u.partialFlush()},this)},dt.prototype.flushStream=function(o){if(!this.captionPackets_.length){this.flushCCStreams(o);return}this.captionPackets_.forEach(function(u,d){u.presortIndex=d}),this.captionPackets_.sort(function(u,d){return u.pts===d.pts?u.presortIndex-d.presortIndex:u.pts-d.pts}),this.captionPackets_.forEach(function(u){u.type<2?this.dispatchCea608Packet(u):this.dispatchCea708Packet(u)},this),this.captionPackets_.length=0,this.flushCCStreams(o)},dt.prototype.flush=function(){return this.flushStream("flush")},dt.prototype.partialFlush=function(){return this.flushStream("partialFlush")},dt.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(o){o.reset()})},dt.prototype.dispatchCea608Packet=function(o){this.setsTextOrXDSActive(o)?this.activeCea608Channel_[o.type]=null:this.setsChannel1Active(o)?this.activeCea608Channel_[o.type]=0:this.setsChannel2Active(o)&&(this.activeCea608Channel_[o.type]=1),this.activeCea608Channel_[o.type]!==null&&this.ccStreams_[(o.type<<1)+this.activeCea608Channel_[o.type]].push(o)},dt.prototype.setsChannel1Active=function(o){return(o.ccData&30720)===4096},dt.prototype.setsChannel2Active=function(o){return(o.ccData&30720)===6144},dt.prototype.setsTextOrXDSActive=function(o){return(o.ccData&28928)===256||(o.ccData&30974)===4138||(o.ccData&30974)===6186},dt.prototype.dispatchCea708Packet=function(o){this.parse708captions_&&this.cc708Stream_.push(o)};var eg={127:9834,4128:32,4129:160,4133:8230,4138:352,4140:338,4144:9608,4145:8216,4146:8217,4147:8220,4148:8221,4149:8226,4153:8482,4154:353,4156:339,4157:8480,4159:376,4214:8539,4215:8540,4216:8541,4217:8542,4218:9168,4219:9124,4220:9123,4221:9135,4222:9126,4223:9121,4256:12600},tg=function(o){var u=eg[o]||o;return o&4096&&o===u?"":String.fromCharCode(u)},Cs=function(o){return 32<=o&&o<=127||160<=o&&o<=255},ei=function(o){this.windowNum=o,this.reset()};ei.prototype.reset=function(){this.clearText(),this.pendingNewLine=!1,this.winAttr={},this.penAttr={},this.penLoc={},this.penColor={},this.visible=0,this.rowLock=0,this.columnLock=0,this.priority=0,this.relativePositioning=0,this.anchorVertical=0,this.anchorHorizontal=0,this.anchorPoint=0,this.rowCount=1,this.virtualRowCount=this.rowCount+1,this.columnCount=41,this.windowStyle=0,this.penStyle=0},ei.prototype.getText=function(){return this.rows.join(`
|
|
193
|
+
`)},ei.prototype.clearText=function(){this.rows=[""],this.rowIdx=0},ei.prototype.newLine=function(o){for(this.rows.length>=this.virtualRowCount&&typeof this.beforeRowOverflow=="function"&&this.beforeRowOverflow(o),this.rows.length>0&&(this.rows.push(""),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--},ei.prototype.isEmpty=function(){return this.rows.length===0?!0:this.rows.length===1?this.rows[0]==="":!1},ei.prototype.addText=function(o){this.rows[this.rowIdx]+=o},ei.prototype.backspace=function(){if(!this.isEmpty()){var o=this.rows[this.rowIdx];this.rows[this.rowIdx]=o.substr(0,o.length-1)}};var Is=function(o,u,d){this.serviceNum=o,this.text="",this.currentWindow=new ei(-1),this.windows=[],this.stream=d,typeof u=="string"&&this.createTextDecoder(u)};Is.prototype.init=function(o,u){this.startPts=o;for(var d=0;d<8;d++)this.windows[d]=new ei(d),typeof u=="function"&&(this.windows[d].beforeRowOverflow=u)},Is.prototype.setCurrentWindow=function(o){this.currentWindow=this.windows[o]},Is.prototype.createTextDecoder=function(o){if(typeof TextDecoder>"u")this.stream.trigger("log",{level:"warn",message:"The `encoding` option is unsupported without TextDecoder support"});else try{this.textDecoder_=new TextDecoder(o)}catch(u){this.stream.trigger("log",{level:"warn",message:"TextDecoder could not be created with "+o+" encoding. "+u})}};var Ee=function(o){o=o||{},Ee.prototype.init.call(this);var u=this,d=o.captionServices||{},h={},g;Object.keys(d).forEach(y=>{g=d[y],/^SERVICE/.test(y)&&(h[y]=g.encoding)}),this.serviceEncodings=h,this.current708Packet=null,this.services={},this.push=function(y){y.type===3?(u.new708Packet(),u.add708Bytes(y)):(u.current708Packet===null&&u.new708Packet(),u.add708Bytes(y))}};Ee.prototype=new na,Ee.prototype.new708Packet=function(){this.current708Packet!==null&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]}},Ee.prototype.add708Bytes=function(o){var u=o.ccData,d=u>>>8,h=u&255;this.current708Packet.ptsVals.push(o.pts),this.current708Packet.data.push(d),this.current708Packet.data.push(h)},Ee.prototype.push708Packet=function(){var o=this.current708Packet,u=o.data,d=null,h=null,g=0,y=u[g++];for(o.seq=y>>6,o.sizeCode=y&63;g<u.length;g++)y=u[g++],d=y>>5,h=y&31,d===7&&h>0&&(y=u[g++],d=y),this.pushServiceBlock(d,g,h),h>0&&(g+=h-1)},Ee.prototype.pushServiceBlock=function(o,u,d){var h,g=u,y=this.current708Packet.data,S=this.services[o];for(S||(S=this.initService(o,g));g<u+d&&g<y.length;g++)h=y[g],Cs(h)?g=this.handleText(g,S):h===24?g=this.multiByteCharacter(g,S):h===16?g=this.extendedCommands(g,S):128<=h&&h<=135?g=this.setCurrentWindow(g,S):152<=h&&h<=159?g=this.defineWindow(g,S):h===136?g=this.clearWindows(g,S):h===140?g=this.deleteWindows(g,S):h===137?g=this.displayWindows(g,S):h===138?g=this.hideWindows(g,S):h===139?g=this.toggleWindows(g,S):h===151?g=this.setWindowAttributes(g,S):h===144?g=this.setPenAttributes(g,S):h===145?g=this.setPenColor(g,S):h===146?g=this.setPenLocation(g,S):h===143?S=this.reset(g,S):h===8?S.currentWindow.backspace():h===12?S.currentWindow.clearText():h===13?S.currentWindow.pendingNewLine=!0:h===14?S.currentWindow.clearText():h===141&&g++},Ee.prototype.extendedCommands=function(o,u){var d=this.current708Packet.data,h=d[++o];return Cs(h)&&(o=this.handleText(o,u,{isExtended:!0})),o},Ee.prototype.getPts=function(o){return this.current708Packet.ptsVals[Math.floor(o/2)]},Ee.prototype.initService=function(o,u){var h="SERVICE"+o,d=this,h,g;return h in this.serviceEncodings&&(g=this.serviceEncodings[h]),this.services[o]=new Is(o,g,d),this.services[o].init(this.getPts(u),function(y){d.flushDisplayed(y,d.services[o])}),this.services[o]},Ee.prototype.handleText=function(o,u,d){var h=d&&d.isExtended,g=d&&d.isMultiByte,y=this.current708Packet.data,S=h?4096:0,E=y[o],k=y[o+1],I=u.currentWindow,O,j;function Q(V){return V.map(te=>("0"+(te&255).toString(16)).slice(-2)).join("")}if(g?(j=[E,k],o++):j=[E],u.textDecoder_&&!h)O=u.textDecoder_.decode(new Uint8Array(j));else if(g){const V=Q(j);O=String.fromCharCode(parseInt(V,16))}else O=tg(S|E);return I.pendingNewLine&&!I.isEmpty()&&I.newLine(this.getPts(o)),I.pendingNewLine=!1,I.addText(O),o},Ee.prototype.multiByteCharacter=function(o,u){var d=this.current708Packet.data,h=d[o+1],g=d[o+2];return Cs(h)&&Cs(g)&&(o=this.handleText(++o,u,{isMultiByte:!0})),o},Ee.prototype.setCurrentWindow=function(o,u){var d=this.current708Packet.data,h=d[o],g=h&7;return u.setCurrentWindow(g),o},Ee.prototype.defineWindow=function(o,u){var d=this.current708Packet.data,h=d[o],g=h&7;u.setCurrentWindow(g);var y=u.currentWindow;return h=d[++o],y.visible=(h&32)>>5,y.rowLock=(h&16)>>4,y.columnLock=(h&8)>>3,y.priority=h&7,h=d[++o],y.relativePositioning=(h&128)>>7,y.anchorVertical=h&127,h=d[++o],y.anchorHorizontal=h,h=d[++o],y.anchorPoint=(h&240)>>4,y.rowCount=h&15,h=d[++o],y.columnCount=h&63,h=d[++o],y.windowStyle=(h&56)>>3,y.penStyle=h&7,y.virtualRowCount=y.rowCount+1,o},Ee.prototype.setWindowAttributes=function(o,u){var d=this.current708Packet.data,h=d[o],g=u.currentWindow.winAttr;return h=d[++o],g.fillOpacity=(h&192)>>6,g.fillRed=(h&48)>>4,g.fillGreen=(h&12)>>2,g.fillBlue=h&3,h=d[++o],g.borderType=(h&192)>>6,g.borderRed=(h&48)>>4,g.borderGreen=(h&12)>>2,g.borderBlue=h&3,h=d[++o],g.borderType+=(h&128)>>5,g.wordWrap=(h&64)>>6,g.printDirection=(h&48)>>4,g.scrollDirection=(h&12)>>2,g.justify=h&3,h=d[++o],g.effectSpeed=(h&240)>>4,g.effectDirection=(h&12)>>2,g.displayEffect=h&3,o},Ee.prototype.flushDisplayed=function(o,u){for(var d=[],h=0;h<8;h++)u.windows[h].visible&&!u.windows[h].isEmpty()&&d.push(u.windows[h].getText());u.endPts=o,u.text=d.join(`
|
|
194
194
|
|
|
195
|
-
`),this.pushCaption(u),u.startPts=o},Ee.prototype.pushCaption=function(o){o.text!==""&&(this.trigger("data",{startPts:o.startPts,endPts:o.endPts,text:o.text,stream:"cc708_"+o.serviceNum}),o.text="",o.startPts=o.endPts)},Ee.prototype.displayWindows=function(o,u){var d=this.current708Packet.data,h=d[++o],f=this.getPts(o);this.flushDisplayed(f,u);for(var y=0;y<8;y++)h&1<<y&&(u.windows[y].visible=1);return o},Ee.prototype.hideWindows=function(o,u){var d=this.current708Packet.data,h=d[++o],f=this.getPts(o);this.flushDisplayed(f,u);for(var y=0;y<8;y++)h&1<<y&&(u.windows[y].visible=0);return o},Ee.prototype.toggleWindows=function(o,u){var d=this.current708Packet.data,h=d[++o],f=this.getPts(o);this.flushDisplayed(f,u);for(var y=0;y<8;y++)h&1<<y&&(u.windows[y].visible^=1);return o},Ee.prototype.clearWindows=function(o,u){var d=this.current708Packet.data,h=d[++o],f=this.getPts(o);this.flushDisplayed(f,u);for(var y=0;y<8;y++)h&1<<y&&u.windows[y].clearText();return o},Ee.prototype.deleteWindows=function(o,u){var d=this.current708Packet.data,h=d[++o],f=this.getPts(o);this.flushDisplayed(f,u);for(var y=0;y<8;y++)h&1<<y&&u.windows[y].reset();return o},Ee.prototype.setPenAttributes=function(o,u){var d=this.current708Packet.data,h=d[o],f=u.currentWindow.penAttr;return h=d[++o],f.textTag=(h&240)>>4,f.offset=(h&12)>>2,f.penSize=h&3,h=d[++o],f.italics=(h&128)>>7,f.underline=(h&64)>>6,f.edgeType=(h&56)>>3,f.fontStyle=h&7,o},Ee.prototype.setPenColor=function(o,u){var d=this.current708Packet.data,h=d[o],f=u.currentWindow.penColor;return h=d[++o],f.fgOpacity=(h&192)>>6,f.fgRed=(h&48)>>4,f.fgGreen=(h&12)>>2,f.fgBlue=h&3,h=d[++o],f.bgOpacity=(h&192)>>6,f.bgRed=(h&48)>>4,f.bgGreen=(h&12)>>2,f.bgBlue=h&3,h=d[++o],f.edgeRed=(h&48)>>4,f.edgeGreen=(h&12)>>2,f.edgeBlue=h&3,o},Ee.prototype.setPenLocation=function(o,u){var d=this.current708Packet.data,h=d[o],f=u.currentWindow.penLoc;return u.currentWindow.pendingNewLine=!0,h=d[++o],f.row=h&15,h=d[++o],f.column=h&63,o},Ee.prototype.reset=function(o,u){var d=this.getPts(o);return this.flushDisplayed(d,u),this.initService(u.serviceNum,o)};var af={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},Is=function(o){return o===null?"":(o=af[o]||o,String.fromCharCode(o))},xs=14,of=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],Ii=function(){for(var o=[],u=xs+1;u--;)o.push({text:"",indent:0,offset:0});return o},Pe=function(o,u){Pe.prototype.init.call(this),this.field_=o||0,this.dataChannel_=u||0,this.name_="CC"+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(d){var h,f,y,S,E;if(h=d.ccData&32639,h===this.lastControlCode_){this.lastControlCode_=null;return}if((h&61440)===4096?this.lastControlCode_=h:h!==this.PADDING_&&(this.lastControlCode_=null),y=h>>>8,S=h&255,h!==this.PADDING_)if(h===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(h===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(d.pts),this.flushDisplayed(d.pts),f=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=f,this.startPts_=d.pts;else if(h===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(d.pts);else if(h===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(d.pts);else if(h===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(d.pts);else if(h===this.CARRIAGE_RETURN_)this.clearFormatting(d.pts),this.flushDisplayed(d.pts),this.shiftRowsUp_(),this.startPts_=d.pts;else if(h===this.BACKSPACE_)this.mode_==="popOn"?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1);else if(h===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(d.pts),this.displayed_=Ii();else if(h===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Ii();else if(h===this.RESUME_DIRECT_CAPTIONING_)this.mode_!=="paintOn"&&(this.flushDisplayed(d.pts),this.displayed_=Ii()),this.mode_="paintOn",this.startPts_=d.pts;else if(this.isSpecialCharacter(y,S))y=(y&3)<<8,E=Is(y|S),this[this.mode_](d.pts,E),this.column_++;else if(this.isExtCharacter(y,S))this.mode_==="popOn"?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1),y=(y&3)<<8,E=Is(y|S),this[this.mode_](d.pts,E),this.column_++;else if(this.isMidRowCode(y,S))this.clearFormatting(d.pts),this[this.mode_](d.pts," "),this.column_++,(S&14)===14&&this.addFormatting(d.pts,["i"]),(S&1)===1&&this.addFormatting(d.pts,["u"]);else if(this.isOffsetControlCode(y,S)){const I=S&3;this.nonDisplayed_[this.row_].offset=I,this.column_+=I}else if(this.isPAC(y,S)){var k=of.indexOf(h&7968);if(this.mode_==="rollUp"&&(k-this.rollUpRows_+1<0&&(k=this.rollUpRows_-1),this.setRollUp(d.pts,k)),k!==this.row_&&k>=0&&k<=14&&(this.clearFormatting(d.pts),this.row_=k),S&1&&this.formatting_.indexOf("u")===-1&&this.addFormatting(d.pts,["u"]),(h&16)===16){const I=(h&14)>>1;this.column_=I*4,this.nonDisplayed_[this.row_].indent+=I}this.isColorPAC(S)&&(S&14)===14&&this.addFormatting(d.pts,["i"])}else this.isNormalChar(y)&&(S===0&&(S=null),E=Is(y),E+=Is(S),this[this.mode_](d.pts,E),this.column_+=E.length)}};Pe.prototype=new na,Pe.prototype.flushDisplayed=function(o){const u=h=>{this.trigger("log",{level:"warn",message:"Skipping a malformed 608 caption at index "+h+"."})},d=[];this.displayed_.forEach((h,f)=>{if(h&&h.text&&h.text.length){try{h.text=h.text.trim()}catch{u(f)}h.text.length&&d.push({text:h.text,line:f+1,position:10+Math.min(70,h.indent*10)+h.offset*2.5})}else h==null&&u(f)}),d.length&&this.trigger("data",{startPts:this.startPts_,endPts:o,content:d,stream:this.name_})},Pe.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=Ii(),this.nonDisplayed_=Ii(),this.lastControlCode_=null,this.column_=0,this.row_=xs,this.rollUpRows_=2,this.formatting_=[]},Pe.prototype.setConstants=function(){this.dataChannel_===0?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):this.dataChannel_===1&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=this.CONTROL_|32,this.END_OF_CAPTION_=this.CONTROL_|47,this.ROLL_UP_2_ROWS_=this.CONTROL_|37,this.ROLL_UP_3_ROWS_=this.CONTROL_|38,this.ROLL_UP_4_ROWS_=this.CONTROL_|39,this.CARRIAGE_RETURN_=this.CONTROL_|45,this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41,this.BACKSPACE_=this.CONTROL_|33,this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44,this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46},Pe.prototype.isSpecialCharacter=function(o,u){return o===this.EXT_&&u>=48&&u<=63},Pe.prototype.isExtCharacter=function(o,u){return(o===this.EXT_+1||o===this.EXT_+2)&&u>=32&&u<=63},Pe.prototype.isMidRowCode=function(o,u){return o===this.EXT_&&u>=32&&u<=47},Pe.prototype.isOffsetControlCode=function(o,u){return o===this.OFFSET_&&u>=33&&u<=35},Pe.prototype.isPAC=function(o,u){return o>=this.BASE_&&o<this.BASE_+8&&u>=64&&u<=127},Pe.prototype.isColorPAC=function(o){return o>=64&&o<=79||o>=96&&o<=127},Pe.prototype.isNormalChar=function(o){return o>=32&&o<=127},Pe.prototype.setRollUp=function(o,u){if(this.mode_!=="rollUp"&&(this.row_=xs,this.mode_="rollUp",this.flushDisplayed(o),this.nonDisplayed_=Ii(),this.displayed_=Ii()),u!==void 0&&u!==this.row_)for(var d=0;d<this.rollUpRows_;d++)this.displayed_[u-d]=this.displayed_[this.row_-d],this.displayed_[this.row_-d]={text:"",indent:0,offset:0};u===void 0&&(u=this.row_),this.topRow_=u-this.rollUpRows_+1},Pe.prototype.addFormatting=function(o,u){this.formatting_=this.formatting_.concat(u);var d=u.reduce(function(h,f){return h+"<"+f+">"},"");this[this.mode_](o,d)},Pe.prototype.clearFormatting=function(o){if(this.formatting_.length){var u=this.formatting_.reverse().reduce(function(d,h){return d+"</"+h+">"},"");this.formatting_=[],this[this.mode_](o,u)}},Pe.prototype.popOn=function(o,u){var d=this.nonDisplayed_[this.row_].text;d+=u,this.nonDisplayed_[this.row_].text=d},Pe.prototype.rollUp=function(o,u){var d=this.displayed_[this.row_].text;d+=u,this.displayed_[this.row_].text=d},Pe.prototype.shiftRowsUp_=function(){var o;for(o=0;o<this.topRow_;o++)this.displayed_[o]={text:"",indent:0,offset:0};for(o=this.row_+1;o<xs+1;o++)this.displayed_[o]={text:"",indent:0,offset:0};for(o=this.topRow_;o<this.row_;o++)this.displayed_[o]=this.displayed_[o+1];this.displayed_[this.row_]={text:"",indent:0,offset:0}},Pe.prototype.paintOn=function(o,u){var d=this.displayed_[this.row_].text;d+=u,this.displayed_[this.row_].text=d};var yl={CaptionStream:dt,Cea608Stream:Pe,Cea708Stream:Ee},As={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},lf=t,uf=8589934592,df=4294967296,_l="shared",sa=function(o,u){var d=1;for(o>u&&(d=-1);Math.abs(u-o)>df;)o+=d*uf;return o},ra=function(o){var u,d;ra.prototype.init.call(this),this.type_=o||_l,this.push=function(h){if(h.type==="metadata"){this.trigger("data",h);return}this.type_!==_l&&h.type!==this.type_||(d===void 0&&(d=h.dts),h.dts=sa(h.dts,d),h.pts=sa(h.pts,d),u=h.dts,this.trigger("data",h))},this.flush=function(){d=u,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){d=void 0,u=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};ra.prototype=new lf;var bl={TimestampRolloverStream:ra,handleRollover:sa},hf=(o,u,d)=>{if(!o)return-1;for(var h=d;h<o.length;h++)if(o[h]===u)return h;return-1},cf={typedArrayIndexOf:hf},Ps=cf.typedArrayIndexOf,Ls={Iso88591:0,Utf16:1,Utf16be:2,Utf8:3},Tl=function(o,u,d){var h,f="";for(h=u;h<d;h++)f+="%"+("00"+o[h].toString(16)).slice(-2);return f},Dn=function(o,u,d){return decodeURIComponent(Tl(o,u,d))},On=function(o,u,d){return unescape(Tl(o,u,d))},Mn=function(o){return o[0]<<21|o[1]<<14|o[2]<<7|o[3]},Rn={APIC:function(o){var u=1,d,h,f="-->";o.data[0]===Ls.Utf8&&(d=Ps(o.data,0,u),!(d<0)&&(o.mimeType=On(o.data,u,d),u=d+1,o.pictureType=o.data[u],u++,h=Ps(o.data,0,u),!(h<0)&&(o.description=Dn(o.data,u,h),u=h+1,o.mimeType===f?o.url=On(o.data,u,o.data.length):o.pictureData=o.data.subarray(u,o.data.length))))},"T*":function(o){o.data[0]===Ls.Utf8&&(o.value=Dn(o.data,1,o.data.length).replace(/\0*$/,""),o.values=o.value.split("\0"))},TXXX:function(o){var u;o.data[0]===Ls.Utf8&&(u=Ps(o.data,0,1),u!==-1&&(o.description=Dn(o.data,1,u),o.value=Dn(o.data,u+1,o.data.length).replace(/\0*$/,""),o.data=o.value))},"W*":function(o){o.url=On(o.data,0,o.data.length).replace(/\0.*$/,"")},WXXX:function(o){var u;o.data[0]===Ls.Utf8&&(u=Ps(o.data,0,1),u!==-1&&(o.description=Dn(o.data,1,u),o.url=On(o.data,u+1,o.data.length).replace(/\0.*$/,"")))},PRIV:function(o){var u;for(u=0;u<o.data.length;u++)if(o.data[u]===0){o.owner=On(o.data,0,u);break}o.privateData=o.data.subarray(u+1),o.data=o.privateData}},pf=function(o){var u,d,h=10,f=0,y=[];if(!(o.length<10||o[0]!==73||o[1]!==68||o[2]!==51)){f=Mn(o.subarray(6,10)),f+=10;var S=o[5]&64;S&&(h+=4,h+=Mn(o.subarray(10,14)),f-=Mn(o.subarray(16,20)));do{if(u=Mn(o.subarray(h+4,h+8)),u<1)break;d=String.fromCharCode(o[h],o[h+1],o[h+2],o[h+3]);var E={id:d,data:o.subarray(h+10,h+u+10)};E.key=E.id,Rn[E.id]?Rn[E.id](E):E.id[0]==="T"?Rn["T*"](E):E.id[0]==="W"&&Rn["W*"](E),y.push(E),h+=10,h+=u}while(h<f);return y}},vl={parseId3Frames:pf,parseSyncSafeInteger:Mn,frameParsers:Rn},ff=t,gf=As,hi=vl,Ds;Ds=function(o){var u={descriptor:o&&o.descriptor},d=0,h=[],f=0,y;if(Ds.prototype.init.call(this),this.dispatchType=gf.METADATA_STREAM_TYPE.toString(16),u.descriptor)for(y=0;y<u.descriptor.length;y++)this.dispatchType+=("00"+u.descriptor[y].toString(16)).slice(-2);this.push=function(S){var E,k,I,O,j,Q;if(S.type==="timed-metadata"){if(S.dataAlignmentIndicator&&(f=0,h.length=0),h.length===0&&(S.data.length<10||S.data[0]!==73||S.data[1]!==68||S.data[2]!==51)){this.trigger("log",{level:"warn",message:"Skipping unrecognized metadata packet"});return}if(h.push(S),f+=S.data.byteLength,h.length===1&&(d=hi.parseSyncSafeInteger(S.data.subarray(6,10)),d+=10),!(f<d)){for(E={data:new Uint8Array(d),frames:[],pts:h[0].pts,dts:h[0].dts},j=0;j<d;)E.data.set(h[0].data.subarray(0,d-j),j),j+=h[0].data.byteLength,f-=h[0].data.byteLength,h.shift();k=10,E.data[5]&64&&(k+=4,k+=hi.parseSyncSafeInteger(E.data.subarray(10,14)),d-=hi.parseSyncSafeInteger(E.data.subarray(16,20)));do{if(I=hi.parseSyncSafeInteger(E.data.subarray(k+4,k+8)),I<1){this.trigger("log",{level:"warn",message:"Malformed ID3 frame encountered. Skipping remaining metadata parsing."});break}if(Q=String.fromCharCode(E.data[k],E.data[k+1],E.data[k+2],E.data[k+3]),O={id:Q,data:E.data.subarray(k+10,k+I+10)},O.key=O.id,hi.frameParsers[O.id]?hi.frameParsers[O.id](O):O.id[0]==="T"?hi.frameParsers["T*"](O):O.id[0]==="W"&&hi.frameParsers["W*"](O),O.owner==="com.apple.streaming.transportStreamTimestamp"){var V=O.data,te=(V[3]&1)<<30|V[4]<<22|V[5]<<14|V[6]<<6|V[7]>>>2;te*=4,te+=V[7]&3,O.timeStamp=te,E.pts===void 0&&E.dts===void 0&&(E.pts=O.timeStamp,E.dts=O.timeStamp),this.trigger("timestamp",O)}E.frames.push(O),k+=10,k+=I}while(k<d);this.trigger("data",E)}}}},Ds.prototype=new ff;var mf=Ds,aa=t,oa=yl,Mt=As,yf=bl.TimestampRolloverStream,Os,Un,Ms,Wi=188,la=71;Os=function(){var o=new Uint8Array(Wi),u=0;Os.prototype.init.call(this),this.push=function(d){var h=0,f=Wi,y;for(u?(y=new Uint8Array(d.byteLength+u),y.set(o.subarray(0,u)),y.set(d,u),u=0):y=d;f<y.byteLength;){if(y[h]===la&&y[f]===la){this.trigger("data",y.subarray(h,f)),h+=Wi,f+=Wi;continue}h++,f++}h<y.byteLength&&(o.set(y.subarray(h),0),u=y.byteLength-h)},this.flush=function(){u===Wi&&o[0]===la&&(this.trigger("data",o),u=0),this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){u=0,this.trigger("reset")}},Os.prototype=new aa,Un=function(){var o,u,d,h;Un.prototype.init.call(this),h=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,o=function(f,y){var S=0;y.payloadUnitStartIndicator&&(S+=f[S]+1),y.type==="pat"?u(f.subarray(S),y):d(f.subarray(S),y)},u=function(f,y){y.section_number=f[7],y.last_section_number=f[8],h.pmtPid=(f[10]&31)<<8|f[11],y.pmtPid=h.pmtPid},d=function(f,y){var S,E,k,I;if(f[5]&1){for(h.programMapTable={video:null,audio:null,"timed-metadata":{}},S=(f[1]&15)<<8|f[2],E=3+S-4,k=(f[10]&15)<<8|f[11],I=12+k;I<E;){var O=f[I],j=(f[I+1]&31)<<8|f[I+2];O===Mt.H264_STREAM_TYPE&&h.programMapTable.video===null?h.programMapTable.video=j:O===Mt.ADTS_STREAM_TYPE&&h.programMapTable.audio===null?h.programMapTable.audio=j:O===Mt.METADATA_STREAM_TYPE&&(h.programMapTable["timed-metadata"][j]=O),I+=((f[I+3]&15)<<8|f[I+4])+5}y.programMapTable=h.programMapTable}},this.push=function(f){var y={},S=4;if(y.payloadUnitStartIndicator=!!(f[1]&64),y.pid=f[1]&31,y.pid<<=8,y.pid|=f[2],(f[3]&48)>>>4>1&&(S+=f[S]+1),y.pid===0)y.type="pat",o(f.subarray(S),y),this.trigger("data",y);else if(y.pid===this.pmtPid)for(y.type="pmt",o(f.subarray(S),y),this.trigger("data",y);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([f,S,y]):this.processPes_(f,S,y)},this.processPes_=function(f,y,S){S.pid===this.programMapTable.video?S.streamType=Mt.H264_STREAM_TYPE:S.pid===this.programMapTable.audio?S.streamType=Mt.ADTS_STREAM_TYPE:S.streamType=this.programMapTable["timed-metadata"][S.pid],S.type="pes",S.data=f.subarray(y),this.trigger("data",S)}},Un.prototype=new aa,Un.STREAM_TYPES={h264:27,adts:15},Ms=function(){var o=this,u=!1,d={data:[],size:0},h={data:[],size:0},f={data:[],size:0},y,S=function(k,I){var O;const j=k[0]<<16|k[1]<<8|k[2];I.data=new Uint8Array,j===1&&(I.packetLength=6+(k[4]<<8|k[5]),I.dataAlignmentIndicator=(k[6]&4)!==0,O=k[7],O&192&&(I.pts=(k[9]&14)<<27|(k[10]&255)<<20|(k[11]&254)<<12|(k[12]&255)<<5|(k[13]&254)>>>3,I.pts*=4,I.pts+=(k[13]&6)>>>1,I.dts=I.pts,O&64&&(I.dts=(k[14]&14)<<27|(k[15]&255)<<20|(k[16]&254)<<12|(k[17]&255)<<5|(k[18]&254)>>>3,I.dts*=4,I.dts+=(k[18]&6)>>>1)),I.data=k.subarray(9+k[8]))},E=function(k,I,O){var j=new Uint8Array(k.size),Q={type:I},V=0,te=0,se=!1,ze;if(!(!k.data.length||k.size<9)){for(Q.trackId=k.data[0].pid,V=0;V<k.data.length;V++)ze=k.data[V],j.set(ze.data,te),te+=ze.data.byteLength;S(j,Q),se=I==="video"||Q.packetLength<=k.size,(O||se)&&(k.size=0,k.data.length=0),se&&o.trigger("data",Q)}};Ms.prototype.init.call(this),this.push=function(k){({pat:function(){},pes:function(){var I,O;switch(k.streamType){case Mt.H264_STREAM_TYPE:I=d,O="video";break;case Mt.ADTS_STREAM_TYPE:I=h,O="audio";break;case Mt.METADATA_STREAM_TYPE:I=f,O="timed-metadata";break;default:return}k.payloadUnitStartIndicator&&E(I,O,!0),I.data.push(k),I.size+=k.data.byteLength},pmt:function(){var I={type:"metadata",tracks:[]};y=k.programMapTable,y.video!==null&&I.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+y.video,codec:"avc",type:"video"}),y.audio!==null&&I.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+y.audio,codec:"adts",type:"audio"}),u=!0,o.trigger("data",I)}})[k.type]()},this.reset=function(){d.size=0,d.data.length=0,h.size=0,h.data.length=0,this.trigger("reset")},this.flushStreams_=function(){E(d,"video"),E(h,"audio"),E(f,"timed-metadata")},this.flush=function(){if(!u&&y){var k={type:"metadata",tracks:[]};y.video!==null&&k.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+y.video,codec:"avc",type:"video"}),y.audio!==null&&k.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+y.audio,codec:"adts",type:"audio"}),o.trigger("data",k)}u=!1,this.flushStreams_(),this.trigger("done")}},Ms.prototype=new aa;var Sl={PAT_PID:0,MP2T_PACKET_LENGTH:Wi,TransportPacketStream:Os,TransportParseStream:Un,ElementaryStream:Ms,TimestampRolloverStream:yf,CaptionStream:oa.CaptionStream,Cea608Stream:oa.Cea608Stream,Cea708Stream:oa.Cea708Stream,MetadataStream:mf};for(var ua in Mt)Mt.hasOwnProperty(ua)&&(Sl[ua]=Mt[ua]);var _f=Sl,bf=t,Tf=T.ONE_SECOND_IN_TS,Rs,El=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];Rs=function(o){var u,d=0;Rs.prototype.init.call(this),this.skipWarn_=function(h,f){this.trigger("log",{level:"warn",message:`adts skiping bytes ${h} to ${f} in frame ${d} outside syncword`})},this.push=function(h){var f=0,y,S,E,k,I;if(o||(d=0),h.type==="audio"){u&&u.length?(E=u,u=new Uint8Array(E.byteLength+h.data.byteLength),u.set(E),u.set(h.data,E.byteLength)):u=h.data;for(var O;f+7<u.length;){if(u[f]!==255||(u[f+1]&246)!==240){typeof O!="number"&&(O=f),f++;continue}if(typeof O=="number"&&(this.skipWarn_(O,f),O=null),S=(~u[f+1]&1)*2,y=(u[f+3]&3)<<11|u[f+4]<<3|(u[f+5]&224)>>5,k=((u[f+6]&3)+1)*1024,I=k*Tf/El[(u[f+2]&60)>>>2],u.byteLength-f<y)break;this.trigger("data",{pts:h.pts+d*I,dts:h.dts+d*I,sampleCount:k,audioobjecttype:(u[f+2]>>>6&3)+1,channelcount:(u[f+2]&1)<<2|(u[f+3]&192)>>>6,samplerate:El[(u[f+2]&60)>>>2],samplingfrequencyindex:(u[f+2]&60)>>>2,samplesize:16,data:u.subarray(f+7+S,f+y)}),d++,f+=y}typeof O=="number"&&(this.skipWarn_(O,f),O=null),u=u.subarray(f)}},this.flush=function(){d=0,this.trigger("done")},this.reset=function(){u=void 0,this.trigger("reset")},this.endTimeline=function(){u=void 0,this.trigger("endedtimeline")}},Rs.prototype=new bf;var vf=Rs,wl;wl=function(o){var u=o.byteLength,d=0,h=0;this.length=function(){return 8*u},this.bitsAvailable=function(){return 8*u+h},this.loadWord=function(){var f=o.byteLength-u,y=new Uint8Array(4),S=Math.min(4,u);if(S===0)throw new Error("no bytes available");y.set(o.subarray(f,f+S)),d=new DataView(y.buffer).getUint32(0),h=S*8,u-=S},this.skipBits=function(f){var y;h>f?(d<<=f,h-=f):(f-=h,y=Math.floor(f/8),f-=y*8,u-=y,this.loadWord(),d<<=f,h-=f)},this.readBits=function(f){var y=Math.min(h,f),S=d>>>32-y;return h-=y,h>0?d<<=y:u>0&&this.loadWord(),y=f-y,y>0?S<<y|this.readBits(y):S},this.skipLeadingZeros=function(){var f;for(f=0;f<h;++f)if(d&2147483648>>>f)return d<<=f,h-=f,f;return this.loadWord(),f+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var f=this.skipLeadingZeros();return this.readBits(f+1)-1},this.readExpGolomb=function(){var f=this.readUnsignedExpGolomb();return 1&f?1+f>>>1:-1*(f>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};var Sf=wl,kl=t,Ef=Sf,Us,Nn,Cl;Nn=function(){var o=0,u,d;Nn.prototype.init.call(this),this.push=function(h){var f;d?(f=new Uint8Array(d.byteLength+h.data.byteLength),f.set(d),f.set(h.data,d.byteLength),d=f):d=h.data;for(var y=d.byteLength;o<y-3;o++)if(d[o+2]===1){u=o+5;break}for(;u<y;)switch(d[u]){case 0:if(d[u-1]!==0){u+=2;break}else if(d[u-2]!==0){u++;break}o+3!==u-2&&this.trigger("data",d.subarray(o+3,u-2));do u++;while(d[u]!==1&&u<y);o=u-2,u+=3;break;case 1:if(d[u-1]!==0||d[u-2]!==0){u+=3;break}this.trigger("data",d.subarray(o+3,u-2)),o=u-2,u+=3;break;default:u+=3;break}d=d.subarray(o),u-=o,o=0},this.reset=function(){d=null,o=0,this.trigger("reset")},this.flush=function(){d&&d.byteLength>3&&this.trigger("data",d.subarray(o+3)),d=null,o=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}},Nn.prototype=new kl,Cl={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},Us=function(){var o=new Nn,u,d,h,f,y,S,E;Us.prototype.init.call(this),u=this,this.push=function(k){k.type==="video"&&(d=k.trackId,h=k.pts,f=k.dts,o.push(k))},o.on("data",function(k){var I={trackId:d,pts:h,dts:f,data:k,nalUnitTypeCode:k[0]&31};switch(I.nalUnitTypeCode){case 5:I.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:I.nalUnitType="sei_rbsp",I.escapedRBSP=y(k.subarray(1));break;case 7:I.nalUnitType="seq_parameter_set_rbsp",I.escapedRBSP=y(k.subarray(1)),I.config=S(I.escapedRBSP);break;case 8:I.nalUnitType="pic_parameter_set_rbsp";break;case 9:I.nalUnitType="access_unit_delimiter_rbsp";break}u.trigger("data",I)}),o.on("done",function(){u.trigger("done")}),o.on("partialdone",function(){u.trigger("partialdone")}),o.on("reset",function(){u.trigger("reset")}),o.on("endedtimeline",function(){u.trigger("endedtimeline")}),this.flush=function(){o.flush()},this.partialFlush=function(){o.partialFlush()},this.reset=function(){o.reset()},this.endTimeline=function(){o.endTimeline()},E=function(k,I){var O=8,j=8,Q,V;for(Q=0;Q<k;Q++)j!==0&&(V=I.readExpGolomb(),j=(O+V+256)%256),O=j===0?O:j},y=function(k){for(var I=k.byteLength,O=[],j=1,Q,V;j<I-2;)k[j]===0&&k[j+1]===0&&k[j+2]===3?(O.push(j+2),j+=2):j++;if(O.length===0)return k;Q=I-O.length,V=new Uint8Array(Q);var te=0;for(j=0;j<Q;te++,j++)te===O[0]&&(te++,O.shift()),V[j]=k[te];return V},S=function(k){var I=0,O=0,j=0,Q=0,V,te,se,ze,nt,qt,zn,Xs,Ks,Pi,Wn,Ie=[1,1],iu,Li;if(V=new Ef(k),te=V.readUnsignedByte(),ze=V.readUnsignedByte(),se=V.readUnsignedByte(),V.skipUnsignedExpGolomb(),Cl[te]&&(nt=V.readUnsignedExpGolomb(),nt===3&&V.skipBits(1),V.skipUnsignedExpGolomb(),V.skipUnsignedExpGolomb(),V.skipBits(1),V.readBoolean()))for(Wn=nt!==3?8:12,Li=0;Li<Wn;Li++)V.readBoolean()&&(Li<6?E(16,V):E(64,V));if(V.skipUnsignedExpGolomb(),qt=V.readUnsignedExpGolomb(),qt===0)V.readUnsignedExpGolomb();else if(qt===1)for(V.skipBits(1),V.skipExpGolomb(),V.skipExpGolomb(),zn=V.readUnsignedExpGolomb(),Li=0;Li<zn;Li++)V.skipExpGolomb();if(V.skipUnsignedExpGolomb(),V.skipBits(1),Xs=V.readUnsignedExpGolomb(),Ks=V.readUnsignedExpGolomb(),Pi=V.readBits(1),Pi===0&&V.skipBits(1),V.skipBits(1),V.readBoolean()&&(I=V.readUnsignedExpGolomb(),O=V.readUnsignedExpGolomb(),j=V.readUnsignedExpGolomb(),Q=V.readUnsignedExpGolomb()),V.readBoolean()&&V.readBoolean()){switch(iu=V.readUnsignedByte(),iu){case 1:Ie=[1,1];break;case 2:Ie=[12,11];break;case 3:Ie=[10,11];break;case 4:Ie=[16,11];break;case 5:Ie=[40,33];break;case 6:Ie=[24,11];break;case 7:Ie=[20,11];break;case 8:Ie=[32,11];break;case 9:Ie=[80,33];break;case 10:Ie=[18,11];break;case 11:Ie=[15,11];break;case 12:Ie=[64,33];break;case 13:Ie=[160,99];break;case 14:Ie=[4,3];break;case 15:Ie=[3,2];break;case 16:Ie=[2,1];break;case 255:{Ie=[V.readUnsignedByte()<<8|V.readUnsignedByte(),V.readUnsignedByte()<<8|V.readUnsignedByte()];break}}Ie&&Ie[0]/Ie[1]}return{profileIdc:te,levelIdc:se,profileCompatibility:ze,width:(Xs+1)*16-I*2-O*2,height:(2-Pi)*(Ks+1)*16-j*2-Q*2,sarRatio:Ie}}},Us.prototype=new kl;var wf={H264Stream:Us,NalByteStream:Nn},kf=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],Il=function(o,u){var d=o[u+6]<<21|o[u+7]<<14|o[u+8]<<7|o[u+9],h=o[u+5],f=(h&16)>>4;return d=d>=0?d:0,f?d+20:d+10},xl=function(o,u){return o.length-u<10||o[u]!==73||o[u+1]!==68||o[u+2]!==51?u:(u+=Il(o,u),xl(o,u))},Cf=function(o){var u=xl(o,0);return o.length>=u+2&&(o[u]&255)===255&&(o[u+1]&240)===240&&(o[u+1]&22)===16},Al=function(o){return o[0]<<21|o[1]<<14|o[2]<<7|o[3]},If=function(o,u,d){var h,f="";for(h=u;h<d;h++)f+="%"+("00"+o[h].toString(16)).slice(-2);return f},xf=function(o,u,d){return unescape(If(o,u,d))},Af=function(o,u){var d=(o[u+5]&224)>>5,h=o[u+4]<<3,f=o[u+3]&6144;return f|h|d},Pf=function(o,u){return o[u]===73&&o[u+1]===68&&o[u+2]===51?"timed-metadata":o[u]&!0&&(o[u+1]&240)===240?"audio":null},Lf=function(o){for(var u=0;u+5<o.length;){if(o[u]!==255||(o[u+1]&246)!==240){u++;continue}return kf[(o[u+2]&60)>>>2]}return null},Df=function(o){var u,d,h,f;u=10,o[5]&64&&(u+=4,u+=Al(o.subarray(10,14)));do{if(d=Al(o.subarray(u+4,u+8)),d<1)return null;if(f=String.fromCharCode(o[u],o[u+1],o[u+2],o[u+3]),f==="PRIV"){h=o.subarray(u+10,u+d+10);for(var y=0;y<h.byteLength;y++)if(h[y]===0){var S=xf(h,0,y);if(S==="com.apple.streaming.transportStreamTimestamp"){var E=h.subarray(y+1),k=(E[3]&1)<<30|E[4]<<22|E[5]<<14|E[6]<<6|E[7]>>>2;return k*=4,k+=E[7]&3,k}break}}u+=10,u+=d}while(u<o.byteLength);return null},da={isLikelyAacData:Cf,parseId3TagSize:Il,parseAdtsSize:Af,parseType:Pf,parseSampleRate:Lf,parseAacTimestamp:Df},Of=t,Pl=da,Ns;Ns=function(){var o=new Uint8Array,u=0;Ns.prototype.init.call(this),this.setTimestamp=function(d){u=d},this.push=function(d){var h=0,f=0,y,S,E,k;for(o.length?(k=o.length,o=new Uint8Array(d.byteLength+k),o.set(o.subarray(0,k)),o.set(d,k)):o=d;o.length-f>=3;){if(o[f]===73&&o[f+1]===68&&o[f+2]===51){if(o.length-f<10||(h=Pl.parseId3TagSize(o,f),f+h>o.length))break;S={type:"timed-metadata",data:o.subarray(f,f+h)},this.trigger("data",S),f+=h;continue}else if((o[f]&255)===255&&(o[f+1]&240)===240){if(o.length-f<7||(h=Pl.parseAdtsSize(o,f),f+h>o.length))break;E={type:"audio",data:o.subarray(f,f+h),pts:u,dts:u},this.trigger("data",E),f+=h;continue}f++}y=o.length-f,y>0?o=o.subarray(f):o=new Uint8Array},this.reset=function(){o=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){o=new Uint8Array,this.trigger("endedtimeline")}},Ns.prototype=new Of;var Mf=Ns,Rf=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],Uf=Rf,Nf=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],Bf=Nf,Bs=t,Bn=Hi,Fn=ki,Fs=Te,Rt=Qp,ti=_f,js=T,Ll=vf,Ff=wf.H264Stream,jf=Mf,$f=da.isLikelyAacData,qf=T.ONE_SECOND_IN_TS,ha=Uf,ca=Bf,jn,Gi,$s,xi,Vf=function(o,u){u.stream=o,this.trigger("log",u)},Dl=function(o,u){for(var d=Object.keys(u),h=0;h<d.length;h++){var f=d[h];f==="headOfPipeline"||!u[f].on||u[f].on("log",Vf.bind(o,f))}},Ol=function(o,u){var d;if(o.length!==u.length)return!1;for(d=0;d<o.length;d++)if(o[d]!==u[d])return!1;return!0},pa=function(o,u,d,h,f,y){var S=d-u,E=h-u,k=f-d;return{start:{dts:o,pts:o+S},end:{dts:o+E,pts:o+k},prependedContentDuration:y,baseMediaDecodeTime:o}};Gi=function(o,u){var d=[],h,f=0,y=0,S=1/0;u=u||{},h=u.firstSequenceNumber||0,Gi.prototype.init.call(this),this.push=function(E){Rt.collectDtsInfo(o,E),o&&ha.forEach(function(k){o[k]=E[k]}),d.push(E)},this.setEarliestDts=function(E){f=E},this.setVideoBaseMediaDecodeTime=function(E){S=E},this.setAudioAppendStart=function(E){y=E},this.flush=function(){var E,k,I,O,j,Q,V;if(d.length===0){this.trigger("done","AudioSegmentStream");return}E=Fs.trimAdtsFramesByEarliestDts(d,o,f),o.baseMediaDecodeTime=Rt.calculateTrackBaseMediaDecodeTime(o,u.keepOriginalTimestamps),V=Fs.prefixWithSilence(o,E,y,S),o.samples=Fs.generateSampleTable(E),I=Bn.mdat(Fs.concatenateFrameData(E)),d=[],k=Bn.moof(h,[o]),O=new Uint8Array(k.byteLength+I.byteLength),h++,O.set(k),O.set(I,k.byteLength),Rt.clearDtsInfo(o),j=Math.ceil(qf*1024/o.samplerate),E.length&&(Q=E.length*j,this.trigger("segmentTimingInfo",pa(js.audioTsToVideoTs(o.baseMediaDecodeTime,o.samplerate),E[0].dts,E[0].pts,E[0].dts+Q,E[0].pts+Q,V||0)),this.trigger("timingInfo",{start:E[0].pts,end:E[0].pts+Q})),this.trigger("data",{track:o,boxes:O}),this.trigger("done","AudioSegmentStream")},this.reset=function(){Rt.clearDtsInfo(o),d=[],this.trigger("reset")}},Gi.prototype=new Bs,jn=function(o,u){var d,h=[],f=[],y,S;u=u||{},d=u.firstSequenceNumber||0,jn.prototype.init.call(this),delete o.minPTS,this.gopCache_=[],this.push=function(E){Rt.collectDtsInfo(o,E),E.nalUnitType==="seq_parameter_set_rbsp"&&!y&&(y=E.config,o.sps=[E.data],ca.forEach(function(k){o[k]=y[k]},this)),E.nalUnitType==="pic_parameter_set_rbsp"&&!S&&(S=E.data,o.pps=[E.data]),h.push(E)},this.flush=function(){for(var E,k,I,O,j,Q,V=0,te,se;h.length&&h[0].nalUnitType!=="access_unit_delimiter_rbsp";)h.shift();if(h.length===0){this.resetStream_(),this.trigger("done","VideoSegmentStream");return}if(E=Fn.groupNalsIntoFrames(h),I=Fn.groupFramesIntoGops(E),I[0][0].keyFrame||(k=this.getGopForFusion_(h[0],o),k?(V=k.duration,I.unshift(k),I.byteLength+=k.byteLength,I.nalCount+=k.nalCount,I.pts=k.pts,I.dts=k.dts,I.duration+=k.duration):I=Fn.extendFirstKeyFrame(I)),f.length){var ze;if(u.alignGopsAtEnd?ze=this.alignGopsAtEnd_(I):ze=this.alignGopsAtStart_(I),!ze){this.gopCache_.unshift({gop:I.pop(),pps:o.pps,sps:o.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),h=[],this.resetStream_(),this.trigger("done","VideoSegmentStream");return}Rt.clearDtsInfo(o),I=ze}Rt.collectDtsInfo(o,I),o.samples=Fn.generateSampleTable(I),j=Bn.mdat(Fn.concatenateNalData(I)),o.baseMediaDecodeTime=Rt.calculateTrackBaseMediaDecodeTime(o,u.keepOriginalTimestamps),this.trigger("processedGopsInfo",I.map(function(nt){return{pts:nt.pts,dts:nt.dts,byteLength:nt.byteLength}})),te=I[0],se=I[I.length-1],this.trigger("segmentTimingInfo",pa(o.baseMediaDecodeTime,te.dts,te.pts,se.dts+se.duration,se.pts+se.duration,V)),this.trigger("timingInfo",{start:I[0].pts,end:I[I.length-1].pts+I[I.length-1].duration}),this.gopCache_.unshift({gop:I.pop(),pps:o.pps,sps:o.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),h=[],this.trigger("baseMediaDecodeTime",o.baseMediaDecodeTime),this.trigger("timelineStartInfo",o.timelineStartInfo),O=Bn.moof(d,[o]),Q=new Uint8Array(O.byteLength+j.byteLength),d++,Q.set(O),Q.set(j,O.byteLength),this.trigger("data",{track:o,boxes:Q}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),h=[],this.gopCache_.length=0,f.length=0,this.trigger("reset")},this.resetStream_=function(){Rt.clearDtsInfo(o),y=void 0,S=void 0},this.getGopForFusion_=function(E){var k=45e3,I=1e4,O=1/0,j,Q,V,te,se;for(se=0;se<this.gopCache_.length;se++)te=this.gopCache_[se],V=te.gop,!(!(o.pps&&Ol(o.pps[0],te.pps[0]))||!(o.sps&&Ol(o.sps[0],te.sps[0])))&&(V.dts<o.timelineStartInfo.dts||(j=E.dts-V.dts-V.duration,j>=-I&&j<=k&&(!Q||O>j)&&(Q=te,O=j)));return Q?Q.gop:null},this.alignGopsAtStart_=function(E){var k,I,O,j,Q,V,te,se;for(Q=E.byteLength,V=E.nalCount,te=E.duration,k=I=0;k<f.length&&I<E.length&&(O=f[k],j=E[I],O.pts!==j.pts);){if(j.pts>O.pts){k++;continue}I++,Q-=j.byteLength,V-=j.nalCount,te-=j.duration}return I===0?E:I===E.length?null:(se=E.slice(I),se.byteLength=Q,se.duration=te,se.nalCount=V,se.pts=se[0].pts,se.dts=se[0].dts,se)},this.alignGopsAtEnd_=function(E){var k,I,O,j,Q,V;for(k=f.length-1,I=E.length-1,Q=null,V=!1;k>=0&&I>=0;){if(O=f[k],j=E[I],O.pts===j.pts){V=!0;break}if(O.pts>j.pts){k--;continue}k===f.length-1&&(Q=I),I--}if(!V&&Q===null)return null;var te;if(V?te=I:te=Q,te===0)return E;var se=E.slice(te),ze=se.reduce(function(nt,qt){return nt.byteLength+=qt.byteLength,nt.duration+=qt.duration,nt.nalCount+=qt.nalCount,nt},{byteLength:0,duration:0,nalCount:0});return se.byteLength=ze.byteLength,se.duration=ze.duration,se.nalCount=ze.nalCount,se.pts=se[0].pts,se.dts=se[0].dts,se},this.alignGopsWith=function(E){f=E}},jn.prototype=new Bs,xi=function(o,u){this.numberOfTracks=0,this.metadataStream=u,o=o||{},typeof o.remux<"u"?this.remuxTracks=!!o.remux:this.remuxTracks=!0,typeof o.keepOriginalTimestamps=="boolean"?this.keepOriginalTimestamps=o.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,xi.prototype.init.call(this),this.push=function(d){if(d.content||d.text)return this.pendingCaptions.push(d);if(d.frames)return this.pendingMetadata.push(d);this.pendingTracks.push(d.track),this.pendingBytes+=d.boxes.byteLength,d.track.type==="video"&&(this.videoTrack=d.track,this.pendingBoxes.push(d.boxes)),d.track.type==="audio"&&(this.audioTrack=d.track,this.pendingBoxes.unshift(d.boxes))}},xi.prototype=new Bs,xi.prototype.flush=function(o){var u=0,d={captions:[],captionStreams:{},metadata:[],info:{}},h,f,y,S=0,E;if(this.pendingTracks.length<this.numberOfTracks){if(o!=="VideoSegmentStream"&&o!=="AudioSegmentStream"||this.remuxTracks)return;if(this.pendingTracks.length===0){this.emittedTracks++,this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0);return}}if(this.videoTrack?(S=this.videoTrack.timelineStartInfo.pts,ca.forEach(function(k){d.info[k]=this.videoTrack[k]},this)):this.audioTrack&&(S=this.audioTrack.timelineStartInfo.pts,ha.forEach(function(k){d.info[k]=this.audioTrack[k]},this)),this.videoTrack||this.audioTrack){for(this.pendingTracks.length===1?d.type=this.pendingTracks[0].type:d.type="combined",this.emittedTracks+=this.pendingTracks.length,y=Bn.initSegment(this.pendingTracks),d.initSegment=new Uint8Array(y.byteLength),d.initSegment.set(y),d.data=new Uint8Array(this.pendingBytes),E=0;E<this.pendingBoxes.length;E++)d.data.set(this.pendingBoxes[E],u),u+=this.pendingBoxes[E].byteLength;for(E=0;E<this.pendingCaptions.length;E++)h=this.pendingCaptions[E],h.startTime=js.metadataTsToSeconds(h.startPts,S,this.keepOriginalTimestamps),h.endTime=js.metadataTsToSeconds(h.endPts,S,this.keepOriginalTimestamps),d.captionStreams[h.stream]=!0,d.captions.push(h);for(E=0;E<this.pendingMetadata.length;E++)f=this.pendingMetadata[E],f.cueTime=js.metadataTsToSeconds(f.pts,S,this.keepOriginalTimestamps),d.metadata.push(f);for(d.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger("data",d),E=0;E<d.captions.length;E++)h=d.captions[E],this.trigger("caption",h);for(E=0;E<d.metadata.length;E++)f=d.metadata[E],this.trigger("id3Frame",f)}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},xi.prototype.setRemux=function(o){this.remuxTracks=o},$s=function(o){var u=this,d=!0,h,f;$s.prototype.init.call(this),o=o||{},this.baseMediaDecodeTime=o.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var y={};this.transmuxPipeline_=y,y.type="aac",y.metadataStream=new ti.MetadataStream,y.aacStream=new jf,y.audioTimestampRolloverStream=new ti.TimestampRolloverStream("audio"),y.timedMetadataTimestampRolloverStream=new ti.TimestampRolloverStream("timed-metadata"),y.adtsStream=new Ll,y.coalesceStream=new xi(o,y.metadataStream),y.headOfPipeline=y.aacStream,y.aacStream.pipe(y.audioTimestampRolloverStream).pipe(y.adtsStream),y.aacStream.pipe(y.timedMetadataTimestampRolloverStream).pipe(y.metadataStream).pipe(y.coalesceStream),y.metadataStream.on("timestamp",function(S){y.aacStream.setTimestamp(S.timeStamp)}),y.aacStream.on("data",function(S){S.type!=="timed-metadata"&&S.type!=="audio"||y.audioSegmentStream||(f=f||{timelineStartInfo:{baseMediaDecodeTime:u.baseMediaDecodeTime},codec:"adts",type:"audio"},y.coalesceStream.numberOfTracks++,y.audioSegmentStream=new Gi(f,o),y.audioSegmentStream.on("log",u.getLogTrigger_("audioSegmentStream")),y.audioSegmentStream.on("timingInfo",u.trigger.bind(u,"audioTimingInfo")),y.adtsStream.pipe(y.audioSegmentStream).pipe(y.coalesceStream),u.trigger("trackinfo",{hasAudio:!!f,hasVideo:!!h}))}),y.coalesceStream.on("data",this.trigger.bind(this,"data")),y.coalesceStream.on("done",this.trigger.bind(this,"done")),Dl(this,y)},this.setupTsPipeline=function(){var y={};this.transmuxPipeline_=y,y.type="ts",y.metadataStream=new ti.MetadataStream,y.packetStream=new ti.TransportPacketStream,y.parseStream=new ti.TransportParseStream,y.elementaryStream=new ti.ElementaryStream,y.timestampRolloverStream=new ti.TimestampRolloverStream,y.adtsStream=new Ll,y.h264Stream=new Ff,y.captionStream=new ti.CaptionStream(o),y.coalesceStream=new xi(o,y.metadataStream),y.headOfPipeline=y.packetStream,y.packetStream.pipe(y.parseStream).pipe(y.elementaryStream).pipe(y.timestampRolloverStream),y.timestampRolloverStream.pipe(y.h264Stream),y.timestampRolloverStream.pipe(y.adtsStream),y.timestampRolloverStream.pipe(y.metadataStream).pipe(y.coalesceStream),y.h264Stream.pipe(y.captionStream).pipe(y.coalesceStream),y.elementaryStream.on("data",function(S){var E;if(S.type==="metadata"){for(E=S.tracks.length;E--;)!h&&S.tracks[E].type==="video"?(h=S.tracks[E],h.timelineStartInfo.baseMediaDecodeTime=u.baseMediaDecodeTime):!f&&S.tracks[E].type==="audio"&&(f=S.tracks[E],f.timelineStartInfo.baseMediaDecodeTime=u.baseMediaDecodeTime);h&&!y.videoSegmentStream&&(y.coalesceStream.numberOfTracks++,y.videoSegmentStream=new jn(h,o),y.videoSegmentStream.on("log",u.getLogTrigger_("videoSegmentStream")),y.videoSegmentStream.on("timelineStartInfo",function(k){f&&!o.keepOriginalTimestamps&&(f.timelineStartInfo=k,y.audioSegmentStream.setEarliestDts(k.dts-u.baseMediaDecodeTime))}),y.videoSegmentStream.on("processedGopsInfo",u.trigger.bind(u,"gopInfo")),y.videoSegmentStream.on("segmentTimingInfo",u.trigger.bind(u,"videoSegmentTimingInfo")),y.videoSegmentStream.on("baseMediaDecodeTime",function(k){f&&y.audioSegmentStream.setVideoBaseMediaDecodeTime(k)}),y.videoSegmentStream.on("timingInfo",u.trigger.bind(u,"videoTimingInfo")),y.h264Stream.pipe(y.videoSegmentStream).pipe(y.coalesceStream)),f&&!y.audioSegmentStream&&(y.coalesceStream.numberOfTracks++,y.audioSegmentStream=new Gi(f,o),y.audioSegmentStream.on("log",u.getLogTrigger_("audioSegmentStream")),y.audioSegmentStream.on("timingInfo",u.trigger.bind(u,"audioTimingInfo")),y.audioSegmentStream.on("segmentTimingInfo",u.trigger.bind(u,"audioSegmentTimingInfo")),y.adtsStream.pipe(y.audioSegmentStream).pipe(y.coalesceStream)),u.trigger("trackinfo",{hasAudio:!!f,hasVideo:!!h})}}),y.coalesceStream.on("data",this.trigger.bind(this,"data")),y.coalesceStream.on("id3Frame",function(S){S.dispatchType=y.metadataStream.dispatchType,u.trigger("id3Frame",S)}),y.coalesceStream.on("caption",this.trigger.bind(this,"caption")),y.coalesceStream.on("done",this.trigger.bind(this,"done")),Dl(this,y)},this.setBaseMediaDecodeTime=function(y){var S=this.transmuxPipeline_;o.keepOriginalTimestamps||(this.baseMediaDecodeTime=y),f&&(f.timelineStartInfo.dts=void 0,f.timelineStartInfo.pts=void 0,Rt.clearDtsInfo(f),S.audioTimestampRolloverStream&&S.audioTimestampRolloverStream.discontinuity()),h&&(S.videoSegmentStream&&(S.videoSegmentStream.gopCache_=[]),h.timelineStartInfo.dts=void 0,h.timelineStartInfo.pts=void 0,Rt.clearDtsInfo(h),S.captionStream.reset()),S.timestampRolloverStream&&S.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(y){f&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(y)},this.setRemux=function(y){var S=this.transmuxPipeline_;o.remux=y,S&&S.coalesceStream&&S.coalesceStream.setRemux(y)},this.alignGopsWith=function(y){h&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(y)},this.getLogTrigger_=function(y){var S=this;return function(E){E.stream=y,S.trigger("log",E)}},this.push=function(y){if(d){var S=$f(y);S&&this.transmuxPipeline_.type!=="aac"?this.setupAacPipeline():!S&&this.transmuxPipeline_.type!=="ts"&&this.setupTsPipeline(),d=!1}this.transmuxPipeline_.headOfPipeline.push(y)},this.flush=function(){d=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}},$s.prototype=new Bs;var Hf={Transmuxer:$s,VideoSegmentStream:jn,AudioSegmentStream:Gi,AUDIO_PROPERTIES:ha,VIDEO_PROPERTIES:ca,generateSegmentTimingInfo:pa},zf=function(o){return o>>>0},Wf=function(o){return("00"+o.toString(16)).slice(-2)},qs={toUnsigned:zf,toHexString:Wf},Gf=function(o){var u="";return u+=String.fromCharCode(o[0]),u+=String.fromCharCode(o[1]),u+=String.fromCharCode(o[2]),u+=String.fromCharCode(o[3]),u},fa=Gf,Xf=qs.toUnsigned,Kf=fa,Ml=function(o,u){var d=[],h,f,y,S,E;if(!u.length)return null;for(h=0;h<o.byteLength;)f=Xf(o[h]<<24|o[h+1]<<16|o[h+2]<<8|o[h+3]),y=Kf(o.subarray(h+4,h+8)),S=f>1?h+f:o.byteLength,y===u[0]&&(u.length===1?d.push(o.subarray(h+8,S)):(E=Ml(o.subarray(h+8,S),u.slice(1)),E.length&&(d=d.concat(E)))),h=S;return d},Vs=Ml,Yf=qs.toUnsigned,Qf=r.getUint64,Jf=function(o){var u={version:o[0],flags:new Uint8Array(o.subarray(1,4))};return u.version===1?u.baseMediaDecodeTime=Qf(o.subarray(4)):u.baseMediaDecodeTime=Yf(o[4]<<24|o[5]<<16|o[6]<<8|o[7]),u},ga=Jf,Zf=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),trackId:u.getUint32(4)},h=d.flags[2]&1,f=d.flags[2]&2,y=d.flags[2]&8,S=d.flags[2]&16,E=d.flags[2]&32,k=d.flags[0]&65536,I=d.flags[0]&131072,O;return O=8,h&&(O+=4,d.baseDataOffset=u.getUint32(12),O+=4),f&&(d.sampleDescriptionIndex=u.getUint32(O),O+=4),y&&(d.defaultSampleDuration=u.getUint32(O),O+=4),S&&(d.defaultSampleSize=u.getUint32(O),O+=4),E&&(d.defaultSampleFlags=u.getUint32(O)),k&&(d.durationIsEmpty=!0),!h&&I&&(d.baseDataOffsetIsMoof=!0),d},ma=Zf,Rl=r.getUint64,eg=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),references:[],referenceId:u.getUint32(4),timescale:u.getUint32(8)},h=12;d.version===0?(d.earliestPresentationTime=u.getUint32(h),d.firstOffset=u.getUint32(h+4),h+=8):(d.earliestPresentationTime=Rl(o.subarray(h)),d.firstOffset=Rl(o.subarray(h+8)),h+=16),h+=2;var f=u.getUint16(h);for(h+=2;f>0;h+=12,f--)d.references.push({referenceType:(o[h]&128)>>>7,referencedSize:u.getUint32(h)&2147483647,subsegmentDuration:u.getUint32(h+4),startsWithSap:!!(o[h+8]&128),sapType:(o[h+8]&112)>>>4,sapDeltaTime:u.getUint32(h+8)&268435455});return d},tg=eg,ig=function(o){return{isLeading:(o[0]&12)>>>2,dependsOn:o[0]&3,isDependedOn:(o[1]&192)>>>6,hasRedundancy:(o[1]&48)>>>4,paddingValue:(o[1]&14)>>>1,isNonSyncSample:o[1]&1,degradationPriority:o[2]<<8|o[3]}},ng=ig,Ul=ng,sg=function(o){var u={version:o[0],flags:new Uint8Array(o.subarray(1,4)),samples:[]},d=new DataView(o.buffer,o.byteOffset,o.byteLength),h=u.flags[2]&1,f=u.flags[2]&4,y=u.flags[1]&1,S=u.flags[1]&2,E=u.flags[1]&4,k=u.flags[1]&8,I=d.getUint32(4),O=8,j;for(h&&(u.dataOffset=d.getInt32(O),O+=4),f&&I&&(j={flags:Ul(o.subarray(O,O+4))},O+=4,y&&(j.duration=d.getUint32(O),O+=4),S&&(j.size=d.getUint32(O),O+=4),k&&(u.version===1?j.compositionTimeOffset=d.getInt32(O):j.compositionTimeOffset=d.getUint32(O),O+=4),u.samples.push(j),I--);I--;)j={},y&&(j.duration=d.getUint32(O),O+=4),S&&(j.size=d.getUint32(O),O+=4),E&&(j.flags=Ul(o.subarray(O,O+4)),O+=4),k&&(u.version===1?j.compositionTimeOffset=d.getInt32(O):j.compositionTimeOffset=d.getUint32(O),O+=4),u.samples.push(j);return u},Nl=sg,rg=r,Bl=rg.getUint64,Qe,ya,kt=function(o){return new Date(o*1e3-20828448e5)},$n=fa,ag=Vs,og=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=[],h,f;for(h=0;h+4<o.length;h+=f){if(f=u.getUint32(h),h+=4,f<=0){d.push("<span style='color:red;'>MALFORMED DATA</span>");continue}switch(o[h]&31){case 1:d.push("slice_layer_without_partitioning_rbsp");break;case 5:d.push("slice_layer_without_partitioning_rbsp_idr");break;case 6:d.push("sei_rbsp");break;case 7:d.push("seq_parameter_set_rbsp");break;case 8:d.push("pic_parameter_set_rbsp");break;case 9:d.push("access_unit_delimiter_rbsp");break;default:d.push("UNKNOWN NAL - "+o[h]&31);break}}return d},ci={avc1:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{dataReferenceIndex:u.getUint16(6),width:u.getUint16(24),height:u.getUint16(26),horizresolution:u.getUint16(28)+u.getUint16(30)/16,vertresolution:u.getUint16(32)+u.getUint16(34)/16,frameCount:u.getUint16(40),depth:u.getUint16(74),config:Qe(o.subarray(78,o.byteLength))}},avcC:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={configurationVersion:o[0],avcProfileIndication:o[1],profileCompatibility:o[2],avcLevelIndication:o[3],lengthSizeMinusOne:o[4]&3,sps:[],pps:[]},h=o[5]&31,f,y,S,E;for(S=6,E=0;E<h;E++)y=u.getUint16(S),S+=2,d.sps.push(new Uint8Array(o.subarray(S,S+y))),S+=y;for(f=o[S],S++,E=0;E<f;E++)y=u.getUint16(S),S+=2,d.pps.push(new Uint8Array(o.subarray(S,S+y))),S+=y;return d},btrt:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{bufferSizeDB:u.getUint32(0),maxBitrate:u.getUint32(4),avgBitrate:u.getUint32(8)}},edts:function(o){return{boxes:Qe(o)}},elst:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),edits:[]},h=u.getUint32(4),f;for(f=8;h;h--)d.version===0?(d.edits.push({segmentDuration:u.getUint32(f),mediaTime:u.getInt32(f+4),mediaRate:u.getUint16(f+8)+u.getUint16(f+10)/(256*256)}),f+=12):(d.edits.push({segmentDuration:Bl(o.subarray(f)),mediaTime:Bl(o.subarray(f+8)),mediaRate:u.getUint16(f+16)+u.getUint16(f+18)/(256*256)}),f+=20);return d},esds:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),esId:o[6]<<8|o[7],streamPriority:o[8]&31,decoderConfig:{objectProfileIndication:o[11],streamType:o[12]>>>2&63,bufferSize:o[13]<<16|o[14]<<8|o[15],maxBitrate:o[16]<<24|o[17]<<16|o[18]<<8|o[19],avgBitrate:o[20]<<24|o[21]<<16|o[22]<<8|o[23],decoderConfigDescriptor:{tag:o[24],length:o[25],audioObjectType:o[26]>>>3&31,samplingFrequencyIndex:(o[26]&7)<<1|o[27]>>>7&1,channelConfiguration:o[27]>>>3&15}}}},ftyp:function(o){for(var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={majorBrand:$n(o.subarray(0,4)),minorVersion:u.getUint32(4),compatibleBrands:[]},h=8;h<o.byteLength;)d.compatibleBrands.push($n(o.subarray(h,h+4))),h+=4;return d},dinf:function(o){return{boxes:Qe(o)}},dref:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),dataReferences:Qe(o.subarray(8))}},hdlr:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),handlerType:$n(o.subarray(8,12)),name:""},h=8;for(h=24;h<o.byteLength;h++){if(o[h]===0){h++;break}d.name+=String.fromCharCode(o[h])}return d.name=decodeURIComponent(escape(d.name)),d},mdat:function(o){return{byteLength:o.byteLength,nals:og(o)}},mdhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=4,h,f={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),language:""};return f.version===1?(d+=4,f.creationTime=kt(u.getUint32(d)),d+=8,f.modificationTime=kt(u.getUint32(d)),d+=4,f.timescale=u.getUint32(d),d+=8,f.duration=u.getUint32(d)):(f.creationTime=kt(u.getUint32(d)),d+=4,f.modificationTime=kt(u.getUint32(d)),d+=4,f.timescale=u.getUint32(d),d+=4,f.duration=u.getUint32(d)),d+=4,h=u.getUint16(d),f.language+=String.fromCharCode((h>>10)+96),f.language+=String.fromCharCode(((h&992)>>5)+96),f.language+=String.fromCharCode((h&31)+96),f},mdia:function(o){return{boxes:Qe(o)}},mfhd:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),sequenceNumber:o[4]<<24|o[5]<<16|o[6]<<8|o[7]}},minf:function(o){return{boxes:Qe(o)}},mp4a:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={dataReferenceIndex:u.getUint16(6),channelcount:u.getUint16(16),samplesize:u.getUint16(18),samplerate:u.getUint16(24)+u.getUint16(26)/65536};return o.byteLength>28&&(d.streamDescriptor=Qe(o.subarray(28))[0]),d},moof:function(o){return{boxes:Qe(o)}},moov:function(o){return{boxes:Qe(o)}},mvex:function(o){return{boxes:Qe(o)}},mvhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=4,h={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4))};return h.version===1?(d+=4,h.creationTime=kt(u.getUint32(d)),d+=8,h.modificationTime=kt(u.getUint32(d)),d+=4,h.timescale=u.getUint32(d),d+=8,h.duration=u.getUint32(d)):(h.creationTime=kt(u.getUint32(d)),d+=4,h.modificationTime=kt(u.getUint32(d)),d+=4,h.timescale=u.getUint32(d),d+=4,h.duration=u.getUint32(d)),d+=4,h.rate=u.getUint16(d)+u.getUint16(d+2)/16,d+=4,h.volume=u.getUint8(d)+u.getUint8(d+1)/8,d+=2,d+=2,d+=2*4,h.matrix=new Uint32Array(o.subarray(d,d+9*4)),d+=9*4,d+=6*4,h.nextTrackId=u.getUint32(d),h},pdin:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),rate:u.getUint32(4),initialDelay:u.getUint32(8)}},sdtp:function(o){var u={version:o[0],flags:new Uint8Array(o.subarray(1,4)),samples:[]},d;for(d=4;d<o.byteLength;d++)u.samples.push({dependsOn:(o[d]&48)>>4,isDependedOn:(o[d]&12)>>2,hasRedundancy:o[d]&3});return u},sidx:tg,smhd:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),balance:o[4]+o[5]/256}},stbl:function(o){return{boxes:Qe(o)}},ctts:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),compositionOffsets:[]},h=u.getUint32(4),f;for(f=8;h;f+=8,h--)d.compositionOffsets.push({sampleCount:u.getUint32(f),sampleOffset:u[d.version===0?"getUint32":"getInt32"](f+4)});return d},stss:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),syncSamples:[]},h=u.getUint32(4),f;for(f=8;h;f+=4,h--)d.syncSamples.push(u.getUint32(f));return d},stco:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),chunkOffsets:[]},h=u.getUint32(4),f;for(f=8;h;f+=4,h--)d.chunkOffsets.push(u.getUint32(f));return d},stsc:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=u.getUint32(4),h={version:o[0],flags:new Uint8Array(o.subarray(1,4)),sampleToChunks:[]},f;for(f=8;d;f+=12,d--)h.sampleToChunks.push({firstChunk:u.getUint32(f),samplesPerChunk:u.getUint32(f+4),sampleDescriptionIndex:u.getUint32(f+8)});return h},stsd:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),sampleDescriptions:Qe(o.subarray(8))}},stsz:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),sampleSize:u.getUint32(4),entries:[]},h;for(h=12;h<o.byteLength;h+=4)d.entries.push(u.getUint32(h));return d},stts:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),timeToSamples:[]},h=u.getUint32(4),f;for(f=8;h;f+=8,h--)d.timeToSamples.push({sampleCount:u.getUint32(f),sampleDelta:u.getUint32(f+4)});return d},styp:function(o){return ci.ftyp(o)},tfdt:ga,tfhd:ma,tkhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=4,h={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4))};return h.version===1?(d+=4,h.creationTime=kt(u.getUint32(d)),d+=8,h.modificationTime=kt(u.getUint32(d)),d+=4,h.trackId=u.getUint32(d),d+=4,d+=8,h.duration=u.getUint32(d)):(h.creationTime=kt(u.getUint32(d)),d+=4,h.modificationTime=kt(u.getUint32(d)),d+=4,h.trackId=u.getUint32(d),d+=4,d+=4,h.duration=u.getUint32(d)),d+=4,d+=2*4,h.layer=u.getUint16(d),d+=2,h.alternateGroup=u.getUint16(d),d+=2,h.volume=u.getUint8(d)+u.getUint8(d+1)/8,d+=2,d+=2,h.matrix=new Uint32Array(o.subarray(d,d+9*4)),d+=9*4,h.width=u.getUint16(d)+u.getUint16(d+2)/65536,d+=4,h.height=u.getUint16(d)+u.getUint16(d+2)/65536,h},traf:function(o){return{boxes:Qe(o)}},trak:function(o){return{boxes:Qe(o)}},trex:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),trackId:u.getUint32(4),defaultSampleDescriptionIndex:u.getUint32(8),defaultSampleDuration:u.getUint32(12),defaultSampleSize:u.getUint32(16),sampleDependsOn:o[20]&3,sampleIsDependedOn:(o[21]&192)>>6,sampleHasRedundancy:(o[21]&48)>>4,samplePaddingValue:(o[21]&14)>>1,sampleIsDifferenceSample:!!(o[21]&1),sampleDegradationPriority:u.getUint16(22)}},trun:Nl,"url ":function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4))}},vmhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),graphicsmode:u.getUint16(4),opcolor:new Uint16Array([u.getUint16(6),u.getUint16(8),u.getUint16(10)])}}};Qe=function(o){for(var u=0,d=[],h,f,y,S,E,k=new ArrayBuffer(o.length),I=new Uint8Array(k),O=0;O<o.length;++O)I[O]=o[O];for(h=new DataView(k);u<o.byteLength;)f=h.getUint32(u),y=$n(o.subarray(u+4,u+8)),S=f>1?u+f:o.byteLength,E=(ci[y]||function(j){return{data:j}})(o.subarray(u+8,S)),E.size=f,E.type=y,d.push(E),u=S;return d},ya=function(o,u){var d;return u=u||0,d=new Array(u*2+1).join(" "),o.map(function(h,f){return d+h.type+`
|
|
195
|
+
`),this.pushCaption(u),u.startPts=o},Ee.prototype.pushCaption=function(o){o.text!==""&&(this.trigger("data",{startPts:o.startPts,endPts:o.endPts,text:o.text,stream:"cc708_"+o.serviceNum}),o.text="",o.startPts=o.endPts)},Ee.prototype.displayWindows=function(o,u){var d=this.current708Packet.data,h=d[++o],g=this.getPts(o);this.flushDisplayed(g,u);for(var y=0;y<8;y++)h&1<<y&&(u.windows[y].visible=1);return o},Ee.prototype.hideWindows=function(o,u){var d=this.current708Packet.data,h=d[++o],g=this.getPts(o);this.flushDisplayed(g,u);for(var y=0;y<8;y++)h&1<<y&&(u.windows[y].visible=0);return o},Ee.prototype.toggleWindows=function(o,u){var d=this.current708Packet.data,h=d[++o],g=this.getPts(o);this.flushDisplayed(g,u);for(var y=0;y<8;y++)h&1<<y&&(u.windows[y].visible^=1);return o},Ee.prototype.clearWindows=function(o,u){var d=this.current708Packet.data,h=d[++o],g=this.getPts(o);this.flushDisplayed(g,u);for(var y=0;y<8;y++)h&1<<y&&u.windows[y].clearText();return o},Ee.prototype.deleteWindows=function(o,u){var d=this.current708Packet.data,h=d[++o],g=this.getPts(o);this.flushDisplayed(g,u);for(var y=0;y<8;y++)h&1<<y&&u.windows[y].reset();return o},Ee.prototype.setPenAttributes=function(o,u){var d=this.current708Packet.data,h=d[o],g=u.currentWindow.penAttr;return h=d[++o],g.textTag=(h&240)>>4,g.offset=(h&12)>>2,g.penSize=h&3,h=d[++o],g.italics=(h&128)>>7,g.underline=(h&64)>>6,g.edgeType=(h&56)>>3,g.fontStyle=h&7,o},Ee.prototype.setPenColor=function(o,u){var d=this.current708Packet.data,h=d[o],g=u.currentWindow.penColor;return h=d[++o],g.fgOpacity=(h&192)>>6,g.fgRed=(h&48)>>4,g.fgGreen=(h&12)>>2,g.fgBlue=h&3,h=d[++o],g.bgOpacity=(h&192)>>6,g.bgRed=(h&48)>>4,g.bgGreen=(h&12)>>2,g.bgBlue=h&3,h=d[++o],g.edgeRed=(h&48)>>4,g.edgeGreen=(h&12)>>2,g.edgeBlue=h&3,o},Ee.prototype.setPenLocation=function(o,u){var d=this.current708Packet.data,h=d[o],g=u.currentWindow.penLoc;return u.currentWindow.pendingNewLine=!0,h=d[++o],g.row=h&15,h=d[++o],g.column=h&63,o},Ee.prototype.reset=function(o,u){var d=this.getPts(o);return this.flushDisplayed(d,u),this.initService(u.serviceNum,o)};var ig={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},xs=function(o){return o===null?"":(o=ig[o]||o,String.fromCharCode(o))},As=14,ng=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],Ii=function(){for(var o=[],u=As+1;u--;)o.push({text:"",indent:0,offset:0});return o},Pe=function(o,u){Pe.prototype.init.call(this),this.field_=o||0,this.dataChannel_=u||0,this.name_="CC"+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(d){var h,g,y,S,E;if(h=d.ccData&32639,h===this.lastControlCode_){this.lastControlCode_=null;return}if((h&61440)===4096?this.lastControlCode_=h:h!==this.PADDING_&&(this.lastControlCode_=null),y=h>>>8,S=h&255,h!==this.PADDING_)if(h===this.RESUME_CAPTION_LOADING_)this.mode_="popOn";else if(h===this.END_OF_CAPTION_)this.mode_="popOn",this.clearFormatting(d.pts),this.flushDisplayed(d.pts),g=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=g,this.startPts_=d.pts;else if(h===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(d.pts);else if(h===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(d.pts);else if(h===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(d.pts);else if(h===this.CARRIAGE_RETURN_)this.clearFormatting(d.pts),this.flushDisplayed(d.pts),this.shiftRowsUp_(),this.startPts_=d.pts;else if(h===this.BACKSPACE_)this.mode_==="popOn"?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1);else if(h===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(d.pts),this.displayed_=Ii();else if(h===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Ii();else if(h===this.RESUME_DIRECT_CAPTIONING_)this.mode_!=="paintOn"&&(this.flushDisplayed(d.pts),this.displayed_=Ii()),this.mode_="paintOn",this.startPts_=d.pts;else if(this.isSpecialCharacter(y,S))y=(y&3)<<8,E=xs(y|S),this[this.mode_](d.pts,E),this.column_++;else if(this.isExtCharacter(y,S))this.mode_==="popOn"?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1),y=(y&3)<<8,E=xs(y|S),this[this.mode_](d.pts,E),this.column_++;else if(this.isMidRowCode(y,S))this.clearFormatting(d.pts),this[this.mode_](d.pts," "),this.column_++,(S&14)===14&&this.addFormatting(d.pts,["i"]),(S&1)===1&&this.addFormatting(d.pts,["u"]);else if(this.isOffsetControlCode(y,S)){const I=S&3;this.nonDisplayed_[this.row_].offset=I,this.column_+=I}else if(this.isPAC(y,S)){var k=ng.indexOf(h&7968);if(this.mode_==="rollUp"&&(k-this.rollUpRows_+1<0&&(k=this.rollUpRows_-1),this.setRollUp(d.pts,k)),k!==this.row_&&k>=0&&k<=14&&(this.clearFormatting(d.pts),this.row_=k),S&1&&this.formatting_.indexOf("u")===-1&&this.addFormatting(d.pts,["u"]),(h&16)===16){const I=(h&14)>>1;this.column_=I*4,this.nonDisplayed_[this.row_].indent+=I}this.isColorPAC(S)&&(S&14)===14&&this.addFormatting(d.pts,["i"])}else this.isNormalChar(y)&&(S===0&&(S=null),E=xs(y),E+=xs(S),this[this.mode_](d.pts,E),this.column_+=E.length)}};Pe.prototype=new na,Pe.prototype.flushDisplayed=function(o){const u=h=>{this.trigger("log",{level:"warn",message:"Skipping a malformed 608 caption at index "+h+"."})},d=[];this.displayed_.forEach((h,g)=>{if(h&&h.text&&h.text.length){try{h.text=h.text.trim()}catch{u(g)}h.text.length&&d.push({text:h.text,line:g+1,position:10+Math.min(70,h.indent*10)+h.offset*2.5})}else h==null&&u(g)}),d.length&&this.trigger("data",{startPts:this.startPts_,endPts:o,content:d,stream:this.name_})},Pe.prototype.reset=function(){this.mode_="popOn",this.topRow_=0,this.startPts_=0,this.displayed_=Ii(),this.nonDisplayed_=Ii(),this.lastControlCode_=null,this.column_=0,this.row_=As,this.rollUpRows_=2,this.formatting_=[]},Pe.prototype.setConstants=function(){this.dataChannel_===0?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):this.dataChannel_===1&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=this.CONTROL_|32,this.END_OF_CAPTION_=this.CONTROL_|47,this.ROLL_UP_2_ROWS_=this.CONTROL_|37,this.ROLL_UP_3_ROWS_=this.CONTROL_|38,this.ROLL_UP_4_ROWS_=this.CONTROL_|39,this.CARRIAGE_RETURN_=this.CONTROL_|45,this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41,this.BACKSPACE_=this.CONTROL_|33,this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44,this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46},Pe.prototype.isSpecialCharacter=function(o,u){return o===this.EXT_&&u>=48&&u<=63},Pe.prototype.isExtCharacter=function(o,u){return(o===this.EXT_+1||o===this.EXT_+2)&&u>=32&&u<=63},Pe.prototype.isMidRowCode=function(o,u){return o===this.EXT_&&u>=32&&u<=47},Pe.prototype.isOffsetControlCode=function(o,u){return o===this.OFFSET_&&u>=33&&u<=35},Pe.prototype.isPAC=function(o,u){return o>=this.BASE_&&o<this.BASE_+8&&u>=64&&u<=127},Pe.prototype.isColorPAC=function(o){return o>=64&&o<=79||o>=96&&o<=127},Pe.prototype.isNormalChar=function(o){return o>=32&&o<=127},Pe.prototype.setRollUp=function(o,u){if(this.mode_!=="rollUp"&&(this.row_=As,this.mode_="rollUp",this.flushDisplayed(o),this.nonDisplayed_=Ii(),this.displayed_=Ii()),u!==void 0&&u!==this.row_)for(var d=0;d<this.rollUpRows_;d++)this.displayed_[u-d]=this.displayed_[this.row_-d],this.displayed_[this.row_-d]={text:"",indent:0,offset:0};u===void 0&&(u=this.row_),this.topRow_=u-this.rollUpRows_+1},Pe.prototype.addFormatting=function(o,u){this.formatting_=this.formatting_.concat(u);var d=u.reduce(function(h,g){return h+"<"+g+">"},"");this[this.mode_](o,d)},Pe.prototype.clearFormatting=function(o){if(this.formatting_.length){var u=this.formatting_.reverse().reduce(function(d,h){return d+"</"+h+">"},"");this.formatting_=[],this[this.mode_](o,u)}},Pe.prototype.popOn=function(o,u){var d=this.nonDisplayed_[this.row_].text;d+=u,this.nonDisplayed_[this.row_].text=d},Pe.prototype.rollUp=function(o,u){var d=this.displayed_[this.row_].text;d+=u,this.displayed_[this.row_].text=d},Pe.prototype.shiftRowsUp_=function(){var o;for(o=0;o<this.topRow_;o++)this.displayed_[o]={text:"",indent:0,offset:0};for(o=this.row_+1;o<As+1;o++)this.displayed_[o]={text:"",indent:0,offset:0};for(o=this.topRow_;o<this.row_;o++)this.displayed_[o]=this.displayed_[o+1];this.displayed_[this.row_]={text:"",indent:0,offset:0}},Pe.prototype.paintOn=function(o,u){var d=this.displayed_[this.row_].text;d+=u,this.displayed_[this.row_].text=d};var ml={CaptionStream:dt,Cea608Stream:Pe,Cea708Stream:Ee},Ps={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},sg=t,rg=8589934592,ag=4294967296,yl="shared",sa=function(o,u){var d=1;for(o>u&&(d=-1);Math.abs(u-o)>ag;)o+=d*rg;return o},ra=function(o){var u,d;ra.prototype.init.call(this),this.type_=o||yl,this.push=function(h){if(h.type==="metadata"){this.trigger("data",h);return}this.type_!==yl&&h.type!==this.type_||(d===void 0&&(d=h.dts),h.dts=sa(h.dts,d),h.pts=sa(h.pts,d),u=h.dts,this.trigger("data",h))},this.flush=function(){d=u,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.discontinuity=function(){d=void 0,u=void 0},this.reset=function(){this.discontinuity(),this.trigger("reset")}};ra.prototype=new sg;var _l={TimestampRolloverStream:ra,handleRollover:sa},og=(o,u,d)=>{if(!o)return-1;for(var h=d;h<o.length;h++)if(o[h]===u)return h;return-1},lg={typedArrayIndexOf:og},Ls=lg.typedArrayIndexOf,Ds={Iso88591:0,Utf16:1,Utf16be:2,Utf8:3},bl=function(o,u,d){var h,g="";for(h=u;h<d;h++)g+="%"+("00"+o[h].toString(16)).slice(-2);return g},Dn=function(o,u,d){return decodeURIComponent(bl(o,u,d))},On=function(o,u,d){return unescape(bl(o,u,d))},Mn=function(o){return o[0]<<21|o[1]<<14|o[2]<<7|o[3]},Rn={APIC:function(o){var u=1,d,h,g="-->";o.data[0]===Ds.Utf8&&(d=Ls(o.data,0,u),!(d<0)&&(o.mimeType=On(o.data,u,d),u=d+1,o.pictureType=o.data[u],u++,h=Ls(o.data,0,u),!(h<0)&&(o.description=Dn(o.data,u,h),u=h+1,o.mimeType===g?o.url=On(o.data,u,o.data.length):o.pictureData=o.data.subarray(u,o.data.length))))},"T*":function(o){o.data[0]===Ds.Utf8&&(o.value=Dn(o.data,1,o.data.length).replace(/\0*$/,""),o.values=o.value.split("\0"))},TXXX:function(o){var u;o.data[0]===Ds.Utf8&&(u=Ls(o.data,0,1),u!==-1&&(o.description=Dn(o.data,1,u),o.value=Dn(o.data,u+1,o.data.length).replace(/\0*$/,""),o.data=o.value))},"W*":function(o){o.url=On(o.data,0,o.data.length).replace(/\0.*$/,"")},WXXX:function(o){var u;o.data[0]===Ds.Utf8&&(u=Ls(o.data,0,1),u!==-1&&(o.description=Dn(o.data,1,u),o.url=On(o.data,u+1,o.data.length).replace(/\0.*$/,"")))},PRIV:function(o){var u;for(u=0;u<o.data.length;u++)if(o.data[u]===0){o.owner=On(o.data,0,u);break}o.privateData=o.data.subarray(u+1),o.data=o.privateData}},ug=function(o){var u,d,h=10,g=0,y=[];if(!(o.length<10||o[0]!==73||o[1]!==68||o[2]!==51)){g=Mn(o.subarray(6,10)),g+=10;var S=o[5]&64;S&&(h+=4,h+=Mn(o.subarray(10,14)),g-=Mn(o.subarray(16,20)));do{if(u=Mn(o.subarray(h+4,h+8)),u<1)break;d=String.fromCharCode(o[h],o[h+1],o[h+2],o[h+3]);var E={id:d,data:o.subarray(h+10,h+u+10)};E.key=E.id,Rn[E.id]?Rn[E.id](E):E.id[0]==="T"?Rn["T*"](E):E.id[0]==="W"&&Rn["W*"](E),y.push(E),h+=10,h+=u}while(h<g);return y}},Tl={parseId3Frames:ug,parseSyncSafeInteger:Mn,frameParsers:Rn},dg=t,hg=Ps,hi=Tl,Os;Os=function(o){var u={descriptor:o&&o.descriptor},d=0,h=[],g=0,y;if(Os.prototype.init.call(this),this.dispatchType=hg.METADATA_STREAM_TYPE.toString(16),u.descriptor)for(y=0;y<u.descriptor.length;y++)this.dispatchType+=("00"+u.descriptor[y].toString(16)).slice(-2);this.push=function(S){var E,k,I,O,j,Q;if(S.type==="timed-metadata"){if(S.dataAlignmentIndicator&&(g=0,h.length=0),h.length===0&&(S.data.length<10||S.data[0]!==73||S.data[1]!==68||S.data[2]!==51)){this.trigger("log",{level:"warn",message:"Skipping unrecognized metadata packet"});return}if(h.push(S),g+=S.data.byteLength,h.length===1&&(d=hi.parseSyncSafeInteger(S.data.subarray(6,10)),d+=10),!(g<d)){for(E={data:new Uint8Array(d),frames:[],pts:h[0].pts,dts:h[0].dts},j=0;j<d;)E.data.set(h[0].data.subarray(0,d-j),j),j+=h[0].data.byteLength,g-=h[0].data.byteLength,h.shift();k=10,E.data[5]&64&&(k+=4,k+=hi.parseSyncSafeInteger(E.data.subarray(10,14)),d-=hi.parseSyncSafeInteger(E.data.subarray(16,20)));do{if(I=hi.parseSyncSafeInteger(E.data.subarray(k+4,k+8)),I<1){this.trigger("log",{level:"warn",message:"Malformed ID3 frame encountered. Skipping remaining metadata parsing."});break}if(Q=String.fromCharCode(E.data[k],E.data[k+1],E.data[k+2],E.data[k+3]),O={id:Q,data:E.data.subarray(k+10,k+I+10)},O.key=O.id,hi.frameParsers[O.id]?hi.frameParsers[O.id](O):O.id[0]==="T"?hi.frameParsers["T*"](O):O.id[0]==="W"&&hi.frameParsers["W*"](O),O.owner==="com.apple.streaming.transportStreamTimestamp"){var V=O.data,te=(V[3]&1)<<30|V[4]<<22|V[5]<<14|V[6]<<6|V[7]>>>2;te*=4,te+=V[7]&3,O.timeStamp=te,E.pts===void 0&&E.dts===void 0&&(E.pts=O.timeStamp,E.dts=O.timeStamp),this.trigger("timestamp",O)}E.frames.push(O),k+=10,k+=I}while(k<d);this.trigger("data",E)}}}},Os.prototype=new dg;var cg=Os,aa=t,oa=ml,Mt=Ps,pg=_l.TimestampRolloverStream,Ms,Un,Rs,Wi=188,la=71;Ms=function(){var o=new Uint8Array(Wi),u=0;Ms.prototype.init.call(this),this.push=function(d){var h=0,g=Wi,y;for(u?(y=new Uint8Array(d.byteLength+u),y.set(o.subarray(0,u)),y.set(d,u),u=0):y=d;g<y.byteLength;){if(y[h]===la&&y[g]===la){this.trigger("data",y.subarray(h,g)),h+=Wi,g+=Wi;continue}h++,g++}h<y.byteLength&&(o.set(y.subarray(h),0),u=y.byteLength-h)},this.flush=function(){u===Wi&&o[0]===la&&(this.trigger("data",o),u=0),this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")},this.reset=function(){u=0,this.trigger("reset")}},Ms.prototype=new aa,Un=function(){var o,u,d,h;Un.prototype.init.call(this),h=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,o=function(g,y){var S=0;y.payloadUnitStartIndicator&&(S+=g[S]+1),y.type==="pat"?u(g.subarray(S),y):d(g.subarray(S),y)},u=function(g,y){y.section_number=g[7],y.last_section_number=g[8],h.pmtPid=(g[10]&31)<<8|g[11],y.pmtPid=h.pmtPid},d=function(g,y){var S,E,k,I;if(g[5]&1){for(h.programMapTable={video:null,audio:null,"timed-metadata":{}},S=(g[1]&15)<<8|g[2],E=3+S-4,k=(g[10]&15)<<8|g[11],I=12+k;I<E;){var O=g[I],j=(g[I+1]&31)<<8|g[I+2];O===Mt.H264_STREAM_TYPE&&h.programMapTable.video===null?h.programMapTable.video=j:O===Mt.ADTS_STREAM_TYPE&&h.programMapTable.audio===null?h.programMapTable.audio=j:O===Mt.METADATA_STREAM_TYPE&&(h.programMapTable["timed-metadata"][j]=O),I+=((g[I+3]&15)<<8|g[I+4])+5}y.programMapTable=h.programMapTable}},this.push=function(g){var y={},S=4;if(y.payloadUnitStartIndicator=!!(g[1]&64),y.pid=g[1]&31,y.pid<<=8,y.pid|=g[2],(g[3]&48)>>>4>1&&(S+=g[S]+1),y.pid===0)y.type="pat",o(g.subarray(S),y),this.trigger("data",y);else if(y.pid===this.pmtPid)for(y.type="pmt",o(g.subarray(S),y),this.trigger("data",y);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([g,S,y]):this.processPes_(g,S,y)},this.processPes_=function(g,y,S){S.pid===this.programMapTable.video?S.streamType=Mt.H264_STREAM_TYPE:S.pid===this.programMapTable.audio?S.streamType=Mt.ADTS_STREAM_TYPE:S.streamType=this.programMapTable["timed-metadata"][S.pid],S.type="pes",S.data=g.subarray(y),this.trigger("data",S)}},Un.prototype=new aa,Un.STREAM_TYPES={h264:27,adts:15},Rs=function(){var o=this,u=!1,d={data:[],size:0},h={data:[],size:0},g={data:[],size:0},y,S=function(k,I){var O;const j=k[0]<<16|k[1]<<8|k[2];I.data=new Uint8Array,j===1&&(I.packetLength=6+(k[4]<<8|k[5]),I.dataAlignmentIndicator=(k[6]&4)!==0,O=k[7],O&192&&(I.pts=(k[9]&14)<<27|(k[10]&255)<<20|(k[11]&254)<<12|(k[12]&255)<<5|(k[13]&254)>>>3,I.pts*=4,I.pts+=(k[13]&6)>>>1,I.dts=I.pts,O&64&&(I.dts=(k[14]&14)<<27|(k[15]&255)<<20|(k[16]&254)<<12|(k[17]&255)<<5|(k[18]&254)>>>3,I.dts*=4,I.dts+=(k[18]&6)>>>1)),I.data=k.subarray(9+k[8]))},E=function(k,I,O){var j=new Uint8Array(k.size),Q={type:I},V=0,te=0,se=!1,ze;if(!(!k.data.length||k.size<9)){for(Q.trackId=k.data[0].pid,V=0;V<k.data.length;V++)ze=k.data[V],j.set(ze.data,te),te+=ze.data.byteLength;S(j,Q),se=I==="video"||Q.packetLength<=k.size,(O||se)&&(k.size=0,k.data.length=0),se&&o.trigger("data",Q)}};Rs.prototype.init.call(this),this.push=function(k){({pat:function(){},pes:function(){var I,O;switch(k.streamType){case Mt.H264_STREAM_TYPE:I=d,O="video";break;case Mt.ADTS_STREAM_TYPE:I=h,O="audio";break;case Mt.METADATA_STREAM_TYPE:I=g,O="timed-metadata";break;default:return}k.payloadUnitStartIndicator&&E(I,O,!0),I.data.push(k),I.size+=k.data.byteLength},pmt:function(){var I={type:"metadata",tracks:[]};y=k.programMapTable,y.video!==null&&I.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+y.video,codec:"avc",type:"video"}),y.audio!==null&&I.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+y.audio,codec:"adts",type:"audio"}),u=!0,o.trigger("data",I)}})[k.type]()},this.reset=function(){d.size=0,d.data.length=0,h.size=0,h.data.length=0,this.trigger("reset")},this.flushStreams_=function(){E(d,"video"),E(h,"audio"),E(g,"timed-metadata")},this.flush=function(){if(!u&&y){var k={type:"metadata",tracks:[]};y.video!==null&&k.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+y.video,codec:"avc",type:"video"}),y.audio!==null&&k.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+y.audio,codec:"adts",type:"audio"}),o.trigger("data",k)}u=!1,this.flushStreams_(),this.trigger("done")}},Rs.prototype=new aa;var vl={PAT_PID:0,MP2T_PACKET_LENGTH:Wi,TransportPacketStream:Ms,TransportParseStream:Un,ElementaryStream:Rs,TimestampRolloverStream:pg,CaptionStream:oa.CaptionStream,Cea608Stream:oa.Cea608Stream,Cea708Stream:oa.Cea708Stream,MetadataStream:cg};for(var ua in Mt)Mt.hasOwnProperty(ua)&&(vl[ua]=Mt[ua]);var gg=vl,fg=t,mg=T.ONE_SECOND_IN_TS,Us,Sl=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];Us=function(o){var u,d=0;Us.prototype.init.call(this),this.skipWarn_=function(h,g){this.trigger("log",{level:"warn",message:`adts skiping bytes ${h} to ${g} in frame ${d} outside syncword`})},this.push=function(h){var g=0,y,S,E,k,I;if(o||(d=0),h.type==="audio"){u&&u.length?(E=u,u=new Uint8Array(E.byteLength+h.data.byteLength),u.set(E),u.set(h.data,E.byteLength)):u=h.data;for(var O;g+7<u.length;){if(u[g]!==255||(u[g+1]&246)!==240){typeof O!="number"&&(O=g),g++;continue}if(typeof O=="number"&&(this.skipWarn_(O,g),O=null),S=(~u[g+1]&1)*2,y=(u[g+3]&3)<<11|u[g+4]<<3|(u[g+5]&224)>>5,k=((u[g+6]&3)+1)*1024,I=k*mg/Sl[(u[g+2]&60)>>>2],u.byteLength-g<y)break;this.trigger("data",{pts:h.pts+d*I,dts:h.dts+d*I,sampleCount:k,audioobjecttype:(u[g+2]>>>6&3)+1,channelcount:(u[g+2]&1)<<2|(u[g+3]&192)>>>6,samplerate:Sl[(u[g+2]&60)>>>2],samplingfrequencyindex:(u[g+2]&60)>>>2,samplesize:16,data:u.subarray(g+7+S,g+y)}),d++,g+=y}typeof O=="number"&&(this.skipWarn_(O,g),O=null),u=u.subarray(g)}},this.flush=function(){d=0,this.trigger("done")},this.reset=function(){u=void 0,this.trigger("reset")},this.endTimeline=function(){u=void 0,this.trigger("endedtimeline")}},Us.prototype=new fg;var yg=Us,El;El=function(o){var u=o.byteLength,d=0,h=0;this.length=function(){return 8*u},this.bitsAvailable=function(){return 8*u+h},this.loadWord=function(){var g=o.byteLength-u,y=new Uint8Array(4),S=Math.min(4,u);if(S===0)throw new Error("no bytes available");y.set(o.subarray(g,g+S)),d=new DataView(y.buffer).getUint32(0),h=S*8,u-=S},this.skipBits=function(g){var y;h>g?(d<<=g,h-=g):(g-=h,y=Math.floor(g/8),g-=y*8,u-=y,this.loadWord(),d<<=g,h-=g)},this.readBits=function(g){var y=Math.min(h,g),S=d>>>32-y;return h-=y,h>0?d<<=y:u>0&&this.loadWord(),y=g-y,y>0?S<<y|this.readBits(y):S},this.skipLeadingZeros=function(){var g;for(g=0;g<h;++g)if(d&2147483648>>>g)return d<<=g,h-=g,g;return this.loadWord(),g+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var g=this.skipLeadingZeros();return this.readBits(g+1)-1},this.readExpGolomb=function(){var g=this.readUnsignedExpGolomb();return 1&g?1+g>>>1:-1*(g>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()};var _g=El,wl=t,bg=_g,Ns,Nn,kl;Nn=function(){var o=0,u,d;Nn.prototype.init.call(this),this.push=function(h){var g;d?(g=new Uint8Array(d.byteLength+h.data.byteLength),g.set(d),g.set(h.data,d.byteLength),d=g):d=h.data;for(var y=d.byteLength;o<y-3;o++)if(d[o+2]===1){u=o+5;break}for(;u<y;)switch(d[u]){case 0:if(d[u-1]!==0){u+=2;break}else if(d[u-2]!==0){u++;break}o+3!==u-2&&this.trigger("data",d.subarray(o+3,u-2));do u++;while(d[u]!==1&&u<y);o=u-2,u+=3;break;case 1:if(d[u-1]!==0||d[u-2]!==0){u+=3;break}this.trigger("data",d.subarray(o+3,u-2)),o=u-2,u+=3;break;default:u+=3;break}d=d.subarray(o),u-=o,o=0},this.reset=function(){d=null,o=0,this.trigger("reset")},this.flush=function(){d&&d.byteLength>3&&this.trigger("data",d.subarray(o+3)),d=null,o=0,this.trigger("done")},this.endTimeline=function(){this.flush(),this.trigger("endedtimeline")}},Nn.prototype=new wl,kl={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},Ns=function(){var o=new Nn,u,d,h,g,y,S,E;Ns.prototype.init.call(this),u=this,this.push=function(k){k.type==="video"&&(d=k.trackId,h=k.pts,g=k.dts,o.push(k))},o.on("data",function(k){var I={trackId:d,pts:h,dts:g,data:k,nalUnitTypeCode:k[0]&31};switch(I.nalUnitTypeCode){case 5:I.nalUnitType="slice_layer_without_partitioning_rbsp_idr";break;case 6:I.nalUnitType="sei_rbsp",I.escapedRBSP=y(k.subarray(1));break;case 7:I.nalUnitType="seq_parameter_set_rbsp",I.escapedRBSP=y(k.subarray(1)),I.config=S(I.escapedRBSP);break;case 8:I.nalUnitType="pic_parameter_set_rbsp";break;case 9:I.nalUnitType="access_unit_delimiter_rbsp";break}u.trigger("data",I)}),o.on("done",function(){u.trigger("done")}),o.on("partialdone",function(){u.trigger("partialdone")}),o.on("reset",function(){u.trigger("reset")}),o.on("endedtimeline",function(){u.trigger("endedtimeline")}),this.flush=function(){o.flush()},this.partialFlush=function(){o.partialFlush()},this.reset=function(){o.reset()},this.endTimeline=function(){o.endTimeline()},E=function(k,I){var O=8,j=8,Q,V;for(Q=0;Q<k;Q++)j!==0&&(V=I.readExpGolomb(),j=(O+V+256)%256),O=j===0?O:j},y=function(k){for(var I=k.byteLength,O=[],j=1,Q,V;j<I-2;)k[j]===0&&k[j+1]===0&&k[j+2]===3?(O.push(j+2),j+=2):j++;if(O.length===0)return k;Q=I-O.length,V=new Uint8Array(Q);var te=0;for(j=0;j<Q;te++,j++)te===O[0]&&(te++,O.shift()),V[j]=k[te];return V},S=function(k){var I=0,O=0,j=0,Q=0,V,te,se,ze,nt,qt,zn,Ks,Ys,Pi,Wn,Ie=[1,1],tu,Li;if(V=new bg(k),te=V.readUnsignedByte(),ze=V.readUnsignedByte(),se=V.readUnsignedByte(),V.skipUnsignedExpGolomb(),kl[te]&&(nt=V.readUnsignedExpGolomb(),nt===3&&V.skipBits(1),V.skipUnsignedExpGolomb(),V.skipUnsignedExpGolomb(),V.skipBits(1),V.readBoolean()))for(Wn=nt!==3?8:12,Li=0;Li<Wn;Li++)V.readBoolean()&&(Li<6?E(16,V):E(64,V));if(V.skipUnsignedExpGolomb(),qt=V.readUnsignedExpGolomb(),qt===0)V.readUnsignedExpGolomb();else if(qt===1)for(V.skipBits(1),V.skipExpGolomb(),V.skipExpGolomb(),zn=V.readUnsignedExpGolomb(),Li=0;Li<zn;Li++)V.skipExpGolomb();if(V.skipUnsignedExpGolomb(),V.skipBits(1),Ks=V.readUnsignedExpGolomb(),Ys=V.readUnsignedExpGolomb(),Pi=V.readBits(1),Pi===0&&V.skipBits(1),V.skipBits(1),V.readBoolean()&&(I=V.readUnsignedExpGolomb(),O=V.readUnsignedExpGolomb(),j=V.readUnsignedExpGolomb(),Q=V.readUnsignedExpGolomb()),V.readBoolean()&&V.readBoolean()){switch(tu=V.readUnsignedByte(),tu){case 1:Ie=[1,1];break;case 2:Ie=[12,11];break;case 3:Ie=[10,11];break;case 4:Ie=[16,11];break;case 5:Ie=[40,33];break;case 6:Ie=[24,11];break;case 7:Ie=[20,11];break;case 8:Ie=[32,11];break;case 9:Ie=[80,33];break;case 10:Ie=[18,11];break;case 11:Ie=[15,11];break;case 12:Ie=[64,33];break;case 13:Ie=[160,99];break;case 14:Ie=[4,3];break;case 15:Ie=[3,2];break;case 16:Ie=[2,1];break;case 255:{Ie=[V.readUnsignedByte()<<8|V.readUnsignedByte(),V.readUnsignedByte()<<8|V.readUnsignedByte()];break}}Ie&&Ie[0]/Ie[1]}return{profileIdc:te,levelIdc:se,profileCompatibility:ze,width:(Ks+1)*16-I*2-O*2,height:(2-Pi)*(Ys+1)*16-j*2-Q*2,sarRatio:Ie}}},Ns.prototype=new wl;var Tg={H264Stream:Ns,NalByteStream:Nn},vg=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],Cl=function(o,u){var d=o[u+6]<<21|o[u+7]<<14|o[u+8]<<7|o[u+9],h=o[u+5],g=(h&16)>>4;return d=d>=0?d:0,g?d+20:d+10},Il=function(o,u){return o.length-u<10||o[u]!==73||o[u+1]!==68||o[u+2]!==51?u:(u+=Cl(o,u),Il(o,u))},Sg=function(o){var u=Il(o,0);return o.length>=u+2&&(o[u]&255)===255&&(o[u+1]&240)===240&&(o[u+1]&22)===16},xl=function(o){return o[0]<<21|o[1]<<14|o[2]<<7|o[3]},Eg=function(o,u,d){var h,g="";for(h=u;h<d;h++)g+="%"+("00"+o[h].toString(16)).slice(-2);return g},wg=function(o,u,d){return unescape(Eg(o,u,d))},kg=function(o,u){var d=(o[u+5]&224)>>5,h=o[u+4]<<3,g=o[u+3]&6144;return g|h|d},Cg=function(o,u){return o[u]===73&&o[u+1]===68&&o[u+2]===51?"timed-metadata":o[u]&!0&&(o[u+1]&240)===240?"audio":null},Ig=function(o){for(var u=0;u+5<o.length;){if(o[u]!==255||(o[u+1]&246)!==240){u++;continue}return vg[(o[u+2]&60)>>>2]}return null},xg=function(o){var u,d,h,g;u=10,o[5]&64&&(u+=4,u+=xl(o.subarray(10,14)));do{if(d=xl(o.subarray(u+4,u+8)),d<1)return null;if(g=String.fromCharCode(o[u],o[u+1],o[u+2],o[u+3]),g==="PRIV"){h=o.subarray(u+10,u+d+10);for(var y=0;y<h.byteLength;y++)if(h[y]===0){var S=wg(h,0,y);if(S==="com.apple.streaming.transportStreamTimestamp"){var E=h.subarray(y+1),k=(E[3]&1)<<30|E[4]<<22|E[5]<<14|E[6]<<6|E[7]>>>2;return k*=4,k+=E[7]&3,k}break}}u+=10,u+=d}while(u<o.byteLength);return null},da={isLikelyAacData:Sg,parseId3TagSize:Cl,parseAdtsSize:kg,parseType:Cg,parseSampleRate:Ig,parseAacTimestamp:xg},Ag=t,Al=da,Bs;Bs=function(){var o=new Uint8Array,u=0;Bs.prototype.init.call(this),this.setTimestamp=function(d){u=d},this.push=function(d){var h=0,g=0,y,S,E,k;for(o.length?(k=o.length,o=new Uint8Array(d.byteLength+k),o.set(o.subarray(0,k)),o.set(d,k)):o=d;o.length-g>=3;){if(o[g]===73&&o[g+1]===68&&o[g+2]===51){if(o.length-g<10||(h=Al.parseId3TagSize(o,g),g+h>o.length))break;S={type:"timed-metadata",data:o.subarray(g,g+h)},this.trigger("data",S),g+=h;continue}else if((o[g]&255)===255&&(o[g+1]&240)===240){if(o.length-g<7||(h=Al.parseAdtsSize(o,g),g+h>o.length))break;E={type:"audio",data:o.subarray(g,g+h),pts:u,dts:u},this.trigger("data",E),g+=h;continue}g++}y=o.length-g,y>0?o=o.subarray(g):o=new Uint8Array},this.reset=function(){o=new Uint8Array,this.trigger("reset")},this.endTimeline=function(){o=new Uint8Array,this.trigger("endedtimeline")}},Bs.prototype=new Ag;var Pg=Bs,Lg=["audioobjecttype","channelcount","samplerate","samplingfrequencyindex","samplesize"],Dg=Lg,Og=["width","height","profileIdc","levelIdc","profileCompatibility","sarRatio"],Mg=Og,Fs=t,Bn=Hi,Fn=ki,js=Te,Rt=Xp,ti=gg,$s=T,Pl=yg,Rg=Tg.H264Stream,Ug=Pg,Ng=da.isLikelyAacData,Bg=T.ONE_SECOND_IN_TS,ha=Dg,ca=Mg,jn,Gi,qs,xi,Fg=function(o,u){u.stream=o,this.trigger("log",u)},Ll=function(o,u){for(var d=Object.keys(u),h=0;h<d.length;h++){var g=d[h];g==="headOfPipeline"||!u[g].on||u[g].on("log",Fg.bind(o,g))}},Dl=function(o,u){var d;if(o.length!==u.length)return!1;for(d=0;d<o.length;d++)if(o[d]!==u[d])return!1;return!0},pa=function(o,u,d,h,g,y){var S=d-u,E=h-u,k=g-d;return{start:{dts:o,pts:o+S},end:{dts:o+E,pts:o+k},prependedContentDuration:y,baseMediaDecodeTime:o}};Gi=function(o,u){var d=[],h,g=0,y=0,S=1/0;u=u||{},h=u.firstSequenceNumber||0,Gi.prototype.init.call(this),this.push=function(E){Rt.collectDtsInfo(o,E),o&&ha.forEach(function(k){o[k]=E[k]}),d.push(E)},this.setEarliestDts=function(E){g=E},this.setVideoBaseMediaDecodeTime=function(E){S=E},this.setAudioAppendStart=function(E){y=E},this.flush=function(){var E,k,I,O,j,Q,V;if(d.length===0){this.trigger("done","AudioSegmentStream");return}E=js.trimAdtsFramesByEarliestDts(d,o,g),o.baseMediaDecodeTime=Rt.calculateTrackBaseMediaDecodeTime(o,u.keepOriginalTimestamps),V=js.prefixWithSilence(o,E,y,S),o.samples=js.generateSampleTable(E),I=Bn.mdat(js.concatenateFrameData(E)),d=[],k=Bn.moof(h,[o]),O=new Uint8Array(k.byteLength+I.byteLength),h++,O.set(k),O.set(I,k.byteLength),Rt.clearDtsInfo(o),j=Math.ceil(Bg*1024/o.samplerate),E.length&&(Q=E.length*j,this.trigger("segmentTimingInfo",pa($s.audioTsToVideoTs(o.baseMediaDecodeTime,o.samplerate),E[0].dts,E[0].pts,E[0].dts+Q,E[0].pts+Q,V||0)),this.trigger("timingInfo",{start:E[0].pts,end:E[0].pts+Q})),this.trigger("data",{track:o,boxes:O}),this.trigger("done","AudioSegmentStream")},this.reset=function(){Rt.clearDtsInfo(o),d=[],this.trigger("reset")}},Gi.prototype=new Fs,jn=function(o,u){var d,h=[],g=[],y,S;u=u||{},d=u.firstSequenceNumber||0,jn.prototype.init.call(this),delete o.minPTS,this.gopCache_=[],this.push=function(E){Rt.collectDtsInfo(o,E),E.nalUnitType==="seq_parameter_set_rbsp"&&!y&&(y=E.config,o.sps=[E.data],ca.forEach(function(k){o[k]=y[k]},this)),E.nalUnitType==="pic_parameter_set_rbsp"&&!S&&(S=E.data,o.pps=[E.data]),h.push(E)},this.flush=function(){for(var E,k,I,O,j,Q,V=0,te,se;h.length&&h[0].nalUnitType!=="access_unit_delimiter_rbsp";)h.shift();if(h.length===0){this.resetStream_(),this.trigger("done","VideoSegmentStream");return}if(E=Fn.groupNalsIntoFrames(h),I=Fn.groupFramesIntoGops(E),I[0][0].keyFrame||(k=this.getGopForFusion_(h[0],o),k?(V=k.duration,I.unshift(k),I.byteLength+=k.byteLength,I.nalCount+=k.nalCount,I.pts=k.pts,I.dts=k.dts,I.duration+=k.duration):I=Fn.extendFirstKeyFrame(I)),g.length){var ze;if(u.alignGopsAtEnd?ze=this.alignGopsAtEnd_(I):ze=this.alignGopsAtStart_(I),!ze){this.gopCache_.unshift({gop:I.pop(),pps:o.pps,sps:o.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),h=[],this.resetStream_(),this.trigger("done","VideoSegmentStream");return}Rt.clearDtsInfo(o),I=ze}Rt.collectDtsInfo(o,I),o.samples=Fn.generateSampleTable(I),j=Bn.mdat(Fn.concatenateNalData(I)),o.baseMediaDecodeTime=Rt.calculateTrackBaseMediaDecodeTime(o,u.keepOriginalTimestamps),this.trigger("processedGopsInfo",I.map(function(nt){return{pts:nt.pts,dts:nt.dts,byteLength:nt.byteLength}})),te=I[0],se=I[I.length-1],this.trigger("segmentTimingInfo",pa(o.baseMediaDecodeTime,te.dts,te.pts,se.dts+se.duration,se.pts+se.duration,V)),this.trigger("timingInfo",{start:I[0].pts,end:I[I.length-1].pts+I[I.length-1].duration}),this.gopCache_.unshift({gop:I.pop(),pps:o.pps,sps:o.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),h=[],this.trigger("baseMediaDecodeTime",o.baseMediaDecodeTime),this.trigger("timelineStartInfo",o.timelineStartInfo),O=Bn.moof(d,[o]),Q=new Uint8Array(O.byteLength+j.byteLength),d++,Q.set(O),Q.set(j,O.byteLength),this.trigger("data",{track:o,boxes:Q}),this.resetStream_(),this.trigger("done","VideoSegmentStream")},this.reset=function(){this.resetStream_(),h=[],this.gopCache_.length=0,g.length=0,this.trigger("reset")},this.resetStream_=function(){Rt.clearDtsInfo(o),y=void 0,S=void 0},this.getGopForFusion_=function(E){var k=45e3,I=1e4,O=1/0,j,Q,V,te,se;for(se=0;se<this.gopCache_.length;se++)te=this.gopCache_[se],V=te.gop,!(!(o.pps&&Dl(o.pps[0],te.pps[0]))||!(o.sps&&Dl(o.sps[0],te.sps[0])))&&(V.dts<o.timelineStartInfo.dts||(j=E.dts-V.dts-V.duration,j>=-I&&j<=k&&(!Q||O>j)&&(Q=te,O=j)));return Q?Q.gop:null},this.alignGopsAtStart_=function(E){var k,I,O,j,Q,V,te,se;for(Q=E.byteLength,V=E.nalCount,te=E.duration,k=I=0;k<g.length&&I<E.length&&(O=g[k],j=E[I],O.pts!==j.pts);){if(j.pts>O.pts){k++;continue}I++,Q-=j.byteLength,V-=j.nalCount,te-=j.duration}return I===0?E:I===E.length?null:(se=E.slice(I),se.byteLength=Q,se.duration=te,se.nalCount=V,se.pts=se[0].pts,se.dts=se[0].dts,se)},this.alignGopsAtEnd_=function(E){var k,I,O,j,Q,V;for(k=g.length-1,I=E.length-1,Q=null,V=!1;k>=0&&I>=0;){if(O=g[k],j=E[I],O.pts===j.pts){V=!0;break}if(O.pts>j.pts){k--;continue}k===g.length-1&&(Q=I),I--}if(!V&&Q===null)return null;var te;if(V?te=I:te=Q,te===0)return E;var se=E.slice(te),ze=se.reduce(function(nt,qt){return nt.byteLength+=qt.byteLength,nt.duration+=qt.duration,nt.nalCount+=qt.nalCount,nt},{byteLength:0,duration:0,nalCount:0});return se.byteLength=ze.byteLength,se.duration=ze.duration,se.nalCount=ze.nalCount,se.pts=se[0].pts,se.dts=se[0].dts,se},this.alignGopsWith=function(E){g=E}},jn.prototype=new Fs,xi=function(o,u){this.numberOfTracks=0,this.metadataStream=u,o=o||{},typeof o.remux<"u"?this.remuxTracks=!!o.remux:this.remuxTracks=!0,typeof o.keepOriginalTimestamps=="boolean"?this.keepOriginalTimestamps=o.keepOriginalTimestamps:this.keepOriginalTimestamps=!1,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,xi.prototype.init.call(this),this.push=function(d){if(d.content||d.text)return this.pendingCaptions.push(d);if(d.frames)return this.pendingMetadata.push(d);this.pendingTracks.push(d.track),this.pendingBytes+=d.boxes.byteLength,d.track.type==="video"&&(this.videoTrack=d.track,this.pendingBoxes.push(d.boxes)),d.track.type==="audio"&&(this.audioTrack=d.track,this.pendingBoxes.unshift(d.boxes))}},xi.prototype=new Fs,xi.prototype.flush=function(o){var u=0,d={captions:[],captionStreams:{},metadata:[],info:{}},h,g,y,S=0,E;if(this.pendingTracks.length<this.numberOfTracks){if(o!=="VideoSegmentStream"&&o!=="AudioSegmentStream"||this.remuxTracks)return;if(this.pendingTracks.length===0){this.emittedTracks++,this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0);return}}if(this.videoTrack?(S=this.videoTrack.timelineStartInfo.pts,ca.forEach(function(k){d.info[k]=this.videoTrack[k]},this)):this.audioTrack&&(S=this.audioTrack.timelineStartInfo.pts,ha.forEach(function(k){d.info[k]=this.audioTrack[k]},this)),this.videoTrack||this.audioTrack){for(this.pendingTracks.length===1?d.type=this.pendingTracks[0].type:d.type="combined",this.emittedTracks+=this.pendingTracks.length,y=Bn.initSegment(this.pendingTracks),d.initSegment=new Uint8Array(y.byteLength),d.initSegment.set(y),d.data=new Uint8Array(this.pendingBytes),E=0;E<this.pendingBoxes.length;E++)d.data.set(this.pendingBoxes[E],u),u+=this.pendingBoxes[E].byteLength;for(E=0;E<this.pendingCaptions.length;E++)h=this.pendingCaptions[E],h.startTime=$s.metadataTsToSeconds(h.startPts,S,this.keepOriginalTimestamps),h.endTime=$s.metadataTsToSeconds(h.endPts,S,this.keepOriginalTimestamps),d.captionStreams[h.stream]=!0,d.captions.push(h);for(E=0;E<this.pendingMetadata.length;E++)g=this.pendingMetadata[E],g.cueTime=$s.metadataTsToSeconds(g.pts,S,this.keepOriginalTimestamps),d.metadata.push(g);for(d.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger("data",d),E=0;E<d.captions.length;E++)h=d.captions[E],this.trigger("caption",h);for(E=0;E<d.metadata.length;E++)g=d.metadata[E],this.trigger("id3Frame",g)}this.emittedTracks>=this.numberOfTracks&&(this.trigger("done"),this.emittedTracks=0)},xi.prototype.setRemux=function(o){this.remuxTracks=o},qs=function(o){var u=this,d=!0,h,g;qs.prototype.init.call(this),o=o||{},this.baseMediaDecodeTime=o.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var y={};this.transmuxPipeline_=y,y.type="aac",y.metadataStream=new ti.MetadataStream,y.aacStream=new Ug,y.audioTimestampRolloverStream=new ti.TimestampRolloverStream("audio"),y.timedMetadataTimestampRolloverStream=new ti.TimestampRolloverStream("timed-metadata"),y.adtsStream=new Pl,y.coalesceStream=new xi(o,y.metadataStream),y.headOfPipeline=y.aacStream,y.aacStream.pipe(y.audioTimestampRolloverStream).pipe(y.adtsStream),y.aacStream.pipe(y.timedMetadataTimestampRolloverStream).pipe(y.metadataStream).pipe(y.coalesceStream),y.metadataStream.on("timestamp",function(S){y.aacStream.setTimestamp(S.timeStamp)}),y.aacStream.on("data",function(S){S.type!=="timed-metadata"&&S.type!=="audio"||y.audioSegmentStream||(g=g||{timelineStartInfo:{baseMediaDecodeTime:u.baseMediaDecodeTime},codec:"adts",type:"audio"},y.coalesceStream.numberOfTracks++,y.audioSegmentStream=new Gi(g,o),y.audioSegmentStream.on("log",u.getLogTrigger_("audioSegmentStream")),y.audioSegmentStream.on("timingInfo",u.trigger.bind(u,"audioTimingInfo")),y.adtsStream.pipe(y.audioSegmentStream).pipe(y.coalesceStream),u.trigger("trackinfo",{hasAudio:!!g,hasVideo:!!h}))}),y.coalesceStream.on("data",this.trigger.bind(this,"data")),y.coalesceStream.on("done",this.trigger.bind(this,"done")),Ll(this,y)},this.setupTsPipeline=function(){var y={};this.transmuxPipeline_=y,y.type="ts",y.metadataStream=new ti.MetadataStream,y.packetStream=new ti.TransportPacketStream,y.parseStream=new ti.TransportParseStream,y.elementaryStream=new ti.ElementaryStream,y.timestampRolloverStream=new ti.TimestampRolloverStream,y.adtsStream=new Pl,y.h264Stream=new Rg,y.captionStream=new ti.CaptionStream(o),y.coalesceStream=new xi(o,y.metadataStream),y.headOfPipeline=y.packetStream,y.packetStream.pipe(y.parseStream).pipe(y.elementaryStream).pipe(y.timestampRolloverStream),y.timestampRolloverStream.pipe(y.h264Stream),y.timestampRolloverStream.pipe(y.adtsStream),y.timestampRolloverStream.pipe(y.metadataStream).pipe(y.coalesceStream),y.h264Stream.pipe(y.captionStream).pipe(y.coalesceStream),y.elementaryStream.on("data",function(S){var E;if(S.type==="metadata"){for(E=S.tracks.length;E--;)!h&&S.tracks[E].type==="video"?(h=S.tracks[E],h.timelineStartInfo.baseMediaDecodeTime=u.baseMediaDecodeTime):!g&&S.tracks[E].type==="audio"&&(g=S.tracks[E],g.timelineStartInfo.baseMediaDecodeTime=u.baseMediaDecodeTime);h&&!y.videoSegmentStream&&(y.coalesceStream.numberOfTracks++,y.videoSegmentStream=new jn(h,o),y.videoSegmentStream.on("log",u.getLogTrigger_("videoSegmentStream")),y.videoSegmentStream.on("timelineStartInfo",function(k){g&&!o.keepOriginalTimestamps&&(g.timelineStartInfo=k,y.audioSegmentStream.setEarliestDts(k.dts-u.baseMediaDecodeTime))}),y.videoSegmentStream.on("processedGopsInfo",u.trigger.bind(u,"gopInfo")),y.videoSegmentStream.on("segmentTimingInfo",u.trigger.bind(u,"videoSegmentTimingInfo")),y.videoSegmentStream.on("baseMediaDecodeTime",function(k){g&&y.audioSegmentStream.setVideoBaseMediaDecodeTime(k)}),y.videoSegmentStream.on("timingInfo",u.trigger.bind(u,"videoTimingInfo")),y.h264Stream.pipe(y.videoSegmentStream).pipe(y.coalesceStream)),g&&!y.audioSegmentStream&&(y.coalesceStream.numberOfTracks++,y.audioSegmentStream=new Gi(g,o),y.audioSegmentStream.on("log",u.getLogTrigger_("audioSegmentStream")),y.audioSegmentStream.on("timingInfo",u.trigger.bind(u,"audioTimingInfo")),y.audioSegmentStream.on("segmentTimingInfo",u.trigger.bind(u,"audioSegmentTimingInfo")),y.adtsStream.pipe(y.audioSegmentStream).pipe(y.coalesceStream)),u.trigger("trackinfo",{hasAudio:!!g,hasVideo:!!h})}}),y.coalesceStream.on("data",this.trigger.bind(this,"data")),y.coalesceStream.on("id3Frame",function(S){S.dispatchType=y.metadataStream.dispatchType,u.trigger("id3Frame",S)}),y.coalesceStream.on("caption",this.trigger.bind(this,"caption")),y.coalesceStream.on("done",this.trigger.bind(this,"done")),Ll(this,y)},this.setBaseMediaDecodeTime=function(y){var S=this.transmuxPipeline_;o.keepOriginalTimestamps||(this.baseMediaDecodeTime=y),g&&(g.timelineStartInfo.dts=void 0,g.timelineStartInfo.pts=void 0,Rt.clearDtsInfo(g),S.audioTimestampRolloverStream&&S.audioTimestampRolloverStream.discontinuity()),h&&(S.videoSegmentStream&&(S.videoSegmentStream.gopCache_=[]),h.timelineStartInfo.dts=void 0,h.timelineStartInfo.pts=void 0,Rt.clearDtsInfo(h),S.captionStream.reset()),S.timestampRolloverStream&&S.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(y){g&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(y)},this.setRemux=function(y){var S=this.transmuxPipeline_;o.remux=y,S&&S.coalesceStream&&S.coalesceStream.setRemux(y)},this.alignGopsWith=function(y){h&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(y)},this.getLogTrigger_=function(y){var S=this;return function(E){E.stream=y,S.trigger("log",E)}},this.push=function(y){if(d){var S=Ng(y);S&&this.transmuxPipeline_.type!=="aac"?this.setupAacPipeline():!S&&this.transmuxPipeline_.type!=="ts"&&this.setupTsPipeline(),d=!1}this.transmuxPipeline_.headOfPipeline.push(y)},this.flush=function(){d=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}},qs.prototype=new Fs;var jg={Transmuxer:qs,VideoSegmentStream:jn,AudioSegmentStream:Gi,AUDIO_PROPERTIES:ha,VIDEO_PROPERTIES:ca,generateSegmentTimingInfo:pa},$g=function(o){return o>>>0},qg=function(o){return("00"+o.toString(16)).slice(-2)},Vs={toUnsigned:$g,toHexString:qg},Vg=function(o){var u="";return u+=String.fromCharCode(o[0]),u+=String.fromCharCode(o[1]),u+=String.fromCharCode(o[2]),u+=String.fromCharCode(o[3]),u},ga=Vg,Hg=Vs.toUnsigned,zg=ga,Ol=function(o,u){var d=[],h,g,y,S,E;if(!u.length)return null;for(h=0;h<o.byteLength;)g=Hg(o[h]<<24|o[h+1]<<16|o[h+2]<<8|o[h+3]),y=zg(o.subarray(h+4,h+8)),S=g>1?h+g:o.byteLength,y===u[0]&&(u.length===1?d.push(o.subarray(h+8,S)):(E=Ol(o.subarray(h+8,S),u.slice(1)),E.length&&(d=d.concat(E)))),h=S;return d},Hs=Ol,Wg=Vs.toUnsigned,Gg=r.getUint64,Xg=function(o){var u={version:o[0],flags:new Uint8Array(o.subarray(1,4))};return u.version===1?u.baseMediaDecodeTime=Gg(o.subarray(4)):u.baseMediaDecodeTime=Wg(o[4]<<24|o[5]<<16|o[6]<<8|o[7]),u},fa=Xg,Kg=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),trackId:u.getUint32(4)},h=d.flags[2]&1,g=d.flags[2]&2,y=d.flags[2]&8,S=d.flags[2]&16,E=d.flags[2]&32,k=d.flags[0]&65536,I=d.flags[0]&131072,O;return O=8,h&&(O+=4,d.baseDataOffset=u.getUint32(12),O+=4),g&&(d.sampleDescriptionIndex=u.getUint32(O),O+=4),y&&(d.defaultSampleDuration=u.getUint32(O),O+=4),S&&(d.defaultSampleSize=u.getUint32(O),O+=4),E&&(d.defaultSampleFlags=u.getUint32(O)),k&&(d.durationIsEmpty=!0),!h&&I&&(d.baseDataOffsetIsMoof=!0),d},ma=Kg,Ml=r.getUint64,Yg=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),references:[],referenceId:u.getUint32(4),timescale:u.getUint32(8)},h=12;d.version===0?(d.earliestPresentationTime=u.getUint32(h),d.firstOffset=u.getUint32(h+4),h+=8):(d.earliestPresentationTime=Ml(o.subarray(h)),d.firstOffset=Ml(o.subarray(h+8)),h+=16),h+=2;var g=u.getUint16(h);for(h+=2;g>0;h+=12,g--)d.references.push({referenceType:(o[h]&128)>>>7,referencedSize:u.getUint32(h)&2147483647,subsegmentDuration:u.getUint32(h+4),startsWithSap:!!(o[h+8]&128),sapType:(o[h+8]&112)>>>4,sapDeltaTime:u.getUint32(h+8)&268435455});return d},Qg=Yg,Jg=function(o){return{isLeading:(o[0]&12)>>>2,dependsOn:o[0]&3,isDependedOn:(o[1]&192)>>>6,hasRedundancy:(o[1]&48)>>>4,paddingValue:(o[1]&14)>>>1,isNonSyncSample:o[1]&1,degradationPriority:o[2]<<8|o[3]}},Zg=Jg,Rl=Zg,ef=function(o){var u={version:o[0],flags:new Uint8Array(o.subarray(1,4)),samples:[]},d=new DataView(o.buffer,o.byteOffset,o.byteLength),h=u.flags[2]&1,g=u.flags[2]&4,y=u.flags[1]&1,S=u.flags[1]&2,E=u.flags[1]&4,k=u.flags[1]&8,I=d.getUint32(4),O=8,j;for(h&&(u.dataOffset=d.getInt32(O),O+=4),g&&I&&(j={flags:Rl(o.subarray(O,O+4))},O+=4,y&&(j.duration=d.getUint32(O),O+=4),S&&(j.size=d.getUint32(O),O+=4),k&&(u.version===1?j.compositionTimeOffset=d.getInt32(O):j.compositionTimeOffset=d.getUint32(O),O+=4),u.samples.push(j),I--);I--;)j={},y&&(j.duration=d.getUint32(O),O+=4),S&&(j.size=d.getUint32(O),O+=4),E&&(j.flags=Rl(o.subarray(O,O+4)),O+=4),k&&(u.version===1?j.compositionTimeOffset=d.getInt32(O):j.compositionTimeOffset=d.getUint32(O),O+=4),u.samples.push(j);return u},Ul=ef,tf=r,Nl=tf.getUint64,Qe,ya,kt=function(o){return new Date(o*1e3-20828448e5)},$n=ga,nf=Hs,sf=function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=[],h,g;for(h=0;h+4<o.length;h+=g){if(g=u.getUint32(h),h+=4,g<=0){d.push("<span style='color:red;'>MALFORMED DATA</span>");continue}switch(o[h]&31){case 1:d.push("slice_layer_without_partitioning_rbsp");break;case 5:d.push("slice_layer_without_partitioning_rbsp_idr");break;case 6:d.push("sei_rbsp");break;case 7:d.push("seq_parameter_set_rbsp");break;case 8:d.push("pic_parameter_set_rbsp");break;case 9:d.push("access_unit_delimiter_rbsp");break;default:d.push("UNKNOWN NAL - "+o[h]&31);break}}return d},ci={avc1:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{dataReferenceIndex:u.getUint16(6),width:u.getUint16(24),height:u.getUint16(26),horizresolution:u.getUint16(28)+u.getUint16(30)/16,vertresolution:u.getUint16(32)+u.getUint16(34)/16,frameCount:u.getUint16(40),depth:u.getUint16(74),config:Qe(o.subarray(78,o.byteLength))}},avcC:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={configurationVersion:o[0],avcProfileIndication:o[1],profileCompatibility:o[2],avcLevelIndication:o[3],lengthSizeMinusOne:o[4]&3,sps:[],pps:[]},h=o[5]&31,g,y,S,E;for(S=6,E=0;E<h;E++)y=u.getUint16(S),S+=2,d.sps.push(new Uint8Array(o.subarray(S,S+y))),S+=y;for(g=o[S],S++,E=0;E<g;E++)y=u.getUint16(S),S+=2,d.pps.push(new Uint8Array(o.subarray(S,S+y))),S+=y;return d},btrt:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{bufferSizeDB:u.getUint32(0),maxBitrate:u.getUint32(4),avgBitrate:u.getUint32(8)}},edts:function(o){return{boxes:Qe(o)}},elst:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),edits:[]},h=u.getUint32(4),g;for(g=8;h;h--)d.version===0?(d.edits.push({segmentDuration:u.getUint32(g),mediaTime:u.getInt32(g+4),mediaRate:u.getUint16(g+8)+u.getUint16(g+10)/(256*256)}),g+=12):(d.edits.push({segmentDuration:Nl(o.subarray(g)),mediaTime:Nl(o.subarray(g+8)),mediaRate:u.getUint16(g+16)+u.getUint16(g+18)/(256*256)}),g+=20);return d},esds:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),esId:o[6]<<8|o[7],streamPriority:o[8]&31,decoderConfig:{objectProfileIndication:o[11],streamType:o[12]>>>2&63,bufferSize:o[13]<<16|o[14]<<8|o[15],maxBitrate:o[16]<<24|o[17]<<16|o[18]<<8|o[19],avgBitrate:o[20]<<24|o[21]<<16|o[22]<<8|o[23],decoderConfigDescriptor:{tag:o[24],length:o[25],audioObjectType:o[26]>>>3&31,samplingFrequencyIndex:(o[26]&7)<<1|o[27]>>>7&1,channelConfiguration:o[27]>>>3&15}}}},ftyp:function(o){for(var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={majorBrand:$n(o.subarray(0,4)),minorVersion:u.getUint32(4),compatibleBrands:[]},h=8;h<o.byteLength;)d.compatibleBrands.push($n(o.subarray(h,h+4))),h+=4;return d},dinf:function(o){return{boxes:Qe(o)}},dref:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),dataReferences:Qe(o.subarray(8))}},hdlr:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),handlerType:$n(o.subarray(8,12)),name:""},h=8;for(h=24;h<o.byteLength;h++){if(o[h]===0){h++;break}d.name+=String.fromCharCode(o[h])}return d.name=decodeURIComponent(escape(d.name)),d},mdat:function(o){return{byteLength:o.byteLength,nals:sf(o)}},mdhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=4,h,g={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),language:""};return g.version===1?(d+=4,g.creationTime=kt(u.getUint32(d)),d+=8,g.modificationTime=kt(u.getUint32(d)),d+=4,g.timescale=u.getUint32(d),d+=8,g.duration=u.getUint32(d)):(g.creationTime=kt(u.getUint32(d)),d+=4,g.modificationTime=kt(u.getUint32(d)),d+=4,g.timescale=u.getUint32(d),d+=4,g.duration=u.getUint32(d)),d+=4,h=u.getUint16(d),g.language+=String.fromCharCode((h>>10)+96),g.language+=String.fromCharCode(((h&992)>>5)+96),g.language+=String.fromCharCode((h&31)+96),g},mdia:function(o){return{boxes:Qe(o)}},mfhd:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),sequenceNumber:o[4]<<24|o[5]<<16|o[6]<<8|o[7]}},minf:function(o){return{boxes:Qe(o)}},mp4a:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={dataReferenceIndex:u.getUint16(6),channelcount:u.getUint16(16),samplesize:u.getUint16(18),samplerate:u.getUint16(24)+u.getUint16(26)/65536};return o.byteLength>28&&(d.streamDescriptor=Qe(o.subarray(28))[0]),d},moof:function(o){return{boxes:Qe(o)}},moov:function(o){return{boxes:Qe(o)}},mvex:function(o){return{boxes:Qe(o)}},mvhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=4,h={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4))};return h.version===1?(d+=4,h.creationTime=kt(u.getUint32(d)),d+=8,h.modificationTime=kt(u.getUint32(d)),d+=4,h.timescale=u.getUint32(d),d+=8,h.duration=u.getUint32(d)):(h.creationTime=kt(u.getUint32(d)),d+=4,h.modificationTime=kt(u.getUint32(d)),d+=4,h.timescale=u.getUint32(d),d+=4,h.duration=u.getUint32(d)),d+=4,h.rate=u.getUint16(d)+u.getUint16(d+2)/16,d+=4,h.volume=u.getUint8(d)+u.getUint8(d+1)/8,d+=2,d+=2,d+=2*4,h.matrix=new Uint32Array(o.subarray(d,d+9*4)),d+=9*4,d+=6*4,h.nextTrackId=u.getUint32(d),h},pdin:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),rate:u.getUint32(4),initialDelay:u.getUint32(8)}},sdtp:function(o){var u={version:o[0],flags:new Uint8Array(o.subarray(1,4)),samples:[]},d;for(d=4;d<o.byteLength;d++)u.samples.push({dependsOn:(o[d]&48)>>4,isDependedOn:(o[d]&12)>>2,hasRedundancy:o[d]&3});return u},sidx:Qg,smhd:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),balance:o[4]+o[5]/256}},stbl:function(o){return{boxes:Qe(o)}},ctts:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),compositionOffsets:[]},h=u.getUint32(4),g;for(g=8;h;g+=8,h--)d.compositionOffsets.push({sampleCount:u.getUint32(g),sampleOffset:u[d.version===0?"getUint32":"getInt32"](g+4)});return d},stss:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4)),syncSamples:[]},h=u.getUint32(4),g;for(g=8;h;g+=4,h--)d.syncSamples.push(u.getUint32(g));return d},stco:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),chunkOffsets:[]},h=u.getUint32(4),g;for(g=8;h;g+=4,h--)d.chunkOffsets.push(u.getUint32(g));return d},stsc:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=u.getUint32(4),h={version:o[0],flags:new Uint8Array(o.subarray(1,4)),sampleToChunks:[]},g;for(g=8;d;g+=12,d--)h.sampleToChunks.push({firstChunk:u.getUint32(g),samplesPerChunk:u.getUint32(g+4),sampleDescriptionIndex:u.getUint32(g+8)});return h},stsd:function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),sampleDescriptions:Qe(o.subarray(8))}},stsz:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),sampleSize:u.getUint32(4),entries:[]},h;for(h=12;h<o.byteLength;h+=4)d.entries.push(u.getUint32(h));return d},stts:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d={version:o[0],flags:new Uint8Array(o.subarray(1,4)),timeToSamples:[]},h=u.getUint32(4),g;for(g=8;h;g+=8,h--)d.timeToSamples.push({sampleCount:u.getUint32(g),sampleDelta:u.getUint32(g+4)});return d},styp:function(o){return ci.ftyp(o)},tfdt:fa,tfhd:ma,tkhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=4,h={version:u.getUint8(0),flags:new Uint8Array(o.subarray(1,4))};return h.version===1?(d+=4,h.creationTime=kt(u.getUint32(d)),d+=8,h.modificationTime=kt(u.getUint32(d)),d+=4,h.trackId=u.getUint32(d),d+=4,d+=8,h.duration=u.getUint32(d)):(h.creationTime=kt(u.getUint32(d)),d+=4,h.modificationTime=kt(u.getUint32(d)),d+=4,h.trackId=u.getUint32(d),d+=4,d+=4,h.duration=u.getUint32(d)),d+=4,d+=2*4,h.layer=u.getUint16(d),d+=2,h.alternateGroup=u.getUint16(d),d+=2,h.volume=u.getUint8(d)+u.getUint8(d+1)/8,d+=2,d+=2,h.matrix=new Uint32Array(o.subarray(d,d+9*4)),d+=9*4,h.width=u.getUint16(d)+u.getUint16(d+2)/65536,d+=4,h.height=u.getUint16(d)+u.getUint16(d+2)/65536,h},traf:function(o){return{boxes:Qe(o)}},trak:function(o){return{boxes:Qe(o)}},trex:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),trackId:u.getUint32(4),defaultSampleDescriptionIndex:u.getUint32(8),defaultSampleDuration:u.getUint32(12),defaultSampleSize:u.getUint32(16),sampleDependsOn:o[20]&3,sampleIsDependedOn:(o[21]&192)>>6,sampleHasRedundancy:(o[21]&48)>>4,samplePaddingValue:(o[21]&14)>>1,sampleIsDifferenceSample:!!(o[21]&1),sampleDegradationPriority:u.getUint16(22)}},trun:Ul,"url ":function(o){return{version:o[0],flags:new Uint8Array(o.subarray(1,4))}},vmhd:function(o){var u=new DataView(o.buffer,o.byteOffset,o.byteLength);return{version:o[0],flags:new Uint8Array(o.subarray(1,4)),graphicsmode:u.getUint16(4),opcolor:new Uint16Array([u.getUint16(6),u.getUint16(8),u.getUint16(10)])}}};Qe=function(o){for(var u=0,d=[],h,g,y,S,E,k=new ArrayBuffer(o.length),I=new Uint8Array(k),O=0;O<o.length;++O)I[O]=o[O];for(h=new DataView(k);u<o.byteLength;)g=h.getUint32(u),y=$n(o.subarray(u+4,u+8)),S=g>1?u+g:o.byteLength,E=(ci[y]||function(j){return{data:j}})(o.subarray(u+8,S)),E.size=g,E.type=y,d.push(E),u=S;return d},ya=function(o,u){var d;return u=u||0,d=new Array(u*2+1).join(" "),o.map(function(h,g){return d+h.type+`
|
|
196
196
|
`+Object.keys(h).filter(function(y){return y!=="type"&&y!=="boxes"}).map(function(y){var S=d+" "+y+": ",E=h[y];if(E instanceof Uint8Array||E instanceof Uint32Array){var k=Array.prototype.slice.call(new Uint8Array(E.buffer,E.byteOffset,E.byteLength)).map(function(I){return" "+("00"+I.toString(16)).slice(-2)}).join("").match(/.{1,24}/g);return k?k.length===1?S+"<"+k.join("").slice(1)+">":S+`<
|
|
197
197
|
`+k.map(function(I){return d+" "+I}).join(`
|
|
198
198
|
`)+`
|
|
@@ -201,19 +201,19 @@ browserWorkerPolyFill(self);
|
|
|
201
201
|
`)}).join(`
|
|
202
202
|
`)+(h.boxes?`
|
|
203
203
|
`+ya(h.boxes,u+1):"")}).join(`
|
|
204
|
-
`)};var Fl={inspect:Qe,textify:ya,parseType:$n,findBox:ag,parseTraf:ci.traf,parseTfdt:ci.tfdt,parseHdlr:ci.hdlr,parseTfhd:ci.tfhd,parseTrun:ci.trun,parseSidx:ci.sidx},lg=function(o){for(var u=0,d=String.fromCharCode(o[u]),h="";d!=="\0";)h+=d,u++,d=String.fromCharCode(o[u]);return h+=d,h},ug={uint8ToCString:lg},Hs=ug.uint8ToCString,dg=r.getUint64,hg=function(o){var u=4,d=o[0],h,f,y,S,E,k,I,O;if(d===0){h=Hs(o.subarray(u)),u+=h.length,f=Hs(o.subarray(u)),u+=f.length;var j=new DataView(o.buffer);y=j.getUint32(u),u+=4,E=j.getUint32(u),u+=4,k=j.getUint32(u),u+=4,I=j.getUint32(u),u+=4}else if(d===1){var j=new DataView(o.buffer);y=j.getUint32(u),u+=4,S=dg(o.subarray(u)),u+=8,k=j.getUint32(u),u+=4,I=j.getUint32(u),u+=4,h=Hs(o.subarray(u)),u+=h.length,f=Hs(o.subarray(u)),u+=f.length}O=new Uint8Array(o.subarray(u,o.byteLength));var Q={scheme_id_uri:h,value:f,timescale:y||1,presentation_time:S,presentation_time_delta:E,event_duration:k,id:I,message_data:O};return pg(d,Q)?Q:void 0},cg=function(o,u,d,h){return o||o===0?o/u:h+d/u},pg=function(o,u){var d=u.scheme_id_uri!=="\0",h=o===0&&jl(u.presentation_time_delta)&&d,f=o===1&&jl(u.presentation_time)&&d;return!(o>1)&&h||f},jl=function(o){return o!==void 0||o!==null},fg={parseEmsgBox:hg,scaleTime:cg},qn;typeof window<"u"?qn=window:typeof i<"u"?qn=i:typeof self<"u"?qn=self:qn={};var $l=qn,zs=qs.toUnsigned,Vn=qs.toHexString,Be=Vs,Xi=fa,_a=fg,gg=ma,mg=Nl,yg=ga,_g=r.getUint64,ql,Vl,Hl,zl,Wl,ba,Gl,Ta=$l,bg=vl.parseId3Frames;ql=function(o){var u={},d=Be(o,["moov","trak"]);return d.reduce(function(h,f){var y,S,E,k,I;return y=Be(f,["tkhd"])[0],!y||(S=y[0],E=S===0?12:20,k=zs(y[E]<<24|y[E+1]<<16|y[E+2]<<8|y[E+3]),I=Be(f,["mdia","mdhd"])[0],!I)?null:(S=I[0],E=S===0?12:20,h[k]=zs(I[E]<<24|I[E+1]<<16|I[E+2]<<8|I[E+3]),h)},u)},Vl=function(o,u){var d;d=Be(u,["moof","traf"]);var h=d.reduce(function(f,y){var S=Be(y,["tfhd"])[0],E=zs(S[4]<<24|S[5]<<16|S[6]<<8|S[7]),k=o[E]||9e4,I=Be(y,["tfdt"])[0],O=new DataView(I.buffer,I.byteOffset,I.byteLength),j;I[0]===1?j=_g(I.subarray(4,12)):j=O.getUint32(4);let Q;return typeof j=="bigint"?Q=j/Ta.BigInt(k):typeof j=="number"&&!isNaN(j)&&(Q=j/k),Q<Number.MAX_SAFE_INTEGER&&(Q=Number(Q)),Q<f&&(f=Q),f},1/0);return typeof h=="bigint"||isFinite(h)?h:0},Hl=function(o,u){var d=Be(u,["moof","traf"]),h=0,f=0,y;if(d&&d.length){var S=Be(d[0],["tfhd"])[0],E=Be(d[0],["trun"])[0],k=Be(d[0],["tfdt"])[0];if(S){var I=gg(S);y=I.trackId}if(k){var O=yg(k);h=O.baseMediaDecodeTime}if(E){var j=mg(E);j.samples&&j.samples.length&&(f=j.samples[0].compositionTimeOffset||0)}}var Q=o[y]||9e4;typeof h=="bigint"&&(f=Ta.BigInt(f),Q=Ta.BigInt(Q));var V=(h+f)/Q;return typeof V=="bigint"&&V<Number.MAX_SAFE_INTEGER&&(V=Number(V)),V},zl=function(o){var u=Be(o,["moov","trak"]),d=[];return u.forEach(function(h){var f=Be(h,["mdia","hdlr"]),y=Be(h,["tkhd"]);f.forEach(function(S,E){var k=Xi(S.subarray(8,12)),I=y[E],O,j,Q;k==="vide"&&(O=new DataView(I.buffer,I.byteOffset,I.byteLength),j=O.getUint8(0),Q=j===0?O.getUint32(12):O.getUint32(20),d.push(Q))})}),d},ba=function(o){var u=o[0],d=u===0?12:20;return zs(o[d]<<24|o[d+1]<<16|o[d+2]<<8|o[d+3])},Wl=function(o){var u=Be(o,["moov","trak"]),d=[];return u.forEach(function(h){var f={},y=Be(h,["tkhd"])[0],S,E;y&&(S=new DataView(y.buffer,y.byteOffset,y.byteLength),E=S.getUint8(0),f.id=E===0?S.getUint32(12):S.getUint32(20));var k=Be(h,["mdia","hdlr"])[0];if(k){var I=Xi(k.subarray(8,12));I==="vide"?f.type="video":I==="soun"?f.type="audio":f.type=I}var O=Be(h,["mdia","minf","stbl","stsd"])[0];if(O){var j=O.subarray(8);f.codec=Xi(j.subarray(4,8));var Q=Be(j,[f.codec])[0],V,te;Q&&(/^[asm]vc[1-9]$/i.test(f.codec)?(V=Q.subarray(78),te=Xi(V.subarray(4,8)),te==="avcC"&&V.length>11?(f.codec+=".",f.codec+=Vn(V[9]),f.codec+=Vn(V[10]),f.codec+=Vn(V[11])):f.codec="avc1.4d400d"):/^mp4[a,v]$/i.test(f.codec)?(V=Q.subarray(28),te=Xi(V.subarray(4,8)),te==="esds"&&V.length>20&&V[19]!==0?(f.codec+="."+Vn(V[19]),f.codec+="."+Vn(V[20]>>>2&63).replace(/^0/,"")):f.codec="mp4a.40.2"):f.codec=f.codec.toLowerCase())}var se=Be(h,["mdia","mdhd"])[0];se&&(f.timescale=ba(se)),d.push(f)}),d},Gl=function(o,u=0){var d=Be(o,["emsg"]);return d.map(h=>{var f=_a.parseEmsgBox(new Uint8Array(h)),y=bg(f.message_data);return{cueTime:_a.scaleTime(f.presentation_time,f.timescale,f.presentation_time_delta,u),duration:_a.scaleTime(f.event_duration,f.timescale),frames:y}})};var Hn={findBox:Be,parseType:Xi,timescale:ql,startTime:Vl,compositionStartTime:Hl,videoTrackIds:zl,tracks:Wl,getTimescaleFromMediaHeader:ba,getEmsgID3:Gl};const{parseTrun:Tg}=Fl,{findBox:Xl}=Hn;var Kl=$l,vg=function(o){var u=Xl(o,["moof","traf"]),d=Xl(o,["mdat"]),h=[];return d.forEach(function(f,y){var S=u[y];h.push({mdat:f,traf:S})}),h},Sg=function(o,u,d){var h=u,f=d.defaultSampleDuration||0,y=d.defaultSampleSize||0,S=d.trackId,E=[];return o.forEach(function(k){var I=Tg(k),O=I.samples;O.forEach(function(j){j.duration===void 0&&(j.duration=f),j.size===void 0&&(j.size=y),j.trackId=S,j.dts=h,j.compositionTimeOffset===void 0&&(j.compositionTimeOffset=0),typeof h=="bigint"?(j.pts=h+Kl.BigInt(j.compositionTimeOffset),h+=Kl.BigInt(j.duration)):(j.pts=h+j.compositionTimeOffset,h+=j.duration)}),E=E.concat(O)}),E},Yl={getMdatTrafPairs:vg,parseSamples:Sg},Eg=ml.discardEmulationPreventionBytes,wg=yl.CaptionStream,va=Vs,kg=ga,Cg=ma,{getMdatTrafPairs:Ig,parseSamples:xg}=Yl,Ag=function(o,u){for(var d=o,h=0;h<u.length;h++){var f=u[h];if(d<f.size)return f;d-=f.size}return null},Pg=function(o,u,d){var h=new DataView(o.buffer,o.byteOffset,o.byteLength),f={logs:[],seiNals:[]},y,S,E,k;for(S=0;S+4<o.length;S+=E)if(E=h.getUint32(S),S+=4,!(E<=0))switch(o[S]&31){case 6:var I=o.subarray(S+1,S+1+E),O=Ag(S,u);if(y={nalUnitType:"sei_rbsp",size:E,data:I,escapedRBSP:Eg(I),trackId:d},O)y.pts=O.pts,y.dts=O.dts,k=O;else if(k)y.pts=k.pts,y.dts=k.dts;else{f.logs.push({level:"warn",message:"We've encountered a nal unit without data at "+S+" for trackId "+d+". See mux.js#223."});break}f.seiNals.push(y);break}return f},Lg=function(o,u){var d={},h=Ig(o);return h.forEach(function(f){var y=f.mdat,S=f.traf,E=va(S,["tfhd"]),k=Cg(E[0]),I=k.trackId,O=va(S,["tfdt"]),j=O.length>0?kg(O[0]).baseMediaDecodeTime:0,Q=va(S,["trun"]),V,te;u===I&&Q.length>0&&(V=xg(Q,j,k),te=Pg(y,V,I),d[I]||(d[I]={seiNals:[],logs:[]}),d[I].seiNals=d[I].seiNals.concat(te.seiNals),d[I].logs=d[I].logs.concat(te.logs))}),d},Dg=function(o,u,d){var h;if(u===null)return null;h=Lg(o,u);var f=h[u]||{};return{seiNals:f.seiNals,logs:f.logs,timescale:d}},Og=function(){var o=!1,u,d,h,f,y,S;this.isInitialized=function(){return o},this.init=function(E){u=new wg,o=!0,S=E?E.isPartial:!1,u.on("data",function(k){k.startTime=k.startPts/f,k.endTime=k.endPts/f,y.captions.push(k),y.captionStreams[k.stream]=!0}),u.on("log",function(k){y.logs.push(k)})},this.isNewInit=function(E,k){return E&&E.length===0||k&&typeof k=="object"&&Object.keys(k).length===0?!1:h!==E[0]||f!==k[h]},this.parse=function(E,k,I){var O;if(this.isInitialized()){if(!k||!I)return null;if(this.isNewInit(k,I))h=k[0],f=I[h];else if(h===null||!f)return d.push(E),null}else return null;for(;d.length>0;){var j=d.shift();this.parse(j,k,I)}return O=Dg(E,h,f),O&&O.logs&&(y.logs=y.logs.concat(O.logs)),O===null||!O.seiNals?y.logs.length?{logs:y.logs,captions:[],captionStreams:[]}:null:(this.pushNals(O.seiNals),this.flushStream(),y)},this.pushNals=function(E){if(!this.isInitialized()||!E||E.length===0)return null;E.forEach(function(k){u.push(k)})},this.flushStream=function(){if(!this.isInitialized())return null;S?u.partialFlush():u.flush()},this.clearParsedCaptions=function(){y.captions=[],y.captionStreams={},y.logs=[]},this.resetCaptionStream=function(){if(!this.isInitialized())return null;u.reset()},this.clearAllCaptions=function(){this.clearParsedCaptions(),this.resetCaptionStream()},this.reset=function(){d=[],h=null,f=null,y?this.clearParsedCaptions():y={captions:[],captionStreams:{},logs:[]},this.resetCaptionStream()},this.reset()},Mg=Og;const{parseTfdt:Rg}=Fl,pi=Vs,{getTimescaleFromMediaHeader:Ug}=Hn,{parseSamples:Ng,getMdatTrafPairs:Bg}=Yl;var Ql=function(){let o=9e4;this.init=function(u){const d=pi(u,["moov","trak","mdia","mdhd"])[0];d&&(o=Ug(d))},this.parseSegment=function(u){const d=[],h=Bg(u);let f=0;return h.forEach(function(y){const S=y.mdat,E=y.traf,k=pi(E,["tfdt"])[0],I=pi(E,["tfhd"])[0],O=pi(E,["trun"]);if(k&&(f=Rg(k).baseMediaDecodeTime),O.length&&I){const j=Ng(O,f,I);let Q=0;j.forEach(function(V){const te="utf-8",se=new TextDecoder(te),ze=S.slice(Q,Q+V.size);if(pi(ze,["vtte"])[0]){Q+=V.size;return}pi(ze,["vttc"]).forEach(function(nt){const qt=pi(nt,["payl"])[0],zn=pi(nt,["sttg"])[0],Xs=V.pts/o,Ks=(V.pts+V.duration)/o;let Pi,Wn;if(qt)try{Pi=se.decode(qt)}catch(Ie){console.error(Ie)}if(zn)try{Wn=se.decode(zn)}catch(Ie){console.error(Ie)}V.duration&&Pi&&d.push({cueText:Pi,start:Xs,end:Ks,settings:Wn})}),Q+=V.size})}}),d}},Sa=As,Jl=function(o){var u=o[1]&31;return u<<=8,u|=o[2],u},Ws=function(o){return!!(o[1]&64)},Gs=function(o){var u=0;return(o[3]&48)>>>4>1&&(u+=o[4]+1),u},Fg=function(o,u){var d=Jl(o);return d===0?"pat":d===u?"pmt":u?"pes":null},jg=function(o){var u=Ws(o),d=4+Gs(o);return u&&(d+=o[d]+1),(o[d+10]&31)<<8|o[d+11]},$g=function(o){var u={},d=Ws(o),h=4+Gs(o);if(d&&(h+=o[h]+1),!!(o[h+5]&1)){var f,y,S;f=(o[h+1]&15)<<8|o[h+2],y=3+f-4,S=(o[h+10]&15)<<8|o[h+11];for(var E=12+S;E<y;){var k=h+E;u[(o[k+1]&31)<<8|o[k+2]]=o[k],E+=((o[k+3]&15)<<8|o[k+4])+5}return u}},qg=function(o,u){var d=Jl(o),h=u[d];switch(h){case Sa.H264_STREAM_TYPE:return"video";case Sa.ADTS_STREAM_TYPE:return"audio";case Sa.METADATA_STREAM_TYPE:return"timed-metadata";default:return null}},Vg=function(o){var u=Ws(o);if(!u)return null;var d=4+Gs(o);if(d>=o.byteLength)return null;var h=null,f;return f=o[d+7],f&192&&(h={},h.pts=(o[d+9]&14)<<27|(o[d+10]&255)<<20|(o[d+11]&254)<<12|(o[d+12]&255)<<5|(o[d+13]&254)>>>3,h.pts*=4,h.pts+=(o[d+13]&6)>>>1,h.dts=h.pts,f&64&&(h.dts=(o[d+14]&14)<<27|(o[d+15]&255)<<20|(o[d+16]&254)<<12|(o[d+17]&255)<<5|(o[d+18]&254)>>>3,h.dts*=4,h.dts+=(o[d+18]&6)>>>1)),h},Ea=function(o){switch(o){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}},Hg=function(o){for(var u=4+Gs(o),d=o.subarray(u),h=0,f=0,y=!1,S;f<d.byteLength-3;f++)if(d[f+2]===1){h=f+5;break}for(;h<d.byteLength;)switch(d[h]){case 0:if(d[h-1]!==0){h+=2;break}else if(d[h-2]!==0){h++;break}f+3!==h-2&&(S=Ea(d[f+3]&31),S==="slice_layer_without_partitioning_rbsp_idr"&&(y=!0));do h++;while(d[h]!==1&&h<d.length);f=h-2,h+=3;break;case 1:if(d[h-1]!==0||d[h-2]!==0){h+=3;break}S=Ea(d[f+3]&31),S==="slice_layer_without_partitioning_rbsp_idr"&&(y=!0),f=h-2,h+=3;break;default:h+=3;break}return d=d.subarray(f),h-=f,f=0,d&&d.byteLength>3&&(S=Ea(d[f+3]&31),S==="slice_layer_without_partitioning_rbsp_idr"&&(y=!0)),y},zg={parseType:Fg,parsePat:jg,parsePmt:$g,parsePayloadUnitStartIndicator:Ws,parsePesType:qg,parsePesTime:Vg,videoPacketContainsKeyFrame:Hg},Zl=As,Ki=bl.handleRollover,ye={};ye.ts=zg,ye.aac=da;var Ai=T.ONE_SECOND_IN_TS,it=188,$t=71,Wg=function(o,u){for(var d=0,h=it,f,y;h<o.byteLength;){if(o[d]===$t&&o[h]===$t){switch(f=o.subarray(d,h),y=ye.ts.parseType(f,u.pid),y){case"pat":u.pid=ye.ts.parsePat(f);break;case"pmt":var S=ye.ts.parsePmt(f);u.table=u.table||{},Object.keys(S).forEach(function(E){u.table[E]=S[E]});break}d+=it,h+=it;continue}d++,h++}},eu=function(o,u,d){for(var h=0,f=it,y,S,E,k,I,O=!1;f<=o.byteLength;){if(o[h]===$t&&(o[f]===$t||f===o.byteLength)){switch(y=o.subarray(h,f),S=ye.ts.parseType(y,u.pid),S){case"pes":E=ye.ts.parsePesType(y,u.table),k=ye.ts.parsePayloadUnitStartIndicator(y),E==="audio"&&k&&(I=ye.ts.parsePesTime(y),I&&(I.type="audio",d.audio.push(I),O=!0));break}if(O)break;h+=it,f+=it;continue}h++,f++}for(f=o.byteLength,h=f-it,O=!1;h>=0;){if(o[h]===$t&&(o[f]===$t||f===o.byteLength)){switch(y=o.subarray(h,f),S=ye.ts.parseType(y,u.pid),S){case"pes":E=ye.ts.parsePesType(y,u.table),k=ye.ts.parsePayloadUnitStartIndicator(y),E==="audio"&&k&&(I=ye.ts.parsePesTime(y),I&&(I.type="audio",d.audio.push(I),O=!0));break}if(O)break;h-=it,f-=it;continue}h--,f--}},Gg=function(o,u,d){for(var h=0,f=it,y,S,E,k,I,O,j,Q,V=!1,te={data:[],size:0};f<o.byteLength;){if(o[h]===$t&&o[f]===$t){switch(y=o.subarray(h,f),S=ye.ts.parseType(y,u.pid),S){case"pes":if(E=ye.ts.parsePesType(y,u.table),k=ye.ts.parsePayloadUnitStartIndicator(y),E==="video"&&(k&&!V&&(I=ye.ts.parsePesTime(y),I&&(I.type="video",d.video.push(I),V=!0)),!d.firstKeyFrame)){if(k&&te.size!==0){for(O=new Uint8Array(te.size),j=0;te.data.length;)Q=te.data.shift(),O.set(Q,j),j+=Q.byteLength;if(ye.ts.videoPacketContainsKeyFrame(O)){var se=ye.ts.parsePesTime(O);se?(d.firstKeyFrame=se,d.firstKeyFrame.type="video"):console.warn("Failed to extract PTS/DTS from PES at first keyframe. This could be an unusual TS segment, or else mux.js did not parse your TS segment correctly. If you know your TS segments do contain PTS/DTS on keyframes please file a bug report! You can try ffprobe to double check for yourself.")}te.size=0}te.data.push(y),te.size+=y.byteLength}break}if(V&&d.firstKeyFrame)break;h+=it,f+=it;continue}h++,f++}for(f=o.byteLength,h=f-it,V=!1;h>=0;){if(o[h]===$t&&o[f]===$t){switch(y=o.subarray(h,f),S=ye.ts.parseType(y,u.pid),S){case"pes":E=ye.ts.parsePesType(y,u.table),k=ye.ts.parsePayloadUnitStartIndicator(y),E==="video"&&k&&(I=ye.ts.parsePesTime(y),I&&(I.type="video",d.video.push(I),V=!0));break}if(V)break;h-=it,f-=it;continue}h--,f--}},Xg=function(o,u){if(o.audio&&o.audio.length){var d=u;(typeof d>"u"||isNaN(d))&&(d=o.audio[0].dts),o.audio.forEach(function(y){y.dts=Ki(y.dts,d),y.pts=Ki(y.pts,d),y.dtsTime=y.dts/Ai,y.ptsTime=y.pts/Ai})}if(o.video&&o.video.length){var h=u;if((typeof h>"u"||isNaN(h))&&(h=o.video[0].dts),o.video.forEach(function(y){y.dts=Ki(y.dts,h),y.pts=Ki(y.pts,h),y.dtsTime=y.dts/Ai,y.ptsTime=y.pts/Ai}),o.firstKeyFrame){var f=o.firstKeyFrame;f.dts=Ki(f.dts,h),f.pts=Ki(f.pts,h),f.dtsTime=f.dts/Ai,f.ptsTime=f.pts/Ai}}},Kg=function(o){for(var u=!1,d=0,h=null,f=null,y=0,S=0,E;o.length-S>=3;){var k=ye.aac.parseType(o,S);switch(k){case"timed-metadata":if(o.length-S<10){u=!0;break}if(y=ye.aac.parseId3TagSize(o,S),y>o.length){u=!0;break}f===null&&(E=o.subarray(S,S+y),f=ye.aac.parseAacTimestamp(E)),S+=y;break;case"audio":if(o.length-S<7){u=!0;break}if(y=ye.aac.parseAdtsSize(o,S),y>o.length){u=!0;break}h===null&&(E=o.subarray(S,S+y),h=ye.aac.parseSampleRate(E)),d++,S+=y;break;default:S++;break}if(u)return null}if(h===null||f===null)return null;var I=Ai/h,O={audio:[{type:"audio",dts:f,pts:f},{type:"audio",dts:f+d*1024*I,pts:f+d*1024*I}]};return O},Yg=function(o){var u={pid:null,table:null},d={};Wg(o,u);for(var h in u.table)if(u.table.hasOwnProperty(h)){var f=u.table[h];switch(f){case Zl.H264_STREAM_TYPE:d.video=[],Gg(o,u,d),d.video.length===0&&delete d.video;break;case Zl.ADTS_STREAM_TYPE:d.audio=[],eu(o,u,d),d.audio.length===0&&delete d.audio;break}}return d},Qg=function(o,u){var d=ye.aac.isLikelyAacData(o),h;return d?h=Kg(o):h=Yg(o),!h||!h.audio&&!h.video?null:(Xg(h,u),h)},Jg={inspect:Qg,parseAudioPes_:eu};const Zg=function(o,u){u.on("data",function(d){const h=d.initSegment;d.initSegment={data:h.buffer,byteOffset:h.byteOffset,byteLength:h.byteLength};const f=d.data;d.data=f.buffer,o.postMessage({action:"data",segment:d,byteOffset:f.byteOffset,byteLength:f.byteLength},[d.data])}),u.on("done",function(d){o.postMessage({action:"done"})}),u.on("gopInfo",function(d){o.postMessage({action:"gopInfo",gopInfo:d})}),u.on("videoSegmentTimingInfo",function(d){const h={start:{decode:T.videoTsToSeconds(d.start.dts),presentation:T.videoTsToSeconds(d.start.pts)},end:{decode:T.videoTsToSeconds(d.end.dts),presentation:T.videoTsToSeconds(d.end.pts)},baseMediaDecodeTime:T.videoTsToSeconds(d.baseMediaDecodeTime)};d.prependedContentDuration&&(h.prependedContentDuration=T.videoTsToSeconds(d.prependedContentDuration)),o.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:h})}),u.on("audioSegmentTimingInfo",function(d){const h={start:{decode:T.videoTsToSeconds(d.start.dts),presentation:T.videoTsToSeconds(d.start.pts)},end:{decode:T.videoTsToSeconds(d.end.dts),presentation:T.videoTsToSeconds(d.end.pts)},baseMediaDecodeTime:T.videoTsToSeconds(d.baseMediaDecodeTime)};d.prependedContentDuration&&(h.prependedContentDuration=T.videoTsToSeconds(d.prependedContentDuration)),o.postMessage({action:"audioSegmentTimingInfo",audioSegmentTimingInfo:h})}),u.on("id3Frame",function(d){o.postMessage({action:"id3Frame",id3Frame:d})}),u.on("caption",function(d){o.postMessage({action:"caption",caption:d})}),u.on("trackinfo",function(d){o.postMessage({action:"trackinfo",trackInfo:d})}),u.on("audioTimingInfo",function(d){o.postMessage({action:"audioTimingInfo",audioTimingInfo:{start:T.videoTsToSeconds(d.start),end:T.videoTsToSeconds(d.end)}})}),u.on("videoTimingInfo",function(d){o.postMessage({action:"videoTimingInfo",videoTimingInfo:{start:T.videoTsToSeconds(d.start),end:T.videoTsToSeconds(d.end)}})}),u.on("log",function(d){o.postMessage({action:"log",log:d})})};class tu{constructor(u,d){this.options=d||{},this.self=u,this.init()}init(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new Hf.Transmuxer(this.options),Zg(this.self,this.transmuxer)}pushMp4Captions(u){this.captionParser||(this.captionParser=new Mg,this.captionParser.init());const d=new Uint8Array(u.data,u.byteOffset,u.byteLength),h=this.captionParser.parse(d,u.trackIds,u.timescales);this.self.postMessage({action:"mp4Captions",captions:h&&h.captions||[],logs:h&&h.logs||[],data:d.buffer},[d.buffer])}initMp4WebVttParser(u){this.webVttParser||(this.webVttParser=new Ql);const d=new Uint8Array(u.data,u.byteOffset,u.byteLength);this.webVttParser.init(d)}getMp4WebVttText(u){this.webVttParser||(this.webVttParser=new Ql);const d=new Uint8Array(u.data,u.byteOffset,u.byteLength),h=this.webVttParser.parseSegment(d);this.self.postMessage({action:"getMp4WebVttText",mp4VttCues:h||[],data:d.buffer},[d.buffer])}probeMp4StartTime({timescales:u,data:d}){const h=Hn.startTime(u,d);this.self.postMessage({action:"probeMp4StartTime",startTime:h,data:d},[d.buffer])}probeMp4Tracks({data:u}){const d=Hn.tracks(u);this.self.postMessage({action:"probeMp4Tracks",tracks:d,data:u},[u.buffer])}probeEmsgID3({data:u,offset:d}){const h=Hn.getEmsgID3(u,d);this.self.postMessage({action:"probeEmsgID3",id3Frames:h,emsgData:u},[u.buffer])}probeTs({data:u,baseStartTime:d}){const h=typeof d=="number"&&!isNaN(d)?d*T.ONE_SECOND_IN_TS:void 0,f=Jg.inspect(u,h);let y=null;f&&(y={hasVideo:f.video&&f.video.length===2||!1,hasAudio:f.audio&&f.audio.length===2||!1},y.hasVideo&&(y.videoStart=f.video[0].ptsTime),y.hasAudio&&(y.audioStart=f.audio[0].ptsTime)),this.self.postMessage({action:"probeTs",result:y,data:u},[u.buffer])}clearAllMp4Captions(){this.captionParser&&this.captionParser.clearAllCaptions()}clearParsedMp4Captions(){this.captionParser&&this.captionParser.clearParsedCaptions()}push(u){const d=new Uint8Array(u.data,u.byteOffset,u.byteLength);this.transmuxer.push(d)}reset(){this.transmuxer.reset()}setTimestampOffset(u){const d=u.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(T.secondsToVideoTs(d)))}setAudioAppendStart(u){this.transmuxer.setAudioAppendStart(Math.ceil(T.secondsToVideoTs(u.appendStart)))}setRemux(u){this.transmuxer.setRemux(u.remux)}flush(u){this.transmuxer.flush(),self.postMessage({action:"done",type:"transmuxed"})}endTimeline(){this.transmuxer.endTimeline(),self.postMessage({action:"endedtimeline",type:"transmuxed"})}alignGopsWith(u){this.transmuxer.alignGopsWith(u.gopsToAlignWith.slice())}}self.onmessage=function(o){if(o.data.action==="init"&&o.data.options){this.messageHandlers=new tu(self,o.data.options);return}this.messageHandlers||(this.messageHandlers=new tu(self)),o.data&&o.data.action&&o.data.action!=="init"&&this.messageHandlers[o.data.action]&&this.messageHandlers[o.data.action](o.data)}}));var KT=mp(XT);const YT=(i,e,t)=>{const{type:n,initSegment:s,captions:r,captionStreams:a,metadata:l,videoFrameDtsTime:c,videoFramePtsTime:g}=i.data.segment;e.buffer.push({captions:r,captionStreams:a,metadata:l});const m=i.data.segment.boxes||{data:i.data.segment.data},b={type:n,data:new Uint8Array(m.data,m.data.byteOffset,m.data.byteLength),initSegment:new Uint8Array(s.data,s.byteOffset,s.byteLength)};typeof c<"u"&&(b.videoFrameDtsTime=c),typeof g<"u"&&(b.videoFramePtsTime=g),t(b)},QT=({transmuxedData:i,callback:e})=>{i.buffer=[],e(i)},JT=(i,e)=>{e.gopInfo=i.data.gopInfo},bp=i=>{const{transmuxer:e,bytes:t,audioAppendStart:n,gopsToAlignWith:s,remux:r,onData:a,onTrackInfo:l,onAudioTimingInfo:c,onVideoTimingInfo:g,onVideoSegmentTimingInfo:m,onAudioSegmentTimingInfo:b,onId3:C,onCaptions:w,onDone:A,onEndedTimeline:v,onTransmuxerLog:M,isEndOfTimeline:D,segment:R,triggerSegmentEventFn:N}=i,F={buffer:[]};let P=D;const $=X=>{e.currentTransmux===i&&(X.data.action==="data"&&YT(X,F,a),X.data.action==="trackinfo"&&l(X.data.trackInfo),X.data.action==="gopInfo"&&JT(X,F),X.data.action==="audioTimingInfo"&&c(X.data.audioTimingInfo),X.data.action==="videoTimingInfo"&&g(X.data.videoTimingInfo),X.data.action==="videoSegmentTimingInfo"&&m(X.data.videoSegmentTimingInfo),X.data.action==="audioSegmentTimingInfo"&&b(X.data.audioSegmentTimingInfo),X.data.action==="id3Frame"&&C([X.data.id3Frame],X.data.id3Frame.dispatchType),X.data.action==="caption"&&w(X.data.caption),X.data.action==="endedtimeline"&&(P=!1,v()),X.data.action==="log"&&M(X.data.log),X.data.type==="transmuxed"&&(P||(e.onmessage=null,QT({transmuxedData:F,callback:A}),Tp(e))))},Y=()=>{const X={message:"Received an error message from the transmuxer worker",metadata:{errorType:B.Error.StreamingFailedToTransmuxSegment,segmentInfo:Mi({segment:R})}};A(null,X)};if(e.onmessage=$,e.onerror=Y,n&&e.postMessage({action:"setAudioAppendStart",appendStart:n}),Array.isArray(s)&&e.postMessage({action:"alignGopsWith",gopsToAlignWith:s}),typeof r<"u"&&e.postMessage({action:"setRemux",remux:r}),t.byteLength){const X=t instanceof ArrayBuffer?t:t.buffer,re=t instanceof ArrayBuffer?0:t.byteOffset;N({type:"segmenttransmuxingstart",segment:R}),e.postMessage({action:"push",data:X,byteOffset:re,byteLength:t.byteLength},[X])}D&&e.postMessage({action:"endTimeline"}),e.postMessage({action:"flush"})},Tp=i=>{i.currentTransmux=null,i.transmuxQueue.length&&(i.currentTransmux=i.transmuxQueue.shift(),typeof i.currentTransmux=="function"?i.currentTransmux():bp(i.currentTransmux))},pd=(i,e)=>{i.postMessage({action:e}),Tp(i)},vp=(i,e)=>{if(!e.currentTransmux){e.currentTransmux=i,pd(e,i);return}e.transmuxQueue.push(pd.bind(null,e,i))},ZT=i=>{vp("reset",i)},ev=i=>{vp("endTimeline",i)},Sp=i=>{if(!i.transmuxer.currentTransmux){i.transmuxer.currentTransmux=i,bp(i);return}i.transmuxer.transmuxQueue.push(i)},tv=i=>{const e=new KT;e.currentTransmux=null,e.transmuxQueue=[];const t=e.terminate;return e.terminate=()=>(e.currentTransmux=null,e.transmuxQueue.length=0,t.call(e)),e.postMessage({action:"init",options:i}),e};var za={reset:ZT,endTimeline:ev,transmux:Sp,createTransmuxer:tv};const un=function(i){const e=i.transmuxer,t=i.endAction||i.action,n=i.callback,s=je({},i,{endAction:null,transmuxer:null,callback:null}),r=a=>{a.data.action===t&&(e.removeEventListener("message",r),a.data.data&&(a.data.data=new Uint8Array(a.data.data,i.byteOffset||0,i.byteLength||a.data.data.byteLength),i.data&&(i.data=a.data.data)),n(a.data))};if(e.addEventListener("message",r),i.data){const a=i.data instanceof ArrayBuffer;s.byteOffset=a?0:i.data.byteOffset,s.byteLength=i.data.byteLength;const l=[a?i.data:i.data.buffer];e.postMessage(s,l)}else e.postMessage(s)},Yt={FAILURE:2,TIMEOUT:-101,ABORTED:-102},Ep="wvtt",go=i=>{i.forEach(e=>{e.abort()})},iv=i=>({bandwidth:i.bandwidth,bytesReceived:i.bytesReceived||0,roundTripTime:i.roundTripTime||0}),nv=i=>{const e=i.target,t={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-e.requestTime||0};return t.bytesReceived=i.loaded,t.bandwidth=Math.floor(t.bytesReceived/t.roundTripTime*8*1e3),t},pl=(i,e)=>{const{requestType:t}=e,n=$i({requestType:t,request:e,error:i});return e.timedout?{status:e.status,message:"HLS request timed-out at URL: "+e.uri,code:Yt.TIMEOUT,xhr:e,metadata:n}:e.aborted?{status:e.status,message:"HLS request aborted at URL: "+e.uri,code:Yt.ABORTED,xhr:e,metadata:n}:i?{status:e.status,message:"HLS request errored at URL: "+e.uri,code:Yt.FAILURE,xhr:e,metadata:n}:e.responseType==="arraybuffer"&&e.response.byteLength===0?{status:e.status,message:"Empty HLS response at URL: "+e.uri,code:Yt.FAILURE,xhr:e,metadata:n}:null},fd=(i,e,t,n)=>(s,r)=>{const a=r.response,l=pl(s,r);if(l)return t(l,i);if(a.byteLength!==16)return t({status:r.status,message:"Invalid HLS key at URL: "+r.uri,code:Yt.FAILURE,xhr:r},i);const c=new DataView(a),g=new Uint32Array([c.getUint32(0),c.getUint32(4),c.getUint32(8),c.getUint32(12)]);for(let b=0;b<e.length;b++)e[b].bytes=g;const m={uri:r.uri};return n({type:"segmentkeyloadcomplete",segment:i,keyInfo:m}),t(null,i)},sv=(i,e)=>{e===Ep&&i.transmuxer.postMessage({action:"initMp4WebVttParser",data:i.map.bytes})},rv=(i,e,t)=>{e===Ep&&un({action:"getMp4WebVttText",data:i.bytes,transmuxer:i.transmuxer,callback:({data:n,mp4VttCues:s})=>{i.bytes=n,t(null,i,{mp4VttCues:s})}})},wp=(i,e)=>{const t=Oo(i.map.bytes);if(t!=="mp4"){const n=i.map.resolvedUri||i.map.uri,s=t||"unknown";return e({internal:!0,message:`Found unsupported ${s} container for initialization segment at URL: ${n}`,code:Yt.FAILURE,metadata:{mediaType:s}})}un({action:"probeMp4Tracks",data:i.map.bytes,transmuxer:i.transmuxer,callback:({tracks:n,data:s})=>(i.map.bytes=s,n.forEach(function(r){i.map.tracks=i.map.tracks||{},!i.map.tracks[r.type]&&(i.map.tracks[r.type]=r,typeof r.id=="number"&&r.timescale&&(i.map.timescales=i.map.timescales||{},i.map.timescales[r.id]=r.timescale),r.type==="text"&&sv(i,r.codec))}),e(null))})},av=({segment:i,finishProcessingFn:e,triggerSegmentEventFn:t})=>(n,s)=>{const r=pl(n,s);if(r)return e(r,i);const a=new Uint8Array(s.response);if(t({type:"segmentloaded",segment:i}),i.map.key)return i.map.encryptedBytes=a,e(null,i);i.map.bytes=a,wp(i,function(l){if(l)return l.xhr=s,l.status=s.status,e(l,i);e(null,i)})},ov=({segment:i,finishProcessingFn:e,responseType:t,triggerSegmentEventFn:n})=>(s,r)=>{const a=pl(s,r);if(a)return e(a,i);n({type:"segmentloaded",segment:i});const l=t==="arraybuffer"||!r.responseText?r.response:WT(r.responseText.substring(i.lastReachedChar||0));return i.stats=iv(r),i.key?i.encryptedBytes=new Uint8Array(l):i.bytes=new Uint8Array(l),e(null,i)},lv=({segment:i,bytes:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:g,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})=>{const A=i.map&&i.map.tracks||{},v=!!(A.audio&&A.video);let M=n.bind(null,i,"audio","start");const D=n.bind(null,i,"audio","end");let R=n.bind(null,i,"video","start");const N=n.bind(null,i,"video","end"),F=()=>Sp({bytes:e,transmuxer:i.transmuxer,audioAppendStart:i.audioAppendStart,gopsToAlignWith:i.gopsToAlignWith,remux:v,onData:P=>{P.type=P.type==="combined"?"video":P.type,m(i,P)},onTrackInfo:P=>{t&&(v&&(P.isMuxed=!0),t(i,P))},onAudioTimingInfo:P=>{M&&typeof P.start<"u"&&(M(P.start),M=null),D&&typeof P.end<"u"&&D(P.end)},onVideoTimingInfo:P=>{R&&typeof P.start<"u"&&(R(P.start),R=null),N&&typeof P.end<"u"&&N(P.end)},onVideoSegmentTimingInfo:P=>{const $={pts:{start:P.start.presentation,end:P.end.presentation},dts:{start:P.start.decode,end:P.end.decode}};w({type:"segmenttransmuxingtiminginfoavailable",segment:i,timingInfo:$}),s(P)},onAudioSegmentTimingInfo:P=>{const $={pts:{start:P.start.pts,end:P.end.pts},dts:{start:P.start.dts,end:P.end.dts}};w({type:"segmenttransmuxingtiminginfoavailable",segment:i,timingInfo:$}),r(P)},onId3:(P,$)=>{a(i,P,$)},onCaptions:P=>{l(i,[P])},isEndOfTimeline:c,onEndedTimeline:()=>{g()},onTransmuxerLog:C,onDone:(P,$)=>{b&&(P.type=P.type==="combined"?"video":P.type,w({type:"segmenttransmuxingcomplete",segment:i}),b($,i,P))},segment:i,triggerSegmentEventFn:w});un({action:"probeTs",transmuxer:i.transmuxer,data:e,baseStartTime:i.baseStartTime,callback:P=>{i.bytes=e=P.data;const $=P.result;$&&(t(i,{hasAudio:$.hasAudio,hasVideo:$.hasVideo,isMuxed:v}),t=null),F()}})},kp=({segment:i,bytes:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:g,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})=>{let A=new Uint8Array(e);if(P1(A)){i.isFmp4=!0;const{tracks:v}=i.map;if(v.text&&(!v.audio||!v.video)){m(i,{data:A,type:"text"}),rv(i,v.text.codec,b);return}const M={isFmp4:!0,hasVideo:!!v.video,hasAudio:!!v.audio};v.audio&&v.audio.codec&&v.audio.codec!=="enca"&&(M.audioCodec=v.audio.codec),v.video&&v.video.codec&&v.video.codec!=="encv"&&(M.videoCodec=v.video.codec),v.video&&v.audio&&(M.isMuxed=!0),t(i,M);const D=(R,N)=>{m(i,{data:A,type:M.hasAudio&&!M.isMuxed?"audio":"video"}),N&&N.length&&a(i,N),R&&R.length&&l(i,R),b(null,i,{})};un({action:"probeMp4StartTime",timescales:i.map.timescales,data:A,transmuxer:i.transmuxer,callback:({data:R,startTime:N})=>{e=R.buffer,i.bytes=A=R,M.hasAudio&&!M.isMuxed&&n(i,"audio","start",N),M.hasVideo&&n(i,"video","start",N),un({action:"probeEmsgID3",data:A,transmuxer:i.transmuxer,offset:N,callback:({emsgData:F,id3Frames:P})=>{if(e=F.buffer,i.bytes=A=F,!v.video||!F.byteLength||!i.transmuxer){D(void 0,P);return}un({action:"pushMp4Captions",endAction:"mp4Captions",transmuxer:i.transmuxer,data:A,timescales:i.map.timescales,trackIds:[v.video.id],callback:$=>{e=$.data.buffer,i.bytes=A=$.data,$.logs.forEach(function(Y){C(ge(Y,{stream:"mp4CaptionParser"}))}),D($.captions,P)}})}})}});return}if(!i.transmuxer){b(null,i,{});return}if(typeof i.container>"u"&&(i.container=Oo(A)),i.container!=="ts"&&i.container!=="aac"){t(i,{hasAudio:!1,hasVideo:!1}),b(null,i,{});return}lv({segment:i,bytes:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:g,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})},Cp=function({id:i,key:e,encryptedBytes:t,decryptionWorker:n,segment:s,doneFn:r},a){const l=g=>{if(g.data.source===i){n.removeEventListener("message",l);const m=g.data.decrypted;a(new Uint8Array(m.bytes,m.byteOffset,m.byteLength))}};n.onerror=()=>{const g="An error occurred in the decryption worker",m=Mi({segment:s}),b={message:g,metadata:{error:new Error(g),errorType:B.Error.StreamingFailedToDecryptSegment,segmentInfo:m,keyInfo:{uri:s.key.resolvedUri||s.map.key.resolvedUri}}};r(b,s)},n.addEventListener("message",l);let c;e.bytes.slice?c=e.bytes.slice():c=new Uint32Array(Array.prototype.slice.call(e.bytes)),n.postMessage(dp({source:i,encrypted:t,key:c,iv:e.iv}),[t.buffer,c.buffer])},uv=({decryptionWorker:i,segment:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:g,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})=>{w({type:"segmentdecryptionstart"}),Cp({id:e.requestId,key:e.key,encryptedBytes:e.encryptedBytes,decryptionWorker:i,segment:e,doneFn:b},A=>{e.bytes=A,w({type:"segmentdecryptioncomplete",segment:e}),kp({segment:e,bytes:e.bytes,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:g,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})})},dv=({activeXhrs:i,decryptionWorker:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:g,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})=>{let A=0,v=!1;return(M,D)=>{if(!v){if(M)return v=!0,go(i),b(M,D);if(A+=1,A===i.length){const R=function(){if(D.encryptedBytes)return uv({decryptionWorker:e,segment:D,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:g,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w});kp({segment:D,bytes:D.bytes,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:g,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})};if(D.endOfAllRequests=Date.now(),D.map&&D.map.encryptedBytes&&!D.map.bytes)return w({type:"segmentdecryptionstart",segment:D}),Cp({decryptionWorker:e,id:D.requestId+"-init",encryptedBytes:D.map.encryptedBytes,key:D.map.key,segment:D,doneFn:b},N=>{D.map.bytes=N,w({type:"segmentdecryptioncomplete",segment:D}),wp(D,F=>{if(F)return go(i),b(F,D);R()})});R()}}}},hv=({loadendState:i,abortFn:e})=>t=>{t.target.aborted&&e&&!i.calledAbortFn&&(e(),i.calledAbortFn=!0)},cv=({segment:i,progressFn:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:g,dataFn:m})=>b=>{if(!b.target.aborted)return i.stats=ge(i.stats,nv(b)),!i.stats.firstBytesReceivedAt&&i.stats.bytesReceived&&(i.stats.firstBytesReceivedAt=Date.now()),e(b,i)},pv=({xhr:i,xhrOptions:e,decryptionWorker:t,segment:n,abortFn:s,progressFn:r,trackInfoFn:a,timingInfoFn:l,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:g,id3Fn:m,captionsFn:b,isEndOfTimeline:C,endedTimelineFn:w,dataFn:A,doneFn:v,onTransmuxerLog:M,triggerSegmentEventFn:D})=>{const R=[],N=dv({activeXhrs:R,decryptionWorker:t,trackInfoFn:a,timingInfoFn:l,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:g,id3Fn:m,captionsFn:b,isEndOfTimeline:C,endedTimelineFn:w,dataFn:A,doneFn:v,onTransmuxerLog:M,triggerSegmentEventFn:D});if(n.key&&!n.key.bytes){const X=[n.key];n.map&&!n.map.bytes&&n.map.key&&n.map.key.resolvedUri===n.key.resolvedUri&&X.push(n.map.key);const re=ge(e,{uri:n.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),ce=fd(n,X,N,D),be={uri:n.key.resolvedUri};D({type:"segmentkeyloadstart",segment:n,keyInfo:be});const he=i(re,ce);R.push(he)}if(n.map&&!n.map.bytes){if(n.map.key&&(!n.key||n.key.resolvedUri!==n.map.key.resolvedUri)){const be=ge(e,{uri:n.map.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),he=fd(n,[n.map.key],N,D),Z={uri:n.map.key.resolvedUri};D({type:"segmentkeyloadstart",segment:n,keyInfo:Z});const de=i(be,he);R.push(de)}const X=ge(e,{uri:n.map.resolvedUri,responseType:"arraybuffer",headers:po(n.map),requestType:"segment-media-initialization"}),re=av({segment:n,finishProcessingFn:N,triggerSegmentEventFn:D});D({type:"segmentloadstart",segment:n});const ce=i(X,re);R.push(ce)}const F=ge(e,{uri:n.part&&n.part.resolvedUri||n.resolvedUri,responseType:"arraybuffer",headers:po(n),requestType:"segment"}),P=ov({segment:n,finishProcessingFn:N,responseType:F.responseType,triggerSegmentEventFn:D});D({type:"segmentloadstart",segment:n});const $=i(F,P);$.addEventListener("progress",cv({segment:n,progressFn:r,trackInfoFn:a,timingInfoFn:l,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:g,id3Fn:m,captionsFn:b,isEndOfTimeline:C,endedTimelineFn:w,dataFn:A})),R.push($);const Y={};return R.forEach(X=>{X.addEventListener("loadend",hv({loadendState:Y,abortFn:s}))}),()=>go(R)},fv=Lt("CodecUtils"),gv=function(i){const e=i.attributes||{};if(e.CODECS)return Ht(e.CODECS)},Ip=(i,e)=>{const t=e.attributes||{};return i&&i.mediaGroups&&i.mediaGroups.AUDIO&&t.AUDIO&&i.mediaGroups.AUDIO[t.AUDIO]},mv=(i,e)=>{if(!Ip(i,e))return!0;const t=e.attributes||{},n=i.mediaGroups.AUDIO[t.AUDIO];for(const s in n)if(!n[s].uri&&!n[s].playlists)return!0;return!1},Ir=function(i){const e={};return i.forEach(({mediaType:t,type:n,details:s})=>{e[t]=e[t]||[],e[t].push(uh(`${n}${s}`))}),Object.keys(e).forEach(function(t){if(e[t].length>1){fv(`multiple ${t} codecs found as attributes: ${e[t].join(", ")}. Setting playlist codecs to null so that we wait for mux.js to probe segments for real codecs.`),e[t]=null;return}e[t]=e[t][0]}),e},gd=function(i){let e=0;return i.audio&&e++,i.video&&e++,e},ds=function(i,e){const t=e.attributes||{},n=Ir(gv(e)||[]);if(Ip(i,e)&&!n.audio&&!mv(i,e)){const s=Ir(a0(i,t.AUDIO)||[]);s.audio&&(n.audio=s.audio)}return n},er=Lt("PlaylistSelector"),md=function(i){if(!i||!i.playlist)return;const e=i.playlist;return JSON.stringify({id:e.id,bandwidth:i.bandwidth,width:i.width,height:i.height,codecs:e.attributes&&e.attributes.CODECS||""})},xr=function(i,e){if(!i)return"";const t=x.getComputedStyle(i);return t?t[e]:""},dn=function(i,e){const t=i.slice();i.sort(function(n,s){const r=e(n,s);return r===0?t.indexOf(n)-t.indexOf(s):r})},fl=function(i,e){let t,n;return i.attributes.BANDWIDTH&&(t=i.attributes.BANDWIDTH),t=t||x.Number.MAX_VALUE,e.attributes.BANDWIDTH&&(n=e.attributes.BANDWIDTH),n=n||x.Number.MAX_VALUE,t-n},yv=function(i,e){let t,n;return i.attributes.RESOLUTION&&i.attributes.RESOLUTION.width&&(t=i.attributes.RESOLUTION.width),t=t||x.Number.MAX_VALUE,e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(n=e.attributes.RESOLUTION.width),n=n||x.Number.MAX_VALUE,t===n&&i.attributes.BANDWIDTH&&e.attributes.BANDWIDTH?i.attributes.BANDWIDTH-e.attributes.BANDWIDTH:t-n};let xp=function(i,e,t,n,s,r){if(!i)return;const a={bandwidth:e,width:t,height:n,limitRenditionByPlayerDimensions:s};let l=i.playlists;ft.isAudioOnly(i)&&(l=r.getAudioTrackPlaylists_(),a.audioOnly=!0);let c=l.map(P=>{let $;const Y=P.attributes&&P.attributes.RESOLUTION&&P.attributes.RESOLUTION.width,X=P.attributes&&P.attributes.RESOLUTION&&P.attributes.RESOLUTION.height;return $=P.attributes&&P.attributes.BANDWIDTH,$=$||x.Number.MAX_VALUE,{bandwidth:$,width:Y,height:X,playlist:P}});dn(c,(P,$)=>P.bandwidth-$.bandwidth),c=c.filter(P=>!ft.isIncompatible(P.playlist));let g=c.filter(P=>ft.isEnabled(P.playlist));g.length||(g=c.filter(P=>!ft.isDisabled(P.playlist)));const m=g.filter(P=>P.bandwidth*We.BANDWIDTH_VARIANCE<e);let b=m[m.length-1];const C=m.filter(P=>P.bandwidth===b.bandwidth)[0];if(s===!1){const P=C||g[0]||c[0];if(P&&P.playlist){let $="sortedPlaylistReps";return C&&($="bandwidthBestRep"),g[0]&&($="enabledPlaylistReps"),er(`choosing ${md(P)} using ${$} with options`,a),P.playlist}return er("could not choose a playlist with options",a),null}const w=m.filter(P=>P.width&&P.height);dn(w,(P,$)=>P.width-$.width);const A=w.filter(P=>P.width===t&&P.height===n);b=A[A.length-1];const v=A.filter(P=>P.bandwidth===b.bandwidth)[0];let M,D,R;v||(M=w.filter(P=>P.width>t||P.height>n),D=M.filter(P=>P.width===M[0].width&&P.height===M[0].height),b=D[D.length-1],R=D.filter(P=>P.bandwidth===b.bandwidth)[0]);let N;if(r.leastPixelDiffSelector){const P=w.map($=>($.pixelDiff=Math.abs($.width-t)+Math.abs($.height-n),$));dn(P,($,Y)=>$.pixelDiff===Y.pixelDiff?Y.bandwidth-$.bandwidth:$.pixelDiff-Y.pixelDiff),N=P[0]}const F=N||R||v||C||g[0]||c[0];if(F&&F.playlist){let P="sortedPlaylistReps";return N?P="leastPixelDiffRep":R?P="resolutionPlusOneRep":v?P="resolutionBestRep":C?P="bandwidthBestRep":g[0]&&(P="enabledPlaylistReps"),er(`choosing ${md(F)} using ${P} with options`,a),F.playlist}return er("could not choose a playlist with options",a),null};const yd=function(){let i=this.useDevicePixelRatio&&x.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(i=this.customPixelRatio),xp(this.playlists.main,this.systemBandwidth,parseInt(xr(this.tech_.el(),"width"),10)*i,parseInt(xr(this.tech_.el(),"height"),10)*i,this.limitRenditionByPlayerDimensions,this.playlistController_)},_v=function(i){let e=-1,t=-1;if(i<0||i>1)throw new Error("Moving average bandwidth decay must be between 0 and 1.");return function(){let n=this.useDevicePixelRatio&&x.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(n=this.customPixelRatio),e<0&&(e=this.systemBandwidth,t=this.systemBandwidth),this.systemBandwidth>0&&this.systemBandwidth!==t&&(e=i*this.systemBandwidth+(1-i)*e,t=this.systemBandwidth),xp(this.playlists.main,e,parseInt(xr(this.tech_.el(),"width"),10)*n,parseInt(xr(this.tech_.el(),"height"),10)*n,this.limitRenditionByPlayerDimensions,this.playlistController_)}},bv=function(i){const{main:e,currentTime:t,bandwidth:n,duration:s,segmentDuration:r,timeUntilRebuffer:a,currentTimeline:l,syncController:c}=i,g=e.playlists.filter(w=>!ft.isIncompatible(w));let m=g.filter(ft.isEnabled);m.length||(m=g.filter(w=>!ft.isDisabled(w)));const b=m.filter(ft.hasAttribute.bind(null,"BANDWIDTH")).map(w=>{const A=c.getSyncPoint(w,s,l,t)?1:2,v=ft.estimateSegmentRequestTime(r,n,w)*A-a;return{playlist:w,rebufferingImpact:v}}),C=b.filter(w=>w.rebufferingImpact<=0);return dn(C,(w,A)=>fl(A.playlist,w.playlist)),C.length?C[0]:(dn(b,(w,A)=>w.rebufferingImpact-A.rebufferingImpact),b[0]||null)},Tv=function(){const i=this.playlists.main.playlists.filter(ft.isEnabled);return dn(i,(e,t)=>fl(e,t)),i.filter(e=>!!ds(this.playlists.main,e).video)[0]||null},vv=i=>{let e=0,t;return i.bytes&&(t=new Uint8Array(i.bytes),i.segments.forEach(n=>{t.set(n,e),e+=n.byteLength})),t};function Ap(i){try{return new URL(i).pathname.split("/").slice(-2).join("/")}catch{return""}}const Sv=function(i,e,t){if(!i[t]){e.trigger({type:"usage",name:"vhs-608"});let n=t;/^cc708_/.test(t)&&(n="SERVICE"+t.split("_")[1]);const s=e.textTracks().getTrackById(n);if(s)i[t]=s;else{const r=e.options_.vhs&&e.options_.vhs.captionServices||{};let a=t,l=t,c=!1;const g=r[n];g&&(a=g.label,l=g.language,c=g.default),i[t]=e.addRemoteTextTrack({kind:"captions",id:n,default:c,label:a,language:l},!1).track}}},Ev=function({inbandTextTracks:i,captionArray:e,timestampOffset:t}){if(!e)return;const n=x.WebKitDataCue||x.VTTCue;e.forEach(s=>{const r=s.stream;s.content?s.content.forEach(a=>{const l=new n(s.startTime+t,s.endTime+t,a.text);l.line=a.line,l.align="left",l.position=a.position,l.positionAlign="line-left",i[r].addCue(l)}):i[r].addCue(new n(s.startTime+t,s.endTime+t,s.text))})},wv=function(i){Object.defineProperties(i.frame,{id:{get(){return B.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),i.value.key}},value:{get(){return B.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),i.value.data}},privateData:{get(){return B.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),i.value.data}}})},kv=({inbandTextTracks:i,metadataArray:e,timestampOffset:t,videoDuration:n})=>{if(!e)return;const s=x.WebKitDataCue||x.VTTCue,r=i.metadataTrack_;if(!r||(e.forEach(m=>{const b=m.cueTime+t;typeof b!="number"||x.isNaN(b)||b<0||!(b<1/0)||!m.frames||!m.frames.length||m.frames.forEach(C=>{const w=new s(b,b,C.value||C.url||C.data||"");w.frame=C,w.value=C,wv(w),r.addCue(w)})}),!r.cues||!r.cues.length))return;const a=r.cues,l=[];for(let m=0;m<a.length;m++)a[m]&&l.push(a[m]);const c=l.reduce((m,b)=>{const C=m[b.startTime]||[];return C.push(b),m[b.startTime]=C,m},{}),g=Object.keys(c).sort((m,b)=>Number(m)-Number(b));g.forEach((m,b)=>{const C=c[m],w=isFinite(n)?n:m,A=Number(g[b+1])||w;C.forEach(v=>{v.endTime=A})})},Cv={id:"ID",class:"CLASS",startDate:"START-DATE",duration:"DURATION",endDate:"END-DATE",endOnNext:"END-ON-NEXT",plannedDuration:"PLANNED-DURATION",scte35Out:"SCTE35-OUT",scte35In:"SCTE35-IN"},Iv=new Set(["id","class","startDate","duration","endDate","endOnNext","startTime","endTime","processDateRange"]),xv=({inbandTextTracks:i,dateRanges:e})=>{const t=i.metadataTrack_;if(!t)return;const n=x.WebKitDataCue||x.VTTCue;e.forEach(s=>{for(const r of Object.keys(s)){if(Iv.has(r))continue;const a=new n(s.startTime,s.endTime,"");a.id=s.id,a.type="com.apple.quicktime.HLS",a.value={key:Cv[r],data:s[r]},(r==="scte35Out"||r==="scte35In")&&(a.value.data=new Uint8Array(a.value.data.match(/[\da-f]{2}/gi)).buffer),t.addCue(a)}s.processDateRange()})},_d=(i,e,t)=>{i.metadataTrack_||(i.metadataTrack_=t.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,B.browser.IS_ANY_SAFARI||(i.metadataTrack_.inBandMetadataTrackDispatchType=e))},ns=function(i,e,t){let n,s;if(t&&t.cues)for(n=t.cues.length;n--;)s=t.cues[n],s.startTime>=i&&s.endTime<=e&&t.removeCue(s)},Av=function(i){const e=i.cues;if(!e)return;const t={};for(let n=e.length-1;n>=0;n--){const s=e[n],r=`${s.startTime}-${s.endTime}-${s.text}`;t[r]?i.removeCue(s):t[r]=s}},Pv=(i,e,t)=>{if(typeof e>"u"||e===null||!i.length)return[];const n=Math.ceil((e-t+3)*Ri.ONE_SECOND_IN_TS);let s;for(s=0;s<i.length&&!(i[s].pts>n);s++);return i.slice(s)},Lv=(i,e,t)=>{if(!e.length)return i;if(t)return e.slice();const n=e[0].pts;let s=0;for(s;s<i.length&&!(i[s].pts>=n);s++);return i.slice(0,s).concat(e)},Dv=(i,e,t,n)=>{const s=Math.ceil((e-n)*Ri.ONE_SECOND_IN_TS),r=Math.ceil((t-n)*Ri.ONE_SECOND_IN_TS),a=i.slice();let l=i.length;for(;l--&&!(i[l].pts<=r););if(l===-1)return a;let c=l+1;for(;c--&&!(i[c].pts<=s););return c=Math.max(c,0),a.splice(c,l-c+1),a},Ov=function(i,e){if(!i&&!e||!i&&e||i&&!e)return!1;if(i===e)return!0;const t=Object.keys(i).sort(),n=Object.keys(e).sort();if(t.length!==n.length)return!1;for(let s=0;s<t.length;s++){const r=t[s];if(r!==n[s]||i[r]!==e[r])return!1}return!0},Mv=function(i,e,t){e=e||[];const n=[];let s=0;for(let r=0;r<e.length;r++){const a=e[r];if(i===a.timeline&&(n.push(r),s+=a.duration,s>t))return r}return n.length===0?0:n[n.length-1]},Qn=1,Rv=500,bd=i=>typeof i=="number"&&isFinite(i),tr=1/60,Uv=(i,e,t)=>i!=="main"||!e||!t?null:!t.hasAudio&&!t.hasVideo?"Neither audio nor video found in segment.":e.hasVideo&&!t.hasVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!e.hasVideo&&t.hasVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null,Nv=(i,e,t)=>{let n=e-We.BACK_BUFFER_LENGTH;i.length&&(n=Math.max(n,i.start(0)));const s=e-t;return Math.min(s,n)},Zi=i=>{const{startOfSegment:e,duration:t,segment:n,part:s,playlist:{mediaSequence:r,id:a,segments:l=[]},mediaIndex:c,partIndex:g,timeline:m}=i,b=l.length-1;let C="mediaIndex/partIndex increment";i.getMediaInfoForTime?C=`getMediaInfoForTime (${i.getMediaInfoForTime})`:i.isSyncRequest&&(C="getSyncSegmentCandidate (isSyncRequest)"),i.independent&&(C+=` with independent ${i.independent}`);const w=typeof g=="number",A=i.segment.uri?"segment":"pre-segment",v=w?Xc({preloadSegment:n})-1:0;return`${A} [${r+c}/${r+b}]`+(w?` part [${g}/${v}]`:"")+` segment start/end [${n.start} => ${n.end}]`+(w?` part start/end [${s.start} => ${s.end}]`:"")+` startOfSegment [${e}] duration [${t}] timeline [${m}] selected by [${C}] playlist [${a}]`},Td=i=>`${i}TimingInfo`,Bv=({segmentTimeline:i,currentTimeline:e,startOfSegment:t,buffered:n,overrideCheck:s})=>!s&&i===e?null:i<e?t:n.length?n.end(n.length-1):t,mo=({timelineChangeController:i,currentTimeline:e,segmentTimeline:t,loaderType:n,audioDisabled:s})=>{if(e===t)return!1;if(n==="audio"){const r=i.lastTimelineChange({type:"main"});return!r||r.to!==t}if(n==="main"&&s){const r=i.pendingTimelineChange({type:"audio"});return!(r&&r.to===t)}return!1},Fv=i=>{if(!i)return!1;const e=i.pendingTimelineChange({type:"audio"}),t=i.pendingTimelineChange({type:"main"}),n=e&&t,s=n&&e.to!==t.to;return!!(n&&e.from!==-1&&t.from!==-1&&s)},jv=i=>{const e=i.timelineChangeController_.pendingTimelineChange({type:"audio"}),t=i.timelineChangeController_.pendingTimelineChange({type:"main"});return e&&t&&e.to<t.to},mi=i=>{const e=i.pendingSegment_;if(e&&mo({timelineChangeController:i.timelineChangeController_,currentTimeline:i.currentTimeline_,segmentTimeline:e.timeline,loaderType:i.loaderType_,audioDisabled:i.audioDisabled_})&&Fv(i.timelineChangeController_)){if(jv(i)){i.timelineChangeController_.trigger("audioTimelineBehind");return}i.timelineChangeController_.trigger("fixBadTimelineChange")}},$v=i=>{let e=0;return["video","audio"].forEach(function(t){const n=i[`${t}TimingInfo`];if(!n)return;const{start:s,end:r}=n;let a;typeof s=="bigint"||typeof r=="bigint"?a=x.BigInt(r)-x.BigInt(s):typeof s=="number"&&typeof r=="number"&&(a=r-s),typeof a<"u"&&a>e&&(e=a)}),typeof e=="bigint"&&e<Number.MAX_SAFE_INTEGER&&(e=Number(e)),e},vd=({segmentDuration:i,maxDuration:e})=>i?Math.round(i)>e+Xt:!1,qv=(i,e)=>{if(e!=="hls")return null;const t=$v({audioTimingInfo:i.audioTimingInfo,videoTimingInfo:i.videoTimingInfo});if(!t)return null;const n=i.playlist.targetDuration,s=vd({segmentDuration:t,maxDuration:n*2}),r=vd({segmentDuration:t,maxDuration:n}),a=`Segment with index ${i.mediaIndex} from playlist ${i.playlist.id} has a duration of ${t} when the reported duration is ${i.duration} and the target duration is ${n}. For HLS content, a duration in excess of the target duration may result in playback issues. See the HLS specification section on EXT-X-TARGETDURATION for more details: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1`;return s||r?{severity:s?"warn":"info",message:a}:null},Mi=({type:i,segment:e})=>{if(!e)return;const t=!!(e.key||e.map&&e.map.ke),n=!!(e.map&&!e.map.bytes),s=e.startOfSegment===void 0?e.start:e.startOfSegment;return{type:i||e.type,uri:e.resolvedUri||e.uri,start:s,duration:e.duration,isEncrypted:t,isMediaInitialization:n}};class yo extends B.EventTarget{constructor(e,t={}){if(super(),!e)throw new TypeError("Initialization settings are required");if(typeof e.currentTime!="function")throw new TypeError("No currentTime getter specified");if(!e.mediaSource)throw new TypeError("No MediaSource specified");this.bandwidth=e.bandwidth,this.throughput={rate:0,count:0},this.roundTrip=NaN,this.resetStats_(),this.mediaIndex=null,this.partIndex=null,this.hasPlayed_=e.hasPlayed,this.currentTime_=e.currentTime,this.seekable_=e.seekable,this.seeking_=e.seeking,this.duration_=e.duration,this.mediaSource_=e.mediaSource,this.vhs_=e.vhs,this.loaderType_=e.loaderType,this.currentMediaInfo_=void 0,this.startingMediaInfo_=void 0,this.segmentMetadataTrack_=e.segmentMetadataTrack,this.goalBufferLength_=e.goalBufferLength,this.sourceType_=e.sourceType,this.sourceUpdater_=e.sourceUpdater,this.inbandTextTracks_=e.inbandTextTracks,this.state_="INIT",this.timelineChangeController_=e.timelineChangeController,this.shouldSaveSegmentTimingInfo_=!0,this.parse708captions_=e.parse708captions,this.useDtsForTimestampOffset_=e.useDtsForTimestampOffset,this.captionServices_=e.captionServices,this.exactManifestTimings=e.exactManifestTimings,this.addMetadataToTextTrack=e.addMetadataToTextTrack,this.checkBufferTimeout_=null,this.error_=void 0,this.currentTimeline_=-1,this.shouldForceTimestampOffsetAfterResync_=!1,this.pendingSegment_=null,this.xhrOptions_=null,this.pendingSegments_=[],this.audioDisabled_=!1,this.isPendingTimestampOffset_=!1,this.gopBuffer_=[],this.timeMapping_=0,this.safeAppend_=!1,this.appendInitSegment_={audio:!0,video:!0},this.playlistOfLastInitSegment_={audio:null,video:null},this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_={id3:[],caption:[]},this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=null,this.activeInitSegmentId_=null,this.initSegments_={},this.cacheEncryptionKeys_=e.cacheEncryptionKeys,this.keyCache_={},this.decrypter_=e.decrypter,this.syncController_=e.syncController,this.syncPoint_={segmentIndex:0,time:0},this.transmuxer_=this.createTransmuxer_(),this.triggerSyncInfoUpdate_=()=>this.trigger("syncinfoupdate"),this.syncController_.on("syncinfoupdate",this.triggerSyncInfoUpdate_),this.mediaSource_.addEventListener("sourceopen",()=>{this.isEndOfStream_()||(this.ended_=!1)}),this.fetchAtBuffer_=!1,this.logger_=Lt(`SegmentLoader[${this.loaderType_}]`),Object.defineProperty(this,"state",{get(){return this.state_},set(n){n!==this.state_&&(this.logger_(`${this.state_} -> ${n}`),this.state_=n,this.trigger("statechange"))}}),this.sourceUpdater_.on("ready",()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():mi(this)}),this.sourceUpdater_.on("codecschange",n=>{this.trigger(je({type:"codecschange"},n))}),this.loaderType_==="main"&&this.timelineChangeController_.on("pendingtimelinechange",()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():mi(this)}),this.loaderType_==="audio"&&this.timelineChangeController_.on("timelinechange",n=>{this.trigger(je({type:"timelinechange"},n)),this.hasEnoughInfoToLoad_()?this.processLoadQueue_():mi(this),this.hasEnoughInfoToAppend_()?this.processCallQueue_():mi(this)})}get mediaSequenceSync_(){return this.syncController_.getMediaSequenceSync(this.loaderType_)}createTransmuxer_(){return za.createTransmuxer({remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,parse708captions:this.parse708captions_,captionServices:this.captionServices_})}resetStats_(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0,this.mediaAppends=0}dispose(){this.trigger("dispose"),this.state="DISPOSED",this.pause(),this.abort_(),this.transmuxer_&&this.transmuxer_.terminate(),this.resetStats_(),this.checkBufferTimeout_&&x.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_),this.off()}setAudio(e){this.audioDisabled_=!e,e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_())}abort(){if(this.state!=="WAITING"){this.pendingSegment_&&(this.pendingSegment_=null),this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_);return}this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()}abort_(){this.pendingSegment_&&this.pendingSegment_.abortRequests&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_),this.waitingOnRemove_=!1,x.clearTimeout(this.quotaExceededErrorRetryTimeout_),this.quotaExceededErrorRetryTimeout_=null}checkForAbort_(e){return this.state==="APPENDING"&&!this.pendingSegment_?(this.state="READY",!0):!this.pendingSegment_||this.pendingSegment_.requestId!==e}error(e){return typeof e<"u"&&(this.logger_("error occurred:",e),this.error_=e),this.pendingSegment_=null,this.error_}endOfStream(){this.ended_=!0,this.transmuxer_&&za.reset(this.transmuxer_),this.gopBuffer_.length=0,this.pause(),this.trigger("ended")}buffered_(){const e=this.getMediaInfo_();if(!this.sourceUpdater_||!e)return tt();if(this.loaderType_==="main"){const{hasAudio:t,hasVideo:n,isMuxed:s}=e;if(n&&t&&!this.audioDisabled_&&!s)return this.sourceUpdater_.buffered();if(n)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()}initSegmentForMap(e,t=!1){if(!e)return null;const n=Cr(e);let s=this.initSegments_[n];return t&&!s&&e.bytes&&(this.initSegments_[n]=s={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,tracks:e.tracks,timescales:e.timescales}),s||e}segmentKey(e,t=!1){if(!e)return null;const n=hp(e);let s=this.keyCache_[n];this.cacheEncryptionKeys_&&t&&!s&&e.bytes&&(this.keyCache_[n]=s={resolvedUri:e.resolvedUri,bytes:e.bytes});const r={resolvedUri:(s||e).resolvedUri};return s&&(r.bytes=s.bytes),r}couldBeginLoading_(){return this.playlist_&&!this.paused()}load(){if(this.monitorBuffer_(),!!this.playlist_){if(this.state==="INIT"&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||this.state!=="READY"&&this.state!=="INIT"||(this.state="READY")}}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}playlist(e,t={}){if(!e||this.playlist_&&this.playlist_.endList&&e.endList&&this.playlist_.uri===e.uri)return;const n=this.playlist_,s=this.pendingSegment_;this.playlist_=e,this.xhrOptions_=t,this.state==="INIT"&&(e.syncInfo={mediaSequence:e.mediaSequence,time:0},this.loaderType_==="main"&&this.syncController_.setDateTimeMappingForStart(e));let r=null;if(n&&(n.id?r=n.id:n.uri&&(r=n.uri)),this.logger_(`playlist update [${r} => ${e.id||e.uri}]`),this.mediaSequenceSync_&&(this.mediaSequenceSync_.update(e,this.currentTime_()),this.logger_(`Playlist update:
|
|
204
|
+
`)};var Bl={inspect:Qe,textify:ya,parseType:$n,findBox:nf,parseTraf:ci.traf,parseTfdt:ci.tfdt,parseHdlr:ci.hdlr,parseTfhd:ci.tfhd,parseTrun:ci.trun,parseSidx:ci.sidx},rf=function(o){for(var u=0,d=String.fromCharCode(o[u]),h="";d!=="\0";)h+=d,u++,d=String.fromCharCode(o[u]);return h+=d,h},af={uint8ToCString:rf},zs=af.uint8ToCString,of=r.getUint64,lf=function(o){var u=4,d=o[0],h,g,y,S,E,k,I,O;if(d===0){h=zs(o.subarray(u)),u+=h.length,g=zs(o.subarray(u)),u+=g.length;var j=new DataView(o.buffer);y=j.getUint32(u),u+=4,E=j.getUint32(u),u+=4,k=j.getUint32(u),u+=4,I=j.getUint32(u),u+=4}else if(d===1){var j=new DataView(o.buffer);y=j.getUint32(u),u+=4,S=of(o.subarray(u)),u+=8,k=j.getUint32(u),u+=4,I=j.getUint32(u),u+=4,h=zs(o.subarray(u)),u+=h.length,g=zs(o.subarray(u)),u+=g.length}O=new Uint8Array(o.subarray(u,o.byteLength));var Q={scheme_id_uri:h,value:g,timescale:y||1,presentation_time:S,presentation_time_delta:E,event_duration:k,id:I,message_data:O};return df(d,Q)?Q:void 0},uf=function(o,u,d,h){return o||o===0?o/u:h+d/u},df=function(o,u){var d=u.scheme_id_uri!=="\0",h=o===0&&Fl(u.presentation_time_delta)&&d,g=o===1&&Fl(u.presentation_time)&&d;return!(o>1)&&h||g},Fl=function(o){return o!==void 0||o!==null},hf={parseEmsgBox:lf,scaleTime:uf},qn;typeof window<"u"?qn=window:typeof i<"u"?qn=i:typeof self<"u"?qn=self:qn={};var jl=qn,Ws=Vs.toUnsigned,Vn=Vs.toHexString,Be=Hs,Xi=ga,_a=hf,cf=ma,pf=Ul,gf=fa,ff=r.getUint64,$l,ql,Vl,Hl,zl,ba,Wl,Ta=jl,mf=Tl.parseId3Frames;$l=function(o){var u={},d=Be(o,["moov","trak"]);return d.reduce(function(h,g){var y,S,E,k,I;return y=Be(g,["tkhd"])[0],!y||(S=y[0],E=S===0?12:20,k=Ws(y[E]<<24|y[E+1]<<16|y[E+2]<<8|y[E+3]),I=Be(g,["mdia","mdhd"])[0],!I)?null:(S=I[0],E=S===0?12:20,h[k]=Ws(I[E]<<24|I[E+1]<<16|I[E+2]<<8|I[E+3]),h)},u)},ql=function(o,u){var d;d=Be(u,["moof","traf"]);var h=d.reduce(function(g,y){var S=Be(y,["tfhd"])[0],E=Ws(S[4]<<24|S[5]<<16|S[6]<<8|S[7]),k=o[E]||9e4,I=Be(y,["tfdt"])[0],O=new DataView(I.buffer,I.byteOffset,I.byteLength),j;I[0]===1?j=ff(I.subarray(4,12)):j=O.getUint32(4);let Q;return typeof j=="bigint"?Q=j/Ta.BigInt(k):typeof j=="number"&&!isNaN(j)&&(Q=j/k),Q<Number.MAX_SAFE_INTEGER&&(Q=Number(Q)),Q<g&&(g=Q),g},1/0);return typeof h=="bigint"||isFinite(h)?h:0},Vl=function(o,u){var d=Be(u,["moof","traf"]),h=0,g=0,y;if(d&&d.length){var S=Be(d[0],["tfhd"])[0],E=Be(d[0],["trun"])[0],k=Be(d[0],["tfdt"])[0];if(S){var I=cf(S);y=I.trackId}if(k){var O=gf(k);h=O.baseMediaDecodeTime}if(E){var j=pf(E);j.samples&&j.samples.length&&(g=j.samples[0].compositionTimeOffset||0)}}var Q=o[y]||9e4;typeof h=="bigint"&&(g=Ta.BigInt(g),Q=Ta.BigInt(Q));var V=(h+g)/Q;return typeof V=="bigint"&&V<Number.MAX_SAFE_INTEGER&&(V=Number(V)),V},Hl=function(o){var u=Be(o,["moov","trak"]),d=[];return u.forEach(function(h){var g=Be(h,["mdia","hdlr"]),y=Be(h,["tkhd"]);g.forEach(function(S,E){var k=Xi(S.subarray(8,12)),I=y[E],O,j,Q;k==="vide"&&(O=new DataView(I.buffer,I.byteOffset,I.byteLength),j=O.getUint8(0),Q=j===0?O.getUint32(12):O.getUint32(20),d.push(Q))})}),d},ba=function(o){var u=o[0],d=u===0?12:20;return Ws(o[d]<<24|o[d+1]<<16|o[d+2]<<8|o[d+3])},zl=function(o){var u=Be(o,["moov","trak"]),d=[];return u.forEach(function(h){var g={},y=Be(h,["tkhd"])[0],S,E;y&&(S=new DataView(y.buffer,y.byteOffset,y.byteLength),E=S.getUint8(0),g.id=E===0?S.getUint32(12):S.getUint32(20));var k=Be(h,["mdia","hdlr"])[0];if(k){var I=Xi(k.subarray(8,12));I==="vide"?g.type="video":I==="soun"?g.type="audio":g.type=I}var O=Be(h,["mdia","minf","stbl","stsd"])[0];if(O){var j=O.subarray(8);g.codec=Xi(j.subarray(4,8));var Q=Be(j,[g.codec])[0],V,te;Q&&(/^[asm]vc[1-9]$/i.test(g.codec)?(V=Q.subarray(78),te=Xi(V.subarray(4,8)),te==="avcC"&&V.length>11?(g.codec+=".",g.codec+=Vn(V[9]),g.codec+=Vn(V[10]),g.codec+=Vn(V[11])):g.codec="avc1.4d400d"):/^mp4[a,v]$/i.test(g.codec)?(V=Q.subarray(28),te=Xi(V.subarray(4,8)),te==="esds"&&V.length>20&&V[19]!==0?(g.codec+="."+Vn(V[19]),g.codec+="."+Vn(V[20]>>>2&63).replace(/^0/,"")):g.codec="mp4a.40.2"):g.codec=g.codec.toLowerCase())}var se=Be(h,["mdia","mdhd"])[0];se&&(g.timescale=ba(se)),d.push(g)}),d},Wl=function(o,u=0){var d=Be(o,["emsg"]);return d.map(h=>{var g=_a.parseEmsgBox(new Uint8Array(h)),y=mf(g.message_data);return{cueTime:_a.scaleTime(g.presentation_time,g.timescale,g.presentation_time_delta,u),duration:_a.scaleTime(g.event_duration,g.timescale),frames:y}})};var Hn={findBox:Be,parseType:Xi,timescale:$l,startTime:ql,compositionStartTime:Vl,videoTrackIds:Hl,tracks:zl,getTimescaleFromMediaHeader:ba,getEmsgID3:Wl};const{parseTrun:yf}=Bl,{findBox:Gl}=Hn;var Xl=jl,_f=function(o){var u=Gl(o,["moof","traf"]),d=Gl(o,["mdat"]),h=[];return d.forEach(function(g,y){var S=u[y];h.push({mdat:g,traf:S})}),h},bf=function(o,u,d){var h=u,g=d.defaultSampleDuration||0,y=d.defaultSampleSize||0,S=d.trackId,E=[];return o.forEach(function(k){var I=yf(k),O=I.samples;O.forEach(function(j){j.duration===void 0&&(j.duration=g),j.size===void 0&&(j.size=y),j.trackId=S,j.dts=h,j.compositionTimeOffset===void 0&&(j.compositionTimeOffset=0),typeof h=="bigint"?(j.pts=h+Xl.BigInt(j.compositionTimeOffset),h+=Xl.BigInt(j.duration)):(j.pts=h+j.compositionTimeOffset,h+=j.duration)}),E=E.concat(O)}),E},Kl={getMdatTrafPairs:_f,parseSamples:bf},Tf=fl.discardEmulationPreventionBytes,vf=ml.CaptionStream,va=Hs,Sf=fa,Ef=ma,{getMdatTrafPairs:wf,parseSamples:kf}=Kl,Cf=function(o,u){for(var d=o,h=0;h<u.length;h++){var g=u[h];if(d<g.size)return g;d-=g.size}return null},If=function(o,u,d){var h=new DataView(o.buffer,o.byteOffset,o.byteLength),g={logs:[],seiNals:[]},y,S,E,k;for(S=0;S+4<o.length;S+=E)if(E=h.getUint32(S),S+=4,!(E<=0))switch(o[S]&31){case 6:var I=o.subarray(S+1,S+1+E),O=Cf(S,u);if(y={nalUnitType:"sei_rbsp",size:E,data:I,escapedRBSP:Tf(I),trackId:d},O)y.pts=O.pts,y.dts=O.dts,k=O;else if(k)y.pts=k.pts,y.dts=k.dts;else{g.logs.push({level:"warn",message:"We've encountered a nal unit without data at "+S+" for trackId "+d+". See mux.js#223."});break}g.seiNals.push(y);break}return g},xf=function(o,u){var d={},h=wf(o);return h.forEach(function(g){var y=g.mdat,S=g.traf,E=va(S,["tfhd"]),k=Ef(E[0]),I=k.trackId,O=va(S,["tfdt"]),j=O.length>0?Sf(O[0]).baseMediaDecodeTime:0,Q=va(S,["trun"]),V,te;u===I&&Q.length>0&&(V=kf(Q,j,k),te=If(y,V,I),d[I]||(d[I]={seiNals:[],logs:[]}),d[I].seiNals=d[I].seiNals.concat(te.seiNals),d[I].logs=d[I].logs.concat(te.logs))}),d},Af=function(o,u,d){var h;if(u===null)return null;h=xf(o,u);var g=h[u]||{};return{seiNals:g.seiNals,logs:g.logs,timescale:d}},Pf=function(){var o=!1,u,d,h,g,y,S;this.isInitialized=function(){return o},this.init=function(E){u=new vf,o=!0,S=E?E.isPartial:!1,u.on("data",function(k){k.startTime=k.startPts/g,k.endTime=k.endPts/g,y.captions.push(k),y.captionStreams[k.stream]=!0}),u.on("log",function(k){y.logs.push(k)})},this.isNewInit=function(E,k){return E&&E.length===0||k&&typeof k=="object"&&Object.keys(k).length===0?!1:h!==E[0]||g!==k[h]},this.parse=function(E,k,I){var O;if(this.isInitialized()){if(!k||!I)return null;if(this.isNewInit(k,I))h=k[0],g=I[h];else if(h===null||!g)return d.push(E),null}else return null;for(;d.length>0;){var j=d.shift();this.parse(j,k,I)}return O=Af(E,h,g),O&&O.logs&&(y.logs=y.logs.concat(O.logs)),O===null||!O.seiNals?y.logs.length?{logs:y.logs,captions:[],captionStreams:[]}:null:(this.pushNals(O.seiNals),this.flushStream(),y)},this.pushNals=function(E){if(!this.isInitialized()||!E||E.length===0)return null;E.forEach(function(k){u.push(k)})},this.flushStream=function(){if(!this.isInitialized())return null;S?u.partialFlush():u.flush()},this.clearParsedCaptions=function(){y.captions=[],y.captionStreams={},y.logs=[]},this.resetCaptionStream=function(){if(!this.isInitialized())return null;u.reset()},this.clearAllCaptions=function(){this.clearParsedCaptions(),this.resetCaptionStream()},this.reset=function(){d=[],h=null,g=null,y?this.clearParsedCaptions():y={captions:[],captionStreams:{},logs:[]},this.resetCaptionStream()},this.reset()},Lf=Pf;const{parseTfdt:Df}=Bl,pi=Hs,{getTimescaleFromMediaHeader:Of}=Hn,{parseSamples:Mf,getMdatTrafPairs:Rf}=Kl;var Yl=function(){let o=9e4;this.init=function(u){const d=pi(u,["moov","trak","mdia","mdhd"])[0];d&&(o=Of(d))},this.parseSegment=function(u){const d=[],h=Rf(u);let g=0;return h.forEach(function(y){const S=y.mdat,E=y.traf,k=pi(E,["tfdt"])[0],I=pi(E,["tfhd"])[0],O=pi(E,["trun"]);if(k&&(g=Df(k).baseMediaDecodeTime),O.length&&I){const j=Mf(O,g,I);let Q=0;j.forEach(function(V){const te="utf-8",se=new TextDecoder(te),ze=S.slice(Q,Q+V.size);if(pi(ze,["vtte"])[0]){Q+=V.size;return}pi(ze,["vttc"]).forEach(function(nt){const qt=pi(nt,["payl"])[0],zn=pi(nt,["sttg"])[0],Ks=V.pts/o,Ys=(V.pts+V.duration)/o;let Pi,Wn;if(qt)try{Pi=se.decode(qt)}catch(Ie){console.error(Ie)}if(zn)try{Wn=se.decode(zn)}catch(Ie){console.error(Ie)}V.duration&&Pi&&d.push({cueText:Pi,start:Ks,end:Ys,settings:Wn})}),Q+=V.size})}}),d}},Sa=Ps,Ql=function(o){var u=o[1]&31;return u<<=8,u|=o[2],u},Gs=function(o){return!!(o[1]&64)},Xs=function(o){var u=0;return(o[3]&48)>>>4>1&&(u+=o[4]+1),u},Uf=function(o,u){var d=Ql(o);return d===0?"pat":d===u?"pmt":u?"pes":null},Nf=function(o){var u=Gs(o),d=4+Xs(o);return u&&(d+=o[d]+1),(o[d+10]&31)<<8|o[d+11]},Bf=function(o){var u={},d=Gs(o),h=4+Xs(o);if(d&&(h+=o[h]+1),!!(o[h+5]&1)){var g,y,S;g=(o[h+1]&15)<<8|o[h+2],y=3+g-4,S=(o[h+10]&15)<<8|o[h+11];for(var E=12+S;E<y;){var k=h+E;u[(o[k+1]&31)<<8|o[k+2]]=o[k],E+=((o[k+3]&15)<<8|o[k+4])+5}return u}},Ff=function(o,u){var d=Ql(o),h=u[d];switch(h){case Sa.H264_STREAM_TYPE:return"video";case Sa.ADTS_STREAM_TYPE:return"audio";case Sa.METADATA_STREAM_TYPE:return"timed-metadata";default:return null}},jf=function(o){var u=Gs(o);if(!u)return null;var d=4+Xs(o);if(d>=o.byteLength)return null;var h=null,g;return g=o[d+7],g&192&&(h={},h.pts=(o[d+9]&14)<<27|(o[d+10]&255)<<20|(o[d+11]&254)<<12|(o[d+12]&255)<<5|(o[d+13]&254)>>>3,h.pts*=4,h.pts+=(o[d+13]&6)>>>1,h.dts=h.pts,g&64&&(h.dts=(o[d+14]&14)<<27|(o[d+15]&255)<<20|(o[d+16]&254)<<12|(o[d+17]&255)<<5|(o[d+18]&254)>>>3,h.dts*=4,h.dts+=(o[d+18]&6)>>>1)),h},Ea=function(o){switch(o){case 5:return"slice_layer_without_partitioning_rbsp_idr";case 6:return"sei_rbsp";case 7:return"seq_parameter_set_rbsp";case 8:return"pic_parameter_set_rbsp";case 9:return"access_unit_delimiter_rbsp";default:return null}},$f=function(o){for(var u=4+Xs(o),d=o.subarray(u),h=0,g=0,y=!1,S;g<d.byteLength-3;g++)if(d[g+2]===1){h=g+5;break}for(;h<d.byteLength;)switch(d[h]){case 0:if(d[h-1]!==0){h+=2;break}else if(d[h-2]!==0){h++;break}g+3!==h-2&&(S=Ea(d[g+3]&31),S==="slice_layer_without_partitioning_rbsp_idr"&&(y=!0));do h++;while(d[h]!==1&&h<d.length);g=h-2,h+=3;break;case 1:if(d[h-1]!==0||d[h-2]!==0){h+=3;break}S=Ea(d[g+3]&31),S==="slice_layer_without_partitioning_rbsp_idr"&&(y=!0),g=h-2,h+=3;break;default:h+=3;break}return d=d.subarray(g),h-=g,g=0,d&&d.byteLength>3&&(S=Ea(d[g+3]&31),S==="slice_layer_without_partitioning_rbsp_idr"&&(y=!0)),y},qf={parseType:Uf,parsePat:Nf,parsePmt:Bf,parsePayloadUnitStartIndicator:Gs,parsePesType:Ff,parsePesTime:jf,videoPacketContainsKeyFrame:$f},Jl=Ps,Ki=_l.handleRollover,ye={};ye.ts=qf,ye.aac=da;var Ai=T.ONE_SECOND_IN_TS,it=188,$t=71,Vf=function(o,u){for(var d=0,h=it,g,y;h<o.byteLength;){if(o[d]===$t&&o[h]===$t){switch(g=o.subarray(d,h),y=ye.ts.parseType(g,u.pid),y){case"pat":u.pid=ye.ts.parsePat(g);break;case"pmt":var S=ye.ts.parsePmt(g);u.table=u.table||{},Object.keys(S).forEach(function(E){u.table[E]=S[E]});break}d+=it,h+=it;continue}d++,h++}},Zl=function(o,u,d){for(var h=0,g=it,y,S,E,k,I,O=!1;g<=o.byteLength;){if(o[h]===$t&&(o[g]===$t||g===o.byteLength)){switch(y=o.subarray(h,g),S=ye.ts.parseType(y,u.pid),S){case"pes":E=ye.ts.parsePesType(y,u.table),k=ye.ts.parsePayloadUnitStartIndicator(y),E==="audio"&&k&&(I=ye.ts.parsePesTime(y),I&&(I.type="audio",d.audio.push(I),O=!0));break}if(O)break;h+=it,g+=it;continue}h++,g++}for(g=o.byteLength,h=g-it,O=!1;h>=0;){if(o[h]===$t&&(o[g]===$t||g===o.byteLength)){switch(y=o.subarray(h,g),S=ye.ts.parseType(y,u.pid),S){case"pes":E=ye.ts.parsePesType(y,u.table),k=ye.ts.parsePayloadUnitStartIndicator(y),E==="audio"&&k&&(I=ye.ts.parsePesTime(y),I&&(I.type="audio",d.audio.push(I),O=!0));break}if(O)break;h-=it,g-=it;continue}h--,g--}},Hf=function(o,u,d){for(var h=0,g=it,y,S,E,k,I,O,j,Q,V=!1,te={data:[],size:0};g<o.byteLength;){if(o[h]===$t&&o[g]===$t){switch(y=o.subarray(h,g),S=ye.ts.parseType(y,u.pid),S){case"pes":if(E=ye.ts.parsePesType(y,u.table),k=ye.ts.parsePayloadUnitStartIndicator(y),E==="video"&&(k&&!V&&(I=ye.ts.parsePesTime(y),I&&(I.type="video",d.video.push(I),V=!0)),!d.firstKeyFrame)){if(k&&te.size!==0){for(O=new Uint8Array(te.size),j=0;te.data.length;)Q=te.data.shift(),O.set(Q,j),j+=Q.byteLength;if(ye.ts.videoPacketContainsKeyFrame(O)){var se=ye.ts.parsePesTime(O);se?(d.firstKeyFrame=se,d.firstKeyFrame.type="video"):console.warn("Failed to extract PTS/DTS from PES at first keyframe. This could be an unusual TS segment, or else mux.js did not parse your TS segment correctly. If you know your TS segments do contain PTS/DTS on keyframes please file a bug report! You can try ffprobe to double check for yourself.")}te.size=0}te.data.push(y),te.size+=y.byteLength}break}if(V&&d.firstKeyFrame)break;h+=it,g+=it;continue}h++,g++}for(g=o.byteLength,h=g-it,V=!1;h>=0;){if(o[h]===$t&&o[g]===$t){switch(y=o.subarray(h,g),S=ye.ts.parseType(y,u.pid),S){case"pes":E=ye.ts.parsePesType(y,u.table),k=ye.ts.parsePayloadUnitStartIndicator(y),E==="video"&&k&&(I=ye.ts.parsePesTime(y),I&&(I.type="video",d.video.push(I),V=!0));break}if(V)break;h-=it,g-=it;continue}h--,g--}},zf=function(o,u){if(o.audio&&o.audio.length){var d=u;(typeof d>"u"||isNaN(d))&&(d=o.audio[0].dts),o.audio.forEach(function(y){y.dts=Ki(y.dts,d),y.pts=Ki(y.pts,d),y.dtsTime=y.dts/Ai,y.ptsTime=y.pts/Ai})}if(o.video&&o.video.length){var h=u;if((typeof h>"u"||isNaN(h))&&(h=o.video[0].dts),o.video.forEach(function(y){y.dts=Ki(y.dts,h),y.pts=Ki(y.pts,h),y.dtsTime=y.dts/Ai,y.ptsTime=y.pts/Ai}),o.firstKeyFrame){var g=o.firstKeyFrame;g.dts=Ki(g.dts,h),g.pts=Ki(g.pts,h),g.dtsTime=g.dts/Ai,g.ptsTime=g.pts/Ai}}},Wf=function(o){for(var u=!1,d=0,h=null,g=null,y=0,S=0,E;o.length-S>=3;){var k=ye.aac.parseType(o,S);switch(k){case"timed-metadata":if(o.length-S<10){u=!0;break}if(y=ye.aac.parseId3TagSize(o,S),y>o.length){u=!0;break}g===null&&(E=o.subarray(S,S+y),g=ye.aac.parseAacTimestamp(E)),S+=y;break;case"audio":if(o.length-S<7){u=!0;break}if(y=ye.aac.parseAdtsSize(o,S),y>o.length){u=!0;break}h===null&&(E=o.subarray(S,S+y),h=ye.aac.parseSampleRate(E)),d++,S+=y;break;default:S++;break}if(u)return null}if(h===null||g===null)return null;var I=Ai/h,O={audio:[{type:"audio",dts:g,pts:g},{type:"audio",dts:g+d*1024*I,pts:g+d*1024*I}]};return O},Gf=function(o){var u={pid:null,table:null},d={};Vf(o,u);for(var h in u.table)if(u.table.hasOwnProperty(h)){var g=u.table[h];switch(g){case Jl.H264_STREAM_TYPE:d.video=[],Hf(o,u,d),d.video.length===0&&delete d.video;break;case Jl.ADTS_STREAM_TYPE:d.audio=[],Zl(o,u,d),d.audio.length===0&&delete d.audio;break}}return d},Xf=function(o,u){var d=ye.aac.isLikelyAacData(o),h;return d?h=Wf(o):h=Gf(o),!h||!h.audio&&!h.video?null:(zf(h,u),h)},Kf={inspect:Xf,parseAudioPes_:Zl};const Yf=function(o,u){u.on("data",function(d){const h=d.initSegment;d.initSegment={data:h.buffer,byteOffset:h.byteOffset,byteLength:h.byteLength};const g=d.data;d.data=g.buffer,o.postMessage({action:"data",segment:d,byteOffset:g.byteOffset,byteLength:g.byteLength},[d.data])}),u.on("done",function(d){o.postMessage({action:"done"})}),u.on("gopInfo",function(d){o.postMessage({action:"gopInfo",gopInfo:d})}),u.on("videoSegmentTimingInfo",function(d){const h={start:{decode:T.videoTsToSeconds(d.start.dts),presentation:T.videoTsToSeconds(d.start.pts)},end:{decode:T.videoTsToSeconds(d.end.dts),presentation:T.videoTsToSeconds(d.end.pts)},baseMediaDecodeTime:T.videoTsToSeconds(d.baseMediaDecodeTime)};d.prependedContentDuration&&(h.prependedContentDuration=T.videoTsToSeconds(d.prependedContentDuration)),o.postMessage({action:"videoSegmentTimingInfo",videoSegmentTimingInfo:h})}),u.on("audioSegmentTimingInfo",function(d){const h={start:{decode:T.videoTsToSeconds(d.start.dts),presentation:T.videoTsToSeconds(d.start.pts)},end:{decode:T.videoTsToSeconds(d.end.dts),presentation:T.videoTsToSeconds(d.end.pts)},baseMediaDecodeTime:T.videoTsToSeconds(d.baseMediaDecodeTime)};d.prependedContentDuration&&(h.prependedContentDuration=T.videoTsToSeconds(d.prependedContentDuration)),o.postMessage({action:"audioSegmentTimingInfo",audioSegmentTimingInfo:h})}),u.on("id3Frame",function(d){o.postMessage({action:"id3Frame",id3Frame:d})}),u.on("caption",function(d){o.postMessage({action:"caption",caption:d})}),u.on("trackinfo",function(d){o.postMessage({action:"trackinfo",trackInfo:d})}),u.on("audioTimingInfo",function(d){o.postMessage({action:"audioTimingInfo",audioTimingInfo:{start:T.videoTsToSeconds(d.start),end:T.videoTsToSeconds(d.end)}})}),u.on("videoTimingInfo",function(d){o.postMessage({action:"videoTimingInfo",videoTimingInfo:{start:T.videoTsToSeconds(d.start),end:T.videoTsToSeconds(d.end)}})}),u.on("log",function(d){o.postMessage({action:"log",log:d})})};class eu{constructor(u,d){this.options=d||{},this.self=u,this.init()}init(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new jg.Transmuxer(this.options),Yf(this.self,this.transmuxer)}pushMp4Captions(u){this.captionParser||(this.captionParser=new Lf,this.captionParser.init());const d=new Uint8Array(u.data,u.byteOffset,u.byteLength),h=this.captionParser.parse(d,u.trackIds,u.timescales);this.self.postMessage({action:"mp4Captions",captions:h&&h.captions||[],logs:h&&h.logs||[],data:d.buffer},[d.buffer])}initMp4WebVttParser(u){this.webVttParser||(this.webVttParser=new Yl);const d=new Uint8Array(u.data,u.byteOffset,u.byteLength);this.webVttParser.init(d)}getMp4WebVttText(u){this.webVttParser||(this.webVttParser=new Yl);const d=new Uint8Array(u.data,u.byteOffset,u.byteLength),h=this.webVttParser.parseSegment(d);this.self.postMessage({action:"getMp4WebVttText",mp4VttCues:h||[],data:d.buffer},[d.buffer])}probeMp4StartTime({timescales:u,data:d}){const h=Hn.startTime(u,d);this.self.postMessage({action:"probeMp4StartTime",startTime:h,data:d},[d.buffer])}probeMp4Tracks({data:u}){const d=Hn.tracks(u);this.self.postMessage({action:"probeMp4Tracks",tracks:d,data:u},[u.buffer])}probeEmsgID3({data:u,offset:d}){const h=Hn.getEmsgID3(u,d);this.self.postMessage({action:"probeEmsgID3",id3Frames:h,emsgData:u},[u.buffer])}probeTs({data:u,baseStartTime:d}){const h=typeof d=="number"&&!isNaN(d)?d*T.ONE_SECOND_IN_TS:void 0,g=Kf.inspect(u,h);let y=null;g&&(y={hasVideo:g.video&&g.video.length===2||!1,hasAudio:g.audio&&g.audio.length===2||!1},y.hasVideo&&(y.videoStart=g.video[0].ptsTime),y.hasAudio&&(y.audioStart=g.audio[0].ptsTime)),this.self.postMessage({action:"probeTs",result:y,data:u},[u.buffer])}clearAllMp4Captions(){this.captionParser&&this.captionParser.clearAllCaptions()}clearParsedMp4Captions(){this.captionParser&&this.captionParser.clearParsedCaptions()}push(u){const d=new Uint8Array(u.data,u.byteOffset,u.byteLength);this.transmuxer.push(d)}reset(){this.transmuxer.reset()}setTimestampOffset(u){const d=u.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(T.secondsToVideoTs(d)))}setAudioAppendStart(u){this.transmuxer.setAudioAppendStart(Math.ceil(T.secondsToVideoTs(u.appendStart)))}setRemux(u){this.transmuxer.setRemux(u.remux)}flush(u){this.transmuxer.flush(),self.postMessage({action:"done",type:"transmuxed"})}endTimeline(){this.transmuxer.endTimeline(),self.postMessage({action:"endedtimeline",type:"transmuxed"})}alignGopsWith(u){this.transmuxer.alignGopsWith(u.gopsToAlignWith.slice())}}self.onmessage=function(o){if(o.data.action==="init"&&o.data.options){this.messageHandlers=new eu(self,o.data.options);return}this.messageHandlers||(this.messageHandlers=new eu(self)),o.data&&o.data.action&&o.data.action!=="init"&&this.messageHandlers[o.data.action]&&this.messageHandlers[o.data.action](o.data)}}));var FT=pp(BT);const jT=(i,e,t)=>{const{type:n,initSegment:s,captions:r,captionStreams:a,metadata:l,videoFrameDtsTime:c,videoFramePtsTime:f}=i.data.segment;e.buffer.push({captions:r,captionStreams:a,metadata:l});const m=i.data.segment.boxes||{data:i.data.segment.data},b={type:n,data:new Uint8Array(m.data,m.data.byteOffset,m.data.byteLength),initSegment:new Uint8Array(s.data,s.byteOffset,s.byteLength)};typeof c<"u"&&(b.videoFrameDtsTime=c),typeof f<"u"&&(b.videoFramePtsTime=f),t(b)},$T=({transmuxedData:i,callback:e})=>{i.buffer=[],e(i)},qT=(i,e)=>{e.gopInfo=i.data.gopInfo},mp=i=>{const{transmuxer:e,bytes:t,audioAppendStart:n,gopsToAlignWith:s,remux:r,onData:a,onTrackInfo:l,onAudioTimingInfo:c,onVideoTimingInfo:f,onVideoSegmentTimingInfo:m,onAudioSegmentTimingInfo:b,onId3:C,onCaptions:w,onDone:A,onEndedTimeline:v,onTransmuxerLog:M,isEndOfTimeline:D,segment:R,triggerSegmentEventFn:N}=i,F={buffer:[]};let P=D;const $=X=>{e.currentTransmux===i&&(X.data.action==="data"&&jT(X,F,a),X.data.action==="trackinfo"&&l(X.data.trackInfo),X.data.action==="gopInfo"&&qT(X,F),X.data.action==="audioTimingInfo"&&c(X.data.audioTimingInfo),X.data.action==="videoTimingInfo"&&f(X.data.videoTimingInfo),X.data.action==="videoSegmentTimingInfo"&&m(X.data.videoSegmentTimingInfo),X.data.action==="audioSegmentTimingInfo"&&b(X.data.audioSegmentTimingInfo),X.data.action==="id3Frame"&&C([X.data.id3Frame],X.data.id3Frame.dispatchType),X.data.action==="caption"&&w(X.data.caption),X.data.action==="endedtimeline"&&(P=!1,v()),X.data.action==="log"&&M(X.data.log),X.data.type==="transmuxed"&&(P||(e.onmessage=null,$T({transmuxedData:F,callback:A}),yp(e))))},Y=()=>{const X={message:"Received an error message from the transmuxer worker",metadata:{errorType:B.Error.StreamingFailedToTransmuxSegment,segmentInfo:Mi({segment:R})}};A(null,X)};if(e.onmessage=$,e.onerror=Y,n&&e.postMessage({action:"setAudioAppendStart",appendStart:n}),Array.isArray(s)&&e.postMessage({action:"alignGopsWith",gopsToAlignWith:s}),typeof r<"u"&&e.postMessage({action:"setRemux",remux:r}),t.byteLength){const X=t instanceof ArrayBuffer?t:t.buffer,re=t instanceof ArrayBuffer?0:t.byteOffset;N({type:"segmenttransmuxingstart",segment:R}),e.postMessage({action:"push",data:X,byteOffset:re,byteLength:t.byteLength},[X])}D&&e.postMessage({action:"endTimeline"}),e.postMessage({action:"flush"})},yp=i=>{i.currentTransmux=null,i.transmuxQueue.length&&(i.currentTransmux=i.transmuxQueue.shift(),typeof i.currentTransmux=="function"?i.currentTransmux():mp(i.currentTransmux))},hd=(i,e)=>{i.postMessage({action:e}),yp(i)},_p=(i,e)=>{if(!e.currentTransmux){e.currentTransmux=i,hd(e,i);return}e.transmuxQueue.push(hd.bind(null,e,i))},VT=i=>{_p("reset",i)},HT=i=>{_p("endTimeline",i)},bp=i=>{if(!i.transmuxer.currentTransmux){i.transmuxer.currentTransmux=i,mp(i);return}i.transmuxer.transmuxQueue.push(i)},zT=i=>{const e=new FT;e.currentTransmux=null,e.transmuxQueue=[];const t=e.terminate;return e.terminate=()=>(e.currentTransmux=null,e.transmuxQueue.length=0,t.call(e)),e.postMessage({action:"init",options:i}),e};var Ha={reset:VT,endTimeline:HT,transmux:bp,createTransmuxer:zT};const un=function(i){const e=i.transmuxer,t=i.endAction||i.action,n=i.callback,s=je({},i,{endAction:null,transmuxer:null,callback:null}),r=a=>{a.data.action===t&&(e.removeEventListener("message",r),a.data.data&&(a.data.data=new Uint8Array(a.data.data,i.byteOffset||0,i.byteLength||a.data.data.byteLength),i.data&&(i.data=a.data.data)),n(a.data))};if(e.addEventListener("message",r),i.data){const a=i.data instanceof ArrayBuffer;s.byteOffset=a?0:i.data.byteOffset,s.byteLength=i.data.byteLength;const l=[a?i.data:i.data.buffer];e.postMessage(s,l)}else e.postMessage(s)},Yt={FAILURE:2,TIMEOUT:-101,ABORTED:-102},Tp="wvtt",go=i=>{i.forEach(e=>{e.abort()})},WT=i=>({bandwidth:i.bandwidth,bytesReceived:i.bytesReceived||0,roundTripTime:i.roundTripTime||0}),GT=i=>{const e=i.target,t={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-e.requestTime||0};return t.bytesReceived=i.loaded,t.bandwidth=Math.floor(t.bytesReceived/t.roundTripTime*8*1e3),t},cl=(i,e)=>{const{requestType:t}=e,n=$i({requestType:t,request:e,error:i});return e.timedout?{status:e.status,message:"HLS request timed-out at URL: "+e.uri,code:Yt.TIMEOUT,xhr:e,metadata:n}:e.aborted?{status:e.status,message:"HLS request aborted at URL: "+e.uri,code:Yt.ABORTED,xhr:e,metadata:n}:i?{status:e.status,message:"HLS request errored at URL: "+e.uri,code:Yt.FAILURE,xhr:e,metadata:n}:e.responseType==="arraybuffer"&&e.response.byteLength===0?{status:e.status,message:"Empty HLS response at URL: "+e.uri,code:Yt.FAILURE,xhr:e,metadata:n}:null},cd=(i,e,t,n)=>(s,r)=>{const a=r.response,l=cl(s,r);if(l)return t(l,i);if(a.byteLength!==16)return t({status:r.status,message:"Invalid HLS key at URL: "+r.uri,code:Yt.FAILURE,xhr:r},i);const c=new DataView(a),f=new Uint32Array([c.getUint32(0),c.getUint32(4),c.getUint32(8),c.getUint32(12)]);for(let b=0;b<e.length;b++)e[b].bytes=f;const m={uri:r.uri};return n({type:"segmentkeyloadcomplete",segment:i,keyInfo:m}),t(null,i)},XT=(i,e)=>{e===Tp&&i.transmuxer.postMessage({action:"initMp4WebVttParser",data:i.map.bytes})},KT=(i,e,t)=>{e===Tp&&un({action:"getMp4WebVttText",data:i.bytes,transmuxer:i.transmuxer,callback:({data:n,mp4VttCues:s})=>{i.bytes=n,t(null,i,{mp4VttCues:s})}})},vp=(i,e)=>{const t=Do(i.map.bytes);if(t!=="mp4"){const n=i.map.resolvedUri||i.map.uri,s=t||"unknown";return e({internal:!0,message:`Found unsupported ${s} container for initialization segment at URL: ${n}`,code:Yt.FAILURE,metadata:{mediaType:s}})}un({action:"probeMp4Tracks",data:i.map.bytes,transmuxer:i.transmuxer,callback:({tracks:n,data:s})=>(i.map.bytes=s,n.forEach(function(r){i.map.tracks=i.map.tracks||{},!i.map.tracks[r.type]&&(i.map.tracks[r.type]=r,typeof r.id=="number"&&r.timescale&&(i.map.timescales=i.map.timescales||{},i.map.timescales[r.id]=r.timescale),r.type==="text"&&XT(i,r.codec))}),e(null))})},YT=({segment:i,finishProcessingFn:e,triggerSegmentEventFn:t})=>(n,s)=>{const r=cl(n,s);if(r)return e(r,i);const a=new Uint8Array(s.response);if(t({type:"segmentloaded",segment:i}),i.map.key)return i.map.encryptedBytes=a,e(null,i);i.map.bytes=a,vp(i,function(l){if(l)return l.xhr=s,l.status=s.status,e(l,i);e(null,i)})},QT=({segment:i,finishProcessingFn:e,responseType:t,triggerSegmentEventFn:n})=>(s,r)=>{const a=cl(s,r);if(a)return e(a,i);n({type:"segmentloaded",segment:i});const l=t==="arraybuffer"||!r.responseText?r.response:UT(r.responseText.substring(i.lastReachedChar||0));return i.stats=WT(r),i.key?i.encryptedBytes=new Uint8Array(l):i.bytes=new Uint8Array(l),e(null,i)},JT=({segment:i,bytes:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})=>{const A=i.map&&i.map.tracks||{},v=!!(A.audio&&A.video);let M=n.bind(null,i,"audio","start");const D=n.bind(null,i,"audio","end");let R=n.bind(null,i,"video","start");const N=n.bind(null,i,"video","end"),F=()=>bp({bytes:e,transmuxer:i.transmuxer,audioAppendStart:i.audioAppendStart,gopsToAlignWith:i.gopsToAlignWith,remux:v,onData:P=>{P.type=P.type==="combined"?"video":P.type,m(i,P)},onTrackInfo:P=>{t&&(v&&(P.isMuxed=!0),t(i,P))},onAudioTimingInfo:P=>{M&&typeof P.start<"u"&&(M(P.start),M=null),D&&typeof P.end<"u"&&D(P.end)},onVideoTimingInfo:P=>{R&&typeof P.start<"u"&&(R(P.start),R=null),N&&typeof P.end<"u"&&N(P.end)},onVideoSegmentTimingInfo:P=>{const $={pts:{start:P.start.presentation,end:P.end.presentation},dts:{start:P.start.decode,end:P.end.decode}};w({type:"segmenttransmuxingtiminginfoavailable",segment:i,timingInfo:$}),s(P)},onAudioSegmentTimingInfo:P=>{const $={pts:{start:P.start.pts,end:P.end.pts},dts:{start:P.start.dts,end:P.end.dts}};w({type:"segmenttransmuxingtiminginfoavailable",segment:i,timingInfo:$}),r(P)},onId3:(P,$)=>{a(i,P,$)},onCaptions:P=>{l(i,[P])},isEndOfTimeline:c,onEndedTimeline:()=>{f()},onTransmuxerLog:C,onDone:(P,$)=>{b&&(P.type=P.type==="combined"?"video":P.type,w({type:"segmenttransmuxingcomplete",segment:i}),b($,i,P))},segment:i,triggerSegmentEventFn:w});un({action:"probeTs",transmuxer:i.transmuxer,data:e,baseStartTime:i.baseStartTime,callback:P=>{i.bytes=e=P.data;const $=P.result;$&&(t(i,{hasAudio:$.hasAudio,hasVideo:$.hasVideo,isMuxed:v}),t=null),F()}})},Sp=({segment:i,bytes:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})=>{let A=new Uint8Array(e);if(T1(A)){i.isFmp4=!0;const{tracks:v}=i.map;if(v.text&&(!v.audio||!v.video)){m(i,{data:A,type:"text"}),KT(i,v.text.codec,b);return}const M={isFmp4:!0,hasVideo:!!v.video,hasAudio:!!v.audio};v.audio&&v.audio.codec&&v.audio.codec!=="enca"&&(M.audioCodec=v.audio.codec),v.video&&v.video.codec&&v.video.codec!=="encv"&&(M.videoCodec=v.video.codec),v.video&&v.audio&&(M.isMuxed=!0),t(i,M);const D=(R,N)=>{m(i,{data:A,type:M.hasAudio&&!M.isMuxed?"audio":"video"}),N&&N.length&&a(i,N),R&&R.length&&l(i,R),b(null,i,{})};un({action:"probeMp4StartTime",timescales:i.map.timescales,data:A,transmuxer:i.transmuxer,callback:({data:R,startTime:N})=>{e=R.buffer,i.bytes=A=R,M.hasAudio&&!M.isMuxed&&n(i,"audio","start",N),M.hasVideo&&n(i,"video","start",N),un({action:"probeEmsgID3",data:A,transmuxer:i.transmuxer,offset:N,callback:({emsgData:F,id3Frames:P})=>{if(e=F.buffer,i.bytes=A=F,!v.video||!F.byteLength||!i.transmuxer){D(void 0,P);return}un({action:"pushMp4Captions",endAction:"mp4Captions",transmuxer:i.transmuxer,data:A,timescales:i.map.timescales,trackIds:[v.video.id],callback:$=>{e=$.data.buffer,i.bytes=A=$.data,$.logs.forEach(function(Y){C(fe(Y,{stream:"mp4CaptionParser"}))}),D($.captions,P)}})}})}});return}if(!i.transmuxer){b(null,i,{});return}if(typeof i.container>"u"&&(i.container=Do(A)),i.container!=="ts"&&i.container!=="aac"){t(i,{hasAudio:!1,hasVideo:!1}),b(null,i,{});return}JT({segment:i,bytes:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})},Ep=function({id:i,key:e,encryptedBytes:t,decryptionWorker:n,segment:s,doneFn:r},a){const l=f=>{if(f.data.source===i){n.removeEventListener("message",l);const m=f.data.decrypted;a(new Uint8Array(m.bytes,m.byteOffset,m.byteLength))}};n.onerror=()=>{const f="An error occurred in the decryption worker",m=Mi({segment:s}),b={message:f,metadata:{error:new Error(f),errorType:B.Error.StreamingFailedToDecryptSegment,segmentInfo:m,keyInfo:{uri:s.key.resolvedUri||s.map.key.resolvedUri}}};r(b,s)},n.addEventListener("message",l);let c;e.bytes.slice?c=e.bytes.slice():c=new Uint32Array(Array.prototype.slice.call(e.bytes)),n.postMessage(op({source:i,encrypted:t,key:c,iv:e.iv}),[t.buffer,c.buffer])},ZT=({decryptionWorker:i,segment:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})=>{w({type:"segmentdecryptionstart"}),Ep({id:e.requestId,key:e.key,encryptedBytes:e.encryptedBytes,decryptionWorker:i,segment:e,doneFn:b},A=>{e.bytes=A,w({type:"segmentdecryptioncomplete",segment:e}),Sp({segment:e,bytes:e.bytes,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})})},ev=({activeXhrs:i,decryptionWorker:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})=>{let A=0,v=!1;return(M,D)=>{if(!v){if(M)return v=!0,go(i),b(M,D);if(A+=1,A===i.length){const R=function(){if(D.encryptedBytes)return ZT({decryptionWorker:e,segment:D,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w});Sp({segment:D,bytes:D.bytes,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m,doneFn:b,onTransmuxerLog:C,triggerSegmentEventFn:w})};if(D.endOfAllRequests=Date.now(),D.map&&D.map.encryptedBytes&&!D.map.bytes)return w({type:"segmentdecryptionstart",segment:D}),Ep({decryptionWorker:e,id:D.requestId+"-init",encryptedBytes:D.map.encryptedBytes,key:D.map.key,segment:D,doneFn:b},N=>{D.map.bytes=N,w({type:"segmentdecryptioncomplete",segment:D}),vp(D,F=>{if(F)return go(i),b(F,D);R()})});R()}}}},tv=({loadendState:i,abortFn:e})=>t=>{t.target.aborted&&e&&!i.calledAbortFn&&(e(),i.calledAbortFn=!0)},iv=({segment:i,progressFn:e,trackInfoFn:t,timingInfoFn:n,videoSegmentTimingInfoFn:s,audioSegmentTimingInfoFn:r,id3Fn:a,captionsFn:l,isEndOfTimeline:c,endedTimelineFn:f,dataFn:m})=>b=>{if(!b.target.aborted)return i.stats=fe(i.stats,GT(b)),!i.stats.firstBytesReceivedAt&&i.stats.bytesReceived&&(i.stats.firstBytesReceivedAt=Date.now()),e(b,i)},nv=({xhr:i,xhrOptions:e,decryptionWorker:t,segment:n,abortFn:s,progressFn:r,trackInfoFn:a,timingInfoFn:l,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:f,id3Fn:m,captionsFn:b,isEndOfTimeline:C,endedTimelineFn:w,dataFn:A,doneFn:v,onTransmuxerLog:M,triggerSegmentEventFn:D})=>{const R=[],N=ev({activeXhrs:R,decryptionWorker:t,trackInfoFn:a,timingInfoFn:l,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:f,id3Fn:m,captionsFn:b,isEndOfTimeline:C,endedTimelineFn:w,dataFn:A,doneFn:v,onTransmuxerLog:M,triggerSegmentEventFn:D});if(n.key&&!n.key.bytes){const X=[n.key];n.map&&!n.map.bytes&&n.map.key&&n.map.key.resolvedUri===n.key.resolvedUri&&X.push(n.map.key);const re=fe(e,{uri:n.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),ce=cd(n,X,N,D),be={uri:n.key.resolvedUri};D({type:"segmentkeyloadstart",segment:n,keyInfo:be});const he=i(re,ce);R.push(he)}if(n.map&&!n.map.bytes){if(n.map.key&&(!n.key||n.key.resolvedUri!==n.map.key.resolvedUri)){const be=fe(e,{uri:n.map.key.resolvedUri,responseType:"arraybuffer",requestType:"segment-key"}),he=cd(n,[n.map.key],N,D),Z={uri:n.map.key.resolvedUri};D({type:"segmentkeyloadstart",segment:n,keyInfo:Z});const de=i(be,he);R.push(de)}const X=fe(e,{uri:n.map.resolvedUri,responseType:"arraybuffer",headers:co(n.map),requestType:"segment-media-initialization"}),re=YT({segment:n,finishProcessingFn:N,triggerSegmentEventFn:D});D({type:"segmentloadstart",segment:n});const ce=i(X,re);R.push(ce)}const F=fe(e,{uri:n.part&&n.part.resolvedUri||n.resolvedUri,responseType:"arraybuffer",headers:co(n),requestType:"segment"}),P=QT({segment:n,finishProcessingFn:N,responseType:F.responseType,triggerSegmentEventFn:D});D({type:"segmentloadstart",segment:n});const $=i(F,P);$.addEventListener("progress",iv({segment:n,progressFn:r,trackInfoFn:a,timingInfoFn:l,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:f,id3Fn:m,captionsFn:b,isEndOfTimeline:C,endedTimelineFn:w,dataFn:A})),R.push($);const Y={};return R.forEach(X=>{X.addEventListener("loadend",tv({loadendState:Y,abortFn:s}))}),()=>go(R)},sv=Lt("CodecUtils"),rv=function(i){const e=i.attributes||{};if(e.CODECS)return Ht(e.CODECS)},wp=(i,e)=>{const t=e.attributes||{};return i&&i.mediaGroups&&i.mediaGroups.AUDIO&&t.AUDIO&&i.mediaGroups.AUDIO[t.AUDIO]},av=(i,e)=>{if(!wp(i,e))return!0;const t=e.attributes||{},n=i.mediaGroups.AUDIO[t.AUDIO];for(const s in n)if(!n[s].uri&&!n[s].playlists)return!0;return!1},Ir=function(i){const e={};return i.forEach(({mediaType:t,type:n,details:s})=>{e[t]=e[t]||[],e[t].push(ah(`${n}${s}`))}),Object.keys(e).forEach(function(t){if(e[t].length>1){sv(`multiple ${t} codecs found as attributes: ${e[t].join(", ")}. Setting playlist codecs to null so that we wait for mux.js to probe segments for real codecs.`),e[t]=null;return}e[t]=e[t][0]}),e},pd=function(i){let e=0;return i.audio&&e++,i.video&&e++,e},hs=function(i,e){const t=e.attributes||{},n=Ir(rv(e)||[]);if(wp(i,e)&&!n.audio&&!av(i,e)){const s=Ir(Y_(i,t.AUDIO)||[]);s.audio&&(n.audio=s.audio)}return n},tr=Lt("PlaylistSelector"),gd=function(i){if(!i||!i.playlist)return;const e=i.playlist;return JSON.stringify({id:e.id,bandwidth:i.bandwidth,width:i.width,height:i.height,codecs:e.attributes&&e.attributes.CODECS||""})},xr=function(i,e){if(!i)return"";const t=x.getComputedStyle(i);return t?t[e]:""},dn=function(i,e){const t=i.slice();i.sort(function(n,s){const r=e(n,s);return r===0?t.indexOf(n)-t.indexOf(s):r})},pl=function(i,e){let t,n;return i.attributes.BANDWIDTH&&(t=i.attributes.BANDWIDTH),t=t||x.Number.MAX_VALUE,e.attributes.BANDWIDTH&&(n=e.attributes.BANDWIDTH),n=n||x.Number.MAX_VALUE,t-n},ov=function(i,e){let t,n;return i.attributes.RESOLUTION&&i.attributes.RESOLUTION.width&&(t=i.attributes.RESOLUTION.width),t=t||x.Number.MAX_VALUE,e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(n=e.attributes.RESOLUTION.width),n=n||x.Number.MAX_VALUE,t===n&&i.attributes.BANDWIDTH&&e.attributes.BANDWIDTH?i.attributes.BANDWIDTH-e.attributes.BANDWIDTH:t-n};let kp=function(i,e,t,n,s,r){if(!i)return;const a={bandwidth:e,width:t,height:n,limitRenditionByPlayerDimensions:s};let l=i.playlists;gt.isAudioOnly(i)&&(l=r.getAudioTrackPlaylists_(),a.audioOnly=!0);let c=l.map(P=>{let $;const Y=P.attributes&&P.attributes.RESOLUTION&&P.attributes.RESOLUTION.width,X=P.attributes&&P.attributes.RESOLUTION&&P.attributes.RESOLUTION.height;return $=P.attributes&&P.attributes.BANDWIDTH,$=$||x.Number.MAX_VALUE,{bandwidth:$,width:Y,height:X,playlist:P}});dn(c,(P,$)=>P.bandwidth-$.bandwidth),c=c.filter(P=>!gt.isIncompatible(P.playlist));let f=c.filter(P=>gt.isEnabled(P.playlist));f.length||(f=c.filter(P=>!gt.isDisabled(P.playlist)));const m=f.filter(P=>P.bandwidth*We.BANDWIDTH_VARIANCE<e);let b=m[m.length-1];const C=m.filter(P=>P.bandwidth===b.bandwidth)[0];if(s===!1){const P=C||f[0]||c[0];if(P&&P.playlist){let $="sortedPlaylistReps";return C&&($="bandwidthBestRep"),f[0]&&($="enabledPlaylistReps"),tr(`choosing ${gd(P)} using ${$} with options`,a),P.playlist}return tr("could not choose a playlist with options",a),null}const w=m.filter(P=>P.width&&P.height);dn(w,(P,$)=>P.width-$.width);const A=w.filter(P=>P.width===t&&P.height===n);b=A[A.length-1];const v=A.filter(P=>P.bandwidth===b.bandwidth)[0];let M,D,R;v||(M=w.filter(P=>P.width>t||P.height>n),D=M.filter(P=>P.width===M[0].width&&P.height===M[0].height),b=D[D.length-1],R=D.filter(P=>P.bandwidth===b.bandwidth)[0]);let N;if(r.leastPixelDiffSelector){const P=w.map($=>($.pixelDiff=Math.abs($.width-t)+Math.abs($.height-n),$));dn(P,($,Y)=>$.pixelDiff===Y.pixelDiff?Y.bandwidth-$.bandwidth:$.pixelDiff-Y.pixelDiff),N=P[0]}const F=N||R||v||C||f[0]||c[0];if(F&&F.playlist){let P="sortedPlaylistReps";return N?P="leastPixelDiffRep":R?P="resolutionPlusOneRep":v?P="resolutionBestRep":C?P="bandwidthBestRep":f[0]&&(P="enabledPlaylistReps"),tr(`choosing ${gd(F)} using ${P} with options`,a),F.playlist}return tr("could not choose a playlist with options",a),null};const fd=function(){let i=this.useDevicePixelRatio&&x.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(i=this.customPixelRatio),kp(this.playlists.main,this.systemBandwidth,parseInt(xr(this.tech_.el(),"width"),10)*i,parseInt(xr(this.tech_.el(),"height"),10)*i,this.limitRenditionByPlayerDimensions,this.playlistController_)},lv=function(i){let e=-1,t=-1;if(i<0||i>1)throw new Error("Moving average bandwidth decay must be between 0 and 1.");return function(){let n=this.useDevicePixelRatio&&x.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(n=this.customPixelRatio),e<0&&(e=this.systemBandwidth,t=this.systemBandwidth),this.systemBandwidth>0&&this.systemBandwidth!==t&&(e=i*this.systemBandwidth+(1-i)*e,t=this.systemBandwidth),kp(this.playlists.main,e,parseInt(xr(this.tech_.el(),"width"),10)*n,parseInt(xr(this.tech_.el(),"height"),10)*n,this.limitRenditionByPlayerDimensions,this.playlistController_)}},uv=function(i){const{main:e,currentTime:t,bandwidth:n,duration:s,segmentDuration:r,timeUntilRebuffer:a,currentTimeline:l,syncController:c}=i,f=e.playlists.filter(w=>!gt.isIncompatible(w));let m=f.filter(gt.isEnabled);m.length||(m=f.filter(w=>!gt.isDisabled(w)));const b=m.filter(gt.hasAttribute.bind(null,"BANDWIDTH")).map(w=>{const A=c.getSyncPoint(w,s,l,t)?1:2,v=gt.estimateSegmentRequestTime(r,n,w)*A-a;return{playlist:w,rebufferingImpact:v}}),C=b.filter(w=>w.rebufferingImpact<=0);return dn(C,(w,A)=>pl(A.playlist,w.playlist)),C.length?C[0]:(dn(b,(w,A)=>w.rebufferingImpact-A.rebufferingImpact),b[0]||null)},dv=function(){const i=this.playlists.main.playlists.filter(gt.isEnabled);return dn(i,(e,t)=>pl(e,t)),i.filter(e=>!!hs(this.playlists.main,e).video)[0]||null},hv=i=>{let e=0,t;return i.bytes&&(t=new Uint8Array(i.bytes),i.segments.forEach(n=>{t.set(n,e),e+=n.byteLength})),t};function Cp(i){try{return new URL(i).pathname.split("/").slice(-2).join("/")}catch{return""}}const cv=function(i,e,t){if(!i[t]){e.trigger({type:"usage",name:"vhs-608"});let n=t;/^cc708_/.test(t)&&(n="SERVICE"+t.split("_")[1]);const s=e.textTracks().getTrackById(n);if(s)i[t]=s;else{const r=e.options_.vhs&&e.options_.vhs.captionServices||{};let a=t,l=t,c=!1;const f=r[n];f&&(a=f.label,l=f.language,c=f.default),i[t]=e.addRemoteTextTrack({kind:"captions",id:n,default:c,label:a,language:l},!1).track}}},pv=function({inbandTextTracks:i,captionArray:e,timestampOffset:t}){if(!e)return;const n=x.WebKitDataCue||x.VTTCue;e.forEach(s=>{const r=s.stream;s.content?s.content.forEach(a=>{const l=new n(s.startTime+t,s.endTime+t,a.text);l.line=a.line,l.align="left",l.position=a.position,l.positionAlign="line-left",i[r].addCue(l)}):i[r].addCue(new n(s.startTime+t,s.endTime+t,s.text))})},gv=function(i){Object.defineProperties(i.frame,{id:{get(){return B.log.warn("cue.frame.id is deprecated. Use cue.value.key instead."),i.value.key}},value:{get(){return B.log.warn("cue.frame.value is deprecated. Use cue.value.data instead."),i.value.data}},privateData:{get(){return B.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead."),i.value.data}}})},fv=({inbandTextTracks:i,metadataArray:e,timestampOffset:t,videoDuration:n})=>{if(!e)return;const s=x.WebKitDataCue||x.VTTCue,r=i.metadataTrack_;if(!r||(e.forEach(m=>{const b=m.cueTime+t;typeof b!="number"||x.isNaN(b)||b<0||!(b<1/0)||!m.frames||!m.frames.length||m.frames.forEach(C=>{const w=new s(b,b,C.value||C.url||C.data||"");w.frame=C,w.value=C,gv(w),r.addCue(w)})}),!r.cues||!r.cues.length))return;const a=r.cues,l=[];for(let m=0;m<a.length;m++)a[m]&&l.push(a[m]);const c=l.reduce((m,b)=>{const C=m[b.startTime]||[];return C.push(b),m[b.startTime]=C,m},{}),f=Object.keys(c).sort((m,b)=>Number(m)-Number(b));f.forEach((m,b)=>{const C=c[m],w=isFinite(n)?n:m,A=Number(f[b+1])||w;C.forEach(v=>{v.endTime=A})})},mv={id:"ID",class:"CLASS",startDate:"START-DATE",duration:"DURATION",endDate:"END-DATE",endOnNext:"END-ON-NEXT",plannedDuration:"PLANNED-DURATION",scte35Out:"SCTE35-OUT",scte35In:"SCTE35-IN"},yv=new Set(["id","class","startDate","duration","endDate","endOnNext","startTime","endTime","processDateRange"]),_v=({inbandTextTracks:i,dateRanges:e})=>{const t=i.metadataTrack_;if(!t)return;const n=x.WebKitDataCue||x.VTTCue;e.forEach(s=>{for(const r of Object.keys(s)){if(yv.has(r))continue;const a=new n(s.startTime,s.endTime,"");a.id=s.id,a.type="com.apple.quicktime.HLS",a.value={key:mv[r],data:s[r]},(r==="scte35Out"||r==="scte35In")&&(a.value.data=new Uint8Array(a.value.data.match(/[\da-f]{2}/gi)).buffer),t.addCue(a)}s.processDateRange()})},md=(i,e,t)=>{i.metadataTrack_||(i.metadataTrack_=t.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track,B.browser.IS_ANY_SAFARI||(i.metadataTrack_.inBandMetadataTrackDispatchType=e))},ss=function(i,e,t){let n,s;if(t&&t.cues)for(n=t.cues.length;n--;)s=t.cues[n],s.startTime>=i&&s.endTime<=e&&t.removeCue(s)},bv=function(i){const e=i.cues;if(!e)return;const t={};for(let n=e.length-1;n>=0;n--){const s=e[n],r=`${s.startTime}-${s.endTime}-${s.text}`;t[r]?i.removeCue(s):t[r]=s}},Tv=(i,e,t)=>{if(typeof e>"u"||e===null||!i.length)return[];const n=Math.ceil((e-t+3)*Ri.ONE_SECOND_IN_TS);let s;for(s=0;s<i.length&&!(i[s].pts>n);s++);return i.slice(s)},vv=(i,e,t)=>{if(!e.length)return i;if(t)return e.slice();const n=e[0].pts;let s=0;for(s;s<i.length&&!(i[s].pts>=n);s++);return i.slice(0,s).concat(e)},Sv=(i,e,t,n)=>{const s=Math.ceil((e-n)*Ri.ONE_SECOND_IN_TS),r=Math.ceil((t-n)*Ri.ONE_SECOND_IN_TS),a=i.slice();let l=i.length;for(;l--&&!(i[l].pts<=r););if(l===-1)return a;let c=l+1;for(;c--&&!(i[c].pts<=s););return c=Math.max(c,0),a.splice(c,l-c+1),a},Ev=function(i,e){if(!i&&!e||!i&&e||i&&!e)return!1;if(i===e)return!0;const t=Object.keys(i).sort(),n=Object.keys(e).sort();if(t.length!==n.length)return!1;for(let s=0;s<t.length;s++){const r=t[s];if(r!==n[s]||i[r]!==e[r])return!1}return!0},wv=function(i,e,t){e=e||[];const n=[];let s=0;for(let r=0;r<e.length;r++){const a=e[r];if(i===a.timeline&&(n.push(r),s+=a.duration,s>t))return r}return n.length===0?0:n[n.length-1]},Jn=1,kv=500,yd=i=>typeof i=="number"&&isFinite(i),ir=1/60,Cv=(i,e,t)=>i!=="main"||!e||!t?null:!t.hasAudio&&!t.hasVideo?"Neither audio nor video found in segment.":e.hasVideo&&!t.hasVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!e.hasVideo&&t.hasVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null,Iv=(i,e,t)=>{let n=e-We.BACK_BUFFER_LENGTH;i.length&&(n=Math.max(n,i.start(0)));const s=e-t;return Math.min(s,n)},Zi=i=>{const{startOfSegment:e,duration:t,segment:n,part:s,playlist:{mediaSequence:r,id:a,segments:l=[]},mediaIndex:c,partIndex:f,timeline:m}=i,b=l.length-1;let C="mediaIndex/partIndex increment";i.getMediaInfoForTime?C=`getMediaInfoForTime (${i.getMediaInfoForTime})`:i.isSyncRequest&&(C="getSyncSegmentCandidate (isSyncRequest)"),i.independent&&(C+=` with independent ${i.independent}`);const w=typeof f=="number",A=i.segment.uri?"segment":"pre-segment",v=w?zc({preloadSegment:n})-1:0;return`${A} [${r+c}/${r+b}]`+(w?` part [${f}/${v}]`:"")+` segment start/end [${n.start} => ${n.end}]`+(w?` part start/end [${s.start} => ${s.end}]`:"")+` startOfSegment [${e}] duration [${t}] timeline [${m}] selected by [${C}] playlist [${a}]`},_d=i=>`${i}TimingInfo`,xv=({segmentTimeline:i,currentTimeline:e,startOfSegment:t,buffered:n,overrideCheck:s})=>!s&&i===e?null:i<e?t:n.length?n.end(n.length-1):t,fo=({timelineChangeController:i,currentTimeline:e,segmentTimeline:t,loaderType:n,audioDisabled:s})=>{if(e===t)return!1;if(n==="audio"){const r=i.lastTimelineChange({type:"main"});return!r||r.to!==t}if(n==="main"&&s){const r=i.pendingTimelineChange({type:"audio"});return!(r&&r.to===t)}return!1},Av=i=>{if(!i)return!1;const e=i.pendingTimelineChange({type:"audio"}),t=i.pendingTimelineChange({type:"main"}),n=e&&t,s=n&&e.to!==t.to;return!!(n&&e.from!==-1&&t.from!==-1&&s)},Pv=i=>{const e=i.timelineChangeController_.pendingTimelineChange({type:"audio"}),t=i.timelineChangeController_.pendingTimelineChange({type:"main"});return e&&t&&e.to<t.to},mi=i=>{const e=i.pendingSegment_;if(e&&fo({timelineChangeController:i.timelineChangeController_,currentTimeline:i.currentTimeline_,segmentTimeline:e.timeline,loaderType:i.loaderType_,audioDisabled:i.audioDisabled_})&&Av(i.timelineChangeController_)){if(Pv(i)){i.timelineChangeController_.trigger("audioTimelineBehind");return}i.timelineChangeController_.trigger("fixBadTimelineChange")}},Lv=i=>{let e=0;return["video","audio"].forEach(function(t){const n=i[`${t}TimingInfo`];if(!n)return;const{start:s,end:r}=n;let a;typeof s=="bigint"||typeof r=="bigint"?a=x.BigInt(r)-x.BigInt(s):typeof s=="number"&&typeof r=="number"&&(a=r-s),typeof a<"u"&&a>e&&(e=a)}),typeof e=="bigint"&&e<Number.MAX_SAFE_INTEGER&&(e=Number(e)),e},bd=({segmentDuration:i,maxDuration:e})=>i?Math.round(i)>e+Xt:!1,Dv=(i,e)=>{if(e!=="hls")return null;const t=Lv({audioTimingInfo:i.audioTimingInfo,videoTimingInfo:i.videoTimingInfo});if(!t)return null;const n=i.playlist.targetDuration,s=bd({segmentDuration:t,maxDuration:n*2}),r=bd({segmentDuration:t,maxDuration:n}),a=`Segment with index ${i.mediaIndex} from playlist ${i.playlist.id} has a duration of ${t} when the reported duration is ${i.duration} and the target duration is ${n}. For HLS content, a duration in excess of the target duration may result in playback issues. See the HLS specification section on EXT-X-TARGETDURATION for more details: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1`;return s||r?{severity:s?"warn":"info",message:a}:null},Mi=({type:i,segment:e})=>{if(!e)return;const t=!!(e.key||e.map&&e.map.ke),n=!!(e.map&&!e.map.bytes),s=e.startOfSegment===void 0?e.start:e.startOfSegment;return{type:i||e.type,uri:e.resolvedUri||e.uri,start:s,duration:e.duration,isEncrypted:t,isMediaInitialization:n}};class mo extends B.EventTarget{constructor(e,t={}){if(super(),!e)throw new TypeError("Initialization settings are required");if(typeof e.currentTime!="function")throw new TypeError("No currentTime getter specified");if(!e.mediaSource)throw new TypeError("No MediaSource specified");this.bandwidth=e.bandwidth,this.throughput={rate:0,count:0},this.roundTrip=NaN,this.resetStats_(),this.mediaIndex=null,this.partIndex=null,this.hasPlayed_=e.hasPlayed,this.currentTime_=e.currentTime,this.seekable_=e.seekable,this.seeking_=e.seeking,this.duration_=e.duration,this.mediaSource_=e.mediaSource,this.vhs_=e.vhs,this.loaderType_=e.loaderType,this.currentMediaInfo_=void 0,this.startingMediaInfo_=void 0,this.segmentMetadataTrack_=e.segmentMetadataTrack,this.goalBufferLength_=e.goalBufferLength,this.sourceType_=e.sourceType,this.sourceUpdater_=e.sourceUpdater,this.inbandTextTracks_=e.inbandTextTracks,this.state_="INIT",this.timelineChangeController_=e.timelineChangeController,this.shouldSaveSegmentTimingInfo_=!0,this.parse708captions_=e.parse708captions,this.useDtsForTimestampOffset_=e.useDtsForTimestampOffset,this.captionServices_=e.captionServices,this.exactManifestTimings=e.exactManifestTimings,this.addMetadataToTextTrack=e.addMetadataToTextTrack,this.checkBufferTimeout_=null,this.error_=void 0,this.currentTimeline_=-1,this.shouldForceTimestampOffsetAfterResync_=!1,this.pendingSegment_=null,this.xhrOptions_=null,this.pendingSegments_=[],this.audioDisabled_=!1,this.isPendingTimestampOffset_=!1,this.gopBuffer_=[],this.timeMapping_=0,this.safeAppend_=!1,this.appendInitSegment_={audio:!0,video:!0},this.playlistOfLastInitSegment_={audio:null,video:null},this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_={id3:[],caption:[]},this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=null,this.activeInitSegmentId_=null,this.initSegments_={},this.cacheEncryptionKeys_=e.cacheEncryptionKeys,this.keyCache_={},this.decrypter_=e.decrypter,this.syncController_=e.syncController,this.syncPoint_={segmentIndex:0,time:0},this.transmuxer_=this.createTransmuxer_(),this.triggerSyncInfoUpdate_=()=>this.trigger("syncinfoupdate"),this.syncController_.on("syncinfoupdate",this.triggerSyncInfoUpdate_),this.mediaSource_.addEventListener("sourceopen",()=>{this.isEndOfStream_()||(this.ended_=!1)}),this.fetchAtBuffer_=!1,this.logger_=Lt(`SegmentLoader[${this.loaderType_}]`),Object.defineProperty(this,"state",{get(){return this.state_},set(n){n!==this.state_&&(this.logger_(`${this.state_} -> ${n}`),this.state_=n,this.trigger("statechange"))}}),this.sourceUpdater_.on("ready",()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():mi(this)}),this.sourceUpdater_.on("codecschange",n=>{this.trigger(je({type:"codecschange"},n))}),this.loaderType_==="main"&&this.timelineChangeController_.on("pendingtimelinechange",()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():mi(this)}),this.loaderType_==="audio"&&this.timelineChangeController_.on("timelinechange",n=>{this.trigger(je({type:"timelinechange"},n)),this.hasEnoughInfoToLoad_()?this.processLoadQueue_():mi(this),this.hasEnoughInfoToAppend_()?this.processCallQueue_():mi(this)})}get mediaSequenceSync_(){return this.syncController_.getMediaSequenceSync(this.loaderType_)}createTransmuxer_(){return Ha.createTransmuxer({remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,parse708captions:this.parse708captions_,captionServices:this.captionServices_})}resetStats_(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0,this.mediaAppends=0}dispose(){this.trigger("dispose"),this.state="DISPOSED",this.pause(),this.abort_(),this.transmuxer_&&this.transmuxer_.terminate(),this.resetStats_(),this.checkBufferTimeout_&&x.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_),this.off()}setAudio(e){this.audioDisabled_=!e,e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_())}abort(){if(this.state!=="WAITING"){this.pendingSegment_&&(this.pendingSegment_=null),this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_);return}this.abort_(),this.state="READY",this.paused()||this.monitorBuffer_()}abort_(){this.pendingSegment_&&this.pendingSegment_.abortRequests&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_),this.waitingOnRemove_=!1,x.clearTimeout(this.quotaExceededErrorRetryTimeout_),this.quotaExceededErrorRetryTimeout_=null}checkForAbort_(e){return this.state==="APPENDING"&&!this.pendingSegment_?(this.state="READY",!0):!this.pendingSegment_||this.pendingSegment_.requestId!==e}error(e){return typeof e<"u"&&(this.logger_("error occurred:",e),this.error_=e),this.pendingSegment_=null,this.error_}endOfStream(){this.ended_=!0,this.transmuxer_&&Ha.reset(this.transmuxer_),this.gopBuffer_.length=0,this.pause(),this.trigger("ended")}buffered_(){const e=this.getMediaInfo_();if(!this.sourceUpdater_||!e)return tt();if(this.loaderType_==="main"){const{hasAudio:t,hasVideo:n,isMuxed:s}=e;if(n&&t&&!this.audioDisabled_&&!s)return this.sourceUpdater_.buffered();if(n)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()}initSegmentForMap(e,t=!1){if(!e)return null;const n=Cr(e);let s=this.initSegments_[n];return t&&!s&&e.bytes&&(this.initSegments_[n]=s={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,tracks:e.tracks,timescales:e.timescales}),s||e}segmentKey(e,t=!1){if(!e)return null;const n=lp(e);let s=this.keyCache_[n];this.cacheEncryptionKeys_&&t&&!s&&e.bytes&&(this.keyCache_[n]=s={resolvedUri:e.resolvedUri,bytes:e.bytes});const r={resolvedUri:(s||e).resolvedUri};return s&&(r.bytes=s.bytes),r}couldBeginLoading_(){return this.playlist_&&!this.paused()}load(){if(this.monitorBuffer_(),!!this.playlist_){if(this.state==="INIT"&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||this.state!=="READY"&&this.state!=="INIT"||(this.state="READY")}}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}playlist(e,t={}){if(!e||this.playlist_&&this.playlist_.endList&&e.endList&&this.playlist_.uri===e.uri)return;const n=this.playlist_,s=this.pendingSegment_;this.playlist_=e,this.xhrOptions_=t,this.state==="INIT"&&(e.syncInfo={mediaSequence:e.mediaSequence,time:0},this.loaderType_==="main"&&this.syncController_.setDateTimeMappingForStart(e));let r=null;if(n&&(n.id?r=n.id:n.uri&&(r=n.uri)),this.logger_(`playlist update [${r} => ${e.id||e.uri}]`),this.mediaSequenceSync_&&(this.mediaSequenceSync_.update(e,this.currentTime_()),this.logger_(`Playlist update:
|
|
205
205
|
currentTime: ${this.currentTime_()}
|
|
206
|
-
bufferedEnd: ${
|
|
207
|
-
`,this.mediaSequenceSync_.diagnostics)),this.trigger("syncinfoupdate"),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();if(!n||n.uri!==e.uri){this.mediaIndex!==null&&(!e.endList&&typeof e.partTargetDuration=="number"?this.resetLoader():this.resyncLoader()),this.currentMediaInfo_=void 0,this.trigger("playlistupdate");return}const a=e.mediaSequence-n.mediaSequence;if(this.logger_(`live window shift [${a}]`),this.mediaIndex!==null)if(this.mediaIndex-=a,this.mediaIndex<0)this.mediaIndex=null,this.partIndex=null;else{const l=this.playlist_.segments[this.mediaIndex];if(this.partIndex&&(!l.parts||!l.parts.length||!l.parts[this.partIndex])){const c=this.mediaIndex;this.logger_(`currently processing part (index ${this.partIndex}) no longer exists.`),this.resetLoader(),this.mediaIndex=c}}s&&(s.mediaIndex-=a,s.mediaIndex<0?(s.mediaIndex=null,s.partIndex=null):(s.mediaIndex>=0&&(s.segment=e.segments[s.mediaIndex]),s.partIndex>=0&&s.segment.parts&&(s.part=s.segment.parts[s.partIndex]))),this.syncController_.saveExpiredSegmentInfo(n,e)}pause(){this.checkBufferTimeout_&&(x.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}paused(){return this.checkBufferTimeout_===null}resetEverything(e){this.ended_=!1,this.activeInitSegmentId_=null,this.appendInitSegment_={audio:!0,video:!0},this.resetLoader(),this.remove(0,1/0,e),this.transmuxer_&&(this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),this.transmuxer_.postMessage({action:"reset"}))}resetLoader(){this.fetchAtBuffer_=!1,this.mediaSequenceSync_&&this.mediaSequenceSync_.resetAppendedStatus(),this.resyncLoader()}resyncLoader(){this.transmuxer_&&
|
|
206
|
+
bufferedEnd: ${qa(this.buffered_())}
|
|
207
|
+
`,this.mediaSequenceSync_.diagnostics)),this.trigger("syncinfoupdate"),this.state==="INIT"&&this.couldBeginLoading_())return this.init_();if(!n||n.uri!==e.uri){this.mediaIndex!==null&&(!e.endList&&typeof e.partTargetDuration=="number"?this.resetLoader():this.resyncLoader()),this.currentMediaInfo_=void 0,this.trigger("playlistupdate");return}const a=e.mediaSequence-n.mediaSequence;if(this.logger_(`live window shift [${a}]`),this.mediaIndex!==null)if(this.mediaIndex-=a,this.mediaIndex<0)this.mediaIndex=null,this.partIndex=null;else{const l=this.playlist_.segments[this.mediaIndex];if(this.partIndex&&(!l.parts||!l.parts.length||!l.parts[this.partIndex])){const c=this.mediaIndex;this.logger_(`currently processing part (index ${this.partIndex}) no longer exists.`),this.resetLoader(),this.mediaIndex=c}}s&&(s.mediaIndex-=a,s.mediaIndex<0?(s.mediaIndex=null,s.partIndex=null):(s.mediaIndex>=0&&(s.segment=e.segments[s.mediaIndex]),s.partIndex>=0&&s.segment.parts&&(s.part=s.segment.parts[s.partIndex]))),this.syncController_.saveExpiredSegmentInfo(n,e)}pause(){this.checkBufferTimeout_&&(x.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=null)}paused(){return this.checkBufferTimeout_===null}resetEverything(e){this.ended_=!1,this.activeInitSegmentId_=null,this.appendInitSegment_={audio:!0,video:!0},this.resetLoader(),this.remove(0,1/0,e),this.transmuxer_&&(this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),this.transmuxer_.postMessage({action:"reset"}))}resetLoader(){this.fetchAtBuffer_=!1,this.mediaSequenceSync_&&this.mediaSequenceSync_.resetAppendedStatus(),this.resyncLoader()}resyncLoader(){this.transmuxer_&&Ha.reset(this.transmuxer_),this.mediaIndex=null,this.partIndex=null,this.syncPoint_=null,this.isPendingTimestampOffset_=!1;const e=this.currentMediaInfo_&&this.currentMediaInfo_.isFmp4;this.sourceType_==="hls"&&!e&&(this.shouldForceTimestampOffsetAfterResync_=!0),this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}remove(e,t,n=()=>{},s=!1){if(t===1/0&&(t=this.duration_()),t<=e){this.logger_("skipping remove because end ${end} is <= start ${start}");return}if(!this.sourceUpdater_||!this.getMediaInfo_()){this.logger_("skipping remove because no source updater or starting media info");return}let r=1;const a=()=>{r--,r===0&&n()};(s||!this.audioDisabled_)&&(r++,this.sourceUpdater_.removeAudio(e,t,a)),(s||this.loaderType_==="main")&&(this.gopBuffer_=Sv(this.gopBuffer_,e,t,this.timeMapping_),r++,this.sourceUpdater_.removeVideo(e,t,a));for(const l in this.inbandTextTracks_)ss(e,t,this.inbandTextTracks_[l]);ss(e,t,this.segmentMetadataTrack_),a()}monitorBuffer_(){this.checkBufferTimeout_&&x.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=x.setTimeout(this.monitorBufferTick_.bind(this),1)}monitorBufferTick_(){this.state==="READY"&&this.fillBuffer_(),this.checkBufferTimeout_&&x.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=x.setTimeout(this.monitorBufferTick_.bind(this),kv)}fillBuffer_(){if(this.sourceUpdater_.updating())return;const e=this.chooseNextRequest_();if(!e)return;const t={segmentInfo:Mi({type:this.loaderType_,segment:e})};this.trigger({type:"segmentselected",metadata:t}),typeof e.timestampOffset=="number"&&(this.isPendingTimestampOffset_=!1,this.timelineChangeController_.pendingTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline})),this.loadSegment_(e)}isEndOfStream_(e=this.mediaIndex,t=this.playlist_,n=this.partIndex){if(!t||!this.mediaSource_)return!1;const s=typeof e=="number"&&t.segments[e],r=e+1===t.segments.length,a=!s||!s.parts||n+1===s.parts.length;return t.endList&&this.mediaSource_.readyState==="open"&&r&&a}chooseNextRequest_(){const e=this.buffered_(),t=qa(e)||0,n=ll(e,this.currentTime_()),s=!this.hasPlayed_()&&n>=1,r=n>=this.goalBufferLength_(),a=this.playlist_.segments;if(!a.length||s||r)return null;this.syncPoint_=this.syncPoint_||this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_(),this.loaderType_);const l={partIndex:null,mediaIndex:null,startOfSegment:null,playlist:this.playlist_,isSyncRequest:!this.syncPoint_};if(l.isSyncRequest)l.mediaIndex=wv(this.currentTimeline_,a,t),this.logger_(`choose next request. Can not find sync point. Fallback to media Index: ${l.mediaIndex}`);else if(this.mediaIndex!==null){const C=a[this.mediaIndex],w=typeof this.partIndex=="number"?this.partIndex:-1;l.startOfSegment=C.end?C.end:t,C.parts&&C.parts[w+1]?(l.mediaIndex=this.mediaIndex,l.partIndex=w+1):l.mediaIndex=this.mediaIndex+1}else{let C,w,A;const v=this.fetchAtBuffer_?t:this.currentTime_();if(this.mediaSequenceSync_&&this.logger_(`chooseNextRequest_ request after Quality Switch:
|
|
208
208
|
For TargetTime: ${v}.
|
|
209
209
|
CurrentTime: ${this.currentTime_()}
|
|
210
210
|
BufferedEnd: ${t}
|
|
211
211
|
Fetch At Buffer: ${this.fetchAtBuffer_}
|
|
212
|
-
`,this.mediaSequenceSync_.diagnostics),this.mediaSequenceSync_&&this.mediaSequenceSync_.isReliable){const M=this.getSyncInfoFromMediaSequenceSync_(v);if(!M){const D="No sync info found while using media sequence sync";return this.error({message:D,metadata:{errorType:B.Error.StreamingFailedToSelectNextSegment,error:new Error(D)}}),this.logger_("chooseNextRequest_ - no sync info found using media sequence sync"),null}this.logger_(`chooseNextRequest_ mediaSequence syncInfo (${M.start} --> ${M.end})`),C=M.segmentIndex,w=M.partIndex,A=M.start}else{this.logger_("chooseNextRequest_ - fallback to a regular segment selection algorithm, based on a syncPoint.");const M=ft.getMediaInfoForTime({exactManifestTimings:this.exactManifestTimings,playlist:this.playlist_,currentTime:v,startingPartIndex:this.syncPoint_.partIndex,startingSegmentIndex:this.syncPoint_.segmentIndex,startTime:this.syncPoint_.time});C=M.segmentIndex,w=M.partIndex,A=M.startTime}l.getMediaInfoForTime=this.fetchAtBuffer_?`bufferedEnd ${v}`:`currentTime ${v}`,l.mediaIndex=C,l.startOfSegment=A,l.partIndex=w,this.logger_(`choose next request. Playlist switched and we have a sync point. Media Index: ${l.mediaIndex} `)}const c=a[l.mediaIndex];let g=c&&typeof l.partIndex=="number"&&c.parts&&c.parts[l.partIndex];if(!c||typeof l.partIndex=="number"&&!g)return null;typeof l.partIndex!="number"&&c.parts&&(l.partIndex=0,g=c.parts[0]);const m=this.vhs_.playlists&&this.vhs_.playlists.main&&this.vhs_.playlists.main.independentSegments||this.playlist_.independentSegments;if(!n&&g&&!m&&!g.independent)if(l.partIndex===0){const C=a[l.mediaIndex-1],w=C.parts&&C.parts.length&&C.parts[C.parts.length-1];w&&w.independent&&(l.mediaIndex-=1,l.partIndex=C.parts.length-1,l.independent="previous segment")}else c.parts[l.partIndex-1].independent&&(l.partIndex-=1,l.independent="previous part");const b=this.mediaSource_&&this.mediaSource_.readyState==="ended";return l.mediaIndex>=a.length-1&&b&&!this.seeking_()?null:(this.shouldForceTimestampOffsetAfterResync_&&(this.shouldForceTimestampOffsetAfterResync_=!1,l.forceTimestampOffset=!0,this.logger_("choose next request. Force timestamp offset after loader resync")),this.generateSegmentInfo_(l))}getSyncInfoFromMediaSequenceSync_(e){if(!this.mediaSequenceSync_)return null;const t=Math.max(e,this.mediaSequenceSync_.start);e!==t&&this.logger_(`getSyncInfoFromMediaSequenceSync_. Pulled target time from ${e} to ${t}`);const n=this.mediaSequenceSync_.getSyncInfoForTime(t);if(!n)return null;if(!n.isAppended)return n;const s=this.mediaSequenceSync_.getSyncInfoForTime(n.end);return s?(s.isAppended&&this.logger_("getSyncInfoFromMediaSequenceSync_: We encounter unexpected scenario where next media sequence sync info is also appended!"),s):null}generateSegmentInfo_(e){const{independent:t,playlist:n,mediaIndex:s,startOfSegment:r,isSyncRequest:a,partIndex:l,forceTimestampOffset:c,getMediaInfoForTime:g}=e,m=n.segments[s],b=typeof l=="number"&&m.parts[l],C={requestId:"segment-loader-"+Math.random(),uri:b&&b.resolvedUri||m.resolvedUri,mediaIndex:s,partIndex:b?l:null,isSyncRequest:a,startOfSegment:r,playlist:n,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:m.timeline,duration:b&&b.duration||m.duration,segment:m,part:b,byteLength:0,transmuxer:this.transmuxer_,getMediaInfoForTime:g,independent:t},w=typeof c<"u"?c:this.isPendingTimestampOffset_;C.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:m.timeline,currentTimeline:this.currentTimeline_,startOfSegment:r,buffered:this.buffered_(),overrideCheck:w});const A=Va(this.sourceUpdater_.audioBuffered());return typeof A=="number"&&(C.audioAppendStart=A-this.sourceUpdater_.audioTimestampOffset()),this.sourceUpdater_.videoBuffered().length&&(C.gopsToAlignWith=Pv(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_)),C}timestampOffsetForSegment_(e){return Bv(e)}earlyAbortWhenNeeded_(e){if(this.vhs_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH||Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)return;const t=this.currentTime_(),n=e.bandwidth,s=this.pendingSegment_.duration,r=ft.estimateSegmentRequestTime(s,n,this.playlist_,e.bytesReceived),a=rT(this.buffered_(),t,this.vhs_.tech_.playbackRate())-1;if(r<=a)return;const l=bv({main:this.vhs_.playlists.main,currentTime:t,bandwidth:n,duration:this.duration_(),segmentDuration:s,timeUntilRebuffer:a,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!l)return;const c=r-a-l.rebufferingImpact;let g=.5;a<=Xt&&(g=1),!(!l.playlist||l.playlist.uri===this.playlist_.uri||c<g)&&(this.bandwidth=l.playlist.attributes.BANDWIDTH*We.BANDWIDTH_VARIANCE+1,this.trigger("earlyabort"))}handleAbort_(e){this.logger_(`Aborting ${Zi(e)}`),this.mediaRequestsAborted+=1}handleProgress_(e,t){this.earlyAbortWhenNeeded_(t.stats),!this.checkForAbort_(t.requestId)&&this.trigger("progress")}handleTrackInfo_(e,t){const{hasAudio:n,hasVideo:s}=t,r={segmentInfo:Mi({type:this.loaderType_,segment:e}),trackInfo:{hasAudio:n,hasVideo:s}};this.trigger({type:"segmenttransmuxingtrackinfoavailable",metadata:r}),this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId)&&(this.checkForIllegalMediaSwitch(t)||(t=t||{},Ov(this.currentMediaInfo_,t)||(this.appendInitSegment_={audio:!0,video:!0},this.startingMediaInfo_=t,this.currentMediaInfo_=t,this.logger_("trackinfo update",t),this.trigger("trackinfo")),!this.checkForAbort_(e.requestId)&&(this.pendingSegment_.trackInfo=t,this.hasEnoughInfoToAppend_()?this.processCallQueue_():mi(this))))}handleTimingInfo_(e,t,n,s){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;const r=this.pendingSegment_,a=Td(t);r[a]=r[a]||{},r[a][n]=s,this.logger_(`timinginfo: ${t} - ${n} - ${s}`),this.hasEnoughInfoToAppend_()?this.processCallQueue_():mi(this)}handleCaptions_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(t.length===0){this.logger_("SegmentLoader received no captions from a caption event");return}if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.caption.push(this.handleCaptions_.bind(this,e,t));return}const n=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset(),s={};t.forEach(r=>{s[r.stream]=s[r.stream]||{startTime:1/0,captions:[],endTime:0};const a=s[r.stream];a.startTime=Math.min(a.startTime,r.startTime+n),a.endTime=Math.max(a.endTime,r.endTime+n),a.captions.push(r)}),Object.keys(s).forEach(r=>{const{startTime:a,endTime:l,captions:c}=s[r],g=this.inbandTextTracks_;this.logger_(`adding cues from ${a} -> ${l} for ${r}`),Sv(g,this.vhs_.tech_,r),ns(a,l,g[r]),Ev({captionArray:c,inbandTextTracks:g,timestampOffset:n})}),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}handleId3_(e,t,n){if(this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId)){if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.id3.push(this.handleId3_.bind(this,e,t,n));return}this.addMetadataToTextTrack(n,t,this.duration_())}}processMetadataQueue_(){this.metadataQueue_.id3.forEach(e=>e()),this.metadataQueue_.caption.forEach(e=>e()),this.metadataQueue_.id3=[],this.metadataQueue_.caption=[]}processCallQueue_(){const e=this.callQueue_;this.callQueue_=[],e.forEach(t=>t())}processLoadQueue_(){const e=this.loadQueue_;this.loadQueue_=[],e.forEach(t=>t())}hasEnoughInfoToLoad_(){if(this.loaderType_!=="audio")return!0;const e=this.pendingSegment_;return e?this.getCurrentMediaInfo_()?!mo({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}):!0:!1}getCurrentMediaInfo_(e=this.pendingSegment_){return e&&e.trackInfo||this.currentMediaInfo_}getMediaInfo_(e=this.pendingSegment_){return this.getCurrentMediaInfo_(e)||this.startingMediaInfo_}getPendingSegmentPlaylist(){return this.pendingSegment_?this.pendingSegment_.playlist:null}hasEnoughInfoToAppend_(){if(!this.sourceUpdater_.ready()||this.waitingOnRemove_||this.quotaExceededErrorRetryTimeout_)return!1;const e=this.pendingSegment_,t=this.getCurrentMediaInfo_();if(!e||!t)return!1;const{hasAudio:n,hasVideo:s,isMuxed:r}=t;return!(s&&!e.videoTimingInfo||n&&!this.audioDisabled_&&!r&&!e.audioTimingInfo||mo({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))}handleData_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(this.callQueue_.length||!this.hasEnoughInfoToAppend_()){mi(this),this.callQueue_.push(this.handleData_.bind(this,e,t));return}const n=this.pendingSegment_;if(this.setTimeMapping_(n.timeline),this.updateMediaSecondsLoaded_(n.part||n.segment),this.mediaSource_.readyState!=="closed"){if(e.map&&(e.map=this.initSegmentForMap(e.map,!0),n.segment.map=e.map),e.key&&this.segmentKey(e.key,!0),n.isFmp4=e.isFmp4,n.timingInfo=n.timingInfo||{},n.isFmp4)this.trigger("fmp4"),n.timingInfo.start=n[Td(t.type)].start;else{const s=this.getCurrentMediaInfo_(),r=this.loaderType_==="main"&&s&&s.hasVideo;let a;r&&(a=n.videoTimingInfo.start),n.timingInfo.start=this.trueSegmentStart_({currentStart:n.timingInfo.start,playlist:n.playlist,mediaIndex:n.mediaIndex,currentVideoTimestampOffset:this.sourceUpdater_.videoTimestampOffset(),useVideoTimingInfo:r,firstVideoFrameTimeForData:a,videoTimingInfo:n.videoTimingInfo,audioTimingInfo:n.audioTimingInfo})}if(this.updateAppendInitSegmentStatus(n,t.type),this.updateSourceBufferTimestampOffset_(n),n.isSyncRequest){this.updateTimingInfoEnd_(n),this.syncController_.saveSegmentTimingInfo({segmentInfo:n,shouldSaveTimelineMapping:this.loaderType_==="main"});const s=this.chooseNextRequest_();if(s.mediaIndex!==n.mediaIndex||s.partIndex!==n.partIndex){this.logger_("sync segment was incorrect, not appending");return}this.logger_("sync segment was correct, appending")}n.hasAppendedData_=!0,this.processMetadataQueue_(),this.appendData_(n,t)}}updateAppendInitSegmentStatus(e,t){this.loaderType_==="main"&&typeof e.timestampOffset=="number"&&!e.changedTimestampOffset&&(this.appendInitSegment_={audio:!0,video:!0}),this.playlistOfLastInitSegment_[t]!==e.playlist&&(this.appendInitSegment_[t]=!0)}getInitSegmentAndUpdateState_({type:e,initSegment:t,map:n,playlist:s}){if(n){const r=Cr(n);if(this.activeInitSegmentId_===r)return null;t=this.initSegmentForMap(n,!0).bytes,this.activeInitSegmentId_=r}return t&&this.appendInitSegment_[e]?(this.playlistOfLastInitSegment_[e]=s,this.appendInitSegment_[e]=!1,this.activeInitSegmentId_=null,t):null}handleQuotaExceededError_({segmentInfo:e,type:t,bytes:n},s){const r=this.sourceUpdater_.audioBuffered(),a=this.sourceUpdater_.videoBuffered();r.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the audio buffer: "+Ui(r).join(", ")),a.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: "+Ui(a).join(", "));const l=r.length?r.start(0):0,c=r.length?r.end(r.length-1):0,g=a.length?a.start(0):0,m=a.length?a.end(a.length-1):0;if(c-l<=Qn&&m-g<=Qn){this.logger_(`On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. Appended byte length: ${n.byteLength}, audio buffer: ${Ui(r).join(", ")}, video buffer: ${Ui(a).join(", ")}, `),this.error({message:"Quota exceeded error with append of a single segment of content",excludeUntil:1/0}),this.trigger("error");return}this.waitingOnRemove_=!0,this.callQueue_.push(this.appendToSourceBuffer_.bind(this,{segmentInfo:e,type:t,bytes:n}));const b=this.currentTime_()-Qn;this.logger_(`On QUOTA_EXCEEDED_ERR, removing audio/video from 0 to ${b}`),this.remove(0,b,()=>{this.logger_(`On QUOTA_EXCEEDED_ERR, retrying append in ${Qn}s`),this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=x.setTimeout(()=>{this.logger_("On QUOTA_EXCEEDED_ERR, re-processing call queue"),this.quotaExceededErrorRetryTimeout_=null,this.processCallQueue_()},Qn*1e3)},!0)}handleAppendError_({segmentInfo:e,type:t,bytes:n},s){if(s){if(s.code===rp){this.handleQuotaExceededError_({segmentInfo:e,type:t,bytes:n});return}this.logger_("Received non QUOTA_EXCEEDED_ERR on append",s),this.error({message:`${t} append of ${n.length}b failed for segment #${e.mediaIndex} in playlist ${e.playlist.id}`,metadata:{errorType:B.Error.StreamingFailedToAppendSegment}}),this.trigger("appenderror")}}appendToSourceBuffer_({segmentInfo:e,type:t,initSegment:n,data:s,bytes:r}){if(!r){const l=[s];let c=s.byteLength;n&&(l.unshift(n),c+=n.byteLength),r=vv({bytes:c,segments:l})}const a={segmentInfo:Mi({type:this.loaderType_,segment:e})};this.trigger({type:"segmentappendstart",metadata:a}),this.sourceUpdater_.appendBuffer({segmentInfo:e,type:t,bytes:r},this.handleAppendError_.bind(this,{segmentInfo:e,type:t,bytes:r}))}handleSegmentTimingInfo_(e,t,n){if(!this.pendingSegment_||t!==this.pendingSegment_.requestId)return;const s=this.pendingSegment_.segment,r=`${e}TimingInfo`;s[r]||(s[r]={}),s[r].transmuxerPrependedSeconds=n.prependedContentDuration||0,s[r].transmuxedPresentationStart=n.start.presentation,s[r].transmuxedDecodeStart=n.start.decode,s[r].transmuxedPresentationEnd=n.end.presentation,s[r].transmuxedDecodeEnd=n.end.decode,s[r].baseMediaDecodeTime=n.baseMediaDecodeTime}appendData_(e,t){const{type:n,data:s}=t;if(!s||!s.byteLength||n==="audio"&&this.audioDisabled_)return;const r=this.getInitSegmentAndUpdateState_({type:n,initSegment:t.initSegment,playlist:e.playlist,map:e.isFmp4?e.segment.map:null});this.appendToSourceBuffer_({segmentInfo:e,type:n,initSegment:r,data:s})}loadSegment_(e){if(this.state="WAITING",this.pendingSegment_=e,this.trimBackBuffer_(e),typeof e.timestampOffset=="number"&&this.transmuxer_&&this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),!this.hasEnoughInfoToLoad_()){mi(this),this.loadQueue_.push(()=>{const t=je({},e,{forceTimestampOffset:!0});je(e,this.generateSegmentInfo_(t)),this.isPendingTimestampOffset_=!1,this.updateTransmuxerAndRequestSegment_(e)});return}this.updateTransmuxerAndRequestSegment_(e)}updateTransmuxerAndRequestSegment_(e){this.shouldUpdateTransmuxerTimestampOffset_(e.timestampOffset)&&(this.gopBuffer_.length=0,e.gopsToAlignWith=[],this.timeMapping_=0,this.transmuxer_.postMessage({action:"reset"}),this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:e.timestampOffset}));const t=this.createSimplifiedSegmentObj_(e),n=this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex),s=this.mediaIndex!==null,r=e.timeline!==this.currentTimeline_&&e.timeline>0,a=n||s&&r;this.logger_(`Requesting
|
|
213
|
-
${
|
|
214
|
-
${Zi(e)}`),t.map&&!t.map.bytes&&(this.logger_("going to request init segment."),this.appendInitSegment_={video:!0,audio:!0}),e.abortRequests=pv({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:t,abortFn:this.handleAbort_.bind(this,e),progressFn:this.handleProgress_.bind(this),trackInfoFn:this.handleTrackInfo_.bind(this),timingInfoFn:this.handleTimingInfo_.bind(this),videoSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"video",e.requestId),audioSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"audio",e.requestId),captionsFn:this.handleCaptions_.bind(this),isEndOfTimeline:a,endedTimelineFn:()=>{this.logger_("received endedtimeline callback")},id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this),onTransmuxerLog:({message:l,level:c,stream:g})=>{this.logger_(`${Zi(e)} logged from transmuxer stream ${g} as a ${c}: ${l}`)},triggerSegmentEventFn:({type:l,segment:c,keyInfo:g,trackInfo:m,timingInfo:b})=>{const C={segmentInfo:Mi({segment:c})};g&&(C.keyInfo=g),m&&(C.trackInfo=m),b&&(C.timingInfo=b),this.trigger({type:l,metadata:C})}})}trimBackBuffer_(e){const t=Nv(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);t>0&&this.remove(0,t)}createSimplifiedSegmentObj_(e){const t=e.segment,n=e.part,s=e.segment.key||e.segment.map&&e.segment.map.key,r=e.segment.map&&!e.segment.map.bytes,a={resolvedUri:n?n.resolvedUri:t.resolvedUri,byterange:n?n.byterange:t.byterange,requestId:e.requestId,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,part:e.part,type:this.loaderType_,start:e.startOfSegment,duration:e.duration,isEncrypted:s,isMediaInitialization:r},l=e.playlist.segments[e.mediaIndex-1];if(l&&l.timeline===t.timeline&&(l.videoTimingInfo?a.baseStartTime=l.videoTimingInfo.transmuxedDecodeEnd:l.audioTimingInfo&&(a.baseStartTime=l.audioTimingInfo.transmuxedDecodeEnd)),t.key){const c=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);a.key=this.segmentKey(t.key),a.key.iv=c}return t.map&&(a.map=this.initSegmentForMap(t.map)),a}saveTransferStats_(e){this.mediaRequests+=1,e&&(this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime)}saveBandwidthRelatedStats_(e,t){if(this.pendingSegment_.byteLength=t.bytesReceived,e<tr){this.logger_(`Ignoring segment's bandwidth because its duration of ${e} is less than the min to record ${tr}`);return}const n={bandwidthInfo:{from:this.bandwidth,to:t.bandwidth}};this.trigger({type:"bandwidthupdated",metadata:n}),this.bandwidth=t.bandwidth,this.roundTrip=t.roundTripTime}handleTimeout_(){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger("bandwidthupdate"),this.trigger("timeout")}segmentRequestFinished_(e,t,n){if(this.callQueue_.length){this.callQueue_.push(this.segmentRequestFinished_.bind(this,e,t,n));return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_||t.requestId!==this.pendingSegment_.requestId)return;if(e){if(this.pendingSegment_=null,this.state="READY",e.code===Yt.ABORTED)return;if(this.pause(),e.code===Yt.TIMEOUT){this.handleTimeout_();return}this.mediaRequestsErrored+=1,this.error(e),this.trigger("error");return}const s=this.pendingSegment_;this.saveBandwidthRelatedStats_(s.duration,t.stats),s.endOfAllRequests=t.endOfAllRequests,n.gopInfo&&(this.gopBuffer_=Lv(this.gopBuffer_,n.gopInfo,this.safeAppend_)),this.state="APPENDING",this.trigger("appending"),this.waitForAppendsToComplete_(s)}setTimeMapping_(e){const t=this.syncController_.mappingForTimeline(e);t!==null&&(this.timeMapping_=t)}updateMediaSecondsLoaded_(e){typeof e.start=="number"&&typeof e.end=="number"?this.mediaSecondsLoaded+=e.end-e.start:this.mediaSecondsLoaded+=e.duration}shouldUpdateTransmuxerTimestampOffset_(e){return e===null?!1:this.loaderType_==="main"&&e!==this.sourceUpdater_.videoTimestampOffset()||!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset()}trueSegmentStart_({currentStart:e,playlist:t,mediaIndex:n,firstVideoFrameTimeForData:s,currentVideoTimestampOffset:r,useVideoTimingInfo:a,videoTimingInfo:l,audioTimingInfo:c}){if(typeof e<"u")return e;if(!a)return c.start;const g=t.segments[n-1];return n===0||!g||typeof g.start>"u"||g.end!==s+r?s:l.start}waitForAppendsToComplete_(e){const t=this.getCurrentMediaInfo_(e);if(!t){this.error({message:"No starting media returned, likely due to an unsupported media format.",playlistExclusionDuration:1/0}),this.trigger("error");return}const{hasAudio:n,hasVideo:s,isMuxed:r}=t,a=this.loaderType_==="main"&&s,l=!this.audioDisabled_&&n&&!r;if(e.waitingOnAppends=0,!e.hasAppendedData_){!e.timingInfo&&typeof e.timestampOffset=="number"&&(this.isPendingTimestampOffset_=!0),e.timingInfo={start:0},e.waitingOnAppends++,this.isPendingTimestampOffset_||(this.updateSourceBufferTimestampOffset_(e),this.processMetadataQueue_()),this.checkAppendsDone_(e);return}a&&e.waitingOnAppends++,l&&e.waitingOnAppends++,a&&this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e)),l&&this.sourceUpdater_.audioQueueCallback(this.checkAppendsDone_.bind(this,e))}checkAppendsDone_(e){this.checkForAbort_(e.requestId)||(e.waitingOnAppends--,e.waitingOnAppends===0&&this.handleAppendsDone_())}checkForIllegalMediaSwitch(e){const t=Uv(this.loaderType_,this.getCurrentMediaInfo_(),e);return t?(this.error({message:t,playlistExclusionDuration:1/0}),this.trigger("error"),!0):!1}updateSourceBufferTimestampOffset_(e){if(e.timestampOffset===null||typeof e.timingInfo.start!="number"||e.changedTimestampOffset||this.loaderType_!=="main")return;let t=!1;e.timestampOffset-=this.getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e.segment.videoTimingInfo,audioTimingInfo:e.segment.audioTimingInfo,timingInfo:e.timingInfo}),e.changedTimestampOffset=!0,e.timestampOffset!==this.sourceUpdater_.videoTimestampOffset()&&(this.sourceUpdater_.videoTimestampOffset(e.timestampOffset),t=!0),e.timestampOffset!==this.sourceUpdater_.audioTimestampOffset()&&(this.sourceUpdater_.audioTimestampOffset(e.timestampOffset),t=!0),t&&this.trigger("timestampoffset")}getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e,audioTimingInfo:t,timingInfo:n}){return this.useDtsForTimestampOffset_?e&&typeof e.transmuxedDecodeStart=="number"?e.transmuxedDecodeStart:t&&typeof t.transmuxedDecodeStart=="number"?t.transmuxedDecodeStart:n.start:n.start}updateTimingInfoEnd_(e){e.timingInfo=e.timingInfo||{};const t=this.getMediaInfo_(),n=this.loaderType_==="main"&&t&&t.hasVideo&&e.videoTimingInfo?e.videoTimingInfo:e.audioTimingInfo;n&&(e.timingInfo.end=typeof n.end=="number"?n.end:n.start+e.duration)}handleAppendsDone_(){if(this.pendingSegment_){const l={segmentInfo:Mi({type:this.loaderType_,segment:this.pendingSegment_})};this.trigger({type:"appendsdone",metadata:l})}if(!this.pendingSegment_){this.state="READY",this.paused()||this.monitorBuffer_();return}const e=this.pendingSegment_;e.part&&e.part.syncInfo?e.part.syncInfo.markAppended():e.segment.syncInfo&&e.segment.syncInfo.markAppended(),this.updateTimingInfoEnd_(e),this.shouldSaveSegmentTimingInfo_&&this.syncController_.saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:this.loaderType_==="main"});const t=qv(e,this.sourceType_);if(t&&(t.severity==="warn"?B.log.warn(t.message):this.logger_(t.message)),this.recordThroughput_(e),this.pendingSegment_=null,this.state="READY",e.isSyncRequest&&(this.trigger("syncinfoupdate"),!e.hasAppendedData_)){this.logger_(`Throwing away un-appended sync request ${Zi(e)}`);return}this.logger_(`Appended ${Zi(e)}`),this.addSegmentMetadataCue_(e),this.fetchAtBuffer_=!0,this.currentTimeline_!==e.timeline&&(this.timelineChangeController_.lastTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline}),this.loaderType_==="main"&&!this.audioDisabled_&&this.timelineChangeController_.lastTimelineChange({type:"audio",from:this.currentTimeline_,to:e.timeline})),this.currentTimeline_=e.timeline,this.trigger("syncinfoupdate");const n=e.segment,s=e.part,r=n.end&&this.currentTime_()-n.end>e.playlist.targetDuration*3,a=s&&s.end&&this.currentTime_()-s.end>e.playlist.partTargetDuration*3;if(r||a){this.logger_(`bad ${r?"segment":"part"} ${Zi(e)}`),this.resetEverything();return}this.mediaIndex!==null&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.mediaIndex=e.mediaIndex,this.partIndex=e.partIndex,this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex)&&this.endOfStream(),this.trigger("appended"),e.hasAppendedData_&&this.mediaAppends++,this.paused()||this.monitorBuffer_()}recordThroughput_(e){if(e.duration<tr){this.logger_(`Ignoring segment's throughput because its duration of ${e.duration} is less than the min to record ${tr}`);return}const t=this.throughput.rate,n=Date.now()-e.endOfAllRequests+1,s=Math.floor(e.byteLength/n*8*1e3);this.throughput.rate+=(s-t)/++this.throughput.count}addSegmentMetadataCue_(e){if(!this.segmentMetadataTrack_)return;const t=e.segment,n=t.start,s=t.end;if(!bd(n)||!bd(s))return;ns(n,s,this.segmentMetadataTrack_);const r=x.WebKitDataCue||x.VTTCue,a={custom:t.custom,dateTimeObject:t.dateTimeObject,dateTimeString:t.dateTimeString,programDateTime:t.programDateTime,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:n,end:s},l=JSON.stringify(a),c=new r(n,s,l);c.value=a,this.segmentMetadataTrack_.addCue(c)}}function ni(){}const Pp=function(i){return typeof i!="string"?i:i.replace(/./,e=>e.toUpperCase())},Vv=["video","audio"],_o=(i,e)=>{const t=e[`${i}Buffer`];return t&&t.updating||e.queuePending[i]},Hv=(i,e)=>{for(let t=0;t<e.length;t++){const n=e[t];if(n.type==="mediaSource")return null;if(n.type===i)return t}return null},hn=(i,e)=>{if(e.queue.length===0)return;let t=0,n=e.queue[t];if(n.type==="mediaSource"){!e.updating()&&e.mediaSource.readyState!=="closed"&&(e.queue.shift(),n.action(e),n.doneFn&&n.doneFn(),hn("audio",e),hn("video",e));return}if(i!=="mediaSource"&&!(!e.ready()||e.mediaSource.readyState==="closed"||_o(i,e))){if(n.type!==i){if(t=Hv(i,e.queue),t===null)return;n=e.queue[t]}if(e.queue.splice(t,1),e.queuePending[i]=n,n.action(i,e),!n.doneFn){e.queuePending[i]=null,hn(i,e);return}}},Lp=(i,e)=>{const t=e[`${i}Buffer`],n=Pp(i);t&&(t.removeEventListener("updateend",e[`on${n}UpdateEnd_`]),t.removeEventListener("error",e[`on${n}Error_`]),e.codecs[i]=null,e[`${i}Buffer`]=null)},zt=(i,e)=>i&&e&&Array.prototype.indexOf.call(i.sourceBuffers,e)!==-1,_t={appendBuffer:(i,e,t)=>(n,s)=>{const r=s[`${n}Buffer`];if(zt(s.mediaSource,r)){s.logger_(`Appending segment ${e.mediaIndex}'s ${i.length} bytes to ${n}Buffer`);try{r.appendBuffer(i)}catch(a){s.logger_(`Error with code ${a.code} `+(a.code===rp?"(QUOTA_EXCEEDED_ERR) ":"")+`when appending segment ${e.mediaIndex} to ${n}Buffer`),s.queuePending[n]=null,t(a)}}},remove:(i,e)=>(t,n)=>{const s=n[`${t}Buffer`];if(zt(n.mediaSource,s)){n.logger_(`Removing ${i} to ${e} from ${t}Buffer`);try{s.remove(i,e)}catch{n.logger_(`Remove ${i} to ${e} from ${t}Buffer failed`)}}},timestampOffset:i=>(e,t)=>{const n=t[`${e}Buffer`];zt(t.mediaSource,n)&&(t.logger_(`Setting ${e}timestampOffset to ${i}`),n.timestampOffset=i)},callback:i=>(e,t)=>{i()},endOfStream:i=>e=>{if(e.mediaSource.readyState==="open"){e.logger_(`Calling mediaSource endOfStream(${i||""})`);try{e.mediaSource.endOfStream(i)}catch(t){B.log.warn("Failed to call media source endOfStream",t)}}},duration:i=>e=>{e.logger_(`Setting mediaSource duration to ${i}`);try{e.mediaSource.duration=i}catch(t){B.log.warn("Failed to set media source duration",t)}},abort:()=>(i,e)=>{if(e.mediaSource.readyState!=="open")return;const t=e[`${i}Buffer`];if(zt(e.mediaSource,t)){e.logger_(`calling abort on ${i}Buffer`);try{t.abort()}catch(n){B.log.warn(`Failed to abort on ${i}Buffer`,n)}}},addSourceBuffer:(i,e)=>t=>{const n=Pp(i),s=cn(e);t.logger_(`Adding ${i}Buffer with codec ${e} to mediaSource`);const r=t.mediaSource.addSourceBuffer(s);r.addEventListener("updateend",t[`on${n}UpdateEnd_`]),r.addEventListener("error",t[`on${n}Error_`]),t.codecs[i]=e,t[`${i}Buffer`]=r},removeSourceBuffer:i=>e=>{const t=e[`${i}Buffer`];if(Lp(i,e),!!zt(e.mediaSource,t)){e.logger_(`Removing ${i}Buffer with codec ${e.codecs[i]} from mediaSource`);try{e.mediaSource.removeSourceBuffer(t)}catch(n){B.log.warn(`Failed to removeSourceBuffer ${i}Buffer`,n)}}},changeType:i=>(e,t)=>{const n=t[`${e}Buffer`],s=cn(i);if(!zt(t.mediaSource,n))return;const r=i.substring(0,i.indexOf(".")),a=t.codecs[e];if(a.substring(0,a.indexOf("."))===r)return;const l={codecsChangeInfo:{from:a,to:i}};t.trigger({type:"codecschange",metadata:l}),t.logger_(`changing ${e}Buffer codec from ${a} to ${i}`);try{n.changeType(s),t.codecs[e]=i}catch(c){l.errorType=B.Error.StreamingCodecsChangeError,l.error=c,c.metadata=l,t.error_=c,t.trigger("error"),B.log.warn(`Failed to changeType on ${e}Buffer`,c)}}},bt=({type:i,sourceUpdater:e,action:t,doneFn:n,name:s})=>{e.queue.push({type:i,action:t,doneFn:n,name:s}),hn(i,e)},Sd=(i,e)=>t=>{const n=e[`${i}Buffered`](),s=iT(n);if(e.logger_(`received "updateend" event for ${i} Source Buffer: `,s),e.queuePending[i]){const r=e.queuePending[i].doneFn;e.queuePending[i]=null,r&&r(e[`${i}Error_`])}hn(i,e)};class Dp extends B.EventTarget{constructor(e){super(),this.mediaSource=e,this.sourceopenListener_=()=>hn("mediaSource",this),this.mediaSource.addEventListener("sourceopen",this.sourceopenListener_),this.logger_=Lt("SourceUpdater"),this.audioTimestampOffset_=0,this.videoTimestampOffset_=0,this.queue=[],this.queuePending={audio:null,video:null},this.delayedAudioAppendQueue_=[],this.videoAppendQueued_=!1,this.codecs={},this.onVideoUpdateEnd_=Sd("video",this),this.onAudioUpdateEnd_=Sd("audio",this),this.onVideoError_=t=>{this.videoError_=t},this.onAudioError_=t=>{this.audioError_=t},this.createdSourceBuffers_=!1,this.initializedEme_=!1,this.triggeredReady_=!1}initializedEme(){this.initializedEme_=!0,this.triggerReady()}hasCreatedSourceBuffers(){return this.createdSourceBuffers_}hasInitializedAnyEme(){return this.initializedEme_}ready(){return this.hasCreatedSourceBuffers()&&this.hasInitializedAnyEme()}createSourceBuffers(e){this.hasCreatedSourceBuffers()||(this.addOrChangeSourceBuffers(e),this.createdSourceBuffers_=!0,this.trigger("createdsourcebuffers"),this.triggerReady())}triggerReady(){this.ready()&&!this.triggeredReady_&&(this.triggeredReady_=!0,this.trigger("ready"))}addSourceBuffer(e,t){bt({type:"mediaSource",sourceUpdater:this,action:_t.addSourceBuffer(e,t),name:"addSourceBuffer"})}abort(e){bt({type:e,sourceUpdater:this,action:_t.abort(e),name:"abort"})}removeSourceBuffer(e){if(!this.canRemoveSourceBuffer()){B.log.error("removeSourceBuffer is not supported!");return}bt({type:"mediaSource",sourceUpdater:this,action:_t.removeSourceBuffer(e),name:"removeSourceBuffer"})}canRemoveSourceBuffer(){return!B.browser.IS_FIREFOX&&x.MediaSource&&x.MediaSource.prototype&&typeof x.MediaSource.prototype.removeSourceBuffer=="function"}static canChangeType(){return x.SourceBuffer&&x.SourceBuffer.prototype&&typeof x.SourceBuffer.prototype.changeType=="function"}canChangeType(){return this.constructor.canChangeType()}changeType(e,t){if(!this.canChangeType()){B.log.error("changeType is not supported!");return}bt({type:e,sourceUpdater:this,action:_t.changeType(t),name:"changeType"})}addOrChangeSourceBuffers(e){if(!e||typeof e!="object"||Object.keys(e).length===0)throw new Error("Cannot addOrChangeSourceBuffers to undefined codecs");Object.keys(e).forEach(t=>{const n=e[t];if(!this.hasCreatedSourceBuffers())return this.addSourceBuffer(t,n);this.canChangeType()&&this.changeType(t,n)})}appendBuffer(e,t){const{segmentInfo:n,type:s,bytes:r}=e;if(this.processedAppend_=!0,s==="audio"&&this.videoBuffer&&!this.videoAppendQueued_){this.delayedAudioAppendQueue_.push([e,t]),this.logger_(`delayed audio append of ${r.length} until video append`);return}const a=t;if(bt({type:s,sourceUpdater:this,action:_t.appendBuffer(r,n||{mediaIndex:-1},a),doneFn:t,name:"appendBuffer"}),s==="video"){if(this.videoAppendQueued_=!0,!this.delayedAudioAppendQueue_.length)return;const l=this.delayedAudioAppendQueue_.slice();this.logger_(`queuing delayed audio ${l.length} appendBuffers`),this.delayedAudioAppendQueue_.length=0,l.forEach(c=>{this.appendBuffer.apply(this,c)})}}audioBuffered(){return zt(this.mediaSource,this.audioBuffer)&&this.audioBuffer.buffered?this.audioBuffer.buffered:tt()}videoBuffered(){return zt(this.mediaSource,this.videoBuffer)&&this.videoBuffer.buffered?this.videoBuffer.buffered:tt()}buffered(){const e=zt(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,t=zt(this.mediaSource,this.audioBuffer)?this.audioBuffer:null;return t&&!e?this.audioBuffered():e&&!t?this.videoBuffered():sT(this.audioBuffered(),this.videoBuffered())}setDuration(e,t=ni){bt({type:"mediaSource",sourceUpdater:this,action:_t.duration(e),name:"duration",doneFn:t})}endOfStream(e=null,t=ni){typeof e!="string"&&(e=void 0),bt({type:"mediaSource",sourceUpdater:this,action:_t.endOfStream(e),name:"endOfStream",doneFn:t})}removeAudio(e,t,n=ni){if(!this.audioBuffered().length||this.audioBuffered().end(0)===0){n();return}bt({type:"audio",sourceUpdater:this,action:_t.remove(e,t),doneFn:n,name:"remove"})}removeVideo(e,t,n=ni){if(!this.videoBuffered().length||this.videoBuffered().end(0)===0){n();return}bt({type:"video",sourceUpdater:this,action:_t.remove(e,t),doneFn:n,name:"remove"})}updating(){return!!(_o("audio",this)||_o("video",this))}audioTimestampOffset(e){return typeof e<"u"&&this.audioBuffer&&this.audioTimestampOffset_!==e&&(bt({type:"audio",sourceUpdater:this,action:_t.timestampOffset(e),name:"timestampOffset"}),this.audioTimestampOffset_=e),this.audioTimestampOffset_}videoTimestampOffset(e){return typeof e<"u"&&this.videoBuffer&&this.videoTimestampOffset_!==e&&(bt({type:"video",sourceUpdater:this,action:_t.timestampOffset(e),name:"timestampOffset"}),this.videoTimestampOffset_=e),this.videoTimestampOffset_}audioQueueCallback(e){this.audioBuffer&&bt({type:"audio",sourceUpdater:this,action:_t.callback(e),name:"callback"})}videoQueueCallback(e){this.videoBuffer&&bt({type:"video",sourceUpdater:this,action:_t.callback(e),name:"callback"})}dispose(){this.trigger("dispose"),Vv.forEach(e=>{this.abort(e),this.canRemoveSourceBuffer()?this.removeSourceBuffer(e):this[`${e}QueueCallback`](()=>Lp(e,this))}),this.videoAppendQueued_=!1,this.delayedAudioAppendQueue_.length=0,this.sourceopenListener_&&this.mediaSource.removeEventListener("sourceopen",this.sourceopenListener_),this.off()}}const Ed=i=>decodeURIComponent(escape(String.fromCharCode.apply(null,i))),zv=i=>{const e=new Uint8Array(i);return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")},wd=new Uint8Array(`
|
|
212
|
+
`,this.mediaSequenceSync_.diagnostics),this.mediaSequenceSync_&&this.mediaSequenceSync_.isReliable){const M=this.getSyncInfoFromMediaSequenceSync_(v);if(!M){const D="No sync info found while using media sequence sync";return this.error({message:D,metadata:{errorType:B.Error.StreamingFailedToSelectNextSegment,error:new Error(D)}}),this.logger_("chooseNextRequest_ - no sync info found using media sequence sync"),null}this.logger_(`chooseNextRequest_ mediaSequence syncInfo (${M.start} --> ${M.end})`),C=M.segmentIndex,w=M.partIndex,A=M.start}else{this.logger_("chooseNextRequest_ - fallback to a regular segment selection algorithm, based on a syncPoint.");const M=gt.getMediaInfoForTime({exactManifestTimings:this.exactManifestTimings,playlist:this.playlist_,currentTime:v,startingPartIndex:this.syncPoint_.partIndex,startingSegmentIndex:this.syncPoint_.segmentIndex,startTime:this.syncPoint_.time});C=M.segmentIndex,w=M.partIndex,A=M.startTime}l.getMediaInfoForTime=this.fetchAtBuffer_?`bufferedEnd ${v}`:`currentTime ${v}`,l.mediaIndex=C,l.startOfSegment=A,l.partIndex=w,this.logger_(`choose next request. Playlist switched and we have a sync point. Media Index: ${l.mediaIndex} `)}const c=a[l.mediaIndex];let f=c&&typeof l.partIndex=="number"&&c.parts&&c.parts[l.partIndex];if(!c||typeof l.partIndex=="number"&&!f)return null;typeof l.partIndex!="number"&&c.parts&&(l.partIndex=0,f=c.parts[0]);const m=this.vhs_.playlists&&this.vhs_.playlists.main&&this.vhs_.playlists.main.independentSegments||this.playlist_.independentSegments;if(!n&&f&&!m&&!f.independent)if(l.partIndex===0){const C=a[l.mediaIndex-1],w=C.parts&&C.parts.length&&C.parts[C.parts.length-1];w&&w.independent&&(l.mediaIndex-=1,l.partIndex=C.parts.length-1,l.independent="previous segment")}else c.parts[l.partIndex-1].independent&&(l.partIndex-=1,l.independent="previous part");const b=this.mediaSource_&&this.mediaSource_.readyState==="ended";return l.mediaIndex>=a.length-1&&b&&!this.seeking_()?null:(this.shouldForceTimestampOffsetAfterResync_&&(this.shouldForceTimestampOffsetAfterResync_=!1,l.forceTimestampOffset=!0,this.logger_("choose next request. Force timestamp offset after loader resync")),this.generateSegmentInfo_(l))}getSyncInfoFromMediaSequenceSync_(e){if(!this.mediaSequenceSync_)return null;const t=Math.max(e,this.mediaSequenceSync_.start);e!==t&&this.logger_(`getSyncInfoFromMediaSequenceSync_. Pulled target time from ${e} to ${t}`);const n=this.mediaSequenceSync_.getSyncInfoForTime(t);if(!n)return null;if(!n.isAppended)return n;const s=this.mediaSequenceSync_.getSyncInfoForTime(n.end);return s?(s.isAppended&&this.logger_("getSyncInfoFromMediaSequenceSync_: We encounter unexpected scenario where next media sequence sync info is also appended!"),s):null}generateSegmentInfo_(e){const{independent:t,playlist:n,mediaIndex:s,startOfSegment:r,isSyncRequest:a,partIndex:l,forceTimestampOffset:c,getMediaInfoForTime:f}=e,m=n.segments[s],b=typeof l=="number"&&m.parts[l],C={requestId:"segment-loader-"+Math.random(),uri:b&&b.resolvedUri||m.resolvedUri,mediaIndex:s,partIndex:b?l:null,isSyncRequest:a,startOfSegment:r,playlist:n,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:m.timeline,duration:b&&b.duration||m.duration,segment:m,part:b,byteLength:0,transmuxer:this.transmuxer_,getMediaInfoForTime:f,independent:t},w=typeof c<"u"?c:this.isPendingTimestampOffset_;C.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:m.timeline,currentTimeline:this.currentTimeline_,startOfSegment:r,buffered:this.buffered_(),overrideCheck:w});const A=qa(this.sourceUpdater_.audioBuffered());return typeof A=="number"&&(C.audioAppendStart=A-this.sourceUpdater_.audioTimestampOffset()),this.sourceUpdater_.videoBuffered().length&&(C.gopsToAlignWith=Tv(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_)),C}timestampOffsetForSegment_(e){return xv(e)}earlyAbortWhenNeeded_(e){if(this.vhs_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH||Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)return;const t=this.currentTime_(),n=e.bandwidth,s=this.pendingSegment_.duration,r=gt.estimateSegmentRequestTime(s,n,this.playlist_,e.bytesReceived),a=Kb(this.buffered_(),t,this.vhs_.tech_.playbackRate())-1;if(r<=a)return;const l=uv({main:this.vhs_.playlists.main,currentTime:t,bandwidth:n,duration:this.duration_(),segmentDuration:s,timeUntilRebuffer:a,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!l)return;const c=r-a-l.rebufferingImpact;let f=.5;a<=Xt&&(f=1),!(!l.playlist||l.playlist.uri===this.playlist_.uri||c<f)&&(this.bandwidth=l.playlist.attributes.BANDWIDTH*We.BANDWIDTH_VARIANCE+1,this.trigger("earlyabort"))}handleAbort_(e){this.logger_(`Aborting ${Zi(e)}`),this.mediaRequestsAborted+=1}handleProgress_(e,t){this.earlyAbortWhenNeeded_(t.stats),!this.checkForAbort_(t.requestId)&&this.trigger("progress")}handleTrackInfo_(e,t){const{hasAudio:n,hasVideo:s}=t,r={segmentInfo:Mi({type:this.loaderType_,segment:e}),trackInfo:{hasAudio:n,hasVideo:s}};this.trigger({type:"segmenttransmuxingtrackinfoavailable",metadata:r}),this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId)&&(this.checkForIllegalMediaSwitch(t)||(t=t||{},Ev(this.currentMediaInfo_,t)||(this.appendInitSegment_={audio:!0,video:!0},this.startingMediaInfo_=t,this.currentMediaInfo_=t,this.logger_("trackinfo update",t),this.trigger("trackinfo")),!this.checkForAbort_(e.requestId)&&(this.pendingSegment_.trackInfo=t,this.hasEnoughInfoToAppend_()?this.processCallQueue_():mi(this))))}handleTimingInfo_(e,t,n,s){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;const r=this.pendingSegment_,a=_d(t);r[a]=r[a]||{},r[a][n]=s,this.logger_(`timinginfo: ${t} - ${n} - ${s}`),this.hasEnoughInfoToAppend_()?this.processCallQueue_():mi(this)}handleCaptions_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(t.length===0){this.logger_("SegmentLoader received no captions from a caption event");return}if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.caption.push(this.handleCaptions_.bind(this,e,t));return}const n=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset(),s={};t.forEach(r=>{s[r.stream]=s[r.stream]||{startTime:1/0,captions:[],endTime:0};const a=s[r.stream];a.startTime=Math.min(a.startTime,r.startTime+n),a.endTime=Math.max(a.endTime,r.endTime+n),a.captions.push(r)}),Object.keys(s).forEach(r=>{const{startTime:a,endTime:l,captions:c}=s[r],f=this.inbandTextTracks_;this.logger_(`adding cues from ${a} -> ${l} for ${r}`),cv(f,this.vhs_.tech_,r),ss(a,l,f[r]),pv({captionArray:c,inbandTextTracks:f,timestampOffset:n})}),this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}handleId3_(e,t,n){if(this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId)){if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.id3.push(this.handleId3_.bind(this,e,t,n));return}this.addMetadataToTextTrack(n,t,this.duration_())}}processMetadataQueue_(){this.metadataQueue_.id3.forEach(e=>e()),this.metadataQueue_.caption.forEach(e=>e()),this.metadataQueue_.id3=[],this.metadataQueue_.caption=[]}processCallQueue_(){const e=this.callQueue_;this.callQueue_=[],e.forEach(t=>t())}processLoadQueue_(){const e=this.loadQueue_;this.loadQueue_=[],e.forEach(t=>t())}hasEnoughInfoToLoad_(){if(this.loaderType_!=="audio")return!0;const e=this.pendingSegment_;return e?this.getCurrentMediaInfo_()?!fo({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}):!0:!1}getCurrentMediaInfo_(e=this.pendingSegment_){return e&&e.trackInfo||this.currentMediaInfo_}getMediaInfo_(e=this.pendingSegment_){return this.getCurrentMediaInfo_(e)||this.startingMediaInfo_}getPendingSegmentPlaylist(){return this.pendingSegment_?this.pendingSegment_.playlist:null}hasEnoughInfoToAppend_(){if(!this.sourceUpdater_.ready()||this.waitingOnRemove_||this.quotaExceededErrorRetryTimeout_)return!1;const e=this.pendingSegment_,t=this.getCurrentMediaInfo_();if(!e||!t)return!1;const{hasAudio:n,hasVideo:s,isMuxed:r}=t;return!(s&&!e.videoTimingInfo||n&&!this.audioDisabled_&&!r&&!e.audioTimingInfo||fo({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))}handleData_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(this.callQueue_.length||!this.hasEnoughInfoToAppend_()){mi(this),this.callQueue_.push(this.handleData_.bind(this,e,t));return}const n=this.pendingSegment_;if(this.setTimeMapping_(n.timeline),this.updateMediaSecondsLoaded_(n.part||n.segment),this.mediaSource_.readyState!=="closed"){if(e.map&&(e.map=this.initSegmentForMap(e.map,!0),n.segment.map=e.map),e.key&&this.segmentKey(e.key,!0),n.isFmp4=e.isFmp4,n.timingInfo=n.timingInfo||{},n.isFmp4)this.trigger("fmp4"),n.timingInfo.start=n[_d(t.type)].start;else{const s=this.getCurrentMediaInfo_(),r=this.loaderType_==="main"&&s&&s.hasVideo;let a;r&&(a=n.videoTimingInfo.start),n.timingInfo.start=this.trueSegmentStart_({currentStart:n.timingInfo.start,playlist:n.playlist,mediaIndex:n.mediaIndex,currentVideoTimestampOffset:this.sourceUpdater_.videoTimestampOffset(),useVideoTimingInfo:r,firstVideoFrameTimeForData:a,videoTimingInfo:n.videoTimingInfo,audioTimingInfo:n.audioTimingInfo})}if(this.updateAppendInitSegmentStatus(n,t.type),this.updateSourceBufferTimestampOffset_(n),n.isSyncRequest){this.updateTimingInfoEnd_(n),this.syncController_.saveSegmentTimingInfo({segmentInfo:n,shouldSaveTimelineMapping:this.loaderType_==="main"});const s=this.chooseNextRequest_();if(s.mediaIndex!==n.mediaIndex||s.partIndex!==n.partIndex){this.logger_("sync segment was incorrect, not appending");return}this.logger_("sync segment was correct, appending")}n.hasAppendedData_=!0,this.processMetadataQueue_(),this.appendData_(n,t)}}updateAppendInitSegmentStatus(e,t){this.loaderType_==="main"&&typeof e.timestampOffset=="number"&&!e.changedTimestampOffset&&(this.appendInitSegment_={audio:!0,video:!0}),this.playlistOfLastInitSegment_[t]!==e.playlist&&(this.appendInitSegment_[t]=!0)}getInitSegmentAndUpdateState_({type:e,initSegment:t,map:n,playlist:s}){if(n){const r=Cr(n);if(this.activeInitSegmentId_===r)return null;t=this.initSegmentForMap(n,!0).bytes,this.activeInitSegmentId_=r}return t&&this.appendInitSegment_[e]?(this.playlistOfLastInitSegment_[e]=s,this.appendInitSegment_[e]=!1,this.activeInitSegmentId_=null,t):null}handleQuotaExceededError_({segmentInfo:e,type:t,bytes:n},s){const r=this.sourceUpdater_.audioBuffered(),a=this.sourceUpdater_.videoBuffered();r.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the audio buffer: "+Ui(r).join(", ")),a.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: "+Ui(a).join(", "));const l=r.length?r.start(0):0,c=r.length?r.end(r.length-1):0,f=a.length?a.start(0):0,m=a.length?a.end(a.length-1):0;if(c-l<=Jn&&m-f<=Jn){this.logger_(`On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. Appended byte length: ${n.byteLength}, audio buffer: ${Ui(r).join(", ")}, video buffer: ${Ui(a).join(", ")}, `),this.error({message:"Quota exceeded error with append of a single segment of content",excludeUntil:1/0}),this.trigger("error");return}this.waitingOnRemove_=!0,this.callQueue_.push(this.appendToSourceBuffer_.bind(this,{segmentInfo:e,type:t,bytes:n}));const b=this.currentTime_()-Jn;this.logger_(`On QUOTA_EXCEEDED_ERR, removing audio/video from 0 to ${b}`),this.remove(0,b,()=>{this.logger_(`On QUOTA_EXCEEDED_ERR, retrying append in ${Jn}s`),this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=x.setTimeout(()=>{this.logger_("On QUOTA_EXCEEDED_ERR, re-processing call queue"),this.quotaExceededErrorRetryTimeout_=null,this.processCallQueue_()},Jn*1e3)},!0)}handleAppendError_({segmentInfo:e,type:t,bytes:n},s){if(s){if(s.code===ip){this.handleQuotaExceededError_({segmentInfo:e,type:t,bytes:n});return}this.logger_("Received non QUOTA_EXCEEDED_ERR on append",s),this.error({message:`${t} append of ${n.length}b failed for segment #${e.mediaIndex} in playlist ${e.playlist.id}`,metadata:{errorType:B.Error.StreamingFailedToAppendSegment}}),this.trigger("appenderror")}}appendToSourceBuffer_({segmentInfo:e,type:t,initSegment:n,data:s,bytes:r}){if(!r){const l=[s];let c=s.byteLength;n&&(l.unshift(n),c+=n.byteLength),r=hv({bytes:c,segments:l})}const a={segmentInfo:Mi({type:this.loaderType_,segment:e})};this.trigger({type:"segmentappendstart",metadata:a}),this.sourceUpdater_.appendBuffer({segmentInfo:e,type:t,bytes:r},this.handleAppendError_.bind(this,{segmentInfo:e,type:t,bytes:r}))}handleSegmentTimingInfo_(e,t,n){if(!this.pendingSegment_||t!==this.pendingSegment_.requestId)return;const s=this.pendingSegment_.segment,r=`${e}TimingInfo`;s[r]||(s[r]={}),s[r].transmuxerPrependedSeconds=n.prependedContentDuration||0,s[r].transmuxedPresentationStart=n.start.presentation,s[r].transmuxedDecodeStart=n.start.decode,s[r].transmuxedPresentationEnd=n.end.presentation,s[r].transmuxedDecodeEnd=n.end.decode,s[r].baseMediaDecodeTime=n.baseMediaDecodeTime}appendData_(e,t){const{type:n,data:s}=t;if(!s||!s.byteLength||n==="audio"&&this.audioDisabled_)return;const r=this.getInitSegmentAndUpdateState_({type:n,initSegment:t.initSegment,playlist:e.playlist,map:e.isFmp4?e.segment.map:null});this.appendToSourceBuffer_({segmentInfo:e,type:n,initSegment:r,data:s})}loadSegment_(e){if(this.state="WAITING",this.pendingSegment_=e,this.trimBackBuffer_(e),typeof e.timestampOffset=="number"&&this.transmuxer_&&this.transmuxer_.postMessage({action:"clearAllMp4Captions"}),!this.hasEnoughInfoToLoad_()){mi(this),this.loadQueue_.push(()=>{const t=je({},e,{forceTimestampOffset:!0});je(e,this.generateSegmentInfo_(t)),this.isPendingTimestampOffset_=!1,this.updateTransmuxerAndRequestSegment_(e)});return}this.updateTransmuxerAndRequestSegment_(e)}updateTransmuxerAndRequestSegment_(e){this.shouldUpdateTransmuxerTimestampOffset_(e.timestampOffset)&&(this.gopBuffer_.length=0,e.gopsToAlignWith=[],this.timeMapping_=0,this.transmuxer_.postMessage({action:"reset"}),this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:e.timestampOffset}));const t=this.createSimplifiedSegmentObj_(e),n=this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex),s=this.mediaIndex!==null,r=e.timeline!==this.currentTimeline_&&e.timeline>0,a=n||s&&r;this.logger_(`Requesting
|
|
213
|
+
${Cp(e.uri)}
|
|
214
|
+
${Zi(e)}`),t.map&&!t.map.bytes&&(this.logger_("going to request init segment."),this.appendInitSegment_={video:!0,audio:!0}),e.abortRequests=nv({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:t,abortFn:this.handleAbort_.bind(this,e),progressFn:this.handleProgress_.bind(this),trackInfoFn:this.handleTrackInfo_.bind(this),timingInfoFn:this.handleTimingInfo_.bind(this),videoSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"video",e.requestId),audioSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"audio",e.requestId),captionsFn:this.handleCaptions_.bind(this),isEndOfTimeline:a,endedTimelineFn:()=>{this.logger_("received endedtimeline callback")},id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this),onTransmuxerLog:({message:l,level:c,stream:f})=>{this.logger_(`${Zi(e)} logged from transmuxer stream ${f} as a ${c}: ${l}`)},triggerSegmentEventFn:({type:l,segment:c,keyInfo:f,trackInfo:m,timingInfo:b})=>{const C={segmentInfo:Mi({segment:c})};f&&(C.keyInfo=f),m&&(C.trackInfo=m),b&&(C.timingInfo=b),this.trigger({type:l,metadata:C})}})}trimBackBuffer_(e){const t=Iv(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);t>0&&this.remove(0,t)}createSimplifiedSegmentObj_(e){const t=e.segment,n=e.part,s=e.segment.key||e.segment.map&&e.segment.map.key,r=e.segment.map&&!e.segment.map.bytes,a={resolvedUri:n?n.resolvedUri:t.resolvedUri,byterange:n?n.byterange:t.byterange,requestId:e.requestId,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,part:e.part,type:this.loaderType_,start:e.startOfSegment,duration:e.duration,isEncrypted:s,isMediaInitialization:r},l=e.playlist.segments[e.mediaIndex-1];if(l&&l.timeline===t.timeline&&(l.videoTimingInfo?a.baseStartTime=l.videoTimingInfo.transmuxedDecodeEnd:l.audioTimingInfo&&(a.baseStartTime=l.audioTimingInfo.transmuxedDecodeEnd)),t.key){const c=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);a.key=this.segmentKey(t.key),a.key.iv=c}return t.map&&(a.map=this.initSegmentForMap(t.map)),a}saveTransferStats_(e){this.mediaRequests+=1,e&&(this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime)}saveBandwidthRelatedStats_(e,t){if(this.pendingSegment_.byteLength=t.bytesReceived,e<ir){this.logger_(`Ignoring segment's bandwidth because its duration of ${e} is less than the min to record ${ir}`);return}const n={bandwidthInfo:{from:this.bandwidth,to:t.bandwidth}};this.trigger({type:"bandwidthupdated",metadata:n}),this.bandwidth=t.bandwidth,this.roundTrip=t.roundTripTime}handleTimeout_(){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger("bandwidthupdate"),this.trigger("timeout")}segmentRequestFinished_(e,t,n){if(this.callQueue_.length){this.callQueue_.push(this.segmentRequestFinished_.bind(this,e,t,n));return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_||t.requestId!==this.pendingSegment_.requestId)return;if(e){if(this.pendingSegment_=null,this.state="READY",e.code===Yt.ABORTED)return;if(this.pause(),e.code===Yt.TIMEOUT){this.handleTimeout_();return}this.mediaRequestsErrored+=1,this.error(e),this.trigger("error");return}const s=this.pendingSegment_;this.saveBandwidthRelatedStats_(s.duration,t.stats),s.endOfAllRequests=t.endOfAllRequests,n.gopInfo&&(this.gopBuffer_=vv(this.gopBuffer_,n.gopInfo,this.safeAppend_)),this.state="APPENDING",this.trigger("appending"),this.waitForAppendsToComplete_(s)}setTimeMapping_(e){const t=this.syncController_.mappingForTimeline(e);t!==null&&(this.timeMapping_=t)}updateMediaSecondsLoaded_(e){typeof e.start=="number"&&typeof e.end=="number"?this.mediaSecondsLoaded+=e.end-e.start:this.mediaSecondsLoaded+=e.duration}shouldUpdateTransmuxerTimestampOffset_(e){return e===null?!1:this.loaderType_==="main"&&e!==this.sourceUpdater_.videoTimestampOffset()||!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset()}trueSegmentStart_({currentStart:e,playlist:t,mediaIndex:n,firstVideoFrameTimeForData:s,currentVideoTimestampOffset:r,useVideoTimingInfo:a,videoTimingInfo:l,audioTimingInfo:c}){if(typeof e<"u")return e;if(!a)return c.start;const f=t.segments[n-1];return n===0||!f||typeof f.start>"u"||f.end!==s+r?s:l.start}waitForAppendsToComplete_(e){const t=this.getCurrentMediaInfo_(e);if(!t){this.error({message:"No starting media returned, likely due to an unsupported media format.",playlistExclusionDuration:1/0}),this.trigger("error");return}const{hasAudio:n,hasVideo:s,isMuxed:r}=t,a=this.loaderType_==="main"&&s,l=!this.audioDisabled_&&n&&!r;if(e.waitingOnAppends=0,!e.hasAppendedData_){!e.timingInfo&&typeof e.timestampOffset=="number"&&(this.isPendingTimestampOffset_=!0),e.timingInfo={start:0},e.waitingOnAppends++,this.isPendingTimestampOffset_||(this.updateSourceBufferTimestampOffset_(e),this.processMetadataQueue_()),this.checkAppendsDone_(e);return}a&&e.waitingOnAppends++,l&&e.waitingOnAppends++,a&&this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e)),l&&this.sourceUpdater_.audioQueueCallback(this.checkAppendsDone_.bind(this,e))}checkAppendsDone_(e){this.checkForAbort_(e.requestId)||(e.waitingOnAppends--,e.waitingOnAppends===0&&this.handleAppendsDone_())}checkForIllegalMediaSwitch(e){const t=Cv(this.loaderType_,this.getCurrentMediaInfo_(),e);return t?(this.error({message:t,playlistExclusionDuration:1/0}),this.trigger("error"),!0):!1}updateSourceBufferTimestampOffset_(e){if(e.timestampOffset===null||typeof e.timingInfo.start!="number"||e.changedTimestampOffset||this.loaderType_!=="main")return;let t=!1;e.timestampOffset-=this.getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e.segment.videoTimingInfo,audioTimingInfo:e.segment.audioTimingInfo,timingInfo:e.timingInfo}),e.changedTimestampOffset=!0,e.timestampOffset!==this.sourceUpdater_.videoTimestampOffset()&&(this.sourceUpdater_.videoTimestampOffset(e.timestampOffset),t=!0),e.timestampOffset!==this.sourceUpdater_.audioTimestampOffset()&&(this.sourceUpdater_.audioTimestampOffset(e.timestampOffset),t=!0),t&&this.trigger("timestampoffset")}getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e,audioTimingInfo:t,timingInfo:n}){return this.useDtsForTimestampOffset_?e&&typeof e.transmuxedDecodeStart=="number"?e.transmuxedDecodeStart:t&&typeof t.transmuxedDecodeStart=="number"?t.transmuxedDecodeStart:n.start:n.start}updateTimingInfoEnd_(e){e.timingInfo=e.timingInfo||{};const t=this.getMediaInfo_(),n=this.loaderType_==="main"&&t&&t.hasVideo&&e.videoTimingInfo?e.videoTimingInfo:e.audioTimingInfo;n&&(e.timingInfo.end=typeof n.end=="number"?n.end:n.start+e.duration)}handleAppendsDone_(){if(this.pendingSegment_){const l={segmentInfo:Mi({type:this.loaderType_,segment:this.pendingSegment_})};this.trigger({type:"appendsdone",metadata:l})}if(!this.pendingSegment_){this.state="READY",this.paused()||this.monitorBuffer_();return}const e=this.pendingSegment_;e.part&&e.part.syncInfo?e.part.syncInfo.markAppended():e.segment.syncInfo&&e.segment.syncInfo.markAppended(),this.updateTimingInfoEnd_(e),this.shouldSaveSegmentTimingInfo_&&this.syncController_.saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:this.loaderType_==="main"});const t=Dv(e,this.sourceType_);if(t&&(t.severity==="warn"?B.log.warn(t.message):this.logger_(t.message)),this.recordThroughput_(e),this.pendingSegment_=null,this.state="READY",e.isSyncRequest&&(this.trigger("syncinfoupdate"),!e.hasAppendedData_)){this.logger_(`Throwing away un-appended sync request ${Zi(e)}`);return}this.logger_(`Appended ${Zi(e)}`),this.addSegmentMetadataCue_(e),this.fetchAtBuffer_=!0,this.currentTimeline_!==e.timeline&&(this.timelineChangeController_.lastTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline}),this.loaderType_==="main"&&!this.audioDisabled_&&this.timelineChangeController_.lastTimelineChange({type:"audio",from:this.currentTimeline_,to:e.timeline})),this.currentTimeline_=e.timeline,this.trigger("syncinfoupdate");const n=e.segment,s=e.part,r=n.end&&this.currentTime_()-n.end>e.playlist.targetDuration*3,a=s&&s.end&&this.currentTime_()-s.end>e.playlist.partTargetDuration*3;if(r||a){this.logger_(`bad ${r?"segment":"part"} ${Zi(e)}`),this.resetEverything();return}this.mediaIndex!==null&&this.trigger("bandwidthupdate"),this.trigger("progress"),this.mediaIndex=e.mediaIndex,this.partIndex=e.partIndex,this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex)&&this.endOfStream(),this.trigger("appended"),e.hasAppendedData_&&this.mediaAppends++,this.paused()||this.monitorBuffer_()}recordThroughput_(e){if(e.duration<ir){this.logger_(`Ignoring segment's throughput because its duration of ${e.duration} is less than the min to record ${ir}`);return}const t=this.throughput.rate,n=Date.now()-e.endOfAllRequests+1,s=Math.floor(e.byteLength/n*8*1e3);this.throughput.rate+=(s-t)/++this.throughput.count}addSegmentMetadataCue_(e){if(!this.segmentMetadataTrack_)return;const t=e.segment,n=t.start,s=t.end;if(!yd(n)||!yd(s))return;ss(n,s,this.segmentMetadataTrack_);const r=x.WebKitDataCue||x.VTTCue,a={custom:t.custom,dateTimeObject:t.dateTimeObject,dateTimeString:t.dateTimeString,programDateTime:t.programDateTime,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:n,end:s},l=JSON.stringify(a),c=new r(n,s,l);c.value=a,this.segmentMetadataTrack_.addCue(c)}}function ni(){}const Ip=function(i){return typeof i!="string"?i:i.replace(/./,e=>e.toUpperCase())},Ov=["video","audio"],yo=(i,e)=>{const t=e[`${i}Buffer`];return t&&t.updating||e.queuePending[i]},Mv=(i,e)=>{for(let t=0;t<e.length;t++){const n=e[t];if(n.type==="mediaSource")return null;if(n.type===i)return t}return null},hn=(i,e)=>{if(e.queue.length===0)return;let t=0,n=e.queue[t];if(n.type==="mediaSource"){!e.updating()&&e.mediaSource.readyState!=="closed"&&(e.queue.shift(),n.action(e),n.doneFn&&n.doneFn(),hn("audio",e),hn("video",e));return}if(i!=="mediaSource"&&!(!e.ready()||e.mediaSource.readyState==="closed"||yo(i,e))){if(n.type!==i){if(t=Mv(i,e.queue),t===null)return;n=e.queue[t]}if(e.queue.splice(t,1),e.queuePending[i]=n,n.action(i,e),!n.doneFn){e.queuePending[i]=null,hn(i,e);return}}},xp=(i,e)=>{const t=e[`${i}Buffer`],n=Ip(i);t&&(t.removeEventListener("updateend",e[`on${n}UpdateEnd_`]),t.removeEventListener("error",e[`on${n}Error_`]),e.codecs[i]=null,e[`${i}Buffer`]=null)},zt=(i,e)=>i&&e&&Array.prototype.indexOf.call(i.sourceBuffers,e)!==-1,_t={appendBuffer:(i,e,t)=>(n,s)=>{const r=s[`${n}Buffer`];if(zt(s.mediaSource,r)){s.logger_(`Appending segment ${e.mediaIndex}'s ${i.length} bytes to ${n}Buffer`);try{r.appendBuffer(i)}catch(a){s.logger_(`Error with code ${a.code} `+(a.code===ip?"(QUOTA_EXCEEDED_ERR) ":"")+`when appending segment ${e.mediaIndex} to ${n}Buffer`),s.queuePending[n]=null,t(a)}}},remove:(i,e)=>(t,n)=>{const s=n[`${t}Buffer`];if(zt(n.mediaSource,s)){n.logger_(`Removing ${i} to ${e} from ${t}Buffer`);try{s.remove(i,e)}catch{n.logger_(`Remove ${i} to ${e} from ${t}Buffer failed`)}}},timestampOffset:i=>(e,t)=>{const n=t[`${e}Buffer`];zt(t.mediaSource,n)&&(t.logger_(`Setting ${e}timestampOffset to ${i}`),n.timestampOffset=i)},callback:i=>(e,t)=>{i()},endOfStream:i=>e=>{if(e.mediaSource.readyState==="open"){e.logger_(`Calling mediaSource endOfStream(${i||""})`);try{e.mediaSource.endOfStream(i)}catch(t){B.log.warn("Failed to call media source endOfStream",t)}}},duration:i=>e=>{e.logger_(`Setting mediaSource duration to ${i}`);try{e.mediaSource.duration=i}catch(t){B.log.warn("Failed to set media source duration",t)}},abort:()=>(i,e)=>{if(e.mediaSource.readyState!=="open")return;const t=e[`${i}Buffer`];if(zt(e.mediaSource,t)){e.logger_(`calling abort on ${i}Buffer`);try{t.abort()}catch(n){B.log.warn(`Failed to abort on ${i}Buffer`,n)}}},addSourceBuffer:(i,e)=>t=>{const n=Ip(i),s=cn(e);t.logger_(`Adding ${i}Buffer with codec ${e} to mediaSource`);const r=t.mediaSource.addSourceBuffer(s);r.addEventListener("updateend",t[`on${n}UpdateEnd_`]),r.addEventListener("error",t[`on${n}Error_`]),t.codecs[i]=e,t[`${i}Buffer`]=r},removeSourceBuffer:i=>e=>{const t=e[`${i}Buffer`];if(xp(i,e),!!zt(e.mediaSource,t)){e.logger_(`Removing ${i}Buffer with codec ${e.codecs[i]} from mediaSource`);try{e.mediaSource.removeSourceBuffer(t)}catch(n){B.log.warn(`Failed to removeSourceBuffer ${i}Buffer`,n)}}},changeType:i=>(e,t)=>{const n=t[`${e}Buffer`],s=cn(i);if(!zt(t.mediaSource,n))return;const r=i.substring(0,i.indexOf(".")),a=t.codecs[e];if(a.substring(0,a.indexOf("."))===r)return;const l={codecsChangeInfo:{from:a,to:i}};t.trigger({type:"codecschange",metadata:l}),t.logger_(`changing ${e}Buffer codec from ${a} to ${i}`);try{n.changeType(s),t.codecs[e]=i}catch(c){l.errorType=B.Error.StreamingCodecsChangeError,l.error=c,c.metadata=l,t.error_=c,t.trigger("error"),B.log.warn(`Failed to changeType on ${e}Buffer`,c)}}},bt=({type:i,sourceUpdater:e,action:t,doneFn:n,name:s})=>{e.queue.push({type:i,action:t,doneFn:n,name:s}),hn(i,e)},Td=(i,e)=>t=>{const n=e[`${i}Buffered`](),s=Wb(n);if(e.logger_(`received "updateend" event for ${i} Source Buffer: `,s),e.queuePending[i]){const r=e.queuePending[i].doneFn;e.queuePending[i]=null,r&&r(e[`${i}Error_`])}hn(i,e)};class Ap extends B.EventTarget{constructor(e){super(),this.mediaSource=e,this.sourceopenListener_=()=>hn("mediaSource",this),this.mediaSource.addEventListener("sourceopen",this.sourceopenListener_),this.logger_=Lt("SourceUpdater"),this.audioTimestampOffset_=0,this.videoTimestampOffset_=0,this.queue=[],this.queuePending={audio:null,video:null},this.delayedAudioAppendQueue_=[],this.videoAppendQueued_=!1,this.codecs={},this.onVideoUpdateEnd_=Td("video",this),this.onAudioUpdateEnd_=Td("audio",this),this.onVideoError_=t=>{this.videoError_=t},this.onAudioError_=t=>{this.audioError_=t},this.createdSourceBuffers_=!1,this.initializedEme_=!1,this.triggeredReady_=!1}initializedEme(){this.initializedEme_=!0,this.triggerReady()}hasCreatedSourceBuffers(){return this.createdSourceBuffers_}hasInitializedAnyEme(){return this.initializedEme_}ready(){return this.hasCreatedSourceBuffers()&&this.hasInitializedAnyEme()}createSourceBuffers(e){this.hasCreatedSourceBuffers()||(this.addOrChangeSourceBuffers(e),this.createdSourceBuffers_=!0,this.trigger("createdsourcebuffers"),this.triggerReady())}triggerReady(){this.ready()&&!this.triggeredReady_&&(this.triggeredReady_=!0,this.trigger("ready"))}addSourceBuffer(e,t){bt({type:"mediaSource",sourceUpdater:this,action:_t.addSourceBuffer(e,t),name:"addSourceBuffer"})}abort(e){bt({type:e,sourceUpdater:this,action:_t.abort(e),name:"abort"})}removeSourceBuffer(e){if(!this.canRemoveSourceBuffer()){B.log.error("removeSourceBuffer is not supported!");return}bt({type:"mediaSource",sourceUpdater:this,action:_t.removeSourceBuffer(e),name:"removeSourceBuffer"})}canRemoveSourceBuffer(){return!B.browser.IS_FIREFOX&&x.MediaSource&&x.MediaSource.prototype&&typeof x.MediaSource.prototype.removeSourceBuffer=="function"}static canChangeType(){return x.SourceBuffer&&x.SourceBuffer.prototype&&typeof x.SourceBuffer.prototype.changeType=="function"}canChangeType(){return this.constructor.canChangeType()}changeType(e,t){if(!this.canChangeType()){B.log.error("changeType is not supported!");return}bt({type:e,sourceUpdater:this,action:_t.changeType(t),name:"changeType"})}addOrChangeSourceBuffers(e){if(!e||typeof e!="object"||Object.keys(e).length===0)throw new Error("Cannot addOrChangeSourceBuffers to undefined codecs");Object.keys(e).forEach(t=>{const n=e[t];if(!this.hasCreatedSourceBuffers())return this.addSourceBuffer(t,n);this.canChangeType()&&this.changeType(t,n)})}appendBuffer(e,t){const{segmentInfo:n,type:s,bytes:r}=e;if(this.processedAppend_=!0,s==="audio"&&this.videoBuffer&&!this.videoAppendQueued_){this.delayedAudioAppendQueue_.push([e,t]),this.logger_(`delayed audio append of ${r.length} until video append`);return}const a=t;if(bt({type:s,sourceUpdater:this,action:_t.appendBuffer(r,n||{mediaIndex:-1},a),doneFn:t,name:"appendBuffer"}),s==="video"){if(this.videoAppendQueued_=!0,!this.delayedAudioAppendQueue_.length)return;const l=this.delayedAudioAppendQueue_.slice();this.logger_(`queuing delayed audio ${l.length} appendBuffers`),this.delayedAudioAppendQueue_.length=0,l.forEach(c=>{this.appendBuffer.apply(this,c)})}}audioBuffered(){return zt(this.mediaSource,this.audioBuffer)&&this.audioBuffer.buffered?this.audioBuffer.buffered:tt()}videoBuffered(){return zt(this.mediaSource,this.videoBuffer)&&this.videoBuffer.buffered?this.videoBuffer.buffered:tt()}buffered(){const e=zt(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,t=zt(this.mediaSource,this.audioBuffer)?this.audioBuffer:null;return t&&!e?this.audioBuffered():e&&!t?this.videoBuffered():Xb(this.audioBuffered(),this.videoBuffered())}setDuration(e,t=ni){bt({type:"mediaSource",sourceUpdater:this,action:_t.duration(e),name:"duration",doneFn:t})}endOfStream(e=null,t=ni){typeof e!="string"&&(e=void 0),bt({type:"mediaSource",sourceUpdater:this,action:_t.endOfStream(e),name:"endOfStream",doneFn:t})}removeAudio(e,t,n=ni){if(!this.audioBuffered().length||this.audioBuffered().end(0)===0){n();return}bt({type:"audio",sourceUpdater:this,action:_t.remove(e,t),doneFn:n,name:"remove"})}removeVideo(e,t,n=ni){if(!this.videoBuffered().length||this.videoBuffered().end(0)===0){n();return}bt({type:"video",sourceUpdater:this,action:_t.remove(e,t),doneFn:n,name:"remove"})}updating(){return!!(yo("audio",this)||yo("video",this))}audioTimestampOffset(e){return typeof e<"u"&&this.audioBuffer&&this.audioTimestampOffset_!==e&&(bt({type:"audio",sourceUpdater:this,action:_t.timestampOffset(e),name:"timestampOffset"}),this.audioTimestampOffset_=e),this.audioTimestampOffset_}videoTimestampOffset(e){return typeof e<"u"&&this.videoBuffer&&this.videoTimestampOffset_!==e&&(bt({type:"video",sourceUpdater:this,action:_t.timestampOffset(e),name:"timestampOffset"}),this.videoTimestampOffset_=e),this.videoTimestampOffset_}audioQueueCallback(e){this.audioBuffer&&bt({type:"audio",sourceUpdater:this,action:_t.callback(e),name:"callback"})}videoQueueCallback(e){this.videoBuffer&&bt({type:"video",sourceUpdater:this,action:_t.callback(e),name:"callback"})}dispose(){this.trigger("dispose"),Ov.forEach(e=>{this.abort(e),this.canRemoveSourceBuffer()?this.removeSourceBuffer(e):this[`${e}QueueCallback`](()=>xp(e,this))}),this.videoAppendQueued_=!1,this.delayedAudioAppendQueue_.length=0,this.sourceopenListener_&&this.mediaSource.removeEventListener("sourceopen",this.sourceopenListener_),this.off()}}const vd=i=>decodeURIComponent(escape(String.fromCharCode.apply(null,i))),Rv=i=>{const e=new Uint8Array(i);return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")},Sd=new Uint8Array(`
|
|
215
215
|
|
|
216
|
-
`.split("").map(i=>i.charCodeAt(0)));class
|
|
217
|
-
`,a=n,l=t;this.start_=a,e.forEach((c,
|
|
218
|
-
`,D.syncInfo=$,$});s.set(l,new
|
|
219
|
-
`,l++,a=C}),this.end_=a,this.storage_=s,this.diagnostics_=r}calculateBaseTime_(e,t,n){if(!this.storage_.size)return 0;if(this.storage_.has(e))return this.storage_.get(e).segmentSyncInfo.start;const s=Math.min(...this.storage_.keys());if(e<s){const r=s-e;let a=this.storage_.get(s).segmentSyncInfo.start;for(let l=0;l<r;l++){const c=t[l];a-=c.duration}return a}return n}isReliablePlaylist_(e,t){return e!=null&&Array.isArray(t)&&t.length}}class Cd extends Op{constructor(e){super(),this.parent_=e}calculateBaseTime_(e,t,n){if(!this.storage_.size){const s=this.parent_.getSyncInfoForMediaSequence(e);return s?s.segmentSyncInfo.start:0}return super.calculateBaseTime_(e,t,n)}}const Qv=86400,Wa=[{name:"VOD",run:(i,e,t,n,s)=>t!==1/0?{time:0,segmentIndex:0,partIndex:null}:null},{name:"MediaSequence",run:(i,e,t,n,s,r)=>{const a=i.getMediaSequenceSync(r);if(!a||!a.isReliable)return null;const l=a.getSyncInfoForTime(s);return l?{time:l.start,partIndex:l.partIndex,segmentIndex:l.segmentIndex}:null}},{name:"ProgramDateTime",run:(i,e,t,n,s)=>{if(!Object.keys(i.timelineToDatetimeMappings).length)return null;let r=null,a=null;const l=oo(e);s=s||0;for(let c=0;c<l.length;c++){const g=e.endList||s===0?c:l.length-(c+1),m=l[g],b=m.segment,C=i.timelineToDatetimeMappings[b.timeline];if(!C||!b.dateTimeObject)continue;let w=b.dateTimeObject.getTime()/1e3+C;if(b.parts&&typeof m.partIndex=="number")for(let v=0;v<m.partIndex;v++)w+=b.parts[v].duration;const A=Math.abs(s-w);if(a!==null&&(A===0||a<A))break;a=A,r={time:w,segmentIndex:m.segmentIndex,partIndex:m.partIndex}}return r}},{name:"Segment",run:(i,e,t,n,s)=>{let r=null,a=null;s=s||0;const l=oo(e);for(let c=0;c<l.length;c++){const g=e.endList||s===0?c:l.length-(c+1),m=l[g],b=m.segment,C=m.part&&m.part.start||b&&b.start;if(b.timeline===n&&typeof C<"u"){const w=Math.abs(s-C);if(a!==null&&a<w)break;(!r||a===null||a>=w)&&(a=w,r={time:C,segmentIndex:m.segmentIndex,partIndex:m.partIndex})}}return r}},{name:"Discontinuity",run:(i,e,t,n,s)=>{let r=null;if(s=s||0,e.discontinuityStarts&&e.discontinuityStarts.length){let a=null;for(let l=0;l<e.discontinuityStarts.length;l++){const c=e.discontinuityStarts[l],g=e.discontinuitySequence+l+1,m=i.discontinuities[g];if(m){const b=Math.abs(s-m.time);if(a!==null&&a<b)break;(!r||a===null||a>=b)&&(a=b,r={time:m.time,segmentIndex:c,partIndex:null})}}}return r}},{name:"Playlist",run:(i,e,t,n,s)=>e.syncInfo?{time:e.syncInfo.time,segmentIndex:e.syncInfo.mediaSequence-e.mediaSequence,partIndex:null}:null}];class Jv extends B.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};const t=new Op,n=new Cd(t),s=new Cd(t);this.mediaSequenceStorage_={main:t,audio:n,vtt:s},this.logger_=Lt("SyncController")}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,t,n,s,r){if(t!==1/0)return Wa.find(({name:l})=>l==="VOD").run(this,e,t);const a=this.runStrategies_(e,t,n,s,r);if(!a.length)return null;for(const l of a){const{syncPoint:c,strategy:g}=l,{segmentIndex:m,time:b}=c;if(m<0)continue;const C=e.segments[m],w=b,A=w+C.duration;if(this.logger_(`Strategy: ${g}. Current time: ${s}. selected segment: ${m}. Time: [${w} -> ${A}]}`),s>=w&&s<A)return this.logger_("Found sync point with exact match: ",c),c}return this.selectSyncPoint_(a,{key:"time",value:s})}getExpiredTime(e,t){if(!e||!e.segments)return null;const n=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!n.length)return null;const s=this.selectSyncPoint_(n,{key:"segmentIndex",value:0});return s.segmentIndex>0&&(s.time*=-1),Math.abs(s.time+us({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:s.segmentIndex,endIndex:0}))}runStrategies_(e,t,n,s,r){const a=[];for(let l=0;l<Wa.length;l++){const c=Wa[l],g=c.run(this,e,t,n,s,r);g&&(g.strategy=c.name,a.push({strategy:c.name,syncPoint:g}))}return a}selectSyncPoint_(e,t){let n=e[0].syncPoint,s=Math.abs(e[0].syncPoint[t.key]-t.value),r=e[0].strategy;for(let a=1;a<e.length;a++){const l=Math.abs(e[a].syncPoint[t.key]-t.value);l<s&&(s=l,n=e[a].syncPoint,r=e[a].strategy)}return this.logger_(`syncPoint for [${t.key}: ${t.value}] chosen with strategy [${r}]: [time:${n.time}, segmentIndex:${n.segmentIndex}`+(typeof n.partIndex=="number"?`,partIndex:${n.partIndex}`:"")+"]"),n}saveExpiredSegmentInfo(e,t){const n=t.mediaSequence-e.mediaSequence;if(n>Qv){B.log.warn(`Not saving expired segment info. Media sequence gap ${n} is too large.`);return}for(let s=n-1;s>=0;s--){const r=e.segments[s];if(r&&typeof r.start<"u"){t.syncInfo={mediaSequence:e.mediaSequence+s,time:r.start},this.logger_(`playlist refresh sync: [time:${t.syncInfo.time}, mediaSequence: ${t.syncInfo.mediaSequence}]`),this.trigger("syncinfoupdate");break}}}setDateTimeMappingForStart(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){const t=e.segments[0],n=t.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[t.timeline]=-n}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:t}){const n=this.calculateSegmentTimeMapping_(e,e.timingInfo,t),s=e.segment;n&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:s.start}));const r=s.dateTimeObject;s.discontinuity&&t&&r&&(this.timelineToDatetimeMappings[s.timeline]=-(r.getTime()/1e3))}timestampOffsetForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].time}mappingForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].mapping}calculateSegmentTimeMapping_(e,t,n){const s=e.segment,r=e.part;let a=this.timelines[e.timeline],l,c;if(typeof e.timestampOffset=="number")a={time:e.startOfSegment,mapping:e.startOfSegment-t.start},n&&(this.timelines[e.timeline]=a,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${a.time}] [mapping: ${a.mapping}]`)),l=e.startOfSegment,c=t.end+a.mapping;else if(a)l=t.start+a.mapping,c=t.end+a.mapping;else return!1;return r&&(r.start=l,r.end=c),(!s.start||l<s.start)&&(s.start=l),s.end=c,!0}saveDiscontinuitySyncInfo_(e){const t=e.playlist,n=e.segment;if(n.discontinuity)this.discontinuities[n.timeline]={time:n.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(let s=0;s<t.discontinuityStarts.length;s++){const r=t.discontinuityStarts[s],a=t.discontinuitySequence+s+1,l=r-e.mediaIndex,c=Math.abs(l);if(!this.discontinuities[a]||this.discontinuities[a].accuracy>c){let g;l<0?g=n.start-us({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:r}):g=n.end+us({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:r}),this.discontinuities[a]={time:g,accuracy:c}}}}dispose(){this.trigger("dispose"),this.off()}}class Zv extends B.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:t,to:n}){return typeof t=="number"&&typeof n=="number"&&(this.pendingTimelineChanges_[e]={type:e,from:t,to:n},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:t,to:n}){if(typeof t=="number"&&typeof n=="number"){this.lastTimelineChanges_[e]={type:e,from:t,to:n},delete this.pendingTimelineChanges_[e];const s={timelineChangeInfo:{from:t,to:n}};this.trigger({type:"timelinechange",metadata:s})}return this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}const eS=yp(_p(function(){var i=function(){function v(){this.listeners={}}var M=v.prototype;return M.on=function(D,R){this.listeners[D]||(this.listeners[D]=[]),this.listeners[D].push(R)},M.off=function(D,R){if(!this.listeners[D])return!1;var N=this.listeners[D].indexOf(R);return this.listeners[D]=this.listeners[D].slice(0),this.listeners[D].splice(N,1),N>-1},M.trigger=function(D){var R=this.listeners[D];if(R)if(arguments.length===2)for(var N=R.length,F=0;F<N;++F)R[F].call(this,arguments[1]);else for(var P=Array.prototype.slice.call(arguments,1),$=R.length,Y=0;Y<$;++Y)R[Y].apply(this,P)},M.dispose=function(){this.listeners={}},M.pipe=function(D){this.on("data",function(R){D.push(R)})},v}();/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */function e(v){return v.subarray(0,v.byteLength-v[v.byteLength-1])}/*! @name aes-decrypter @version 4.0.2 @license Apache-2.0 */const t=function(){const v=[[[],[],[],[],[]],[[],[],[],[],[]]],M=v[0],D=v[1],R=M[4],N=D[4];let F,P,$;const Y=[],X=[];let re,ce,be,he,Z,de;for(F=0;F<256;F++)X[(Y[F]=F<<1^(F>>7)*283)^F]=F;for(P=$=0;!R[P];P^=re||1,$=X[$]||1)for(he=$^$<<1^$<<2^$<<3^$<<4,he=he>>8^he&255^99,R[P]=he,N[he]=P,be=Y[ce=Y[re=Y[P]]],de=be*16843009^ce*65537^re*257^P*16843008,Z=Y[he]*257^he*16843008,F=0;F<4;F++)M[F][P]=Z=Z<<24^Z>>>8,D[F][he]=de=de<<24^de>>>8;for(F=0;F<5;F++)M[F]=M[F].slice(0),D[F]=D[F].slice(0);return v};let n=null;class s{constructor(M){n||(n=t()),this._tables=[[n[0][0].slice(),n[0][1].slice(),n[0][2].slice(),n[0][3].slice(),n[0][4].slice()],[n[1][0].slice(),n[1][1].slice(),n[1][2].slice(),n[1][3].slice(),n[1][4].slice()]];let D,R,N;const F=this._tables[0][4],P=this._tables[1],$=M.length;let Y=1;if($!==4&&$!==6&&$!==8)throw new Error("Invalid aes key size");const X=M.slice(0),re=[];for(this._key=[X,re],D=$;D<4*$+28;D++)N=X[D-1],(D%$===0||$===8&&D%$===4)&&(N=F[N>>>24]<<24^F[N>>16&255]<<16^F[N>>8&255]<<8^F[N&255],D%$===0&&(N=N<<8^N>>>24^Y<<24,Y=Y<<1^(Y>>7)*283)),X[D]=X[D-$]^N;for(R=0;D;R++,D--)N=X[R&3?D:D-4],D<=4||R<4?re[R]=N:re[R]=P[0][F[N>>>24]]^P[1][F[N>>16&255]]^P[2][F[N>>8&255]]^P[3][F[N&255]]}decrypt(M,D,R,N,F,P){const $=this._key[1];let Y=M^$[0],X=N^$[1],re=R^$[2],ce=D^$[3],be,he,Z;const de=$.length/4-2;let ee,Xe=4;const Ye=this._tables[1],$e=Ye[0],He=Ye[1],me=Ye[2],fe=Ye[3],mt=Ye[4];for(ee=0;ee<de;ee++)be=$e[Y>>>24]^He[X>>16&255]^me[re>>8&255]^fe[ce&255]^$[Xe],he=$e[X>>>24]^He[re>>16&255]^me[ce>>8&255]^fe[Y&255]^$[Xe+1],Z=$e[re>>>24]^He[ce>>16&255]^me[Y>>8&255]^fe[X&255]^$[Xe+2],ce=$e[ce>>>24]^He[Y>>16&255]^me[X>>8&255]^fe[re&255]^$[Xe+3],Xe+=4,Y=be,X=he,re=Z;for(ee=0;ee<4;ee++)F[(3&-ee)+P]=mt[Y>>>24]<<24^mt[X>>16&255]<<16^mt[re>>8&255]<<8^mt[ce&255]^$[Xe++],be=Y,Y=X,X=re,re=ce,ce=be}}class r extends i{constructor(){super(i),this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null}push(M){this.jobs.push(M),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}const a=function(v){return v<<24|(v&65280)<<8|(v&16711680)>>8|v>>>24},l=function(v,M,D){const R=new Int32Array(v.buffer,v.byteOffset,v.byteLength>>2),N=new s(Array.prototype.slice.call(M)),F=new Uint8Array(v.byteLength),P=new Int32Array(F.buffer);let $,Y,X,re,ce,be,he,Z,de;for($=D[0],Y=D[1],X=D[2],re=D[3],de=0;de<R.length;de+=4)ce=a(R[de]),be=a(R[de+1]),he=a(R[de+2]),Z=a(R[de+3]),N.decrypt(ce,be,he,Z,P,de),P[de]=a(P[de]^$),P[de+1]=a(P[de+1]^Y),P[de+2]=a(P[de+2]^X),P[de+3]=a(P[de+3]^re),$=ce,Y=be,X=he,re=Z;return F};class c{constructor(M,D,R,N){const F=c.STEP,P=new Int32Array(M.buffer),$=new Uint8Array(M.byteLength);let Y=0;for(this.asyncStream_=new r,this.asyncStream_.push(this.decryptChunk_(P.subarray(Y,Y+F),D,R,$)),Y=F;Y<P.length;Y+=F)R=new Uint32Array([a(P[Y-4]),a(P[Y-3]),a(P[Y-2]),a(P[Y-1])]),this.asyncStream_.push(this.decryptChunk_(P.subarray(Y,Y+F),D,R,$));this.asyncStream_.push(function(){N(null,e($))})}static get STEP(){return 32e3}decryptChunk_(M,D,R,N){return function(){const F=l(M,D,R);N.set(F,M.byteOffset)}}}var g=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof or<"u"?or:typeof self<"u"?self:{},m;typeof window<"u"?m=window:typeof g<"u"?m=g:typeof self<"u"?m=self:m={};var b=m,C=function(v){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(v):v&&v.buffer instanceof ArrayBuffer},w=b.BigInt||Number;w("0x1"),w("0x100"),w("0x10000"),w("0x1000000"),w("0x100000000"),w("0x10000000000"),w("0x1000000000000"),w("0x100000000000000"),w("0x10000000000000000"),function(){var v=new Uint16Array([65484]),M=new Uint8Array(v.buffer,v.byteOffset,v.byteLength);return M[0]===255?"big":M[0]===204?"little":"unknown"}();const A=function(v){const M={};return Object.keys(v).forEach(D=>{const R=v[D];C(R)?M[D]={bytes:R.buffer,byteOffset:R.byteOffset,byteLength:R.byteLength}:M[D]=R}),M};self.onmessage=function(v){const M=v.data,D=new Uint8Array(M.encrypted.bytes,M.encrypted.byteOffset,M.encrypted.byteLength),R=new Uint32Array(M.key.bytes,M.key.byteOffset,M.key.byteLength/4),N=new Uint32Array(M.iv.bytes,M.iv.byteOffset,M.iv.byteLength/4);new c(D,R,N,function(F,P){self.postMessage(A({source:M.source,decrypted:P}),[P.buffer])})}}));var tS=mp(eS);const iS=i=>{let e=i.default?"main":"alternative";return i.characteristics&&i.characteristics.indexOf("public.accessibility.describes-video")>=0&&(e="main-desc"),e},Mp=(i,e)=>{i.abort(),i.pause(),e&&e.activePlaylistLoader&&(e.activePlaylistLoader.pause(),e.activePlaylistLoader=null)},bo=(i,e)=>{e.activePlaylistLoader=i,i.load()},nS=(i,e)=>()=>{const{segmentLoaders:{[i]:t,main:n},mediaTypes:{[i]:s}}=e,r=s.activeTrack(),a=s.getActiveGroup(),l=s.activePlaylistLoader,c=s.lastGroup_;if(!(a&&c&&a.id===c.id)&&(s.lastGroup_=a,s.lastTrack_=r,Mp(t,s),!(!a||a.isMainPlaylist))){if(!a.playlistLoader){l&&n.resetEverything();return}t.resyncLoader(),bo(a.playlistLoader,s)}},sS=(i,e)=>()=>{const{segmentLoaders:{[i]:t},mediaTypes:{[i]:n}}=e;n.lastGroup_=null,t.abort(),t.pause()},rS=(i,e)=>()=>{const{mainPlaylistLoader:t,segmentLoaders:{[i]:n,main:s},mediaTypes:{[i]:r}}=e,a=r.activeTrack(),l=r.getActiveGroup(),c=r.activePlaylistLoader,g=r.lastTrack_;if(!(g&&a&&g.id===a.id)&&(r.lastGroup_=l,r.lastTrack_=a,Mp(n,r),!!l)){if(l.isMainPlaylist){if(!a||!g||a.id===g.id)return;const m=e.vhs.playlistController_,b=m.selectPlaylist();if(m.media()===b)return;r.logger_(`track change. Switching main audio from ${g.id} to ${a.id}`),t.pause(),s.resetEverything(),m.fastQualityChange_(b);return}if(i==="AUDIO"){if(!l.playlistLoader){s.setAudio(!0),s.resetEverything();return}n.setAudio(!0),s.setAudio(!1)}if(c===l.playlistLoader){bo(l.playlistLoader,r);return}n.track&&n.track(a),n.resetEverything(),bo(l.playlistLoader,r)}},Ar={AUDIO:(i,e)=>()=>{const{mediaTypes:{[i]:t},excludePlaylist:n}=e,s=t.activeTrack(),r=t.activeGroup(),a=(r.filter(c=>c.default)[0]||r[0]).id,l=t.tracks[a];if(s===l){n({error:{message:"Problem encountered loading the default audio track."}});return}B.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(const c in t.tracks)t.tracks[c].enabled=t.tracks[c]===l;t.onTrackChanged()},SUBTITLES:(i,e)=>()=>{const{mediaTypes:{[i]:t}}=e;B.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.");const n=t.activeTrack();n&&(n.mode="disabled"),t.onTrackChanged()}},Id={AUDIO:(i,e,t)=>{if(!e)return;const{tech:n,requestOptions:s,segmentLoaders:{[i]:r}}=t;e.on("loadedmetadata",()=>{const a=e.media();r.playlist(a,s),(!n.paused()||a.endList&&n.preload()!=="none")&&r.load()}),e.on("loadedplaylist",()=>{r.playlist(e.media(),s),n.paused()||r.load()}),e.on("error",Ar[i](i,t))},SUBTITLES:(i,e,t)=>{const{tech:n,requestOptions:s,segmentLoaders:{[i]:r},mediaTypes:{[i]:a}}=t;e.on("loadedmetadata",()=>{const l=e.media();r.playlist(l,s),r.track(a.activeTrack()),(!n.paused()||l.endList&&n.preload()!=="none")&&r.load()}),e.on("loadedplaylist",()=>{r.playlist(e.media(),s),n.paused()||r.load()}),e.on("error",Ar[i](i,t))}},aS={AUDIO:(i,e)=>{const{vhs:t,sourceType:n,segmentLoaders:{[i]:s},requestOptions:r,main:{mediaGroups:a},mediaTypes:{[i]:{groups:l,tracks:c,logger_:g}},mainPlaylistLoader:m}=e,b=vs(m.main);(!a[i]||Object.keys(a[i]).length===0)&&(a[i]={main:{default:{default:!0}}},b&&(a[i].main.default.playlists=m.main.playlists));for(const C in a[i]){l[C]||(l[C]=[]);for(const w in a[i][C]){let A=a[i][C][w],v;if(b?(g(`AUDIO group '${C}' label '${w}' is a main playlist`),A.isMainPlaylist=!0,v=null):n==="vhs-json"&&A.playlists?v=new nn(A.playlists[0],t,r):A.resolvedUri?v=new nn(A.resolvedUri,t,r):A.playlists&&n==="dash"?v=new fo(A.playlists[0],t,r,m):v=null,A=ge({id:w,playlistLoader:v},A),Id[i](i,A.playlistLoader,e),l[C].push(A),typeof c[w]>"u"){const M=new B.AudioTrack({id:w,kind:iS(A),enabled:!1,language:A.language,default:A.default,label:w});c[w]=M}}}s.on("error",Ar[i](i,e))},SUBTITLES:(i,e)=>{const{tech:t,vhs:n,sourceType:s,segmentLoaders:{[i]:r},requestOptions:a,main:{mediaGroups:l},mediaTypes:{[i]:{groups:c,tracks:g}},mainPlaylistLoader:m}=e;for(const b in l[i]){c[b]||(c[b]=[]);for(const C in l[i][b]){if(!n.options_.useForcedSubtitles&&l[i][b][C].forced)continue;let w=l[i][b][C],A;if(s==="hls")A=new nn(w.resolvedUri,n,a);else if(s==="dash"){if(!w.playlists.filter(v=>v.excludeUntil!==1/0).length)return;A=new fo(w.playlists[0],n,a,m)}else s==="vhs-json"&&(A=new nn(w.playlists?w.playlists[0]:w.resolvedUri,n,a));if(w=ge({id:C,playlistLoader:A},w),Id[i](i,w.playlistLoader,e),c[b].push(w),typeof g[C]>"u"){const v=t.addRemoteTextTrack({id:C,kind:"subtitles",default:w.default&&w.autoselect,language:w.language,label:C},!1).track;g[C]=v}}}r.on("error",Ar[i](i,e))},"CLOSED-CAPTIONS":(i,e)=>{const{tech:t,main:{mediaGroups:n},mediaTypes:{[i]:{groups:s,tracks:r}}}=e;for(const a in n[i]){s[a]||(s[a]=[]);for(const l in n[i][a]){const c=n[i][a][l];if(!/^(?:CC|SERVICE)/.test(c.instreamId))continue;const g=t.options_.vhs&&t.options_.vhs.captionServices||{};let m={label:l,language:c.language,instreamId:c.instreamId,default:c.default&&c.autoselect};if(g[m.instreamId]&&(m=ge(m,g[m.instreamId])),m.default===void 0&&delete m.default,s[a].push(ge({id:l},c)),typeof r[l]>"u"){const b=t.addRemoteTextTrack({id:m.instreamId,kind:"captions",default:m.default,language:m.language,label:m.label},!1).track;r[l]=b}}}}},Rp=(i,e)=>{for(let t=0;t<i.length;t++)if(cl(e,i[t])||i[t].playlists&&Rp(i[t].playlists,e))return!0;return!1},oS=(i,e)=>t=>{const{mainPlaylistLoader:n,mediaTypes:{[i]:{groups:s}}}=e,r=n.media();if(!r)return null;let a=null;r.attributes[i]&&(a=s[r.attributes[i]]);const l=Object.keys(s);if(!a)if(i==="AUDIO"&&l.length>1&&vs(e.main))for(let c=0;c<l.length;c++){const g=s[l[c]];if(Rp(g,r)){a=g;break}}else s.main?a=s.main:l.length===1&&(a=s[l[0]]);return typeof t>"u"?a:t===null||!a?null:a.filter(c=>c.id===t.id)[0]||null},lS={AUDIO:(i,e)=>()=>{const{mediaTypes:{[i]:{tracks:t}}}=e;for(const n in t)if(t[n].enabled)return t[n];return null},SUBTITLES:(i,e)=>()=>{const{mediaTypes:{[i]:{tracks:t}}}=e;for(const n in t)if(t[n].mode==="showing"||t[n].mode==="hidden")return t[n];return null}},uS=(i,{mediaTypes:e})=>()=>{const t=e[i].activeTrack();return t?e[i].activeGroup(t):null},dS=i=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(g=>{aS[g](g,i)});const{mediaTypes:e,mainPlaylistLoader:t,tech:n,vhs:s,segmentLoaders:{["AUDIO"]:r,main:a}}=i;["AUDIO","SUBTITLES"].forEach(g=>{e[g].activeGroup=oS(g,i),e[g].activeTrack=lS[g](g,i),e[g].onGroupChanged=nS(g,i),e[g].onGroupChanging=sS(g,i),e[g].onTrackChanged=rS(g,i),e[g].getActiveGroup=uS(g,i)});const l=e.AUDIO.activeGroup();if(l){const g=(l.filter(m=>m.default)[0]||l[0]).id;e.AUDIO.tracks[g].enabled=!0,e.AUDIO.onGroupChanged(),e.AUDIO.onTrackChanged(),e.AUDIO.getActiveGroup().playlistLoader?(a.setAudio(!1),r.setAudio(!0)):a.setAudio(!0)}t.on("mediachange",()=>{["AUDIO","SUBTITLES"].forEach(g=>e[g].onGroupChanged())}),t.on("mediachanging",()=>{["AUDIO","SUBTITLES"].forEach(g=>e[g].onGroupChanging())});const c=()=>{e.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"vhs-audio-change"})};n.audioTracks().addEventListener("change",c),n.remoteTextTracks().addEventListener("change",e.SUBTITLES.onTrackChanged),s.on("dispose",()=>{n.audioTracks().removeEventListener("change",c),n.remoteTextTracks().removeEventListener("change",e.SUBTITLES.onTrackChanged)}),n.clearTracks("audio");for(const g in e.AUDIO.tracks)n.audioTracks().addTrack(e.AUDIO.tracks[g])},hS=()=>{const i={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{i[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:ni,activeTrack:ni,getActiveGroup:ni,onGroupChanged:ni,onTrackChanged:ni,lastTrack_:null,logger_:Lt(`MediaGroups[${e}]`)}}),i};class xd{constructor(){this.priority_=[],this.pathwayClones_=new Map}set version(e){e===1&&(this.version_=e)}set ttl(e){this.ttl_=e||300}set reloadUri(e){e&&(this.reloadUri_=pt(this.reloadUri_,e))}set priority(e){e&&e.length&&(this.priority_=e)}set pathwayClones(e){e&&e.length&&(this.pathwayClones_=new Map(e.map(t=>[t.ID,t])))}get version(){return this.version_}get ttl(){return this.ttl_}get reloadUri(){return this.reloadUri_}get priority(){return this.priority_}get pathwayClones(){return this.pathwayClones_}}class cS extends B.EventTarget{constructor(e,t){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new xd,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.currentPathwayClones=new Map,this.nextPathwayClones=new Map,this.excludedSteeringManifestURLs=new Set,this.logger_=Lt("Content Steering"),this.xhr_=e,this.getBandwidth_=t}assignTagProperties(e,t){this.manifestType_=t.serverUri?"HLS":"DASH";const n=t.serverUri||t.serverURL;if(!n){this.logger_(`steering manifest URL is ${n}, cannot request steering manifest.`),this.trigger("error");return}if(n.startsWith("data:")){this.decodeDataUriManifest_(n.substring(n.indexOf(",")+1));return}this.steeringManifest.reloadUri=pt(e,n),this.defaultPathway=t.pathwayId||t.defaultServiceLocation,this.queryBeforeStart=t.queryBeforeStart,this.proxyServerUrl_=t.proxyServerURL,this.defaultPathway&&!this.queryBeforeStart&&this.trigger("content-steering")}requestSteeringManifest(e){const t=this.steeringManifest.reloadUri;if(!t)return;const n=e?t:this.getRequestURI(t);if(!n){this.logger_("No valid content steering manifest URIs. Stopping content steering."),this.trigger("error"),this.dispose();return}const s={contentSteeringInfo:{uri:n}};this.trigger({type:"contentsteeringloadstart",metadata:s}),this.request_=this.xhr_({uri:n,requestType:"content-steering-manifest"},(r,a)=>{if(r){if(a.status===410){this.logger_(`manifest request 410 ${r}.`),this.logger_(`There will be no more content steering requests to ${n} this session.`),this.excludedSteeringManifestURLs.add(n);return}if(a.status===429){const g=a.responseHeaders["retry-after"];this.logger_(`manifest request 429 ${r}.`),this.logger_(`content steering will retry in ${g} seconds.`),this.startTTLTimeout_(parseInt(g,10));return}this.logger_(`manifest failed to load ${r}.`),this.startTTLTimeout_();return}this.trigger({type:"contentsteeringloadcomplete",metadata:s});let l;try{l=JSON.parse(this.request_.responseText)}catch(g){const m={errorType:B.Error.StreamingContentSteeringParserError,error:g};this.trigger({type:"error",metadata:m})}this.assignSteeringProperties_(l);const c={contentSteeringInfo:s.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:"contentsteeringparsed",metadata:c}),this.startTTLTimeout_()})}setProxyServerUrl_(e){const t=new x.URL(e),n=new x.URL(this.proxyServerUrl_);return n.searchParams.set("url",encodeURI(t.toString())),this.setSteeringParams_(n.toString())}decodeDataUriManifest_(e){const t=JSON.parse(x.atob(e));this.assignSteeringProperties_(t)}setSteeringParams_(e){const t=new x.URL(e),n=this.getPathway(),s=this.getBandwidth_();if(n){const r=`_${this.manifestType_}_pathway`;t.searchParams.set(r,n)}if(s){const r=`_${this.manifestType_}_throughput`;t.searchParams.set(r,s)}return t.toString()}assignSteeringProperties_(e){if(this.steeringManifest.version=e.VERSION,!this.steeringManifest.version){this.logger_(`manifest version is ${e.VERSION}, which is not supported.`),this.trigger("error");return}this.steeringManifest.ttl=e.TTL,this.steeringManifest.reloadUri=e["RELOAD-URI"],this.steeringManifest.priority=e["PATHWAY-PRIORITY"]||e["SERVICE-LOCATION-PRIORITY"],this.steeringManifest.pathwayClones=e["PATHWAY-CLONES"],this.nextPathwayClones=this.steeringManifest.pathwayClones,this.availablePathways_.size||(this.logger_("There are no available pathways for content steering. Ending content steering."),this.trigger("error"),this.dispose());const t=(n=>{for(const s of n)if(this.availablePathways_.has(s))return s;return[...this.availablePathways_][0]})(this.steeringManifest.priority);this.currentPathway!==t&&(this.currentPathway=t,this.trigger("content-steering"))}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;const t=s=>this.excludedSteeringManifestURLs.has(s);if(this.proxyServerUrl_){const s=this.setProxyServerUrl_(e);if(!t(s))return s}const n=this.setSteeringParams_(e);return t(n)?null:n}startTTLTimeout_(e=this.steeringManifest.ttl){const t=e*1e3;this.ttlTimeout_=x.setTimeout(()=>{this.requestSteeringManifest()},t)}clearTTLTimeout_(){x.clearTimeout(this.ttlTimeout_),this.ttlTimeout_=null}abort(){this.request_&&this.request_.abort(),this.request_=null}dispose(){this.off("content-steering"),this.off("error"),this.abort(),this.clearTTLTimeout_(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=null,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.excludedSteeringManifestURLs=new Set,this.availablePathways_=new Set,this.steeringManifest=new xd}addAvailablePathway(e){e&&this.availablePathways_.add(e)}clearAvailablePathways(){this.availablePathways_.clear()}excludePathway(e){return this.availablePathways_.delete(e)}didDASHTagChange(e,t){return!t&&this.steeringManifest.reloadUri||t&&(pt(e,t.serverURL)!==this.steeringManifest.reloadUri||t.defaultServiceLocation!==this.defaultPathway||t.queryBeforeStart!==this.queryBeforeStart||t.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}}const pS=(i,e)=>{let t=null;return(...n)=>{clearTimeout(t),t=setTimeout(()=>{i.apply(null,n)},e)}},fS=10;let yi;const gS=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],mS=function(i){return this.audioSegmentLoader_[i]+this.mainSegmentLoader_[i]},yS=function({currentPlaylist:i,buffered:e,currentTime:t,nextPlaylist:n,bufferLowWaterLine:s,bufferHighWaterLine:r,duration:a,bufferBasedABR:l,log:c}){if(!n)return B.log.warn("We received no playlist to switch to. Please check your stream."),!1;const g=`allowing switch ${i&&i.id||"null"} -> ${n.id}`;if(!i)return c(`${g} as current playlist is not set`),!0;if(n.id===i.id)return!1;const m=!!tn(e,t).length;if(!i.endList)return!m&&typeof i.partTargetDuration=="number"?(c(`not ${g} as current playlist is live llhls, but currentTime isn't in buffered.`),!1):(c(`${g} as current playlist is live`),!0);const b=ul(e,t),C=l?We.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:We.MAX_BUFFER_LOW_WATER_LINE;if(a<C)return c(`${g} as duration < max low water line (${a} < ${C})`),!0;const w=n.attributes.BANDWIDTH,A=i.attributes.BANDWIDTH;if(w<A&&(!l||b<r)){let v=`${g} as next bandwidth < current bandwidth (${w} < ${A})`;return l&&(v+=` and forwardBuffer < bufferHighWaterLine (${b} < ${r})`),c(v),!0}if((!l||w>A)&&b>=s){let v=`${g} as forwardBuffer >= bufferLowWaterLine (${b} >= ${s})`;return l&&(v+=` and next bandwidth > current bandwidth (${w} > ${A})`),c(v),!0}return c(`not ${g} as no switching criteria met`),!1};class _S extends B.EventTarget{constructor(e){super(),this.fastQualityChange_=pS(this.fastQualityChange_.bind(this),100);const{src:t,withCredentials:n,tech:s,bandwidth:r,externVhs:a,useCueTags:l,playlistExclusionDuration:c,enableLowInitialPlaylist:g,sourceType:m,cacheEncryptionKeys:b,bufferBasedABR:C,leastPixelDiffSelector:w,captionServices:A,experimentalUseMMS:v}=e;if(!t)throw new Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:M}=e;(M===null||typeof M>"u")&&(M=1/0),yi=a,this.bufferBasedABR=!!C,this.leastPixelDiffSelector=!!w,this.withCredentials=n,this.tech_=s,this.vhs_=s.vhs,this.player_=e.player_,this.sourceType_=m,this.useCueTags_=l,this.playlistExclusionDuration=c,this.maxPlaylistRetries=M,this.enableLowInitialPlaylist=g,this.usingManagedMediaSource_=!1,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:n,maxPlaylistRetries:M,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=hS(),v&&x.ManagedMediaSource?(this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new x.ManagedMediaSource,this.usingManagedMediaSource_=!0,B.log("Using ManagedMediaSource")):x.MediaSource&&(this.mediaSource=new x.MediaSource),this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.load=this.load.bind(this),this.pause=this.pause.bind(this),this.mediaSource.addEventListener("durationchange",this.handleDurationChange_),this.mediaSource.addEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.addEventListener("sourceended",this.handleSourceEnded_),this.mediaSource.addEventListener("startstreaming",this.load),this.mediaSource.addEventListener("endstreaming",this.pause),this.seekable_=tt(),this.hasPlayed_=!1,this.syncController_=new Jv(e),this.segmentMetadataTrack_=s.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.decrypter_=new tS,this.sourceUpdater_=new Dp(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new Zv,this.keyStatusMap_=new Map;const D={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:A,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:r,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:b,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_==="dash"?new fo(t,this.vhs_,ge(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new nn(t,this.vhs_,ge(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new yo(ge(D,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new yo(ge(D,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new Gv(ge(D,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((F,P)=>{function $(){s.off("vttjserror",Y),F()}function Y(){s.off("vttjsloaded",$),P()}s.one("vttjsloaded",$),s.one("vttjserror",Y),s.addWebVttScript_()})}),e);const R=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new cS(this.vhs_.xhr,R),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_())),gS.forEach(F=>{this[F+"_"]=mS.bind(this,F)}),this.logger_=Lt("pc"),this.triggeredFmp4Usage=!1,this.tech_.preload()==="none"?(this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one("play",this.loadOnPlay_)):this.mainPlaylistLoader_.load(),this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1;const N=this.tech_.preload()==="none"?"play":"loadstart";this.tech_.one(N,()=>{const F=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-F,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends})})}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){const e=this.mainAppendsToLoadedData_(),t=this.audioAppendsToLoadedData_();return e===-1||t===-1?-1:e+t}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e="abr"){const t=this.selectPlaylist();t&&this.shouldSwitchToMedia_(t)&&this.switchMedia_(t,e)}switchMedia_(e,t,n){const s=this.media(),r=s&&(s.id||s.uri),a=e&&(e.id||e.uri);if(r&&r!==a){this.logger_(`switch media ${r} -> ${a} from ${t}`);const l={renditionInfo:{id:a,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:t};this.trigger({type:"renditionselected",metadata:l}),this.tech_.trigger({type:"usage",name:`vhs-rendition-change-${t}`})}this.mainPlaylistLoader_.media(e,n)}switchMediaForDASHContentSteering_(){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{const t=this.mediaTypes_[e],n=t?t.activeGroup():null,s=this.contentSteeringController_.getPathway();if(n&&s){const r=(n.length?n[0].playlists:n.playlists).filter(a=>a.attributes.serviceLocation===s);r.length&&this.mediaTypes_[e].activePlaylistLoader.media(r[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=x.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(x.clearInterval(this.abrTimer_),this.abrTimer_=null)}getAudioTrackPlaylists_(){const e=this.main(),t=e&&e.playlists||[];if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return t;const n=e.mediaGroups.AUDIO,s=Object.keys(n);let r;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)r=this.mediaTypes_.AUDIO.activeTrack();else{const l=n.main||s.length&&n[s[0]];for(const c in l)if(l[c].default){r={label:c};break}}if(!r)return t;const a=[];for(const l in n)if(n[l][r.label]){const c=n[l][r.label];if(c.playlists&&c.playlists.length)a.push.apply(a,c.playlists);else if(c.uri)a.push(c);else if(e.playlists.length)for(let g=0;g<e.playlists.length;g++){const m=e.playlists[g];m.attributes&&m.attributes.AUDIO&&m.attributes.AUDIO===l&&a.push(m)}}return a.length?a:t}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",()=>{const e=this.mainPlaylistLoader_.media(),t=e.targetDuration*1.5*1e3;lo(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,e.endList&&this.tech_.preload()!=="none"&&(this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.mainSegmentLoader_.load()),dS({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),e),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media()?this.trigger("selectedinitialmedia"):this.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",()=>{this.trigger("selectedinitialmedia")})}),this.mainPlaylistLoader_.on("loadedplaylist",()=>{this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_);let e=this.mainPlaylistLoader_.media();if(!e){this.attachContentSteeringListeners_(),this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let t;if(this.enableLowInitialPlaylist&&(t=this.selectInitialPlaylist()),t||(t=this.selectPlaylist()),!t||!this.shouldSwitchToMedia_(t)||(this.initialMedia_=t,this.switchMedia_(this.initialMedia_,"initial"),!(this.sourceType_==="vhs-json"&&this.initialMedia_.segments)))return;e=this.initialMedia_}this.handleUpdatedMediaPlaylist(e)}),this.mainPlaylistLoader_.on("error",()=>{const e=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:e.playlist,error:e})}),this.mainPlaylistLoader_.on("mediachanging",()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on("mediachange",()=>{const e=this.mainPlaylistLoader_.media(),t=e.targetDuration*1.5*1e3;lo(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,this.sourceType_==="dash"&&this.mainPlaylistLoader_.isPaused&&this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_?this.runFastQualitySwitch_():this.mainSegmentLoader_.load(),this.tech_.trigger({type:"mediachange",bubbles:!0})}),this.mainPlaylistLoader_.on("playlistunchanged",()=>{const e=this.mainPlaylistLoader_.media();e.lastExcludeReason_!=="playlist-unchanged"&&this.stuckAtPlaylistEnd_(e)&&(this.excludePlaylist({error:{message:"Playlist no longer updating.",reason:"playlist-unchanged"}}),this.tech_.trigger("playliststuck"))}),this.mainPlaylistLoader_.on("renditiondisabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"})}),this.mainPlaylistLoader_.on("renditionenabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"})}),["manifestrequeststart","manifestrequestcomplete","manifestparsestart","manifestparsecomplete","playlistrequeststart","playlistrequestcomplete","playlistparsestart","playlistparsecomplete","renditiondisabled","renditionenabled"].forEach(e=>{this.mainPlaylistLoader_.on(e,t=>{this.player_.trigger(je({},t))})})}handleUpdatedMediaPlaylist(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_&&this.runFastQualitySwitch_(),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load())}triggerPresenceUsage_(e,t){const n=e.mediaGroups||{};let s=!0;const r=Object.keys(n.AUDIO);for(const a in n.AUDIO)for(const l in n.AUDIO[a])n.AUDIO[a][l].uri||(s=!1);s&&this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),Object.keys(n.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),yi.Playlist.isAes(t)&&this.tech_.trigger({type:"usage",name:"vhs-aes"}),r.length&&Object.keys(n.AUDIO[r[0]]).length>1&&this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"})}shouldSwitchToMedia_(e){const t=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,n=this.tech_.currentTime(),s=this.bufferLowWaterLine(),r=this.bufferHighWaterLine(),a=this.tech_.buffered();return yS({buffered:a,currentTime:n,currentPlaylist:t,nextPlaylist:e,bufferLowWaterLine:s,bufferHighWaterLine:r,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_})}setupSegmentLoaderListeners_(){this.mainSegmentLoader_.on("bandwidthupdate",()=>{this.checkABR_("bandwidthupdate"),this.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("timeout",()=>{this.bufferBasedABR&&this.mainSegmentLoader_.load()}),this.bufferBasedABR||this.mainSegmentLoader_.on("progress",()=>{this.trigger("progress")}),this.mainSegmentLoader_.on("error",()=>{const t=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:t.playlist,error:t})}),this.mainSegmentLoader_.on("appenderror",()=>{this.error=this.mainSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",()=>{this.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.audioSegmentLoader_.on("appenderror",()=>{this.error=this.audioSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("ended",()=>{this.logger_("main segment loader ended"),this.onEndOfStream()}),this.timelineChangeController_.on("audioTimelineBehind",()=>{const t=this.audioSegmentLoader_.pendingSegment_;if(!t||!t.segment||!t.segment.syncInfo)return;const n=t.segment.syncInfo.end+.01;this.tech_.setCurrentTime(n)}),this.timelineChangeController_.on("fixBadTimelineChange",()=>{this.logger_("Fix bad timeline change. Restarting al segment loaders..."),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}),this.mainSegmentLoader_.on("earlyabort",t=>{this.bufferBasedABR||(this.delegateLoaders_("all",["abort"]),this.excludePlaylist({error:{message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},playlistExclusionDuration:fS}))});const e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();const t=this.getCodecsOrExclude_();t&&this.sourceUpdater_.addOrChangeSourceBuffers(t)};this.mainSegmentLoader_.on("trackinfo",e),this.audioSegmentLoader_.on("trackinfo",e),this.mainSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("ended",()=>{this.logger_("audioSegmentLoader ended"),this.onEndOfStream()}),["segmentselected","segmentloadstart","segmentloaded","segmentkeyloadstart","segmentkeyloadcomplete","segmentdecryptionstart","segmentdecryptioncomplete","segmenttransmuxingstart","segmenttransmuxingcomplete","segmenttransmuxingtrackinfoavailable","segmenttransmuxingtiminginfoavailable","segmentappendstart","appendsdone","bandwidthupdated","timelinechange","codecschange"].forEach(t=>{this.mainSegmentLoader_.on(t,n=>{this.player_.trigger(je({},n))}),this.audioSegmentLoader_.on(t,n=>{this.player_.trigger(je({},n))}),this.subtitleSegmentLoader_.on(t,n=>{this.player_.trigger(je({},n))})})}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}pause(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}fastQualityChange_(e=this.selectPlaylist()){if(e&&e===this.mainPlaylistLoader_.media()){this.logger_("skipping fastQualityChange because new media is same as old");return}this.switchMedia_(e,"fast-quality"),this.waitingForFastQualityPlaylistReceived_=!0}runFastQualitySwitch_(){this.waitingForFastQualityPlaylistReceived_=!1,this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}play(){if(this.setupFirstPlay())return;this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();const e=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<e.start(0))return this.tech_.setCurrentTime(e.end(e.length-1))}setupFirstPlay(){const e=this.mainPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_)return!1;if(!e.endList||e.start){const t=this.seekable();if(!t.length)return!1;const n=t.end(0);let s=n;if(e.start){const r=e.start.timeOffset;r<0?s=Math.max(n+r,t.start(0)):s=Math.min(n,r)}this.trigger("firstplay"),this.tech_.setCurrentTime(s)}return this.hasPlayed_=!0,this.load(),!0}handleSourceOpen_(){if(this.tryToCreateSourceBuffers_(),this.tech_.autoplay()){const e=this.tech_.play();typeof e<"u"&&typeof e.then=="function"&&e.then(null,t=>{})}this.trigger("sourceopen")}handleSourceEnded_(){if(!this.inbandTextTracks_.metadataTrack_)return;const e=this.inbandTextTracks_.metadataTrack_.cues;if(!e||!e.length)return;const t=this.duration();e[e.length-1].endTime=isNaN(t)||Math.abs(t)===1/0?Number.MAX_VALUE:t}handleDurationChange_(){this.tech_.trigger("durationchange")}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){const t=this.mainSegmentLoader_.getCurrentMediaInfo_();!t||t.hasVideo?e=e&&this.audioSegmentLoader_.ended_:e=this.audioSegmentLoader_.ended_}e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream())}stuckAtPlaylistEnd_(e){if(!this.seekable().length)return!1;const t=this.syncController_.getExpiredTime(e,this.duration());if(t===null)return!1;const n=yi.Playlist.playlistEnd(e,t),s=this.tech_.currentTime(),r=this.tech_.buffered();if(!r.length)return n-s<=Kt;const a=r.end(r.length-1);return a-s<=Kt&&n-a<=Kt}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:t={},playlistExclusionDuration:n}){if(e=e||this.mainPlaylistLoader_.media(),n=n||t.playlistExclusionDuration||this.playlistExclusionDuration,!e){this.error=t,this.mediaSource.readyState!=="open"?this.trigger("error"):this.sourceUpdater_.endOfStream("network");return}e.playlistErrors_++;const s=this.mainPlaylistLoader_.main.playlists,r=s.filter(ta),a=r.length===1&&r[0]===e;if(s.length===1&&n!==1/0)return B.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger("retryplaylist"),this.mainPlaylistLoader_.load(a);if(a){if(this.main().contentSteering){const A=this.pathwayAttribute_(e),v=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(A),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(A)},v);return}let w=!1;s.forEach(A=>{if(A===e)return;const v=A.excludeUntil;typeof v<"u"&&v!==1/0&&(w=!0,delete A.excludeUntil)}),w&&(B.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"))}let l;e.playlistErrors_>this.maxPlaylistRetries?l=1/0:l=Date.now()+n*1e3,e.excludeUntil=l,t.reason&&(e.lastExcludeReason_=t.reason),this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});const c=this.selectPlaylist();if(!c){this.error="Playback cannot continue. No available working or supported playlists.",this.trigger("error");return}const g=t.internal?this.logger_:B.log.warn,m=t.message?" "+t.message:"";g(`${t.internal?"Internal problem":"Problem"} encountered with playlist ${e.id}.${m} Switching to playlist ${c.id}.`),c.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),c.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]);const b=c.targetDuration/2*1e3||5*1e3,C=typeof c.lastRequest=="number"&&Date.now()-c.lastRequest<=b;return this.switchMedia_(c,"exclude",a||C)}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(e,t){const n=[],s=e==="all";(s||e==="main")&&n.push(this.mainPlaylistLoader_);const r=[];(s||e==="audio")&&r.push("AUDIO"),(s||e==="subtitle")&&(r.push("CLOSED-CAPTIONS"),r.push("SUBTITLES")),r.forEach(a=>{const l=this.mediaTypes_[a]&&this.mediaTypes_[a].activePlaylistLoader;l&&n.push(l)}),["main","audio","subtitle"].forEach(a=>{const l=this[`${a}SegmentLoader_`];l&&(e===a||e==="all")&&n.push(l)}),n.forEach(a=>t.forEach(l=>{typeof a[l]=="function"&&a[l]()}))}setCurrentTime(e){const t=tn(this.tech_.buffered(),e);if(!(this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media())||!this.mainPlaylistLoader_.media().segments)return 0;if(t&&t.length)return e;this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}duration(){if(!this.mainPlaylistLoader_)return 0;const e=this.mainPlaylistLoader_.media();return e?e.endList?this.mediaSource?this.mediaSource.duration:yi.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}getSeekableRange_(e,t){const n=e.media();if(!n)return null;const s=this.syncController_.getMediaSequenceSync(t);if(s&&s.isReliable){const l=s.start,c=s.end;if(!isFinite(l)||!isFinite(c))return null;const g=yi.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,n),m=Math.max(0,c-g);return m<l?null:tt([[l,m]])}const r=this.syncController_.getExpiredTime(n,this.duration());if(r===null)return null;const a=yi.Playlist.seekable(n,r,yi.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,n));return a.length?a:null}computeFinalSeekable_(e,t){if(!t)return e;const n=e.start(0),s=e.end(0),r=t.start(0),a=t.end(0);return r>s||n>a?e:tt([[Math.max(n,r),Math.min(s,a)]])}onSyncInfoUpdate_(){if(!this.mainPlaylistLoader_)return;const e=this.getSeekableRange_(this.mainPlaylistLoader_,"main");if(!e)return;let t;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(t=this.getSeekableRange_(this.mediaTypes_.AUDIO.activePlaylistLoader,"audio"),!t))return;const n=this.seekable_;if(this.seekable_=this.computeFinalSeekable_(e,t),!this.seekable_||n&&n.length&&this.seekable_.length&&n.start(0)===this.seekable_.start(0)&&n.end(0)===this.seekable_.end(0))return;this.logger_(`seekable updated [${Wc(this.seekable_)}]`);const s={seekableRanges:this.seekable_};this.trigger({type:"seekablerangeschanged",metadata:s}),this.tech_.trigger("seekablechanged")}updateDuration(e){if(this.updateDuration_&&(this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.updateDuration_=null),this.mediaSource.readyState!=="open"){this.updateDuration_=this.updateDuration.bind(this,e),this.mediaSource.addEventListener("sourceopen",this.updateDuration_);return}if(e){const s=this.seekable();if(!s.length)return;(isNaN(this.mediaSource.duration)||this.mediaSource.duration<s.end(s.length-1))&&this.sourceUpdater_.setDuration(s.end(s.length-1));return}const t=this.tech_.buffered();let n=yi.Playlist.duration(this.mainPlaylistLoader_.media());t.length>0&&(n=Math.max(n,t.end(t.length-1))),this.mediaSource.duration!==n&&this.sourceUpdater_.setDuration(n)}dispose(){this.trigger("dispose"),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.contentSteeringController_.dispose(),this.keyStatusMap_.clear(),this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_),["AUDIO","SUBTITLES"].forEach(e=>{const t=this.mediaTypes_[e].groups;for(const n in t)t[n].forEach(s=>{s.playlistLoader&&s.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){const e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,t=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),n=e?!!this.audioSegmentLoader_.getCurrentMediaInfo_():!0;return!(!t||!n)}getCodecsOrExclude_(){const e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},t=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;const n=ds(this.main(),t),s={},r=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(s.video=n.video||e.main.videoCodec||l0),e.main.isMuxed&&(s.video+=`,${n.audio||e.main.audioCodec||Eu}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||r)&&(s.audio=n.audio||e.main.audioCodec||e.audio.audioCodec||Eu,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!s.audio&&!s.video){this.excludePlaylist({playlistToExclude:t,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0});return}const a=(g,m)=>g?rs(m,this.usingManagedMediaSource_):Pa(m),l={};let c;if(["video","audio"].forEach(function(g){if(s.hasOwnProperty(g)&&!a(e[g].isFmp4,s[g])){const m=e[g].isFmp4?"browser":"muxer";l[m]=l[m]||[],l[m].push(s[g]),g==="audio"&&(c=m)}}),r&&c&&t.attributes.AUDIO){const g=t.attributes.AUDIO;this.main().playlists.forEach(m=>{(m.attributes&&m.attributes.AUDIO)===g&&m!==t&&(m.excludeUntil=1/0)}),this.logger_(`excluding audio group ${g} as ${c} does not support codec(s): "${s.audio}"`)}if(Object.keys(l).length){const g=Object.keys(l).reduce((m,b)=>(m&&(m+=", "),m+=`${b} does not support codec(s): "${l[b].join(",")}"`,m),"")+".";this.excludePlaylist({playlistToExclude:t,error:{internal:!0,message:g},playlistExclusionDuration:1/0});return}if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){const g=[];if(["video","audio"].forEach(m=>{const b=(Ht(this.sourceUpdater_.codecs[m]||"")[0]||{}).type,C=(Ht(s[m]||"")[0]||{}).type;b&&C&&b.toLowerCase()!==C.toLowerCase()&&g.push(`"${this.sourceUpdater_.codecs[m]}" -> "${s[m]}"`)}),g.length){this.excludePlaylist({playlistToExclude:t,error:{message:`Codec switching not supported: ${g.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0});return}}return s}tryToCreateSourceBuffers_(){if(this.mediaSource.readyState!=="open"||this.sourceUpdater_.hasCreatedSourceBuffers()||!this.areMediaTypesKnown_())return;const e=this.getCodecsOrExclude_();if(!e)return;this.sourceUpdater_.createSourceBuffers(e);const t=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(t)}excludeUnsupportedVariants_(){const e=this.main().playlists,t=[];Object.keys(e).forEach(n=>{const s=e[n];if(t.indexOf(s.id)!==-1)return;t.push(s.id);const r=ds(this.main,s),a=[];r.audio&&!Pa(r.audio)&&!rs(r.audio,this.usingManagedMediaSource_)&&a.push(`audio codec ${r.audio}`),r.video&&!Pa(r.video)&&!rs(r.video,this.usingManagedMediaSource_)&&a.push(`video codec ${r.video}`),r.text&&r.text==="stpp.ttml.im1t"&&a.push(`text codec ${r.text}`),a.length&&(s.excludeUntil=1/0,this.logger_(`excluding ${s.id} for unsupported: ${a.join(", ")}`))})}excludeIncompatibleVariants_(e){const t=[],n=this.main().playlists,s=Ir(Ht(e)),r=gd(s),a=s.video&&Ht(s.video)[0]||null,l=s.audio&&Ht(s.audio)[0]||null;Object.keys(n).forEach(c=>{const g=n[c];if(t.indexOf(g.id)!==-1||g.excludeUntil===1/0)return;t.push(g.id);const m=[],b=ds(this.mainPlaylistLoader_.main,g),C=gd(b);if(!(!b.audio&&!b.video)){if(C!==r&&m.push(`codec count "${C}" !== "${r}"`),!this.sourceUpdater_.canChangeType()){const w=b.video&&Ht(b.video)[0]||null,A=b.audio&&Ht(b.audio)[0]||null;w&&a&&w.type.toLowerCase()!==a.type.toLowerCase()&&m.push(`video codec "${w.type}" !== "${a.type}"`),A&&l&&A.type.toLowerCase()!==l.type.toLowerCase()&&m.push(`audio codec "${A.type}" !== "${l.type}"`)}m.length&&(g.excludeUntil=1/0,this.logger_(`excluding ${g.id}: ${m.join(" && ")}`))}})}updateAdCues_(e){let t=0;const n=this.seekable();n.length&&(t=n.start(0)),Kv(e,this.cueTagsTrack_,t)}goalBufferLength(){const e=this.tech_.currentTime(),t=We.GOAL_BUFFER_LENGTH,n=We.GOAL_BUFFER_LENGTH_RATE,s=Math.max(t,We.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*n,s)}bufferLowWaterLine(){const e=this.tech_.currentTime(),t=We.BUFFER_LOW_WATER_LINE,n=We.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(t,We.MAX_BUFFER_LOW_WATER_LINE),r=Math.max(t,We.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*n,this.bufferBasedABR?r:s)}bufferHighWaterLine(){return We.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){_d(this.inbandTextTracks_,"com.apple.streaming",this.tech_),xv({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,t,n){const s=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();_d(this.inbandTextTracks_,e,this.tech_),kv({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:s,videoDuration:n})}pathwayAttribute_(e){return e.attributes["PATHWAY-ID"]||e.attributes.serviceLocation}initContentSteeringController_(){const e=this.main();if(e.contentSteering){for(const t of e.playlists)this.contentSteeringController_.addAvailablePathway(this.pathwayAttribute_(t));if(this.contentSteeringController_.assignTagProperties(e.uri,e.contentSteering),this.contentSteeringController_.queryBeforeStart){this.contentSteeringController_.requestSteeringManifest(!0);return}this.tech_.one("canplay",()=>{this.contentSteeringController_.requestSteeringManifest()})}}resetContentSteeringController_(){this.contentSteeringController_.clearAvailablePathways(),this.contentSteeringController_.dispose(),this.initContentSteeringController_()}attachContentSteeringListeners_(){this.contentSteeringController_.on("content-steering",this.excludeThenChangePathway_.bind(this)),["contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"].forEach(e=>{this.contentSteeringController_.on(e,t=>{this.trigger(je({},t))})}),this.sourceType_==="dash"&&this.mainPlaylistLoader_.on("loadedplaylist",()=>{const e=this.main();(this.contentSteeringController_.didDASHTagChange(e.uri,e.contentSteering)||(()=>{const t=this.contentSteeringController_.getAvailablePathways(),n=[];for(const s of e.playlists){const r=s.attributes.serviceLocation;if(r&&(n.push(r),!t.has(r)))return!0}return!!(!n.length&&t.size)})())&&this.resetContentSteeringController_()})}excludeThenChangePathway_(){const e=this.contentSteeringController_.getPathway();if(!e)return;this.handlePathwayClones_();const t=this.main().playlists,n=new Set;let s=!1;Object.keys(t).forEach(r=>{const a=t[r],l=this.pathwayAttribute_(a),c=l&&e!==l;a.excludeUntil===1/0&&a.lastExcludeReason_==="content-steering"&&!c&&(delete a.excludeUntil,delete a.lastExcludeReason_,s=!0);const g=!a.excludeUntil&&a.excludeUntil!==1/0;!n.has(a.id)&&c&&g&&(n.add(a.id),a.excludeUntil=1/0,a.lastExcludeReason_="content-steering",this.logger_(`excluding ${a.id} for ${a.lastExcludeReason_}`))}),this.contentSteeringController_.manifestType_==="DASH"&&Object.keys(this.mediaTypes_).forEach(r=>{const a=this.mediaTypes_[r];if(a.activePlaylistLoader){const l=a.activePlaylistLoader.media_;l&&l.attributes.serviceLocation!==e&&(s=!0)}}),s&&this.changeSegmentPathway_()}handlePathwayClones_(){const e=this.main().playlists,t=this.contentSteeringController_.currentPathwayClones,n=this.contentSteeringController_.nextPathwayClones;if(t&&t.size||n&&n.size){for(const[s,r]of t.entries())n.get(s)||(this.mainPlaylistLoader_.updateOrDeleteClone(r),this.contentSteeringController_.excludePathway(s));for(const[s,r]of n.entries()){const a=t.get(s);if(!a){e.filter(l=>l.attributes["PATHWAY-ID"]===r["BASE-ID"]).forEach(l=>{this.mainPlaylistLoader_.addClonePathway(r,l)}),this.contentSteeringController_.addAvailablePathway(s);continue}this.equalPathwayClones_(a,r)||(this.mainPlaylistLoader_.updateOrDeleteClone(r,!0),this.contentSteeringController_.addAvailablePathway(s))}this.contentSteeringController_.currentPathwayClones=new Map(JSON.parse(JSON.stringify([...n])))}}equalPathwayClones_(e,t){if(e["BASE-ID"]!==t["BASE-ID"]||e.ID!==t.ID||e["URI-REPLACEMENT"].HOST!==t["URI-REPLACEMENT"].HOST)return!1;const n=e["URI-REPLACEMENT"].PARAMS,s=t["URI-REPLACEMENT"].PARAMS;for(const r in n)if(n[r]!==s[r])return!1;for(const r in s)if(n[r]!==s[r])return!1;return!0}changeSegmentPathway_(){const e=this.selectPlaylist();this.pauseLoading(),this.contentSteeringController_.manifestType_==="DASH"&&this.switchMediaForDASHContentSteering_(),this.switchMedia_(e,"content-steering")}excludeNonUsablePlaylistsByKeyId_(){if(!this.mainPlaylistLoader_||!this.mainPlaylistLoader_.main)return;let e=0;const t="non-usable";this.mainPlaylistLoader_.main.playlists.forEach(n=>{const s=this.mainPlaylistLoader_.getKeyIdSet(n);!s||!s.size||s.forEach(r=>{const a="usable",l=this.keyStatusMap_.has(r)&&this.keyStatusMap_.get(r)===a,c=n.lastExcludeReason_===t&&n.excludeUntil===1/0;l?l&&c&&(delete n.excludeUntil,delete n.lastExcludeReason_,this.logger_(`enabling playlist ${n.id} because key ID ${r} is ${a}`)):(n.excludeUntil!==1/0&&n.lastExcludeReason_!==t&&(n.excludeUntil=1/0,n.lastExcludeReason_=t,this.logger_(`excluding playlist ${n.id} because the key ID ${r} doesn't exist in the keyStatusMap or is not ${a}`)),e++)})}),e>=this.mainPlaylistLoader_.main.playlists.length&&this.mainPlaylistLoader_.main.playlists.forEach(n=>{const s=n&&n.attributes&&n.attributes.RESOLUTION&&n.attributes.RESOLUTION.height<720,r=n.excludeUntil===1/0&&n.lastExcludeReason_===t;s&&r&&(delete n.excludeUntil,B.log.warn(`enabling non-HD playlist ${n.id} because all playlists were excluded due to ${t} key IDs`))})}addKeyStatus_(e,t){const n=(typeof e=="string"?e:zv(e)).slice(0,32).toLowerCase();this.logger_(`KeyStatus '${t}' with key ID ${n} added to the keyStatusMap`),this.keyStatusMap_.set(n,t)}updatePlaylistByKeyStatus(e,t){this.addKeyStatus_(e,t),this.waitingForFastQualityPlaylistReceived_||this.excludeNonUsableThenChangePlaylist_(),this.mainPlaylistLoader_.off("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this)),this.mainPlaylistLoader_.on("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this))}excludeNonUsableThenChangePlaylist_(){this.excludeNonUsablePlaylistsByKeyId_(),this.fastQualityChange_()}}const bS=(i,e,t)=>n=>{const s=i.main.playlists[e],r=hl(s),a=ta(s);if(typeof n>"u")return a;n?delete s.disabled:s.disabled=!0;const l={renditionInfo:{id:e,bandwidth:s.attributes.BANDWIDTH,resolution:s.attributes.RESOLUTION,codecs:s.attributes.CODECS},cause:"fast-quality"};return n!==a&&!r&&(n?(t(s),i.trigger({type:"renditionenabled",metadata:l})):i.trigger({type:"renditiondisabled",metadata:l})),n};class TS{constructor(e,t,n){const{playlistController_:s}=e,r=s.fastQualityChange_.bind(s);if(t.attributes){const a=t.attributes.RESOLUTION;this.width=a&&a.width,this.height=a&&a.height,this.bandwidth=t.attributes.BANDWIDTH,this.frameRate=t.attributes["FRAME-RATE"]}this.codecs=ds(s.main(),t),this.playlist=t,this.id=n,this.enabled=bS(e.playlists,t.id,r)}}const vS=function(i){i.representations=()=>{const e=i.playlistController_.main(),t=vs(e)?i.playlistController_.getAudioTrackPlaylists_():e.playlists;return t?t.filter(n=>!hl(n)).map((n,s)=>new TS(i,n,n.id)):[]}},Ad=["seeking","seeked","pause","playing","error"];class SS extends B.EventTarget{constructor(e){super(),this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.playedRanges_=[],this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=Lt("PlaybackWatcher"),this.logger_("initialize");const t=()=>this.monitorCurrentTime_(),n=()=>this.monitorCurrentTime_(),s=()=>this.techWaiting_(),r=()=>this.resetTimeUpdate_(),a=this.playlistController_,l=["main","subtitle","audio"],c={};l.forEach(m=>{c[m]={reset:()=>this.resetSegmentDownloads_(m),updateend:()=>this.checkSegmentDownloads_(m)},a[`${m}SegmentLoader_`].on("appendsdone",c[m].updateend),a[`${m}SegmentLoader_`].on("playlistupdate",c[m].reset),this.tech_.on(["seeked","seeking"],c[m].reset)});const g=m=>{["main","audio"].forEach(b=>{a[`${b}SegmentLoader_`][m]("appended",this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),g("off"))},this.clearSeekingAppendCheck_=()=>g("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),g("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",s),this.tech_.on(Ad,r),this.tech_.on("canplay",n),this.tech_.one("play",t),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",s),this.tech_.off(Ad,r),this.tech_.off("canplay",n),this.tech_.off("play",t),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),l.forEach(m=>{a[`${m}SegmentLoader_`].off("appendsdone",c[m].updateend),a[`${m}SegmentLoader_`].off("playlistupdate",c[m].reset),this.tech_.off(["seeked","seeking"],c[m].reset)}),this.checkCurrentTimeTimeout_&&x.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&x.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=x.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){const t=this.playlistController_[`${e}SegmentLoader_`];this[`${e}StalledDownloads_`]>0&&this.logger_(`resetting possible stalled download count for ${e} loader`),this[`${e}StalledDownloads_`]=0,this[`${e}Buffered_`]=t.buffered_()}checkSegmentDownloads_(e){const t=this.playlistController_,n=t[`${e}SegmentLoader_`],s=n.buffered_(),r=aT(this[`${e}Buffered_`],s);if(this[`${e}Buffered_`]=s,r){const a={bufferedRanges:s};t.trigger({type:"bufferedrangeschanged",metadata:a}),this.resetSegmentDownloads_(e);return}this[`${e}StalledDownloads_`]++,this.logger_(`found #${this[`${e}StalledDownloads_`]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:n.playlist_&&n.playlist_.id,buffered:Ui(s)}),!(this[`${e}StalledDownloads_`]<10)&&(this.logger_(`${e} loader stalled download exclusion`),this.resetSegmentDownloads_(e),this.tech_.trigger({type:"usage",name:`vhs-${e}-download-exclusion`}),e!=="subtitle"&&t.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0}))}checkCurrentTime_(){if(this.tech_.paused()||this.tech_.seeking())return;const e=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===e&&(!t.length||e+Kt>=t.end(t.length-1)))return this.techWaiting_();if(this.consecutiveUpdates>=5&&e===this.lastRecordedTime)this.consecutiveUpdates++,this.waiting_();else if(e===this.lastRecordedTime)this.consecutiveUpdates++;else{this.playedRanges_.push(tt([this.lastRecordedTime,e]));const n={playedRanges:this.playedRanges_};this.playlistController_.trigger({type:"playedrangeschanged",metadata:n}),this.consecutiveUpdates=0,this.lastRecordedTime=e}}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;const e=this.seekable(),t=this.tech_.currentTime(),n=this.afterSeekableWindow_(e,t,this.media(),this.allowSeeksWithinUnsafeLiveWindow);let s;if(n&&(s=e.end(e.length-1)),this.beforeSeekableWindow_(e,t)){const w=e.start(0);s=w+(w===e.end(0)?0:Kt)}if(typeof s<"u")return this.logger_(`Trying to seek outside of seekable at time ${t} with seekable range ${Wc(e)}. Seeking to ${s}.`),this.tech_.setCurrentTime(s),!0;const r=this.playlistController_.sourceUpdater_,a=this.tech_.buffered(),l=r.audioBuffer?r.audioBuffered():null,c=r.videoBuffer?r.videoBuffered():null,g=this.media(),m=g.partTargetDuration?g.partTargetDuration:(g.targetDuration-Xt)*2,b=[l,c];for(let w=0;w<b.length;w++)if(b[w]&&ul(b[w],t)<m)return!1;const C=Zs(a,t);return C.length===0?!1:(s=C.start(0)+Kt,this.logger_(`Buffered region starts (${C.start(0)}) just beyond seek point (${t}). Seeking to ${s}.`),this.tech_.setCurrentTime(s),!0)}waiting_(){if(this.techWaiting_())return;const e=this.tech_.currentTime(),t=this.tech_.buffered(),n=tn(t,e);if(n.length&&e+3<=n.end(0)){this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${n.start(0)} -> ${n.end(0)}]. Attempting to resume playback by seeking to the current time.`),this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"});return}}techWaiting_(){const e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking())return!0;if(this.beforeSeekableWindow_(e,t)){const a=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${t}. Seeking to live point (seekable end) ${a}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(a),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0}const n=this.tech_.vhs.playlistController_.sourceUpdater_,s=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:n.audioBuffered(),videoBuffered:n.videoBuffered(),currentTime:t}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0;const r=Zs(s,t);return r.length>0?(this.logger_(`Stopped at ${t} and seeking to ${r.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(t),!0):!1}afterSeekableWindow_(e,t,n,s=!1){if(!e.length)return!1;let r=e.end(e.length-1)+Kt;const a=!n.endList,l=typeof n.partTargetDuration=="number";return a&&(l||s)&&(r=e.end(e.length-1)+n.targetDuration*3),t>r}beforeSeekableWindow_(e,t){return!!(e.length&&e.start(0)>0&&t<e.start(0)-this.liveRangeSafeTimeDelta)}videoUnderflow_({videoBuffered:e,audioBuffered:t,currentTime:n}){if(!e)return;let s;if(e.length&&t.length){const r=tn(e,n-3),a=tn(e,n),l=tn(t,n);l.length&&!a.length&&r.length&&(s={start:r.end(0),end:l.end(0)})}else Zs(e,n).length||(s=this.gapFromVideoUnderflow_(e,n));return s?(this.logger_(`Encountered a gap in video from ${s.start} to ${s.end}. Seeking to current time ${n}`),!0):!1}skipTheGap_(e){const t=this.tech_.buffered(),n=this.tech_.currentTime(),s=Zs(t,n);if(this.resetTimeUpdate_(),s.length===0||n!==e)return;this.logger_("skipTheGap_:","currentTime:",n,"scheduled currentTime:",e,"nextRange start:",s.start(0)),this.tech_.setCurrentTime(s.start(0)+Xt);const r={gapInfo:{from:n,to:s.start(0)}};this.playlistController_.trigger({type:"gapjumped",metadata:r}),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"})}gapFromVideoUnderflow_(e,t){const n=nT(e);for(let s=0;s<n.length;s++){const r=n.start(s),a=n.end(s);if(t-r<4&&t-r>2)return{start:r,end:a}}return null}}const ES={errorInterval:30,getSource(i){const e=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return i(e)}},Up=function(i,e){let t=0,n=0;const s=ge(ES,e);i.ready(()=>{i.trigger({type:"usage",name:"vhs-error-reload-initialized"})});const r=function(){n&&i.currentTime(n)},a=function(m){m!=null&&(n=i.duration()!==1/0&&i.currentTime()||0,i.one("loadedmetadata",r),i.src(m),i.trigger({type:"usage",name:"vhs-error-reload"}),i.play())},l=function(){if(Date.now()-t<s.errorInterval*1e3){i.trigger({type:"usage",name:"vhs-error-reload-canceled"});return}if(!s.getSource||typeof s.getSource!="function"){B.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),s.getSource.call(i,a)},c=function(){i.off("loadedmetadata",r),i.off("error",l),i.off("dispose",c)},g=function(m){c(),Up(i,m)};i.on("error",l),i.on("dispose",c),i.reloadSourceOnError=g},wS=function(i){Up(this,i)};var Np="3.16.2",kS="7.1.0",CS="1.3.1",IS="7.2.0",xS="4.0.2";const Oe={PlaylistLoader:nn,Playlist:ft,utils:PT,STANDARD_PLAYLIST_SELECTOR:yd,INITIAL_PLAYLIST_SELECTOR:Tv,lastBandwidthSelector:yd,movingAverageBandwidthSelector:_v,comparePlaylistBandwidth:fl,comparePlaylistResolution:yv,xhr:up()};Object.keys(We).forEach(i=>{Object.defineProperty(Oe,i,{get(){return B.log.warn(`using Vhs.${i} is UNSAFE be sure you know what you are doing`),We[i]},set(e){if(B.log.warn(`using Vhs.${i} is UNSAFE be sure you know what you are doing`),typeof e!="number"||e<0){B.log.warn(`value of Vhs.${i} must be greater than or equal to 0`);return}We[i]=e}})});const Bp="videojs-vhs",Fp=function(i,e){const t=e.media();let n=-1;for(let s=0;s<i.length;s++)if(i[s].id===t.id){n=s;break}i.selectedIndex_=n,i.trigger({selectedIndex:n,type:"change"})},AS=function(i,e){e.representations().forEach(t=>{i.addQualityLevel(t)}),Fp(i,e.playlists)};Oe.canPlaySource=function(){return B.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const PS=(i,e,t)=>{if(!i)return i;let n={};e&&e.attributes&&e.attributes.CODECS&&(n=Ir(Ht(e.attributes.CODECS))),t&&t.attributes&&t.attributes.CODECS&&(n.audio=t.attributes.CODECS);const s=cn(n.video),r=cn(n.audio),a={};for(const l in i)a[l]={},r&&(a[l].audioContentType=r),s&&(a[l].videoContentType=s),e.contentProtection&&e.contentProtection[l]&&e.contentProtection[l].pssh&&(a[l].pssh=e.contentProtection[l].pssh),typeof i[l]=="string"&&(a[l].url=i[l]);return ge(i,a)},LS=(i,e)=>i.reduce((t,n)=>{if(!n.contentProtection)return t;const s=e.reduce((r,a)=>{const l=n.contentProtection[a];return l&&l.pssh&&(r[a]={pssh:l.pssh}),r},{});return Object.keys(s).length&&t.push(s),t},[]),DS=({player:i,sourceKeySystems:e,audioMedia:t,mainPlaylists:n})=>{if(!i.eme.initializeMediaKeys)return Promise.resolve();const s=t?n.concat([t]):n,r=LS(s,Object.keys(e)),a=[],l=[];return r.forEach(c=>{l.push(new Promise((g,m)=>{i.tech_.one("keysessioncreated",g)})),a.push(new Promise((g,m)=>{i.eme.initializeMediaKeys({keySystems:c},b=>{if(b){m(b);return}g()})}))}),Promise.race([Promise.all(a),Promise.race(l)])},OS=({player:i,sourceKeySystems:e,media:t,audioMedia:n})=>{const s=PS(e,t,n);return s?(i.currentSource().keySystems=s,s&&!i.eme?(B.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),!1):!0):!1},jp=()=>{if(!x.localStorage)return null;const i=x.localStorage.getItem(Bp);if(!i)return null;try{return JSON.parse(i)}catch{return null}},MS=i=>{if(!x.localStorage)return!1;let e=jp();e=e?ge(e,i):i;try{x.localStorage.setItem(Bp,JSON.stringify(e))}catch{return!1}return e},RS=i=>i.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0?JSON.parse(i.substring(i.indexOf(",")+1)):i,$p=(i,e)=>{i._requestCallbackSet||(i._requestCallbackSet=new Set),i._requestCallbackSet.add(e)},qp=(i,e)=>{i._responseCallbackSet||(i._responseCallbackSet=new Set),i._responseCallbackSet.add(e)},Vp=(i,e)=>{i._requestCallbackSet&&(i._requestCallbackSet.delete(e),i._requestCallbackSet.size||delete i._requestCallbackSet)},Hp=(i,e)=>{i._responseCallbackSet&&(i._responseCallbackSet.delete(e),i._responseCallbackSet.size||delete i._responseCallbackSet)};Oe.supportsNativeHls=function(){if(!G||!G.createElement)return!1;const i=G.createElement("video");return B.getTech("Html5").isSupported()?["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some(function(e){return/maybe|probably/i.test(i.canPlayType(e))}):!1}();Oe.supportsNativeDash=function(){return!G||!G.createElement||!B.getTech("Html5").isSupported()?!1:/maybe|probably/i.test(G.createElement("video").canPlayType("application/dash+xml"))}();Oe.supportsTypeNatively=i=>i==="hls"?Oe.supportsNativeHls:i==="dash"?Oe.supportsNativeDash:!1;Oe.isSupported=function(){return B.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};Oe.xhr.onRequest=function(i){$p(Oe.xhr,i)};Oe.xhr.onResponse=function(i){qp(Oe.xhr,i)};Oe.xhr.offRequest=function(i){Vp(Oe.xhr,i)};Oe.xhr.offResponse=function(i){Hp(Oe.xhr,i)};const US=B.getComponent("Component");class zp extends US{constructor(e,t,n){if(super(t,n.vhs),typeof n.initialBandwidth=="number"&&(this.options_.bandwidth=n.initialBandwidth),this.logger_=Lt("VhsHandler"),t.options_&&t.options_.playerId){const s=B.getPlayer(t.options_.playerId);this.player_=s}if(this.tech_=t,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native VHS requires emulated tracks. See https://git.io/vMpjB");this.on(G,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],s=>{const r=G.fullscreenElement||G.webkitFullscreenElement||G.mozFullScreenElement||G.msFullscreenElement;r&&r.contains(this.tech_.el())?this.playlistController_.fastQualityChange_():this.playlistController_.checkABR_()}),this.on(this.tech_,"seeking",function(){if(this.ignoreNextSeekingEvent_){this.ignoreNextSeekingEvent_=!1;return}this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){this.tech_.error()&&this.playlistController_&&this.playlistController_.pauseLoading()}),this.on(this.tech_,"play",this.play)}setOptions_(e={}){if(this.options_=ge(this.options_,e),this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.useForcedSubtitles=this.options_.useForcedSubtitles||!1,this.options_.useNetworkInformationApi=this.options_.useNetworkInformationApi||!1,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=this.options_.llhls!==!1,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,typeof this.options_.playlistExclusionDuration!="number"&&(this.options_.playlistExclusionDuration=60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){const n=jp();n&&n.bandwidth&&(this.options_.bandwidth=n.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"})),n&&n.throughput&&(this.options_.throughput=n.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=We.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===We.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","customPixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useForcedSubtitles","useNetworkInformationApi","useDtsForTimestampOffset","exactManifestTimings","leastPixelDiffSelector"].forEach(n=>{typeof this.source_[n]<"u"&&(this.options_[n]=this.source_[n])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio;const t=this.options_.customPixelRatio;typeof t=="number"&&t>=0&&(this.customPixelRatio=t)}setOptions(e={}){this.setOptions_(e)}src(e,t){if(!e)return;this.setOptions_(),this.options_.src=RS(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=Oe,this.options_.sourceType=hh(t),this.options_.seekTo=r=>{this.tech_.setCurrentTime(r)},this.options_.player_=this.player_,this.playlistController_=new _S(this.options_);const n=ge({liveRangeSafeTimeDelta:Kt},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new SS(n),this.attachStreamingEventListeners_(),this.playlistController_.on("error",()=>{const r=B.players[this.tech_.options_.playerId];let a=this.playlistController_.error;typeof a=="object"&&!a.code?a.code=3:typeof a=="string"&&(a={message:a,code:3}),r.error(a)});const s=this.options_.bufferBasedABR?Oe.movingAverageBandwidthSelector(.55):Oe.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):s.bind(this),this.playlistController_.selectInitialPlaylist=Oe.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(r){this.playlistController_.selectPlaylist=r.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(r){this.playlistController_.mainSegmentLoader_.throughput.rate=r,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let r=this.playlistController_.mainSegmentLoader_.bandwidth;const a=x.navigator.connection||x.navigator.mozConnection||x.navigator.webkitConnection,l=1e7;if(this.options_.useNetworkInformationApi&&a){const c=a.downlink*1e3*1e3;c>=l&&r>=l?r=Math.max(r,c):r=c}return r},set(r){this.playlistController_.mainSegmentLoader_.bandwidth=r,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){const r=1/(this.bandwidth||1);let a;return this.throughput>0?a=1/this.throughput:a=0,Math.floor(1/(r+a))},set(){B.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>Ui(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>Ui(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one("canplay",this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on("bandwidthupdate",()=>{this.options_.useBandwidthFromLocalStorage&&MS({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{vS(this)}),this.playlistController_.sourceUpdater_.on("createdsourcebuffers",()=>{this.setupEme_()}),this.on(this.playlistController_,"progress",function(){this.tech_.trigger("progress")}),this.on(this.playlistController_,"firstplay",function(){this.ignoreNextSeekingEvent_=!0}),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=x.URL.createObjectURL(this.playlistController_.mediaSource),(B.browser.IS_ANY_SAFARI||B.browser.IS_IOS)&&this.options_.overrideNative&&this.options_.sourceType==="hls"&&typeof this.tech_.addSourceElement=="function"?(this.tech_.addSourceElement(this.mediaSourceUrl_),this.tech_.addSourceElement(this.source_.src)):this.tech_.src(this.mediaSourceUrl_))}createKeySessions_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_("waiting for EME key session creation"),DS({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then(()=>{this.logger_("created EME key session"),this.playlistController_.sourceUpdater_.initializedEme()}).catch(t=>{this.logger_("error while creating EME key session",t),this.player_.error({message:"Failed to initialize media keys for EME",code:3})})}handleWaitingForKey_(){this.logger_("waitingforkey fired, attempting to create any new key sessions"),this.createKeySessions_()}setupEme_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,t=OS({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});if(this.player_.tech_.on("keystatuschange",n=>{this.playlistController_.updatePlaylistByKeyStatus(n.keyId,n.status)}),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on("waitingforkey",this.handleWaitingForKey_),!t){this.playlistController_.sourceUpdater_.initializedEme();return}this.createKeySessions_()}setupQualityLevels_(){const e=B.players[this.tech_.options_.playerId];!e||!e.qualityLevels||this.qualityLevels_||(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{AS(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{Fp(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":Np,"mux.js":kS,"mpd-parser":CS,"m3u8-parser":IS,"aes-decrypter":xS}}version(){return this.constructor.version()}canChangeType(){return Dp.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.playlistController_&&this.playlistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.mediaSourceUrl_&&x.URL.revokeObjectURL&&(x.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,t){return NT({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,n=!0,s=2){return fp({programTime:e,playlist:this.playlistController_.media(),retryCount:s,pauseAfterSeek:n,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}setupXhrHooks_(){this.xhr.onRequest=e=>{$p(this.xhr,e)},this.xhr.onResponse=e=>{qp(this.xhr,e)},this.xhr.offRequest=e=>{Vp(this.xhr,e)},this.xhr.offResponse=e=>{Hp(this.xhr,e)},this.player_.trigger("xhr-hooks-ready")}attachStreamingEventListeners_(){const e=["seekablerangeschanged","bufferedrangeschanged","contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"],t=["gapjumped","playedrangeschanged"];e.forEach(n=>{this.playlistController_.on(n,s=>{this.player_.trigger(je({},s))})}),t.forEach(n=>{this.playbackWatcher_.on(n,s=>{this.player_.trigger(je({},s))})})}}const Pr={name:"videojs-http-streaming",VERSION:Np,canHandleSource(i,e={}){const t=ge(B.options,e);return!t.vhs.experimentalUseMMS&&!rs("avc1.4d400d,mp4a.40.2",!1)?!1:Pr.canPlayType(i.type,t)},handleSource(i,e,t={}){const n=ge(B.options,t);return e.vhs=new zp(i,e,n),e.vhs.xhr=up(),e.vhs.setupXhrHooks_(),e.vhs.src(i.src,i.type),e.vhs},canPlayType(i,e){const t=hh(i);if(!t)return"";const n=Pr.getOverrideNative(e);return!Oe.supportsTypeNatively(t)||n?"maybe":""},getOverrideNative(i={}){const{vhs:e={}}=i,t=!(B.browser.IS_ANY_SAFARI||B.browser.IS_IOS),{overrideNative:n=t}=e;return n}},NS=()=>rs("avc1.4d400d,mp4a.40.2",!0);NS()&&B.getTech("Html5").registerSourceHandler(Pr,0);B.VhsHandler=zp;B.VhsSourceHandler=Pr;B.Vhs=Oe;B.use||B.registerComponent("Vhs",Oe);B.options.vhs=B.options.vhs||{};(!B.getPlugin||!B.getPlugin("reloadSourceOnError"))&&B.registerPlugin("reloadSourceOnError",wS);const BS=i=>{const e=_e.useRef();return _e.useEffect(()=>{if(!e.current&&i.current){const t=document.createElement("video-js");t.classList.add("vjs-big-play-centered"),i.current.appendChild(t),e.current=B(t,{controls:!1,playsinline:!0})}return()=>{e.current&&(e.current.dispose(),e.current=void 0)}},[]),e},Wp={time:0,adCount:0,adPosition:0,skipDelay:0,playing:!1,paused:!1,reset:()=>{},whyThisAd:null,hasAdUrl:!1,adAction:i=>{},playMuted:!1,muted:!1,autoplay:!0},xe=W.i(Wp),Pd=i=>{if(!i)return 0;const e=i.duration(),t=i.currentTime();return e===void 0||isNaN(e)||t===void 0||isNaN(t)?0:Math.round(e-t)},FS=(i,e)=>{const t=qy(i,e),n=BS(i),s=_e.useRef(),r=_e.useRef(!1),a=_e.useRef(!1),l=_e.useCallback(()=>{if(a.current)return;const w=t.get().nonceManager;if(w&&r.current)try{w.sendPlaybackEnd()}catch(A){console.warn("[PAL] sendPlaybackEnd failed",A)}a.current=!0},[t]),c=_e.useCallback(()=>{l(),n.current&&(n.current.pause(),n.current.src(void 0)),s.current=void 0,xe.set({...Wp,reset:c})},[n,l]);_e.useEffect(()=>{xe.setKey("reset",c)},[c]);const g=_e.useCallback(()=>{var w,A,v;const{adPosition:M,adCount:D}=xe.get();if(n.current){if(M<D){const R=M+1,{ads:N,muted:F,autoplay:P,nonceManager:$}=t.get(),Y=N[R-1];if(Y){(w=s.current)==null||w.complete(),s.current=new Md.ue(null,Y.ad,Y.creative),s.current.on("clickthrough",X=>{if($)try{$.sendAdClick()}catch(re){console.warn("[PAL] sendAdClick failed",re)}window.open(X,"_blank")}),xe.setKey("adPosition",R),xe.setKey("playMuted",F),xe.setKey("skipDelay",Y.creative.skipDelay||0),xe.setKey("time",0),xe.setKey("adAction",X=>{s.current&&s.current.click(null,{CLICKPOS:[X.clientX,X.clientY]})}),xe.setKey("whyThisAd",Y.creative.icons.find(X=>X.program==="GoogleWhyThisAd")||null),xe.setKey("hasAdUrl",!!((A=Y.creative.videoClickThroughURLTemplate)!=null&&A.url)),n.current.src(Y.mediaFileUrl),xe.setKey("playing",!0),M===0?(xe.setKey("muted",F),xe.setKey("autoplay",P),F&&n.current.muted(!0),P?n.current.play():(n.current.pause(),xe.setKey("paused",!0))):n.current.play();return}}(v=s.current)==null||v.complete(),c()}},[n,c,t]),m=_e.useCallback(()=>{if(!n.current)return;const w=n.current.muted();n.current.muted(!w),xe.setKey("muted",!w),s.current&&s.current.setMuted(!w)},[n]),b=_e.useCallback(()=>{n.current&&(n.current.paused()?(n.current.play(),s.current&&s.current.setPaused(!1)):(n.current.pause(),s.current&&s.current.setPaused(!0)))},[n]),C=_e.useCallback(()=>{n.current&&(s.current&&s.current.skip(),g())},[g,n]);return _e.useEffect(()=>{const w=n.current;if(!w)return()=>{};const A=P=>{if(xe.setKey("playing",!0),xe.setKey("paused",!1),xe.setKey("time",Pd(P.target.player)),!r.current){const $=t.get().nonceManager;if($)try{$.sendPlaybackStart(),r.current=!0,a.current=!1}catch(Y){console.warn("[PAL] sendPlaybackStart failed",Y)}}},v=()=>{var P;(P=s.current)==null||P.complete(),g()},M=P=>{xe.setKey("muted",P.target.player.muted())},D=()=>{xe.setKey("paused",!0)},R=P=>{P.target.tagName==="VIDEO"&&(xe.get().autoplay||b())},N=P=>{xe.setKey("time",Pd(P.target.player)),s.current&&s.current.setProgress(P.target.player.currentTime())},F=()=>{c()};return w.on("play",A),w.on("ended",v),w.on("muted",M),w.on("pause",D),w.on("click",R),w.on("timeupdate",N),w.on("error",F),()=>{w.off("play",A),w.off("ended",v),w.off("muted",M),w.off("pause",D),w.off("click",R),w.off("timeupdate",N),w.off("error",F)}},[b,g,n,c,t]),_e.useEffect(()=>t.subscribe(w=>{w&&(r.current=!1,a.current=!1,xe.setKey("adCount",w.ads.length),xe.setKey("adPosition",0),g())}),[t,n,g]),_e.useEffect(()=>()=>{c()},[c]),[xe,m,b,C,s]},jS=({promotion:i,onClose:e,promotionId:t,externalAd:n,skipAutoClose:s})=>{var r,a,l,c,g;const m=_e.useRef(null),[b,C,w,A]=FS(m,n==null?void 0:n.url),{time:v,adCount:M,adPosition:D,skipDelay:R,playing:N,paused:F,reset:P,muted:$,playMuted:Y,autoplay:X,whyThisAd:re,hasAdUrl:ce,adAction:be}=W.useStore(b),he=((r=i.sponsor)==null?void 0:r.logo)&&i.logoMode===oe.PromotionLogoMode.CENTER;return z.jsxs($d,{className:"PromoOverlay",children:[z.jsxs(qd,{children:[z.jsx(Vd,{className:W.cx_default(!he&&Hd),children:z.jsx(Wd,{style:{transform:"scale(1.5)"},children:"Ad"})}),z.jsxs(Oy,{children:[z.jsx(wy,{time:v,adCount:M,adPosition:D}),!!R&&N&&z.jsx(W.y,{timerClassName:"SkipTimerCount",className:"ClosePromoIcon",close:()=>{A()},duration:R,isPlaying:!F,skipIcon:!0}),s&&z.jsx(W.y,{className:"ClosePromoIcon",close:()=>{P(),e==null||e()}})]})]}),z.jsx(zd,{className:W.cx_default(uu,N&&du,!N&&hu),children:z.jsxs(Dy,{ref:m,children:[re&&z.jsx(Cy,{whyThisAd:re}),z.jsxs(Iy,{style:(re==null?void 0:re.xPosition)==="right"?{left:"8px"}:{right:"8px"},children:[Y&&z.jsx(Ay,{className:W.cx_default(!$&&"muted"),onClick:()=>C()}),F&&!X&&z.jsx(Ly,{onClick:()=>w()})]})]})}),ce&&z.jsx(Gd,{className:W.cx_default(uu,N&&du,!N&&hu),children:z.jsx(Xd,{as:"button",onClick:be,style:{backgroundColor:((l=(a=i.banner)==null?void 0:a.ctaButton)==null?void 0:l.color)||"#009dc4",color:((g=(c=i.banner)==null?void 0:c.ctaButton)==null?void 0:g.textColor)||"#fff"},"data-a":"button","data-promo-id":t,"data-promo-type":i.type,target:"_blank",children:"Show more"})})]})},Ld=i=>{var e,t,n,s,r,a,l,c,g,m,b,C,w,A,v,M,D,R,N,F,P,$,Y,X,re,ce,be,he,Z,de;const{promotion:ee,open:Xe,advertisementPaused:Ye,togglePause:$e,controlVideo:He,skipAutoClose:me,promotionId:fe,onClose:mt,markAsViewed:Et,externalAd:we,isEventFired:ue,fireEvent:Re,muted:Hi}=i,oi=ee.type===oe.PromotionType.INGAME_IAB11_LBAR||ee.type===oe.PromotionType.INGAME_IAB11||ee.type===oe.PromotionType.INGAME_IAB11_SIDEBAR,li=((e=ee.sponsor)==null?void 0:e.logo)&&ee.logoMode===oe.PromotionLogoMode.CENTER,Ei=!!((n=(t=ee.banner)==null?void 0:t.video)!=null&&n.url),yt=ee.autoPlayVideo===oe.AutoPlayVideo.ENABLED,ui=ee.playVideoMuted===oe.PlayVideoMuted.ENABLED;if(_e.useEffect(()=>{$e==null||$e(Ei||yt),Xe==null||Xe()},[]),_e.useEffect(()=>{fe&&ee.type&&Et&&Et()},[fe,ee.type,Et]),_e.useEffect(()=>()=>{He==null||He({muted:!1})},[He]),we)return z.jsx(jS,{...i,externalAd:we});let Ft=(s=ee.banner)==null?void 0:s.url;Ft&&Ft.indexOf("http")!==0&&(Ft=`https://${Ft}`);let wi=!0;return Ei&&(!Ye||!yt?wi=!0:wi=!1),z.jsxs($d,{className:"PromoOverlay",children:[z.jsxs("div",{children:[z.jsxs(qd,{children:[z.jsxs(Vd,{className:W.cx_default(!li&&Hd),children:[((r=ee.sponsor)==null?void 0:r.logo)&&ee.logoMode===oe.PromotionLogoMode.LEFT&&z.jsx(au,{className:"PromoSponsorLogo",src:(a=ee.sponsor)==null?void 0:a.logo,alt:"promo"}),z.jsxs(yy,{style:{paddingLeft:(l=ee.sponsor)!=null&&l.logo&&ee.logoMode===oe.PromotionLogoMode.LEFT?"0px":"8px"},children:[((c=ee.sponsor)==null?void 0:c.logo)&&ee.logoMode===oe.PromotionLogoMode.LEFT&&z.jsx(py,{children:(g=ee.sponsor)==null?void 0:g.name}),z.jsxs(_y,{className:"SponsorText",children:[z.jsx(Wd,{children:"AD"}),z.jsx(by,{children:"SPONSORED"})]})]})]}),z.jsx(W.y,{className:"ClosePromoIcon",close:mt,autoClose:(m=ee.closeTimer)==null?void 0:m.auto,duration:me?0:(b=ee.closeTimer)==null?void 0:b.seconds,isPlaying:wi})]}),z.jsxs(zd,{children:[li&&z.jsx(au,{className:gy,src:(C=ee.sponsor)==null?void 0:C.logo,alt:"promo"}),z.jsx(ou,{children:(A=(w=ee.banner)==null?void 0:w.video)!=null&&A.url?z.jsx(W.Et,{source:(M=(v=ee.banner)==null?void 0:v.video)==null?void 0:M.url,poster:(R=(D=ee.banner)==null?void 0:D.video)==null?void 0:R.thumbnailUrl,aspectRatio:oi?"1/1":"2/1",onRender:()=>{ue!=null&&ue("video-rendered")||(W.eventBus.emit("advertisement",{action:"videoRendered",payload:{id:fe,type:ee.type}}),Re==null||Re("video-rendered"))},onQuartile:Dt=>{ue!=null&&ue(`video-quartile-${Dt}`)||(W.eventBus.emit("advertisement",{action:"quartileCompleted",payload:{id:fe,type:ee.type,quartile:Dt}}),Re==null||Re(`video-quartile-${Dt}`))},onMute:Dt=>{const Ot=Dt?"muted":"unmuted";ue!=null&&ue(Ot)||(W.eventBus.emit("advertisement",{action:Dt?"videoMuted":"videoUnmuted",payload:{id:fe,type:ee.type}}),Re==null||Re(Ot))},onPause:()=>{yt&&($e==null||$e(!0))},onReplay:()=>{ue!=null&&ue("replayed")||(W.eventBus.emit("advertisement",{action:"videoReplayed",payload:{id:fe,type:ee.type}}),Re==null||Re("replayed"))},onPlay:()=>{ue!=null&&ue("played")||(W.eventBus.emit("advertisement",{action:"videoPlay",payload:{id:fe,type:ee.type}}),Re==null||Re("played")),$e==null||$e(!1),ue!=null&&ue("played")&&ue!=null&&ue("ended")&&!(ue!=null&&ue("replayed"))&&(W.eventBus.emit("advertisement",{action:"videoReplayed",payload:{id:fe,type:ee.type}}),Re==null||Re("replayed"))},onEnd:()=>{ue!=null&&ue("ended")||(W.eventBus.emit("advertisement",{action:"videoEnd",payload:{id:fe,type:ee.type}}),Re==null||Re("ended"))},controlVideo:He,autoPlay:yt,playMuted:ui,muted:Hi}):(N=ee.banner)!=null&&N.imageUrl?z.jsx(fy,{style:oi?{aspectRatio:"1/1"}:{},src:(F=ee.banner)==null?void 0:F.imageUrl,alt:"promo"}):null}),!oi&&z.jsxs(ou,{children:[((P=ee.banner)==null?void 0:P.title)&&z.jsx(Ty,{className:W.cx_default("AdvTitle",li&&vy),children:($=ee.banner)==null?void 0:$.title}),((Y=ee.banner)==null?void 0:Y.body)&&z.jsx(my,{className:"AdvDescription",children:(X=ee.banner)==null?void 0:X.body})]})]})]}),ee.buttonType===oe.PromotionButtonType.BASIC&&z.jsx(Gd,{children:z.jsx(Xd,{href:Ft,style:{backgroundColor:((ce=(re=ee.banner)==null?void 0:re.ctaButton)==null?void 0:ce.color)||"#009dc4",color:((he=(be=ee.banner)==null?void 0:be.ctaButton)==null?void 0:he.textColor)||"#fff"},"data-a":"button","data-promo-id":fe,"data-promo-type":ee.type,target:"_blank",children:(de=(Z=ee.banner)==null?void 0:Z.ctaButton)==null?void 0:de.label})})]})},$S=W.styled_default("div")({name:"SidebarContainer",class:"s1abskp8",propsAsIs:!1}),qS=({children:i,direction:e,style:t,className:n,hiding:s})=>z.jsx(To,{direction:e,style:t,hiding:s,className:n,children:z.jsx($S,{children:i})}),Dd=i=>(i==null?void 0:i.type)===oe.PromotionType.INGAME_IAB11_LBAR||(i==null?void 0:i.type)===oe.PromotionType.INGAME_IAB21_LBAR,VS=i=>(i==null?void 0:i.type)===oe.PromotionType.INGAME_IAB11_SIDEBAR||(i==null?void 0:i.type)===oe.PromotionType.INGAME_IAB21_SIDEBAR,HS=i=>(i==null?void 0:i.type)===oe.PromotionType.INGAME_IAB11||(i==null?void 0:i.type)===oe.PromotionType.INGAME_IAB21,zS=({advertisement:i,close:e,skipTypeCheck:t,skipAutoClose:n,layoutMode:s="side-by-side",sidebar:r,isNotification:a,banner:l,markAsViewed:c,open:g,externalAd:m,controlVideo:b,advertisementPaused:C,togglePause:w,isEventFired:A,fireEvent:v,muted:M})=>i.promotion?a&&i.notification?z.jsx(hy,{open:()=>g==null?void 0:g({fromNotification:!0}),notification:i.notification,promotionId:i.question.id,close:e}):!r&&!l&&(t||HS(i.promotion))?z.jsx(cy,{className:"PromoOverlayContainer",children:z.jsx(Ld,{markAsViewed:c,promotionId:i.question.id,promotion:i.promotion,onClose:e,open:g,skipAutoClose:n,externalAd:m,controlVideo:b,advertisementPaused:C,togglePause:w,isEventFired:A,fireEvent:v,muted:M})}):r&&(t||Dd(i.promotion)||VS(i.promotion)||m)?z.jsx(qS,{className:"PromoSidebarContainer",direction:r,hiding:!1,children:z.jsx(Ld,{markAsViewed:c,promotionId:i.question.id,promotion:i.promotion,externalAd:m,onClose:e,open:g,controlVideo:b,skipAutoClose:n,advertisementPaused:C,togglePause:w,isEventFired:A,fireEvent:v,muted:M})}):l&&Dd(i.promotion)?z.jsx(Ud,{promotionId:i.question.id,hiding:!1,promotion:i.promotion,direction:l,isEventFired:A,fireEvent:v}):null:null,Od=W.styled_default("div")({name:"AdvertisementUIWrap",class:"aa6pjif",propsAsIs:!1}),WS=i=>{const e=i.target;if(e instanceof HTMLAnchorElement&&e.target==="_blank"){const t=e.getAttribute("data-promo-id")||"",n=e.getAttribute("data-promo-type")||oe.PromotionType.UNSET;e.getAttribute("data-a")==="button"&&W.eventBus.emit("advertisement",{action:"buttonSelect",payload:{id:t,type:n}}),e.getAttribute("data-a")==="banner"&&W.eventBus.emit("advertisement",{action:"bannerSelect",payload:{id:t,type:n}})}},GS=({gamification:i,advertisement:e,layoutMode:t,skipAutoClose:n,skipTypeCheck:s,sidebar:r,banner:a,notification:l,isMobileScreen:c,persistent:g,containerId:m,externalAd:b,controlVideo:C,muted:w})=>{var A,v,M,D,R,N,F,P,$,Y,X,re,ce,be,he,Z,de,ee,Xe,Ye,$e;const He=_e.useRef(null),me=W.useStore(e.$store),fe=W.useStore(i.openedQuestion.$store);W.b(He,{enabled:!!me.data,event:"click",listener:WS});const mt=((M=(v=(A=me.data)==null?void 0:A.question)==null?void 0:v.backgroundImage)==null?void 0:M.landscapeUrl)||((R=(D=me.data)==null?void 0:D.promotion)==null?void 0:R.backgroundImageLandscapeUrl),Et=((P=(F=(N=me.data)==null?void 0:N.question)==null?void 0:F.backgroundImage)==null?void 0:P.portraitUrl)||((Y=($=me.data)==null?void 0:$.promotion)==null?void 0:Y.backgroundImagePortraitUrl),we=W.y$1({containerId:m,landscapeUrl:mt,portraitUrl:Et});if(((X=fe==null?void 0:fe.attributes)==null?void 0:X.adUnit)===oe.AdUnit.STANDART&&(be=(ce=(re=fe==null?void 0:fe.attributes)==null?void 0:re.adPromotion)==null?void 0:ce.banner)!=null&&be.imageUrl)return a?z.jsx(Od,{ref:He,style:{height:"100%"},className:W.cx_default("SL-AdvertisementUIWrap",c&&"mobile-view"),children:z.jsx(vm,{cardId:fe.id,promotion:{...(he=fe==null?void 0:fe.attributes)==null?void 0:he.adPromotion,adUnit:(Z=fe==null?void 0:fe.attributes)==null?void 0:Z.adUnit}})}):null;const ue=!a&&!r;if(me.data===void 0||!g&&me.isViewed)return null;const Re=((Xe=(ee=(de=me==null?void 0:me.data)==null?void 0:de.notification)==null?void 0:ee.promotion)==null?void 0:Xe.mode)===oe.NotificationPromotionMode.LOWER_THIRD;return z.jsxs(Od,{ref:He,style:{height:ue?"auto":"100%"},className:W.cx_default("SL-AdvertisementUIWrap",c&&"mobile-view",Re&&"SL-AdvertisementUIWrap--lower-third"),children:[!l&&we,z.jsx(zS,{skipTypeCheck:s,sidebar:r,banner:a,advertisement:me.data,advertisementPaused:!!me.isPaused,togglePause:me.togglePause,isEventFired:me.isEventFired,toggleMute:me.toggleMute,fireEvent:me.fireEvent,close:me.close,externalAd:b?me.externalAd:void 0,markAsViewed:(Ye=i.advertisement)==null?void 0:Ye.markAsViewed,open:($e=i.advertisement)==null?void 0:$e.open,layoutMode:t,isNotification:l,skipAutoClose:n,controlVideo:C,muted:w})]})},Gp=({sdk:i,sidebar:e,externalAd:t,banner:n,skipAutoClose:s,skipTypeCheck:r,layoutMode:a,isMobileScreen:l,persistent:c,notification:g,muted:m})=>{const b=W.useStore(i.featuresList.getStore()),[C,w]=_e.useState(!t),A=W.useStore(i.options);if(_e.useEffect(()=>{if(t){const M=document.createElement("script");M.async=!0,M.src="https://imasdk.googleapis.com/pal/sdkloader/pal.js",document.body.appendChild(M),M.onload=()=>{w(!0)}}},[t]),e&&n)return z.jsx("div",{style:{color:"red"},children:"define either sidebar or banner, not both."});if(n&&t)return z.jsx("div",{style:{color:"red"},children:"externalAd is not supported with banner"});if(!b)return null;const v=i.getFeature(oe.SdkOverlayType.GAMES);return!v||t&&!C?null:z.jsx(GS,{gamification:v,advertisement:v.advertisement,sidebar:e,banner:n,layoutMode:a,isMobileScreen:l,persistent:c,notification:g,skipTypeCheck:r,skipAutoClose:s,externalAd:t,controlVideo:i.controlVideoPlayer,containerId:A.containerId,muted:m})},XS=({event:i,sidebar:e,banner:t,isMobileScreen:n,skipAutoClose:s,persistent:r,theme:a,notification:l,skipTypeCheck:c,externalAd:g,muted:m=!1})=>{const b=W.useStreamLayer(),C=W.useStreamLayerUI(),w=W.useStreamLayerTheme();return b?g&&!C.promotionExternalAd?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):!g&&C.promotionExternalAd?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):e&&!C.promotionSidebar?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):t&&!C.promotionBanner?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):l&&!C.promotionNotification?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):!t&&!e&&!l&&!C.promotionOverlay&&!c?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):z.jsxs("div",{className:"StreamLayerSDK",children:[z.jsx(W.h,{customTheme:a??w.theme,themeMode:w.themeMode,children:z.jsx(Gp,{sdk:b,sidebar:e,banner:t,isMobileScreen:n,persistent:r,notification:l,skipTypeCheck:c,skipAutoClose:s,layoutMode:"side-by-side",externalAd:g,muted:m})}),i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i})]}):null};exports.StreamLayerSDKAdvertisement=XS;exports.StreamLayerSDKAdvertisementUI=Gp;
|
|
216
|
+
`.split("").map(i=>i.charCodeAt(0)));class Uv extends Error{constructor(){super("Trying to parse received VTT cues, but there is no WebVTT. Make sure vtt.js is loaded.")}}class Nv extends mo{constructor(e,t={}){super(e,t),this.mediaSource_=null,this.subtitlesTrack_=null,this.featuresNativeTextTracks_=e.featuresNativeTextTracks,this.loadVttJs=e.loadVttJs,this.shouldSaveSegmentTimingInfo_=!1}buffered_(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues||!this.subtitlesTrack_.cues.length)return tt();const e=this.subtitlesTrack_.cues,t=e[0].startTime,n=e[e.length-1].startTime;return tt([[t,n]])}initSegmentForMap(e,t=!1){if(!e)return null;const n=Cr(e);let s=this.initSegments_[n];if(t&&!s&&e.bytes){const r=Sd.byteLength+e.bytes.byteLength,a=new Uint8Array(r);a.set(e.bytes),a.set(Sd,e.bytes.byteLength),this.initSegments_[n]=s={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:a}}return s||e}couldBeginLoading_(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}init_(){return this.state="READY",this.resetEverything(),this.monitorBuffer_()}track(e){return typeof e>"u"?this.subtitlesTrack_:(this.subtitlesTrack_=e,this.state==="INIT"&&this.couldBeginLoading_()&&this.init_(),this.subtitlesTrack_)}remove(e,t){ss(e,t,this.subtitlesTrack_)}fillBuffer_(){const e=this.chooseNextRequest_();if(e){if(this.syncController_.timestampOffsetForTimeline(e.timeline)===null){const t=()=>{this.state="READY",this.paused()||this.monitorBuffer_()};this.syncController_.one("timestampoffset",t),this.state="WAITING_ON_TIMELINE";return}this.loadSegment_(e)}}timestampOffsetForSegment_(){return null}chooseNextRequest_(){return this.skipEmptySegments_(super.chooseNextRequest_())}skipEmptySegments_(e){for(;e&&e.segment.empty;){if(e.mediaIndex+1>=e.playlist.segments.length){e=null;break}e=this.generateSegmentInfo_({playlist:e.playlist,mediaIndex:e.mediaIndex+1,startOfSegment:e.startOfSegment+e.duration,isSyncRequest:e.isSyncRequest})}return e}stopForError(e){this.error(e),this.state="READY",this.pause(),this.trigger("error")}segmentRequestFinished_(e,t,n){if(!this.subtitlesTrack_){this.state="READY";return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_){this.state="READY",this.mediaRequestsAborted+=1;return}if(e){e.code===Yt.TIMEOUT&&this.handleTimeout_(),e.code===Yt.ABORTED?this.mediaRequestsAborted+=1:this.mediaRequestsErrored+=1,this.stopForError(e);return}const s=this.pendingSegment_,r=n.mp4VttCues&&n.mp4VttCues.length;r&&(s.mp4VttCues=n.mp4VttCues),this.saveBandwidthRelatedStats_(s.duration,t.stats),t.key&&this.segmentKey(t.key,!0),this.state="APPENDING",this.trigger("appending");const a=s.segment;if(a.map&&(a.map.bytes=t.map.bytes),s.bytes=t.bytes,typeof x.WebVTT!="function"&&typeof this.loadVttJs=="function"){this.state="WAITING_ON_VTTJS",this.loadVttJs().then(()=>this.segmentRequestFinished_(e,t,n),()=>this.stopForError({message:"Error loading vtt.js"}));return}a.requested=!0;try{this.parseVTTCues_(s)}catch(l){this.stopForError({message:l.message,metadata:{errorType:B.Error.StreamingVttParserError,error:l}});return}if(r||this.updateTimeMapping_(s,this.syncController_.timelines[s.timeline],this.playlist_),s.cues.length?s.timingInfo={start:s.cues[0].startTime,end:s.cues[s.cues.length-1].endTime}:s.timingInfo={start:s.startOfSegment,end:s.startOfSegment+s.duration},s.isSyncRequest){this.trigger("syncinfoupdate"),this.pendingSegment_=null,this.state="READY";return}s.byteLength=s.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,s.cues.forEach(l=>{this.subtitlesTrack_.addCue(this.featuresNativeTextTracks_?new x.VTTCue(l.startTime,l.endTime,l.text):l)}),bv(this.subtitlesTrack_),this.handleAppendsDone_()}handleData_(e,t){const n=e&&e.type==="vtt",s=t&&t.type==="text";n&&s&&super.handleData_(e,t)}updateTimingInfoEnd_(){}parseMp4VttCues_(e){const t=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset();e.mp4VttCues.forEach(n=>{const s=n.start+t,r=n.end+t,a=new x.VTTCue(s,r,n.cueText);n.settings&&n.settings.split(" ").forEach(l=>{const c=l.split(":"),f=c[0],m=c[1];a[f]=isNaN(m)?m:Number(m)}),e.cues.push(a)})}parseVTTCues_(e){let t,n=!1;if(typeof x.WebVTT!="function")throw new Uv;if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},e.mp4VttCues){this.parseMp4VttCues_(e);return}typeof x.TextDecoder=="function"?t=new x.TextDecoder("utf8"):(t=x.WebVTT.StringDecoder(),n=!0);const s=new x.WebVTT.Parser(x,x.vttjs,t);if(s.oncue=e.cues.push.bind(e.cues),s.ontimestampmap=a=>{e.timestampmap=a},s.onparsingerror=a=>{B.log.warn("Error encountered when parsing cues: "+a.message)},e.segment.map){let a=e.segment.map.bytes;n&&(a=vd(a)),s.parse(a)}let r=e.bytes;n&&(r=vd(r)),s.parse(r),s.flush()}updateTimeMapping_(e,t,n){const s=e.segment;if(!t)return;if(!e.cues.length){s.empty=!0;return}const{MPEGTS:r,LOCAL:a}=e.timestampmap,l=r/Ri.ONE_SECOND_IN_TS-a+t.mapping;if(e.cues.forEach(c=>{const f=c.endTime-c.startTime,m=this.handleRollover_(c.startTime+l,t.time);c.startTime=Math.max(m,0),c.endTime=Math.max(m+f,0)}),!n.syncInfo){const c=e.cues[0].startTime,f=e.cues[e.cues.length-1].startTime;n.syncInfo={mediaSequence:n.mediaSequence+e.mediaIndex,time:Math.min(c,f-s.duration)}}}handleRollover_(e,t){if(t===null)return e;let n=e*Ri.ONE_SECOND_IN_TS;const s=t*Ri.ONE_SECOND_IN_TS;let r;for(s<n?r=-8589934592:r=8589934592;Math.abs(n-s)>4294967296;)n+=r;return n/Ri.ONE_SECOND_IN_TS}}const Bv=function(i,e){const t=i.cues;for(let n=0;n<t.length;n++){const s=t[n];if(e>=s.adStartTime&&e<=s.adEndTime)return s}return null},Fv=function(i,e,t=0){if(!i.segments)return;let n=t,s;for(let r=0;r<i.segments.length;r++){const a=i.segments[r];if(s||(s=Bv(e,n+a.duration/2)),s){if("cueIn"in a){s.endTime=n,s.adEndTime=n,n+=a.duration,s=null;continue}if(n<s.endTime){n+=a.duration;continue}s.endTime+=a.duration}else if("cueOut"in a&&(s=new x.VTTCue(n,n+a.duration,a.cueOut),s.adStartTime=n,s.adEndTime=n+parseFloat(a.cueOut),e.addCue(s)),"cueOutCont"in a){const[l,c]=a.cueOutCont.split("/").map(parseFloat);s=new x.VTTCue(n,n+a.duration,""),s.adStartTime=n-l,s.adEndTime=s.adStartTime+c,e.addCue(s)}n+=a.duration}};class Ed{constructor({start:e,end:t,segmentIndex:n,partIndex:s=null,appended:r=!1}){this.start_=e,this.end_=t,this.segmentIndex_=n,this.partIndex_=s,this.appended_=r}isInRange(e){return e>=this.start&&e<this.end}markAppended(){this.appended_=!0}resetAppendedStatus(){this.appended_=!1}get isAppended(){return this.appended_}get start(){return this.start_}get end(){return this.end_}get segmentIndex(){return this.segmentIndex_}get partIndex(){return this.partIndex_}}class jv{constructor(e,t=[]){this.segmentSyncInfo_=e,this.partsSyncInfo_=t}get segmentSyncInfo(){return this.segmentSyncInfo_}get partsSyncInfo(){return this.partsSyncInfo_}get hasPartsSyncInfo(){return this.partsSyncInfo_.length>0}resetAppendStatus(){this.segmentSyncInfo_.resetAppendedStatus(),this.partsSyncInfo_.forEach(e=>e.resetAppendedStatus())}}class Pp{constructor(){this.storage_=new Map,this.diagnostics_="",this.isReliable_=!1,this.start_=-1/0,this.end_=1/0}get start(){return this.start_}get end(){return this.end_}get diagnostics(){return this.diagnostics_}get isReliable(){return this.isReliable_}resetAppendedStatus(){this.storage_.forEach(e=>e.resetAppendStatus())}update(e,t){const{mediaSequence:n,segments:s}=e;if(this.isReliable_=this.isReliablePlaylist_(n,s),!!this.isReliable_)return this.updateStorage_(s,n,this.calculateBaseTime_(n,s,t))}getSyncInfoForTime(e){for(const{segmentSyncInfo:t,partsSyncInfo:n}of this.storage_.values())if(n.length){for(const s of n)if(s.isInRange(e))return s}else if(t.isInRange(e))return t;return null}getSyncInfoForMediaSequence(e){return this.storage_.get(e)}updateStorage_(e,t,n){const s=new Map;let r=`
|
|
217
|
+
`,a=n,l=t;this.start_=a,e.forEach((c,f)=>{const m=this.storage_.get(l),b=a,C=b+c.duration,w=!!(m&&m.segmentSyncInfo&&m.segmentSyncInfo.isAppended),A=new Ed({start:b,end:C,appended:w,segmentIndex:f});c.syncInfo=A;let v=a;const M=(c.parts||[]).map((D,R)=>{const N=v,F=v+D.duration,P=!!(m&&m.partsSyncInfo&&m.partsSyncInfo[R]&&m.partsSyncInfo[R].isAppended),$=new Ed({start:N,end:F,appended:P,segmentIndex:f,partIndex:R});return v=F,r+=`Media Sequence: ${l}.${R} | Range: ${N} --> ${F} | Appended: ${P}
|
|
218
|
+
`,D.syncInfo=$,$});s.set(l,new jv(A,M)),r+=`${Cp(c.resolvedUri)} | Media Sequence: ${l} | Range: ${b} --> ${C} | Appended: ${w}
|
|
219
|
+
`,l++,a=C}),this.end_=a,this.storage_=s,this.diagnostics_=r}calculateBaseTime_(e,t,n){if(!this.storage_.size)return 0;if(this.storage_.has(e))return this.storage_.get(e).segmentSyncInfo.start;const s=Math.min(...this.storage_.keys());if(e<s){const r=s-e;let a=this.storage_.get(s).segmentSyncInfo.start;for(let l=0;l<r;l++){const c=t[l];a-=c.duration}return a}return n}isReliablePlaylist_(e,t){return e!=null&&Array.isArray(t)&&t.length}}class wd extends Pp{constructor(e){super(),this.parent_=e}calculateBaseTime_(e,t,n){if(!this.storage_.size){const s=this.parent_.getSyncInfoForMediaSequence(e);return s?s.segmentSyncInfo.start:0}return super.calculateBaseTime_(e,t,n)}}const $v=86400,za=[{name:"VOD",run:(i,e,t,n,s)=>t!==1/0?{time:0,segmentIndex:0,partIndex:null}:null},{name:"MediaSequence",run:(i,e,t,n,s,r)=>{const a=i.getMediaSequenceSync(r);if(!a||!a.isReliable)return null;const l=a.getSyncInfoForTime(s);return l?{time:l.start,partIndex:l.partIndex,segmentIndex:l.segmentIndex}:null}},{name:"ProgramDateTime",run:(i,e,t,n,s)=>{if(!Object.keys(i.timelineToDatetimeMappings).length)return null;let r=null,a=null;const l=ao(e);s=s||0;for(let c=0;c<l.length;c++){const f=e.endList||s===0?c:l.length-(c+1),m=l[f],b=m.segment,C=i.timelineToDatetimeMappings[b.timeline];if(!C||!b.dateTimeObject)continue;let w=b.dateTimeObject.getTime()/1e3+C;if(b.parts&&typeof m.partIndex=="number")for(let v=0;v<m.partIndex;v++)w+=b.parts[v].duration;const A=Math.abs(s-w);if(a!==null&&(A===0||a<A))break;a=A,r={time:w,segmentIndex:m.segmentIndex,partIndex:m.partIndex}}return r}},{name:"Segment",run:(i,e,t,n,s)=>{let r=null,a=null;s=s||0;const l=ao(e);for(let c=0;c<l.length;c++){const f=e.endList||s===0?c:l.length-(c+1),m=l[f],b=m.segment,C=m.part&&m.part.start||b&&b.start;if(b.timeline===n&&typeof C<"u"){const w=Math.abs(s-C);if(a!==null&&a<w)break;(!r||a===null||a>=w)&&(a=w,r={time:C,segmentIndex:m.segmentIndex,partIndex:m.partIndex})}}return r}},{name:"Discontinuity",run:(i,e,t,n,s)=>{let r=null;if(s=s||0,e.discontinuityStarts&&e.discontinuityStarts.length){let a=null;for(let l=0;l<e.discontinuityStarts.length;l++){const c=e.discontinuityStarts[l],f=e.discontinuitySequence+l+1,m=i.discontinuities[f];if(m){const b=Math.abs(s-m.time);if(a!==null&&a<b)break;(!r||a===null||a>=b)&&(a=b,r={time:m.time,segmentIndex:c,partIndex:null})}}}return r}},{name:"Playlist",run:(i,e,t,n,s)=>e.syncInfo?{time:e.syncInfo.time,segmentIndex:e.syncInfo.mediaSequence-e.mediaSequence,partIndex:null}:null}];class qv extends B.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};const t=new Pp,n=new wd(t),s=new wd(t);this.mediaSequenceStorage_={main:t,audio:n,vtt:s},this.logger_=Lt("SyncController")}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,t,n,s,r){if(t!==1/0)return za.find(({name:l})=>l==="VOD").run(this,e,t);const a=this.runStrategies_(e,t,n,s,r);if(!a.length)return null;for(const l of a){const{syncPoint:c,strategy:f}=l,{segmentIndex:m,time:b}=c;if(m<0)continue;const C=e.segments[m],w=b,A=w+C.duration;if(this.logger_(`Strategy: ${f}. Current time: ${s}. selected segment: ${m}. Time: [${w} -> ${A}]}`),s>=w&&s<A)return this.logger_("Found sync point with exact match: ",c),c}return this.selectSyncPoint_(a,{key:"time",value:s})}getExpiredTime(e,t){if(!e||!e.segments)return null;const n=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!n.length)return null;const s=this.selectSyncPoint_(n,{key:"segmentIndex",value:0});return s.segmentIndex>0&&(s.time*=-1),Math.abs(s.time+ds({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:s.segmentIndex,endIndex:0}))}runStrategies_(e,t,n,s,r){const a=[];for(let l=0;l<za.length;l++){const c=za[l],f=c.run(this,e,t,n,s,r);f&&(f.strategy=c.name,a.push({strategy:c.name,syncPoint:f}))}return a}selectSyncPoint_(e,t){let n=e[0].syncPoint,s=Math.abs(e[0].syncPoint[t.key]-t.value),r=e[0].strategy;for(let a=1;a<e.length;a++){const l=Math.abs(e[a].syncPoint[t.key]-t.value);l<s&&(s=l,n=e[a].syncPoint,r=e[a].strategy)}return this.logger_(`syncPoint for [${t.key}: ${t.value}] chosen with strategy [${r}]: [time:${n.time}, segmentIndex:${n.segmentIndex}`+(typeof n.partIndex=="number"?`,partIndex:${n.partIndex}`:"")+"]"),n}saveExpiredSegmentInfo(e,t){const n=t.mediaSequence-e.mediaSequence;if(n>$v){B.log.warn(`Not saving expired segment info. Media sequence gap ${n} is too large.`);return}for(let s=n-1;s>=0;s--){const r=e.segments[s];if(r&&typeof r.start<"u"){t.syncInfo={mediaSequence:e.mediaSequence+s,time:r.start},this.logger_(`playlist refresh sync: [time:${t.syncInfo.time}, mediaSequence: ${t.syncInfo.mediaSequence}]`),this.trigger("syncinfoupdate");break}}}setDateTimeMappingForStart(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){const t=e.segments[0],n=t.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[t.timeline]=-n}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:t}){const n=this.calculateSegmentTimeMapping_(e,e.timingInfo,t),s=e.segment;n&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:s.start}));const r=s.dateTimeObject;s.discontinuity&&t&&r&&(this.timelineToDatetimeMappings[s.timeline]=-(r.getTime()/1e3))}timestampOffsetForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].time}mappingForTimeline(e){return typeof this.timelines[e]>"u"?null:this.timelines[e].mapping}calculateSegmentTimeMapping_(e,t,n){const s=e.segment,r=e.part;let a=this.timelines[e.timeline],l,c;if(typeof e.timestampOffset=="number")a={time:e.startOfSegment,mapping:e.startOfSegment-t.start},n&&(this.timelines[e.timeline]=a,this.trigger("timestampoffset"),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${a.time}] [mapping: ${a.mapping}]`)),l=e.startOfSegment,c=t.end+a.mapping;else if(a)l=t.start+a.mapping,c=t.end+a.mapping;else return!1;return r&&(r.start=l,r.end=c),(!s.start||l<s.start)&&(s.start=l),s.end=c,!0}saveDiscontinuitySyncInfo_(e){const t=e.playlist,n=e.segment;if(n.discontinuity)this.discontinuities[n.timeline]={time:n.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(let s=0;s<t.discontinuityStarts.length;s++){const r=t.discontinuityStarts[s],a=t.discontinuitySequence+s+1,l=r-e.mediaIndex,c=Math.abs(l);if(!this.discontinuities[a]||this.discontinuities[a].accuracy>c){let f;l<0?f=n.start-ds({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:r}):f=n.end+ds({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:r}),this.discontinuities[a]={time:f,accuracy:c}}}}dispose(){this.trigger("dispose"),this.off()}}class Vv extends B.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger("pendingtimelinechange")}pendingTimelineChange({type:e,from:t,to:n}){return typeof t=="number"&&typeof n=="number"&&(this.pendingTimelineChanges_[e]={type:e,from:t,to:n},this.trigger("pendingtimelinechange")),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:t,to:n}){if(typeof t=="number"&&typeof n=="number"){this.lastTimelineChanges_[e]={type:e,from:t,to:n},delete this.pendingTimelineChanges_[e];const s={timelineChangeInfo:{from:t,to:n}};this.trigger({type:"timelinechange",metadata:s})}return this.lastTimelineChanges_[e]}dispose(){this.trigger("dispose"),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}const Hv=gp(fp(function(){var i=function(){function v(){this.listeners={}}var M=v.prototype;return M.on=function(D,R){this.listeners[D]||(this.listeners[D]=[]),this.listeners[D].push(R)},M.off=function(D,R){if(!this.listeners[D])return!1;var N=this.listeners[D].indexOf(R);return this.listeners[D]=this.listeners[D].slice(0),this.listeners[D].splice(N,1),N>-1},M.trigger=function(D){var R=this.listeners[D];if(R)if(arguments.length===2)for(var N=R.length,F=0;F<N;++F)R[F].call(this,arguments[1]);else for(var P=Array.prototype.slice.call(arguments,1),$=R.length,Y=0;Y<$;++Y)R[Y].apply(this,P)},M.dispose=function(){this.listeners={}},M.pipe=function(D){this.on("data",function(R){D.push(R)})},v}();/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */function e(v){return v.subarray(0,v.byteLength-v[v.byteLength-1])}/*! @name aes-decrypter @version 4.0.2 @license Apache-2.0 */const t=function(){const v=[[[],[],[],[],[]],[[],[],[],[],[]]],M=v[0],D=v[1],R=M[4],N=D[4];let F,P,$;const Y=[],X=[];let re,ce,be,he,Z,de;for(F=0;F<256;F++)X[(Y[F]=F<<1^(F>>7)*283)^F]=F;for(P=$=0;!R[P];P^=re||1,$=X[$]||1)for(he=$^$<<1^$<<2^$<<3^$<<4,he=he>>8^he&255^99,R[P]=he,N[he]=P,be=Y[ce=Y[re=Y[P]]],de=be*16843009^ce*65537^re*257^P*16843008,Z=Y[he]*257^he*16843008,F=0;F<4;F++)M[F][P]=Z=Z<<24^Z>>>8,D[F][he]=de=de<<24^de>>>8;for(F=0;F<5;F++)M[F]=M[F].slice(0),D[F]=D[F].slice(0);return v};let n=null;class s{constructor(M){n||(n=t()),this._tables=[[n[0][0].slice(),n[0][1].slice(),n[0][2].slice(),n[0][3].slice(),n[0][4].slice()],[n[1][0].slice(),n[1][1].slice(),n[1][2].slice(),n[1][3].slice(),n[1][4].slice()]];let D,R,N;const F=this._tables[0][4],P=this._tables[1],$=M.length;let Y=1;if($!==4&&$!==6&&$!==8)throw new Error("Invalid aes key size");const X=M.slice(0),re=[];for(this._key=[X,re],D=$;D<4*$+28;D++)N=X[D-1],(D%$===0||$===8&&D%$===4)&&(N=F[N>>>24]<<24^F[N>>16&255]<<16^F[N>>8&255]<<8^F[N&255],D%$===0&&(N=N<<8^N>>>24^Y<<24,Y=Y<<1^(Y>>7)*283)),X[D]=X[D-$]^N;for(R=0;D;R++,D--)N=X[R&3?D:D-4],D<=4||R<4?re[R]=N:re[R]=P[0][F[N>>>24]]^P[1][F[N>>16&255]]^P[2][F[N>>8&255]]^P[3][F[N&255]]}decrypt(M,D,R,N,F,P){const $=this._key[1];let Y=M^$[0],X=N^$[1],re=R^$[2],ce=D^$[3],be,he,Z;const de=$.length/4-2;let ee,Xe=4;const Ye=this._tables[1],$e=Ye[0],He=Ye[1],me=Ye[2],ge=Ye[3],mt=Ye[4];for(ee=0;ee<de;ee++)be=$e[Y>>>24]^He[X>>16&255]^me[re>>8&255]^ge[ce&255]^$[Xe],he=$e[X>>>24]^He[re>>16&255]^me[ce>>8&255]^ge[Y&255]^$[Xe+1],Z=$e[re>>>24]^He[ce>>16&255]^me[Y>>8&255]^ge[X&255]^$[Xe+2],ce=$e[ce>>>24]^He[Y>>16&255]^me[X>>8&255]^ge[re&255]^$[Xe+3],Xe+=4,Y=be,X=he,re=Z;for(ee=0;ee<4;ee++)F[(3&-ee)+P]=mt[Y>>>24]<<24^mt[X>>16&255]<<16^mt[re>>8&255]<<8^mt[ce&255]^$[Xe++],be=Y,Y=X,X=re,re=ce,ce=be}}class r extends i{constructor(){super(i),this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){this.jobs.shift()(),this.jobs.length?this.timeout_=setTimeout(this.processJob_.bind(this),this.delay):this.timeout_=null}push(M){this.jobs.push(M),this.timeout_||(this.timeout_=setTimeout(this.processJob_.bind(this),this.delay))}}const a=function(v){return v<<24|(v&65280)<<8|(v&16711680)>>8|v>>>24},l=function(v,M,D){const R=new Int32Array(v.buffer,v.byteOffset,v.byteLength>>2),N=new s(Array.prototype.slice.call(M)),F=new Uint8Array(v.byteLength),P=new Int32Array(F.buffer);let $,Y,X,re,ce,be,he,Z,de;for($=D[0],Y=D[1],X=D[2],re=D[3],de=0;de<R.length;de+=4)ce=a(R[de]),be=a(R[de+1]),he=a(R[de+2]),Z=a(R[de+3]),N.decrypt(ce,be,he,Z,P,de),P[de]=a(P[de]^$),P[de+1]=a(P[de+1]^Y),P[de+2]=a(P[de+2]^X),P[de+3]=a(P[de+3]^re),$=ce,Y=be,X=he,re=Z;return F};class c{constructor(M,D,R,N){const F=c.STEP,P=new Int32Array(M.buffer),$=new Uint8Array(M.byteLength);let Y=0;for(this.asyncStream_=new r,this.asyncStream_.push(this.decryptChunk_(P.subarray(Y,Y+F),D,R,$)),Y=F;Y<P.length;Y+=F)R=new Uint32Array([a(P[Y-4]),a(P[Y-3]),a(P[Y-2]),a(P[Y-1])]),this.asyncStream_.push(this.decryptChunk_(P.subarray(Y,Y+F),D,R,$));this.asyncStream_.push(function(){N(null,e($))})}static get STEP(){return 32e3}decryptChunk_(M,D,R,N){return function(){const F=l(M,D,R);N.set(F,M.byteOffset)}}}var f=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof ar<"u"?ar:typeof self<"u"?self:{},m;typeof window<"u"?m=window:typeof f<"u"?m=f:typeof self<"u"?m=self:m={};var b=m,C=function(v){return ArrayBuffer.isView==="function"?ArrayBuffer.isView(v):v&&v.buffer instanceof ArrayBuffer},w=b.BigInt||Number;w("0x1"),w("0x100"),w("0x10000"),w("0x1000000"),w("0x100000000"),w("0x10000000000"),w("0x1000000000000"),w("0x100000000000000"),w("0x10000000000000000"),function(){var v=new Uint16Array([65484]),M=new Uint8Array(v.buffer,v.byteOffset,v.byteLength);return M[0]===255?"big":M[0]===204?"little":"unknown"}();const A=function(v){const M={};return Object.keys(v).forEach(D=>{const R=v[D];C(R)?M[D]={bytes:R.buffer,byteOffset:R.byteOffset,byteLength:R.byteLength}:M[D]=R}),M};self.onmessage=function(v){const M=v.data,D=new Uint8Array(M.encrypted.bytes,M.encrypted.byteOffset,M.encrypted.byteLength),R=new Uint32Array(M.key.bytes,M.key.byteOffset,M.key.byteLength/4),N=new Uint32Array(M.iv.bytes,M.iv.byteOffset,M.iv.byteLength/4);new c(D,R,N,function(F,P){self.postMessage(A({source:M.source,decrypted:P}),[P.buffer])})}}));var zv=pp(Hv);const Wv=i=>{let e=i.default?"main":"alternative";return i.characteristics&&i.characteristics.indexOf("public.accessibility.describes-video")>=0&&(e="main-desc"),e},Lp=(i,e)=>{i.abort(),i.pause(),e&&e.activePlaylistLoader&&(e.activePlaylistLoader.pause(),e.activePlaylistLoader=null)},_o=(i,e)=>{e.activePlaylistLoader=i,i.load()},Gv=(i,e)=>()=>{const{segmentLoaders:{[i]:t,main:n},mediaTypes:{[i]:s}}=e,r=s.activeTrack(),a=s.getActiveGroup(),l=s.activePlaylistLoader,c=s.lastGroup_;if(!(a&&c&&a.id===c.id)&&(s.lastGroup_=a,s.lastTrack_=r,Lp(t,s),!(!a||a.isMainPlaylist))){if(!a.playlistLoader){l&&n.resetEverything();return}t.resyncLoader(),_o(a.playlistLoader,s)}},Xv=(i,e)=>()=>{const{segmentLoaders:{[i]:t},mediaTypes:{[i]:n}}=e;n.lastGroup_=null,t.abort(),t.pause()},Kv=(i,e)=>()=>{const{mainPlaylistLoader:t,segmentLoaders:{[i]:n,main:s},mediaTypes:{[i]:r}}=e,a=r.activeTrack(),l=r.getActiveGroup(),c=r.activePlaylistLoader,f=r.lastTrack_;if(!(f&&a&&f.id===a.id)&&(r.lastGroup_=l,r.lastTrack_=a,Lp(n,r),!!l)){if(l.isMainPlaylist){if(!a||!f||a.id===f.id)return;const m=e.vhs.playlistController_,b=m.selectPlaylist();if(m.media()===b)return;r.logger_(`track change. Switching main audio from ${f.id} to ${a.id}`),t.pause(),s.resetEverything(),m.fastQualityChange_(b);return}if(i==="AUDIO"){if(!l.playlistLoader){s.setAudio(!0),s.resetEverything();return}n.setAudio(!0),s.setAudio(!1)}if(c===l.playlistLoader){_o(l.playlistLoader,r);return}n.track&&n.track(a),n.resetEverything(),_o(l.playlistLoader,r)}},Ar={AUDIO:(i,e)=>()=>{const{mediaTypes:{[i]:t},excludePlaylist:n}=e,s=t.activeTrack(),r=t.activeGroup(),a=(r.filter(c=>c.default)[0]||r[0]).id,l=t.tracks[a];if(s===l){n({error:{message:"Problem encountered loading the default audio track."}});return}B.log.warn("Problem encountered loading the alternate audio track.Switching back to default.");for(const c in t.tracks)t.tracks[c].enabled=t.tracks[c]===l;t.onTrackChanged()},SUBTITLES:(i,e)=>()=>{const{mediaTypes:{[i]:t}}=e;B.log.warn("Problem encountered loading the subtitle track.Disabling subtitle track.");const n=t.activeTrack();n&&(n.mode="disabled"),t.onTrackChanged()}},kd={AUDIO:(i,e,t)=>{if(!e)return;const{tech:n,requestOptions:s,segmentLoaders:{[i]:r}}=t;e.on("loadedmetadata",()=>{const a=e.media();r.playlist(a,s),(!n.paused()||a.endList&&n.preload()!=="none")&&r.load()}),e.on("loadedplaylist",()=>{r.playlist(e.media(),s),n.paused()||r.load()}),e.on("error",Ar[i](i,t))},SUBTITLES:(i,e,t)=>{const{tech:n,requestOptions:s,segmentLoaders:{[i]:r},mediaTypes:{[i]:a}}=t;e.on("loadedmetadata",()=>{const l=e.media();r.playlist(l,s),r.track(a.activeTrack()),(!n.paused()||l.endList&&n.preload()!=="none")&&r.load()}),e.on("loadedplaylist",()=>{r.playlist(e.media(),s),n.paused()||r.load()}),e.on("error",Ar[i](i,t))}},Yv={AUDIO:(i,e)=>{const{vhs:t,sourceType:n,segmentLoaders:{[i]:s},requestOptions:r,main:{mediaGroups:a},mediaTypes:{[i]:{groups:l,tracks:c,logger_:f}},mainPlaylistLoader:m}=e,b=Ss(m.main);(!a[i]||Object.keys(a[i]).length===0)&&(a[i]={main:{default:{default:!0}}},b&&(a[i].main.default.playlists=m.main.playlists));for(const C in a[i]){l[C]||(l[C]=[]);for(const w in a[i][C]){let A=a[i][C][w],v;if(b?(f(`AUDIO group '${C}' label '${w}' is a main playlist`),A.isMainPlaylist=!0,v=null):n==="vhs-json"&&A.playlists?v=new nn(A.playlists[0],t,r):A.resolvedUri?v=new nn(A.resolvedUri,t,r):A.playlists&&n==="dash"?v=new po(A.playlists[0],t,r,m):v=null,A=fe({id:w,playlistLoader:v},A),kd[i](i,A.playlistLoader,e),l[C].push(A),typeof c[w]>"u"){const M=new B.AudioTrack({id:w,kind:Wv(A),enabled:!1,language:A.language,default:A.default,label:w});c[w]=M}}}s.on("error",Ar[i](i,e))},SUBTITLES:(i,e)=>{const{tech:t,vhs:n,sourceType:s,segmentLoaders:{[i]:r},requestOptions:a,main:{mediaGroups:l},mediaTypes:{[i]:{groups:c,tracks:f}},mainPlaylistLoader:m}=e;for(const b in l[i]){c[b]||(c[b]=[]);for(const C in l[i][b]){if(!n.options_.useForcedSubtitles&&l[i][b][C].forced)continue;let w=l[i][b][C],A;if(s==="hls")A=new nn(w.resolvedUri,n,a);else if(s==="dash"){if(!w.playlists.filter(v=>v.excludeUntil!==1/0).length)return;A=new po(w.playlists[0],n,a,m)}else s==="vhs-json"&&(A=new nn(w.playlists?w.playlists[0]:w.resolvedUri,n,a));if(w=fe({id:C,playlistLoader:A},w),kd[i](i,w.playlistLoader,e),c[b].push(w),typeof f[C]>"u"){const v=t.addRemoteTextTrack({id:C,kind:"subtitles",default:w.default&&w.autoselect,language:w.language,label:C},!1).track;f[C]=v}}}r.on("error",Ar[i](i,e))},"CLOSED-CAPTIONS":(i,e)=>{const{tech:t,main:{mediaGroups:n},mediaTypes:{[i]:{groups:s,tracks:r}}}=e;for(const a in n[i]){s[a]||(s[a]=[]);for(const l in n[i][a]){const c=n[i][a][l];if(!/^(?:CC|SERVICE)/.test(c.instreamId))continue;const f=t.options_.vhs&&t.options_.vhs.captionServices||{};let m={label:l,language:c.language,instreamId:c.instreamId,default:c.default&&c.autoselect};if(f[m.instreamId]&&(m=fe(m,f[m.instreamId])),m.default===void 0&&delete m.default,s[a].push(fe({id:l},c)),typeof r[l]>"u"){const b=t.addRemoteTextTrack({id:m.instreamId,kind:"captions",default:m.default,language:m.language,label:m.label},!1).track;r[l]=b}}}}},Dp=(i,e)=>{for(let t=0;t<i.length;t++)if(hl(e,i[t])||i[t].playlists&&Dp(i[t].playlists,e))return!0;return!1},Qv=(i,e)=>t=>{const{mainPlaylistLoader:n,mediaTypes:{[i]:{groups:s}}}=e,r=n.media();if(!r)return null;let a=null;r.attributes[i]&&(a=s[r.attributes[i]]);const l=Object.keys(s);if(!a)if(i==="AUDIO"&&l.length>1&&Ss(e.main))for(let c=0;c<l.length;c++){const f=s[l[c]];if(Dp(f,r)){a=f;break}}else s.main?a=s.main:l.length===1&&(a=s[l[0]]);return typeof t>"u"?a:t===null||!a?null:a.filter(c=>c.id===t.id)[0]||null},Jv={AUDIO:(i,e)=>()=>{const{mediaTypes:{[i]:{tracks:t}}}=e;for(const n in t)if(t[n].enabled)return t[n];return null},SUBTITLES:(i,e)=>()=>{const{mediaTypes:{[i]:{tracks:t}}}=e;for(const n in t)if(t[n].mode==="showing"||t[n].mode==="hidden")return t[n];return null}},Zv=(i,{mediaTypes:e})=>()=>{const t=e[i].activeTrack();return t?e[i].activeGroup(t):null},eS=i=>{["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(f=>{Yv[f](f,i)});const{mediaTypes:e,mainPlaylistLoader:t,tech:n,vhs:s,segmentLoaders:{["AUDIO"]:r,main:a}}=i;["AUDIO","SUBTITLES"].forEach(f=>{e[f].activeGroup=Qv(f,i),e[f].activeTrack=Jv[f](f,i),e[f].onGroupChanged=Gv(f,i),e[f].onGroupChanging=Xv(f,i),e[f].onTrackChanged=Kv(f,i),e[f].getActiveGroup=Zv(f,i)});const l=e.AUDIO.activeGroup();if(l){const f=(l.filter(m=>m.default)[0]||l[0]).id;e.AUDIO.tracks[f].enabled=!0,e.AUDIO.onGroupChanged(),e.AUDIO.onTrackChanged(),e.AUDIO.getActiveGroup().playlistLoader?(a.setAudio(!1),r.setAudio(!0)):a.setAudio(!0)}t.on("mediachange",()=>{["AUDIO","SUBTITLES"].forEach(f=>e[f].onGroupChanged())}),t.on("mediachanging",()=>{["AUDIO","SUBTITLES"].forEach(f=>e[f].onGroupChanging())});const c=()=>{e.AUDIO.onTrackChanged(),n.trigger({type:"usage",name:"vhs-audio-change"})};n.audioTracks().addEventListener("change",c),n.remoteTextTracks().addEventListener("change",e.SUBTITLES.onTrackChanged),s.on("dispose",()=>{n.audioTracks().removeEventListener("change",c),n.remoteTextTracks().removeEventListener("change",e.SUBTITLES.onTrackChanged)}),n.clearTracks("audio");for(const f in e.AUDIO.tracks)n.audioTracks().addTrack(e.AUDIO.tracks[f])},tS=()=>{const i={};return["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{i[e]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:ni,activeTrack:ni,getActiveGroup:ni,onGroupChanged:ni,onTrackChanged:ni,lastTrack_:null,logger_:Lt(`MediaGroups[${e}]`)}}),i};class Cd{constructor(){this.priority_=[],this.pathwayClones_=new Map}set version(e){e===1&&(this.version_=e)}set ttl(e){this.ttl_=e||300}set reloadUri(e){e&&(this.reloadUri_=pt(this.reloadUri_,e))}set priority(e){e&&e.length&&(this.priority_=e)}set pathwayClones(e){e&&e.length&&(this.pathwayClones_=new Map(e.map(t=>[t.ID,t])))}get version(){return this.version_}get ttl(){return this.ttl_}get reloadUri(){return this.reloadUri_}get priority(){return this.priority_}get pathwayClones(){return this.pathwayClones_}}class iS extends B.EventTarget{constructor(e,t){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new Cd,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.currentPathwayClones=new Map,this.nextPathwayClones=new Map,this.excludedSteeringManifestURLs=new Set,this.logger_=Lt("Content Steering"),this.xhr_=e,this.getBandwidth_=t}assignTagProperties(e,t){this.manifestType_=t.serverUri?"HLS":"DASH";const n=t.serverUri||t.serverURL;if(!n){this.logger_(`steering manifest URL is ${n}, cannot request steering manifest.`),this.trigger("error");return}if(n.startsWith("data:")){this.decodeDataUriManifest_(n.substring(n.indexOf(",")+1));return}this.steeringManifest.reloadUri=pt(e,n),this.defaultPathway=t.pathwayId||t.defaultServiceLocation,this.queryBeforeStart=t.queryBeforeStart,this.proxyServerUrl_=t.proxyServerURL,this.defaultPathway&&!this.queryBeforeStart&&this.trigger("content-steering")}requestSteeringManifest(e){const t=this.steeringManifest.reloadUri;if(!t)return;const n=e?t:this.getRequestURI(t);if(!n){this.logger_("No valid content steering manifest URIs. Stopping content steering."),this.trigger("error"),this.dispose();return}const s={contentSteeringInfo:{uri:n}};this.trigger({type:"contentsteeringloadstart",metadata:s}),this.request_=this.xhr_({uri:n,requestType:"content-steering-manifest"},(r,a)=>{if(r){if(a.status===410){this.logger_(`manifest request 410 ${r}.`),this.logger_(`There will be no more content steering requests to ${n} this session.`),this.excludedSteeringManifestURLs.add(n);return}if(a.status===429){const f=a.responseHeaders["retry-after"];this.logger_(`manifest request 429 ${r}.`),this.logger_(`content steering will retry in ${f} seconds.`),this.startTTLTimeout_(parseInt(f,10));return}this.logger_(`manifest failed to load ${r}.`),this.startTTLTimeout_();return}this.trigger({type:"contentsteeringloadcomplete",metadata:s});let l;try{l=JSON.parse(this.request_.responseText)}catch(f){const m={errorType:B.Error.StreamingContentSteeringParserError,error:f};this.trigger({type:"error",metadata:m})}this.assignSteeringProperties_(l);const c={contentSteeringInfo:s.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:"contentsteeringparsed",metadata:c}),this.startTTLTimeout_()})}setProxyServerUrl_(e){const t=new x.URL(e),n=new x.URL(this.proxyServerUrl_);return n.searchParams.set("url",encodeURI(t.toString())),this.setSteeringParams_(n.toString())}decodeDataUriManifest_(e){const t=JSON.parse(x.atob(e));this.assignSteeringProperties_(t)}setSteeringParams_(e){const t=new x.URL(e),n=this.getPathway(),s=this.getBandwidth_();if(n){const r=`_${this.manifestType_}_pathway`;t.searchParams.set(r,n)}if(s){const r=`_${this.manifestType_}_throughput`;t.searchParams.set(r,s)}return t.toString()}assignSteeringProperties_(e){if(this.steeringManifest.version=e.VERSION,!this.steeringManifest.version){this.logger_(`manifest version is ${e.VERSION}, which is not supported.`),this.trigger("error");return}this.steeringManifest.ttl=e.TTL,this.steeringManifest.reloadUri=e["RELOAD-URI"],this.steeringManifest.priority=e["PATHWAY-PRIORITY"]||e["SERVICE-LOCATION-PRIORITY"],this.steeringManifest.pathwayClones=e["PATHWAY-CLONES"],this.nextPathwayClones=this.steeringManifest.pathwayClones,this.availablePathways_.size||(this.logger_("There are no available pathways for content steering. Ending content steering."),this.trigger("error"),this.dispose());const t=(n=>{for(const s of n)if(this.availablePathways_.has(s))return s;return[...this.availablePathways_][0]})(this.steeringManifest.priority);this.currentPathway!==t&&(this.currentPathway=t,this.trigger("content-steering"))}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;const t=s=>this.excludedSteeringManifestURLs.has(s);if(this.proxyServerUrl_){const s=this.setProxyServerUrl_(e);if(!t(s))return s}const n=this.setSteeringParams_(e);return t(n)?null:n}startTTLTimeout_(e=this.steeringManifest.ttl){const t=e*1e3;this.ttlTimeout_=x.setTimeout(()=>{this.requestSteeringManifest()},t)}clearTTLTimeout_(){x.clearTimeout(this.ttlTimeout_),this.ttlTimeout_=null}abort(){this.request_&&this.request_.abort(),this.request_=null}dispose(){this.off("content-steering"),this.off("error"),this.abort(),this.clearTTLTimeout_(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=null,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.excludedSteeringManifestURLs=new Set,this.availablePathways_=new Set,this.steeringManifest=new Cd}addAvailablePathway(e){e&&this.availablePathways_.add(e)}clearAvailablePathways(){this.availablePathways_.clear()}excludePathway(e){return this.availablePathways_.delete(e)}didDASHTagChange(e,t){return!t&&this.steeringManifest.reloadUri||t&&(pt(e,t.serverURL)!==this.steeringManifest.reloadUri||t.defaultServiceLocation!==this.defaultPathway||t.queryBeforeStart!==this.queryBeforeStart||t.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}}const nS=(i,e)=>{let t=null;return(...n)=>{clearTimeout(t),t=setTimeout(()=>{i.apply(null,n)},e)}},sS=10;let yi;const rS=["mediaRequests","mediaRequestsAborted","mediaRequestsTimedout","mediaRequestsErrored","mediaTransferDuration","mediaBytesTransferred","mediaAppends"],aS=function(i){return this.audioSegmentLoader_[i]+this.mainSegmentLoader_[i]},oS=function({currentPlaylist:i,buffered:e,currentTime:t,nextPlaylist:n,bufferLowWaterLine:s,bufferHighWaterLine:r,duration:a,bufferBasedABR:l,log:c}){if(!n)return B.log.warn("We received no playlist to switch to. Please check your stream."),!1;const f=`allowing switch ${i&&i.id||"null"} -> ${n.id}`;if(!i)return c(`${f} as current playlist is not set`),!0;if(n.id===i.id)return!1;const m=!!tn(e,t).length;if(!i.endList)return!m&&typeof i.partTargetDuration=="number"?(c(`not ${f} as current playlist is live llhls, but currentTime isn't in buffered.`),!1):(c(`${f} as current playlist is live`),!0);const b=ll(e,t),C=l?We.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:We.MAX_BUFFER_LOW_WATER_LINE;if(a<C)return c(`${f} as duration < max low water line (${a} < ${C})`),!0;const w=n.attributes.BANDWIDTH,A=i.attributes.BANDWIDTH;if(w<A&&(!l||b<r)){let v=`${f} as next bandwidth < current bandwidth (${w} < ${A})`;return l&&(v+=` and forwardBuffer < bufferHighWaterLine (${b} < ${r})`),c(v),!0}if((!l||w>A)&&b>=s){let v=`${f} as forwardBuffer >= bufferLowWaterLine (${b} >= ${s})`;return l&&(v+=` and next bandwidth > current bandwidth (${w} > ${A})`),c(v),!0}return c(`not ${f} as no switching criteria met`),!1};class lS extends B.EventTarget{constructor(e){super(),this.fastQualityChange_=nS(this.fastQualityChange_.bind(this),100);const{src:t,withCredentials:n,tech:s,bandwidth:r,externVhs:a,useCueTags:l,playlistExclusionDuration:c,enableLowInitialPlaylist:f,sourceType:m,cacheEncryptionKeys:b,bufferBasedABR:C,leastPixelDiffSelector:w,captionServices:A,experimentalUseMMS:v}=e;if(!t)throw new Error("A non-empty playlist URL or JSON manifest string is required");let{maxPlaylistRetries:M}=e;(M===null||typeof M>"u")&&(M=1/0),yi=a,this.bufferBasedABR=!!C,this.leastPixelDiffSelector=!!w,this.withCredentials=n,this.tech_=s,this.vhs_=s.vhs,this.player_=e.player_,this.sourceType_=m,this.useCueTags_=l,this.playlistExclusionDuration=c,this.maxPlaylistRetries=M,this.enableLowInitialPlaylist=f,this.usingManagedMediaSource_=!1,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack("metadata","ad-cues"),this.cueTagsTrack_.inBandMetadataTrackDispatchType=""),this.requestOptions_={withCredentials:n,maxPlaylistRetries:M,timeout:null},this.on("error",this.pauseLoading),this.mediaTypes_=tS(),v&&x.ManagedMediaSource?(this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new x.ManagedMediaSource,this.usingManagedMediaSource_=!0,B.log("Using ManagedMediaSource")):x.MediaSource&&(this.mediaSource=new x.MediaSource),this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.load=this.load.bind(this),this.pause=this.pause.bind(this),this.mediaSource.addEventListener("durationchange",this.handleDurationChange_),this.mediaSource.addEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.addEventListener("sourceended",this.handleSourceEnded_),this.mediaSource.addEventListener("startstreaming",this.load),this.mediaSource.addEventListener("endstreaming",this.pause),this.seekable_=tt(),this.hasPlayed_=!1,this.syncController_=new qv(e),this.segmentMetadataTrack_=s.addRemoteTextTrack({kind:"metadata",label:"segment-metadata"},!1).track,this.decrypter_=new zv,this.sourceUpdater_=new Ap(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new Vv,this.keyStatusMap_=new Map;const D={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:A,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:r,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:b,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_==="dash"?new po(t,this.vhs_,fe(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new nn(t,this.vhs_,fe(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new mo(fe(D,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:"main"}),e),this.audioSegmentLoader_=new mo(fe(D,{loaderType:"audio"}),e),this.subtitleSegmentLoader_=new Nv(fe(D,{loaderType:"vtt",featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((F,P)=>{function $(){s.off("vttjserror",Y),F()}function Y(){s.off("vttjsloaded",$),P()}s.one("vttjsloaded",$),s.one("vttjserror",Y),s.addWebVttScript_()})}),e);const R=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new iS(this.vhs_.xhr,R),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one("loadedplaylist",()=>this.startABRTimer_()),this.tech_.on("pause",()=>this.stopABRTimer_()),this.tech_.on("play",()=>this.startABRTimer_())),rS.forEach(F=>{this[F+"_"]=aS.bind(this,F)}),this.logger_=Lt("pc"),this.triggeredFmp4Usage=!1,this.tech_.preload()==="none"?(this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one("play",this.loadOnPlay_)):this.mainPlaylistLoader_.load(),this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1;const N=this.tech_.preload()==="none"?"play":"loadstart";this.tech_.one(N,()=>{const F=Date.now();this.tech_.one("loadeddata",()=>{this.timeToLoadedData__=Date.now()-F,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends})})}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){const e=this.mainAppendsToLoadedData_(),t=this.audioAppendsToLoadedData_();return e===-1||t===-1?-1:e+t}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e="abr"){const t=this.selectPlaylist();t&&this.shouldSwitchToMedia_(t)&&this.switchMedia_(t,e)}switchMedia_(e,t,n){const s=this.media(),r=s&&(s.id||s.uri),a=e&&(e.id||e.uri);if(r&&r!==a){this.logger_(`switch media ${r} -> ${a} from ${t}`);const l={renditionInfo:{id:a,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:t};this.trigger({type:"renditionselected",metadata:l}),this.tech_.trigger({type:"usage",name:`vhs-rendition-change-${t}`})}this.mainPlaylistLoader_.media(e,n)}switchMediaForDASHContentSteering_(){["AUDIO","SUBTITLES","CLOSED-CAPTIONS"].forEach(e=>{const t=this.mediaTypes_[e],n=t?t.activeGroup():null,s=this.contentSteeringController_.getPathway();if(n&&s){const r=(n.length?n[0].playlists:n.playlists).filter(a=>a.attributes.serviceLocation===s);r.length&&this.mediaTypes_[e].activePlaylistLoader.media(r[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=x.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(x.clearInterval(this.abrTimer_),this.abrTimer_=null)}getAudioTrackPlaylists_(){const e=this.main(),t=e&&e.playlists||[];if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return t;const n=e.mediaGroups.AUDIO,s=Object.keys(n);let r;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)r=this.mediaTypes_.AUDIO.activeTrack();else{const l=n.main||s.length&&n[s[0]];for(const c in l)if(l[c].default){r={label:c};break}}if(!r)return t;const a=[];for(const l in n)if(n[l][r.label]){const c=n[l][r.label];if(c.playlists&&c.playlists.length)a.push.apply(a,c.playlists);else if(c.uri)a.push(c);else if(e.playlists.length)for(let f=0;f<e.playlists.length;f++){const m=e.playlists[f];m.attributes&&m.attributes.AUDIO&&m.attributes.AUDIO===l&&a.push(m)}}return a.length?a:t}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on("loadedmetadata",()=>{const e=this.mainPlaylistLoader_.media(),t=e.targetDuration*1.5*1e3;oo(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,e.endList&&this.tech_.preload()!=="none"&&(this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.mainSegmentLoader_.load()),eS({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),e),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media()?this.trigger("selectedinitialmedia"):this.mediaTypes_.AUDIO.activePlaylistLoader.one("loadedmetadata",()=>{this.trigger("selectedinitialmedia")})}),this.mainPlaylistLoader_.on("loadedplaylist",()=>{this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_);let e=this.mainPlaylistLoader_.media();if(!e){this.attachContentSteeringListeners_(),this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let t;if(this.enableLowInitialPlaylist&&(t=this.selectInitialPlaylist()),t||(t=this.selectPlaylist()),!t||!this.shouldSwitchToMedia_(t)||(this.initialMedia_=t,this.switchMedia_(this.initialMedia_,"initial"),!(this.sourceType_==="vhs-json"&&this.initialMedia_.segments)))return;e=this.initialMedia_}this.handleUpdatedMediaPlaylist(e)}),this.mainPlaylistLoader_.on("error",()=>{const e=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:e.playlist,error:e})}),this.mainPlaylistLoader_.on("mediachanging",()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on("mediachange",()=>{const e=this.mainPlaylistLoader_.media(),t=e.targetDuration*1.5*1e3;oo(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,this.sourceType_==="dash"&&this.mainPlaylistLoader_.isPaused&&this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_?this.runFastQualitySwitch_():this.mainSegmentLoader_.load(),this.tech_.trigger({type:"mediachange",bubbles:!0})}),this.mainPlaylistLoader_.on("playlistunchanged",()=>{const e=this.mainPlaylistLoader_.media();e.lastExcludeReason_!=="playlist-unchanged"&&this.stuckAtPlaylistEnd_(e)&&(this.excludePlaylist({error:{message:"Playlist no longer updating.",reason:"playlist-unchanged"}}),this.tech_.trigger("playliststuck"))}),this.mainPlaylistLoader_.on("renditiondisabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-disabled"})}),this.mainPlaylistLoader_.on("renditionenabled",()=>{this.tech_.trigger({type:"usage",name:"vhs-rendition-enabled"})}),["manifestrequeststart","manifestrequestcomplete","manifestparsestart","manifestparsecomplete","playlistrequeststart","playlistrequestcomplete","playlistparsestart","playlistparsecomplete","renditiondisabled","renditionenabled"].forEach(e=>{this.mainPlaylistLoader_.on(e,t=>{this.player_.trigger(je({},t))})})}handleUpdatedMediaPlaylist(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_&&this.runFastQualitySwitch_(),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load())}triggerPresenceUsage_(e,t){const n=e.mediaGroups||{};let s=!0;const r=Object.keys(n.AUDIO);for(const a in n.AUDIO)for(const l in n.AUDIO[a])n.AUDIO[a][l].uri||(s=!1);s&&this.tech_.trigger({type:"usage",name:"vhs-demuxed"}),Object.keys(n.SUBTITLES).length&&this.tech_.trigger({type:"usage",name:"vhs-webvtt"}),yi.Playlist.isAes(t)&&this.tech_.trigger({type:"usage",name:"vhs-aes"}),r.length&&Object.keys(n.AUDIO[r[0]]).length>1&&this.tech_.trigger({type:"usage",name:"vhs-alternate-audio"}),this.useCueTags_&&this.tech_.trigger({type:"usage",name:"vhs-playlist-cue-tags"})}shouldSwitchToMedia_(e){const t=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,n=this.tech_.currentTime(),s=this.bufferLowWaterLine(),r=this.bufferHighWaterLine(),a=this.tech_.buffered();return oS({buffered:a,currentTime:n,currentPlaylist:t,nextPlaylist:e,bufferLowWaterLine:s,bufferHighWaterLine:r,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_})}setupSegmentLoaderListeners_(){this.mainSegmentLoader_.on("bandwidthupdate",()=>{this.checkABR_("bandwidthupdate"),this.tech_.trigger("bandwidthupdate")}),this.mainSegmentLoader_.on("timeout",()=>{this.bufferBasedABR&&this.mainSegmentLoader_.load()}),this.bufferBasedABR||this.mainSegmentLoader_.on("progress",()=>{this.trigger("progress")}),this.mainSegmentLoader_.on("error",()=>{const t=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:t.playlist,error:t})}),this.mainSegmentLoader_.on("appenderror",()=>{this.error=this.mainSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on("timestampoffset",()=>{this.tech_.trigger({type:"usage",name:"vhs-timestamp-offset"})}),this.audioSegmentLoader_.on("syncinfoupdate",()=>{this.onSyncInfoUpdate_()}),this.audioSegmentLoader_.on("appenderror",()=>{this.error=this.audioSegmentLoader_.error_,this.trigger("error")}),this.mainSegmentLoader_.on("ended",()=>{this.logger_("main segment loader ended"),this.onEndOfStream()}),this.timelineChangeController_.on("audioTimelineBehind",()=>{const t=this.audioSegmentLoader_.pendingSegment_;if(!t||!t.segment||!t.segment.syncInfo)return;const n=t.segment.syncInfo.end+.01;this.tech_.setCurrentTime(n)}),this.timelineChangeController_.on("fixBadTimelineChange",()=>{this.logger_("Fix bad timeline change. Restarting al segment loaders..."),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}),this.mainSegmentLoader_.on("earlyabort",t=>{this.bufferBasedABR||(this.delegateLoaders_("all",["abort"]),this.excludePlaylist({error:{message:"Aborted early because there isn't enough bandwidth to complete the request without rebuffering."},playlistExclusionDuration:sS}))});const e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();const t=this.getCodecsOrExclude_();t&&this.sourceUpdater_.addOrChangeSourceBuffers(t)};this.mainSegmentLoader_.on("trackinfo",e),this.audioSegmentLoader_.on("trackinfo",e),this.mainSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("fmp4",()=>{this.triggeredFmp4Usage||(this.tech_.trigger({type:"usage",name:"vhs-fmp4"}),this.triggeredFmp4Usage=!0)}),this.audioSegmentLoader_.on("ended",()=>{this.logger_("audioSegmentLoader ended"),this.onEndOfStream()}),["segmentselected","segmentloadstart","segmentloaded","segmentkeyloadstart","segmentkeyloadcomplete","segmentdecryptionstart","segmentdecryptioncomplete","segmenttransmuxingstart","segmenttransmuxingcomplete","segmenttransmuxingtrackinfoavailable","segmenttransmuxingtiminginfoavailable","segmentappendstart","appendsdone","bandwidthupdated","timelinechange","codecschange"].forEach(t=>{this.mainSegmentLoader_.on(t,n=>{this.player_.trigger(je({},n))}),this.audioSegmentLoader_.on(t,n=>{this.player_.trigger(je({},n))}),this.subtitleSegmentLoader_.on(t,n=>{this.player_.trigger(je({},n))})})}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}pause(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}fastQualityChange_(e=this.selectPlaylist()){if(e&&e===this.mainPlaylistLoader_.media()){this.logger_("skipping fastQualityChange because new media is same as old");return}this.switchMedia_(e,"fast-quality"),this.waitingForFastQualityPlaylistReceived_=!0}runFastQualitySwitch_(){this.waitingForFastQualityPlaylistReceived_=!1,this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}play(){if(this.setupFirstPlay())return;this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();const e=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<e.start(0))return this.tech_.setCurrentTime(e.end(e.length-1))}setupFirstPlay(){const e=this.mainPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_)return!1;if(!e.endList||e.start){const t=this.seekable();if(!t.length)return!1;const n=t.end(0);let s=n;if(e.start){const r=e.start.timeOffset;r<0?s=Math.max(n+r,t.start(0)):s=Math.min(n,r)}this.trigger("firstplay"),this.tech_.setCurrentTime(s)}return this.hasPlayed_=!0,this.load(),!0}handleSourceOpen_(){if(this.tryToCreateSourceBuffers_(),this.tech_.autoplay()){const e=this.tech_.play();typeof e<"u"&&typeof e.then=="function"&&e.then(null,t=>{})}this.trigger("sourceopen")}handleSourceEnded_(){if(!this.inbandTextTracks_.metadataTrack_)return;const e=this.inbandTextTracks_.metadataTrack_.cues;if(!e||!e.length)return;const t=this.duration();e[e.length-1].endTime=isNaN(t)||Math.abs(t)===1/0?Number.MAX_VALUE:t}handleDurationChange_(){this.tech_.trigger("durationchange")}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){const t=this.mainSegmentLoader_.getCurrentMediaInfo_();!t||t.hasVideo?e=e&&this.audioSegmentLoader_.ended_:e=this.audioSegmentLoader_.ended_}e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream())}stuckAtPlaylistEnd_(e){if(!this.seekable().length)return!1;const t=this.syncController_.getExpiredTime(e,this.duration());if(t===null)return!1;const n=yi.Playlist.playlistEnd(e,t),s=this.tech_.currentTime(),r=this.tech_.buffered();if(!r.length)return n-s<=Kt;const a=r.end(r.length-1);return a-s<=Kt&&n-a<=Kt}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:t={},playlistExclusionDuration:n}){if(e=e||this.mainPlaylistLoader_.media(),n=n||t.playlistExclusionDuration||this.playlistExclusionDuration,!e){this.error=t,this.mediaSource.readyState!=="open"?this.trigger("error"):this.sourceUpdater_.endOfStream("network");return}e.playlistErrors_++;const s=this.mainPlaylistLoader_.main.playlists,r=s.filter(ta),a=r.length===1&&r[0]===e;if(s.length===1&&n!==1/0)return B.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger("retryplaylist"),this.mainPlaylistLoader_.load(a);if(a){if(this.main().contentSteering){const A=this.pathwayAttribute_(e),v=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(A),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(A)},v);return}let w=!1;s.forEach(A=>{if(A===e)return;const v=A.excludeUntil;typeof v<"u"&&v!==1/0&&(w=!0,delete A.excludeUntil)}),w&&(B.log.warn("Removing other playlists from the exclusion list because the last rendition is about to be excluded."),this.tech_.trigger("retryplaylist"))}let l;e.playlistErrors_>this.maxPlaylistRetries?l=1/0:l=Date.now()+n*1e3,e.excludeUntil=l,t.reason&&(e.lastExcludeReason_=t.reason),this.tech_.trigger("excludeplaylist"),this.tech_.trigger({type:"usage",name:"vhs-rendition-excluded"});const c=this.selectPlaylist();if(!c){this.error="Playback cannot continue. No available working or supported playlists.",this.trigger("error");return}const f=t.internal?this.logger_:B.log.warn,m=t.message?" "+t.message:"";f(`${t.internal?"Internal problem":"Problem"} encountered with playlist ${e.id}.${m} Switching to playlist ${c.id}.`),c.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_("audio",["abort","pause"]),c.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_("subtitle",["abort","pause"]),this.delegateLoaders_("main",["abort","pause"]);const b=c.targetDuration/2*1e3||5*1e3,C=typeof c.lastRequest=="number"&&Date.now()-c.lastRequest<=b;return this.switchMedia_(c,"exclude",a||C)}pauseLoading(){this.delegateLoaders_("all",["abort","pause"]),this.stopABRTimer_()}delegateLoaders_(e,t){const n=[],s=e==="all";(s||e==="main")&&n.push(this.mainPlaylistLoader_);const r=[];(s||e==="audio")&&r.push("AUDIO"),(s||e==="subtitle")&&(r.push("CLOSED-CAPTIONS"),r.push("SUBTITLES")),r.forEach(a=>{const l=this.mediaTypes_[a]&&this.mediaTypes_[a].activePlaylistLoader;l&&n.push(l)}),["main","audio","subtitle"].forEach(a=>{const l=this[`${a}SegmentLoader_`];l&&(e===a||e==="all")&&n.push(l)}),n.forEach(a=>t.forEach(l=>{typeof a[l]=="function"&&a[l]()}))}setCurrentTime(e){const t=tn(this.tech_.buffered(),e);if(!(this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media())||!this.mainPlaylistLoader_.media().segments)return 0;if(t&&t.length)return e;this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}duration(){if(!this.mainPlaylistLoader_)return 0;const e=this.mainPlaylistLoader_.media();return e?e.endList?this.mediaSource?this.mediaSource.duration:yi.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}getSeekableRange_(e,t){const n=e.media();if(!n)return null;const s=this.syncController_.getMediaSequenceSync(t);if(s&&s.isReliable){const l=s.start,c=s.end;if(!isFinite(l)||!isFinite(c))return null;const f=yi.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,n),m=Math.max(0,c-f);return m<l?null:tt([[l,m]])}const r=this.syncController_.getExpiredTime(n,this.duration());if(r===null)return null;const a=yi.Playlist.seekable(n,r,yi.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,n));return a.length?a:null}computeFinalSeekable_(e,t){if(!t)return e;const n=e.start(0),s=e.end(0),r=t.start(0),a=t.end(0);return r>s||n>a?e:tt([[Math.max(n,r),Math.min(s,a)]])}onSyncInfoUpdate_(){if(!this.mainPlaylistLoader_)return;const e=this.getSeekableRange_(this.mainPlaylistLoader_,"main");if(!e)return;let t;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(t=this.getSeekableRange_(this.mediaTypes_.AUDIO.activePlaylistLoader,"audio"),!t))return;const n=this.seekable_;if(this.seekable_=this.computeFinalSeekable_(e,t),!this.seekable_||n&&n.length&&this.seekable_.length&&n.start(0)===this.seekable_.start(0)&&n.end(0)===this.seekable_.end(0))return;this.logger_(`seekable updated [${Vc(this.seekable_)}]`);const s={seekableRanges:this.seekable_};this.trigger({type:"seekablerangeschanged",metadata:s}),this.tech_.trigger("seekablechanged")}updateDuration(e){if(this.updateDuration_&&(this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.updateDuration_=null),this.mediaSource.readyState!=="open"){this.updateDuration_=this.updateDuration.bind(this,e),this.mediaSource.addEventListener("sourceopen",this.updateDuration_);return}if(e){const s=this.seekable();if(!s.length)return;(isNaN(this.mediaSource.duration)||this.mediaSource.duration<s.end(s.length-1))&&this.sourceUpdater_.setDuration(s.end(s.length-1));return}const t=this.tech_.buffered();let n=yi.Playlist.duration(this.mainPlaylistLoader_.media());t.length>0&&(n=Math.max(n,t.end(t.length-1))),this.mediaSource.duration!==n&&this.sourceUpdater_.setDuration(n)}dispose(){this.trigger("dispose"),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.contentSteeringController_.dispose(),this.keyStatusMap_.clear(),this.loadOnPlay_&&this.tech_.off("play",this.loadOnPlay_),["AUDIO","SUBTITLES"].forEach(e=>{const t=this.mediaTypes_[e].groups;for(const n in t)t[n].forEach(s=>{s.playlistLoader&&s.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener("sourceopen",this.updateDuration_),this.mediaSource.removeEventListener("durationchange",this.handleDurationChange_),this.mediaSource.removeEventListener("sourceopen",this.handleSourceOpen_),this.mediaSource.removeEventListener("sourceended",this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){const e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,t=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),n=e?!!this.audioSegmentLoader_.getCurrentMediaInfo_():!0;return!(!t||!n)}getCodecsOrExclude_(){const e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},t=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;const n=hs(this.main(),t),s={},r=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(s.video=n.video||e.main.videoCodec||J_),e.main.isMuxed&&(s.video+=`,${n.audio||e.main.audioCodec||vu}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||r)&&(s.audio=n.audio||e.main.audioCodec||e.audio.audioCodec||vu,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!s.audio&&!s.video){this.excludePlaylist({playlistToExclude:t,error:{message:"Could not determine codecs for playlist."},playlistExclusionDuration:1/0});return}const a=(f,m)=>f?as(m,this.usingManagedMediaSource_):Aa(m),l={};let c;if(["video","audio"].forEach(function(f){if(s.hasOwnProperty(f)&&!a(e[f].isFmp4,s[f])){const m=e[f].isFmp4?"browser":"muxer";l[m]=l[m]||[],l[m].push(s[f]),f==="audio"&&(c=m)}}),r&&c&&t.attributes.AUDIO){const f=t.attributes.AUDIO;this.main().playlists.forEach(m=>{(m.attributes&&m.attributes.AUDIO)===f&&m!==t&&(m.excludeUntil=1/0)}),this.logger_(`excluding audio group ${f} as ${c} does not support codec(s): "${s.audio}"`)}if(Object.keys(l).length){const f=Object.keys(l).reduce((m,b)=>(m&&(m+=", "),m+=`${b} does not support codec(s): "${l[b].join(",")}"`,m),"")+".";this.excludePlaylist({playlistToExclude:t,error:{internal:!0,message:f},playlistExclusionDuration:1/0});return}if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){const f=[];if(["video","audio"].forEach(m=>{const b=(Ht(this.sourceUpdater_.codecs[m]||"")[0]||{}).type,C=(Ht(s[m]||"")[0]||{}).type;b&&C&&b.toLowerCase()!==C.toLowerCase()&&f.push(`"${this.sourceUpdater_.codecs[m]}" -> "${s[m]}"`)}),f.length){this.excludePlaylist({playlistToExclude:t,error:{message:`Codec switching not supported: ${f.join(", ")}.`,internal:!0},playlistExclusionDuration:1/0});return}}return s}tryToCreateSourceBuffers_(){if(this.mediaSource.readyState!=="open"||this.sourceUpdater_.hasCreatedSourceBuffers()||!this.areMediaTypesKnown_())return;const e=this.getCodecsOrExclude_();if(!e)return;this.sourceUpdater_.createSourceBuffers(e);const t=[e.video,e.audio].filter(Boolean).join(",");this.excludeIncompatibleVariants_(t)}excludeUnsupportedVariants_(){const e=this.main().playlists,t=[];Object.keys(e).forEach(n=>{const s=e[n];if(t.indexOf(s.id)!==-1)return;t.push(s.id);const r=hs(this.main,s),a=[];r.audio&&!Aa(r.audio)&&!as(r.audio,this.usingManagedMediaSource_)&&a.push(`audio codec ${r.audio}`),r.video&&!Aa(r.video)&&!as(r.video,this.usingManagedMediaSource_)&&a.push(`video codec ${r.video}`),r.text&&r.text==="stpp.ttml.im1t"&&a.push(`text codec ${r.text}`),a.length&&(s.excludeUntil=1/0,this.logger_(`excluding ${s.id} for unsupported: ${a.join(", ")}`))})}excludeIncompatibleVariants_(e){const t=[],n=this.main().playlists,s=Ir(Ht(e)),r=pd(s),a=s.video&&Ht(s.video)[0]||null,l=s.audio&&Ht(s.audio)[0]||null;Object.keys(n).forEach(c=>{const f=n[c];if(t.indexOf(f.id)!==-1||f.excludeUntil===1/0)return;t.push(f.id);const m=[],b=hs(this.mainPlaylistLoader_.main,f),C=pd(b);if(!(!b.audio&&!b.video)){if(C!==r&&m.push(`codec count "${C}" !== "${r}"`),!this.sourceUpdater_.canChangeType()){const w=b.video&&Ht(b.video)[0]||null,A=b.audio&&Ht(b.audio)[0]||null;w&&a&&w.type.toLowerCase()!==a.type.toLowerCase()&&m.push(`video codec "${w.type}" !== "${a.type}"`),A&&l&&A.type.toLowerCase()!==l.type.toLowerCase()&&m.push(`audio codec "${A.type}" !== "${l.type}"`)}m.length&&(f.excludeUntil=1/0,this.logger_(`excluding ${f.id}: ${m.join(" && ")}`))}})}updateAdCues_(e){let t=0;const n=this.seekable();n.length&&(t=n.start(0)),Fv(e,this.cueTagsTrack_,t)}goalBufferLength(){const e=this.tech_.currentTime(),t=We.GOAL_BUFFER_LENGTH,n=We.GOAL_BUFFER_LENGTH_RATE,s=Math.max(t,We.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*n,s)}bufferLowWaterLine(){const e=this.tech_.currentTime(),t=We.BUFFER_LOW_WATER_LINE,n=We.BUFFER_LOW_WATER_LINE_RATE,s=Math.max(t,We.MAX_BUFFER_LOW_WATER_LINE),r=Math.max(t,We.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*n,this.bufferBasedABR?r:s)}bufferHighWaterLine(){return We.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){md(this.inbandTextTracks_,"com.apple.streaming",this.tech_),_v({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,t,n){const s=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();md(this.inbandTextTracks_,e,this.tech_),fv({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:s,videoDuration:n})}pathwayAttribute_(e){return e.attributes["PATHWAY-ID"]||e.attributes.serviceLocation}initContentSteeringController_(){const e=this.main();if(e.contentSteering){for(const t of e.playlists)this.contentSteeringController_.addAvailablePathway(this.pathwayAttribute_(t));if(this.contentSteeringController_.assignTagProperties(e.uri,e.contentSteering),this.contentSteeringController_.queryBeforeStart){this.contentSteeringController_.requestSteeringManifest(!0);return}this.tech_.one("canplay",()=>{this.contentSteeringController_.requestSteeringManifest()})}}resetContentSteeringController_(){this.contentSteeringController_.clearAvailablePathways(),this.contentSteeringController_.dispose(),this.initContentSteeringController_()}attachContentSteeringListeners_(){this.contentSteeringController_.on("content-steering",this.excludeThenChangePathway_.bind(this)),["contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"].forEach(e=>{this.contentSteeringController_.on(e,t=>{this.trigger(je({},t))})}),this.sourceType_==="dash"&&this.mainPlaylistLoader_.on("loadedplaylist",()=>{const e=this.main();(this.contentSteeringController_.didDASHTagChange(e.uri,e.contentSteering)||(()=>{const t=this.contentSteeringController_.getAvailablePathways(),n=[];for(const s of e.playlists){const r=s.attributes.serviceLocation;if(r&&(n.push(r),!t.has(r)))return!0}return!!(!n.length&&t.size)})())&&this.resetContentSteeringController_()})}excludeThenChangePathway_(){const e=this.contentSteeringController_.getPathway();if(!e)return;this.handlePathwayClones_();const t=this.main().playlists,n=new Set;let s=!1;Object.keys(t).forEach(r=>{const a=t[r],l=this.pathwayAttribute_(a),c=l&&e!==l;a.excludeUntil===1/0&&a.lastExcludeReason_==="content-steering"&&!c&&(delete a.excludeUntil,delete a.lastExcludeReason_,s=!0);const f=!a.excludeUntil&&a.excludeUntil!==1/0;!n.has(a.id)&&c&&f&&(n.add(a.id),a.excludeUntil=1/0,a.lastExcludeReason_="content-steering",this.logger_(`excluding ${a.id} for ${a.lastExcludeReason_}`))}),this.contentSteeringController_.manifestType_==="DASH"&&Object.keys(this.mediaTypes_).forEach(r=>{const a=this.mediaTypes_[r];if(a.activePlaylistLoader){const l=a.activePlaylistLoader.media_;l&&l.attributes.serviceLocation!==e&&(s=!0)}}),s&&this.changeSegmentPathway_()}handlePathwayClones_(){const e=this.main().playlists,t=this.contentSteeringController_.currentPathwayClones,n=this.contentSteeringController_.nextPathwayClones;if(t&&t.size||n&&n.size){for(const[s,r]of t.entries())n.get(s)||(this.mainPlaylistLoader_.updateOrDeleteClone(r),this.contentSteeringController_.excludePathway(s));for(const[s,r]of n.entries()){const a=t.get(s);if(!a){e.filter(l=>l.attributes["PATHWAY-ID"]===r["BASE-ID"]).forEach(l=>{this.mainPlaylistLoader_.addClonePathway(r,l)}),this.contentSteeringController_.addAvailablePathway(s);continue}this.equalPathwayClones_(a,r)||(this.mainPlaylistLoader_.updateOrDeleteClone(r,!0),this.contentSteeringController_.addAvailablePathway(s))}this.contentSteeringController_.currentPathwayClones=new Map(JSON.parse(JSON.stringify([...n])))}}equalPathwayClones_(e,t){if(e["BASE-ID"]!==t["BASE-ID"]||e.ID!==t.ID||e["URI-REPLACEMENT"].HOST!==t["URI-REPLACEMENT"].HOST)return!1;const n=e["URI-REPLACEMENT"].PARAMS,s=t["URI-REPLACEMENT"].PARAMS;for(const r in n)if(n[r]!==s[r])return!1;for(const r in s)if(n[r]!==s[r])return!1;return!0}changeSegmentPathway_(){const e=this.selectPlaylist();this.pauseLoading(),this.contentSteeringController_.manifestType_==="DASH"&&this.switchMediaForDASHContentSteering_(),this.switchMedia_(e,"content-steering")}excludeNonUsablePlaylistsByKeyId_(){if(!this.mainPlaylistLoader_||!this.mainPlaylistLoader_.main)return;let e=0;const t="non-usable";this.mainPlaylistLoader_.main.playlists.forEach(n=>{const s=this.mainPlaylistLoader_.getKeyIdSet(n);!s||!s.size||s.forEach(r=>{const a="usable",l=this.keyStatusMap_.has(r)&&this.keyStatusMap_.get(r)===a,c=n.lastExcludeReason_===t&&n.excludeUntil===1/0;l?l&&c&&(delete n.excludeUntil,delete n.lastExcludeReason_,this.logger_(`enabling playlist ${n.id} because key ID ${r} is ${a}`)):(n.excludeUntil!==1/0&&n.lastExcludeReason_!==t&&(n.excludeUntil=1/0,n.lastExcludeReason_=t,this.logger_(`excluding playlist ${n.id} because the key ID ${r} doesn't exist in the keyStatusMap or is not ${a}`)),e++)})}),e>=this.mainPlaylistLoader_.main.playlists.length&&this.mainPlaylistLoader_.main.playlists.forEach(n=>{const s=n&&n.attributes&&n.attributes.RESOLUTION&&n.attributes.RESOLUTION.height<720,r=n.excludeUntil===1/0&&n.lastExcludeReason_===t;s&&r&&(delete n.excludeUntil,B.log.warn(`enabling non-HD playlist ${n.id} because all playlists were excluded due to ${t} key IDs`))})}addKeyStatus_(e,t){const n=(typeof e=="string"?e:Rv(e)).slice(0,32).toLowerCase();this.logger_(`KeyStatus '${t}' with key ID ${n} added to the keyStatusMap`),this.keyStatusMap_.set(n,t)}updatePlaylistByKeyStatus(e,t){this.addKeyStatus_(e,t),this.waitingForFastQualityPlaylistReceived_||this.excludeNonUsableThenChangePlaylist_(),this.mainPlaylistLoader_.off("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this)),this.mainPlaylistLoader_.on("loadedplaylist",this.excludeNonUsableThenChangePlaylist_.bind(this))}excludeNonUsableThenChangePlaylist_(){this.excludeNonUsablePlaylistsByKeyId_(),this.fastQualityChange_()}}const uS=(i,e,t)=>n=>{const s=i.main.playlists[e],r=dl(s),a=ta(s);if(typeof n>"u")return a;n?delete s.disabled:s.disabled=!0;const l={renditionInfo:{id:e,bandwidth:s.attributes.BANDWIDTH,resolution:s.attributes.RESOLUTION,codecs:s.attributes.CODECS},cause:"fast-quality"};return n!==a&&!r&&(n?(t(s),i.trigger({type:"renditionenabled",metadata:l})):i.trigger({type:"renditiondisabled",metadata:l})),n};class dS{constructor(e,t,n){const{playlistController_:s}=e,r=s.fastQualityChange_.bind(s);if(t.attributes){const a=t.attributes.RESOLUTION;this.width=a&&a.width,this.height=a&&a.height,this.bandwidth=t.attributes.BANDWIDTH,this.frameRate=t.attributes["FRAME-RATE"]}this.codecs=hs(s.main(),t),this.playlist=t,this.id=n,this.enabled=uS(e.playlists,t.id,r)}}const hS=function(i){i.representations=()=>{const e=i.playlistController_.main(),t=Ss(e)?i.playlistController_.getAudioTrackPlaylists_():e.playlists;return t?t.filter(n=>!dl(n)).map((n,s)=>new dS(i,n,n.id)):[]}},Id=["seeking","seeked","pause","playing","error"];class cS extends B.EventTarget{constructor(e){super(),this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.playedRanges_=[],this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=Lt("PlaybackWatcher"),this.logger_("initialize");const t=()=>this.monitorCurrentTime_(),n=()=>this.monitorCurrentTime_(),s=()=>this.techWaiting_(),r=()=>this.resetTimeUpdate_(),a=this.playlistController_,l=["main","subtitle","audio"],c={};l.forEach(m=>{c[m]={reset:()=>this.resetSegmentDownloads_(m),updateend:()=>this.checkSegmentDownloads_(m)},a[`${m}SegmentLoader_`].on("appendsdone",c[m].updateend),a[`${m}SegmentLoader_`].on("playlistupdate",c[m].reset),this.tech_.on(["seeked","seeking"],c[m].reset)});const f=m=>{["main","audio"].forEach(b=>{a[`${b}SegmentLoader_`][m]("appended",this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),f("off"))},this.clearSeekingAppendCheck_=()=>f("off"),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),f("on")},this.tech_.on("seeked",this.clearSeekingAppendCheck_),this.tech_.on("seeking",this.watchForBadSeeking_),this.tech_.on("waiting",s),this.tech_.on(Id,r),this.tech_.on("canplay",n),this.tech_.one("play",t),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_("dispose"),this.tech_.off("waiting",s),this.tech_.off(Id,r),this.tech_.off("canplay",n),this.tech_.off("play",t),this.tech_.off("seeking",this.watchForBadSeeking_),this.tech_.off("seeked",this.clearSeekingAppendCheck_),l.forEach(m=>{a[`${m}SegmentLoader_`].off("appendsdone",c[m].updateend),a[`${m}SegmentLoader_`].off("playlistupdate",c[m].reset),this.tech_.off(["seeked","seeking"],c[m].reset)}),this.checkCurrentTimeTimeout_&&x.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&x.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=x.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){const t=this.playlistController_[`${e}SegmentLoader_`];this[`${e}StalledDownloads_`]>0&&this.logger_(`resetting possible stalled download count for ${e} loader`),this[`${e}StalledDownloads_`]=0,this[`${e}Buffered_`]=t.buffered_()}checkSegmentDownloads_(e){const t=this.playlistController_,n=t[`${e}SegmentLoader_`],s=n.buffered_(),r=Yb(this[`${e}Buffered_`],s);if(this[`${e}Buffered_`]=s,r){const a={bufferedRanges:s};t.trigger({type:"bufferedrangeschanged",metadata:a}),this.resetSegmentDownloads_(e);return}this[`${e}StalledDownloads_`]++,this.logger_(`found #${this[`${e}StalledDownloads_`]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:n.playlist_&&n.playlist_.id,buffered:Ui(s)}),!(this[`${e}StalledDownloads_`]<10)&&(this.logger_(`${e} loader stalled download exclusion`),this.resetSegmentDownloads_(e),this.tech_.trigger({type:"usage",name:`vhs-${e}-download-exclusion`}),e!=="subtitle"&&t.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0}))}checkCurrentTime_(){if(this.tech_.paused()||this.tech_.seeking())return;const e=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===e&&(!t.length||e+Kt>=t.end(t.length-1)))return this.techWaiting_();if(this.consecutiveUpdates>=5&&e===this.lastRecordedTime)this.consecutiveUpdates++,this.waiting_();else if(e===this.lastRecordedTime)this.consecutiveUpdates++;else{this.playedRanges_.push(tt([this.lastRecordedTime,e]));const n={playedRanges:this.playedRanges_};this.playlistController_.trigger({type:"playedrangeschanged",metadata:n}),this.consecutiveUpdates=0,this.lastRecordedTime=e}}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;const e=this.seekable(),t=this.tech_.currentTime(),n=this.afterSeekableWindow_(e,t,this.media(),this.allowSeeksWithinUnsafeLiveWindow);let s;if(n&&(s=e.end(e.length-1)),this.beforeSeekableWindow_(e,t)){const w=e.start(0);s=w+(w===e.end(0)?0:Kt)}if(typeof s<"u")return this.logger_(`Trying to seek outside of seekable at time ${t} with seekable range ${Vc(e)}. Seeking to ${s}.`),this.tech_.setCurrentTime(s),!0;const r=this.playlistController_.sourceUpdater_,a=this.tech_.buffered(),l=r.audioBuffer?r.audioBuffered():null,c=r.videoBuffer?r.videoBuffered():null,f=this.media(),m=f.partTargetDuration?f.partTargetDuration:(f.targetDuration-Xt)*2,b=[l,c];for(let w=0;w<b.length;w++)if(b[w]&&ll(b[w],t)<m)return!1;const C=er(a,t);return C.length===0?!1:(s=C.start(0)+Kt,this.logger_(`Buffered region starts (${C.start(0)}) just beyond seek point (${t}). Seeking to ${s}.`),this.tech_.setCurrentTime(s),!0)}waiting_(){if(this.techWaiting_())return;const e=this.tech_.currentTime(),t=this.tech_.buffered(),n=tn(t,e);if(n.length&&e+3<=n.end(0)){this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${n.start(0)} -> ${n.end(0)}]. Attempting to resume playback by seeking to the current time.`),this.tech_.trigger({type:"usage",name:"vhs-unknown-waiting"});return}}techWaiting_(){const e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking())return!0;if(this.beforeSeekableWindow_(e,t)){const a=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${t}. Seeking to live point (seekable end) ${a}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(a),this.tech_.trigger({type:"usage",name:"vhs-live-resync"}),!0}const n=this.tech_.vhs.playlistController_.sourceUpdater_,s=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:n.audioBuffered(),videoBuffered:n.videoBuffered(),currentTime:t}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:"usage",name:"vhs-video-underflow"}),!0;const r=er(s,t);return r.length>0?(this.logger_(`Stopped at ${t} and seeking to ${r.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(t),!0):!1}afterSeekableWindow_(e,t,n,s=!1){if(!e.length)return!1;let r=e.end(e.length-1)+Kt;const a=!n.endList,l=typeof n.partTargetDuration=="number";return a&&(l||s)&&(r=e.end(e.length-1)+n.targetDuration*3),t>r}beforeSeekableWindow_(e,t){return!!(e.length&&e.start(0)>0&&t<e.start(0)-this.liveRangeSafeTimeDelta)}videoUnderflow_({videoBuffered:e,audioBuffered:t,currentTime:n}){if(!e)return;let s;if(e.length&&t.length){const r=tn(e,n-3),a=tn(e,n),l=tn(t,n);l.length&&!a.length&&r.length&&(s={start:r.end(0),end:l.end(0)})}else er(e,n).length||(s=this.gapFromVideoUnderflow_(e,n));return s?(this.logger_(`Encountered a gap in video from ${s.start} to ${s.end}. Seeking to current time ${n}`),!0):!1}skipTheGap_(e){const t=this.tech_.buffered(),n=this.tech_.currentTime(),s=er(t,n);if(this.resetTimeUpdate_(),s.length===0||n!==e)return;this.logger_("skipTheGap_:","currentTime:",n,"scheduled currentTime:",e,"nextRange start:",s.start(0)),this.tech_.setCurrentTime(s.start(0)+Xt);const r={gapInfo:{from:n,to:s.start(0)}};this.playlistController_.trigger({type:"gapjumped",metadata:r}),this.tech_.trigger({type:"usage",name:"vhs-gap-skip"})}gapFromVideoUnderflow_(e,t){const n=Gb(e);for(let s=0;s<n.length;s++){const r=n.start(s),a=n.end(s);if(t-r<4&&t-r>2)return{start:r,end:a}}return null}}const pS={errorInterval:30,getSource(i){const e=this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource();return i(e)}},Op=function(i,e){let t=0,n=0;const s=fe(pS,e);i.ready(()=>{i.trigger({type:"usage",name:"vhs-error-reload-initialized"})});const r=function(){n&&i.currentTime(n)},a=function(m){m!=null&&(n=i.duration()!==1/0&&i.currentTime()||0,i.one("loadedmetadata",r),i.src(m),i.trigger({type:"usage",name:"vhs-error-reload"}),i.play())},l=function(){if(Date.now()-t<s.errorInterval*1e3){i.trigger({type:"usage",name:"vhs-error-reload-canceled"});return}if(!s.getSource||typeof s.getSource!="function"){B.log.error("ERROR: reloadSourceOnError - The option getSource must be a function!");return}return t=Date.now(),s.getSource.call(i,a)},c=function(){i.off("loadedmetadata",r),i.off("error",l),i.off("dispose",c)},f=function(m){c(),Op(i,m)};i.on("error",l),i.on("dispose",c),i.reloadSourceOnError=f},gS=function(i){Op(this,i)};var Mp="3.16.2",fS="7.1.0",mS="1.3.1",yS="7.2.0",_S="4.0.2";const Oe={PlaylistLoader:nn,Playlist:gt,utils:TT,STANDARD_PLAYLIST_SELECTOR:fd,INITIAL_PLAYLIST_SELECTOR:dv,lastBandwidthSelector:fd,movingAverageBandwidthSelector:lv,comparePlaylistBandwidth:pl,comparePlaylistResolution:ov,xhr:ap()};Object.keys(We).forEach(i=>{Object.defineProperty(Oe,i,{get(){return B.log.warn(`using Vhs.${i} is UNSAFE be sure you know what you are doing`),We[i]},set(e){if(B.log.warn(`using Vhs.${i} is UNSAFE be sure you know what you are doing`),typeof e!="number"||e<0){B.log.warn(`value of Vhs.${i} must be greater than or equal to 0`);return}We[i]=e}})});const Rp="videojs-vhs",Up=function(i,e){const t=e.media();let n=-1;for(let s=0;s<i.length;s++)if(i[s].id===t.id){n=s;break}i.selectedIndex_=n,i.trigger({selectedIndex:n,type:"change"})},bS=function(i,e){e.representations().forEach(t=>{i.addQualityLevel(t)}),Up(i,e.playlists)};Oe.canPlaySource=function(){return B.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};const TS=(i,e,t)=>{if(!i)return i;let n={};e&&e.attributes&&e.attributes.CODECS&&(n=Ir(Ht(e.attributes.CODECS))),t&&t.attributes&&t.attributes.CODECS&&(n.audio=t.attributes.CODECS);const s=cn(n.video),r=cn(n.audio),a={};for(const l in i)a[l]={},r&&(a[l].audioContentType=r),s&&(a[l].videoContentType=s),e.contentProtection&&e.contentProtection[l]&&e.contentProtection[l].pssh&&(a[l].pssh=e.contentProtection[l].pssh),typeof i[l]=="string"&&(a[l].url=i[l]);return fe(i,a)},vS=(i,e)=>i.reduce((t,n)=>{if(!n.contentProtection)return t;const s=e.reduce((r,a)=>{const l=n.contentProtection[a];return l&&l.pssh&&(r[a]={pssh:l.pssh}),r},{});return Object.keys(s).length&&t.push(s),t},[]),SS=({player:i,sourceKeySystems:e,audioMedia:t,mainPlaylists:n})=>{if(!i.eme.initializeMediaKeys)return Promise.resolve();const s=t?n.concat([t]):n,r=vS(s,Object.keys(e)),a=[],l=[];return r.forEach(c=>{l.push(new Promise((f,m)=>{i.tech_.one("keysessioncreated",f)})),a.push(new Promise((f,m)=>{i.eme.initializeMediaKeys({keySystems:c},b=>{if(b){m(b);return}f()})}))}),Promise.race([Promise.all(a),Promise.race(l)])},ES=({player:i,sourceKeySystems:e,media:t,audioMedia:n})=>{const s=TS(e,t,n);return s?(i.currentSource().keySystems=s,s&&!i.eme?(B.log.warn("DRM encrypted source cannot be decrypted without a DRM plugin"),!1):!0):!1},Np=()=>{if(!x.localStorage)return null;const i=x.localStorage.getItem(Rp);if(!i)return null;try{return JSON.parse(i)}catch{return null}},wS=i=>{if(!x.localStorage)return!1;let e=Np();e=e?fe(e,i):i;try{x.localStorage.setItem(Rp,JSON.stringify(e))}catch{return!1}return e},kS=i=>i.toLowerCase().indexOf("data:application/vnd.videojs.vhs+json,")===0?JSON.parse(i.substring(i.indexOf(",")+1)):i,Bp=(i,e)=>{i._requestCallbackSet||(i._requestCallbackSet=new Set),i._requestCallbackSet.add(e)},Fp=(i,e)=>{i._responseCallbackSet||(i._responseCallbackSet=new Set),i._responseCallbackSet.add(e)},jp=(i,e)=>{i._requestCallbackSet&&(i._requestCallbackSet.delete(e),i._requestCallbackSet.size||delete i._requestCallbackSet)},$p=(i,e)=>{i._responseCallbackSet&&(i._responseCallbackSet.delete(e),i._responseCallbackSet.size||delete i._responseCallbackSet)};Oe.supportsNativeHls=function(){if(!G||!G.createElement)return!1;const i=G.createElement("video");return B.getTech("Html5").isSupported()?["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"].some(function(e){return/maybe|probably/i.test(i.canPlayType(e))}):!1}();Oe.supportsNativeDash=function(){return!G||!G.createElement||!B.getTech("Html5").isSupported()?!1:/maybe|probably/i.test(G.createElement("video").canPlayType("application/dash+xml"))}();Oe.supportsTypeNatively=i=>i==="hls"?Oe.supportsNativeHls:i==="dash"?Oe.supportsNativeDash:!1;Oe.isSupported=function(){return B.log.warn("VHS is no longer a tech. Please remove it from your player's techOrder.")};Oe.xhr.onRequest=function(i){Bp(Oe.xhr,i)};Oe.xhr.onResponse=function(i){Fp(Oe.xhr,i)};Oe.xhr.offRequest=function(i){jp(Oe.xhr,i)};Oe.xhr.offResponse=function(i){$p(Oe.xhr,i)};const CS=B.getComponent("Component");class qp extends CS{constructor(e,t,n){if(super(t,n.vhs),typeof n.initialBandwidth=="number"&&(this.options_.bandwidth=n.initialBandwidth),this.logger_=Lt("VhsHandler"),t.options_&&t.options_.playerId){const s=B.getPlayer(t.options_.playerId);this.player_=s}if(this.tech_=t,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw new Error("Overriding native VHS requires emulated tracks. See https://git.io/vMpjB");this.on(G,["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],s=>{const r=G.fullscreenElement||G.webkitFullscreenElement||G.mozFullScreenElement||G.msFullscreenElement;r&&r.contains(this.tech_.el())?this.playlistController_.fastQualityChange_():this.playlistController_.checkABR_()}),this.on(this.tech_,"seeking",function(){if(this.ignoreNextSeekingEvent_){this.ignoreNextSeekingEvent_=!1;return}this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,"error",function(){this.tech_.error()&&this.playlistController_&&this.playlistController_.pauseLoading()}),this.on(this.tech_,"play",this.play)}setOptions_(e={}){if(this.options_=fe(this.options_,e),this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.useBandwidthFromLocalStorage=typeof this.source_.useBandwidthFromLocalStorage<"u"?this.source_.useBandwidthFromLocalStorage:this.options_.useBandwidthFromLocalStorage||!1,this.options_.useForcedSubtitles=this.options_.useForcedSubtitles||!1,this.options_.useNetworkInformationApi=this.options_.useNetworkInformationApi||!1,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=this.options_.llhls!==!1,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,typeof this.options_.playlistExclusionDuration!="number"&&(this.options_.playlistExclusionDuration=60),typeof this.options_.bandwidth!="number"&&this.options_.useBandwidthFromLocalStorage){const n=Np();n&&n.bandwidth&&(this.options_.bandwidth=n.bandwidth,this.tech_.trigger({type:"usage",name:"vhs-bandwidth-from-local-storage"})),n&&n.throughput&&(this.options_.throughput=n.throughput,this.tech_.trigger({type:"usage",name:"vhs-throughput-from-local-storage"}))}typeof this.options_.bandwidth!="number"&&(this.options_.bandwidth=We.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===We.INITIAL_BANDWIDTH,["withCredentials","useDevicePixelRatio","customPixelRatio","limitRenditionByPlayerDimensions","bandwidth","customTagParsers","customTagMappers","cacheEncryptionKeys","playlistSelector","initialPlaylistSelector","bufferBasedABR","liveRangeSafeTimeDelta","llhls","useForcedSubtitles","useNetworkInformationApi","useDtsForTimestampOffset","exactManifestTimings","leastPixelDiffSelector"].forEach(n=>{typeof this.source_[n]<"u"&&(this.options_[n]=this.source_[n])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio;const t=this.options_.customPixelRatio;typeof t=="number"&&t>=0&&(this.customPixelRatio=t)}setOptions(e={}){this.setOptions_(e)}src(e,t){if(!e)return;this.setOptions_(),this.options_.src=kS(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=Oe,this.options_.sourceType=lh(t),this.options_.seekTo=r=>{this.tech_.setCurrentTime(r)},this.options_.player_=this.player_,this.playlistController_=new lS(this.options_);const n=fe({liveRangeSafeTimeDelta:Kt},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new cS(n),this.attachStreamingEventListeners_(),this.playlistController_.on("error",()=>{const r=B.players[this.tech_.options_.playerId];let a=this.playlistController_.error;typeof a=="object"&&!a.code?a.code=3:typeof a=="string"&&(a={message:a,code:3}),r.error(a)});const s=this.options_.bufferBasedABR?Oe.movingAverageBandwidthSelector(.55):Oe.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):s.bind(this),this.playlistController_.selectInitialPlaylist=Oe.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(r){this.playlistController_.selectPlaylist=r.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(r){this.playlistController_.mainSegmentLoader_.throughput.rate=r,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let r=this.playlistController_.mainSegmentLoader_.bandwidth;const a=x.navigator.connection||x.navigator.mozConnection||x.navigator.webkitConnection,l=1e7;if(this.options_.useNetworkInformationApi&&a){const c=a.downlink*1e3*1e3;c>=l&&r>=l?r=Math.max(r,c):r=c}return r},set(r){this.playlistController_.mainSegmentLoader_.bandwidth=r,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){const r=1/(this.bandwidth||1);let a;return this.throughput>0?a=1/this.throughput:a=0,Math.floor(1/(r+a))},set(){B.log.error('The "systemBandwidth" property is read-only')}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>Ui(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>Ui(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one("canplay",this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on("bandwidthupdate",()=>{this.options_.useBandwidthFromLocalStorage&&wS({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on("selectedinitialmedia",()=>{hS(this)}),this.playlistController_.sourceUpdater_.on("createdsourcebuffers",()=>{this.setupEme_()}),this.on(this.playlistController_,"progress",function(){this.tech_.trigger("progress")}),this.on(this.playlistController_,"firstplay",function(){this.ignoreNextSeekingEvent_=!0}),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=x.URL.createObjectURL(this.playlistController_.mediaSource),(B.browser.IS_ANY_SAFARI||B.browser.IS_IOS)&&this.options_.overrideNative&&this.options_.sourceType==="hls"&&typeof this.tech_.addSourceElement=="function"?(this.tech_.addSourceElement(this.mediaSourceUrl_),this.tech_.addSourceElement(this.source_.src)):this.tech_.src(this.mediaSourceUrl_))}createKeySessions_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_("waiting for EME key session creation"),SS({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then(()=>{this.logger_("created EME key session"),this.playlistController_.sourceUpdater_.initializedEme()}).catch(t=>{this.logger_("error while creating EME key session",t),this.player_.error({message:"Failed to initialize media keys for EME",code:3})})}handleWaitingForKey_(){this.logger_("waitingforkey fired, attempting to create any new key sessions"),this.createKeySessions_()}setupEme_(){const e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,t=ES({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});if(this.player_.tech_.on("keystatuschange",n=>{this.playlistController_.updatePlaylistByKeyStatus(n.keyId,n.status)}),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on("waitingforkey",this.handleWaitingForKey_),!t){this.playlistController_.sourceUpdater_.initializedEme();return}this.createKeySessions_()}setupQualityLevels_(){const e=B.players[this.tech_.options_.playerId];!e||!e.qualityLevels||this.qualityLevels_||(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on("selectedinitialmedia",()=>{bS(this.qualityLevels_,this)}),this.playlists.on("mediachange",()=>{Up(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":Mp,"mux.js":fS,"mpd-parser":mS,"m3u8-parser":yS,"aes-decrypter":_S}}version(){return this.constructor.version()}canChangeType(){return Ap.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.playlistController_&&this.playlistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.mediaSourceUrl_&&x.URL.revokeObjectURL&&(x.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off("waitingforkey",this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,t){return IT({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,n=!0,s=2){return hp({programTime:e,playlist:this.playlistController_.media(),retryCount:s,pauseAfterSeek:n,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}setupXhrHooks_(){this.xhr.onRequest=e=>{Bp(this.xhr,e)},this.xhr.onResponse=e=>{Fp(this.xhr,e)},this.xhr.offRequest=e=>{jp(this.xhr,e)},this.xhr.offResponse=e=>{$p(this.xhr,e)},this.player_.trigger("xhr-hooks-ready")}attachStreamingEventListeners_(){const e=["seekablerangeschanged","bufferedrangeschanged","contentsteeringloadstart","contentsteeringloadcomplete","contentsteeringparsed"],t=["gapjumped","playedrangeschanged"];e.forEach(n=>{this.playlistController_.on(n,s=>{this.player_.trigger(je({},s))})}),t.forEach(n=>{this.playbackWatcher_.on(n,s=>{this.player_.trigger(je({},s))})})}}const Pr={name:"videojs-http-streaming",VERSION:Mp,canHandleSource(i,e={}){const t=fe(B.options,e);return!t.vhs.experimentalUseMMS&&!as("avc1.4d400d,mp4a.40.2",!1)?!1:Pr.canPlayType(i.type,t)},handleSource(i,e,t={}){const n=fe(B.options,t);return e.vhs=new qp(i,e,n),e.vhs.xhr=ap(),e.vhs.setupXhrHooks_(),e.vhs.src(i.src,i.type),e.vhs},canPlayType(i,e){const t=lh(i);if(!t)return"";const n=Pr.getOverrideNative(e);return!Oe.supportsTypeNatively(t)||n?"maybe":""},getOverrideNative(i={}){const{vhs:e={}}=i,t=!(B.browser.IS_ANY_SAFARI||B.browser.IS_IOS),{overrideNative:n=t}=e;return n}},IS=()=>as("avc1.4d400d,mp4a.40.2",!0);IS()&&B.getTech("Html5").registerSourceHandler(Pr,0);B.VhsHandler=qp;B.VhsSourceHandler=Pr;B.Vhs=Oe;B.use||B.registerComponent("Vhs",Oe);B.options.vhs=B.options.vhs||{};(!B.getPlugin||!B.getPlugin("reloadSourceOnError"))&&B.registerPlugin("reloadSourceOnError",gS);const xS=i=>{const e=_e.useRef();return _e.useEffect(()=>{if(!e.current&&i.current){const t=document.createElement("video-js");t.classList.add("vjs-big-play-centered"),i.current.appendChild(t),e.current=B(t,{controls:!1,playsinline:!0})}return()=>{e.current&&(e.current.dispose(),e.current=void 0)}},[]),e},Vp={time:0,adCount:0,adPosition:0,skipDelay:0,playing:!1,paused:!1,reset:()=>{},whyThisAd:null,hasAdUrl:!1,adAction:i=>{},playMuted:!1,muted:!1,autoplay:!0},xe=W.i(Vp),xd=i=>{if(!i)return 0;const e=i.duration(),t=i.currentTime();return e===void 0||isNaN(e)||t===void 0||isNaN(t)?0:Math.round(e-t)},AS=(i,e)=>{const t=Dy(i,e),n=xS(i),s=_e.useRef(),r=_e.useRef(!1),a=_e.useRef(!1),l=_e.useCallback(()=>{if(a.current)return;const w=t.get().nonceManager;if(w&&r.current)try{w.sendPlaybackEnd()}catch(A){console.warn("[PAL] sendPlaybackEnd failed",A)}a.current=!0},[t]),c=_e.useCallback(()=>{l(),n.current&&(n.current.pause(),n.current.src(void 0)),s.current=void 0,xe.set({...Vp,reset:c})},[n,l]);_e.useEffect(()=>{xe.setKey("reset",c)},[c]);const f=_e.useCallback(()=>{var w,A,v;const{adPosition:M,adCount:D}=xe.get();if(n.current){if(M<D){const R=M+1,{ads:N,muted:F,autoplay:P,nonceManager:$}=t.get(),Y=N[R-1];if(Y){(w=s.current)==null||w.complete(),s.current=new Dd.ue(null,Y.ad,Y.creative),s.current.on("clickthrough",X=>{if($)try{$.sendAdClick()}catch(re){console.warn("[PAL] sendAdClick failed",re)}window.open(X,"_blank")}),xe.setKey("adPosition",R),xe.setKey("playMuted",F),xe.setKey("skipDelay",Y.creative.skipDelay||0),xe.setKey("time",0),xe.setKey("adAction",X=>{s.current&&s.current.click(null,{CLICKPOS:[X.clientX,X.clientY]})}),xe.setKey("whyThisAd",Y.creative.icons.find(X=>X.program==="GoogleWhyThisAd")||null),xe.setKey("hasAdUrl",!!((A=Y.creative.videoClickThroughURLTemplate)!=null&&A.url)),n.current.src(Y.mediaFileUrl),xe.setKey("playing",!0),M===0?(xe.setKey("muted",F),xe.setKey("autoplay",P),F&&n.current.muted(!0),P?n.current.play():(n.current.pause(),xe.setKey("paused",!0))):n.current.play();return}}(v=s.current)==null||v.complete(),c()}},[n,c,t]),m=_e.useCallback(()=>{if(!n.current)return;const w=n.current.muted();n.current.muted(!w),xe.setKey("muted",!w),s.current&&s.current.setMuted(!w)},[n]),b=_e.useCallback(()=>{n.current&&(n.current.paused()?(n.current.play(),s.current&&s.current.setPaused(!1)):(n.current.pause(),s.current&&s.current.setPaused(!0)))},[n]),C=_e.useCallback(()=>{n.current&&(s.current&&s.current.skip(),f())},[f,n]);return _e.useEffect(()=>{const w=n.current;if(!w)return()=>{};const A=P=>{if(xe.setKey("playing",!0),xe.setKey("paused",!1),xe.setKey("time",xd(P.target.player)),!r.current){const $=t.get().nonceManager;if($)try{$.sendPlaybackStart(),r.current=!0,a.current=!1}catch(Y){console.warn("[PAL] sendPlaybackStart failed",Y)}}},v=()=>{var P;(P=s.current)==null||P.complete(),f()},M=P=>{xe.setKey("muted",P.target.player.muted())},D=()=>{xe.setKey("paused",!0)},R=P=>{P.target.tagName==="VIDEO"&&(xe.get().autoplay||b())},N=P=>{xe.setKey("time",xd(P.target.player)),s.current&&s.current.setProgress(P.target.player.currentTime())},F=()=>{c()};return w.on("play",A),w.on("ended",v),w.on("muted",M),w.on("pause",D),w.on("click",R),w.on("timeupdate",N),w.on("error",F),()=>{w.off("play",A),w.off("ended",v),w.off("muted",M),w.off("pause",D),w.off("click",R),w.off("timeupdate",N),w.off("error",F)}},[b,f,n,c,t]),_e.useEffect(()=>t.subscribe(w=>{w&&(r.current=!1,a.current=!1,xe.setKey("adCount",w.ads.length),xe.setKey("adPosition",0),f())}),[t,n,f]),_e.useEffect(()=>()=>{c()},[c]),[xe,m,b,C,s]},PS=({promotion:i,onClose:e,promotionId:t,externalAd:n,skipAutoClose:s})=>{var r,a,l,c,f;const m=_e.useRef(null),[b,C,w,A]=AS(m,n==null?void 0:n.url),{time:v,adCount:M,adPosition:D,skipDelay:R,playing:N,paused:F,reset:P,muted:$,playMuted:Y,autoplay:X,whyThisAd:re,hasAdUrl:ce,adAction:be}=W.useStore(b),he=((r=i.sponsor)==null?void 0:r.logo)&&i.logoMode===ue.PromotionLogoMode.CENTER;return z.jsxs(Bd,{className:"PromoOverlay",children:[z.jsxs(Fd,{children:[z.jsx(jd,{className:W.cx_default(!he&&$d),children:z.jsx(Vd,{style:{transform:"scale(1.5)"},children:"Ad"})}),z.jsxs(Ey,{children:[z.jsx(gy,{time:v,adCount:M,adPosition:D}),!!R&&N&&z.jsx(W.y,{timerClassName:"SkipTimerCount",className:"ClosePromoIcon",close:()=>{A()},duration:R,isPlaying:!F,skipIcon:!0}),s&&z.jsx(W.y,{className:"ClosePromoIcon",close:()=>{P(),e==null||e()}})]})]}),z.jsx(qd,{className:W.cx_default(ou,N&&lu,!N&&uu),children:z.jsxs(Sy,{ref:m,children:[re&&z.jsx(my,{whyThisAd:re}),z.jsxs(yy,{style:(re==null?void 0:re.xPosition)==="right"?{left:"8px"}:{right:"8px"},children:[Y&&z.jsx(by,{className:W.cx_default(!$&&"muted"),onClick:()=>C()}),F&&!X&&z.jsx(vy,{onClick:()=>w()})]})]})}),ce&&z.jsx(Hd,{className:W.cx_default(ou,N&&lu,!N&&uu),children:z.jsx(zd,{as:"button",onClick:be,style:{backgroundColor:((l=(a=i.banner)==null?void 0:a.ctaButton)==null?void 0:l.color)||"#009dc4",color:((f=(c=i.banner)==null?void 0:c.ctaButton)==null?void 0:f.textColor)||"#fff"},"data-a":"button","data-promo-id":t,"data-promo-type":i.type,target:"_blank",children:"Show more"})})]})},Ad=i=>{var e,t,n,s,r,a,l,c,f,m,b,C,w,A,v,M,D,R,N,F,P,$,Y,X,re,ce,be,he,Z,de;const{promotion:ee,open:Xe,advertisementPaused:Ye,togglePause:$e,controlVideo:He,skipAutoClose:me,promotionId:ge,onClose:mt,markAsViewed:Et,externalAd:we,isEventFired:le,fireEvent:Re,muted:Hi}=i,oi=ee.type===ue.PromotionType.INGAME_IAB11_LBAR||ee.type===ue.PromotionType.INGAME_IAB11||ee.type===ue.PromotionType.INGAME_IAB11_SIDEBAR,li=((e=ee.sponsor)==null?void 0:e.logo)&&ee.logoMode===ue.PromotionLogoMode.CENTER,Ei=!!((n=(t=ee.banner)==null?void 0:t.video)!=null&&n.url),yt=ee.autoPlayVideo===ue.AutoPlayVideo.ENABLED,ui=ee.playVideoMuted===ue.PlayVideoMuted.ENABLED;if(_e.useEffect(()=>{$e==null||$e(Ei||yt),Xe==null||Xe()},[]),_e.useEffect(()=>{ge&&ee.type&&Et&&Et()},[ge,ee.type,Et]),_e.useEffect(()=>()=>{He==null||He({muted:!1})},[He]),we)return z.jsx(PS,{...i,externalAd:we});let Ft=(s=ee.banner)==null?void 0:s.url;Ft&&Ft.indexOf("http")!==0&&(Ft=`https://${Ft}`);let wi=!0;return Ei&&(!Ye||!yt?wi=!0:wi=!1),z.jsxs(Bd,{className:"PromoOverlay",children:[z.jsxs("div",{children:[z.jsxs(Fd,{children:[z.jsxs(jd,{className:W.cx_default(!li&&$d),children:[((r=ee.sponsor)==null?void 0:r.logo)&&ee.logoMode===ue.PromotionLogoMode.LEFT&&z.jsx(su,{className:"PromoSponsorLogo",src:(a=ee.sponsor)==null?void 0:a.logo,alt:"promo"}),z.jsxs(oy,{style:{paddingLeft:(l=ee.sponsor)!=null&&l.logo&&ee.logoMode===ue.PromotionLogoMode.LEFT?"0px":"8px"},children:[((c=ee.sponsor)==null?void 0:c.logo)&&ee.logoMode===ue.PromotionLogoMode.LEFT&&z.jsx(ny,{children:(f=ee.sponsor)==null?void 0:f.name}),z.jsxs(ly,{className:"SponsorText",children:[z.jsx(Vd,{children:"AD"}),z.jsx(uy,{children:"SPONSORED"})]})]})]}),z.jsx(W.y,{className:"ClosePromoIcon",close:mt,autoClose:(m=ee.closeTimer)==null?void 0:m.auto,duration:me?0:(b=ee.closeTimer)==null?void 0:b.seconds,isPlaying:wi})]}),z.jsxs(qd,{children:[li&&z.jsx(su,{className:ry,src:(C=ee.sponsor)==null?void 0:C.logo,alt:"promo"}),z.jsx(ru,{children:(A=(w=ee.banner)==null?void 0:w.video)!=null&&A.url?z.jsx(W.Et,{source:(M=(v=ee.banner)==null?void 0:v.video)==null?void 0:M.url,poster:(R=(D=ee.banner)==null?void 0:D.video)==null?void 0:R.thumbnailUrl,aspectRatio:oi?"1/1":"2/1",onRender:()=>{le!=null&&le("video-rendered")||(W.eventBus.emit("advertisement",{action:"videoRendered",payload:{id:ge,type:ee.type}}),Re==null||Re("video-rendered"))},onQuartile:Dt=>{le!=null&&le(`video-quartile-${Dt}`)||(W.eventBus.emit("advertisement",{action:"quartileCompleted",payload:{id:ge,type:ee.type,quartile:Dt}}),Re==null||Re(`video-quartile-${Dt}`))},onMute:Dt=>{const Ot=Dt?"muted":"unmuted";le!=null&&le(Ot)||(W.eventBus.emit("advertisement",{action:Dt?"videoMuted":"videoUnmuted",payload:{id:ge,type:ee.type}}),Re==null||Re(Ot))},onPause:()=>{yt&&($e==null||$e(!0))},onReplay:()=>{le!=null&&le("replayed")||(W.eventBus.emit("advertisement",{action:"videoReplayed",payload:{id:ge,type:ee.type}}),Re==null||Re("replayed"))},onPlay:()=>{le!=null&&le("played")||(W.eventBus.emit("advertisement",{action:"videoPlay",payload:{id:ge,type:ee.type}}),Re==null||Re("played")),$e==null||$e(!1),le!=null&&le("played")&&le!=null&&le("ended")&&!(le!=null&&le("replayed"))&&(W.eventBus.emit("advertisement",{action:"videoReplayed",payload:{id:ge,type:ee.type}}),Re==null||Re("replayed"))},onEnd:()=>{le!=null&&le("ended")||(W.eventBus.emit("advertisement",{action:"videoEnd",payload:{id:ge,type:ee.type}}),Re==null||Re("ended"))},controlVideo:He,autoPlay:yt,playMuted:ui,muted:Hi}):(N=ee.banner)!=null&&N.imageUrl?z.jsx(sy,{style:oi?{aspectRatio:"1/1"}:{},src:(F=ee.banner)==null?void 0:F.imageUrl,alt:"promo"}):null}),!oi&&z.jsxs(ru,{children:[((P=ee.banner)==null?void 0:P.title)&&z.jsx(dy,{className:W.cx_default("AdvTitle",li&&hy),children:($=ee.banner)==null?void 0:$.title}),((Y=ee.banner)==null?void 0:Y.body)&&z.jsx(ay,{className:"AdvDescription",children:(X=ee.banner)==null?void 0:X.body})]})]})]}),ee.buttonType===ue.PromotionButtonType.BASIC&&z.jsx(Hd,{children:z.jsx(zd,{href:Ft,style:{backgroundColor:((ce=(re=ee.banner)==null?void 0:re.ctaButton)==null?void 0:ce.color)||"#009dc4",color:((he=(be=ee.banner)==null?void 0:be.ctaButton)==null?void 0:he.textColor)||"#fff"},"data-a":"button","data-promo-id":ge,"data-promo-type":ee.type,target:"_blank",children:(de=(Z=ee.banner)==null?void 0:Z.ctaButton)==null?void 0:de.label})})]})},LS=W.styled_default("div")({name:"SidebarContainer",class:"s1abskp8",propsAsIs:!1}),DS=({children:i,direction:e,style:t,className:n,hiding:s})=>z.jsx(bo,{direction:e,style:t,hiding:s,className:n,children:z.jsx(LS,{children:i})}),Pd=i=>(i==null?void 0:i.type)===ue.PromotionType.INGAME_IAB11_LBAR||(i==null?void 0:i.type)===ue.PromotionType.INGAME_IAB21_LBAR,OS=i=>(i==null?void 0:i.type)===ue.PromotionType.INGAME_IAB11_SIDEBAR||(i==null?void 0:i.type)===ue.PromotionType.INGAME_IAB21_SIDEBAR,MS=i=>(i==null?void 0:i.type)===ue.PromotionType.INGAME_IAB11||(i==null?void 0:i.type)===ue.PromotionType.INGAME_IAB21,RS=({advertisement:i,close:e,skipTypeCheck:t,skipAutoClose:n,layoutMode:s="side-by-side",sidebar:r,isNotification:a,banner:l,markAsViewed:c,open:f,externalAd:m,controlVideo:b,advertisementPaused:C,togglePause:w,isEventFired:A,fireEvent:v,muted:M})=>i.promotion?a&&i.notification?z.jsx(ty,{open:()=>f==null?void 0:f({fromNotification:!0}),notification:i.notification,promotionId:i.question.id,close:e}):!r&&!l&&(t||MS(i.promotion))?z.jsx(iy,{className:"PromoOverlayContainer",children:z.jsx(Ad,{markAsViewed:c,promotionId:i.question.id,promotion:i.promotion,onClose:e,open:f,skipAutoClose:n,externalAd:m,controlVideo:b,advertisementPaused:C,togglePause:w,isEventFired:A,fireEvent:v,muted:M})}):r&&(t||Pd(i.promotion)||OS(i.promotion)||m)?z.jsx(DS,{className:"PromoSidebarContainer",direction:r,hiding:!1,children:z.jsx(Ad,{markAsViewed:c,promotionId:i.question.id,promotion:i.promotion,externalAd:m,onClose:e,open:f,controlVideo:b,skipAutoClose:n,advertisementPaused:C,togglePause:w,isEventFired:A,fireEvent:v,muted:M})}):l&&Pd(i.promotion)?z.jsx(Od,{promotionId:i.question.id,hiding:!1,promotion:i.promotion,direction:l,isEventFired:A,fireEvent:v}):null:null,Ld=W.styled_default("div")({name:"AdvertisementUIWrap",class:"aa6pjif",propsAsIs:!1}),US=i=>{const e=i.target;if(e instanceof HTMLAnchorElement&&e.target==="_blank"){const t=e.getAttribute("data-promo-id")||"",n=e.getAttribute("data-promo-type")||ue.PromotionType.UNSET;e.getAttribute("data-a")==="button"&&W.eventBus.emit("advertisement",{action:"buttonSelect",payload:{id:t,type:n}}),e.getAttribute("data-a")==="banner"&&W.eventBus.emit("advertisement",{action:"bannerSelect",payload:{id:t,type:n}})}},NS=({gamification:i,advertisement:e,layoutMode:t,skipAutoClose:n,skipTypeCheck:s,sidebar:r,banner:a,notification:l,isMobileScreen:c,persistent:f,containerId:m,externalAd:b,controlVideo:C,muted:w})=>{var A,v,M,D,R,N,F,P,$,Y,X,re,ce,be,he,Z,de,ee,Xe,Ye,$e;const He=_e.useRef(null),me=W.useStore(e.$store),ge=W.useStore(i.openedQuestion.$store);W.b(He,{enabled:!!me.data,event:"click",listener:US});const mt=((M=(v=(A=me.data)==null?void 0:A.question)==null?void 0:v.backgroundImage)==null?void 0:M.landscapeUrl)||((R=(D=me.data)==null?void 0:D.promotion)==null?void 0:R.backgroundImageLandscapeUrl),Et=((P=(F=(N=me.data)==null?void 0:N.question)==null?void 0:F.backgroundImage)==null?void 0:P.portraitUrl)||((Y=($=me.data)==null?void 0:$.promotion)==null?void 0:Y.backgroundImagePortraitUrl),we=W.y$1({containerId:m,landscapeUrl:mt,portraitUrl:Et});if(((X=ge==null?void 0:ge.attributes)==null?void 0:X.adUnit)===ue.AdUnit.STANDART&&(be=(ce=(re=ge==null?void 0:ge.attributes)==null?void 0:re.adPromotion)==null?void 0:ce.banner)!=null&&be.imageUrl)return a?z.jsx(Ld,{ref:He,style:{height:"100%"},className:W.cx_default("SL-AdvertisementUIWrap",c&&"mobile-view"),children:z.jsx(hm,{cardId:ge.id,promotion:{...(he=ge==null?void 0:ge.attributes)==null?void 0:he.adPromotion,adUnit:(Z=ge==null?void 0:ge.attributes)==null?void 0:Z.adUnit}})}):null;const le=!a&&!r;if(me.data===void 0||!f&&me.isViewed)return null;const Re=((Xe=(ee=(de=me==null?void 0:me.data)==null?void 0:de.notification)==null?void 0:ee.promotion)==null?void 0:Xe.mode)===ue.NotificationPromotionMode.LOWER_THIRD;return z.jsxs(Ld,{ref:He,style:{height:le?"auto":"100%"},className:W.cx_default("SL-AdvertisementUIWrap",c&&"mobile-view",Re&&"SL-AdvertisementUIWrap--lower-third"),children:[!l&&we,z.jsx(RS,{skipTypeCheck:s,sidebar:r,banner:a,advertisement:me.data,advertisementPaused:!!me.isPaused,togglePause:me.togglePause,isEventFired:me.isEventFired,toggleMute:me.toggleMute,fireEvent:me.fireEvent,close:me.close,externalAd:b?me.externalAd:void 0,markAsViewed:(Ye=i.advertisement)==null?void 0:Ye.markAsViewed,open:($e=i.advertisement)==null?void 0:$e.open,layoutMode:t,isNotification:l,skipAutoClose:n,controlVideo:C,muted:w})]})},Hp=({sdk:i,sidebar:e,externalAd:t,banner:n,skipAutoClose:s,skipTypeCheck:r,layoutMode:a,isMobileScreen:l,persistent:c,notification:f,muted:m})=>{const b=W.useStore(i.featuresList.getStore()),[C,w]=_e.useState(!t),A=W.useStore(i.options);if(_e.useEffect(()=>{if(t){const M=document.createElement("script");M.async=!0,M.src="https://imasdk.googleapis.com/pal/sdkloader/pal.js",document.body.appendChild(M),M.onload=()=>{w(!0)}}},[t]),e&&n)return z.jsx("div",{style:{color:"red"},children:"define either sidebar or banner, not both."});if(n&&t)return z.jsx("div",{style:{color:"red"},children:"externalAd is not supported with banner"});if(!b)return null;const v=i.getFeature(ue.SdkOverlayType.GAMES);return!v||t&&!C?null:z.jsx(NS,{gamification:v,advertisement:v.advertisement,sidebar:e,banner:n,layoutMode:a,isMobileScreen:l,persistent:c,notification:f,skipTypeCheck:r,skipAutoClose:s,externalAd:t,controlVideo:i.controlVideoPlayer,containerId:A.containerId,muted:m})},BS=({event:i,sidebar:e,banner:t,isMobileScreen:n,skipAutoClose:s,persistent:r,theme:a,notification:l,skipTypeCheck:c,externalAd:f,muted:m=!1})=>{const b=W.useStreamLayer(),C=W.useStreamLayerUI(),w=W.useStreamLayerTheme();return b?f&&!C.promotionExternalAd?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):!f&&C.promotionExternalAd?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):e&&!C.promotionSidebar?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):t&&!C.promotionBanner?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):l&&!C.promotionNotification?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):!t&&!e&&!l&&!C.promotionOverlay&&!c?i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i}):z.jsxs("div",{className:"StreamLayerSDK",children:[z.jsx(W.h,{customTheme:a??w.theme,themeMode:w.themeMode,children:z.jsx(Hp,{sdk:b,sidebar:e,banner:t,isMobileScreen:n,persistent:r,notification:l,skipTypeCheck:c,skipAutoClose:s,layoutMode:"side-by-side",externalAd:f,muted:m})}),i!==void 0&&z.jsx(W.StreamLayerSDKEvent,{event:i})]}):null};exports.StreamLayerSDKAdvertisement=BS;exports.StreamLayerSDKAdvertisementUI=Hp;
|