ranui 0.2.0-alpha.6 → 0.2.0-alpha.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.
@@ -1,33 +1,33 @@
1
- var g=this,m=function(){"use strict";var ranui=(function(ke){Object.defineProperty(ke,Symbol.toStringTag,{value:"Module"});var Vl=Object.defineProperty,Wl=(e,i,n)=>()=>{if(n)throw n[0];try{return e&&(i=e(e=0)),i}catch(c){throw n=[c],c}},a0=(e,i)=>()=>(i||(e((i={exports:{}}).exports,i),e=null),i.exports),n0=(e,i)=>{let n={};for(var c in e)Vl(n,c,{get:e[c],enumerable:!0});return i||Vl(n,Symbol.toStringTag,{value:"Module"}),n},Ta="ran-theme",Ui=null,Qi=null,Da=e=>{if(e&&"style"in e)return e;if(e&&"documentElement"in e)return e.documentElement;if(!(typeof document>"u"))return document.documentElement},Xl=e=>{const i=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches;e.setAttribute("data-ran-theme",i?"dark":"light"),e.setAttribute("theme",i?"dark":"light")},o0=()=>{Ui&&Qi&&(Ui.removeEventListener("change",Qi),Ui=null,Qi=null)},_n=(e,i)=>{const n=Da(i);if(n){if(o0(),e==="system"){if(typeof window>"u")return;Xl(n),Ui=window.matchMedia("(prefers-color-scheme: dark)"),Qi=()=>Xl(n),Ui.addEventListener("change",Qi);try{localStorage.setItem(Ta,"system")}catch{}return}n.setAttribute("data-ran-theme",e),n.setAttribute("theme",e);try{localStorage.setItem(Ta,e)}catch{}}},Jl=e=>{const i=Da(e);if(!i)return"";const n=i.getAttribute("data-ran-theme")||i.getAttribute("theme")||"";if(n==="light"||n==="dark"){try{if(localStorage.getItem(Ta)==="system")return"system"}catch{}return n}return""},_l=(e,i,n)=>{const c=Da(n);c&&c.style.setProperty(e,String(i))},jl=(e,i)=>{const n=Da(i);n&&n.style.removeProperty(e)},s0=(e,i)=>{Object.entries(e).forEach(([n,c])=>{if(c==null){jl(n,i);return}_l(n,c,i)})},l0=e=>{if(!(typeof localStorage>"u"))try{const i=localStorage.getItem(Ta);(i==="light"||i==="dark"||i==="system")&&_n(i,e)}catch{}},Zl=class{_events=new Map;tap=(e,i)=>{this._events.get(e)&&e!==Symbol.for("NEW_LISTENER")&&this.call(Symbol.for("NEW_LISTENER"),e);const n=this._events.get(e)||new Set;return typeof i=="function"?n.add({name:e,callback:i}):n.add(i),this._events.set(e,n),this};call=(e,...i)=>((this._events.get(e)||new Set).forEach(n=>{const{callback:c}=n;c(...i)}),this);callSync=async(e,...i)=>{const n=this._events.get(e)||new Set;for(const c of n){const{callback:g}=c;await g(...i)}return this};once=(e,i)=>{let n;if(typeof i=="function")n={name:e,callback:(...c)=>{i(...c),this.off(e,n)},initialCallback:i};else{const{callback:c}=i;n={name:e,callback:(...g)=>{c(...g),this.off(e,n)},initialCallback:c}}return this.tap(e,n),this};off=(e,i)=>{const n=[...this._events.get(e)||new Set].filter(c=>{if(typeof i=="function")return c.callback!==i&&c.initialCallback!==i;{const{callback:g}=i;return c.callback!==g&&c.initialCallback!==g}});return this._events.set(e,new Set(n)),this}},jn=(e=8)=>Math.random().toString(36).substring(2,e+2),$l=(e="")=>{if(e.length===0)return 0;if(e.endsWith("%")){const i=Number(e.replace("%",""));return i>1?i/100:i}return Number(e)},Ft=(e,i=0,n=1)=>Math.min(n,Math.max(i,e)),c0=e=>typeof e=="function";function Ra(e){return e<10?`0${e}`:e}var pi=e=>{if(e===0)return"00:00";if(!e)return"";const i=Math.trunc(e/3600),n=Math.trunc(e%3600/60),c=Ra(Math.trunc(e-3600*i-60*n));return i===0?`${Ra(n)}:${c}`:`${Ra(i)}:${Ra(n)}:${c}`},ec=()=>{if(typeof window<"u"){const e=navigator.userAgent.toLowerCase();return/ipad|ipod/.test(e)?"ipad":/android/.test(e)?"android":/iphone/.test(e)?"iphone":"pc"}return"pc"},tc=typeof window<"u",Ni=()=>{if(!tc)return!1;const e=window.navigator.userAgent;return!!/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(e)},Hi=e=>{const i=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||1;return(tc&&window.devicePixelRatio||1)/i},d0=12e4,h0="__ranuts_bridge__",u0="default",rc=new class{bridges=new Set;attachedWindow=null;handleMessage=e=>{for(const i of Array.from(this.bridges))i.receive(e)};add(e){this.bridges.add(e),typeof window<"u"&&this.attachedWindow!==window&&(window.addEventListener("message",this.handleMessage),this.attachedWindow=window)}remove(e){this.bridges.delete(e),this.bridges.size===0&&this.attachedWindow&&(this.attachedWindow.removeEventListener("message",this.handleMessage),this.attachedWindow=null)}},g0=class{targetWindow;targetOrigin;messageHandlers;pendingRequests;channel;senderId;available;constructor(e,i="*",n=u0){this.targetOrigin=i,this.channel=n,this.senderId=jn(12),this.messageHandlers=new Map,this.pendingRequests=new Map,this.available=typeof window<"u",this.available?(this.targetWindow=e??window,rc.add(this)):this.targetWindow=void 0}post(e,i){const n={...i,__bridge:h0,channel:this.channel,senderId:this.senderId};e.postMessage(n,this.targetOrigin)}receive=e=>{if(!this.available||this.targetOrigin!=="*"&&e.origin!==this.targetOrigin||e.source&&e.source!==this.targetWindow)return;const i=e.data;if(!i||typeof i!="object"||i.__bridge!=="__ranuts_bridge__"||(i.channel??"default")!==this.channel)return;const{type:n,payload:c,id:g,isResponse:m,isError:b,senderId:E}=i;if(m&&g){const F=this.pendingRequests.get(g);F&&(b?F.reject(new Error(typeof c=="string"?c:"Bridge request failed")):F.resolve(c),this.pendingRequests.delete(g));return}if(E&&E===this.senderId||typeof n!="string"||!this.messageHandlers.has(n))return;const R=this.messageHandlers.get(n);if(c0(R)){const F=e.source??this.targetWindow;Promise.resolve(R(c)).then(Q=>{g&&this.post(F,{type:n,payload:Q,id:g,isResponse:!0})}).catch(Q=>{g&&this.post(F,{type:n,payload:Q instanceof Error?Q.message:String(Q),id:g,isResponse:!0,isError:!0})})}};on=(e,i)=>{this.messageHandlers.set(e,i)};off=e=>{this.messageHandlers.delete(e)};send=async(e,i)=>{if(!this.available)return Promise.reject(new Error("PostMessageBridge is unavailable outside a browser environment"));const n=jn(10);return new Promise((c,g)=>{const m=setTimeout(()=>{this.pendingRequests.has(n)&&(this.pendingRequests.delete(n),g(new Error("Request timeout")))},d0),b=E=>{clearTimeout(m),g(E)};this.pendingRequests.set(n,{resolve:E=>{clearTimeout(m),c(E)},reject:b});try{this.post(this.targetWindow,{type:e,payload:i,id:n})}catch(E){this.pendingRequests.delete(n),b(E instanceof Error?E:new Error("Failed to post message"))}})};broadcast=e=>{if(this.available)try{this.post(this.targetWindow,{type:e.type,payload:e.payload})}catch{}};destroy=()=>{rc.remove(this),this.messageHandlers.clear(),this.pendingRequests.forEach(e=>{e.reject(new Error("Bridge destroyed"))}),this.pendingRequests.clear()}},f0=class xa{static instance;bridges=new Map;constructor(){}static getInstance(){return xa.instance||(xa.instance=new xa),xa.instance}connectClient=({id:i,targetOrigin:n,targetWindow:c,channel:g})=>{const m=new g0(c,n,g);if(i||(i=jn(10)),this.bridges.has(i))throw new Error(`Bridge ${i} already exists`);return this.bridges.set(i,m),{bridge:m,id:i}};getClient=i=>this.bridges.get(i);removeClient=i=>{const n=this.bridges.get(i);n&&(n.destroy(),this.bridges.delete(i))};removeAllClient=()=>{this.bridges.forEach(i=>{i.destroy()}),this.bridges.clear()};broadcast=i=>{this.bridges.forEach(n=>{n.broadcast(i)})};sendTo=(i,n,c)=>{const g=this.getClient(i);return g?g.send(n,c):Promise.reject(new Error(`Bridge ${i} not found`))}},O1=f0.getInstance(),P1=new Zl,pe=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Z=class{highOrder;lowOrder;constructor(e,i){this.highOrder=e,this.lowOrder=i}},U1=[new Z(pe[0],3609767458),new Z(pe[1],602891725),new Z(pe[2],3964484399),new Z(pe[3],2173295548),new Z(pe[4],4081628472),new Z(pe[5],3053834265),new Z(pe[6],2937671579),new Z(pe[7],3664609560),new Z(pe[8],2734883394),new Z(pe[9],1164996542),new Z(pe[10],1323610764),new Z(pe[11],3590304994),new Z(pe[12],4068182383),new Z(pe[13],991336113),new Z(pe[14],633803317),new Z(pe[15],3479774868),new Z(pe[16],2666613458),new Z(pe[17],944711139),new Z(pe[18],2341262773),new Z(pe[19],2007800933),new Z(pe[20],1495990901),new Z(pe[21],1856431235),new Z(pe[22],3175218132),new Z(pe[23],2198950837),new Z(pe[24],3999719339),new Z(pe[25],766784016),new Z(pe[26],2566594879),new Z(pe[27],3203337956),new Z(pe[28],1034457026),new Z(pe[29],2466948901),new Z(pe[30],3758326383),new Z(pe[31],168717936),new Z(pe[32],1188179964),new Z(pe[33],1546045734),new Z(pe[34],1522805485),new Z(pe[35],2643833823),new Z(pe[36],2343527390),new Z(pe[37],1014477480),new Z(pe[38],1206759142),new Z(pe[39],344077627),new Z(pe[40],1290863460),new Z(pe[41],3158454273),new Z(pe[42],3505952657),new Z(pe[43],106217008),new Z(pe[44],3606008344),new Z(pe[45],1432725776),new Z(pe[46],1467031594),new Z(pe[47],851169720),new Z(pe[48],3100823752),new Z(pe[49],1363258195),new Z(pe[50],3750685593),new Z(pe[51],3785050280),new Z(pe[52],3318307427),new Z(pe[53],3812723403),new Z(pe[54],2003034995),new Z(pe[55],3602036899),new Z(pe[56],1575990012),new Z(pe[57],1125592928),new Z(pe[58],2716904306),new Z(pe[59],442776044),new Z(pe[60],593698344),new Z(pe[61],3733110249),new Z(pe[62],2999351573),new Z(pe[63],3815920427),new Z(3391569614,3928383900),new Z(3515267271,566280711),new Z(3940187606,3454069534),new Z(4118630271,4000239992),new Z(116418474,1914138554),new Z(174292421,2731055270),new Z(289380356,3203993006),new Z(460393269,320620315),new Z(685471733,587496836),new Z(852142971,1086792851),new Z(1017036298,365543100),new Z(1126000580,2618297676),new Z(1288033470,3409855158),new Z(1501505948,4234509866),new Z(1607167915,987167468),new Z(1816402316,1246189591)],Q1=[new Z(0,1),new Z(0,32898),new Z(2147483648,32906),new Z(2147483648,2147516416),new Z(0,32907),new Z(0,2147483649),new Z(2147483648,2147516545),new Z(2147483648,32777),new Z(0,138),new Z(0,136),new Z(0,2147516425),new Z(0,2147483658),new Z(0,2147516555),new Z(2147483648,139),new Z(2147483648,32905),new Z(2147483648,32771),new Z(2147483648,32770),new Z(2147483648,128),new Z(0,32778),new Z(2147483648,2147483658),new Z(2147483648,2147516545),new Z(2147483648,32896),new Z(0,2147483649),new Z(2147483648,2147516424)],Gi=(e,i=500)=>{let n;return(...c)=>{clearTimeout(n),n=setTimeout(()=>{e.apply(void 0,c)},i)}},or=(e,i)=>{if(typeof document>"u")return;const n=e.classList;n.contains(i)||n.add(i)},kr=(e,i)=>{if(typeof document>"u")return;const n=e.classList;n.contains(i)&&n.remove(i)},ic=()=>{let e=0,i=null;return function(n,c=300){return function(...g){const m=Date.now();m-e>=c?(i!=null&&(clearTimeout(i),i=null),e=m,n.apply(this,g)):i??=window.setTimeout(()=>{e=Date.now(),n.apply(this,g),i=null},c-(m-e))}}},Zn=new Map([[100,"Continue"],[101,"Switching Protocols"],[102,"Processing"],[103,"Early Hints"],[200,"OK"],[201,"Created"],[202,"Accepted"],[203,"Non-Authoritative Information"],[204,"No Content"],[205,"Reset Content"],[206,"Partial Content"],[207,"Multi-Status"],[208,"Already Reported"],[226,"IM Used"],[300,"Multiple Choices"],[301,"Moved Permanently"],[302,"Found"],[303,"See Other"],[304,"Not Modified"],[305,"Use Proxy"],[307,"Temporary Redirect"],[308,"Permanent Redirect"],[400,"Bad Request"],[401,"Unauthorized"],[402,"Payment Required"],[403,"Forbidden"],[404,"Not Found"],[405,"Method Not Allowed"],[406,"Not Acceptable"],[407,"Proxy Authentication Required"],[408,"Request Timeout"],[409,"Conflict"],[410,"Gone"],[411,"Length Required"],[412,"Precondition Failed"],[413,"Payload Too Large"],[414,"URI Too Long"],[415,"Unsupported Media Type"],[416,"Range Not Satisfiable"],[417,"Expectation Failed"],[418,"I'm a Teapot"],[421,"Misdirected Request"],[422,"Unprocessable Entity"],[423,"Locked"],[424,"Failed Dependency"],[425,"Too Early"],[426,"Upgrade Required"],[428,"Precondition Required"],[429,"Too Many Requests"],[431,"Request Header Fields Too Large"],[451,"Unavailable For Legal Reasons"],[500,"Internal Server Error"],[501,"Not Implemented"],[502,"Bad Gateway"],[503,"Service Unavailable"],[504,"Gateway Timeout"],[505,"HTTP Version Not Supported"],[506,"Variant Also Negotiates"],[507,"Insufficient Storage"],[508,"Loop Detected"],[509,"Bandwidth Limit Exceeded"],[510,"Not Extended"],[511,"Network Authentication Required"]]),N1={message:Zn,code:(function(e){const i=new Map;for(const[n,c]of e)i.set(c.toLowerCase(),n);return i})(Zn),codes:(function(e){const i=[];for(const[n,c]of e)i.push(n);return i})(Zn),redirect:{300:!0,301:!0,302:!0,303:!0,305:!0,307:!0,308:!0},empty:{204:!0,205:!0,304:!0},retry:{502:!0,503:!0,504:!0}},p0='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{box-sizing:var(--ran-btn-box-sizing, border-box);position:var(--ran-btn-position, relative);display:var(--ran-btn-display, inline-flex);background-image:var(--ran-btn-background-image, none);box-shadow:var(--ran-btn-box-shadow, var(--ran-skin-raised-shadow, 0 2px #00000004));cursor:var(--ran-btn-cursor, pointer);-webkit-user-select:var(--ran-btn-user-select, none);user-select:var(--ran-btn-user-select, none);touch-action:var(--ran-btn-touch-action, manipulation);overflow:var(--ran-btn-overflow, hidden);pointer-events:var(--ran-btn-pointer-events, auto)}:host .ran-btn{box-sizing:var(--ran-btn-contain-box-sizing, border-box);position:var(--ran-btn-contain-position, relative);display:var(--ran-btn-contain-display, block);background-image:var(--ran-btn-contain-background-image, none);cursor:var(--ran-btn-contain-cursor, pointer);transition:var(--ran-btn-contain-transition, opacity var(--ran-motion-duration-base, .2s) cubic-bezier(.645, .045, .355, 1));-webkit-user-select:var(--ran-btn-contain-user-select, none);user-select:var(--ran-btn-contain-user-select, none);touch-action:var(--ran-btn-contain-touch-action, manipulation);border-radius:var(--ran-btn-content-border-radius, var(--ran-radius-sm, 6px));background:var(--ran-btn-contain-background, var(--ran-color-bg-elevated, #fff))}:host,:host(:active),:host(:focus){outline:0;-webkit-tap-highlight-color:transparent}:host .ran-btn,:host(:active) .ran-btn,:host(:focus) .ran-btn{outline:var(--ran-btn-contain-outline, 0)}:host(:focus-visible){outline:var(--ran-btn-focus-outline, 2px solid var(--ran-color-primary));outline-offset:var(--ran-btn-focus-outline-offset, 2px)}:host([type="primary"]) .ran-btn-content{background-color:var(--ran-btn-content-background-color, var(--ran-color-primary, #006bff));background-image:var(--ran-btn-content-background-image, none);border-color:var(--ran-btn-content-border-color, var(--ran-color-primary, #006bff));color:var(--ran-btn-content-color, #fff)}:host([type="primary"]:not([disabled])) .ran-btn:after{background-image:var(--ran-btn-after-background-image, radial-gradient(circle, #fff 10%, transparent 10.01%))}:host([type="primary"]:not([disabled]):active) .ran-btn-content{background-color:var(--ran-btn-content-active-background-color, var(--ran-color-primary-active, #005ff2));border-color:var(--ran-btn-content-active-border-color, var(--ran-color-primary-active, #005ff2))}:host([type="contrast"]) .ran-btn-content{background-color:var(--ran-btn-content-background-color, var(--ran-color-contrast-bg, #171717));background-image:var(--ran-btn-content-background-image, none);border-color:var(--ran-btn-content-border-color, var(--ran-color-contrast-bg, #171717));color:var(--ran-btn-content-color, var(--ran-color-contrast-text, #fff))}:host([type="contrast"]:not([disabled])) .ran-btn:after{background-image:var(--ran-btn-after-background-image, radial-gradient(circle, var(--ran-color-contrast-text, #fff) 10%, transparent 10.01%))}:host([type="contrast"]:not([disabled]):active) .ran-btn-content{background-color:var(--ran-btn-content-active-background-color, var(--ran-color-contrast-bg-active, #4d4d4d));border-color:var(--ran-btn-content-active-border-color, var(--ran-color-contrast-bg-active, #4d4d4d))}@media(min-width:1024px){:host(:not([disabled]):hover) .ran-btn-content{border-color:var(--ran-btn-content-hover-border-color, var(--ran-color-border-hover, #c9c9c9));color:var(--ran-btn-content-hover-color, var(--ran-color-text, #171717))}:host([type="primary"]:not([disabled]):hover) .ran-btn-content{background-color:var(--ran-btn-content-hover-background-color, var(--ran-color-primary-hover, #0059ec));border-color:var(--ran-btn-content-hover-border-color, var(--ran-color-primary-hover, #0059ec));color:var(--ran-btn-content-hover-color, #fff)}:host([type="contrast"]:not([disabled]):hover) .ran-btn-content{background-color:var(--ran-btn-content-hover-background-color, var(--ran-color-contrast-bg-hover, #383838));border-color:var(--ran-btn-content-hover-border-color, var(--ran-color-contrast-bg-hover, #383838));color:var(--ran-btn-content-hover-color, var(--ran-color-contrast-text, #fff))}:host([type="warning"]:not([disabled]):hover) .ran-btn-content{border-color:var(--ran-btn-content-warning-border-color, var(--ran-color-danger, #ff4d4f));background-color:var(--ran-btn-content-warning-background-color, var(--ran-color-danger, #ff4d4f));color:var(--ran-btn-content-warning-color, #fff)}}:host([type="warning"]) .ran-btn-content{border-color:var(--ran-btn-content-warning-border-color, var(--ran-color-danger, #ff4d4f));background-color:var(--ran-btn-content-warning-background-color, var(--ran-color-danger, #ff4d4f));background-image:var(--ran-btn-content-background-image, none);color:var(--ran-btn-content-warning-color, #fff)}:host([type="warning"]:not([disabled])) .ran-btn:after{background-image:var(--ran-btn-after-background-image, radial-gradient(circle, #fff 10%, transparent 10.01%))}:host([type="text"]) .ran-btn-content{border:var(--ran-btn-content-text-border, none)}:host([disabled]){cursor:var(--ran-btn-disabled-cursor, not-allowed);pointer-events:var(--ran-btn-disabled-pointer-events, all);opacity:var(--ran-btn-disabled-opacity, .6)}:host([disabled]) .ran-btn{cursor:var(--ran-btn-disabled-container-cursor, not-allowed);pointer-events:var(--ran-btn-disabled-container-pointer-events, all);opacity:var(--ran-btn-disabled-container-opacity, .6)}:host(:not([disabled]):active) .ran-btn:after{transform:var(--ran-btn-after-transform, translate(-50%, -50%) scale(0));opacity:var(--ran-btn-after-opacity, .3);transition:var(--ran-btn-after-transition, 0s)}@media(min-width:1024px){:host(:not([disabled],[effect])) .ran-btn:after{content:"";display:block;position:absolute;width:100%;height:100%;left:var(--ran-x, 0);top:var(--ran-y, 0);pointer-events:none;background-image:radial-gradient(circle,var(--ran-gray-alpha-400, #00000014) 10%,transparent 10.01%);background-repeat:no-repeat;background-position:50%;transform:translate(-50%,-50%) scale(10);opacity:0;transition:transform .3s,opacity .8s}}:host .slot{display:var(--ran-btn-slot-display, block)}.ran-btn-content{display:var(--ran-btn-content-display, flex);justify-content:var(--ran-btn-content-display, space-between);align-items:var(--ran-btn-content-align-items, center);padding:var(--ran-btn-content-padding, 4px 15px);border:var(--ran-btn-content-border, 1px solid transparent);border-image-source:var(--ran-btn-content-border-image-source, none);border-image-slice:var(--ran-btn-content-border-image-slice, 8);border-image-width:var(--ran-btn-content-border-image-width, 4px);border-image-outset:0;border-image-repeat:stretch;border-radius:var(--ran-btn-content-border-radius, var(--ran-radius-sm, 6px));border-color:var(--ran-btn-content-border-color, var(--ran-color-border, #eaeaea));color:var(--ran-btn-content-color, var(--ran-color-text, #000000d9));line-height:var(--ran-btn-content-line-height, 22px);font-size:var(--ran-btn-content-font-size, 14px);font-weight:var(--ran-btn-content-font-weight, 400);font-family:var(--ran-btn-content-font-family, var(--ran-skin-font-family, inherit));white-space:var(--ran-btn-content-white-space, nowrap);text-align:var(--ran-btn-content-text-align, center);box-sizing:var(--ran-btn-content-box-sizing, border-box)}.ran-btn-content .icon{margin-right:var(--ran-btn-icon-margin-right, 2px)}',Br=typeof document>"u",vt=class{ac;constructor(){this.ac=new AbortController}get signal(){return this.ac.signal}on(e,i,n,c){return e.addEventListener(i,n,{...c,signal:this.ac.signal}),this}delegate(e,i,n,c,g){return e.addEventListener(n,m=>{const b=m.target?.closest(i);b&&e.contains(b)&&c(m,b)},{...g,signal:this.ac.signal}),this}abort(){this.ac.abort(),this.ac=new AbortController}},Yi=null,Ki=null,ac=null;function m0(e,i){const n=i?.equals??Object.is;let c=e;const g=new Set;return[()=>(Yi&&Ki&&(g.add(Yi),Ki.add(g)),c),E=>{const R=typeof E=="function"?E(c):E;if(!n(c,R))if(c=R,ac)for(const F of g)ac.add(F);else for(const F of[...g])F()}]}function La(e){let i,n=!1;const c=new Set,g=()=>{if(n)return;i?.();for(const E of c)E.delete(g);c.clear();const m=Yi,b=Ki;Yi=g,Ki=c;try{i=e()??void 0}finally{Yi=m,Ki=b}};return g(),()=>{n=!0,i?.();for(const m of c)m.delete(g);c.clear()}}function mi(e){return typeof e!="string"?String(e):e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function nc(e){return mi(e)}var v0=e=>typeof e=="string"?!1:"tagName"in e&&"childrenList"in e,A0=(e,i)=>{const n=i.trim();if(!n)return!1;if(n.startsWith("."))return e.classList.contains(n.slice(1));if(n.startsWith("#"))return e.getAttribute("id")===n.slice(1);if(n.startsWith("[")&&n.endsWith("]")){const[c,g]=n.slice(1,-1).trim().split("="),m=(c||"").trim();if(!m)return!1;if(g==null)return e.hasAttribute(m);const b=g.trim().replace(/^['"]|['"]$/g,"");return e.getAttribute(m)===b}return e.tagName===n.toLowerCase()},Ma=(e,i,n)=>{for(const c of e)v0(c)&&(A0(c,i)&&n.push(c),Ma(c.childrenList,i,n))},$n=class{childrenList=[];appendChild(e){return this.childrenList.push(e),e}serialize(){return this.childrenList.map(e=>typeof e=="string"?mi(e):e.serialize()).join("")}querySelector(e){const i=this.querySelectorAll(e);return i.length>0?i[0]:null}querySelectorAll(e){const i=[];return Ma(this.childrenList,e,i),i}},eo=class{tagName;attributes=new Map;inlineStyles=new Map;childrenList=[];shadowRoot=null;textContent=null;content;eventListeners=new Map;style={setProperty:(e,i)=>{const n=e.startsWith("--")?e:e.replace(/([A-Z])/g,"-$1").toLowerCase();this.inlineStyles.set(n,i)},removeProperty:e=>this.inlineStyles.delete(e)};classList={add:(...e)=>{const i=this.attributes.get("class")||"",n=new Set([...i.split(" ").filter(Boolean),...e]);this.attributes.set("class",Array.from(n).join(" "))},remove:(...e)=>{const i=(this.attributes.get("class")||"").split(" ").filter(n=>!e.includes(n));this.attributes.set("class",i.join(" "))},toggle:e=>{this.classList.contains(e)?this.classList.remove(e):this.classList.add(e)},contains:e=>(this.attributes.get("class")||"").split(" ").includes(e)};_innerHTML="";get innerHTML(){return this._innerHTML}set innerHTML(e){this._innerHTML=e,this.tagName==="template"&&this.content&&(this.content.childrenList=[e])}constructor(e="div"){this.tagName=e.toLowerCase(),this.tagName==="template"&&(this.content=new $n)}get hidden(){return this.hasAttribute("hidden")}set hidden(e){e?this.setAttribute("hidden",""):this.removeAttribute("hidden")}setAttribute(e,i){this.attributes.set(e,i)}getAttribute(e){return this.attributes.get(e)||null}removeAttribute(e){this.attributes.delete(e)}hasAttribute(e){return this.attributes.has(e)}appendChild(e){return this.childrenList.push(e),e}attachShadow(e){return this.shadowRoot=new b0(this,e),this.shadowRoot}querySelector(e){const i=this.querySelectorAll(e);return i.length>0?i[0]:null}querySelectorAll(e){const i=[];return Ma(this.childrenList,e,i),i}addEventListener(e,i){const n=this.eventListeners.get(e)||new Set;n.add(i),this.eventListeners.set(e,n)}removeEventListener(e,i){const n=this.eventListeners.get(e);n&&(n.delete(i),n.size===0&&this.eventListeners.delete(e))}dispatchEvent(e){const i=this.eventListeners.get(e.type);if(!i||i.size===0)return!0;for(const n of i)typeof n=="function"?n.call(this,e):n.handleEvent(e);return!e.defaultPrevented}serialize(e){typeof this._preSerialize=="function"&&this._preSerialize();const i=e||this._ssrTag||this.tagName,n=Array.from(this.attributes.entries()).map(([b,E])=>` ${b}="${nc(E)}"`).join(""),c=Array.from(this.inlineStyles.entries()).map(([b,E])=>`${b}:${E}`).join(";"),g=c?` style="${nc(c)}"`:"";let m="";return this.shadowRoot&&(m+=this.shadowRoot.serialize()),this.textContent!==null?m+=mi(this.textContent):this._innerHTML?m+=this._innerHTML:m+=this.childrenList.map(b=>typeof b=="string"?mi(b):(b instanceof $n,b.serialize())).join(""),["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"].includes(i)&&!m?`<${i}${n}${g} />`:`<${i}${n}${g}>${m}</${i}>`}},b0=class{host;options;childrenList=[];adoptedStyleSheets=[];constructor(e,i){this.host=e,this.options=i}appendChild(e){return this.childrenList.push(e),e}querySelector(e){const i=this.querySelectorAll(e);return i.length>0?i[0]:null}querySelectorAll(e){const i=[];return Ma(this.childrenList,e,i),i}serialize(){return`<template shadowrootmode="${this.options.mode}"${this.options.delegatesFocus?" shadowrootdelegatesfocus":""}>${this.adoptedStyleSheets.map(e=>`<style>${mi(e)}</style>`).join("")}${this.childrenList.map(e=>typeof e=="string"?mi(e):(e instanceof $n,e.serialize())).join("")}</template>`}},oc=class $g{el;constructor(i){this.el=Br?new eo(i):document.createElement(i)}id(i){return this.el.setAttribute("id",i),this}class(i){return Br?this.el.attributes.set("class",i):this.el.className=i,this}addClass(...i){return i.forEach(n=>this.el.classList.add(n)),this}removeClass(...i){return i.forEach(n=>this.el.classList.remove(n)),this}attr(i,n){return this.el.setAttribute(i,n),this}attrs(i){return Object.entries(i).forEach(([n,c])=>{c!=null&&this.el.setAttribute(n,String(c))}),this}boolAttr(i,n,c=""){return n?this.el.setAttribute(i,c):this.el.removeAttribute(i),this}part(i){return this.el.setAttribute("part",i),this}data(i,n){return this.attr(`data-${i}`,n)}style(i,n){return typeof i=="string"?this.el.style.setProperty(i,n??""):Object.entries(i).forEach(([c,g])=>this.el.style.setProperty(c,g)),this}cssVar(i,n){const c=i.startsWith("--")?i:`--${i}`;return this.style(c,n)}aria(i,n){return this.attr(`aria-${i}`,n)}role(i){return this.attr("role",i)}tabIndex(i){return this.attr("tabindex",String(i))}label(i){return this.aria("label",i)}labelledBy(i){return this.aria("labelledby",i)}describedBy(i){return this.aria("describedby",i)}ariaHidden(i=!0){return this.aria("hidden",String(i))}on(i,n,c){return this.el.addEventListener(i,n,c),this}listen(i,n,c,g){return i.on(this.el,n,c,g),this}delegate(i,n,c,g,m){return i.delegate(this.el,n,c,g,m),this}children(...i){const n=c=>c.reduce((g,m)=>Array.isArray(m)?g.concat(n(m)):g.concat(m),[]);return n(i).forEach(c=>{c!=null&&(c instanceof $g?this.el.appendChild(c.build()):typeof c=="string"?Br?this.el.appendChild(c):this.el.appendChild(document.createTextNode(c)):this.el.appendChild(c))}),this}replaceChildren(...i){if(Br){const n=this.el;n.childrenList=[]}else this.el.replaceChildren();return this.children(...i)}text(i){return this.el.textContent=i,this}ref(i){return i.current=this.el,this}shadow(i={mode:"closed"}){const n=this.el.attachShadow(i);return new y0(this.el,n,i)}build(){return this.el}serialize(){if(Br)return this.el.serialize();const i=document.createElement("div");return i.appendChild(this.el.cloneNode(!0)),i.innerHTML}},y0=class{root;hostEl;options;constructor(e,i,n){this.hostEl=e,this.root=i,this.options=n}children(...e){const i=n=>n.reduce((c,g)=>Array.isArray(g)?c.concat(i(g)):c.concat(g),[]);return i(e).forEach(n=>{n!=null&&(n instanceof oc?this.root.appendChild(n.build()):typeof n=="string"?Br?this.root.appendChild(n):this.root.appendChild(document.createTextNode(n)):this.root.appendChild(n))}),this}adoptSheet(...e){return this.root.adoptedStyleSheets=[...this.root.adoptedStyleSheets,...e],this}css(e){if(Br)return this.root.adoptedStyleSheets.push(e),this;if(typeof CSSStyleSheet<"u")try{const n=new CSSStyleSheet;return n.replaceSync(e),this.root.adoptedStyleSheets=[...this.root.adoptedStyleSheets,n],this}catch{}const i=document.createElement("style");return i.textContent=e,this.root.appendChild(i),this}done(){return{host:this.hostEl,shadow:this.root}}serialize(){return Br?this.root.serialize():this.root.innerHTML}},Ne=e=>new oc(e),K=()=>Ne("div"),Hr=()=>Ne("span"),gt=()=>Ne("slot"),sc=()=>Ne("button"),to=()=>Ne("input"),w0=()=>Ne("style"),C0=()=>Ne("label"),sr=[!1,"false",null,void 0],rt=e=>{const i=e.hasAttribute("disabled"),n=e.getAttribute("disabled");return!!(i&&!sr.includes(n))},lc=new Map;function qe(e,i){Br?(lc.set(e,i),i.prototype._ssrTag=e):customElements.get(e)||customElements.define(e,i)}function E0(){return lc}var cc=()=>typeof document<"u"?HTMLElement:eo,Ve=cc(),k0=e=>{if(e.tagName&&e.tagName!=="div")return e.tagName;const i=E0();for(const[n,c]of i)if(e instanceof c)return n;return e.constructor.name.toLowerCase()},B0=e=>{if(!e)return"";const i=k0(e);return typeof e.serialize=="function"||e instanceof eo?e.serialize(i):""},ro=new Map,io=new Map,I0=(e,i)=>{if(!(typeof document>"u")&&i){if(typeof CSSStyleSheet<"u")try{if(!ro.has(i)){const c=new CSSStyleSheet;c.replaceSync(i),ro.set(i,c)}const n=ro.get(i);e.adoptedStyleSheets.includes(n)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]);return}catch{}if(!e.querySelector("style[data-ranui]")){const n=document.createElement("style");n.setAttribute("data-ranui",""),n.textContent=i,e.appendChild(n)}}},S0=(e,i)=>{if(!(typeof document>"u")&&i){if(typeof CSSStyleSheet<"u")try{if(!io.has(i)){const c=new CSSStyleSheet;c.replaceSync(i),io.set(i,c)}const n=io.get(i);e.adoptedStyleSheets.includes(n)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]);return}catch{}if(!Array.from(e.querySelectorAll("style[data-ranui-sheet]")).some(n=>n.textContent===i)){const n=document.createElement("style");n.setAttribute("data-ranui-sheet",""),n.textContent=i,e.appendChild(n)}}},dc=new WeakMap,hc="@media (prefers-reduced-motion: reduce){*,*::before,*::after{animation-duration:.01ms !important;animation-iteration-count:1 !important;transition-duration:.01ms !important;scroll-behavior:auto !important}}",We=(e,i="",n={mode:"closed"})=>{const c=e.shadowRoot||dc.get(e)||e.attachShadow(n);return dc.set(e,c),I0(c,i?`${i}
1
+ var g=this,m=function(){"use strict";var ranui=(function(ke){Object.defineProperty(ke,Symbol.toStringTag,{value:"Module"});var Vl=Object.defineProperty,Wl=(e,i,n)=>()=>{if(n)throw n[0];try{return e&&(i=e(e=0)),i}catch(c){throw n=[c],c}},a0=(e,i)=>()=>(i||(e((i={exports:{}}).exports,i),e=null),i.exports),n0=(e,i)=>{let n={};for(var c in e)Vl(n,c,{get:e[c],enumerable:!0});return i||Vl(n,Symbol.toStringTag,{value:"Module"}),n},Ta="ran-theme",Ui=null,Qi=null,Da=e=>{if(e&&"style"in e)return e;if(e&&"documentElement"in e)return e.documentElement;if(!(typeof document>"u"))return document.documentElement},Xl=e=>{const i=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches;e.setAttribute("data-ran-theme",i?"dark":"light"),e.setAttribute("theme",i?"dark":"light")},o0=()=>{Ui&&Qi&&(Ui.removeEventListener("change",Qi),Ui=null,Qi=null)},_n=(e,i)=>{const n=Da(i);if(n){if(o0(),e==="system"){if(typeof window>"u")return;Xl(n),Ui=window.matchMedia("(prefers-color-scheme: dark)"),Qi=()=>Xl(n),Ui.addEventListener("change",Qi);try{localStorage.setItem(Ta,"system")}catch{}return}n.setAttribute("data-ran-theme",e),n.setAttribute("theme",e);try{localStorage.setItem(Ta,e)}catch{}}},Jl=e=>{const i=Da(e);if(!i)return"";const n=i.getAttribute("data-ran-theme")||i.getAttribute("theme")||"";if(n==="light"||n==="dark"){try{if(localStorage.getItem(Ta)==="system")return"system"}catch{}return n}return""},_l=(e,i,n)=>{const c=Da(n);c&&c.style.setProperty(e,String(i))},jl=(e,i)=>{const n=Da(i);n&&n.style.removeProperty(e)},s0=(e,i)=>{Object.entries(e).forEach(([n,c])=>{if(c==null){jl(n,i);return}_l(n,c,i)})},l0=e=>{if(!(typeof localStorage>"u"))try{const i=localStorage.getItem(Ta);(i==="light"||i==="dark"||i==="system")&&_n(i,e)}catch{}},Zl=class{_events=new Map;tap=(e,i)=>{this._events.get(e)&&e!==Symbol.for("NEW_LISTENER")&&this.call(Symbol.for("NEW_LISTENER"),e);const n=this._events.get(e)||new Set;return typeof i=="function"?n.add({name:e,callback:i}):n.add(i),this._events.set(e,n),this};call=(e,...i)=>((this._events.get(e)||new Set).forEach(n=>{const{callback:c}=n;c(...i)}),this);callSync=async(e,...i)=>{const n=this._events.get(e)||new Set;for(const c of n){const{callback:g}=c;await g(...i)}return this};once=(e,i)=>{let n;if(typeof i=="function")n={name:e,callback:(...c)=>{i(...c),this.off(e,n)},initialCallback:i};else{const{callback:c}=i;n={name:e,callback:(...g)=>{c(...g),this.off(e,n)},initialCallback:c}}return this.tap(e,n),this};off=(e,i)=>{const n=[...this._events.get(e)||new Set].filter(c=>{if(typeof i=="function")return c.callback!==i&&c.initialCallback!==i;{const{callback:g}=i;return c.callback!==g&&c.initialCallback!==g}});return this._events.set(e,new Set(n)),this}},jn=(e=8)=>Math.random().toString(36).substring(2,e+2),$l=(e="")=>{if(e.length===0)return 0;if(e.endsWith("%")){const i=Number(e.replace("%",""));return i>1?i/100:i}return Number(e)},Ft=(e,i=0,n=1)=>Math.min(n,Math.max(i,e)),c0=e=>typeof e=="function";function Ra(e){return e<10?`0${e}`:e}var pi=e=>{if(e===0)return"00:00";if(!e)return"";const i=Math.trunc(e/3600),n=Math.trunc(e%3600/60),c=Ra(Math.trunc(e-3600*i-60*n));return i===0?`${Ra(n)}:${c}`:`${Ra(i)}:${Ra(n)}:${c}`},ec=()=>{if(typeof window<"u"){const e=navigator.userAgent.toLowerCase();return/ipad|ipod/.test(e)?"ipad":/android/.test(e)?"android":/iphone/.test(e)?"iphone":"pc"}return"pc"},tc=typeof window<"u",Ni=()=>{if(!tc)return!1;const e=window.navigator.userAgent;return!!/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(e)},Hi=e=>{const i=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||1;return(tc&&window.devicePixelRatio||1)/i},d0=12e4,h0="__ranuts_bridge__",u0="default",rc=new class{bridges=new Set;attachedWindow=null;handleMessage=e=>{for(const i of Array.from(this.bridges))i.receive(e)};add(e){this.bridges.add(e),typeof window<"u"&&this.attachedWindow!==window&&(window.addEventListener("message",this.handleMessage),this.attachedWindow=window)}remove(e){this.bridges.delete(e),this.bridges.size===0&&this.attachedWindow&&(this.attachedWindow.removeEventListener("message",this.handleMessage),this.attachedWindow=null)}},g0=class{targetWindow;targetOrigin;messageHandlers;pendingRequests;channel;senderId;available;constructor(e,i="*",n=u0){this.targetOrigin=i,this.channel=n,this.senderId=jn(12),this.messageHandlers=new Map,this.pendingRequests=new Map,this.available=typeof window<"u",this.available?(this.targetWindow=e??window,rc.add(this)):this.targetWindow=void 0}post(e,i){const n={...i,__bridge:h0,channel:this.channel,senderId:this.senderId};e.postMessage(n,this.targetOrigin)}receive=e=>{if(!this.available||this.targetOrigin!=="*"&&e.origin!==this.targetOrigin||e.source&&e.source!==this.targetWindow)return;const i=e.data;if(!i||typeof i!="object"||i.__bridge!=="__ranuts_bridge__"||(i.channel??"default")!==this.channel)return;const{type:n,payload:c,id:g,isResponse:m,isError:b,senderId:E}=i;if(m&&g){const F=this.pendingRequests.get(g);F&&(b?F.reject(new Error(typeof c=="string"?c:"Bridge request failed")):F.resolve(c),this.pendingRequests.delete(g));return}if(E&&E===this.senderId||typeof n!="string"||!this.messageHandlers.has(n))return;const R=this.messageHandlers.get(n);if(c0(R)){const F=e.source??this.targetWindow;Promise.resolve(R(c)).then(Q=>{g&&this.post(F,{type:n,payload:Q,id:g,isResponse:!0})}).catch(Q=>{g&&this.post(F,{type:n,payload:Q instanceof Error?Q.message:String(Q),id:g,isResponse:!0,isError:!0})})}};on=(e,i)=>{this.messageHandlers.set(e,i)};off=e=>{this.messageHandlers.delete(e)};send=async(e,i)=>{if(!this.available)return Promise.reject(new Error("PostMessageBridge is unavailable outside a browser environment"));const n=jn(10);return new Promise((c,g)=>{const m=setTimeout(()=>{this.pendingRequests.has(n)&&(this.pendingRequests.delete(n),g(new Error("Request timeout")))},d0),b=E=>{clearTimeout(m),g(E)};this.pendingRequests.set(n,{resolve:E=>{clearTimeout(m),c(E)},reject:b});try{this.post(this.targetWindow,{type:e,payload:i,id:n})}catch(E){this.pendingRequests.delete(n),b(E instanceof Error?E:new Error("Failed to post message"))}})};broadcast=e=>{if(this.available)try{this.post(this.targetWindow,{type:e.type,payload:e.payload})}catch{}};destroy=()=>{rc.remove(this),this.messageHandlers.clear(),this.pendingRequests.forEach(e=>{e.reject(new Error("Bridge destroyed"))}),this.pendingRequests.clear()}},f0=class xa{static instance;bridges=new Map;constructor(){}static getInstance(){return xa.instance||(xa.instance=new xa),xa.instance}connectClient=({id:i,targetOrigin:n,targetWindow:c,channel:g})=>{const m=new g0(c,n,g);if(i||(i=jn(10)),this.bridges.has(i))throw new Error(`Bridge ${i} already exists`);return this.bridges.set(i,m),{bridge:m,id:i}};getClient=i=>this.bridges.get(i);removeClient=i=>{const n=this.bridges.get(i);n&&(n.destroy(),this.bridges.delete(i))};removeAllClient=()=>{this.bridges.forEach(i=>{i.destroy()}),this.bridges.clear()};broadcast=i=>{this.bridges.forEach(n=>{n.broadcast(i)})};sendTo=(i,n,c)=>{const g=this.getClient(i);return g?g.send(n,c):Promise.reject(new Error(`Bridge ${i} not found`))}},P1=f0.getInstance(),U1=new Zl,pe=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Z=class{highOrder;lowOrder;constructor(e,i){this.highOrder=e,this.lowOrder=i}},Q1=[new Z(pe[0],3609767458),new Z(pe[1],602891725),new Z(pe[2],3964484399),new Z(pe[3],2173295548),new Z(pe[4],4081628472),new Z(pe[5],3053834265),new Z(pe[6],2937671579),new Z(pe[7],3664609560),new Z(pe[8],2734883394),new Z(pe[9],1164996542),new Z(pe[10],1323610764),new Z(pe[11],3590304994),new Z(pe[12],4068182383),new Z(pe[13],991336113),new Z(pe[14],633803317),new Z(pe[15],3479774868),new Z(pe[16],2666613458),new Z(pe[17],944711139),new Z(pe[18],2341262773),new Z(pe[19],2007800933),new Z(pe[20],1495990901),new Z(pe[21],1856431235),new Z(pe[22],3175218132),new Z(pe[23],2198950837),new Z(pe[24],3999719339),new Z(pe[25],766784016),new Z(pe[26],2566594879),new Z(pe[27],3203337956),new Z(pe[28],1034457026),new Z(pe[29],2466948901),new Z(pe[30],3758326383),new Z(pe[31],168717936),new Z(pe[32],1188179964),new Z(pe[33],1546045734),new Z(pe[34],1522805485),new Z(pe[35],2643833823),new Z(pe[36],2343527390),new Z(pe[37],1014477480),new Z(pe[38],1206759142),new Z(pe[39],344077627),new Z(pe[40],1290863460),new Z(pe[41],3158454273),new Z(pe[42],3505952657),new Z(pe[43],106217008),new Z(pe[44],3606008344),new Z(pe[45],1432725776),new Z(pe[46],1467031594),new Z(pe[47],851169720),new Z(pe[48],3100823752),new Z(pe[49],1363258195),new Z(pe[50],3750685593),new Z(pe[51],3785050280),new Z(pe[52],3318307427),new Z(pe[53],3812723403),new Z(pe[54],2003034995),new Z(pe[55],3602036899),new Z(pe[56],1575990012),new Z(pe[57],1125592928),new Z(pe[58],2716904306),new Z(pe[59],442776044),new Z(pe[60],593698344),new Z(pe[61],3733110249),new Z(pe[62],2999351573),new Z(pe[63],3815920427),new Z(3391569614,3928383900),new Z(3515267271,566280711),new Z(3940187606,3454069534),new Z(4118630271,4000239992),new Z(116418474,1914138554),new Z(174292421,2731055270),new Z(289380356,3203993006),new Z(460393269,320620315),new Z(685471733,587496836),new Z(852142971,1086792851),new Z(1017036298,365543100),new Z(1126000580,2618297676),new Z(1288033470,3409855158),new Z(1501505948,4234509866),new Z(1607167915,987167468),new Z(1816402316,1246189591)],N1=[new Z(0,1),new Z(0,32898),new Z(2147483648,32906),new Z(2147483648,2147516416),new Z(0,32907),new Z(0,2147483649),new Z(2147483648,2147516545),new Z(2147483648,32777),new Z(0,138),new Z(0,136),new Z(0,2147516425),new Z(0,2147483658),new Z(0,2147516555),new Z(2147483648,139),new Z(2147483648,32905),new Z(2147483648,32771),new Z(2147483648,32770),new Z(2147483648,128),new Z(0,32778),new Z(2147483648,2147483658),new Z(2147483648,2147516545),new Z(2147483648,32896),new Z(0,2147483649),new Z(2147483648,2147516424)],Gi=(e,i=500)=>{let n;return(...c)=>{clearTimeout(n),n=setTimeout(()=>{e.apply(void 0,c)},i)}},or=(e,i)=>{if(typeof document>"u")return;const n=e.classList;n.contains(i)||n.add(i)},kr=(e,i)=>{if(typeof document>"u")return;const n=e.classList;n.contains(i)&&n.remove(i)},ic=()=>{let e=0,i=null;return function(n,c=300){return function(...g){const m=Date.now();m-e>=c?(i!=null&&(clearTimeout(i),i=null),e=m,n.apply(this,g)):i??=window.setTimeout(()=>{e=Date.now(),n.apply(this,g),i=null},c-(m-e))}}},Zn=new Map([[100,"Continue"],[101,"Switching Protocols"],[102,"Processing"],[103,"Early Hints"],[200,"OK"],[201,"Created"],[202,"Accepted"],[203,"Non-Authoritative Information"],[204,"No Content"],[205,"Reset Content"],[206,"Partial Content"],[207,"Multi-Status"],[208,"Already Reported"],[226,"IM Used"],[300,"Multiple Choices"],[301,"Moved Permanently"],[302,"Found"],[303,"See Other"],[304,"Not Modified"],[305,"Use Proxy"],[307,"Temporary Redirect"],[308,"Permanent Redirect"],[400,"Bad Request"],[401,"Unauthorized"],[402,"Payment Required"],[403,"Forbidden"],[404,"Not Found"],[405,"Method Not Allowed"],[406,"Not Acceptable"],[407,"Proxy Authentication Required"],[408,"Request Timeout"],[409,"Conflict"],[410,"Gone"],[411,"Length Required"],[412,"Precondition Failed"],[413,"Payload Too Large"],[414,"URI Too Long"],[415,"Unsupported Media Type"],[416,"Range Not Satisfiable"],[417,"Expectation Failed"],[418,"I'm a Teapot"],[421,"Misdirected Request"],[422,"Unprocessable Entity"],[423,"Locked"],[424,"Failed Dependency"],[425,"Too Early"],[426,"Upgrade Required"],[428,"Precondition Required"],[429,"Too Many Requests"],[431,"Request Header Fields Too Large"],[451,"Unavailable For Legal Reasons"],[500,"Internal Server Error"],[501,"Not Implemented"],[502,"Bad Gateway"],[503,"Service Unavailable"],[504,"Gateway Timeout"],[505,"HTTP Version Not Supported"],[506,"Variant Also Negotiates"],[507,"Insufficient Storage"],[508,"Loop Detected"],[509,"Bandwidth Limit Exceeded"],[510,"Not Extended"],[511,"Network Authentication Required"]]),H1={message:Zn,code:(function(e){const i=new Map;for(const[n,c]of e)i.set(c.toLowerCase(),n);return i})(Zn),codes:(function(e){const i=[];for(const[n,c]of e)i.push(n);return i})(Zn),redirect:{300:!0,301:!0,302:!0,303:!0,305:!0,307:!0,308:!0},empty:{204:!0,205:!0,304:!0},retry:{502:!0,503:!0,504:!0}},p0='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{box-sizing:var(--ran-btn-box-sizing, border-box);position:var(--ran-btn-position, relative);display:var(--ran-btn-display, inline-flex);background-image:var(--ran-btn-background-image, none);box-shadow:var(--ran-btn-box-shadow, var(--ran-skin-raised-shadow, 0 2px #00000004));cursor:var(--ran-btn-cursor, pointer);-webkit-user-select:var(--ran-btn-user-select, none);user-select:var(--ran-btn-user-select, none);touch-action:var(--ran-btn-touch-action, manipulation);overflow:var(--ran-btn-overflow, hidden);pointer-events:var(--ran-btn-pointer-events, auto)}:host .ran-btn{box-sizing:var(--ran-btn-contain-box-sizing, border-box);position:var(--ran-btn-contain-position, relative);display:var(--ran-btn-contain-display, block);background-image:var(--ran-btn-contain-background-image, none);cursor:var(--ran-btn-contain-cursor, pointer);transition:var(--ran-btn-contain-transition, opacity var(--ran-motion-duration-base, .2s) cubic-bezier(.645, .045, .355, 1));-webkit-user-select:var(--ran-btn-contain-user-select, none);user-select:var(--ran-btn-contain-user-select, none);touch-action:var(--ran-btn-contain-touch-action, manipulation);border-radius:var(--ran-btn-content-border-radius, var(--ran-radius-sm, 6px));background:var(--ran-btn-contain-background, var(--ran-color-bg-elevated, #fff))}:host,:host(:active),:host(:focus){outline:0;-webkit-tap-highlight-color:transparent}:host .ran-btn,:host(:active) .ran-btn,:host(:focus) .ran-btn{outline:var(--ran-btn-contain-outline, 0)}:host(:focus-visible){outline:var(--ran-btn-focus-outline, 2px solid var(--ran-color-primary));outline-offset:var(--ran-btn-focus-outline-offset, 2px)}:host([type="primary"]) .ran-btn-content{background-color:var(--ran-btn-content-background-color, var(--ran-color-primary, #006bff));background-image:var(--ran-btn-content-background-image, none);border-color:var(--ran-btn-content-border-color, var(--ran-color-primary, #006bff));color:var(--ran-btn-content-color, #fff)}:host([type="primary"]:not([disabled])) .ran-btn:after{background-image:var(--ran-btn-after-background-image, radial-gradient(circle, #fff 10%, transparent 10.01%))}:host([type="primary"]:not([disabled]):active) .ran-btn-content{background-color:var(--ran-btn-content-active-background-color, var(--ran-color-primary-active, #005ff2));border-color:var(--ran-btn-content-active-border-color, var(--ran-color-primary-active, #005ff2))}:host([type="contrast"]) .ran-btn-content{background-color:var(--ran-btn-content-background-color, var(--ran-color-contrast-bg, #171717));background-image:var(--ran-btn-content-background-image, none);border-color:var(--ran-btn-content-border-color, var(--ran-color-contrast-bg, #171717));color:var(--ran-btn-content-color, var(--ran-color-contrast-text, #fff))}:host([type="contrast"]:not([disabled])) .ran-btn:after{background-image:var(--ran-btn-after-background-image, radial-gradient(circle, var(--ran-color-contrast-text, #fff) 10%, transparent 10.01%))}:host([type="contrast"]:not([disabled]):active) .ran-btn-content{background-color:var(--ran-btn-content-active-background-color, var(--ran-color-contrast-bg-active, #4d4d4d));border-color:var(--ran-btn-content-active-border-color, var(--ran-color-contrast-bg-active, #4d4d4d))}@media(min-width:1024px){:host(:not([disabled]):hover) .ran-btn-content{border-color:var(--ran-btn-content-hover-border-color, var(--ran-color-border-hover, #c9c9c9));color:var(--ran-btn-content-hover-color, var(--ran-color-text, #171717))}:host([type="primary"]:not([disabled]):hover) .ran-btn-content{background-color:var(--ran-btn-content-hover-background-color, var(--ran-color-primary-hover, #0059ec));border-color:var(--ran-btn-content-hover-border-color, var(--ran-color-primary-hover, #0059ec));color:var(--ran-btn-content-hover-color, #fff)}:host([type="contrast"]:not([disabled]):hover) .ran-btn-content{background-color:var(--ran-btn-content-hover-background-color, var(--ran-color-contrast-bg-hover, #383838));border-color:var(--ran-btn-content-hover-border-color, var(--ran-color-contrast-bg-hover, #383838));color:var(--ran-btn-content-hover-color, var(--ran-color-contrast-text, #fff))}:host([type="warning"]:not([disabled]):hover) .ran-btn-content{border-color:var(--ran-btn-content-warning-border-color, var(--ran-color-danger, #ff4d4f));background-color:var(--ran-btn-content-warning-background-color, var(--ran-color-danger, #ff4d4f));color:var(--ran-btn-content-warning-color, #fff)}}:host([type="warning"]) .ran-btn-content{border-color:var(--ran-btn-content-warning-border-color, var(--ran-color-danger, #ff4d4f));background-color:var(--ran-btn-content-warning-background-color, var(--ran-color-danger, #ff4d4f));background-image:var(--ran-btn-content-background-image, none);color:var(--ran-btn-content-warning-color, #fff)}:host([type="warning"]:not([disabled])) .ran-btn:after{background-image:var(--ran-btn-after-background-image, radial-gradient(circle, #fff 10%, transparent 10.01%))}:host([type="text"]) .ran-btn-content{border:var(--ran-btn-content-text-border, none)}:host([disabled]){cursor:var(--ran-btn-disabled-cursor, not-allowed);pointer-events:var(--ran-btn-disabled-pointer-events, all);opacity:var(--ran-btn-disabled-opacity, .6)}:host([disabled]) .ran-btn{cursor:var(--ran-btn-disabled-container-cursor, not-allowed);pointer-events:var(--ran-btn-disabled-container-pointer-events, all);opacity:var(--ran-btn-disabled-container-opacity, .6)}:host(:not([disabled]):active) .ran-btn:after{transform:var(--ran-btn-after-transform, translate(-50%, -50%) scale(0));opacity:var(--ran-btn-after-opacity, .3);transition:var(--ran-btn-after-transition, 0s)}@media(min-width:1024px){:host(:not([disabled],[effect])) .ran-btn:after{content:"";display:block;position:absolute;width:100%;height:100%;left:var(--ran-x, 0);top:var(--ran-y, 0);pointer-events:none;background-image:radial-gradient(circle,var(--ran-gray-alpha-400, #00000014) 10%,transparent 10.01%);background-repeat:no-repeat;background-position:50%;transform:translate(-50%,-50%) scale(10);opacity:0;transition:transform .3s,opacity .8s}}:host .slot{display:var(--ran-btn-slot-display, block)}.ran-btn-content{display:var(--ran-btn-content-display, flex);justify-content:var(--ran-btn-content-display, space-between);align-items:var(--ran-btn-content-align-items, center);padding:var(--ran-btn-content-padding, 4px 15px);border:var(--ran-btn-content-border, 1px solid transparent);border-image-source:var(--ran-btn-content-border-image-source, none);border-image-slice:var(--ran-btn-content-border-image-slice, 8);border-image-width:var(--ran-btn-content-border-image-width, 4px);border-image-outset:0;border-image-repeat:stretch;border-radius:var(--ran-btn-content-border-radius, var(--ran-radius-sm, 6px));border-color:var(--ran-btn-content-border-color, var(--ran-color-border, #eaeaea));color:var(--ran-btn-content-color, var(--ran-color-text, #000000d9));line-height:var(--ran-btn-content-line-height, 22px);font-size:var(--ran-btn-content-font-size, 14px);font-weight:var(--ran-btn-content-font-weight, 400);font-family:var(--ran-btn-content-font-family, var(--ran-skin-font-family, inherit));white-space:var(--ran-btn-content-white-space, nowrap);text-align:var(--ran-btn-content-text-align, center);box-sizing:var(--ran-btn-content-box-sizing, border-box)}.ran-btn-content .icon{margin-right:var(--ran-btn-icon-margin-right, 2px)}',Br=typeof document>"u",vt=class{ac;constructor(){this.ac=new AbortController}get signal(){return this.ac.signal}on(e,i,n,c){return e.addEventListener(i,n,{...c,signal:this.ac.signal}),this}delegate(e,i,n,c,g){return e.addEventListener(n,m=>{const b=m.target?.closest(i);b&&e.contains(b)&&c(m,b)},{...g,signal:this.ac.signal}),this}abort(){this.ac.abort(),this.ac=new AbortController}},Yi=null,Ki=null,ac=null;function m0(e,i){const n=i?.equals??Object.is;let c=e;const g=new Set;return[()=>(Yi&&Ki&&(g.add(Yi),Ki.add(g)),c),E=>{const R=typeof E=="function"?E(c):E;if(!n(c,R))if(c=R,ac)for(const F of g)ac.add(F);else for(const F of[...g])F()}]}function La(e){let i,n=!1;const c=new Set,g=()=>{if(n)return;i?.();for(const E of c)E.delete(g);c.clear();const m=Yi,b=Ki;Yi=g,Ki=c;try{i=e()??void 0}finally{Yi=m,Ki=b}};return g(),()=>{n=!0,i?.();for(const m of c)m.delete(g);c.clear()}}function mi(e){return typeof e!="string"?String(e):e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function nc(e){return mi(e)}var v0=e=>typeof e=="string"?!1:"tagName"in e&&"childrenList"in e,A0=(e,i)=>{const n=i.trim();if(!n)return!1;if(n.startsWith("."))return e.classList.contains(n.slice(1));if(n.startsWith("#"))return e.getAttribute("id")===n.slice(1);if(n.startsWith("[")&&n.endsWith("]")){const[c,g]=n.slice(1,-1).trim().split("="),m=(c||"").trim();if(!m)return!1;if(g==null)return e.hasAttribute(m);const b=g.trim().replace(/^['"]|['"]$/g,"");return e.getAttribute(m)===b}return e.tagName===n.toLowerCase()},Ma=(e,i,n)=>{for(const c of e)v0(c)&&(A0(c,i)&&n.push(c),Ma(c.childrenList,i,n))},$n=class{childrenList=[];appendChild(e){return this.childrenList.push(e),e}serialize(){return this.childrenList.map(e=>typeof e=="string"?mi(e):e.serialize()).join("")}querySelector(e){const i=this.querySelectorAll(e);return i.length>0?i[0]:null}querySelectorAll(e){const i=[];return Ma(this.childrenList,e,i),i}},eo=class{tagName;attributes=new Map;inlineStyles=new Map;childrenList=[];shadowRoot=null;textContent=null;content;eventListeners=new Map;style={setProperty:(e,i)=>{const n=e.startsWith("--")?e:e.replace(/([A-Z])/g,"-$1").toLowerCase();this.inlineStyles.set(n,i)},removeProperty:e=>this.inlineStyles.delete(e)};classList={add:(...e)=>{const i=this.attributes.get("class")||"",n=new Set([...i.split(" ").filter(Boolean),...e]);this.attributes.set("class",Array.from(n).join(" "))},remove:(...e)=>{const i=(this.attributes.get("class")||"").split(" ").filter(n=>!e.includes(n));this.attributes.set("class",i.join(" "))},toggle:e=>{this.classList.contains(e)?this.classList.remove(e):this.classList.add(e)},contains:e=>(this.attributes.get("class")||"").split(" ").includes(e)};_innerHTML="";get innerHTML(){return this._innerHTML}set innerHTML(e){this._innerHTML=e,this.tagName==="template"&&this.content&&(this.content.childrenList=[e])}constructor(e="div"){this.tagName=e.toLowerCase(),this.tagName==="template"&&(this.content=new $n)}get hidden(){return this.hasAttribute("hidden")}set hidden(e){e?this.setAttribute("hidden",""):this.removeAttribute("hidden")}setAttribute(e,i){this.attributes.set(e,i)}getAttribute(e){return this.attributes.get(e)||null}removeAttribute(e){this.attributes.delete(e)}hasAttribute(e){return this.attributes.has(e)}appendChild(e){return this.childrenList.push(e),e}attachShadow(e){return this.shadowRoot=new b0(this,e),this.shadowRoot}querySelector(e){const i=this.querySelectorAll(e);return i.length>0?i[0]:null}querySelectorAll(e){const i=[];return Ma(this.childrenList,e,i),i}addEventListener(e,i){const n=this.eventListeners.get(e)||new Set;n.add(i),this.eventListeners.set(e,n)}removeEventListener(e,i){const n=this.eventListeners.get(e);n&&(n.delete(i),n.size===0&&this.eventListeners.delete(e))}dispatchEvent(e){const i=this.eventListeners.get(e.type);if(!i||i.size===0)return!0;for(const n of i)typeof n=="function"?n.call(this,e):n.handleEvent(e);return!e.defaultPrevented}serialize(e){typeof this._preSerialize=="function"&&this._preSerialize();const i=e||this._ssrTag||this.tagName,n=Array.from(this.attributes.entries()).map(([b,E])=>` ${b}="${nc(E)}"`).join(""),c=Array.from(this.inlineStyles.entries()).map(([b,E])=>`${b}:${E}`).join(";"),g=c?` style="${nc(c)}"`:"";let m="";return this.shadowRoot&&(m+=this.shadowRoot.serialize()),this.textContent!==null?m+=mi(this.textContent):this._innerHTML?m+=this._innerHTML:m+=this.childrenList.map(b=>typeof b=="string"?mi(b):(b instanceof $n,b.serialize())).join(""),["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"].includes(i)&&!m?`<${i}${n}${g} />`:`<${i}${n}${g}>${m}</${i}>`}},b0=class{host;options;childrenList=[];adoptedStyleSheets=[];constructor(e,i){this.host=e,this.options=i}appendChild(e){return this.childrenList.push(e),e}querySelector(e){const i=this.querySelectorAll(e);return i.length>0?i[0]:null}querySelectorAll(e){const i=[];return Ma(this.childrenList,e,i),i}serialize(){return`<template shadowrootmode="${this.options.mode}"${this.options.delegatesFocus?" shadowrootdelegatesfocus":""}>${this.adoptedStyleSheets.map(e=>`<style>${mi(e)}</style>`).join("")}${this.childrenList.map(e=>typeof e=="string"?mi(e):(e instanceof $n,e.serialize())).join("")}</template>`}},oc=class $g{el;constructor(i){this.el=Br?new eo(i):document.createElement(i)}id(i){return this.el.setAttribute("id",i),this}class(i){return Br?this.el.attributes.set("class",i):this.el.className=i,this}addClass(...i){return i.forEach(n=>this.el.classList.add(n)),this}removeClass(...i){return i.forEach(n=>this.el.classList.remove(n)),this}attr(i,n){return this.el.setAttribute(i,n),this}attrs(i){return Object.entries(i).forEach(([n,c])=>{c!=null&&this.el.setAttribute(n,String(c))}),this}boolAttr(i,n,c=""){return n?this.el.setAttribute(i,c):this.el.removeAttribute(i),this}part(i){return this.el.setAttribute("part",i),this}data(i,n){return this.attr(`data-${i}`,n)}style(i,n){return typeof i=="string"?this.el.style.setProperty(i,n??""):Object.entries(i).forEach(([c,g])=>this.el.style.setProperty(c,g)),this}cssVar(i,n){const c=i.startsWith("--")?i:`--${i}`;return this.style(c,n)}aria(i,n){return this.attr(`aria-${i}`,n)}role(i){return this.attr("role",i)}tabIndex(i){return this.attr("tabindex",String(i))}label(i){return this.aria("label",i)}labelledBy(i){return this.aria("labelledby",i)}describedBy(i){return this.aria("describedby",i)}ariaHidden(i=!0){return this.aria("hidden",String(i))}on(i,n,c){return this.el.addEventListener(i,n,c),this}listen(i,n,c,g){return i.on(this.el,n,c,g),this}delegate(i,n,c,g,m){return i.delegate(this.el,n,c,g,m),this}children(...i){const n=c=>c.reduce((g,m)=>Array.isArray(m)?g.concat(n(m)):g.concat(m),[]);return n(i).forEach(c=>{c!=null&&(c instanceof $g?this.el.appendChild(c.build()):typeof c=="string"?Br?this.el.appendChild(c):this.el.appendChild(document.createTextNode(c)):this.el.appendChild(c))}),this}replaceChildren(...i){if(Br){const n=this.el;n.childrenList=[]}else this.el.replaceChildren();return this.children(...i)}text(i){return this.el.textContent=i,this}ref(i){return i.current=this.el,this}shadow(i={mode:"closed"}){const n=this.el.attachShadow(i);return new y0(this.el,n,i)}build(){return this.el}serialize(){if(Br)return this.el.serialize();const i=document.createElement("div");return i.appendChild(this.el.cloneNode(!0)),i.innerHTML}},y0=class{root;hostEl;options;constructor(e,i,n){this.hostEl=e,this.root=i,this.options=n}children(...e){const i=n=>n.reduce((c,g)=>Array.isArray(g)?c.concat(i(g)):c.concat(g),[]);return i(e).forEach(n=>{n!=null&&(n instanceof oc?this.root.appendChild(n.build()):typeof n=="string"?Br?this.root.appendChild(n):this.root.appendChild(document.createTextNode(n)):this.root.appendChild(n))}),this}adoptSheet(...e){return this.root.adoptedStyleSheets=[...this.root.adoptedStyleSheets,...e],this}css(e){if(Br)return this.root.adoptedStyleSheets.push(e),this;if(typeof CSSStyleSheet<"u")try{const n=new CSSStyleSheet;return n.replaceSync(e),this.root.adoptedStyleSheets=[...this.root.adoptedStyleSheets,n],this}catch{}const i=document.createElement("style");return i.textContent=e,this.root.appendChild(i),this}done(){return{host:this.hostEl,shadow:this.root}}serialize(){return Br?this.root.serialize():this.root.innerHTML}},Ne=e=>new oc(e),K=()=>Ne("div"),Hr=()=>Ne("span"),gt=()=>Ne("slot"),sc=()=>Ne("button"),to=()=>Ne("input"),w0=()=>Ne("style"),C0=()=>Ne("label"),sr=[!1,"false",null,void 0],rt=e=>{const i=e.hasAttribute("disabled"),n=e.getAttribute("disabled");return!!(i&&!sr.includes(n))},lc=new Map;function qe(e,i){Br?(lc.set(e,i),i.prototype._ssrTag=e):customElements.get(e)||customElements.define(e,i)}function E0(){return lc}var cc=()=>typeof document<"u"?HTMLElement:eo,Ve=cc(),k0=e=>{if(e.tagName&&e.tagName!=="div")return e.tagName;const i=E0();for(const[n,c]of i)if(e instanceof c)return n;return e.constructor.name.toLowerCase()},B0=e=>{if(!e)return"";const i=k0(e);return typeof e.serialize=="function"||e instanceof eo?e.serialize(i):""},ro=new Map,io=new Map,I0=(e,i)=>{if(!(typeof document>"u")&&i){if(typeof CSSStyleSheet<"u")try{if(!ro.has(i)){const c=new CSSStyleSheet;c.replaceSync(i),ro.set(i,c)}const n=ro.get(i);e.adoptedStyleSheets.includes(n)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]);return}catch{}if(!e.querySelector("style[data-ranui]")){const n=document.createElement("style");n.setAttribute("data-ranui",""),n.textContent=i,e.appendChild(n)}}},S0=(e,i)=>{if(!(typeof document>"u")&&i){if(typeof CSSStyleSheet<"u")try{if(!io.has(i)){const c=new CSSStyleSheet;c.replaceSync(i),io.set(i,c)}const n=io.get(i);e.adoptedStyleSheets.includes(n)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]);return}catch{}if(!Array.from(e.querySelectorAll("style[data-ranui-sheet]")).some(n=>n.textContent===i)){const n=document.createElement("style");n.setAttribute("data-ranui-sheet",""),n.textContent=i,e.appendChild(n)}}},dc=new WeakMap,hc="@media (prefers-reduced-motion: reduce){*,*::before,*::after{animation-duration:.01ms !important;animation-iteration-count:1 !important;transition-duration:.01ms !important;scroll-behavior:auto !important}}",We=(e,i="",n={mode:"closed"})=>{const c=e.shadowRoot||dc.get(e)||e.attachShadow(n);return dc.set(e,c),I0(c,i?`${i}
2
2
  ${hc}`:hc),c},_e=(e,i,n)=>{const c=e.querySelector(i);if(c)return c;const g=n();return e.appendChild(g),g},Be=(e,i,n="")=>e.getAttribute(i)??n,Le=(e,i,n,c={})=>{if(c.removeEmpty&&!n){e.removeAttribute(i);return}e.setAttribute(i,n??"")},Xe=(e,i,n,c,g)=>{if(n!=="sheet"||c===g)return;const m=e.getAttribute("sheet")||"";m&&S0(i,m)},uc=class extends Ve{_btn;_btnContent;_iconElement;_slot;_shadowDom;_events=new vt;debounceTimeId;static get observedAttributes(){return["disabled","icon","effect","iconSize","type","sheet"]}constructor(){super(),this._shadowDom=We(this,p0);const e=_e(this._shadowDom,".ran-btn",()=>K().class("ran-btn").attr("part","button").role("button").tabIndex(0).children(K().class("ran-btn-content").attr("part","content").children(gt().class("slot"))).build());this._btn=e,this._btnContent=e.querySelector(".ran-btn-content"),this._slot=e.querySelector("slot")}get sheet(){return this.getAttribute("sheet")||""}set sheet(e){this.setAttribute("sheet",e||""),this.handlerExternalCss()}get disabled(){return rt(this)}set disabled(e){!e||e==="false"?(this.removeAttribute("disabled"),this.removeAttribute("aria-disabled")):(this.setAttribute("disabled",""),this.setAttribute("aria-disabled","true"))}get iconSize(){return this.getAttribute("iconSize")||""}set iconSize(e){!e||e==="false"?this.removeAttribute("iconSize"):(this.setAttribute("iconSize",e),this.setIcon())}get icon(){return this.getAttribute("icon")||""}set icon(e){!e||e==="false"?this.removeAttribute("icon"):(this.setAttribute("icon",e),this.setIcon())}get effect(){return this.getAttribute("effect")||""}set effect(e){sr.includes(e)||!e?this.removeAttribute("effect"):this.setAttribute("effect",e)}get type(){return this.getAttribute("type")||""}set type(e){e?this.setAttribute("type",e):this.removeAttribute("type")}setIcon=()=>{if(typeof document>"u"||!this._slot)return;const e=this.icon;if(!e){this._iconElement&&(this._iconElement.remove(),this._iconElement=void 0);return}if(this._iconElement)this._iconElement.setAttribute("name",e);else{let m=this._shadowDom.querySelector("r-icon");m||(m=Ne("r-icon").attr("color","currentColor").class("icon").build(),this._slot.insertAdjacentElement("beforebegin",m)),this._iconElement=m,this._iconElement.setAttribute("name",e)}const{width:i,height:n}=this._slot.getBoundingClientRect(),c=Math.min(i,n)||16,g=this.iconSize||`${c>5?c-5:c}`;this._iconElement.setAttribute("size",String(g))};mousedown=e=>{if(ec()==="pc"&&!this.disabled){this.debounceMouseEvent();const{left:i,top:n}=this.getBoundingClientRect();this._btn.style.setProperty("--ran-x",`${e.clientX-i}px`),this._btn.style.setProperty("--ran-y",`${e.clientY-n}px`)}};mouseup=()=>{ec()==="pc"&&(this.debounceTimeId||(this.debounceTimeId=setTimeout(()=>{this._btn.style.removeProperty("--ran-x"),this._btn.style.removeProperty("--ran-y"),this.debounceMouseEvent()},600)))};keydown=e=>{rt(this)||(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.click())};debounceMouseEvent=()=>{this.debounceTimeId&&(clearTimeout(this.debounceTimeId),this.debounceTimeId=void 0)};handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};syncA11yState=()=>{const e=rt(this);this._btn.setAttribute("aria-disabled",e?"true":"false"),this._btn.tabIndex=e?-1:0,e?(this.setAttribute("aria-disabled","true"),this._btnContent.setAttribute("disabled","true")):(this.removeAttribute("aria-disabled"),this._btnContent.removeAttribute("disabled"))};connectedCallback(){this.handlerExternalCss(),this.setIcon(),this.syncA11yState(),this._events.on(this._btn,"mousedown",this.mousedown).on(this._btn,"mouseup",this.mouseup).on(this._btn,"keydown",this.keydown)}disconnectedCallback(){this.debounceMouseEvent(),this._events.abort()}attributeChangedCallback(e,i,n){i!==n&&(e==="disabled"&&this._btnContent&&this.syncA11yState(),(e==="icon"||e==="iconSize")&&this.setIcon(),e==="sheet"&&this.handlerExternalCss())}};qe("r-button",uc);var x0=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:var(--ran-icon-host-display, inline-flex)}:host([spin]){animation-name:var(--ran-icon-host-spin-animation-name, rotate);animation-duration:var(--ran-icon-host-spin-animation-name, 1.4s);animation-timing-function:linear;animation-iteration-count:var(--ran-icon-host-spin-animation-name, infinite)}.ran-icon{display:var(--ran-icon-display, flex);align-items:var(--ran-icon-align-items, center);justify-content:var(--ran-icon-justify-content, center);color:var(--ran-icon-color, inherit);font-size:var(--ran-icon-font-size, 1em);margin:var(--ran-icon-margin, 0)}.ran-icon svg{width:var(--ran-icon-svg-width, 1em);height:var(--ran-icon-svg-height, 1em);fill:var(--ran-icon-svg-fill, currentColor);stroke:var(--ran-icon-svg-stroke, currentColor)}@keyframes rotate{to{transform:var(--ran-icon-keyframes-to-transform, rotate(360deg))}}",T0=!1,gc=new Map,ao=!1,zi=e=>/<svg[\s>]/i.test(e),D0=e=>{if(typeof e=="string")return zi(e)?e:void 0;if(!e||typeof e!="object")return;const i=e,n=i.data;if(typeof n=="string"&&zi(n))return n;const c=i.default;if(typeof c=="string"&&zi(c))return c;if(c&&typeof c=="object"){const g=c;if(typeof g.data=="string"&&zi(g.data))return g.data}},no=(e,i)=>{ao=!0;const n=D0(i);n&&(gc.set(`inline:${e}`,n),typeof window<"u"&&window.dispatchEvent(new CustomEvent("ranui-icon-registered",{detail:{name:e}})))},fc=e=>{ao=!0,Object.entries(e).forEach(([i,n])=>{no(i,n)})},pc=class extends Ve{isDev=T0;_events=new vt;static get observedAttributes(){return["name","size","color","spin","decorative","aria-label","sheet"]}_icon;_div;_shadowDom;_onIconRegistered=e=>{const i=e.detail?.name;i&&i===this.name&&!this._icon&&this.setIcon()};constructor(){super(),this._shadowDom=We(this,x0);const e=_e(this._shadowDom,".ran-icon",()=>K().class("ran-icon").part("ran-icon").build());this._div=e}get name(){return Be(this,"name")}set name(e){e&&this.setAttribute("name",e)}get size(){return Be(this,"size")}set size(e){e&&this.setAttribute("size",e)}get color(){return Be(this,"color")}set color(e){e&&this.setAttribute("color",e)}get spin(){return this.hasAttribute("spin")}set spin(e){e?this.setAttribute("spin",""):this.removeAttribute("spin")}get decorative(){const e=this.getAttribute("decorative");return e==null?!this.hasAttribute("aria-label"):e!=="false"&&e!=="0"}set decorative(e){this.setAttribute("decorative",e?"true":"false")}get ariaLabel(){return Be(this,"aria-label")}set ariaLabel(e){Le(this,"aria-label",e,{removeEmpty:!0})}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};syncA11y=()=>{if(this._icon){if(this.decorative){this.setAttribute("aria-hidden","true"),this.removeAttribute("role"),this._icon.setAttribute("aria-hidden","true"),this._icon.setAttribute("focusable","false");return}this.removeAttribute("aria-hidden"),this.setAttribute("role","img"),this._icon.removeAttribute("aria-hidden"),this._icon.setAttribute("focusable","false")}};setIcon=()=>{if(typeof document>"u")return;this._icon&&(this._icon.remove(),this._icon=void 0);const e=this.name;if(e)if(e.startsWith("<svg"))this.renderSvg(e,e);else try{const i=`inline:${e}`,n=gc.get(i);if(!n){this.isDev&&ao&&console.warn(`[ranui-icon] icon not registered: ${e}`);return}n&&this.isSvgText(n)?this.renderSvg(n,e):this.isDev&&console.warn(`[ranui-icon] invalid svg text: ${e}`)}catch(i){this.isDev&&console.warn(`[ranui-icon] render icon failed: ${e}`,i)}};isSvgText=e=>zi(e);parseSvg=e=>{const i=new window.DOMParser().parseFromString(e,"image/svg+xml").documentElement;if(!i||i.tagName.toLowerCase()==="parsererror"||i.tagName.toLowerCase()!=="svg")return;const n=new XMLSerializer().serializeToString(i),c=Ne("template").build();c.innerHTML=n.trim();const g=c.content.firstElementChild;if(!(!g||g.tagName.toLowerCase()!=="svg"))return g};renderSvg=(e,i)=>{const n=this.parseSvg(e);n?(this._icon=n,this._icon.setAttribute("part","icon-svg"),this._icon.setAttribute("data-name",i),this._div.appendChild(this._icon),this.setSize(),this.setColor(),this.setSpin(),this.syncA11y()):this.isDev&&console.warn(`[ranui-icon] parse svg failed: ${i}`)};setSize=()=>{if(this._icon){const e=this.size||"1em";this._icon.setAttribute("width",e),this._icon.setAttribute("height",e);const i=/^\d+(\.\d+)?$/.test(e)?`${e}px`:e;this._icon.style.setProperty("width",i),this._icon.style.setProperty("height",i)}};setColor=()=>{if(this._icon){const e=this.color||"currentColor";this._icon.style.setProperty("color",e),this._icon.style.setProperty("fill",e),this._icon.style.setProperty("stroke",e)}};setSpin=()=>{this.spin?this._div.classList.add("ran-icon-spin"):this._div.classList.remove("ran-icon-spin")};connectedCallback(){this._events.on(window,"ranui-icon-registered",this._onIconRegistered),this.handlerExternalCss(),this.setIcon()}disconnectedCallback(){this._events.abort()}attributeChangedCallback(e,i,n){i!==n&&(e==="name"&&this.setIcon(),e==="size"&&this.setSize(),e==="color"&&this.setColor(),e==="spin"&&this.setSpin(),(e==="decorative"||e==="aria-label")&&this.syncA11y(),e==="sheet"&&this.handlerExternalCss())}};qe("r-icon",pc);var R0=`
3
3
  data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWBSGcbGzM6GCKqlIBRV0dHRJFarQ0eUT8LH4BnRU0NHR0UEFVdIlFRV7TzRksomPY8uykTk/zewQfKw/9znv4yvJynLv4uLiV2dBoDiBf4qP3/ARuCRABEFAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghggQAQZQKAnYEaQBAQaASKIAQJEkAEEegJmBElAoBEgghgg0Aj8i0JO4OzsrPv69Wv+hi2qPHr0qNvf39+iI97soRIh4f3z58/u7du3SXX7Xt7Z2enevHmzfQe+oSN2apSAPj09TSrb+XKI/f379+08+A0cNRE2ANkupk+ACNPvkSPcAAEibACyXUyfABGm3yNHuAECRNgAZLuYPgEirKlHu7u7XdyytGwHAd8jjNyng4OD7vnz51dbPT8/7z58+NB9+/bt6jU/TI+AGWHEnrx48eJ/EsSmHzx40L18+fLyzxF3ZVMjEyDCiEDjMYZZS5wiPXnyZFbJaxMhQIQRGzHvWR7XCyOCXsOmiDAi1HmPMMQjDpbpEiDCiL358eNHurW/5SnWdIBbXiDCiA38/Pnzrce2YyZ4//59F3ePLNMl4PbpiL2J0L979+7yDtHDhw8vtzzvdGnEXdvUigSIsCLAWavHp/+qM0BcXMd/q25n1vF57TYBp0a3mUzilePj4+7k5KSLb6gt6ydAhPUzXnoPR0dHl79WGTNCfBnn1uvSCJdegQhLI1vvCk+fPu2ePXt2tZOYEV6/fn31dz+shwAR1sP1cqvLntbEN9MxA9xcYjsxS1jWR4AIa2Ibzx0tc44fYX/16lV6NDFLXH+YL32jwiACRBiEbf5KcXoTIsQSpzXx4N28Ja4BQoK7rgXiydbHjx/P25TaQAJEGAguWy0+2Q8PD6/Ki4R8EVl+bzBOnZY95fq9rj9zAkTI2SxdidBHqG9+skdw43borCXO/ZcJdraPWdv22uIEiLA4q7nvvCug8WTqzQveOH26fodo7g6uFe/a17W3+nFBAkRYENRdb1vkkz1CH9cPsVy/jrhr27PqMYvENYNlHAIesRiBYwRy0V+8iXP8+/fvX11Mr7L7ECueb/r48eMqm7FuI2BGWDEG8cm+7G3NEOfmdcTQw4h9/55lhm7DekRYKQPZF2ArbXTAyu4kDYB2YxUzwg0gi/41ztHnfQG26HbGel/crVrm7tNY+/1btkOEAZ2M05r4FB7r9GbAIdxaZYrHdOsgJ/wCEQY0J74TmOKnbxxT9n3FgGGWWsVdowHtjt9Nnvf7yQM2aZU/TIAIAxrw6dOnAWtZZcoEnBpNuTuObWMEiLAx1HY0ZQJEmHJ3HNvGCBBhY6jtaMoEiJB0Z29vL6ls58vxPcO8/zfrdo5qvKO+d3Fx8Wu8zf1dW4p/cPzLly/dtv9Ts/EbcvGAHhHyfBIhZ6NSiIBTo0LNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg==
4
- `,L0=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}",mc=class extends Ve{static get observedAttributes(){return["src","fallback","sheet","alt"]}_image;_container;_shadowDom;constructor(){super(),this._shadowDom=We(this,L0);const e=_e(this._shadowDom,".ran-image",()=>K().class("ran-image").build());this._container=e}get fallback(){return Be(this,"fallback",R0)}set fallback(e){Le(this,"fallback",e,{removeEmpty:!0})}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}get alt(){return Be(this,"alt")}set alt(e){Le(this,"alt",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};listenFallback(e,i){e==="fallback"&&this._image&&(i?this._image.setAttribute("fallback",i):this._image.removeAttribute("fallback"))}updateSrc=()=>{this._image&&(this._image.src=this.getAttribute("src")||"")};connectedCallback(){this.handlerExternalCss(),this._image=new Image,this._image.alt=this.alt,this._image.addEventListener("error",()=>{this._image&&this.fallback&&(this._image.src=this.fallback)}),this._image.addEventListener("load",()=>{this._image&&this._container.appendChild(this._image)}),this.updateSrc()}attributeChangedCallback(e,i,n){i!==n&&(this.listenFallback(e,n),e==="src"&&this.updateSrc(),e==="alt"&&this._image&&(this._image.alt=n??""),e==="sheet"&&this.handlerExternalCss())}};qe("r-img",mc);var M0=`.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{position:var(--ran-input-host-position, relative);display:var(--ran-input-host-display, block);box-sizing:var(--ran-input-host-box-sizing, border-box)}:host([placeholder]) .ran-input-label{transform:var(--ran-input-label-placeholder-transform, translateY( calc(-50% - .43em) ) scale(.8));top:var(--ran-input-label-placeholder-top, 0)}:host .ran-input-label{transform:var(--ran-input-label-transform, translateY(-50%));top:var(--ran-input-label-top, 50%)}.ran-input{box-sizing:var(--ran-input-box-sizing, border-box);position:var(--ran-input-position, relative);display:var(--ran-input-display, flex);width:var(--ran-input-width, 100%);height:var(--ran-input-height, auto);min-width:var(--ran-input-min-width, 0);padding:var(--ran-input-padding, 0px 0px 0px 4px);color:var(--ran-input-color, var(--ran-color-text, #000000d9));font-size:var(--ran-input-font-size, 12px);font-family:var(--ran-input-font-family, var(--ran-skin-font-family, inherit));line-height:var(--ran-input-line-height, 1.5715);background-color:var(--ran-input-background-color, var(--ran-color-bg-elevated, #fff));background-image:var(--ran-input-background-image, none);border:var(--ran-input-border, 1px solid var(--ran-color-border, #eaeaea));border-image-source:var(--ran-input-border-image-source, none);border-image-slice:var(--ran-input-border-image-slice, 8);border-image-width:var(--ran-input-border-image-width, 4px);border-image-outset:0;border-image-repeat:stretch;border-radius:var(--ran-input-border-radius, var(--ran-radius-sm, 6px));transition:var(--ran-input-transition, none);min-height:var(--ran-input-min-height, 32px)}.ran-input .ran-icon{display:var(--ran-input-icon-display, flex);align-items:var(--ran-input-icon-align-items, center);justify-content:var(--ran-input-icon-justify-content, center)}.ran-input:focus-within{border-color:var(--ran-input-active-border-color, var(--ran-color-primary, #006bff));box-shadow:var(--ran-input-active-box-shadow, 0 0 0 2px var(--ran-blue-400, #cae7ff));border-right-width:var(--ran-input-active-border-right-width, 1px);outline:var(--ran-input-active-outline, 0)}.ran-input:hover{border-color:var(--ran-input-hover-border-color, var(--ran-color-primary, #006bff));border-right-width:var(--ran-input-hover-border-right-width, 1px)}.ran-input>.ran-input-content:hover~.ran-input-label{color:var(--ran-input-label-hover-color, var(--ran-color-primary, #006bff))}.ran-input[value]>.ran-input-label{transform:var(--ran-input-label-value-transform, translateY( calc(-50% - .43em) ) scale(.8));color:var(--ran-input-label-value-color, var(--ran-color-text-disabled, #00000040))}.ran-input[status=error] .ran-input-content,.ran-input[status=warning] .ran-input-content{padding-right:var(--ran-input-content-status-padding-right, 28px)}.ran-input[status=error]:after,.ran-input[status=warning]:after{content:"";position:absolute;top:50%;right:10px;width:16px;height:16px;transform:translateY(-50%);pointer-events:none;mask-position:center;mask-repeat:no-repeat;mask-size:contain;-webkit-mask-position:center;-webkit-mask-repeat:no-repeat;-webkit-mask-size:contain}.ran-input[status=error]{border-color:var(--ran-input-status-error-border-color, var(--ran-color-danger, #ff4d4f))}.ran-input[status=error]>.ran-input-content~.ran-input-label{color:var(--ran-input-label-status-error-color, var(--ran-color-danger, #ff4d4f))}.ran-input[status=error]:after{background-color:var(--ran-color-danger, #ff4d4f);mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 3.5h1.5v5h-1.5v-5zM8 11a1 1 0 110 2 1 1 0 010-2z'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 3.5h1.5v5h-1.5v-5zM8 11a1 1 0 110 2 1 1 0 010-2z'/%3E%3C/svg%3E")}.ran-input[status=warning]{border-color:var(--ran-input-status-warning-border-color, var(--ran-color-warning, #faad14))}.ran-input[status=warning]>.ran-input-content~.ran-input-label{color:var(--ran-input-label-status-warning-color, var(--ran-color-warning, #faad14))}.ran-input[status=warning]:after{background-color:var(--ran-color-warning, #faad14);mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.5l6.85 11.86a.5.5 0 01-.43.75H1.58a.5.5 0 01-.43-.75L8 1.5zm-.75 4.25v3.5h1.5v-3.5h-1.5zM8 10.75a1 1 0 110 2 1 1 0 010-2z'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.5l6.85 11.86a.5.5 0 01-.43.75H1.58a.5.5 0 01-.43-.75L8 1.5zm-.75 4.25v3.5h1.5v-3.5h-1.5zM8 10.75a1 1 0 110 2 1 1 0 010-2z'/%3E%3C/svg%3E")}.ran-input[disabled]{color:var(--ran-input-disabled-color, var(--ran-color-text-disabled, #00000040));background-color:var(--ran-input-disabled-background-color, var(--ran-color-bg-muted, #f5f5f5));border-color:var(--ran-input-disabled-border-color, var(--ran-color-border, #eaeaea));box-shadow:var(--ran-input-disabled-box-shadow, none);cursor:var(--ran-input-disabled-cursor, not-allowed);opacity:var(--ran-input-disabled-opacity, 1)}.ran-input[disabled]>.ran-input-content{color:var(--ran-input-content-disabled-color, var(--ran-color-text-disabled, #00000040));background-color:var(--ran-input-content-disabled-background-color, var(--ran-color-bg-muted, #f5f5f5));border-color:var(--ran-input-content-disabled-border-color, var(--ran-color-border, #eaeaea));box-shadow:var(--ran-input-content-disabled-box-shadow, none);cursor:var(--ran-input-content-disabled-cursor, not-allowed);opacity:var(--ran-input-content-disabled-opacity, 1)}.ran-input[disabled]>.ran-input-content~.ran-input-label{color:var(--ran-input-label-disabled-color, var(--ran-color-text-disabled, #00000040));background-color:var(--ran-input-label-disabled-background-color, var(--ran-color-bg-muted, #f5f5f5))}.ran-input[disabled]>.ran-input-label{color:var(--ran-input-label-disabled-color, var(--ran-color-text-disabled, #999));border-color:var(--ran-input-label-disabled-border-color, var(--ran-color-border, #eaeaea));box-shadow:var(--ran-input-label-disabled-box-shadow, none);cursor:var(--ran-input-label-disabled-cursor, not-allowed)}.ran-input-content{writing-mode:var(--ran-input-content-writing-mode, horizontal-tb);text-rendering:var(--ran-input-content-text-rendering, auto);letter-spacing:var(--ran-input-content-letter-spacing, normal);word-spacing:var(--ran-input-content-word-spacing, normal);text-transform:var(--ran-input-content-text-transform, none);text-indent:var(--ran-input-content-text-indent, 0px);text-shadow:var(--ran-input-content-text-shadow, none);text-align:var(--ran-input-content-text-align, start);cursor:var(--ran-input-content-cursor, text);touch-action:var(--ran-input-content-touch-action, manipulation);-webkit-appearance:var(--ran-input-content--webkit-appearance, none);text-overflow:var(--ran-input-content-text-overflow, ellipsis);box-sizing:var(--ran-input-content-box-sizing, border-box);margin:var(--ran-input-content-margin, 0);font-variant:var(--ran-input-content-font-variant, tabular-nums);list-style:var(--ran-input-content-list-style, none);font-feature-settings:var(--ran-input-content-font-feature-settings, "tnum");position:var(--ran-input-content-position, relative);border:var(--ran-input-content-border, none);width:var(--ran-input-content-width, 100%);height:var(--ran-input-content-height, 100%);min-height:var(--ran-input-content-min-height, 30px);min-width:var(--ran-input-content-min-width, 0);color:var(--ran-input-content-color, var(--ran-color-text, #000000d9));font-size:var(--ran-input-content-font-size, 14px);line-height:var(--ran-input-content-line-height, 1.48);background-color:var(--ran-input-content-background-color, var(--ran-color-bg-elevated, #fff));background-image:var(--ran-input-content-background-image, none);transition:var(--ran-input-content-transition, none);outline:var(--ran-input-content-outline, none);border-radius:var(--ran-input-content-border-radius, var(--ran-radius-sm, 6px));padding:var(--ran-input-content-padding, 0 0 0 2px);font-weight:var(--ran-input-content-font-weight, 400)}.ran-input-content:focus,.ran-input-content:hover{border:var(--ran-input-content-hover-border, none);outline:var(--ran-input-content-hover-outline, 0)}.ran-input-content::placeholder{color:var(--ran-input-content-placeholder-color, var(--ran-color-text-disabled, #999))}.ran-input-content:placeholder-shown~.ran-input-label{transform:var(--ran-input-content-placeholder-label-transform, translateY( calc(-50% - .43em) ) scale(.8))}.ran-input-content:focus~.ran-input-label{transform:var(--ran-input-content-focus-label-transform, translateY( calc(-50% - .43em) ) scale(.8));top:var(--ran-input-content-focus-label-top, 0px)}.ran-input-content::-webkit-search-cancel-button{display:none;-webkit-appearance:none}.ran-input-label{box-sizing:var(--ran-input-label-box-sizing, border-box);pointer-events:var(--ran-input-label-pointer-events, none);position:var(--ran-input-label-position, absolute);font-size:var(--ran-input-label-font-size, 14px);left:var(--ran-input-label-left, 8px);transition:var(--ran-input-label-transition, transform .3s, top .3s, font-size .3s);transform-origin:var(--ran-input-label-transform-origin, left);padding:var(--ran-input-label-padding, 0 0);color:var(--ran-input-label-color, var(--ran-color-text-disabled, #999));background:var(--ran-input-label-background, var(--ran-color-bg-elevated, #fff));opacity:var(--ran-input-label-opacity, .9)}.ran-input-message{margin-top:var(--ran-input-message-margin-top, 4px);font-size:var(--ran-input-message-font-size, 12px);line-height:var(--ran-input-message-line-height, 1.5);color:var(--ran-input-message-color, var(--ran-color-text-secondary, #8c8c8c))}.ran-input-message:empty{display:none}:host([status="error"]) .ran-input-message{color:var(--ran-input-message-error-color, var(--ran-color-danger, #ff4d4f))}:host([status="warning"]) .ran-input-message{color:var(--ran-input-message-warning-color, var(--ran-color-warning, #faad14))}`,F0=0,vc=class extends Ve{static formAssociated=!0;_internals;static get observedAttributes(){return["label","disabled","name","placeholder","type","icon","value","status","message","min","max","step","required","sheet"]}_events=new vt;_shadowDom;_input;_label;_inputContent;_icon;_message;constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=void 0}this._shadowDom=We(this,M0);const e=_e(this._shadowDom,".ran-input",()=>K().class("ran-input").part("input").children(to().class("ran-input-content").part("content")).build());this._input=e,this._inputContent=e.querySelector(".ran-input-content"),this._inputContent.id||(this._inputContent.id=`ran-input-${++F0}`)}get value(){return this.getAttribute("value")||""}set value(e){!rt(this)&&e?(this.setAttribute("value",e),this._input.setAttribute("value",e)):(this.removeAttribute("value"),this._input.removeAttribute("value")),this._internals?.setFormValue?.(this.getAttribute("value")??"")}get placeholder(){return this.getAttribute("placeholder")||""}set placeholder(e){e?this.setAttribute("placeholder",e):this.removeAttribute("placeholder")}get required(){return this.hasAttribute("required")}set required(e){!e||e==="false"?this.removeAttribute("required"):this.setAttribute("required","")}get disabled(){return rt(this)}set disabled(e){sr.includes(e)?(this.removeAttribute("disabled"),this._input.removeAttribute("disabled"),this._inputContent.removeAttribute("disabled")):(this.setAttribute("disabled",""),this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled",""))}get label(){return this.getAttribute("label")||""}set label(e){this.setAttribute("label",e)}get status(){return this.getAttribute("status")||""}set status(e){e?(this.setAttribute("status",e),this._input.setAttribute("status",e)):(this.removeAttribute("status"),this._input.removeAttribute("status"))}get message(){return this.getAttribute("message")||""}set message(e){e?this.setAttribute("message",e):this.removeAttribute("message")}get name(){return this.getAttribute("name")||""}set name(e){this.setAttribute("name",e)}get min(){return this.getAttribute("min")||""}set min(e){this.type==="number"&&this.setAttribute("min",e)}get max(){return this.getAttribute("max")||""}set max(e){this.type==="number"&&this.setAttribute("max",e)}get step(){return this.getAttribute("step")||""}set step(e){this.type==="number"&&this.setAttribute("step",e)}get icon(){return this.getAttribute("icon")||""}set icon(e){e?this.setAttribute("icon",e):this.removeAttribute("icon")}get type(){return this.getAttribute("type")||""}set type(e){e?this.setAttribute("type",e):this.removeAttribute("type")}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};customInput=e=>{e.stopPropagation(),e.preventDefault();const{target:i,data:n=""}=e;this.value=i?.value||n||"",this.dispatchEvent(new CustomEvent("input",{detail:{value:this.value}}))};customChange=()=>{this.value=this._inputContent?.value??this.value,this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value}}))};listenPlaceholder=(e,i)=>{e==="placeholder"&&this._inputContent&&(i!=null?this._inputContent.setAttribute("placeholder",i):this._inputContent.removeAttribute("placeholder"))};listenLabel=(e,i)=>{e==="label"&&this._inputContent&&(i!=null?this._label?this._label.innerHTML=i:(this._label=C0().class("ran-input-label").part("label").text(i).build(),this._label.htmlFor=this._inputContent.id,this._input.appendChild(this._label)):(this._input.removeAttribute("label"),this._label&&(this._input.removeChild(this._label),this._label=void 0)))};listenType=(e,i)=>{e==="type"&&this._inputContent&&(i?this._inputContent.setAttribute("type",i):(this._inputContent.removeAttribute("type"),this._inputContent.removeAttribute("min"),this._inputContent.removeAttribute("max"),this._inputContent.removeAttribute("step")))};listenStatus=(e,i)=>{e==="status"&&this._input&&(i?this._input.setAttribute("status",i):this._input.removeAttribute("status"))};listenMessage=(e,i)=>{e==="message"&&(i?(this._message||(this._message=K().class("ran-input-message").part("message").build(),this._shadowDom.appendChild(this._message)),this._message.textContent=i):this._message&&(this._message.remove(),this._message=void 0))};listenNumericConstraint=(e,i)=>{(e==="min"||e==="max"||e==="step")&&this._inputContent&&(this.type==="number"&&i!=null?this._inputContent.setAttribute(e,i):this._inputContent.removeAttribute(e))};listenRequired=(e,i)=>{e==="required"&&this._inputContent&&(i!=null?this._inputContent.setAttribute("required",""):this._inputContent.removeAttribute("required"))};listenDisabled=(e,i)=>{e==="disabled"&&this._input&&(sr.includes(i)?this._input.removeAttribute("disabled"):(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")))};listenIcon=(e,i,n)=>{e==="icon"&&i&&i!==n&&(this.removeAttribute("label"),this.setAttribute("icon",i),this.dealIcon())};dealIcon=()=>{this._icon||(this._icon=Ne("r-icon").class("ran-icon").build(),this._inputContent.insertAdjacentElement("beforebegin",this._icon)),this.icon&&this._icon.setAttribute("name",this.icon)};listenEvent=(e,i,n)=>{this.listenPlaceholder(e,n),this.listenLabel(e,n),this.listenStatus(e,n),this.listenMessage(e,n),this.listenNumericConstraint(e,n),this.listenRequired(e,n),this.listenDisabled(e,n),this.listenIcon(e,n,i),e==="value"&&i!==n&&(this._inputContent.value=n,this._input.setAttribute("value",n))};connectedCallback(){this.handlerExternalCss(),this.value&&(this._inputContent.value=this.value,this._input.setAttribute("value",this.value)),this._internals?.setFormValue?.(this.value),this.status&&this._input.setAttribute("status",this.status),this.message&&this.listenMessage("message",this.message),rt(this)&&(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")),this.type&&this._inputContent.setAttribute("type",this.type),this.type==="number"&&(this.min&&this._inputContent.setAttribute("min",this.min),this.max&&this._inputContent.setAttribute("max",this.max),this.step&&this._inputContent.setAttribute("step",this.step)),this.required&&this._inputContent.setAttribute("required",""),this._events.on(this._inputContent,"input",this.customInput),this._events.on(this._inputContent,"change",this.customChange),document.readyState==="complete"&&this.dealIcon()}disconnectedCallback(){this._events.abort()}attributeChangedCallback(e,i,n){i!==n&&(this.listenEvent(e,i,n),e==="sheet"&&this.handlerExternalCss())}};qe("r-input",vc);var O0='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host([type="toast"]) .ran-message-notice{padding:8px;text-align:center;max-width:90%;margin:0 auto;word-break:break-all}:host([type="toast"]) .ran-message-notice-content{display:inline-block;padding:10px 16px;background:#000000b3;border-radius:7px;pointer-events:all}:host([type="toast"]) .ran-message-notice-content-info{align-items:center;display:flex}:host([type="toast"]) .ran-message-notice-content-info span{margin:0;padding:0;font-size:14px;font-variant:tabular-nums;list-style:none;font-feature-settings:"tnum";z-index:1010;width:100%;pointer-events:none;color:#fff}.ran-message-notice{padding:var(--ran-message-notice-padding, 8px);text-align:var(--ran-message-notice-text-align, center);max-width:var(--ran-message-notice-max-width, 90%);margin:var(--ran-message-notice-margin, 0 auto);word-break:var(--ran-message-notice-word-break, break-all)}.ran-message-notice-content{display:var(--ran-message-notice-content-display, inline-block);padding:var(--ran-message-notice-content-padding, 10px 16px);background:var(--ran-message-notice-content-background, var(--ran-color-bg-elevated, #fff));border-image-source:var(--ran-message-notice-content-border-image-source, none);border-image-slice:var(--ran-message-notice-content-border-image-slice, 8);border-image-width:var(--ran-message-notice-content-border-image-width, 4px);border-image-outset:0;border-image-repeat:stretch;border-radius:var(--ran-message-notice-content-border-radius, var(--ran-radius-md, 12px));box-shadow:var(--ran-message-notice-content-box-shadow, var(--ran-shadow-menu, 0 2px 4px #0000000d, 0 8px 24px -6px #00000024));pointer-events:var(--ran-message-notice-content-pointer-events, all)}.ran-message-notice-content-info{align-items:var(--ran-message-notice-content-info-align-items, center);display:var(--ran-message-notice-content-info-display, flex)}.ran-message-notice-content-info span{margin:var(--ran-message-notice-content-info-span-margin, 0);padding:var(--ran-message-notice-content-info-span-padding, 0);color:var(--ran-message-notice-content-info-span-color, var(--ran-color-text, #000000d9));font-size:var(--ran-message-notice-content-info-span-font-size, 14px);font-variant:var(--ran-message-notice-content-info-span-font-variant, tabular-nums);list-style:var(--ran-message-notice-content-info-span-list-style, none);font-feature-settings:var(--ran-message-notice-content-info-span-font-feature-settings, "tnum");z-index:var(--ran-message-notice-content-info-span-z-index, 1010);width:var(--ran-message-notice-content-info-span-width, 100%);pointer-events:var(--ran-message-notice-content-info-span-pointer-events, none)}@keyframes rotate{to{transform:rotate(360deg)}}@keyframes MessageMoveIn{0%{padding:0;transform:translateY(-100%);opacity:0}to{padding:8px;transform:translateY(0);opacity:1}}@keyframes MessageMoveOut{0%{max-height:150px;padding:8px;opacity:1}to{max-height:0;padding:0;opacity:0}}.ranui-message{box-sizing:var(--ran-message-box-sizing, border-box);margin:var(--ran-message-margin, 0);padding:var(--ran-message-padding, 0);color:var(--ran-message-color, var(--ran-color-text, #000000d9));font-size:var(--ran-message-font-size, 14px);font-variant:var(--ran-message-font-variant, tabular-nums);line-height:var(--ran-message-line-height, 1.5715);list-style:var(--ran-message-ist-style, none);font-feature-settings:var(--ran-message-font-feature-settings, "tnum");position:var(--ran-message-position, fixed);top:var(--ran-message-top, 8px);left:var(--ran-message-left, 0);z-index:var(--ran-message-z-index, var(--ran-z-message, 1200));width:var(--ran-message-width, 100%);pointer-events:var(--ran-message-pointer-events, none)}.ranui-message .message-in{animation-name:var(--ran-message-in-animation-name, MessageMoveIn);animation-duration:var(--ran-message-in-animation-duration, .3s);animation-timing-function:var(--ran-message-in-animation-timing-function, cubic-bezier(.78, .14, .15, .86))}.ranui-message .message-leave{animation-name:var(--ran-message-leave-animation-name, MessageMoveOut);animation-duration:var(--ran-message-leave-animation-duration, .3s);animation-timing-function:var(--ran-message-leave-animation-timing-function, cubic-bezier(.78, .14, .15, .86))}',P0={success:!0,_identification:!0,data:'<svg t="1667965185400" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8572" width="200" height="200"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m193.5 301.7l-210.6 292c-12.7 17.7-39 17.7-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z" p-id="8573"></path></svg>'},U0={success:!0,_identification:!0,data:'<svg t="1667965220951" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8711" width="200" height="200"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m165.4 618.2l-66-0.3L512 563.4l-99.3 118.4-66.1 0.3c-4.4 0-8-3.5-8-8 0-1.9 0.7-3.7 1.9-5.2l130.1-155L340.5 359c-1.2-1.5-1.9-3.3-1.9-5.2 0-4.4 3.6-8 8-8l66.1 0.3L512 464.6l99.3-118.4 66-0.3c4.4 0 8 3.5 8 8 0 1.9-0.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z" p-id="8712"></path></svg>'},Q0={success:!0,_identification:!0,data:'<svg t="1667965239916" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8850" width="200" height="200"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272z m-32-344c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48z" p-id="8851"></path></svg>'},N0={success:!0,_identification:!0,data:'<svg t="1667965273540" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8989" width="200" height="200"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296z m32 440c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48z" p-id="8990"></path></svg>'},Ac="data-ranui-message-host",H0=()=>`[${Ac}="true"]`,G0=(e,i)=>{const n=i?.top??8,c=i?.zIndex??1200;e.style.setProperty("position","fixed"),e.style.setProperty("top",typeof n=="number"?`${n}px`:String(n)),e.style.setProperty("left","0"),e.style.setProperty("width","100%"),e.style.setProperty("z-index",String(c)),e.style.setProperty("pointer-events","none")},Y0=e=>typeof document>"u"?null:e?.getContainer?.()||document.body,K0=e=>{if(typeof document>"u")return null;const i=Y0(e)||document.body;let n=i.querySelector(H0());return n||(n=K().attr(Ac,"true").children(K().class("ranui-message").attr("aria-live","polite").attr("aria-atomic","false")).build(),i.appendChild(n)),G0(n,e),n.querySelector(".ranui-message")},bc=300,yc=3e3;fc({"check-circle-fill":P0,"close-circle-fill":U0,"info-circle-fill":Q0,"warning-circle-fill":N0});var z0=new Map([["success","check-circle-fill"],["warning","warning-circle-fill"],["error","close-circle-fill"],["info","info-circle-fill"],["toast",null]]),q0=new Map([["success","#52c41a"],["warning","#faad14"],["error","#ff4d4f"],["info","#006bff"],["toast","rgba(0, 0, 0, 0.7)"]]),wc=class extends Ve{_info;_notice;_content;_icon;_span;_shadowDom;timeId;close;static get observedAttributes(){return["type","content","sheet"]}constructor(){super(),this._shadowDom=We(this,O0);const e=_e(this._shadowDom,".ran-message-notice",()=>K().class("ran-message-notice").children(K().class("ran-message-notice-content").children(K().class("ran-message-notice-content-info").children(Ne("r-icon"),Hr()))).build());this._notice=e,this._content=e.querySelector(".ran-message-notice-content"),this._info=e.querySelector(".ran-message-notice-content-info"),this._icon=e.querySelector("r-icon"),this._span=e.querySelector("span"),this.handlerExternalCss()}connectedCallback(){Ve.prototype.connectedCallback?.call(this),this.hasAttribute("aria-atomic")||this.setAttribute("aria-atomic","true")}get type(){return this.getAttribute("type")}set type(e){e&&this.setAttribute("type",e)}get content(){return this.getAttribute("content")}set content(e){e&&this.setAttribute("content",e)}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};setA11yRole=e=>{const i=e==="error"||e==="warning";this.setAttribute("role",i?"alert":"status")};setIcon=e=>{const i=z0.get(e),n=q0.get(e);i&&(this._icon?.setAttribute("name",i),this._icon?.style.setProperty("margin-right","8px"),this._icon?.setAttribute("size","18"),n&&this._icon?.setAttribute("color",n))};attributeChangedCallback(e,i,n){i!==n&&(e==="content"&&(this._span.textContent=n),e==="type"&&(this.setIcon(n),this.setA11yRole(n)),e==="sheet"&&this.handlerExternalCss())}};qe("r-message",wc);function V0(){if(typeof window>"u")return null;const e=n=>c=>{const g={},m=Ne("r-message").class("message").build();m.timeId&&clearTimeout(m.timeId),m.setAttribute("type",n);let b=yc,E;if(!c)return;typeof c=="string"?m.setAttribute("content",c):(m.setAttribute("content",c.content),E=c.close,b=c.duration||yc,g.top=c.top,g.zIndex=c.zIndex,g.getContainer=c.getContainer);const R=K0(g);if(!R)return;const F=setTimeout(()=>{m.classList.remove("message-in"),m.classList.add("message-leave"),clearTimeout(F)},b-bc);m.timeId=setTimeout(()=>{m.classList.remove("message-leave"),R.removeChild(m),E&&E()},b),R.appendChild(m),m.classList.add("message-in"),setTimeout(()=>{m.classList.remove("message-in")},bc)},i={info:e("info"),success:e("success"),error:e("error"),warning:e("warning"),toast:e("toast")};return window.message=i,window.ranui||(window.ranui={}),window.ranui.message=i,i}var H1=V0(),W0='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}@keyframes skeleton{0%{transform:translate(-37.5%)}to{transform:translate(37.5%)}}.ran-skeleton{position:relative;z-index:0;overflow:hidden;background:0 0;width:100%;height:var(--ran-skeleton-height, 16px);background:var(--ran-skeleton-background, var(--ran-gray-alpha-200, rgba(0, 0, 0, .06)));border-radius:var(--ran-skeleton-border-radius, var(--ran-radius-sm, 6px))}.ran-skeleton:after{position:absolute;top:0;inset-inline-end:-150%;bottom:0;inset-inline-start:-150%;background:var(--ran-skeleton-shimmer, linear-gradient(90deg, var(--ran-gray-alpha-200, rgba(0, 0, 0, .06)) 25%, var(--ran-gray-alpha-500, rgba(0, 0, 0, .15)) 37%, var(--ran-gray-alpha-200, rgba(0, 0, 0, .06)) 63%));animation-name:skeleton;animation-duration:var(--ran-skeleton-animation-duration, 1.4s);animation-timing-function:ease;animation-iteration-count:infinite;content:""}',Cc=class extends Ve{_div;_shadowDom;static get observedAttributes(){return["sheet"]}constructor(){super(),this._shadowDom=We(this,W0),this._div=_e(this._shadowDom,".ran-skeleton",()=>K().class("ran-skeleton").build())}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};connectedCallback(){this.handlerExternalCss()}attributeChangedCallback(e,i,n){i!==n&&e==="sheet"&&this.handlerExternalCss()}};qe("r-skeleton",Cc);var X0=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}",Ec=class extends Ve{static get observedAttributes(){return["label","key","disabled","icon","effect","iconSize","sheet"]}_events=new vt;_div;parent;_shadowDom;constructor(){super(),this._shadowDom=We(this,X0);const e=_e(this._shadowDom,"slot",()=>gt().part("content").build());this._div=e}get label(){return this.getAttribute("label")||""}set label(e){this.setAttribute("label",e)}get icon(){return this.getAttribute("icon")}set icon(e){!e||e==="false"?this.removeAttribute("icon"):this.setAttribute("icon",e)}get iconSize(){return this.getAttribute("iconSize")}set iconSize(e){!e||e==="false"?this.removeAttribute("iconSize"):this.setAttribute("iconSize",e)}get key(){return this.getAttribute("r-key")}set key(e){e?this.setAttribute("r-key",e):this.removeAttribute("r-key")}get disabled(){return this.getAttribute("disabled")}set disabled(e){!e||e==="false"?this.removeAttribute("disabled"):this.setAttribute("disabled",e)}get effect(){return this.getAttribute("effect")}set effect(e){!e||e==="false"?this.removeAttribute("effect"):this.setAttribute("effect",e)}get sheet(){return this.getAttribute("sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};initAttribute=()=>{this.parent=this.parentNode,this.key&&(this.parent?.updateAttribute(this.key,"icon",this.icon),this.parent?.updateAttribute(this.key,"iconSize",this.iconSize),this.parent?.updateAttribute(this.key,"effect",this.effect))};connectedCallback(){this.handlerExternalCss(),this._events.on(document,"DOMContentLoaded",this.initAttribute)}disconnectedCallback(){this._events.abort()}attributeChangedCallback(e,i,n){i!==n&&(this.key&&this.parent?.updateAttribute&&(e==="icon"&&this.parent?.updateAttribute(this.key,"icon",n),e==="iconSize"&&this.parent?.updateAttribute(this.key,"iconSize",n),e==="effect"&&this.parent?.updateAttribute(this.key,"effect",n),e==="disabled"&&this.parent?.updateAttribute(this.key,"disabled",n)),e==="sheet"&&this.handlerExternalCss())}};qe("r-tab",Ec);var J0='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-tab ::slotted(r-tab){box-sizing:border-box;width:100%;height:100%;padding:10px;flex-shrink:0;overflow:auto;text-align:start}.ran-tab-header{position:relative;overflow:hidden;scroll-behavior:smooth}.ran-tab-header-nav{display:flex;flex-flow:row nowrap;justify-content:flex-start;align-items:center}.ran-tab-header-nav::-webkit-scrollbar{display:none}.ran-tab-header-nav-item{flex-shrink:0}.ran-tab-header-nav .active{color:var(--ran-tab-active-color, var(--ran-color-primary, #006bff))}.ran-tab-header-line{position:absolute;width:0;margin-top:-2px;height:2px;border-radius:2px;background:var(--ran-tab-line-color, var(--ran-color-primary, #006bff));transition:var(--ran-tab-line-transition, left .2s, width .2s, transform .2s)}.ran-tab-content{overflow:hidden}.ran-tab-content-wrap{display:flex;width:100%;height:100%;transition:var(--ran-tab-content-transition, transform .2s)}:host([type="line"]) .ran-tab-header-nav-item{border:solid 1px transparent}:host([type="line"]) .ran-tab-header-nav .active{color:var(--ran-tab-line-color, var(--ran-color-primary, #006bff));border:solid 1px transparent;border-color:var(--ran-tab-border-color, var(--ran-color-border, rgba(0, 0, 0, .2))) var(--ran-tab-border-color, var(--ran-color-border, rgba(0, 0, 0, .2))) transparent;border-radius:var(--ran-tab-border-radius, var(--ran-radius-sm, .25em)) var(--ran-tab-border-radius, var(--ran-radius-sm, .25em)) 0 0}:host([type="line"]) .ran-tab-header-line{transition:none;visibility:hidden}:host([type="line"]) .ran-tab-header-line:after,:host([type="line"]) .ran-tab-header-line:before{content:"";position:absolute;visibility:visible;width:9999px;height:1px;bottom:0;background:var(--ran-tab-border-color, var(--ran-color-border, rgba(0, 0, 0, .2)))}:host([type="line"]) .ran-tab-header-line:after{left:100%}:host([type="line"]) .ran-tab-header-line:before{right:100%}:host([align="center"]) .ran-tab-header-nav{justify-content:center}:host([align="center"]) .ran-tab-header-line{left:50%}:host([align="end"]) .ran-tab-header-nav{justify-content:flex-end}',_0=0,kc=class extends Ve{static get observedAttributes(){return["active","type","align","effect","sheet"]}_events=new vt;_container;_header;_nav;_line;_content;_wrap;_slot;_shadowDom;_tabsId;tabHeaderKeyMapIndex;constructor(){super(),this._tabsId=++_0,this._shadowDom=We(this,J0),this.tabHeaderKeyMapIndex={};const e=_e(this._shadowDom,".ran-tab",()=>K().class("ran-tab").part("tabs").children(K().class("ran-tab-header").part("header").children(K().class("ran-tab-header-nav").part("nav"),K().class("ran-tab-header-line").part("indicator")),K().class("ran-tab-content").part("content").children(K().class("ran-tab-content-wrap").part("content-wrap").children(gt()))).build());this._container=e,this._header=e.querySelector(".ran-tab-header"),this._nav=e.querySelector(".ran-tab-header-nav"),this._line=e.querySelector(".ran-tab-header-line"),this._content=e.querySelector(".ran-tab-content"),this._wrap=e.querySelector(".ran-tab-content-wrap"),this._slot=e.querySelector("slot"),this._nav.setAttribute("role","tablist")}get align(){return Be(this,"align","start")}set align(e){this.setAttribute("align",e)}get type(){return Be(this,"type","flat")}set type(e){this.setAttribute("type",e)}get active(){return this.getAttribute("active")}set active(e){e?(this.setAttribute("active",e),this.setTabLine(e),this.setTabContent(e),this.syncTabsAria()):this.removeAttribute("active")}get effect(){return this.getAttribute("effect")}set effect(e){!e||e==="false"?this.removeAttribute("effect"):this.setAttribute("effect",e)}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};initTabHeaderKeyMapIndex=(e,i)=>{if(this.tabHeaderKeyMapIndex[e])throw new Error("tab 组件的 key 值存在重复,或者某个 tab 组件缺少 key 属性");this.tabHeaderKeyMapIndex[e]=i};createTabHeader(e,i){const n=e.getAttribute("label")||"",c=e.getAttribute("icon")||"",g=e.getAttribute("iconSize")||"",m=e.getAttribute("r-key")||`${i}`,b=e.getAttribute("type")||"text";this.initTabHeaderKeyMapIndex(m,i);const E=Ne("r-button").class("tab-header-nav-item").attr("type",b).attr("r-key",m).text(n);return c&&E.attr("icon",c),g&&E.attr("iconSize",g),rt(e)&&E.attr("disabled",""),this.effect&&(e.setAttribute("effect",this.effect),this._line.style.setProperty("display","none")),e.setAttribute("r-key",m),E.build()}initTabLineAlignCenter=()=>{const{length:e}=this._nav.children;let i=0;for(let n=0;n<e;n++){const{width:c=0}=this._nav.children[n].getBoundingClientRect();i+=c}this._line.style.setProperty("left",`calc(50% - ${i/2}px)`)};initTabLineAlignEnd=()=>{const{length:e}=this._nav.children;let i=0;for(let n=0;n<e;n++){const{width:c=0}=this._nav.children[n].getBoundingClientRect();i+=c}this._line.style.setProperty("left",`calc(100% - ${i}px)`)};setTabLine=e=>{if(e){const i=this.tabHeaderKeyMapIndex[e],{width:n=0}=this._nav.children[i].getBoundingClientRect();this._line.style.setProperty("width",`${n}px`);let c=0;for(let g=0;g<i;g++){const{width:m=0}=this._nav.children[g].getBoundingClientRect();c+=m}this._line.style.setProperty("transform",`translateX(${c}px)`)}};setTabContent=e=>{if(e){const i=this.tabHeaderKeyMapIndex[e];this._wrap.style.setProperty("transform",`translateX(${i*-100}%)`)}};clickTabHead=e=>{const i=e.currentTarget??e.target,n=i.getAttribute("r-key");!rt(i)&&n&&this.activateKey(n)};activateKey=e=>{this.setAttribute("active",e),this.setTabLine(e),this.setTabContent(e),this._nav.querySelectorAll(".active").forEach(n=>n.classList.remove("active"));const i=this.tabHeaderKeyMapIndex[e];this._nav.children[i]?.classList.add("active"),this.syncTabsAria()};tabFocusable=e=>e._btn??e;tabIdFor=e=>`ran-tab-${this._tabsId}-${e}`;panelIdFor=e=>`ran-tabpanel-${this._tabsId}-${e}`;syncTabsAria=()=>{const e=this.active,i=this._slot?.assignedElements?.()??[];[...this._nav.children].forEach((n,c)=>{const g=n.getAttribute("r-key")??`${c}`,m=g===e,b=rt(n),E=this.tabFocusable(n);E.setAttribute("role","tab"),E.id=this.tabIdFor(g),E.setAttribute("aria-controls",this.panelIdFor(g)),E.setAttribute("aria-selected",m?"true":"false"),E.tabIndex=m&&!b?0:-1;const R=i[c];R&&(R.setAttribute("role","tabpanel"),R.id=this.panelIdFor(g),R.setAttribute("aria-labelledby",this.tabIdFor(g)),R.setAttribute("tabindex",m?"0":"-1"),m?R.removeAttribute("aria-hidden"):R.setAttribute("aria-hidden","true"))})};onNavKeydown=e=>{if(!["ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(e.key))return;const i=[...this._nav.children].filter(b=>!rt(b));if(!i.length)return;const n=e.target?.closest?.(".tab-header-nav-item")??e.target;let c=i.findIndex(b=>b===n);c<0&&(c=i.findIndex(b=>b.getAttribute("r-key")===this.active)),c<0&&(c=0);let g=c;e.key==="ArrowRight"||e.key==="ArrowDown"?g=(c+1)%i.length:e.key==="ArrowLeft"||e.key==="ArrowUp"?g=(c-1+i.length)%i.length:e.key==="Home"?g=0:e.key==="End"&&(g=i.length-1),e.preventDefault();const m=i[g].getAttribute("r-key");m&&(this.activateKey(m),this.tabFocusable(i[g]).focus())};updateAttribute=(e,i,n="")=>{const c=this.tabHeaderKeyMapIndex[e];e&&n&&this._nav.children[c]?this._nav.children[c]?.setAttribute(i,n):this._nav.children[c]?.removeAttribute(i)};initActive=()=>{const e=[...this._nav.children],i=e.filter(m=>!rt(m));let n;if(this.active!=null&&(n=i.find(m=>m.getAttribute("r-key")===this.active),n?.setAttribute("r-key",this.active)),n||(n=i.shift()),!n)return;const c=e.findIndex(m=>m===n),g=n?.getAttribute("r-key")||`${c}`;g!=null&&(this.setAttribute("active",`${g}`),n.classList.add("active"),this.setTabContent(g),setTimeout(()=>{this.setTabLine(g)},200))};listenSlotChange=()=>{this._slot.assignedElements().forEach((e,i)=>{const n=this.createTabHeader(e,i);this._nav.appendChild(n),n.addEventListener("click",this.clickTabHead)}),this.initActive(),this.syncTabsAria(),this.align&&(this.align==="center"&&this.initTabLineAlignCenter(),this.align==="end"&&this.initTabLineAlignEnd())};connectedCallback(){this.handlerExternalCss(),this._events.on(this._slot,"slotchange",this.listenSlotChange),this._events.on(this._nav,"keydown",this.onNavKeydown)}disconnectedCallback(){this._events.abort()}attributeChangedCallback(e,i,n){i!==n&&(this.dispatchEvent(new CustomEvent("change",{detail:{active:this.active}})),e==="align"&&(n==="center"&&this.initTabLineAlignCenter(),n==="end"&&this.initTabLineAlignEnd()),e==="effect"&&[...this._nav.children].forEach(c=>{!this.effect||this.effect==="false"?c.removeAttribute("effect"):c.setAttribute("effect",n)}),e==="active"&&this.setAttribute(e,n),e==="sheet"&&this.handlerExternalCss())}};qe("r-tabs",kc);var j0=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{--ran-radar-polygon-color: var(--ran-color-border, #e6e6e6);--ran-radar-line-color: var(--ran-color-border, #e6e6e6);--ran-radar-fill-color: rgba(255, 121, 35, .6);--ran-radar-stroke-color: rgba(255, 121, 35, .6)}.ran-radar{position:var(--ran-radar-position, relative);width:var(--ran-radar-width, 100%);height:var(--ran-radar-height, 100%);display:var(--ran-radar-display, block)}.ran-radar canvas{width:100%;height:100%}",Z0="rgba(0,0,0,0)",$0="rgba(0,0,0,1)",Bc="#e6e6e6",Ic="#e6e6e6",ef="黑体",Sc="rgba(255,121,35,0.60)",xc="rgba(255,121,35,0.60)",Tc=class extends Ve{mData;mCount;mW;mCenter;mRadius;mAngle;static get observedAttributes(){return["abilitys","colorpolygon","colorline","fillcolor","strokecolor","sheet"]}abilityRadarChartContainer;abilityRadarChart;_iconElement;_shadowDom;resizeObserver;constructor(){super(),this._shadowDom=We(this,j0);const e=_e(this._shadowDom,".ran-radar",()=>K().class("ran-radar").children(Ne("canvas").build()).build()),i=e.querySelector("canvas");this.abilityRadarChartContainer=e,this.abilityRadarChart=i,this.resizeObserver=new ResizeObserver(this.resize),this.resizeObserver.observe(this.abilityRadarChartContainer)}resize=()=>{this.refreshData()};get abilitys(){const e=this.getAttribute("abilitys");if(typeof e=="string")try{return JSON.parse(e)}catch(i){return console.error(`Failed to parse the rule in JSON.parse: ${e}, error: ${i}`),e}return e}set abilitys(e){typeof e=="string"?this.setAttribute("abilitys",e||""):this.setAttribute("abilitys",JSON.stringify(e)||"")}_cssVar(e){return typeof getComputedStyle>"u"?"":getComputedStyle(this).getPropertyValue(e).trim()}get colorPolygon(){return this.getAttribute("colorPolygon")||this._cssVar("--ran-radar-polygon-color")||Bc}set colorPolygon(e){this.setAttribute("colorPolygon",e||Bc)}get colorLine(){return this.getAttribute("colorLine")||this._cssVar("--ran-radar-line-color")||Ic}set colorLine(e){this.setAttribute("colorLine",e||Ic)}get fontColor(){return this._cssVar("--ran-color-text")||$0}get fillColor(){return this.getAttribute("fillColor")||this._cssVar("--ran-radar-fill-color")||Sc}set fillColor(e){this.setAttribute("fillColor",e||Sc)}get strokeColor(){return this.getAttribute("strokeColor")||this._cssVar("--ran-radar-stroke-color")||xc}set strokeColor(e){this.setAttribute("strokeColor",e||xc)}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};refreshData(){const e=this.abilityRadarChart.getContext("2d");if(!this.abilityRadarChartContainer||!e)return;const i=Hi(e),n=this.abilityRadarChartContainer.clientWidth*i,c=this.abilityRadarChartContainer.clientHeight*i;this.abilityRadarChart.width=n,this.abilityRadarChart.height=c,this.mW=n,this.mData=this.abilitys,this.mCount=this.mData?.length||1,this.mCenter=this.mW/2,this.mRadius=this.mCenter-50*i,this.mAngle=Math.PI*2/this.mCount,this.drawPolygon(e),this.drawSide(e),this.drawLines(e),this.drawText(e),this.drawRegion(e),this.drawCircle(e)}drawSide(e){if(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle)return;e.save(),e.strokeStyle=this.colorLine;const i=this.mRadius;for(let n=0;n<this.mCount;n++){const c=this.mCenter+i*Math.sin(this.mAngle*n),g=this.mCenter+i*Math.cos(this.mAngle*n);e.lineTo(c,g)}e.closePath(),e.stroke()}drawPolygon(e){if(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle)return;e.save(),e.strokeStyle=this.colorPolygon;const i=this.mRadius/4;e.setLineDash([6,6]);for(let n=0;n<4;n++){e.beginPath();const c=i*(n+1);for(let g=0;g<this.mCount;g++){const m=this.mCenter+c*Math.sin(this.mAngle*g),b=this.mCenter+c*Math.cos(this.mAngle*g);e.lineTo(m,b)}e.closePath(),e.stroke()}e.restore()}drawLines(e){if(!(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle)){e.save(),e.beginPath(),e.strokeStyle=this.colorLine;for(let i=0;i<this.mCount;i++){const n=this.mCenter+this.mRadius*Math.sin(this.mAngle*i),c=this.mCenter+this.mRadius*Math.cos(this.mAngle*i);e.moveTo(this.mCenter,this.mCenter),e.lineTo(n,c)}e.stroke(),e.restore()}}drawText(e){if(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle||!this.mData)return;e.save();const i=Hi(e),n=this.mCenter/12;for(let c=0;c<this.mCount;c++){const g=this.mCenter+this.mRadius*Math.sin(this.mAngle*c),m=this.mCenter+this.mRadius*Math.cos(this.mAngle*c),b=this.mData[c]?.backgroundColor||Z0,E=this.mData[c]?.fontColor||this.fontColor,R=this.mData[c]?.fontFamily||ef,F=this.mData[c]?.fontSize||n;e.font=`${F}px ${R}`,this.mAngle*c>=0&&this.mAngle*c<Math.PI/2?this.drawButton(e,b,g,m,44*i,24*i,12*i,this.mData[c].abilityName,E,R,F):this.mAngle*c>=Math.PI/2&&this.mAngle*c<Math.PI?this.drawButton(e,b,g,m-24*i,44*i,24*i,12*i,this.mData[c].abilityName,E,R,F):this.mAngle*c>=Math.PI&&this.mAngle*c<Math.PI*3/2?this.drawButton(e,b,g-44*i,m-24*i,44*i,24*i,12*i,this.mData[c].abilityName,E,R,F):this.drawButton(e,b,g-44*i,m,44*i,24*i,12*i,this.mData[c].abilityName,E,R,F)}e.restore()}drawButton(e,i,n,c,g,m,b,E,R,F,Q){e.beginPath();const Y=Hi(e);e.fillStyle=i,e.moveTo(n+b,c),e.lineTo(n+g-b,c),e.arc(n+g-b,c+b,b,Math.PI*3/2,Math.PI*2),e.lineTo(n+g,c+m-b),e.arc(n+g-b,c+m-b,b,Math.PI,Math.PI/2),e.lineTo(n+b,c+m),e.arc(n+b,c+m-b,b,Math.PI/2,Math.PI),e.lineTo(n,c+b),e.arc(n+b,c+b,b,Math.PI,Math.PI*3/2),e.fill(),e.closePath(),e.beginPath(),e.fillStyle=R,e.font=`${Q||12*Y}px ${F}`,e.textAlign="center",e.textBaseline="middle",e.fillText(E,n+g/2,c+m/2)}drawRegion(e){if(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle||!this.mData)return;const i=Hi(e);e.save(),e.beginPath();for(let n=0;n<this.mCount;n++){const c=this.mCenter+this.mRadius*Math.sin(this.mAngle*n)*this.mData[n].scoreRate/100,g=this.mCenter+this.mRadius*Math.cos(this.mAngle*n)*this.mData[n].scoreRate/100;e.lineTo(c,g)}e.closePath(),e.fillStyle=this.fillColor,e.fill(),e.strokeStyle=this.strokeColor,e.lineWidth=1*i,e.stroke(),e.restore()}drawCircle(e){if(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle||!this.mData)return;const i=Hi(e);e.save();for(let n=0;n<this.mCount;n++){const c=this.mCenter+this.mRadius*Math.sin(this.mAngle*n)*this.mData[n].scoreRate/100,g=this.mCenter+this.mRadius*Math.cos(this.mAngle*n)*this.mData[n].scoreRate/100;e.beginPath(),e.arc(c,g,3,0,Math.PI*2),e.lineWidth=1.5*i,e.strokeStyle=this.strokeColor,e.stroke()}e.restore()}connectedCallback(){this.handlerExternalCss(),this.refreshData()}disconnectedCallback(){this.resizeObserver.disconnect()}attributeChangedCallback(e,i,n){i!==n&&(["abilitys","colorpolygon","colorline","fillcolor","strokecolor"].includes(e)&&this.abilityRadarChartContainer&&this.refreshData(),e==="sheet"&&this.handlerExternalCss())}};qe("r-radar",Tc);var tf=a0(((e,i)=>{(function n(c){function b(d,s){var t=Object.keys(d);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(d);s&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(d,a).enumerable})),t.push.apply(t,r)}return t}function E(d){for(var s=1;s<arguments.length;s++){var t=arguments[s]!=null?arguments[s]:{};s%2?b(Object(t),!0).forEach(function(r){Q(d,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(t)):b(Object(t)).forEach(function(r){Object.defineProperty(d,r,Object.getOwnPropertyDescriptor(t,r))})}return d}function R(d,s){for(var t=0;t<s.length;t++){var r=s[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(d,Fe(r.key),r)}}function F(d,s,t){return s&&R(d.prototype,s),t&&R(d,t),Object.defineProperty(d,"prototype",{writable:!1}),d}function Q(d,s,t){return(s=Fe(s))in d?Object.defineProperty(d,s,{value:t,enumerable:!0,configurable:!0,writable:!0}):d[s]=t,d}function Y(){return Y=Object.assign?Object.assign.bind():function(d){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(d[r]=t[r])}return d},Y.apply(this,arguments)}function X(d,s){d.prototype=Object.create(s.prototype),d.prototype.constructor=d,ne(d,s)}function _(d){return _=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},_(d)}function ne(d,s){return ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},ne(d,s)}function te(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ge(d,s,t){return ge=te()?Reflect.construct.bind():function(r,a,o){var l=[null];l.push.apply(l,a);var h=new(Function.bind.apply(r,l));return o&&ne(h,o.prototype),h},ge.apply(null,arguments)}function ce(d){var s=typeof Map=="function"?new Map:void 0;return ce=function(t){if(t===null||(r=t,Function.toString.call(r).indexOf("[native code]")===-1))return t;var r;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(s!==void 0){if(s.has(t))return s.get(t);s.set(t,a)}function a(){return ge(t,arguments,_(this).constructor)}return a.prototype=Object.create(t.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),ne(a,t)},ce(d)}function be(d,s){(s==null||s>d.length)&&(s=d.length);for(var t=0,r=new Array(s);t<s;t++)r[t]=d[t];return r}function xe(d,s){var t=typeof Symbol<"u"&&d[Symbol.iterator]||d["@@iterator"];if(t)return(t=t.call(d)).next.bind(t);if(Array.isArray(d)||(t=(function(a,o){if(a){if(typeof a=="string")return be(a,o);var l=Object.prototype.toString.call(a).slice(8,-1);return l==="Object"&&a.constructor&&(l=a.constructor.name),l==="Map"||l==="Set"?Array.from(a):l==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?be(a,o):void 0}})(d))||s&&d&&typeof d.length=="number"){t&&(d=t);var r=0;return function(){return r>=d.length?{done:!0}:{done:!1,value:d[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
5
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Fe(d){var s=(function(t,r){if(typeof t!="object"||t===null)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var o=a.call(t,r||"default");if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)})(d,"string");return typeof s=="symbol"?s:String(s)}function Te(d){return d&&d.__esModule&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d}var De={exports:{}};(function(d,s){var t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,a=/(?:\/|^)\.(?=\/)/g,o=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,l={buildAbsoluteURL:function(h,u,f){if(f=f||{},h=h.trim(),!(u=u.trim())){if(!f.alwaysNormalize)return h;var p=l.parseURL(h);if(!p)throw new Error("Error trying to parse base URL.");return p.path=l.normalizePath(p.path),l.buildURLFromParts(p)}var v=l.parseURL(u);if(!v)throw new Error("Error trying to parse relative URL.");if(v.scheme)return f.alwaysNormalize?(v.path=l.normalizePath(v.path),l.buildURLFromParts(v)):u;var w=l.parseURL(h);if(!w)throw new Error("Error trying to parse base URL.");if(!w.netLoc&&w.path&&w.path[0]!=="/"){var C=r.exec(w.path);w.netLoc=C[1],w.path=C[2]}w.netLoc&&!w.path&&(w.path="/");var k={scheme:w.scheme,netLoc:v.netLoc,path:null,params:v.params,query:v.query,fragment:v.fragment};if(!v.netLoc&&(k.netLoc=w.netLoc,v.path[0]!=="/"))if(v.path){var I=w.path,D=I.substring(0,I.lastIndexOf("/")+1)+v.path;k.path=l.normalizePath(D)}else k.path=w.path,v.params||(k.params=w.params,v.query||(k.query=w.query));return k.path===null&&(k.path=f.alwaysNormalize?l.normalizePath(v.path):v.path),l.buildURLFromParts(k)},parseURL:function(h){var u=t.exec(h);return u?{scheme:u[1]||"",netLoc:u[2]||"",path:u[3]||"",params:u[4]||"",query:u[5]||"",fragment:u[6]||""}:null},normalizePath:function(h){for(h=h.split("").reverse().join("").replace(a,"");h.length!==(h=h.replace(o,"")).length;);return h.split("").reverse().join("")},buildURLFromParts:function(h){return h.scheme+h.netLoc+h.path+h.params+h.query+h.fragment}};d.exports=l})(De);var Ge=De.exports,se=Number.isFinite||function(d){return typeof d=="number"&&isFinite(d)},x=(function(d){return d.MEDIA_ATTACHING="hlsMediaAttaching",d.MEDIA_ATTACHED="hlsMediaAttached",d.MEDIA_DETACHING="hlsMediaDetaching",d.MEDIA_DETACHED="hlsMediaDetached",d.BUFFER_RESET="hlsBufferReset",d.BUFFER_CODECS="hlsBufferCodecs",d.BUFFER_CREATED="hlsBufferCreated",d.BUFFER_APPENDING="hlsBufferAppending",d.BUFFER_APPENDED="hlsBufferAppended",d.BUFFER_EOS="hlsBufferEos",d.BUFFER_FLUSHING="hlsBufferFlushing",d.BUFFER_FLUSHED="hlsBufferFlushed",d.MANIFEST_LOADING="hlsManifestLoading",d.MANIFEST_LOADED="hlsManifestLoaded",d.MANIFEST_PARSED="hlsManifestParsed",d.LEVEL_SWITCHING="hlsLevelSwitching",d.LEVEL_SWITCHED="hlsLevelSwitched",d.LEVEL_LOADING="hlsLevelLoading",d.LEVEL_LOADED="hlsLevelLoaded",d.LEVEL_UPDATED="hlsLevelUpdated",d.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",d.LEVELS_UPDATED="hlsLevelsUpdated",d.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",d.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",d.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",d.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",d.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",d.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",d.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",d.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",d.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",d.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",d.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",d.CUES_PARSED="hlsCuesParsed",d.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",d.INIT_PTS_FOUND="hlsInitPtsFound",d.FRAG_LOADING="hlsFragLoading",d.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",d.FRAG_LOADED="hlsFragLoaded",d.FRAG_DECRYPTED="hlsFragDecrypted",d.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",d.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",d.FRAG_PARSING_METADATA="hlsFragParsingMetadata",d.FRAG_PARSED="hlsFragParsed",d.FRAG_BUFFERED="hlsFragBuffered",d.FRAG_CHANGED="hlsFragChanged",d.FPS_DROP="hlsFpsDrop",d.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",d.ERROR="hlsError",d.DESTROYING="hlsDestroying",d.KEY_LOADING="hlsKeyLoading",d.KEY_LOADED="hlsKeyLoaded",d.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",d.BACK_BUFFER_REACHED="hlsBackBufferReached",d})({}),ue=(function(d){return d.NETWORK_ERROR="networkError",d.MEDIA_ERROR="mediaError",d.KEY_SYSTEM_ERROR="keySystemError",d.MUX_ERROR="muxError",d.OTHER_ERROR="otherError",d})({}),q=(function(d){return d.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",d.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",d.KEY_SYSTEM_NO_SESSION="keySystemNoSession",d.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",d.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",d.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",d.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",d.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",d.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",d.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",d.MANIFEST_LOAD_ERROR="manifestLoadError",d.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",d.MANIFEST_PARSING_ERROR="manifestParsingError",d.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",d.LEVEL_EMPTY_ERROR="levelEmptyError",d.LEVEL_LOAD_ERROR="levelLoadError",d.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",d.LEVEL_PARSING_ERROR="levelParsingError",d.LEVEL_SWITCH_ERROR="levelSwitchError",d.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",d.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",d.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",d.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",d.FRAG_LOAD_ERROR="fragLoadError",d.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",d.FRAG_DECRYPT_ERROR="fragDecryptError",d.FRAG_PARSING_ERROR="fragParsingError",d.FRAG_GAP="fragGap",d.REMUX_ALLOC_ERROR="remuxAllocError",d.KEY_LOAD_ERROR="keyLoadError",d.KEY_LOAD_TIMEOUT="keyLoadTimeOut",d.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",d.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",d.BUFFER_APPEND_ERROR="bufferAppendError",d.BUFFER_APPENDING_ERROR="bufferAppendingError",d.BUFFER_STALLED_ERROR="bufferStalledError",d.BUFFER_FULL_ERROR="bufferFullError",d.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",d.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",d.INTERNAL_EXCEPTION="internalException",d.INTERNAL_ABORTED="aborted",d.UNKNOWN="unknown",d})({}),At=function(){},ut={trace:At,debug:At,log:At,warn:At,info:At,error:At},ft=ut;function Kt(d){var s=self.console[d];return s?s.bind(self.console,"["+d+"] >"):At}function tr(d,s){if(self.console&&d===!0||typeof d=="object"){(function(t){for(var r=arguments.length,a=new Array(r>1?r-1:0),o=1;o<r;o++)a[o-1]=arguments[o];a.forEach(function(l){ft[l]=t[l]?t[l].bind(t):Kt(l)})})(d,"debug","log","info","warn","error");try{ft.log('Debug logs enabled for "'+s+'" in hls.js version 1.4.12')}catch{ft=ut}}else ft=ut}var G=ft,ri=/^(\d+)x(\d+)$/,Nt=/(.+?)=(".*?"|.*?)(?:,|$)/g,Ke=(function(){function d(t){for(var r in typeof t=="string"&&(t=d.parseAttrList(t)),t)t.hasOwnProperty(r)&&(r.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(r)),this[r]=t[r])}var s=d.prototype;return s.decimalInteger=function(t){var r=parseInt(this[t],10);return r>Number.MAX_SAFE_INTEGER?1/0:r},s.hexadecimalInteger=function(t){if(this[t]){var r=(this[t]||"0x").slice(2);r=(1&r.length?"0":"")+r;for(var a=new Uint8Array(r.length/2),o=0;o<r.length/2;o++)a[o]=parseInt(r.slice(2*o,2*o+2),16);return a}return null},s.hexadecimalIntegerAsNumber=function(t){var r=parseInt(this[t],16);return r>Number.MAX_SAFE_INTEGER?1/0:r},s.decimalFloatingPoint=function(t){return parseFloat(this[t])},s.optionalFloat=function(t,r){var a=this[t];return a?parseFloat(a):r},s.enumeratedString=function(t){return this[t]},s.bool=function(t){return this[t]==="YES"},s.decimalResolution=function(t){var r=ri.exec(this[t]);if(r!==null)return{width:parseInt(r[1],10),height:parseInt(r[2],10)}},d.parseAttrList=function(t){var r,a={};for(Nt.lastIndex=0;(r=Nt.exec(t))!==null;){var o=r[2];o.indexOf('"')===0&&o.lastIndexOf('"')===o.length-1&&(o=o.slice(1,-1)),a[r[1].trim()]=o}return a},d})();function It(d){return d==="SCTE35-OUT"||d==="SCTE35-IN"}var mr=(function(){function d(s,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var r=t.attr;for(var a in r)if(Object.prototype.hasOwnProperty.call(s,a)&&s[a]!==r[a]){G.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+s.ID+'"'),this._badValueForSameId=a;break}s=Y(new Ke({}),r,s)}if(this.attr=s,this._startDate=new Date(s["START-DATE"]),"END-DATE"in this.attr){var o=new Date(this.attr["END-DATE"]);se(o.getTime())&&(this._endDate=o)}}return F(d,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var s=this.duration;return s!==null?new Date(this._startDate.getTime()+1e3*s):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var s=this.attr.decimalFloatingPoint("DURATION");if(se(s))return s}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&se(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),d})(),vr=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}},ot="audio",bt="video",zt="audiovideo",rr=(function(){function d(s){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[ot]=null,t[bt]=null,t[zt]=null,t),this.baseurl=s}return d.prototype.setByteRange=function(s,t){var r=s.split("@",2),a=[];r.length===1?a[0]=t?t.byteRangeEndOffset:0:a[0]=parseInt(r[1]),a[1]=parseInt(r[0])+a[0],this._byteRange=a},F(d,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Ge.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(s){this._url=s}}]),d})(),Ar=(function(d){function s(r,a){var o;return(o=d.call(this,a)||this)._decryptdata=null,o.rawProgramDateTime=null,o.programDateTime=null,o.tagList=[],o.duration=0,o.sn=0,o.levelkeys=void 0,o.type=void 0,o.loader=null,o.keyLoader=null,o.level=-1,o.cc=0,o.startPTS=void 0,o.endPTS=void 0,o.startDTS=void 0,o.endDTS=void 0,o.start=0,o.deltaPTS=void 0,o.maxStartPTS=void 0,o.minEndPTS=void 0,o.stats=new vr,o.urlId=0,o.data=void 0,o.bitrateTest=!1,o.title=null,o.initSegment=null,o.endList=void 0,o.gap=void 0,o.type=r,o}X(s,d);var t=s.prototype;return t.setKeyFormat=function(r){if(this.levelkeys){var a=this.levelkeys[r];a&&!this._decryptdata&&(this._decryptdata=a.getDecryptData(this.sn))}},t.abortRequests=function(){var r,a;(r=this.loader)==null||r.abort(),(a=this.keyLoader)==null||a.abort()},t.setElementaryStreamInfo=function(r,a,o,l,h,u){u===void 0&&(u=!1);var f=this.elementaryStreams,p=f[r];p?(p.startPTS=Math.min(p.startPTS,a),p.endPTS=Math.max(p.endPTS,o),p.startDTS=Math.min(p.startDTS,l),p.endDTS=Math.max(p.endDTS,h)):f[r]={startPTS:a,endPTS:o,startDTS:l,endDTS:h,partial:u}},t.clearElementaryStreamInfo=function(){var r=this.elementaryStreams;r[ot]=null,r[bt]=null,r[zt]=null},F(s,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var r=this.levelkeys.identity;if(r)this._decryptdata=r.getDecryptData(this.sn);else{var a=Object.keys(this.levelkeys);if(a.length===1)return this._decryptdata=this.levelkeys[a[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!se(this.programDateTime))return null;var r=se(this.duration)?this.duration:0;return this.programDateTime+1e3*r}},{key:"encrypted",get:function(){var r;if((r=this._decryptdata)!=null&&r.encrypted)return!0;if(this.levelkeys){var a=Object.keys(this.levelkeys),o=a.length;if(o>1||o===1&&this.levelkeys[a[0]].encrypted)return!0}return!1}}]),s})(rr),zr=(function(d){function s(t,r,a,o,l){var h;(h=d.call(this,a)||this).fragOffset=0,h.duration=0,h.gap=!1,h.independent=!1,h.relurl=void 0,h.fragment=void 0,h.index=void 0,h.stats=new vr,h.duration=t.decimalFloatingPoint("DURATION"),h.gap=t.bool("GAP"),h.independent=t.bool("INDEPENDENT"),h.relurl=t.enumeratedString("URI"),h.fragment=r,h.index=o;var u=t.enumeratedString("BYTERANGE");return u&&h.setByteRange(u,l),l&&(h.fragOffset=l.fragOffset+l.duration),h}return X(s,d),F(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}]),s})(rr),ga=(function(){function d(s){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=s}return d.prototype.reloaded=function(s){if(!s)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-s.lastPartSn,r=this.lastPartIndex-s.lastPartIndex;this.updated=this.endSN!==s.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>s.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*s.misses):this.misses=s.misses+1,this.availabilityDelay=s.availabilityDelay},F(d,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&se(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var s=this.driftEndTime-this.driftStartTime;return s>0?1e3*(this.driftEnd-this.driftStart)/s:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var s;return(s=this.partList)!=null&&s.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var s;return(s=this.fragments)!=null&&s.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var s;return(s=this.partList)!=null&&s.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var s;return(s=this.partList)!=null&&s.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),d})();function ii(d){return Uint8Array.from(atob(d),function(s){return s.charCodeAt(0)})}function fa(d){var s,t,r=d.split(":"),a=null;if(r[0]==="data"&&r.length===2){var o=r[1].split(";"),l=o[o.length-1].split(",");if(l.length===2){var h=l[0]==="base64",u=l[1];h?(o.splice(-1,1),a=ii(u)):(s=qr(u).subarray(0,16),(t=new Uint8Array(16)).set(s,16-s.length),a=t)}}return a}function qr(d){return Uint8Array.from(unescape(encodeURIComponent(d)),function(s){return s.charCodeAt(0)})}var $e={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Vr="org.w3.clearkey",Lr="com.apple.streamingkeydelivery",qt="com.microsoft.playready",Mr="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function cu(d){switch(d){case Lr:return $e.FAIRPLAY;case qt:return $e.PLAYREADY;case Mr:return $e.WIDEVINE;case Vr:return $e.CLEARKEY}}var du="edef8ba979d64acea3c827dcd51d21ed";function hu(d){switch(d){case $e.FAIRPLAY:return Lr;case $e.PLAYREADY:return qt;case $e.WIDEVINE:return Mr;case $e.CLEARKEY:return Vr}}function Xs(d){var s=d.drmSystems,t=d.widevineLicenseUrl,r=s?[$e.FAIRPLAY,$e.WIDEVINE,$e.PLAYREADY,$e.CLEARKEY].filter(function(a){return!!s[a]}):[];return!r[$e.WIDEVINE]&&t&&r.push($e.WIDEVINE),r}var uu=typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function ai(d,s,t){return Uint8Array.prototype.slice?d.slice(s,t):new Uint8Array(Array.prototype.slice.call(d,s,t))}var Js,_s=function(d,s){return s+10<=d.length&&d[s]===73&&d[s+1]===68&&d[s+2]===51&&d[s+3]<255&&d[s+4]<255&&d[s+6]<128&&d[s+7]<128&&d[s+8]<128&&d[s+9]<128},gu=function(d,s){return s+10<=d.length&&d[s]===51&&d[s+1]===68&&d[s+2]===73&&d[s+3]<255&&d[s+4]<255&&d[s+6]<128&&d[s+7]<128&&d[s+8]<128&&d[s+9]<128},kn=function(d,s){for(var t=s,r=0;_s(d,s);)r+=10,r+=Bn(d,s+6),gu(d,s+10)&&(r+=10),s+=r;if(r>0)return d.subarray(t,t+r)},Bn=function(d,s){var t=0;return t=(127&d[s])<<21,t|=(127&d[s+1])<<14,t|=(127&d[s+2])<<7,t|=127&d[s+3]},Pp=function(d,s){return _s(d,s)&&Bn(d,s+6)+10<=d.length-s},fu=function(d){return d&&d.key==="PRIV"&&d.info==="com.apple.streaming.transportStreamTimestamp"},Up=function(d){var s=String.fromCharCode(d[0],d[1],d[2],d[3]),t=Bn(d,4);return{type:s,size:t,data:d.subarray(10,10+t)}},pu=function(d){for(var s=0,t=[];_s(d,s);){for(var r=Bn(d,s+6),a=(s+=10)+r;s+8<a;){var o=Up(d.subarray(s)),l=Qp(o);l&&t.push(l),s+=o.size+10}gu(d,s)&&(s+=10)}return t},Qp=function(d){return d.type==="PRIV"?Np(d):d.type[0]==="W"?Gp(d):Hp(d)},Np=function(d){if(!(d.size<2)){var s=br(d.data,!0),t=new Uint8Array(d.data.subarray(s.length+1));return{key:d.type,info:s,data:t.buffer}}},Hp=function(d){if(!(d.size<2)){if(d.type==="TXXX"){var s=1,t=br(d.data.subarray(s),!0);s+=t.length+1;var r=br(d.data.subarray(s));return{key:d.type,info:t,data:r}}var a=br(d.data.subarray(1));return{key:d.type,data:a}}},Gp=function(d){if(d.type==="WXXX"){if(d.size<2)return;var s=1,t=br(d.data.subarray(s),!0);s+=t.length+1;var r=br(d.data.subarray(s));return{key:d.type,info:t,data:r}}var a=br(d.data);return{key:d.type,data:a}},Yp=function(d){if(d.data.byteLength===8){var s=new Uint8Array(d.data),t=1&s[3],r=(s[4]<<23)+(s[5]<<15)+(s[6]<<7)+s[7];return r/=45,t&&(r+=4772185884e-2),Math.round(r)}},br=function(d,s){s===void 0&&(s=!1);var t=Kp();if(t){var r=t.decode(d);if(s){var a=r.indexOf("\0");return a!==-1?r.substring(0,a):r}return r.replace(/\0/g,"")}for(var o,l,h,u=d.length,f="",p=0;p<u;){if((o=d[p++])===0&&s)return f;if(o!==0&&o!==3)switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:f+=String.fromCharCode(o);break;case 12:case 13:l=d[p++],f+=String.fromCharCode((31&o)<<6|63&l);break;case 14:l=d[p++],h=d[p++],f+=String.fromCharCode((15&o)<<12|(63&l)<<6|(63&h)<<0)}}return f};function Kp(){return Js||self.TextDecoder===void 0||(Js=new self.TextDecoder("utf-8")),Js}var yr=function(d){for(var s="",t=0;t<d.length;t++){var r=d[t].toString(16);r.length<2&&(r="0"+r),s+=r}return s},In=Math.pow(2,32)-1,zp=[].push,mu={video:1,audio:2,id3:3,text:4};function yt(d){return String.fromCharCode.apply(null,d)}function vu(d,s){var t=d[s]<<8|d[s+1];return t<0?65536+t:t}function Re(d,s){var t=Au(d,s);return t<0?4294967296+t:t}function Au(d,s){return d[s]<<24|d[s+1]<<16|d[s+2]<<8|d[s+3]}function js(d,s,t){d[s]=t>>24,d[s+1]=t>>16&255,d[s+2]=t>>8&255,d[s+3]=255&t}function Ye(d,s){var t=[];if(!s.length)return t;for(var r=d.byteLength,a=0;a<r;){var o=Re(d,a),l=o>1?a+o:r;if(yt(d.subarray(a+4,a+8))===s[0])if(s.length===1)t.push(d.subarray(a+8,l));else{var h=Ye(d.subarray(a+8,l),s.slice(1));h.length&&zp.apply(t,h)}a=l}return t}function qp(d){var s=[],t=d[0],r=8,a=Re(d,r);r+=4,r+=t===0?8:16,r+=2;var o=d.length+0,l=vu(d,r);r+=2;for(var h=0;h<l;h++){var u=r,f=Re(d,u);u+=4;var p=2147483647&f;if((2147483648&f)>>>31==1)return G.warn("SIDX has hierarchical references (not supported)"),null;var v=Re(d,u);u+=4,s.push({referenceSize:p,subsegmentDuration:v,info:{duration:v/a,start:o,end:o+p-1}}),o+=p,r=u+=4}return{earliestPresentationTime:0,timescale:a,version:t,referencesCount:l,references:s}}function bu(d){for(var s=[],t=Ye(d,["moov","trak"]),r=0;r<t.length;r++){var a=t[r],o=Ye(a,["tkhd"])[0];if(o){var l=o[0],h=l===0?12:20,u=Re(o,h),f=Ye(a,["mdia","mdhd"])[0];if(f){var p=Re(f,h=(l=f[0])===0?12:20),v=Ye(a,["mdia","hdlr"])[0];if(v){var w=yt(v.subarray(8,12)),C={soun:ot,vide:bt}[w];if(C){var k=Ye(a,["mdia","minf","stbl","stsd"])[0],I=void 0;k&&(I=yt(k.subarray(12,16))),s[u]={timescale:p,type:C},s[C]={timescale:p,id:u,codec:I}}}}}}return Ye(d,["moov","mvex","trex"]).forEach(function(D){var B=s[Re(D,4)];B&&(B.default={duration:Re(D,12),flags:Re(D,20)})}),s}function yu(d){var s=Ye(d,["schm"])[0];if(s){var t=yt(s.subarray(4,8));if(t==="cbcs"||t==="cenc")return Ye(d,["schi","tenc"])[0]}return G.error("[eme] missing 'schm' box"),null}function Vp(d){var s=Re(d,0),t=8;1&s&&(t+=4),4&s&&(t+=4);for(var r=0,a=Re(d,4),o=0;o<a;o++)256&s&&(r+=Re(d,t),t+=4),512&s&&(t+=4),1024&s&&(t+=4),2048&s&&(t+=4);return r}function ni(d,s){var t=new Uint8Array(d.length+s.length);return t.set(d),t.set(s,d.length),t}function wu(d,s){var t=[],r=s.samples,a=s.timescale,o=s.id,l=!1;return Ye(r,["moof"]).map(function(h){var u=h.byteOffset-8;Ye(h,["traf"]).map(function(f){var p=Ye(f,["tfdt"]).map(function(v){var w=v[0],C=Re(v,4);return w===1&&(C*=Math.pow(2,32),C+=Re(v,8)),C/a})[0];return p!==void 0&&(d=p),Ye(f,["tfhd"]).map(function(v){var w=Re(v,4),C=16777215&Re(v,0),k=0,I=(16&C)!=0,D=0,B=(32&C)!=0,T=8;w===o&&((1&C)!=0&&(T+=8),(2&C)!=0&&(T+=4),(8&C)!=0&&(k=Re(v,T),T+=4),I&&(D=Re(v,T),T+=4),B&&(T+=4),s.type==="video"&&(l=(function(U){if(!U)return!1;var M=U.indexOf("."),H=M<0?U:U.substring(0,M);return H==="hvc1"||H==="hev1"||H==="dvh1"||H==="dvhe"})(s.codec)),Ye(f,["trun"]).map(function(U){var M=U[0],H=16777215&Re(U,0),V=(1&H)!=0,W=0,$=(4&H)!=0,J=(256&H)!=0,j=0,le=(512&H)!=0,ie=0,me=(1024&H)!=0,we=(2048&H)!=0,ve=0,Ae=Re(U,4),Ie=8;V&&(W=Re(U,Ie),Ie+=4),$&&(Ie+=4);for(var fe=W+u,Pe=0;Pe<Ae;Pe++){if(J?(j=Re(U,Ie),Ie+=4):j=k,le?(ie=Re(U,Ie),Ie+=4):ie=D,me&&(Ie+=4),we&&(ve=M===0?Re(U,Ie):Au(U,Ie),Ie+=4),s.type===bt)for(var Ue=0;Ue<ie;){var ze=Re(r,fe);Wp(l,r[fe+=4])&&Cu(r.subarray(fe,fe+ze),l?2:1,d+ve/a,t),fe+=ze,Ue+=ze+4}d+=j/a}}))})})}),t}function Wp(d,s){if(d){var t=s>>1&63;return t===39||t===40}return(31&s)==6}function Cu(d,s,t,r){var a=Eu(d),o=0;o+=s;for(var l=0,h=0,u=!1,f=0;o<a.length;){l=0;do{if(o>=a.length)break;l+=f=a[o++]}while(f===255);h=0;do{if(o>=a.length)break;h+=f=a[o++]}while(f===255);var p=a.length-o;if(!u&&l===4&&o<a.length){if(u=!0,a[o++]===181){var v=vu(a,o);if(o+=2,v===49){var w=Re(a,o);if(o+=4,w===1195456820){var C=a[o++];if(C===3){var k=a[o++],I=64&k,D=I?2+3*(31&k):0,B=new Uint8Array(D);if(I){B[0]=k;for(var T=1;T<D;T++)B[T]=a[o++]}r.push({type:C,payloadType:l,pts:t,bytes:B})}}}}}else if(l===5&&h<p){if(u=!0,h>16){for(var U=[],M=0;M<16;M++){var H=a[o++].toString(16);U.push(H.length==1?"0"+H:H),M!==3&&M!==5&&M!==7&&M!==9||U.push("-")}for(var V=h-16,W=new Uint8Array(V),$=0;$<V;$++)W[$]=a[o++];r.push({payloadType:l,pts:t,uuid:U.join(""),userData:br(W),userDataBytes:W})}}else if(h<p)o+=h;else if(h>p)break}}function Eu(d){for(var s=d.byteLength,t=[],r=1;r<s-2;)d[r]===0&&d[r+1]===0&&d[r+2]===3?(t.push(r+2),r+=2):r++;if(t.length===0)return d;var a=s-t.length,o=new Uint8Array(a),l=0;for(r=0;r<a;l++,r++)l===t[0]&&(l++,t.shift()),o[r]=d[l];return o}function Xp(d,s,t){if(d.byteLength!==16)throw new RangeError("Invalid system id");var r,a,o;if(s){r=1,a=new Uint8Array(16*s.length);for(var l=0;l<s.length;l++){var h=s[l];if(h.byteLength!==16)throw new RangeError("Invalid key");a.set(h,16*l)}}else r=0,a=new Uint8Array;r>0?(o=new Uint8Array(4),s.length>0&&new DataView(o.buffer).setUint32(0,s.length,!1)):o=new Uint8Array;var u=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(u.buffer).setUint32(0,t.byteLength,!1),(function(f){for(var p=arguments.length,v=new Array(p>1?p-1:0),w=1;w<p;w++)v[w-1]=arguments[w];for(var C=v.length,k=8,I=C;I--;)k+=v[I].byteLength;var D=new Uint8Array(k);for(D[0]=k>>24&255,D[1]=k>>16&255,D[2]=k>>8&255,D[3]=255&k,D.set(f,4),I=0,k=8;I<C;I++)D.set(v[I],k),k+=v[I].byteLength;return D})([112,115,115,104],new Uint8Array([r,0,0,0]),d,o,a,u,t||new Uint8Array)}var Sn={},Zs=(function(){function d(t,r,a,o,l){o===void 0&&(o=[1]),l===void 0&&(l=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=r,this.keyFormat=a,this.keyFormatVersions=o,this.iv=l,this.encrypted=!!t&&t!=="NONE",this.isCommonEncryption=this.encrypted&&t!=="AES-128"}d.clearKeyUriToKeyIdMap=function(){Sn={}};var s=d.prototype;return s.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Lr:case Mr:case qt:case Vr:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},s.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof t!="number"&&(this.method!=="AES-128"||this.iv||G.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0);var r=(function(D){for(var B=new Uint8Array(16),T=12;T<16;T++)B[T]=D>>8*(15-T)&255;return B})(t);return new d(this.method,this.uri,"identity",this.keyFormatVersions,r)}var a=fa(this.uri);if(a)switch(this.keyFormat){case Mr:this.pssh=a,a.length>=22&&(this.keyId=a.subarray(a.length-22,a.length-6));break;case qt:var o=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Xp(o,null,a);var l=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/2),h=String.fromCharCode.apply(null,Array.from(l)),u=h.substring(h.indexOf("<"),h.length),f=new DOMParser().parseFromString(u,"text/xml").getElementsByTagName("KID")[0];if(f){var p=f.childNodes[0]?f.childNodes[0].nodeValue:f.getAttribute("VALUE");if(p){var v=ii(p).subarray(0,16);(function(D){var B=function(T,U,M){var H=T[U];T[U]=T[M],T[M]=H};B(D,0,3),B(D,1,2),B(D,4,5),B(D,6,7)})(v),this.keyId=v}}break;default:var w=a.subarray(0,16);if(w.length!==16){var C=new Uint8Array(16);C.set(w,16-w.length),w=C}this.keyId=w}if(!this.keyId||this.keyId.byteLength!==16){var k=Sn[this.uri];if(!k){var I=Object.keys(Sn).length%Number.MAX_SAFE_INTEGER;k=new Uint8Array(16),new DataView(k.buffer,12,4).setUint32(0,I),Sn[this.uri]=k}this.keyId=k}return this},d})(),ku=/\{\$([a-zA-Z0-9-_]+)\}/g;function Bu(d){return ku.test(d)}function Rt(d,s,t){if(d.variableList!==null||d.hasVariableRefs)for(var r=t.length;r--;){var a=t[r],o=s[a];o&&(s[a]=$s(d,o))}}function $s(d,s){if(d.variableList!==null||d.hasVariableRefs){var t=d.variableList;return s.replace(ku,function(r){var a=r.substring(2,r.length-1),o=t?.[a];return o===void 0?(d.playlistParsingError||(d.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'+a+'"')),r):o})}return s}function Iu(d,s,t){var r,a,o=d.variableList;if(o||(d.variableList=o={}),"QUERYPARAM"in s){r=s.QUERYPARAM;try{var l=new self.URL(t).searchParams;if(!l.has(r))throw new Error('"'+r+'" does not match any query parameter in URI: "'+t+'"');a=l.get(r)}catch(h){d.playlistParsingError||(d.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+h.message))}}else r=s.NAME,a=s.VALUE;r in o?d.playlistParsingError||(d.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'+r+'"')):o[r]=a||""}function Jp(d,s,t){var r=s.IMPORT;if(t&&r in t){var a=d.variableList;a||(d.variableList=a={}),a[r]=t[r]}else d.playlistParsingError||(d.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+r+'"'))}function xn(){if(typeof self<"u")return self.MediaSource||self.WebKitMediaSource}var _p={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},Su=xn();function el(d,s){var t;return(t=Su?.isTypeSupported((s||"video")+'/mp4;codecs="'+d+'"'))!=null&&t}var xu=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Tu=/#EXT-X-MEDIA:(.*)/g,jp=/^#EXT(?:INF|-X-TARGETDURATION):/m,Du=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Zp=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),pa=(function(){function d(){}return d.findGroup=function(s,t){for(var r=0;r<s.length;r++){var a=s[r];if(a.id===t)return a}},d.convertAVC1ToAVCOTI=function(s){var t=s.split(".");if(t.length>2){var r=t.shift()+".";return r+=parseInt(t.shift()).toString(16),r+=("000"+parseInt(t.shift()).toString(16)).slice(-4)}return s},d.resolve=function(s,t){return Ge.buildAbsoluteURL(t,s,{alwaysNormalize:!0})},d.isMediaPlaylist=function(s){return jp.test(s)},d.parseMasterPlaylist=function(s,t){var r,a={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Bu(s)},o=[];for(xu.lastIndex=0;(r=xu.exec(s))!=null;)if(r[1]){var l,h=new Ke(r[1]);Rt(a,h,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var u=$s(a,r[2]),f={attrs:h,bitrate:h.decimalInteger("AVERAGE-BANDWIDTH")||h.decimalInteger("BANDWIDTH"),name:h.NAME,url:d.resolve(u,t)},p=h.decimalResolution("RESOLUTION");p&&(f.width=p.width,f.height=p.height),$p((h.CODECS||"").split(/[ ,]+/).filter(function(T){return T}),f),f.videoCodec&&f.videoCodec.indexOf("avc1")!==-1&&(f.videoCodec=d.convertAVC1ToAVCOTI(f.videoCodec)),(l=f.unknownCodecs)!=null&&l.length||o.push(f),a.levels.push(f)}else if(r[3]){var v=r[3],w=r[4];switch(v){case"SESSION-DATA":var C=new Ke(w);Rt(a,C,["DATA-ID","LANGUAGE","VALUE","URI"]);var k=C["DATA-ID"];k&&(a.sessionData===null&&(a.sessionData={}),a.sessionData[k]=C);break;case"SESSION-KEY":var I=Ru(w,t,a);I.encrypted&&I.isSupported()?(a.sessionKeys===null&&(a.sessionKeys=[]),a.sessionKeys.push(I)):G.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+w+'"');break;case"DEFINE":var D=new Ke(w);Rt(a,D,["NAME","VALUE","QUERYPARAM"]),Iu(a,D,t);break;case"CONTENT-STEERING":var B=new Ke(w);Rt(a,B,["SERVER-URI","PATHWAY-ID"]),a.contentSteering={uri:d.resolve(B["SERVER-URI"],t),pathwayId:B["PATHWAY-ID"]||"."};break;case"START":a.startTimeOffset=Lu(w)}}return a.levels=o.length>0&&o.length<a.levels.length?o:a.levels,a.levels.length===0&&(a.playlistParsingError=new Error("no levels found in manifest")),a},d.parseMasterPlaylistMedia=function(s,t,r){var a,o={},l=r.levels,h={AUDIO:l.map(function(I){return{id:I.attrs.AUDIO,audioCodec:I.audioCodec}}),SUBTITLES:l.map(function(I){return{id:I.attrs.SUBTITLES,textCodec:I.textCodec}}),"CLOSED-CAPTIONS":[]},u=0;for(Tu.lastIndex=0;(a=Tu.exec(s))!==null;){var f=new Ke(a[1]),p=f.TYPE;if(p){var v=h[p],w=o[p]||[];o[p]=w,Rt(r,f,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var C={attrs:f,bitrate:0,id:u++,groupId:f["GROUP-ID"]||"",instreamId:f["INSTREAM-ID"],name:f.NAME||f.LANGUAGE||"",type:p,default:f.bool("DEFAULT"),autoselect:f.bool("AUTOSELECT"),forced:f.bool("FORCED"),lang:f.LANGUAGE,url:f.URI?d.resolve(f.URI,t):""};if(v!=null&&v.length){var k=d.findGroup(v,C.groupId)||v[0];Mu(C,k,"audioCodec"),Mu(C,k,"textCodec")}w.push(C)}}return o},d.parseLevelPlaylist=function(s,t,r,a,o,l){var h,u,f,p=new ga(t),v=p.fragments,w=null,C=0,k=0,I=0,D=0,B=null,T=new Ar(a,t),U=-1,M=!1;for(Du.lastIndex=0,p.m3u8=s,p.hasVariableRefs=Bu(s);(h=Du.exec(s))!==null;){M&&(M=!1,(T=new Ar(a,t)).start=I,T.sn=C,T.cc=D,T.level=r,w&&(T.initSegment=w,T.rawProgramDateTime=w.rawProgramDateTime,w.rawProgramDateTime=null));var H=h[1];if(H){T.duration=parseFloat(H);var V=(" "+h[2]).slice(1);T.title=V||null,T.tagList.push(V?["INF",H,V]:["INF",H])}else if(h[3]){if(se(T.duration)){T.start=I,f&&Pu(T,f,p),T.sn=C,T.level=r,T.cc=D,T.urlId=o,v.push(T);var W=(" "+h[3]).slice(1);T.relurl=$s(p,W),Fu(T,B),B=T,I+=T.duration,C++,k=0,M=!0}}else if(h[4]){var $=(" "+h[4]).slice(1);B?T.setByteRange($,B):T.setByteRange($)}else if(h[5])T.rawProgramDateTime=(" "+h[5]).slice(1),T.tagList.push(["PROGRAM-DATE-TIME",T.rawProgramDateTime]),U===-1&&(U=v.length);else{if(!(h=h[0].match(Zp))){G.warn("No matches on slow regex match for level playlist!");continue}for(u=1;u<h.length&&h[u]===void 0;u++);var J=(" "+h[u]).slice(1),j=(" "+h[u+1]).slice(1),le=h[u+2]?(" "+h[u+2]).slice(1):"";switch(J){case"PLAYLIST-TYPE":p.type=j.toUpperCase();break;case"MEDIA-SEQUENCE":C=p.startSN=parseInt(j);break;case"SKIP":var ie=new Ke(j);Rt(p,ie,["RECENTLY-REMOVED-DATERANGES"]);var me=ie.decimalInteger("SKIPPED-SEGMENTS");if(se(me)){p.skippedSegments=me;for(var we=me;we--;)v.unshift(null);C+=me}var ve=ie.enumeratedString("RECENTLY-REMOVED-DATERANGES");ve&&(p.recentlyRemovedDateranges=ve.split(" "));break;case"TARGETDURATION":p.targetduration=Math.max(parseInt(j),1);break;case"VERSION":p.version=parseInt(j);break;case"EXTM3U":break;case"ENDLIST":p.live=!1;break;case"#":(j||le)&&T.tagList.push(le?[j,le]:[j]);break;case"DISCONTINUITY":D++,T.tagList.push(["DIS"]);break;case"GAP":T.gap=!0,T.tagList.push([J]);break;case"BITRATE":T.tagList.push([J,j]);break;case"DATERANGE":var Ae=new Ke(j);Rt(p,Ae,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Rt(p,Ae,Ae.clientAttrs);var Ie=new mr(Ae,p.dateRanges[Ae.ID]);Ie.isValid||p.skippedSegments?p.dateRanges[Ie.id]=Ie:G.warn('Ignoring invalid DATERANGE tag: "'+j+'"'),T.tagList.push(["EXT-X-DATERANGE",j]);break;case"DEFINE":var fe=new Ke(j);Rt(p,fe,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in fe?Jp(p,fe,l):Iu(p,fe,t);break;case"DISCONTINUITY-SEQUENCE":D=parseInt(j);break;case"KEY":var Pe=Ru(j,t,p);if(Pe.isSupported()){if(Pe.method==="NONE"){f=void 0;break}f||(f={}),f[Pe.keyFormat]&&(f=Y({},f)),f[Pe.keyFormat]=Pe}else G.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+j+'"');break;case"START":p.startTimeOffset=Lu(j);break;case"MAP":var Ue=new Ke(j);if(Rt(p,Ue,["BYTERANGE","URI"]),T.duration){var ze=new Ar(a,t);Ou(ze,Ue,r,f),w=ze,T.initSegment=w,w.rawProgramDateTime&&!T.rawProgramDateTime&&(T.rawProgramDateTime=w.rawProgramDateTime)}else Ou(T,Ue,r,f),w=T,M=!0;break;case"SERVER-CONTROL":var je=new Ke(j);p.canBlockReload=je.bool("CAN-BLOCK-RELOAD"),p.canSkipUntil=je.optionalFloat("CAN-SKIP-UNTIL",0),p.canSkipDateRanges=p.canSkipUntil>0&&je.bool("CAN-SKIP-DATERANGES"),p.partHoldBack=je.optionalFloat("PART-HOLD-BACK",0),p.holdBack=je.optionalFloat("HOLD-BACK",0);break;case"PART-INF":p.partTarget=new Ke(j).decimalFloatingPoint("PART-TARGET");break;case"PART":var mt=p.partList;mt||(mt=p.partList=[]);var Tt=k>0?mt[mt.length-1]:void 0,ir=k++,Ht=new Ke(j);Rt(p,Ht,["BYTERANGE","URI"]);var Jt=new zr(Ht,T,t,ir,Tt);mt.push(Jt),T.duration+=Jt.duration;break;case"PRELOAD-HINT":var pt=new Ke(j);Rt(p,pt,["URI"]),p.preloadHint=pt;break;case"RENDITION-REPORT":var Ct=new Ke(j);Rt(p,Ct,["URI"]),p.renditionReports=p.renditionReports||[],p.renditionReports.push(Ct);break;default:G.warn("line parsed but not handled: "+h)}}}B&&!B.relurl?(v.pop(),I-=B.duration,p.partList&&(p.fragmentHint=B)):p.partList&&(Fu(T,B),T.cc=D,p.fragmentHint=T,f&&Pu(T,f,p));var ar=v.length,hi=v[0],Mt=v[ar-1];if((I+=p.skippedSegments*p.targetduration)>0&&ar&&Mt){p.averagetargetduration=I/ar;var Vn=Mt.sn;p.endSN=Vn!=="initSegment"?Vn:0,p.live||(Mt.endList=!0),hi&&(p.startCC=hi.cc)}else p.endSN=0,p.startCC=0;return p.fragmentHint&&(I+=p.fragmentHint.duration),p.totalduration=I,p.endCC=D,U>0&&(function(Sa,Wn){for(var Pi=Sa[Wn],ui=Wn;ui--;){var gi=Sa[ui];if(!gi)return;gi.programDateTime=Pi.programDateTime-1e3*gi.duration,Pi=gi}})(v,U),p},d})();function Ru(d,s,t){var r,a,o=new Ke(d);Rt(t,o,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var l=(r=o.METHOD)!=null?r:"",h=o.URI,u=o.hexadecimalInteger("IV"),f=o.KEYFORMATVERSIONS,p=(a=o.KEYFORMAT)!=null?a:"identity";return h&&o.IV&&!u&&G.error("Invalid IV: "+o.IV),new Zs(l,h?pa.resolve(h,s):"",p,(f||"1").split("/").map(Number).filter(Number.isFinite),u)}function Lu(d){var s=new Ke(d).decimalFloatingPoint("TIME-OFFSET");return se(s)?s:null}function $p(d,s){["video","audio","text"].forEach(function(t){var r=d.filter(function(o){return(function(l,h){var u=_p[h];return!!u&&u[l.slice(0,4)]===!0})(o,t)});if(r.length){var a=r.filter(function(o){return o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0});s[t+"Codec"]=a.length>0?a[0]:r[0],d=d.filter(function(o){return r.indexOf(o)===-1})}}),s.unknownCodecs=d}function Mu(d,s,t){var r=s[t];r&&(d[t]=r)}function Fu(d,s){d.rawProgramDateTime?d.programDateTime=Date.parse(d.rawProgramDateTime):s!=null&&s.programDateTime&&(d.programDateTime=s.endProgramDateTime),se(d.programDateTime)||(d.programDateTime=null,d.rawProgramDateTime=null)}function Ou(d,s,t,r){d.relurl=s.URI,s.BYTERANGE&&d.setByteRange(s.BYTERANGE),d.level=t,d.sn="initSegment",r&&(d.levelkeys=r),d.initSegment=null}function Pu(d,s,t){d.levelkeys=s;var r=t.encryptedFragments;r.length&&r[r.length-1].levelkeys===s||!Object.keys(s).some(function(a){return s[a].isCommonEncryption})||r.push(d)}var Bi="manifest",oi="level",wr="audioTrack",Fr="subtitleTrack",Je="main",Cr="audio",Wr="subtitle";function Uu(d){switch(d.type){case wr:return Cr;case Fr:return Wr;default:return Je}}function tl(d,s){var t=d.url;return t!==void 0&&t.indexOf("data:")!==0||(t=s.url),t}var em=(function(){function d(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}var s=d.prototype;return s.startLoad=function(t){},s.stopLoad=function(){this.destroyInternalLoaders()},s.registerListeners=function(){var t=this.hls;t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.LEVEL_LOADING,this.onLevelLoading,this),t.on(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},s.unregisterListeners=function(){var t=this.hls;t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.LEVEL_LOADING,this.onLevelLoading,this),t.off(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},s.createInternalLoader=function(t){var r=this.hls.config,a=r.pLoader,o=r.loader,l=new(a||o)(r);return this.loaders[t.type]=l,l},s.getInternalLoader=function(t){return this.loaders[t.type]},s.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},s.destroyInternalLoaders=function(){for(var t in this.loaders){var r=this.loaders[t];r&&r.destroy(),this.resetInternalLoader(t)}},s.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},s.onManifestLoading=function(t,r){var a=r.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Bi,url:a,deliveryDirectives:null})},s.onLevelLoading=function(t,r){var a=r.id,o=r.level,l=r.url,h=r.deliveryDirectives;this.load({id:a,level:o,responseType:"text",type:oi,url:l,deliveryDirectives:h})},s.onAudioTrackLoading=function(t,r){var a=r.id,o=r.groupId,l=r.url,h=r.deliveryDirectives;this.load({id:a,groupId:o,level:null,responseType:"text",type:wr,url:l,deliveryDirectives:h})},s.onSubtitleTrackLoading=function(t,r){var a=r.id,o=r.groupId,l=r.url,h=r.deliveryDirectives;this.load({id:a,groupId:o,level:null,responseType:"text",type:Fr,url:l,deliveryDirectives:h})},s.load=function(t){var r,a,o,l=this,h=this.hls.config,u=this.getInternalLoader(t);if(u){var f=u.context;if(f&&f.url===t.url)return void G.trace("[playlist-loader]: playlist request ongoing");G.log("[playlist-loader]: aborting previous loader for type: "+t.type),u.abort()}if(a=t.type===Bi?h.manifestLoadPolicy.default:Y({},h.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),u=this.createInternalLoader(t),(r=t.deliveryDirectives)!=null&&r.part&&(t.type===oi&&t.level!==null?o=this.hls.levels[t.level].details:t.type===wr&&t.id!==null?o=this.hls.audioTracks[t.id].details:t.type===Fr&&t.id!==null&&(o=this.hls.subtitleTracks[t.id].details),o)){var p=o.partTarget,v=o.targetduration;if(p&&v){var w=1e3*Math.max(3*p,.8*v);a=Y({},a,{maxTimeToFirstByteMs:Math.min(w,a.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(w,a.maxTimeToFirstByteMs)})}}var C=a.errorRetry||a.timeoutRetry||{},k={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:C.maxNumRetry||0,retryDelay:C.retryDelayMs||0,maxRetryDelay:C.maxRetryDelayMs||0};u.load(t,k,{onSuccess:function(I,D,B,T){var U=l.getInternalLoader(B);l.resetInternalLoader(B.type);var M=I.data;M.indexOf("#EXTM3U")===0?(D.parsing.start=performance.now(),pa.isMediaPlaylist(M)?l.handleTrackOrLevelPlaylist(I,D,B,T||null,U):l.handleMasterPlaylist(I,D,B,T)):l.handleManifestParsingError(I,B,new Error("no EXTM3U delimiter"),T||null,D)},onError:function(I,D,B,T){l.handleNetworkError(D,B,!1,I,T)},onTimeout:function(I,D,B){l.handleNetworkError(D,B,!0,void 0,I)}})},s.handleMasterPlaylist=function(t,r,a,o){var l=this.hls,h=t.data,u=tl(t,a),f=pa.parseMasterPlaylist(h,u);if(f.playlistParsingError)this.handleManifestParsingError(t,a,f.playlistParsingError,o,r);else{var p=f.contentSteering,v=f.levels,w=f.sessionData,C=f.sessionKeys,k=f.startTimeOffset,I=f.variableList;this.variableList=I;var D=pa.parseMasterPlaylistMedia(h,u,f),B=D.AUDIO,T=B===void 0?[]:B,U=D.SUBTITLES,M=D["CLOSED-CAPTIONS"];T.length&&(T.some(function(H){return!H.url})||!v[0].audioCodec||v[0].attrs.AUDIO||(G.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),T.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Ke({}),bitrate:0,url:""}))),l.trigger(x.MANIFEST_LOADED,{levels:v,audioTracks:T,subtitles:U,captions:M,contentSteering:p,url:u,stats:r,networkDetails:o,sessionData:w,sessionKeys:C,startTimeOffset:k,variableList:I})}},s.handleTrackOrLevelPlaylist=function(t,r,a,o,l){var h=this.hls,u=a.id,f=a.level,p=a.type,v=tl(t,a),w=se(u)?u:0,C=se(f)?f:w,k=Uu(a),I=pa.parseLevelPlaylist(t.data,v,C,k,w,this.variableList);if(p===Bi){var D={attrs:new Ke({}),bitrate:0,details:I,name:"",url:v};h.trigger(x.MANIFEST_LOADED,{levels:[D],audioTracks:[],url:v,stats:r,networkDetails:o,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}r.parsing.end=performance.now(),a.levelDetails=I,this.handlePlaylistLoaded(I,t,r,a,o,l)},s.handleManifestParsingError=function(t,r,a,o,l){this.hls.trigger(x.ERROR,{type:ue.NETWORK_ERROR,details:q.MANIFEST_PARSING_ERROR,fatal:r.type===Bi,url:t.url,err:a,error:a,reason:a.message,response:t,context:r,networkDetails:o,stats:l})},s.handleNetworkError=function(t,r,a,o,l){a===void 0&&(a=!1);var h="A network "+(a?"timeout":"error"+(o?" (status "+o.code+")":""))+" occurred while loading "+t.type;t.type===oi?h+=": "+t.level+" id: "+t.id:t.type!==wr&&t.type!==Fr||(h+=" id: "+t.id+' group-id: "'+t.groupId+'"');var u=new Error(h);G.warn("[playlist-loader]: "+h);var f=q.UNKNOWN,p=!1,v=this.getInternalLoader(t);switch(t.type){case Bi:f=a?q.MANIFEST_LOAD_TIMEOUT:q.MANIFEST_LOAD_ERROR,p=!0;break;case oi:f=a?q.LEVEL_LOAD_TIMEOUT:q.LEVEL_LOAD_ERROR,p=!1;break;case wr:f=a?q.AUDIO_TRACK_LOAD_TIMEOUT:q.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case Fr:f=a?q.SUBTITLE_TRACK_LOAD_TIMEOUT:q.SUBTITLE_LOAD_ERROR,p=!1}v&&this.resetInternalLoader(t.type);var w={type:ue.NETWORK_ERROR,details:f,fatal:p,url:t.url,loader:v,context:t,error:u,networkDetails:r,stats:l};o&&(w.response=E({url:r?.url||t.url,data:void 0},o)),this.hls.trigger(x.ERROR,w)},s.handlePlaylistLoaded=function(t,r,a,o,l,h){var u=this.hls,f=o.type,p=o.level,v=o.id,w=o.groupId,C=o.deliveryDirectives,k=tl(r,o),I=Uu(o),D=typeof o.level=="number"&&I===Je?p:void 0;if(t.fragments.length){t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));var B=t.playlistParsingError;if(B)u.trigger(x.ERROR,{type:ue.NETWORK_ERROR,details:q.LEVEL_PARSING_ERROR,fatal:!1,url:k,error:B,reason:B.message,response:r,context:o,level:D,parent:I,networkDetails:l,stats:a});else switch(t.live&&h&&(h.getCacheAge&&(t.ageHeader=h.getCacheAge()||0),h.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),f){case Bi:case oi:u.trigger(x.LEVEL_LOADED,{details:t,level:D||0,id:v||0,stats:a,networkDetails:l,deliveryDirectives:C});break;case wr:u.trigger(x.AUDIO_TRACK_LOADED,{details:t,id:v||0,groupId:w||"",stats:a,networkDetails:l,deliveryDirectives:C});break;case Fr:u.trigger(x.SUBTITLE_TRACK_LOADED,{details:t,id:v||0,groupId:w||"",stats:a,networkDetails:l,deliveryDirectives:C})}}else{var T=new Error("No Segments found in Playlist");u.trigger(x.ERROR,{type:ue.NETWORK_ERROR,details:q.LEVEL_EMPTY_ERROR,fatal:!1,url:k,error:T,reason:T.message,response:r,context:o,level:D,parent:I,networkDetails:l,stats:a})}},d})();function Qu(d,s){var t;try{t=new Event("addtrack")}catch{(t=document.createEvent("Event")).initEvent("addtrack",!1,!1)}t.track=d,s.dispatchEvent(t)}function Nu(d,s){var t=d.mode;if(t==="disabled"&&(d.mode="hidden"),d.cues&&!d.cues.getCueById(s.id))try{if(d.addCue(s),!d.cues.getCueById(s.id))throw new Error("addCue is failed for: "+s)}catch(a){G.debug("[texttrack-utils]: "+a);try{var r=new self.TextTrackCue(s.startTime,s.endTime,s.text);r.id=s.id,d.addCue(r)}catch(o){G.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+o)}}t==="disabled"&&(d.mode=t)}function Ii(d){var s=d.mode;if(s==="disabled"&&(d.mode="hidden"),d.cues)for(var t=d.cues.length;t--;)d.removeCue(d.cues[t]);s==="disabled"&&(d.mode=s)}function rl(d,s,t,r){var a=d.mode;if(a==="disabled"&&(d.mode="hidden"),d.cues&&d.cues.length>0)for(var o=(function(h,u,f){var p=[],v=(function(I,D){if(D<I[0].startTime)return 0;var B=I.length-1;if(D>I[B].endTime)return-1;for(var T=0,U=B;T<=U;){var M=Math.floor((U+T)/2);if(D<I[M].startTime)U=M-1;else{if(!(D>I[M].startTime&&T<B))return M;T=M+1}}return I[T].startTime-D<D-I[U].startTime?T:U})(h,u);if(v>-1)for(var w=v,C=h.length;w<C;w++){var k=h[w];if(k.startTime>=u&&k.endTime<=f)p.push(k);else if(k.startTime>f)return p}return p})(d.cues,s,t),l=0;l<o.length;l++)r&&!r(o[l])||d.removeCue(o[l]);a==="disabled"&&(d.mode=a)}var ma="org.id3",tm="com.apple.quicktime.HLS",va="https://aomedia.org/emsg/ID3";function il(){if(typeof self<"u")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var Tn=(function(){var d=il();try{new d(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function al(d,s){return d.getTime()/1e3-s}var rm=(function(){function d(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}var s=d.prototype;return s.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},s._registerListeners=function(){var t=this.hls;t.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(x.LEVEL_UPDATED,this.onLevelUpdated,this)},s._unregisterListeners=function(){var t=this.hls;t.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(x.LEVEL_UPDATED,this.onLevelUpdated,this)},s.onMediaAttached=function(t,r){this.media=r.media},s.onMediaDetaching=function(){this.id3Track&&(Ii(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},s.onManifestLoading=function(){this.dateRangeCuesAppended={}},s.createTrack=function(t){var r=this.getID3Track(t.textTracks);return r.mode="hidden",r},s.getID3Track=function(t){if(this.media){for(var r=0;r<t.length;r++){var a=t[r];if(a.kind==="metadata"&&a.label==="id3")return Qu(a,this.media),a}return this.media.addTextTrack("metadata","id3")}},s.onFragParsingMetadata=function(t,r){if(this.media){var a=this.hls.config,o=a.enableEmsgMetadataCues,l=a.enableID3MetadataCues;if(o||l){var h=r.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var u=il(),f=0;f<h.length;f++){var p=h[f].type;if((p!==va||o)&&l){var v=pu(h[f].data);if(v){var w=h[f].pts,C=w+h[f].duration;C>Tn&&(C=Tn),C-w<=0&&(C=w+.25);for(var k=0;k<v.length;k++){var I=v[k];if(!fu(I)){this.updateId3CueEnds(w,p);var D=new u(w,C,"");D.value=I,p&&(D.type=p),this.id3Track.addCue(D)}}}}}}}},s.updateId3CueEnds=function(t,r){var a,o=(a=this.id3Track)==null?void 0:a.cues;if(o)for(var l=o.length;l--;){var h=o[l];h.type===r&&h.startTime<t&&h.endTime===Tn&&(h.endTime=t)}},s.onBufferFlushing=function(t,r){var a=r.startOffset,o=r.endOffset,l=r.type,h=this.id3Track,u=this.hls;if(u){var f=u.config,p=f.enableEmsgMetadataCues,v=f.enableID3MetadataCues;h&&(p||v)&&rl(h,a,o,l==="audio"?function(w){return w.type===ma&&v}:l==="video"?function(w){return w.type===va&&p}:function(w){return w.type===ma&&v||w.type===va&&p})}},s.onLevelUpdated=function(t,r){var a=this,o=r.details;if(this.media&&o.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var l=this.dateRangeCuesAppended,h=this.id3Track,u=o.dateRanges,f=Object.keys(u);if(h)for(var p=Object.keys(l).filter(function(T){return!f.includes(T)}),v=function(){var T=p[w];Object.keys(l[T].cues).forEach(function(U){h.removeCue(l[T].cues[U])}),delete l[T]},w=p.length;w--;)v();var C=o.fragments[o.fragments.length-1];if(f.length!==0&&se(C?.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var k=C.programDateTime/1e3-C.start,I=il(),D=function(){var T=f[B],U=u[T],M=l[T],H=M?.cues||{},V=M?.durationKnown||!1,W=al(U.startDate,k),$=Tn,J=U.endDate;if(J)$=al(J,k),V=!0;else if(U.endOnNext&&!V){var j=f.reduce(function(fe,Pe){var Ue=u[Pe];return Ue.class===U.class&&Ue.id!==Pe&&Ue.startDate>U.startDate&&fe.push(Ue),fe},[]).sort(function(fe,Pe){return fe.startDate.getTime()-Pe.startDate.getTime()})[0];j&&($=al(j.startDate,k),V=!0)}for(var le,ie,me=Object.keys(U.attr),we=0;we<me.length;we++){var ve=me[we];if((ie=ve)!=="ID"&&ie!=="CLASS"&&ie!=="START-DATE"&&ie!=="DURATION"&&ie!=="END-DATE"&&ie!=="END-ON-NEXT"){var Ae=H[ve];if(Ae)V&&!M.durationKnown&&(Ae.endTime=$);else{var Ie=U.attr[ve];Ae=new I(W,$,""),It(ve)&&(le=Ie,Ie=Uint8Array.from(le.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),Ae.value={key:ve,data:Ie},Ae.type=tm,Ae.id=T,a.id3Track.addCue(Ae),H[ve]=Ae}}}l[T]={cues:H,dateRange:U,durationKnown:V}},B=0;B<f.length;B++)D()}}},d})(),im=(function(){function d(t){var r=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return r.timeupdate()},this.hls=t,this.config=t.config,this.registerListeners()}var s=d.prototype;return s.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},s.registerListeners=function(){this.hls.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(x.ERROR,this.onError,this)},s.unregisterListeners=function(){this.hls.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(x.ERROR,this.onError,this)},s.onMediaAttached=function(t,r){this.media=r.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},s.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},s.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},s.onLevelUpdated=function(t,r){var a=r.details;this.levelDetails=a,a.advanced&&this.timeupdate(),!a.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},s.onError=function(t,r){var a;r.details===q.BUFFER_STALLED_ERROR&&(this.stallCount++,(a=this.levelDetails)!=null&&a.live&&G.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},s.timeupdate=function(){var t=this.media,r=this.levelDetails;if(t&&r){this.currentTime=t.currentTime;var a=this.computeLatency();if(a!==null){this._latency=a;var o=this.config,l=o.lowLatencyMode,h=o.maxLiveSyncPlaybackRate;if(l&&h!==1){var u=this.targetLatency;if(u!==null){var f=a-u,p=f<Math.min(this.maxLatency,u+r.targetduration);if(r.live&&p&&f>.05&&this.forwardBufferLength>1){var v=Math.min(2,Math.max(1,h)),w=Math.round(2/(1+Math.exp(-.75*f-this.edgeStalled))*20)/20;t.playbackRate=Math.min(v,Math.max(1,w))}else t.playbackRate!==1&&t.playbackRate!==0&&(t.playbackRate=1)}}}}},s.estimateLiveEdge=function(){var t=this.levelDetails;return t===null?null:t.edge+t.age},s.computeLatency=function(){var t=this.estimateLiveEdge();return t===null?null:t-this.currentTime},F(d,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config,r=this.levelDetails;return t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:r?t.liveMaxLatencyDurationCount*r.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(t===null)return null;var r=t.holdBack,a=t.partHoldBack,o=t.targetduration,l=this.config,h=l.liveSyncDuration,u=l.liveSyncDurationCount,f=l.lowLatencyMode,p=this.hls.userConfig,v=f&&a||r;(p.liveSyncDuration||p.liveSyncDurationCount||v===0)&&(v=h!==void 0?h:u*o);var w=o;return v+Math.min(1*this.stallCount,w)}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),r=this.targetLatency,a=this.levelDetails;if(t===null||r===null||a===null)return null;var o=a.edge,l=t-r-this.edgeStalled,h=o-a.totalduration,u=o-(this.config.lowLatencyMode&&a.partTarget||a.targetduration);return Math.min(Math.max(h,l),u)}},{key:"drift",get:function(){var t=this.levelDetails;return t===null?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;if(t===null)return 0;var r=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-r,0)}},{key:"forwardBufferLength",get:function(){var t=this.media,r=this.levelDetails;if(!t||!r)return 0;var a=t.buffered.length;return(a?t.buffered.end(a-1):r.edge)-this.currentTime}}]),d})(),nl=["NONE","TYPE-0","TYPE-1",null],ol="",am="YES",nm="v2",Hu=(function(){function d(s,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=s,this.part=t,this.skip=r}return d.prototype.addDirectives=function(s){var t=new self.URL(s);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},d})(),Aa=(function(){function d(s){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[s.url],this._attrs=[s.attrs],this.bitrate=s.bitrate,s.details&&(this.details=s.details),this.id=s.id||0,this.name=s.name,this.width=s.width||0,this.height=s.height||0,this.audioCodec=s.audioCodec,this.videoCodec=s.videoCodec,this.unknownCodecs=s.unknownCodecs,this.codecSet=[s.videoCodec,s.audioCodec].filter(function(t){return t}).join(",").replace(/\.[^.,]+/g,"")}return d.prototype.addFallback=function(s){this.url.push(s.url),this._attrs.push(s.attrs)},F(d,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"attrs",get:function(){return this._attrs[this._urlId]}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(s){var t=s%this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}},{key:"audioGroupId",get:function(){var s;return(s=this.audioGroupIds)==null?void 0:s[this.urlId]}},{key:"textGroupId",get:function(){var s;return(s=this.textGroupIds)==null?void 0:s[this.urlId]}}]),d})();function sl(d,s){var t=s.startPTS;if(se(t)){var r,a=0;s.sn>d.sn?(a=t-d.start,r=d):(a=d.start-t,r=s),r.duration!==a&&(r.duration=a)}else s.sn>d.sn?d.cc===s.cc&&d.minEndPTS?s.start=d.start+(d.minEndPTS-d.start):s.start=d.start+d.duration:s.start=Math.max(d.start-s.duration,0)}function Gu(d,s,t,r,a,o){r-t<=0&&(G.warn("Fragment should have a positive duration",s),r=t+s.duration,o=a+s.duration);var l=t,h=r,u=s.startPTS,f=s.endPTS;if(se(u)){var p=Math.abs(u-t);se(s.deltaPTS)?s.deltaPTS=Math.max(p,s.deltaPTS):s.deltaPTS=p,l=Math.max(t,u),t=Math.min(t,u),a=Math.min(a,s.startDTS),h=Math.min(r,f),r=Math.max(r,f),o=Math.max(o,s.endDTS)}var v=t-s.start;s.start!==0&&(s.start=t),s.duration=r-s.start,s.startPTS=t,s.maxStartPTS=l,s.startDTS=a,s.endPTS=r,s.minEndPTS=h,s.endDTS=o;var w,C=s.sn;if(!d||C<d.startSN||C>d.endSN)return 0;var k=C-d.startSN,I=d.fragments;for(I[k]=s,w=k;w>0;w--)sl(I[w],I[w-1]);for(w=k;w<I.length-1;w++)sl(I[w],I[w+1]);return d.fragmentHint&&sl(I[I.length-1],d.fragmentHint),d.PTSKnown=d.alignedSliding=!0,v}function om(d,s){for(var t=null,r=d.fragments,a=r.length-1;a>=0;a--){var o=r[a].initSegment;if(o){t=o;break}}d.fragmentHint&&delete d.fragmentHint.endPTS;var l,h,u,f,p,v=0;if((function(B,T,U){for(var M=T.skippedSegments,H=Math.max(B.startSN,T.startSN)-T.startSN,V=(B.fragmentHint?1:0)+(M?T.endSN:Math.min(B.endSN,T.endSN))-T.startSN,W=T.startSN-B.startSN,$=T.fragmentHint?T.fragments.concat(T.fragmentHint):T.fragments,J=B.fragmentHint?B.fragments.concat(B.fragmentHint):B.fragments,j=H;j<=V;j++){var le=J[W+j],ie=$[j];M&&!ie&&j<M&&(ie=T.fragments[j]=le),le&&ie&&U(le,ie)}})(d,s,function(B,T){B.relurl&&(v=B.cc-T.cc),se(B.startPTS)&&se(B.endPTS)&&(T.start=T.startPTS=B.startPTS,T.startDTS=B.startDTS,T.maxStartPTS=B.maxStartPTS,T.endPTS=B.endPTS,T.endDTS=B.endDTS,T.minEndPTS=B.minEndPTS,T.duration=B.endPTS-B.startPTS,T.duration&&(l=T),s.PTSKnown=s.alignedSliding=!0),T.elementaryStreams=B.elementaryStreams,T.loader=B.loader,T.stats=B.stats,T.urlId=B.urlId,B.initSegment&&(T.initSegment=B.initSegment,t=B.initSegment)}),t&&(s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments).forEach(function(B){var T;B.initSegment&&B.initSegment.relurl!==((T=t)==null?void 0:T.relurl)||(B.initSegment=t)}),s.skippedSegments)if(s.deltaUpdateFailed=s.fragments.some(function(B){return!B}),s.deltaUpdateFailed){G.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var w=s.skippedSegments;w--;)s.fragments.shift();s.startSN=s.fragments[0].sn,s.startCC=s.fragments[0].cc}else s.canSkipDateRanges&&(s.dateRanges=(h=d.dateRanges,u=s.dateRanges,f=s.recentlyRemovedDateranges,p=Y({},h),f&&f.forEach(function(B){delete p[B]}),Object.keys(u).forEach(function(B){var T=new mr(u[B].attr,p[B]);T.isValid?p[B]=T:G.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(u[B].attr)+'"')}),p));var C=s.fragments;if(v){G.warn("discontinuity sliding from playlist, take drift into account");for(var k=0;k<C.length;k++)C[k].cc+=v}s.skippedSegments&&(s.startCC=s.fragments[0].cc),(function(B,T,U){if(B&&T)for(var M=0,H=0,V=B.length;H<=V;H++){var W=B[H],$=T[H+M];W&&$&&W.index===$.index&&W.fragment.sn===$.fragment.sn?U(W,$):M--}})(d.partList,s.partList,function(B,T){T.elementaryStreams=B.elementaryStreams,T.stats=B.stats}),l?Gu(s,l,l.startPTS,l.endPTS,l.startDTS,l.endDTS):Yu(d,s),C.length&&(s.totalduration=s.edge-C[0].start),s.driftStartTime=d.driftStartTime,s.driftStart=d.driftStart;var I=s.advancedDateTime;if(s.advanced&&I){var D=s.edge;s.driftStart||(s.driftStartTime=I,s.driftStart=D),s.driftEndTime=I,s.driftEnd=D}else s.driftEndTime=d.driftEndTime,s.driftEnd=d.driftEnd,s.advancedDateTime=d.advancedDateTime}function Yu(d,s){var t=s.startSN+s.skippedSegments-d.startSN,r=d.fragments;t<0||t>=r.length||ll(s,r[t].start)}function ll(d,s){if(s){for(var t=d.fragments,r=d.skippedSegments;r<t.length;r++)t[r].start+=s;d.fragmentHint&&(d.fragmentHint.start+=s)}}function Ku(d,s,t){var r;return d!=null&&d.details?zu((r=d.details)==null?void 0:r.partList,s,t):null}function zu(d,s,t){if(d)for(var r=d.length;r--;){var a=d[r];if(a.index===t&&a.fragment.sn===s)return a}return null}function Dn(d){switch(d.details){case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_TIMEOUT:case q.LEVEL_LOAD_TIMEOUT:case q.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function qu(d,s){var t=Dn(s);return d.default[(t?"timeout":"error")+"Retry"]}function cl(d,s){var t=d.backoff==="linear"?1:Math.pow(2,s);return Math.min(t*d.retryDelayMs,d.maxRetryDelayMs)}function Vu(d){return E(E({},d),{errorRetry:null,timeoutRetry:null})}function Rn(d,s,t,r){return!!d&&s<d.maxNumRetry&&((function(a){return a===0&&navigator.onLine===!1||!!a&&(a<400||a>499)})(r)||!!t)}var Wu=function(d,s){for(var t=0,r=d.length-1,a=null,o=null;t<=r;){var l=s(o=d[a=(t+r)/2|0]);if(l>0)t=a+1;else{if(!(l<0))return o;r=a-1}}return null};function ba(d,s,t,r){t===void 0&&(t=0),r===void 0&&(r=0);var a=null;if(d?a=s[d.sn-s[0].sn+1]||null:t===0&&s[0].start===0&&(a=s[0]),a&&dl(t,r,a)===0)return a;var o=Wu(s,dl.bind(null,t,r));return!o||o===d&&a?a:o}function dl(d,s,t){if(d===void 0&&(d=0),s===void 0&&(s=0),t.start<=d&&t.start+t.duration>d)return 0;var r=Math.min(s,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-r<=d?1:t.start-r>d&&t.start?-1:0}function sm(d,s,t){var r=1e3*Math.min(s,t.duration+(t.deltaPTS?t.deltaPTS:0));return(t.endProgramDateTime||0)-r>d}var hl,lm=3e5,ul=0,Or=2,Ln=5,Si=0,Mn=1,Xu=2,cm=(function(){function d(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=G.log.bind(G,"[info]:"),this.warn=G.warn.bind(G,"[warning]:"),this.error=G.error.bind(G,"[error]:"),this.registerListeners()}var s=d.prototype;return s.registerListeners=function(){var t=this.hls;t.on(x.ERROR,this.onError,this),t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.LEVEL_UPDATED,this.onLevelUpdated,this)},s.unregisterListeners=function(){var t=this.hls;t&&(t.off(x.ERROR,this.onError,this),t.off(x.ERROR,this.onErrorOut,this),t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.LEVEL_UPDATED,this.onLevelUpdated,this))},s.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},s.startLoad=function(t){this.playlistError=0},s.stopLoad=function(){},s.getVariantLevelIndex=function(t){return t?.type===Je?t.level:this.hls.loadLevel},s.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},s.onLevelUpdated=function(){this.playlistError=0},s.onError=function(t,r){var a,o;if(!r.fatal){var l=this.hls,h=r.context;switch(r.details){case q.FRAG_LOAD_ERROR:case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_ERROR:case q.KEY_LOAD_TIMEOUT:r.errorAction=this.getFragRetryOrSwitchAction(r);return;case q.FRAG_PARSING_ERROR:if((a=r.frag)!=null&&a.gap)return void(r.errorAction={action:ul,flags:Si});case q.FRAG_GAP:case q.FRAG_DECRYPT_ERROR:r.errorAction=this.getFragRetryOrSwitchAction(r),r.errorAction.action=Or;return;case q.LEVEL_EMPTY_ERROR:case q.LEVEL_PARSING_ERROR:var u,f,p=r.parent===Je?r.level:l.loadLevel;r.details===q.LEVEL_EMPTY_ERROR&&(u=r.context)!=null&&(f=u.levelDetails)!=null&&f.live?r.errorAction=this.getPlaylistRetryOrSwitchAction(r,p):(r.levelRetry=!1,r.errorAction=this.getLevelSwitchAction(r,p));return;case q.LEVEL_LOAD_ERROR:case q.LEVEL_LOAD_TIMEOUT:typeof h?.level=="number"&&(r.errorAction=this.getPlaylistRetryOrSwitchAction(r,h.level));return;case q.AUDIO_TRACK_LOAD_ERROR:case q.AUDIO_TRACK_LOAD_TIMEOUT:case q.SUBTITLE_LOAD_ERROR:case q.SUBTITLE_TRACK_LOAD_TIMEOUT:if(h){var v=l.levels[l.loadLevel];if(v&&(h.type===wr&&h.groupId===v.audioGroupId||h.type===Fr&&h.groupId===v.textGroupId))return r.errorAction=this.getPlaylistRetryOrSwitchAction(r,l.loadLevel),r.errorAction.action=Or,void(r.errorAction.flags=Mn)}return;case q.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var w=l.levels[l.loadLevel],C=w?.attrs["HDCP-LEVEL"];C&&(r.errorAction={action:Or,flags:Xu,hdcpLevel:C});return;case q.BUFFER_ADD_CODEC_ERROR:case q.REMUX_ALLOC_ERROR:r.errorAction=this.getLevelSwitchAction(r,(o=r.level)!=null?o:l.loadLevel);return;case q.INTERNAL_EXCEPTION:case q.BUFFER_APPENDING_ERROR:case q.BUFFER_APPEND_ERROR:case q.BUFFER_FULL_ERROR:case q.LEVEL_SWITCH_ERROR:case q.BUFFER_STALLED_ERROR:case q.BUFFER_SEEK_OVER_HOLE:case q.BUFFER_NUDGE_ON_STALL:r.errorAction={action:ul,flags:Si};return}if(r.type===ue.KEY_SYSTEM_ERROR){var k=this.getVariantLevelIndex(r.frag);r.levelRetry=!1,r.errorAction=this.getLevelSwitchAction(r,k);return}}},s.getPlaylistRetryOrSwitchAction=function(t,r){var a,o=qu(this.hls.config.playlistLoadPolicy,t),l=this.playlistError++,h=(a=t.response)==null?void 0:a.code;if(Rn(o,l,Dn(t),h))return{action:Ln,flags:Si,retryConfig:o,retryCount:l};var u=this.getLevelSwitchAction(t,r);return o&&(u.retryConfig=o,u.retryCount=l),u},s.getFragRetryOrSwitchAction=function(t){var r=this.hls,a=this.getVariantLevelIndex(t.frag),o=r.levels[a],l=r.config,h=l.fragLoadPolicy,u=l.keyLoadPolicy,f=qu(t.details.startsWith("key")?u:h,t),p=r.levels.reduce(function(k,I){return k+I.fragmentError},0);if(o){var v;t.details!==q.FRAG_GAP&&o.fragmentError++;var w=(v=t.response)==null?void 0:v.code;if(Rn(f,p,Dn(t),w))return{action:Ln,flags:Si,retryConfig:f,retryCount:p}}var C=this.getLevelSwitchAction(t,a);return f&&(C.retryConfig=f,C.retryCount=p),C},s.getLevelSwitchAction=function(t,r){var a=this.hls;r??=a.loadLevel;var o=this.hls.levels[r];if(o&&(o.loadError++,a.autoLevelEnabled)){for(var l,h,u=-1,f=a.levels,p=a.loadLevel,v=a.minAutoLevel,w=a.maxAutoLevel,C=(l=t.frag)==null?void 0:l.type,k=(h=t.context)!=null?h:{},I=k.type,D=k.groupId,B=f.length;B--;){var T=(B+p)%f.length;if(T!==p&&T>=v&&T<=w&&f[T].loadError===0){var U=f[T];if(t.details===q.FRAG_GAP&&t.frag){var M=f[T].details;if(M){var H=ba(t.frag,M.fragments,t.frag.start);if(H!=null&&H.gap)continue}}else if(I===wr&&D===U.audioGroupId||I===Fr&&D===U.textGroupId||C===Cr&&o.audioGroupId===U.audioGroupId||C===Wr&&o.textGroupId===U.textGroupId)continue;u=T;break}}if(u>-1&&a.loadLevel!==u)return t.levelRetry=!0,this.playlistError=0,{action:Or,flags:Si,nextAutoLevel:u}}return{action:Or,flags:Mn}},s.onErrorOut=function(t,r){var a;switch((a=r.errorAction)==null?void 0:a.action){case ul:break;case Or:this.sendAlternateToPenaltyBox(r),r.errorAction.resolved||r.details===q.FRAG_GAP||(r.fatal=!0)}r.fatal&&this.hls.stopLoad()},s.sendAlternateToPenaltyBox=function(t){var r=this.hls,a=t.errorAction;if(a){var o=a.flags,l=a.hdcpLevel,h=a.nextAutoLevel;switch(o){case Si:this.switchLevel(t,h);break;case Mn:a.resolved||(a.resolved=this.redundantFailover(t));break;case Xu:l&&(r.maxHdcpLevel=nl[nl.indexOf(l)-1],a.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+r.maxHdcpLevel+'" or lower')}a.resolved||this.switchLevel(t,h)}},s.switchLevel=function(t,r){r!==void 0&&t.errorAction&&(this.warn("switching to level "+r+" after "+t.details),this.hls.nextAutoLevel=r,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},s.redundantFailover=function(t){var r=this,a=this.hls,o=this.penalizedRenditions,l=t.parent===Je?t.level:a.loadLevel,h=a.levels[l],u=h.url.length,f=t.frag?t.frag.urlId:h.urlId;h.urlId!==f||t.frag&&!h.details||this.penalizeRendition(h,t);for(var p=function(){var C=(f+v)%u,k=o[C];if(!k||(function(I,D,B){if(performance.now()-I.lastErrorPerfMs>lm)return!0;var T=I.details;if(D.details===q.FRAG_GAP&&T&&D.frag){var U=D.frag.start,M=ba(null,T.fragments,U);if(M&&!M.gap)return!0}if(B&&I.errors.length<B.errors.length){var H=I.errors[I.errors.length-1];if(T&&H.frag&&D.frag&&Math.abs(H.frag.start-D.frag.start)>3*T.targetduration)return!0}return!1})(k,t,o[f]))return r.warn("Switching to Redundant Stream "+(C+1)+"/"+u+': "'+h.url[C]+'" after '+t.details),r.playlistError=0,a.levels.forEach(function(I){I.urlId=C}),a.nextLoadLevel=l,{v:!0}},v=1;v<u;v++){var w=p();if(typeof w=="object")return w.v}return!1},s.penalizeRendition=function(t,r){var a=this.penalizedRenditions,o=a[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};o.lastErrorPerfMs=performance.now(),o.errors.push(r),o.details=t.details,a[t.urlId]=o},d})(),gl=(function(){function d(t,r){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=G.log.bind(G,r+":"),this.warn=G.warn.bind(G,r+":"),this.hls=t}var s=d.prototype;return s.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},s.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},s.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},s.stopLoad=function(){this.canLoad=!1,this.clearTimer()},s.switchParams=function(t,r){var a=r?.renditionReports;if(a){for(var o=-1,l=0;l<a.length;l++){var h=a[l],u=void 0;try{u=new self.URL(h.URI,r.url).href}catch(C){G.warn("Could not construct new URL for Rendition Report: "+C),u=h.URI||""}if(u===t){o=l;break}u===t.substring(0,u.length)&&(o=l)}if(o!==-1){var f=a[o],p=parseInt(f["LAST-MSN"])||r?.lastPartSn,v=parseInt(f["LAST-PART"])||r?.lastPartIndex;if(this.hls.config.lowLatencyMode){var w=Math.min(r.age-r.partTarget,r.targetduration);v>=0&&w>r.partTarget&&(v+=1)}return new Hu(p,v>=0?v:void 0,ol)}}},s.loadPlaylist=function(t){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},s.shouldLoadPlaylist=function(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)},s.shouldReloadPlaylist=function(t){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(t)},s.playlistLoaded=function(t,r,a){var o=this,l=r.details,h=r.stats,u=self.performance.now(),f=h.loading.first?Math.max(0,u-h.loading.first):0;if(l.advancedDateTime=Date.now()-f,l.live||a!=null&&a.live){if(l.reloaded(a),a&&this.log("live playlist "+t+" "+(l.advanced?"REFRESHED "+l.lastPartSn+"-"+l.lastPartIndex:l.updated?"UPDATED":"MISSED")),a&&l.fragments.length>0&&om(a,l),!this.canLoad||!l.live)return;var p,v=void 0,w=void 0;if(l.canBlockReload&&l.endSN&&l.advanced){var C=this.hls.config.lowLatencyMode,k=l.lastPartSn,I=l.endSN,D=l.lastPartIndex,B=k===I;D!==-1?(v=B?I+1:k,w=B?C?0:D:D+1):v=I+1;var T=l.age,U=T+l.ageHeader,M=Math.min(U-l.partTarget,1.5*l.targetduration);if(M>0){if(a&&M>a.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+a.tuneInGoal+" to: "+M+" with playlist age: "+l.age),M=0;else{var H=Math.floor(M/l.targetduration);v+=H,w!==void 0&&(w+=Math.round(M%l.targetduration/l.partTarget)),this.log("CDN Tune-in age: "+l.ageHeader+"s last advanced "+T.toFixed(2)+"s goal: "+M+" skip sn "+H+" to part "+w)}l.tuneInGoal=M}if(p=this.getDeliveryDirectives(l,r.deliveryDirectives,v,w),C||!B)return void this.loadPlaylist(p)}else(l.canBlockReload||l.canSkipUntil)&&(p=this.getDeliveryDirectives(l,r.deliveryDirectives,v,w));var V=this.hls.mainForwardBufferInfo,W=V?V.end-V.len:0,$=(function(j,le){le===void 0&&(le=1/0);var ie=1e3*j.targetduration;if(j.updated){var me=j.fragments;if(me.length&&4*ie>le){var we=1e3*me[me.length-1].duration;we<ie&&(ie=we)}}else ie/=2;return Math.round(ie)})(l,1e3*(l.edge-W));l.updated&&u>this.requestScheduled+$&&(this.requestScheduled=h.loading.start),v!==void 0&&l.canBlockReload?this.requestScheduled=h.loading.first+$-(1e3*l.partTarget||1e3):this.requestScheduled===-1||this.requestScheduled+$<u?this.requestScheduled=u:this.requestScheduled-u<=0&&(this.requestScheduled+=$);var J=this.requestScheduled-u;J=Math.max(0,J),this.log("reload live playlist "+t+" in "+Math.round(J)+" ms"),this.timer=self.setTimeout(function(){return o.loadPlaylist(p)},J)}else this.clearTimer()},s.getDeliveryDirectives=function(t,r,a,o){var l=(function(h,u){var f=h.canSkipUntil,p=h.canSkipDateRanges,v=h.endSN;return f&&(u!==void 0?u-v:0)<f?p?nm:am:ol})(t,a);return r!=null&&r.skip&&t.deltaUpdateFailed&&(a=r.msn,o=r.part,l=ol),new Hu(a,o,l)},s.checkRetry=function(t){var r=this,a=t.details,o=Dn(t),l=t.errorAction,h=l||{},u=h.action,f=h.retryCount,p=f===void 0?0:f,v=h.retryConfig,w=!!l&&!!v&&(u===Ln||!l.resolved&&u===Or);if(w){var C;if(this.requestScheduled=-1,p>=v.maxNumRetry)return!1;if(o&&(C=t.context)!=null&&C.deliveryDirectives)this.warn("Retrying playlist loading "+(p+1)+"/"+v.maxNumRetry+' after "'+a+'" without delivery-directives'),this.loadPlaylist();else{var k=cl(v,p);this.timer=self.setTimeout(function(){return r.loadPlaylist()},k),this.warn("Retrying playlist loading "+(p+1)+"/"+v.maxNumRetry+' after "'+a+'" in '+k+"ms")}t.levelRetry=!0,l.resolved=!0}return w},d})(),dm=(function(d){function s(r,a){var o;return(o=d.call(this,r,"[level-controller]")||this)._levels=[],o._firstLevel=-1,o._startLevel=void 0,o.currentLevel=null,o.currentLevelIndex=-1,o.manualLevelIndex=-1,o.steering=void 0,o.onParsedComplete=void 0,o.steering=a,o._registerListeners(),o}X(s,d);var t=s.prototype;return t._registerListeners=function(){var r=this.hls;r.on(x.MANIFEST_LOADING,this.onManifestLoading,this),r.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),r.on(x.LEVEL_LOADED,this.onLevelLoaded,this),r.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(x.FRAG_LOADED,this.onFragLoaded,this),r.on(x.ERROR,this.onError,this)},t._unregisterListeners=function(){var r=this.hls;r.off(x.MANIFEST_LOADING,this.onManifestLoading,this),r.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),r.off(x.LEVEL_LOADED,this.onLevelLoaded,this),r.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(x.FRAG_LOADED,this.onFragLoaded,this),r.off(x.ERROR,this.onError,this)},t.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),d.prototype.destroy.call(this)},t.startLoad=function(){this._levels.forEach(function(r){r.loadError=0,r.fragmentError=0}),d.prototype.startLoad.call(this)},t.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]},t.onManifestLoading=function(r,a){this.resetLevels()},t.onManifestLoaded=function(r,a){var o,l=[],h={};a.levels.forEach(function(u){var f,p=u.attrs;((f=u.audioCodec)==null?void 0:f.indexOf("mp4a.40.34"))!==-1&&(hl||(hl=/chrome|firefox/i.test(navigator.userAgent)),hl&&(u.audioCodec=void 0));var v=p.AUDIO,w=p.CODECS,C=p["FRAME-RATE"],k=p["PATHWAY-ID"],I=p.RESOLUTION,D=p.SUBTITLES,B=(k||".")+"-"+u.bitrate+"-"+I+"-"+C+"-"+w;(o=h[B])?o.addFallback(u):(o=new Aa(u),h[B]=o,l.push(o)),Fn(o,"audio",v),Fn(o,"text",D)}),this.filterAndSortMediaOptions(l,a)},t.filterAndSortMediaOptions=function(r,a){var o=this,l=[],h=[],u=!1,f=!1,p=!1,v=r.filter(function(T){var U=T.audioCodec,M=T.videoCodec,H=T.width,V=T.height,W=T.unknownCodecs;return u||(u=!(!H||!V)),f||(f=!!M),p||(p=!!U),!(W!=null&&W.length)&&(!U||el(U,"audio"))&&(!M||el(M,"video"))});if((u||f)&&p&&(v=v.filter(function(T){var U=T.videoCodec,M=T.width,H=T.height;return!!U||!(!M||!H)})),v.length!==0){a.audioTracks&&Ju(l=a.audioTracks.filter(function(T){return!T.audioCodec||el(T.audioCodec,"audio")})),a.subtitles&&Ju(h=a.subtitles);var w=v.slice(0);v.sort(function(T,U){return T.attrs["HDCP-LEVEL"]!==U.attrs["HDCP-LEVEL"]?(T.attrs["HDCP-LEVEL"]||"")>(U.attrs["HDCP-LEVEL"]||"")?1:-1:T.bitrate!==U.bitrate?T.bitrate-U.bitrate:T.attrs["FRAME-RATE"]!==U.attrs["FRAME-RATE"]?T.attrs.decimalFloatingPoint("FRAME-RATE")-U.attrs.decimalFloatingPoint("FRAME-RATE"):T.attrs.SCORE!==U.attrs.SCORE?T.attrs.decimalFloatingPoint("SCORE")-U.attrs.decimalFloatingPoint("SCORE"):u&&T.height!==U.height?T.height-U.height:0});var C=w[0];if(this.steering&&(v=this.steering.filterParsedLevels(v)).length!==w.length){for(var k=0;k<w.length;k++)if(w[k].pathwayId===v[0].pathwayId){C=w[k];break}}this._levels=v;for(var I=0;I<v.length;I++)if(v[I]===C){this._firstLevel=I,this.log("manifest loaded, "+v.length+" level(s) found, first bitrate: "+C.bitrate);break}var D=p&&!f,B={levels:v,audioTracks:l,subtitleTracks:h,sessionData:a.sessionData,sessionKeys:a.sessionKeys,firstLevel:this._firstLevel,stats:a.stats,audio:p,video:f,altAudio:!D&&l.some(function(T){return!!T.url})};this.hls.trigger(x.MANIFEST_PARSED,B),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then(function(){if(o.hls){var T=new Error("no level with compatible codecs found in manifest");o.hls.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:a.url,error:T,reason:T.message})}})},t.onError=function(r,a){!a.fatal&&a.context&&a.context.type===oi&&a.context.level===this.level&&this.checkRetry(a)},t.onFragLoaded=function(r,a){var o=a.frag;if(o!==void 0&&o.type===Je){var l=this._levels[o.level];l!==void 0&&(l.loadError=0)}},t.onLevelLoaded=function(r,a){var o,l,h=a.level,u=a.details,f=this._levels[h];if(!f)return this.warn("Invalid level index "+h),void((l=a.deliveryDirectives)!=null&&l.skip&&(u.deltaUpdateFailed=!0));h===this.currentLevelIndex?(f.fragmentError===0&&(f.loadError=0),this.playlistLoaded(h,a,f.details)):(o=a.deliveryDirectives)!=null&&o.skip&&(u.deltaUpdateFailed=!0)},t.onAudioTrackSwitched=function(r,a){var o=this.currentLevel;if(o){var l=this.hls.audioTracks[a.id].groupId;if(o.audioGroupIds&&o.audioGroupId!==l){for(var h=-1,u=0;u<o.audioGroupIds.length;u++)if(o.audioGroupIds[u]===l){h=u;break}h!==-1&&h!==o.urlId&&(o.urlId=h,this.canLoad&&this.startLoad())}}},t.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var a=this.currentLevelIndex,o=this.currentLevel;if(o&&this.shouldLoadPlaylist(o)){var l=o.urlId,h=o.uri;if(r)try{h=r.addDirectives(h)}catch(f){this.warn("Could not construct new URL with HLS Delivery Directives: "+f)}var u=o.attrs["PATHWAY-ID"];this.log("Loading level index "+a+(r?.msn!==void 0?" at sn "+r.msn+" part "+r.part:"")+" with"+(u?" Pathway "+u:"")+" URI "+(l+1)+"/"+o.url.length+" "+h),this.clearTimer(),this.hls.trigger(x.LEVEL_LOADING,{url:h,level:a,id:l,deliveryDirectives:r||null})}},t.removeLevel=function(r,a){var o=this,l=function(u,f){return f!==a},h=this._levels.filter(function(u,f){return f!==r||(u.url.length>1&&a!==void 0?(u.url=u.url.filter(l),u.audioGroupIds&&(u.audioGroupIds=u.audioGroupIds.filter(l)),u.textGroupIds&&(u.textGroupIds=u.textGroupIds.filter(l)),u.urlId=0,!0):(o.steering&&o.steering.removeLevel(u),!1))});this.hls.trigger(x.LEVELS_UPDATED,{levels:h})},t.onLevelsUpdated=function(r,a){var o=a.levels;o.forEach(function(l,h){var u=l.details;u!=null&&u.fragments&&u.fragments.forEach(function(f){f.level=h})}),this._levels=o},F(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(r){var a=this._levels;if(a.length!==0){if(r<0||r>=a.length){var o=new Error("invalid level idx"),l=r<0;if(this.hls.trigger(x.ERROR,{type:ue.OTHER_ERROR,details:q.LEVEL_SWITCH_ERROR,level:r,fatal:l,error:o,reason:o.message}),l)return;r=Math.min(r,a.length-1)}var h=this.currentLevelIndex,u=this.currentLevel,f=u?u.attrs["PATHWAY-ID"]:void 0,p=a[r],v=p.attrs["PATHWAY-ID"];if(this.currentLevelIndex=r,this.currentLevel=p,h!==r||!p.details||!u||f!==v){this.log("Switching to level "+r+(v?" with Pathway "+v:"")+" from level "+h+(f?" with Pathway "+f:""));var w=Y({},p,{level:r,maxBitrate:p.maxBitrate,attrs:p.attrs,uri:p.uri,urlId:p.urlId});delete w._attrs,delete w._urlId,this.hls.trigger(x.LEVEL_SWITCHING,w);var C=p.details;if(!C||C.live){var k=this.switchParams(p.uri,u?.details);this.loadPlaylist(k)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(r){this.manualLevelIndex=r,this._startLevel===void 0&&(this._startLevel=r),r!==-1&&(this.level=r)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(r){this._firstLevel=r}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var r=this.hls.config.startLevel;return r!==void 0?r:this._firstLevel}return this._startLevel},set:function(r){this._startLevel=r}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(r){this.level=r,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=r)}}]),s})(gl);function Fn(d,s,t){t&&(s==="audio"?(d.audioGroupIds||(d.audioGroupIds=[]),d.audioGroupIds[d.url.length-1]=t):s==="text"&&(d.textGroupIds||(d.textGroupIds=[]),d.textGroupIds[d.url.length-1]=t))}function Ju(d){var s={};d.forEach(function(t){var r=t.groupId||"";t.id=s[r]=s[r]||0,s[r]++})}var ya="NOT_LOADED",_u="APPENDING",xi="PARTIAL",wa="OK",hm=(function(){function d(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}var s=d.prototype;return s._registerListeners=function(){var t=this.hls;t.on(x.BUFFER_APPENDED,this.onBufferAppended,this),t.on(x.FRAG_BUFFERED,this.onFragBuffered,this),t.on(x.FRAG_LOADED,this.onFragLoaded,this)},s._unregisterListeners=function(){var t=this.hls;t.off(x.BUFFER_APPENDED,this.onBufferAppended,this),t.off(x.FRAG_BUFFERED,this.onFragBuffered,this),t.off(x.FRAG_LOADED,this.onFragLoaded,this)},s.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},s.getAppendedFrag=function(t,r){var a=this.activePartLists[r];if(a)for(var o=a.length;o--;){var l=a[o];if(!l)break;var h=l.end;if(l.start<=t&&h!==null&&t<=h)return l}return this.getBufferedFrag(t,r)},s.getBufferedFrag=function(t,r){for(var a=this.fragments,o=Object.keys(a),l=o.length;l--;){var h=a[o[l]];if(h?.body.type===r&&h.buffered){var u=h.body;if(u.start<=t&&t<=u.end)return u}}return null},s.detectEvictedFragments=function(t,r,a,o){var l=this;this.timeRanges&&(this.timeRanges[t]=r);var h=o?.fragment.sn||-1;Object.keys(this.fragments).forEach(function(u){var f=l.fragments[u];if(f&&!(h>=f.body.sn))if(f.buffered||f.loaded){var p=f.range[t];p&&p.time.some(function(v){var w=!l.isTimeBuffered(v.startPTS,v.endPTS,r);return w&&l.removeFragment(f.body),w})}else f.body.type===a&&l.removeFragment(f.body)})},s.detectPartialFragments=function(t){var r=this,a=this.timeRanges,o=t.frag,l=t.part;if(a&&o.sn!=="initSegment"){var h=Ti(o),u=this.fragments[h];if(!(!u||u.buffered&&o.gap)){var f=!o.relurl;Object.keys(a).forEach(function(p){var v=o.elementaryStreams[p];if(v){var w=a[p],C=f||v.partial===!0;u.range[p]=r.getBufferedTimes(o,l,C,w)}}),u.loaded=null,Object.keys(u.range).length?(u.buffered=!0,(u.body.endList=o.endList||u.body.endList)&&(this.endListFragments[u.body.type]=u),On(u)||this.removeParts(o.sn-1,o.type)):this.removeFragment(u.body)}}},s.removeParts=function(t,r){var a=this.activePartLists[r];a&&(this.activePartLists[r]=a.filter(function(o){return o.fragment.sn>=t}))},s.fragBuffered=function(t,r){var a=Ti(t),o=this.fragments[a];!o&&r&&(o=this.fragments[a]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),o&&(o.loaded=null,o.buffered=!0)},s.getBufferedTimes=function(t,r,a,o){for(var l={time:[],partial:a},h=t.start,u=t.end,f=t.minEndPTS||u,p=t.maxStartPTS||h,v=0;v<o.length;v++){var w=o.start(v)-this.bufferPadding,C=o.end(v)+this.bufferPadding;if(p>=w&&f<=C){l.time.push({startPTS:Math.max(h,o.start(v)),endPTS:Math.min(u,o.end(v))});break}if(h<C&&u>w)l.partial=!0,l.time.push({startPTS:Math.max(h,o.start(v)),endPTS:Math.min(u,o.end(v))});else if(u<=w)break}return l},s.getPartialFragment=function(t){var r,a,o,l=null,h=0,u=this.bufferPadding,f=this.fragments;return Object.keys(f).forEach(function(p){var v=f[p];v&&On(v)&&(a=v.body.start-u,o=v.body.end+u,t>=a&&t<=o&&(r=Math.min(t-a,o-t),h<=r&&(l=v.body,h=r)))}),l},s.isEndListAppended=function(t){var r=this.endListFragments[t];return r!==void 0&&(r.buffered||On(r))},s.getState=function(t){var r=Ti(t),a=this.fragments[r];return a?a.buffered?On(a)?xi:wa:_u:ya},s.isTimeBuffered=function(t,r,a){for(var o,l,h=0;h<a.length;h++){if(o=a.start(h)-this.bufferPadding,l=a.end(h)+this.bufferPadding,t>=o&&r<=l)return!0;if(r<=o)return!1}return!1},s.onFragLoaded=function(t,r){var a=r.frag,o=r.part;if(a.sn!=="initSegment"&&!a.bitrateTest){var l=o?null:r,h=Ti(a);this.fragments[h]={body:a,appendedPTS:null,loaded:l,buffered:!1,range:Object.create(null)}}},s.onBufferAppended=function(t,r){var a=this,o=r.frag,l=r.part,h=r.timeRanges;if(o.sn!=="initSegment"){var u=o.type;if(l){var f=this.activePartLists[u];f||(this.activePartLists[u]=f=[]),f.push(l)}this.timeRanges=h,Object.keys(h).forEach(function(p){var v=h[p];a.detectEvictedFragments(p,v,u,l)})}},s.onFragBuffered=function(t,r){this.detectPartialFragments(r)},s.hasFragment=function(t){var r=Ti(t);return!!this.fragments[r]},s.hasParts=function(t){var r;return!((r=this.activePartLists[t])==null||!r.length)},s.removeFragmentsInRange=function(t,r,a,o,l){var h=this;o&&!this.hasGaps||Object.keys(this.fragments).forEach(function(u){var f=h.fragments[u];if(f){var p=f.body;p.type!==a||o&&!p.gap||p.start<r&&p.end>t&&(f.buffered||l)&&h.removeFragment(p)}})},s.removeFragment=function(t){var r=Ti(t);t.stats.loaded=0,t.clearElementaryStreamInfo();var a=this.activePartLists[t.type];if(a){var o=t.sn;this.activePartLists[t.type]=a.filter(function(l){return l.fragment.sn!==o})}delete this.fragments[r],t.endList&&delete this.endListFragments[t.type]},s.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},d})();function On(d){var s,t,r;return d.buffered&&(d.body.gap||((s=d.range.video)==null?void 0:s.partial)||((t=d.range.audio)==null?void 0:t.partial)||((r=d.range.audiovideo)==null?void 0:r.partial))}function Ti(d){return d.type+"_"+d.level+"_"+d.urlId+"_"+d.sn}var ju=Math.pow(2,17),um=(function(){function d(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var s=d.prototype;return s.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},s.abort=function(){this.loader&&this.loader.abort()},s.load=function(t,r){var a=this,o=t.url;if(!o)return Promise.reject(new Pr({type:ue.NETWORK_ERROR,details:q.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a "+(o?"part list":"url")),networkDetails:null}));this.abort();var l=this.config,h=l.fLoader,u=l.loader;return new Promise(function(f,p){if(a.loader&&a.loader.destroy(),t.gap){if(t.tagList.some(function(I){return I[0]==="GAP"}))return void p($u(t));t.gap=!1}var v=a.loader=t.loader=h?new h(l):new u(l),w=Zu(t),C=Vu(l.fragLoadPolicy.default),k={loadPolicy:C,timeout:C.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:ju};t.stats=v.stats,v.load(w,k,{onSuccess:function(I,D,B,T){a.resetLoader(t,v);var U=I.data;B.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(U.slice(0,16)),U=U.slice(16)),f({frag:t,part:null,payload:U,networkDetails:T})},onError:function(I,D,B,T){a.resetLoader(t,v),p(new Pr({type:ue.NETWORK_ERROR,details:q.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:E({url:o,data:void 0},I),error:new Error("HTTP Error "+I.code+" "+I.text),networkDetails:B,stats:T}))},onAbort:function(I,D,B){a.resetLoader(t,v),p(new Pr({type:ue.NETWORK_ERROR,details:q.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:B,stats:I}))},onTimeout:function(I,D,B){a.resetLoader(t,v),p(new Pr({type:ue.NETWORK_ERROR,details:q.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error("Timeout after "+k.timeout+"ms"),networkDetails:B,stats:I}))},onProgress:function(I,D,B,T){r&&r({frag:t,part:null,payload:B,networkDetails:T})}})})},s.loadPart=function(t,r,a){var o=this;this.abort();var l=this.config,h=l.fLoader,u=l.loader;return new Promise(function(f,p){if(o.loader&&o.loader.destroy(),t.gap||r.gap)p($u(t,r));else{var v=o.loader=t.loader=h?new h(l):new u(l),w=Zu(t,r),C=Vu(l.fragLoadPolicy.default),k={loadPolicy:C,timeout:C.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:ju};r.stats=v.stats,v.load(w,k,{onSuccess:function(I,D,B,T){o.resetLoader(t,v),o.updateStatsFromPart(t,r);var U={frag:t,part:r,payload:I.data,networkDetails:T};a(U),f(U)},onError:function(I,D,B,T){o.resetLoader(t,v),p(new Pr({type:ue.NETWORK_ERROR,details:q.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:r,response:E({url:w.url,data:void 0},I),error:new Error("HTTP Error "+I.code+" "+I.text),networkDetails:B,stats:T}))},onAbort:function(I,D,B){t.stats.aborted=r.stats.aborted,o.resetLoader(t,v),p(new Pr({type:ue.NETWORK_ERROR,details:q.INTERNAL_ABORTED,fatal:!1,frag:t,part:r,error:new Error("Aborted"),networkDetails:B,stats:I}))},onTimeout:function(I,D,B){o.resetLoader(t,v),p(new Pr({type:ue.NETWORK_ERROR,details:q.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:r,error:new Error("Timeout after "+k.timeout+"ms"),networkDetails:B,stats:I}))}})}})},s.updateStatsFromPart=function(t,r){var a=t.stats,o=r.stats,l=o.total;if(a.loaded+=o.loaded,l){var h=Math.round(t.duration/r.duration),u=Math.min(Math.round(a.loaded/l),h),f=(h-u)*Math.round(a.loaded/u);a.total=a.loaded+f}else a.total=Math.max(a.loaded,a.total);var p=a.loading,v=o.loading;p.start?p.first+=v.first-v.start:(p.start=v.start,p.first=v.first),p.end=v.end},s.resetLoader=function(t,r){t.loader=null,this.loader===r&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),r.destroy()},d})();function Zu(d,s){s===void 0&&(s=null);var t=s||d,r={frag:d,part:s,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},a=t.byteRangeStartOffset,o=t.byteRangeEndOffset;if(se(a)&&se(o)){var l,h=a,u=o;if(d.sn==="initSegment"&&((l=d.decryptdata)==null?void 0:l.method)==="AES-128"){var f=o-a;f%16&&(u=o+(16-f%16)),a!==0&&(r.resetIV=!0,h=a-16)}r.rangeStart=h,r.rangeEnd=u}return r}function $u(d,s){var t=new Error("GAP "+(d.gap?"tag":"attribute")+" found"),r={type:ue.MEDIA_ERROR,details:q.FRAG_GAP,fatal:!1,frag:d,error:t,networkDetails:null};return s&&(r.part=s),(s||d).stats.aborted=!0,new Pr(r)}var Pr=(function(d){function s(t){var r;return(r=d.call(this,t.error.message)||this).data=void 0,r.data=t,r}return X(s,d),s})(ce(Error)),gm=(function(){function d(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}var s=d.prototype;return s.abort=function(t){for(var r in this.keyUriToKeyInfo){var a=this.keyUriToKeyInfo[r].loader;if(a){if(t&&t!==a.context.frag.type)return;a.abort()}}},s.detach=function(){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t];(r.mediaKeySessionContext||r.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}},s.destroy=function(){for(var t in this.detach(),this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;r&&r.destroy()}this.keyUriToKeyInfo={}},s.createKeyLoadError=function(t,r,a,o,l){return r===void 0&&(r=q.KEY_LOAD_ERROR),new Pr({type:ue.NETWORK_ERROR,details:r,fatal:!1,frag:t,response:l,error:a,networkDetails:o})},s.loadClear=function(t,r){var a=this;if(this.emeController&&this.config.emeEnabled)for(var o=t.sn,l=t.cc,h=function(){var f=r[u];if(l<=f.cc&&(o==="initSegment"||f.sn==="initSegment"||o<f.sn))return a.emeController.selectKeySystemFormat(f).then(function(p){f.setKeyFormat(p)}),"break"},u=0;u<r.length&&h()!=="break";u++);},s.load=function(t){var r=this;return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then(function(a){return r.loadInternal(t,a)}):this.loadInternal(t)},s.loadInternal=function(t,r){var a,o;r&&t.setKeyFormat(r);var l=t.decryptdata;if(!l){var h=new Error(r?"Expected frag.decryptdata to be defined after setting format "+r:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,q.KEY_LOAD_ERROR,h))}var u=l.uri;if(!u)return Promise.reject(this.createKeyLoadError(t,q.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+u+'"')));var f,p=this.keyUriToKeyInfo[u];if((a=p)!=null&&a.decryptdata.key)return l.key=p.decryptdata.key,Promise.resolve({frag:t,keyInfo:p});if((o=p)!=null&&o.keyLoadPromise)switch((f=p.mediaKeySessionContext)==null?void 0:f.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return p.keyLoadPromise.then(function(v){return l.key=v.keyInfo.decryptdata.key,{frag:t,keyInfo:p}})}switch(p=this.keyUriToKeyInfo[u]={decryptdata:l,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},l.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return l.keyFormat==="identity"?this.loadKeyHTTP(p,t):this.loadKeyEME(p,t);case"AES-128":return this.loadKeyHTTP(p,t);default:return Promise.reject(this.createKeyLoadError(t,q.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+l.method+'"')))}},s.loadKeyEME=function(t,r){var a={frag:r,keyInfo:t};if(this.emeController&&this.config.emeEnabled){var o=this.emeController.loadKey(a);if(o)return(t.keyLoadPromise=o.then(function(l){return t.mediaKeySessionContext=l,a})).catch(function(l){throw t.keyLoadPromise=null,l})}return Promise.resolve(a)},s.loadKeyHTTP=function(t,r){var a=this,o=this.config,l=new o.loader(o);return r.keyLoader=t.loader=l,t.keyLoadPromise=new Promise(function(h,u){var f={keyInfo:t,frag:r,responseType:"arraybuffer",url:t.decryptdata.uri},p=o.keyLoadPolicy.default,v={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};l.load(f,v,{onSuccess:function(w,C,k,I){var D=k.frag,B=k.keyInfo,T=k.url;if(!D.decryptdata||B!==a.keyUriToKeyInfo[T])return u(a.createKeyLoadError(D,q.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),I));B.decryptdata.key=D.decryptdata.key=new Uint8Array(w.data),D.keyLoader=null,B.loader=null,h({frag:D,keyInfo:B})},onError:function(w,C,k,I){a.resetLoader(C),u(a.createKeyLoadError(r,q.KEY_LOAD_ERROR,new Error("HTTP Error "+w.code+" loading key "+w.text),k,E({url:f.url,data:void 0},w)))},onTimeout:function(w,C,k){a.resetLoader(C),u(a.createKeyLoadError(r,q.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),k))},onAbort:function(w,C,k){a.resetLoader(C),u(a.createKeyLoadError(r,q.INTERNAL_ABORTED,new Error("key loading aborted"),k))}})})},s.resetLoader=function(t){var r=t.frag,a=t.keyInfo,o=t.url,l=a.loader;r.keyLoader===l&&(r.keyLoader=null,a.loader=null),delete this.keyUriToKeyInfo[o],l&&l.destroy()},d})(),fm=(function(){function d(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var s=d.prototype;return s.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},s.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},s.onHandlerDestroyed=function(){},s.hasInterval=function(){return!!this._tickInterval},s.hasNextTick=function(){return!!this._tickTimer},s.setInterval=function(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)},s.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},s.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},s.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},s.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},s.doTick=function(){},d})(),pm={length:0,start:function(){return 0},end:function(){return 0}},ct=(function(){function d(){}return d.isBuffered=function(s,t){try{if(s){for(var r=d.getBuffered(s),a=0;a<r.length;a++)if(t>=r.start(a)&&t<=r.end(a))return!0}}catch{}return!1},d.bufferInfo=function(s,t,r){try{if(s){var a,o=d.getBuffered(s),l=[];for(a=0;a<o.length;a++)l.push({start:o.start(a),end:o.end(a)});return this.bufferedInfo(l,t,r)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}},d.bufferedInfo=function(s,t,r){t=Math.max(0,t),s.sort(function(I,D){return I.start-D.start||D.end-I.end});var a=[];if(r)for(var o=0;o<s.length;o++){var l=a.length;if(l){var h=a[l-1].end;s[o].start-h<r?s[o].end>h&&(a[l-1].end=s[o].end):a.push(s[o])}else a.push(s[o])}else a=s;for(var u,f=0,p=t,v=t,w=0;w<a.length;w++){var C=a[w].start,k=a[w].end;if(t+r>=C&&t<k)p=C,f=(v=k)-t;else if(t+r<C){u=C;break}}return{len:f,start:p||0,end:v||0,nextStart:u}},d.getBuffered=function(s){try{return s.buffered}catch(t){return G.log("failed to get media.buffered",t),pm}},d})(),fl=function(d,s,t,r,a,o){r===void 0&&(r=0),a===void 0&&(a=-1),o===void 0&&(o=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=d,this.sn=s,this.id=t,this.size=r,this.part=a,this.partial=o};function eg(d,s){for(var t=null,r=0,a=d.length;r<a;r++){var o=d[r];if(o&&o.cc===s){t=o;break}}return t}function tg(d,s){if(d){var t=d.start+s;d.start=d.startPTS=t,d.endPTS=t+d.duration}}function pl(d,s){for(var t=s.fragments,r=0,a=t.length;r<a;r++)tg(t[r],d);s.fragmentHint&&tg(s.fragmentHint,d),s.alignedSliding=!0}function mm(d,s,t){s&&((function(r,a,o){if((function(h,u,f){return!(!u.details||!(f.endCC>f.startCC||h&&h.cc<f.startCC))})(r,o,a)){var l=(function(h,u,f){var p=h.fragments,v=u.fragments;if(v.length&&p.length){var w=eg(p,v[0].cc);if(w&&(!w||w.startPTS))return w;G.log("No frag in previous level to align on")}else G.log("No fragments to align")})(o.details,a);l&&se(l.start)&&(G.log("Adjusting PTS using last level due to CC increase within current level "+a.url),pl(l.start,a))}})(d,t,s),!t.alignedSliding&&s.details&&(function(r,a){if(a.fragments.length&&r.hasProgramDateTime&&a.hasProgramDateTime){var o=a.fragments[0].programDateTime,l=r.fragments[0].programDateTime,h=(l-o)/1e3+a.fragments[0].start;h&&se(h)&&(G.log("Adjusting PTS using programDateTime delta "+(l-o)+"ms, sliding:"+h.toFixed(3)+" "+r.url+" "),pl(h,r))}})(t,s.details),t.alignedSliding||!s.details||t.skippedSegments||Yu(s.details,t))}function rg(d,s){if(d.hasProgramDateTime&&s.hasProgramDateTime){var t=d.fragments,r=s.fragments;if(t.length&&r.length){var a=r[Math.round(r.length/2)-1],o=eg(t,a.cc)||t[Math.round(t.length/2)-1],l=a.programDateTime,h=o.programDateTime;l!==null&&h!==null&&pl((h-l)/1e3-(o.start-a.start),d)}}}var vm=(function(){function d(s,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=s,this.aesIV=t}return d.prototype.decrypt=function(s,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,s)},d})(),Am=(function(){function d(s,t){this.subtle=void 0,this.key=void 0,this.subtle=s,this.key=t}return d.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},d})(),bm=(function(){function d(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var s=d.prototype;return s.uint8ArrayToUint32Array_=function(t){for(var r=new DataView(t),a=new Uint32Array(4),o=0;o<4;o++)a[o]=r.getUint32(4*o);return a},s.initTable=function(){var t=this.sBox,r=this.invSBox,a=this.subMix,o=a[0],l=a[1],h=a[2],u=a[3],f=this.invSubMix,p=f[0],v=f[1],w=f[2],C=f[3],k=new Uint32Array(256),I=0,D=0,B=0;for(B=0;B<256;B++)k[B]=B<128?B<<1:B<<1^283;for(B=0;B<256;B++){var T=D^D<<1^D<<2^D<<3^D<<4;T=T>>>8^255&T^99,t[I]=T,r[T]=I;var U=k[I],M=k[U],H=k[M],V=257*k[T]^16843008*T;o[I]=V<<24|V>>>8,l[I]=V<<16|V>>>16,h[I]=V<<8|V>>>24,u[I]=V,V=16843009*H^65537*M^257*U^16843008*I,p[T]=V<<24|V>>>8,v[T]=V<<16|V>>>16,w[T]=V<<8|V>>>24,C[T]=V,I?(I=U^k[k[k[H^U]]],D^=k[k[D]]):I=D=1}},s.expandKey=function(t){for(var r=this.uint8ArrayToUint32Array_(t),a=!0,o=0;o<r.length&&a;)a=r[o]===this.key[o],o++;if(!a){this.key=r;var l=this.keySize=r.length;if(l!==4&&l!==6&&l!==8)throw new Error("Invalid aes key size="+l);var h,u,f,p,v=this.ksRows=4*(l+6+1),w=this.keySchedule=new Uint32Array(v),C=this.invKeySchedule=new Uint32Array(v),k=this.sBox,I=this.rcon,D=this.invSubMix,B=D[0],T=D[1],U=D[2],M=D[3];for(h=0;h<v;h++)h<l?f=w[h]=r[h]:(p=f,h%l==0?(p=k[(p=p<<8|p>>>24)>>>24]<<24|k[p>>>16&255]<<16|k[p>>>8&255]<<8|k[255&p],p^=I[h/l|0]<<24):l>6&&h%l==4&&(p=k[p>>>24]<<24|k[p>>>16&255]<<16|k[p>>>8&255]<<8|k[255&p]),w[h]=f=(w[h-l]^p)>>>0);for(u=0;u<v;u++)h=v-u,p=3&u?w[h]:w[h-4],C[u]=u<4||h<=4?p:B[k[p>>>24]]^T[k[p>>>16&255]]^U[k[p>>>8&255]]^M[k[255&p]],C[u]=C[u]>>>0}},s.networkToHostOrderSwap=function(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24},s.decrypt=function(t,r,a){for(var o,l,h,u,f,p,v,w,C,k,I,D,B,T,U=this.keySize+6,M=this.invKeySchedule,H=this.invSBox,V=this.invSubMix,W=V[0],$=V[1],J=V[2],j=V[3],le=this.uint8ArrayToUint32Array_(a),ie=le[0],me=le[1],we=le[2],ve=le[3],Ae=new Int32Array(t),Ie=new Int32Array(Ae.length),fe=this.networkToHostOrderSwap;r<Ae.length;){for(C=fe(Ae[r]),k=fe(Ae[r+1]),I=fe(Ae[r+2]),D=fe(Ae[r+3]),f=C^M[0],p=D^M[1],v=I^M[2],w=k^M[3],B=4,T=1;T<U;T++)o=W[f>>>24]^$[p>>16&255]^J[v>>8&255]^j[255&w]^M[B],l=W[p>>>24]^$[v>>16&255]^J[w>>8&255]^j[255&f]^M[B+1],h=W[v>>>24]^$[w>>16&255]^J[f>>8&255]^j[255&p]^M[B+2],u=W[w>>>24]^$[f>>16&255]^J[p>>8&255]^j[255&v]^M[B+3],f=o,p=l,v=h,w=u,B+=4;o=H[f>>>24]<<24^H[p>>16&255]<<16^H[v>>8&255]<<8^H[255&w]^M[B],l=H[p>>>24]<<24^H[v>>16&255]<<16^H[w>>8&255]<<8^H[255&f]^M[B+1],h=H[v>>>24]<<24^H[w>>16&255]<<16^H[f>>8&255]<<8^H[255&p]^M[B+2],u=H[w>>>24]<<24^H[f>>16&255]<<16^H[p>>8&255]<<8^H[255&v]^M[B+3],Ie[r]=fe(o^ie),Ie[r+1]=fe(u^me),Ie[r+2]=fe(h^we),Ie[r+3]=fe(l^ve),ie=C,me=k,we=I,ve=D,r+=4}return Ie.buffer},d})(),ml=(function(){function d(t,r){var a=(r===void 0?{}:r).removePKCS7Padding,o=a===void 0||a;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=o,o)try{var l=self.crypto;l&&(this.subtle=l.subtle||l.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var s=d.prototype;return s.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},s.isSync=function(){return this.useSoftware},s.flush=function(){var t=this.currentResult,r=this.remainderData;if(!t||r)return this.reset(),null;var a,o,l,h=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?(o=(a=h).byteLength,(l=o&&new DataView(a.buffer).getUint8(o-1))?ai(a,0,o-l):a):h},s.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},s.decrypt=function(t,r,a){var o=this;return this.useSoftware?new Promise(function(l,h){o.softwareDecrypt(new Uint8Array(t),r,a);var u=o.flush();u?l(u.buffer):h(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),r,a)},s.softwareDecrypt=function(t,r,a){var o=this.currentIV,l=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(t=ni(h,t),this.remainderData=null);var u=this.getValidChunk(t);if(!u.length)return null;o&&(a=o);var f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new bm),f.expandKey(r);var p=l;return this.currentResult=f.decrypt(u.buffer,0,a),this.currentIV=ai(u,-16).buffer,p||null},s.webCryptoDecrypt=function(t,r,a){var o=this,l=this.subtle;return this.key===r&&this.fastAesKey||(this.key=r,this.fastAesKey=new Am(l,r)),this.fastAesKey.expandKey().then(function(h){return l?(o.logOnce("WebCrypto AES decrypt"),new vm(l,new Uint8Array(a)).decrypt(t.buffer,h)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(h){return G.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+h.name+": "+h.message),o.onWebCryptoError(t,r,a)})},s.onWebCryptoError=function(t,r,a){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,r,a);var o=this.flush();if(o)return o.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},s.getValidChunk=function(t){var r=t,a=t.length-t.length%16;return a!==t.length&&(r=ai(t,0,a),this.remainderData=ai(t,a)),r},s.logOnce=function(t){this.logEnabled&&(G.log("[decrypter]: "+t),this.logEnabled=!1)},d})(),ym=function(d){for(var s="",t=d.length,r=0;r<t;r++)s+="["+d.start(r).toFixed(3)+"-"+d.end(r).toFixed(3)+"]";return s},Vt="STOPPED",Qe="IDLE",vl="KEY_LOADING",Di="FRAG_LOADING",Ri="FRAG_LOADING_WAITING_RETRY",Ca="WAITING_TRACK",Ur="PARSING",Pn="PARSED",Ea="ENDED",Li="ERROR",ka="WAITING_INIT_PTS",si="WAITING_LEVEL",Al=(function(d){function s(r,a,o,l,h){var u;return(u=d.call(this)||this).hls=void 0,u.fragPrevious=null,u.fragCurrent=null,u.fragmentTracker=void 0,u.transmuxer=null,u._state=Vt,u.playlistType=void 0,u.media=null,u.mediaBuffer=null,u.config=void 0,u.bitrateTest=!1,u.lastCurrentTime=0,u.nextLoadPosition=0,u.startPosition=0,u.startTimeOffset=null,u.loadedmetadata=!1,u.retryDate=0,u.levels=null,u.fragmentLoader=void 0,u.keyLoader=void 0,u.levelLastLoaded=null,u.startFragRequested=!1,u.decrypter=void 0,u.initPTS=[],u.onvseeking=null,u.onvended=null,u.logPrefix="",u.log=void 0,u.warn=void 0,u.playlistType=h,u.logPrefix=l,u.log=G.log.bind(G,l+":"),u.warn=G.warn.bind(G,l+":"),u.hls=r,u.fragmentLoader=new um(r.config),u.keyLoader=o,u.fragmentTracker=a,u.config=r.config,u.decrypter=new ml(r.config),r.on(x.MANIFEST_LOADED,u.onManifestLoaded,(function(f){if(f===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return f})(u)),u}X(s,d);var t=s.prototype;return t.doTick=function(){this.onTickEnd()},t.onTickEnd=function(){},t.startLoad=function(r){},t.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var r=this.fragCurrent;r!=null&&r.loader&&(r.abortRequests(),this.fragmentTracker.removeFragment(r)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Vt},t._streamEnded=function(r,a){if(a.live||r.nextStart||!r.end||!this.media)return!1;var o=a.partList;if(o!=null&&o.length){var l=o[o.length-1];return ct.isBuffered(this.media,l.start+l.duration/2)}var h=a.fragments[a.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(h)},t.getLevelDetails=function(){var r;if(this.levels&&this.levelLastLoaded!==null)return(r=this.levels[this.levelLastLoaded])==null?void 0:r.details},t.onMediaAttached=function(r,a){var o=this.media=this.mediaBuffer=a.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),o.addEventListener("seeking",this.onvseeking),o.addEventListener("ended",this.onvended);var l=this.config;this.levels&&l.autoStartLoad&&this.state===Vt&&this.startLoad(l.startPosition)},t.onMediaDetaching=function(){var r=this.media;r!=null&&r.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),r&&this.onvseeking&&this.onvended&&(r.removeEventListener("seeking",this.onvseeking),r.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},t.onMediaSeeking=function(){var r=this.config,a=this.fragCurrent,o=this.media,l=this.mediaBuffer,h=this.state,u=o?o.currentTime:0,f=ct.bufferInfo(l||o,u,r.maxBufferHole);if(this.log("media seeking to "+(se(u)?u.toFixed(3):u)+", state: "+h),this.state===Ea)this.resetLoadingState();else if(a){var p=r.maxFragLookUpTolerance,v=a.start-p,w=a.start+a.duration+p;if(!f.len||w<f.start||v>f.end){var C=u>w;(u<v||C)&&(C&&a.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),a.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}o&&(this.fragmentTracker.removeFragmentsInRange(u,1/0,this.playlistType,!0),this.lastCurrentTime=u),this.loadedmetadata||f.len||(this.nextLoadPosition=this.startPosition=u),this.tickImmediate()},t.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},t.onManifestLoaded=function(r,a){this.startTimeOffset=a.startTimeOffset,this.initPTS=[]},t.onHandlerDestroying=function(){this.stopLoad(),d.prototype.onHandlerDestroying.call(this)},t.onHandlerDestroyed=function(){this.state=Vt,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,d.prototype.onHandlerDestroyed.call(this)},t.loadFragment=function(r,a,o){this._loadFragForPlayback(r,a,o)},t._loadFragForPlayback=function(r,a,o){var l=this;this._doFragLoad(r,a,o,function(h){if(l.fragContextChanged(r))return l.warn("Fragment "+r.sn+(h.part?" p: "+h.part.index:"")+" of level "+r.level+" was dropped during download."),void l.fragmentTracker.removeFragment(r);r.stats.chunkCount++,l._handleFragmentLoadProgress(h)}).then(function(h){if(h){var u=l.state;l.fragContextChanged(r)?(u===Di||!l.fragCurrent&&u===Ur)&&(l.fragmentTracker.removeFragment(r),l.state=Qe):("payload"in h&&(l.log("Loaded fragment "+r.sn+" of level "+r.level),l.hls.trigger(x.FRAG_LOADED,h)),l._handleFragmentLoadComplete(h))}}).catch(function(h){l.state!==Vt&&l.state!==Li&&(l.warn(h),l.resetFragmentLoading(r))})},t.clearTrackerIfNeeded=function(r){var a,o=this.fragmentTracker;if(o.getState(r)===_u){var l=r.type,h=this.getFwdBufferInfo(this.mediaBuffer,l),u=Math.max(r.duration,h?h.len:this.config.maxBufferLength);this.reduceMaxBufferLength(u)&&o.removeFragment(r)}else((a=this.mediaBuffer)==null?void 0:a.buffered.length)===0?o.removeAllFragments():o.hasParts(r.type)&&(o.detectPartialFragments({frag:r,part:null,stats:r.stats,id:r.type}),o.getState(r)===xi&&o.removeFragment(r))},t.checkLiveUpdate=function(r){if(r.updated&&!r.live){var a=r.fragments[r.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:a,part:null,stats:a.stats,id:a.type})}r.fragments[0]||(r.deltaUpdateFailed=!0)},t.flushMainBuffer=function(r,a,o){if(o===void 0&&(o=null),r-a){var l={startOffset:r,endOffset:a,type:o};this.hls.trigger(x.BUFFER_FLUSHING,l)}},t._loadInitSegment=function(r,a){var o=this;this._doFragLoad(r,a).then(function(l){if(!l||o.fragContextChanged(r)||!o.levels)throw new Error("init load aborted");return l}).then(function(l){var h=o.hls,u=l.payload,f=r.decryptdata;if(u&&u.byteLength>0&&f&&f.key&&f.iv&&f.method==="AES-128"){var p=self.performance.now();return o.decrypter.decrypt(new Uint8Array(u),f.key.buffer,f.iv.buffer).catch(function(v){throw h.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_DECRYPT_ERROR,fatal:!1,error:v,reason:v.message,frag:r}),v}).then(function(v){var w=self.performance.now();return h.trigger(x.FRAG_DECRYPTED,{frag:r,payload:v,stats:{tstart:p,tdecrypt:w}}),l.payload=v,l})}return l}).then(function(l){var h=o.fragCurrent,u=o.hls;if(!o.levels)throw new Error("init load aborted, missing levels");var f=r.stats;o.state=Qe,a.fragmentError=0,r.data=new Uint8Array(l.payload),f.parsing.start=f.buffering.start=self.performance.now(),f.parsing.end=f.buffering.end=self.performance.now(),l.frag===h&&u.trigger(x.FRAG_BUFFERED,{stats:f,frag:h,part:null,id:r.type}),o.tick()}).catch(function(l){o.state!==Vt&&o.state!==Li&&(o.warn(l),o.resetFragmentLoading(r))})},t.fragContextChanged=function(r){var a=this.fragCurrent;return!r||!a||r.level!==a.level||r.sn!==a.sn||r.urlId!==a.urlId},t.fragBufferedComplete=function(r,a){var o,l,h,u,f=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+r.type+" sn: "+r.sn+(a?" part: "+a.index:"")+" of "+(this.playlistType===Je?"level":"track")+" "+r.level+" (frag:["+((o=r.startPTS)!=null?o:NaN).toFixed(3)+"-"+((l=r.endPTS)!=null?l:NaN).toFixed(3)+"] > buffer:"+(f?ym(ct.getBuffered(f)):"(detached)")+")"),this.state=Qe,f&&(!this.loadedmetadata&&r.type==Je&&f.buffered.length&&((h=this.fragCurrent)==null?void 0:h.sn)===((u=this.fragPrevious)==null?void 0:u.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},t.seekToStartPos=function(){},t._handleFragmentLoadComplete=function(r){var a=this.transmuxer;if(a){var o=r.frag,l=r.part,h=r.partsLoaded,u=!h||h.length===0||h.some(function(p){return!p}),f=new fl(o.level,o.sn,o.stats.chunkCount+1,0,l?l.index:-1,!u);a.flush(f)}},t._handleFragmentLoadProgress=function(r){},t._doFragLoad=function(r,a,o,l){var h,u=this;o===void 0&&(o=null);var f=a?.details;if(!this.levels||!f)throw new Error("frag load aborted, missing level"+(f?"":" detail")+"s");var p=null;if(!r.encrypted||(h=r.decryptdata)!=null&&h.key?!r.encrypted&&f.encryptedFragments.length&&this.keyLoader.loadClear(r,f.encryptedFragments):(this.log("Loading key for "+r.sn+" of ["+f.startSN+"-"+f.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+r.level),this.state=vl,this.fragCurrent=r,p=this.keyLoader.load(r).then(function(B){if(!u.fragContextChanged(B.frag))return u.hls.trigger(x.KEY_LOADED,B),u.state===vl&&(u.state=Qe),B}),this.hls.trigger(x.KEY_LOADING,{frag:r}),this.fragCurrent===null&&(p=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),o=Math.max(r.start,o||0),this.config.lowLatencyMode&&r.sn!=="initSegment"){var v=f.partList;if(v&&l){o>r.end&&f.fragmentHint&&(r=f.fragmentHint);var w=this.getNextPart(v,r,o);if(w>-1){var C,k=v[w];return this.log("Loading part sn: "+r.sn+" p: "+k.index+" cc: "+r.cc+" of playlist ["+f.startSN+"-"+f.endSN+"] parts [0-"+w+"-"+(v.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+r.level+", target: "+parseFloat(o.toFixed(3))),this.nextLoadPosition=k.start+k.duration,this.state=Di,C=p?p.then(function(B){return!B||u.fragContextChanged(B.frag)?null:u.doFragPartsLoad(r,k,a,l)}).catch(function(B){return u.handleFragLoadError(B)}):this.doFragPartsLoad(r,k,a,l).catch(function(B){return u.handleFragLoadError(B)}),this.hls.trigger(x.FRAG_LOADING,{frag:r,part:k,targetBufferTime:o}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):C}if(!r.url||this.loadedEndOfParts(v,o))return Promise.resolve(null)}}this.log("Loading fragment "+r.sn+" cc: "+r.cc+" "+(f?"of ["+f.startSN+"-"+f.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+r.level+", target: "+parseFloat(o.toFixed(3))),se(r.sn)&&!this.bitrateTest&&(this.nextLoadPosition=r.start+r.duration),this.state=Di;var I,D=this.config.progressive;return I=D&&p?p.then(function(B){return!B||u.fragContextChanged(B?.frag)?null:u.fragmentLoader.load(r,l)}).catch(function(B){return u.handleFragLoadError(B)}):Promise.all([this.fragmentLoader.load(r,D?l:void 0),p]).then(function(B){var T=B[0];return!D&&T&&l&&l(T),T}).catch(function(B){return u.handleFragLoadError(B)}),this.hls.trigger(x.FRAG_LOADING,{frag:r,targetBufferTime:o}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):I},t.doFragPartsLoad=function(r,a,o,l){var h=this;return new Promise(function(u,f){var p,v=[],w=(p=o.details)==null?void 0:p.partList;(function C(k){h.fragmentLoader.loadPart(r,k,l).then(function(I){v[k.index]=I;var D=I.part;h.hls.trigger(x.FRAG_LOADED,I);var B=Ku(o,r.sn,k.index+1)||zu(w,r.sn,k.index+1);if(!B)return u({frag:r,part:D,partsLoaded:v});C(B)}).catch(f)})(a)})},t.handleFragLoadError=function(r){if("data"in r){var a=r.data;r.data&&a.details===q.INTERNAL_ABORTED?this.handleFragLoadAborted(a.frag,a.part):this.hls.trigger(x.ERROR,a)}else this.hls.trigger(x.ERROR,{type:ue.OTHER_ERROR,details:q.INTERNAL_EXCEPTION,err:r,error:r,fatal:!0});return null},t._handleTransmuxerFlush=function(r){var a=this.getCurrentContext(r);if(a&&this.state===Ur){var o=a.frag,l=a.part,h=a.level,u=self.performance.now();o.stats.parsing.end=u,l&&(l.stats.parsing.end=u),this.updateLevelTiming(o,l,h,r.partial)}else this.fragCurrent||this.state===Vt||this.state===Li||(this.state=Qe)},t.getCurrentContext=function(r){var a=this.levels,o=this.fragCurrent,l=r.level,h=r.sn,u=r.part;if(a==null||!a[l])return this.warn("Levels object was unset while buffering fragment "+h+" of level "+l+". The current chunk will not be buffered."),null;var f=a[l],p=u>-1?Ku(f,h,u):null,v=p?p.fragment:(function(w,C,k){if(w==null||!w.details)return null;var I=w.details,D=I.fragments[C-I.startSN];return D||((D=I.fragmentHint)&&D.sn===C?D:C<I.startSN&&k&&k.sn===C?k:null)})(f,h,o);return v?(o&&o!==v&&(v.stats=o.stats),{frag:v,part:p,level:f}):null},t.bufferFragmentData=function(r,a,o,l,h){var u;if(r&&this.state===Ur){var f=r.data1,p=r.data2,v=f;if(f&&p&&(v=ni(f,p)),(u=v)!=null&&u.length){var w={type:r.type,frag:a,part:o,chunkMeta:l,parent:a.type,data:v};if(this.hls.trigger(x.BUFFER_APPENDING,w),r.dropped&&r.independent&&!o){if(h)return;this.flushBufferGap(a)}}}},t.flushBufferGap=function(r){var a=this.media;if(a)if(ct.isBuffered(a,a.currentTime)){var o=a.currentTime,l=ct.bufferInfo(a,o,0),h=r.duration,u=Math.min(2*this.config.maxFragLookUpTolerance,.25*h),f=Math.max(Math.min(r.start-u,l.end-u),o+u);r.start-f>u&&this.flushMainBuffer(f,r.start)}else this.flushMainBuffer(0,r.start)},t.getFwdBufferInfo=function(r,a){var o=this.getLoadPosition();return se(o)?this.getFwdBufferInfoAtPos(r,o,a):null},t.getFwdBufferInfoAtPos=function(r,a,o){var l=this.config.maxBufferHole,h=ct.bufferInfo(r,a,l);if(h.len===0&&h.nextStart!==void 0){var u=this.fragmentTracker.getBufferedFrag(a,o);if(u&&h.nextStart<u.end)return ct.bufferInfo(r,a,Math.max(h.nextStart,l))}return h},t.getMaxBufferLength=function(r){var a,o=this.config;return a=r?Math.max(8*o.maxBufferSize/r,o.maxBufferLength):o.maxBufferLength,Math.min(a,o.maxMaxBufferLength)},t.reduceMaxBufferLength=function(r){var a=this.config,o=r||a.maxBufferLength;return a.maxMaxBufferLength>=o&&(a.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+a.maxMaxBufferLength+"s"),!0)},t.getAppendedFrag=function(r,a){var o=this.fragmentTracker.getAppendedFrag(r,Je);return o&&"fragment"in o?o.fragment:o},t.getNextFragment=function(r,a){var o=a.fragments,l=o.length;if(!l)return null;var h,u=this.config,f=o[0].start;if(a.live){var p=u.initialLiveManifestSize;if(l<p)return this.warn("Not enough fragments to start playback (have: "+l+", need: "+p+")"),null;a.PTSKnown||this.startFragRequested||this.startPosition!==-1||(h=this.getInitialLiveFragment(a,o),this.startPosition=h?this.hls.liveSyncPosition||h.start:r)}else r<=f&&(h=o[0]);if(!h){var v=u.lowLatencyMode?a.partEnd:a.fragmentEnd;h=this.getFragmentAtPosition(r,v,a)}return this.mapToInitFragWhenRequired(h)},t.isLoopLoading=function(r,a){var o=this.fragmentTracker.getState(r);return(o===wa||o===xi&&!!r.gap)&&this.nextLoadPosition>a},t.getNextFragmentLoopLoading=function(r,a,o,l,h){var u=r.gap,f=this.getNextFragment(this.nextLoadPosition,a);if(f===null)return f;if(r=f,u&&r&&!r.gap&&o.nextStart){var p=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,o.nextStart,l);if(p!==null&&o.len+p.len>=h)return this.log('buffer full after gaps in "'+l+'" playlist starting at sn: '+r.sn),null}return r},t.mapToInitFragWhenRequired=function(r){return r==null||!r.initSegment||r!=null&&r.initSegment.data||this.bitrateTest?r:r.initSegment},t.getNextPart=function(r,a,o){for(var l=-1,h=!1,u=!0,f=0,p=r.length;f<p;f++){var v=r[f];if(u=u&&!v.independent,l>-1&&o<v.start)break;var w=v.loaded;w?l=-1:(h||v.independent||u)&&v.fragment===a&&(l=f),h=w}return l},t.loadedEndOfParts=function(r,a){var o=r[r.length-1];return o&&a>o.start&&o.loaded},t.getInitialLiveFragment=function(r,a){var o=this.fragPrevious,l=null;if(o){if(r.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+o.programDateTime),l=(function(p,v,w){if(v===null||!Array.isArray(p)||!p.length||!se(v)||v<(p[0].programDateTime||0)||v>=(p[p.length-1].endProgramDateTime||0))return null;w=w||0;for(var C=0;C<p.length;++C){var k=p[C];if(sm(v,w,k))return k}return null})(a,o.endProgramDateTime,this.config.maxFragLookUpTolerance)),!l){var h=o.sn+1;if(h>=r.startSN&&h<=r.endSN){var u=a[h-r.startSN];o.cc===u.cc&&(l=u,this.log("Live playlist, switching playlist, load frag with next SN: "+l.sn))}l||(l=(function(p,v){return Wu(p,function(w){return w.cc<v?1:w.cc>v?-1:0})})(a,o.cc),l&&this.log("Live playlist, switching playlist, load frag with same CC: "+l.sn))}}else{var f=this.hls.liveSyncPosition;f!==null&&(l=this.getFragmentAtPosition(f,this.bitrateTest?r.fragmentEnd:r.edge,r))}return l},t.getFragmentAtPosition=function(r,a,o){var l,h=this.config,u=this.fragPrevious,f=o.fragments,p=o.endSN,v=o.fragmentHint,w=h.maxFragLookUpTolerance,C=o.partList,k=!!(h.lowLatencyMode&&C!=null&&C.length&&v);if(k&&v&&!this.bitrateTest&&(f=f.concat(v),p=v.sn),l=r<a?ba(u,f,r,r>a-w?0:w):f[f.length-1]){var I=l.sn-o.startSN,D=this.fragmentTracker.getState(l);if((D===wa||D===xi&&l.gap)&&(u=l),u&&l.sn===u.sn&&(!k||C[0].fragment.sn>l.sn)&&u&&l.level===u.level){var B=f[I+1];l=l.sn<p&&this.fragmentTracker.getState(B)!==wa?B:null}}return l},t.synchronizeToLiveEdge=function(r){var a=this.config,o=this.media;if(o){var l=this.hls.liveSyncPosition,h=o.currentTime,u=r.fragments[0].start,f=r.edge,p=h>=u-a.maxFragLookUpTolerance&&h<=f;if(l!==null&&o.duration>l&&(h<l||!p)){var v=a.liveMaxLatencyDuration!==void 0?a.liveMaxLatencyDuration:a.liveMaxLatencyDurationCount*r.targetduration;(!p&&o.readyState<4||h<f-v)&&(this.loadedmetadata||(this.nextLoadPosition=l),o.readyState&&(this.warn("Playback: "+h.toFixed(3)+" is located too far from the end of live sliding playlist: "+f+", reset currentTime to : "+l.toFixed(3)),o.currentTime=l))}}},t.alignPlaylists=function(r,a){var o=this.levels,l=this.levelLastLoaded,h=this.fragPrevious,u=l!==null?o[l]:null,f=r.fragments.length;if(!f)return this.warn("No fragments in live playlist"),0;var p=r.fragments[0].start,v=!a,w=r.alignedSliding&&se(p);if(v||!w&&!p){mm(h,u,r);var C=r.fragments[0].start;return this.log("Live playlist sliding: "+C.toFixed(2)+" start-sn: "+(a?a.startSN:"na")+"->"+r.startSN+" prev-sn: "+(h?h.sn:"na")+" fragments: "+f),C}return p},t.waitForCdnTuneIn=function(r){return r.live&&r.canBlockReload&&r.partTarget&&r.tuneInGoal>Math.max(r.partHoldBack,3*r.partTarget)},t.setStartPosition=function(r,a){var o=this.startPosition;if(o<a&&(o=-1),o===-1||this.lastCurrentTime===-1){var l=this.startTimeOffset!==null,h=l?this.startTimeOffset:r.startTimeOffset;h!==null&&se(h)?(o=a+h,h<0&&(o+=r.totalduration),o=Math.min(Math.max(a,o),a+r.totalduration),this.log("Start time offset "+h+" found in "+(l?"multivariant":"media")+" playlist, adjust startPosition to "+o),this.startPosition=o):r.live?o=this.hls.liveSyncPosition||a:this.startPosition=o=0,this.lastCurrentTime=o}this.nextLoadPosition=o},t.getLoadPosition=function(){var r=this.media,a=0;return this.loadedmetadata&&r?a=r.currentTime:this.nextLoadPosition&&(a=this.nextLoadPosition),a},t.handleFragLoadAborted=function(r,a){this.transmuxer&&r.sn!=="initSegment"&&r.stats.aborted&&(this.warn("Fragment "+r.sn+(a?" part "+a.index:"")+" of level "+r.level+" was aborted"),this.resetFragmentLoading(r))},t.resetFragmentLoading=function(r){this.fragCurrent&&(this.fragContextChanged(r)||this.state===Ri)||(this.state=Qe)},t.onFragmentOrKeyLoadError=function(r,a){if(a.chunkMeta&&!a.frag){var o=this.getCurrentContext(a.chunkMeta);o&&(a.frag=o.frag)}var l=a.frag;if(l&&l.type===r&&this.levels)if(this.fragContextChanged(l)){var h;this.warn("Frag load error must match current frag to retry "+l.url+" > "+((h=this.fragCurrent)==null?void 0:h.url))}else{var u=a.details===q.FRAG_GAP;u&&this.fragmentTracker.fragBuffered(l,!0);var f=a.errorAction,p=f||{},v=p.action,w=p.retryCount,C=w===void 0?0:w,k=p.retryConfig;if(f&&v===Ln&&k){var I;this.resetStartWhenNotLoaded((I=this.levelLastLoaded)!=null?I:l.level);var D=cl(k,C);this.warn("Fragment "+l.sn+" of "+r+" "+l.level+" errored with "+a.details+", retrying loading "+(C+1)+"/"+k.maxNumRetry+" in "+D+"ms"),f.resolved=!0,this.retryDate=self.performance.now()+D,this.state=Ri}else k&&f?(this.resetFragmentErrors(r),C<k.maxNumRetry?u||(f.resolved=!0):G.warn(a.details+" reached or exceeded max retry ("+C+")")):f?.action===Or?this.state=si:this.state=Li;this.tickImmediate()}},t.reduceLengthAndFlushBuffer=function(r){if(this.state===Ur||this.state===Pn){var a=r.parent,o=this.getFwdBufferInfo(this.mediaBuffer,a),l=o&&o.len>.5;l&&this.reduceMaxBufferLength(o.len);var h=!l;return h&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+a+" buffer"),r.frag&&(this.fragmentTracker.removeFragment(r.frag),this.nextLoadPosition=r.frag.start),this.resetLoadingState(),h}return!1},t.resetFragmentErrors=function(r){r===Cr&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Vt&&(this.state=Qe)},t.afterBufferFlushed=function(r,a,o){if(r){var l=ct.getBuffered(r);this.fragmentTracker.detectEvictedFragments(a,l,o),this.state===Ea&&this.resetLoadingState()}},t.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Qe},t.resetStartWhenNotLoaded=function(r){if(!this.loadedmetadata){this.startFragRequested=!1;var a=this.levels?this.levels[r].details:null;a!=null&&a.live?(this.startPosition=-1,this.setStartPosition(a,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},t.resetWhenMissingContext=function(r){var a;this.warn("The loading context changed while buffering fragment "+r.sn+" of level "+r.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((a=this.levelLastLoaded)!=null?a:r.level),this.resetLoadingState()},t.removeUnbufferedFrags=function(r){r===void 0&&(r=0),this.fragmentTracker.removeFragmentsInRange(r,1/0,this.playlistType,!1,!0)},t.updateLevelTiming=function(r,a,o,l){var h,u=this,f=o.details;if(f){if(Object.keys(r.elementaryStreams).reduce(function(v,w){var C=r.elementaryStreams[w];if(C){var k=C.endPTS-C.startPTS;if(k<=0)return u.warn("Could not parse fragment "+r.sn+" "+w+" duration reliably ("+k+")"),v||!1;var I=l?0:Gu(f,r,C.startPTS,C.endPTS,C.startDTS,C.endDTS);return u.hls.trigger(x.LEVEL_PTS_UPDATED,{details:f,level:o,drift:I,type:w,frag:r,start:C.startPTS,end:C.endPTS}),!0}return v},!1))o.fragmentError=0;else if(((h=this.transmuxer)==null?void 0:h.error)===null){var p=new Error("Found no media in fragment "+r.sn+" of level "+r.level+" resetting transmuxer to fallback to playlist timing");if(o.fragmentError===0&&(o.fragmentError++,r.gap=!0,this.fragmentTracker.removeFragment(r),this.fragmentTracker.fragBuffered(r,!0)),this.warn(p.message),this.hls.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!1,error:p,frag:r,reason:"Found no media in msn "+r.sn+' of level "'+o.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=Pn,this.hls.trigger(x.FRAG_PARSED,{frag:r,part:a})}else this.warn("level.details undefined")},t.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},t.recoverWorkerError=function(r){var a,o,l;r.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((a=(o=this.levelLastLoaded)!=null?o:(l=this.fragCurrent)==null?void 0:l.level)!=null?a:0),this.resetLoadingState())},F(s,[{key:"state",get:function(){return this._state},set:function(r){var a=this._state;a!==r&&(this._state=r,this.log(a+"->"+r))}}]),s})(fm);function ig(){return self.SourceBuffer||self.WebKitSourceBuffer}function Er(d,s){return d===void 0&&(d=""),s===void 0&&(s=9e4),{type:d,id:-1,pid:-1,inputTimeScale:s,sequenceNumber:-1,samples:[],dropped:0}}var ag=(function(){function d(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var s=d.prototype;return s.resetInitSegment=function(t,r,a,o){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},s.resetTimeStamp=function(t){this.initPTS=t,this.resetContiguity()},s.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},s.canParse=function(t,r){return!1},s.appendFrame=function(t,r,a){},s.demux=function(t,r){this.cachedData&&(t=ni(this.cachedData,t),this.cachedData=null);var a,o=kn(t,0),l=o?o.length:0,h=this._audioTrack,u=this._id3Track,f=o?(function(C){for(var k=pu(C),I=0;I<k.length;I++){var D=k[I];if(fu(D))return Yp(D)}})(o):void 0,p=t.length;for((this.basePTS===null||this.frameIndex===0&&se(f))&&(this.basePTS=wm(f,r,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),o&&o.length>0&&u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:o,type:ma,duration:Number.POSITIVE_INFINITY});l<p;){if(this.canParse(t,l)){var v=this.appendFrame(h,t,l);v?(this.frameIndex++,this.lastPTS=v.sample.pts,a=l+=v.length):l=p}else Pp(t,l)?(o=kn(t,l),u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:o,type:ma,duration:Number.POSITIVE_INFINITY}),a=l+=o.length):l++;if(l===p&&a!==p){var w=ai(t,a);this.cachedData?this.cachedData=ni(this.cachedData,w):this.cachedData=w}}return{audioTrack:h,videoTrack:Er(),id3Track:u,textTrack:Er()}},s.demuxSampleAes=function(t,r,a){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},s.flush=function(t){var r=this.cachedData;return r&&(this.cachedData=null,this.demux(r,0)),{audioTrack:this._audioTrack,videoTrack:Er(),id3Track:this._id3Track,textTrack:Er()}},s.destroy=function(){},d})(),wm=function(d,s,t){return se(d)?90*d:9e4*s+(t?9e4*t.baseTime/t.timescale:0)};function ng(d,s){return d[s]===255&&(246&d[s+1])==240}function og(d,s){return 1&d[s+1]?7:9}function bl(d,s){return(3&d[s+3])<<11|d[s+4]<<3|(224&d[s+5])>>>5}function Un(d,s){return s+1<d.length&&ng(d,s)}function Cm(d,s){if(Un(d,s)){var t=og(d,s);if(s+t>=d.length)return!1;var r=bl(d,s);if(r<=t)return!1;var a=s+r;return a===d.length||Un(d,a)}return!1}function sg(d,s,t,r,a){if(!d.samplerate){var o=(function(l,h,u,f){var p,v,w,C,k=navigator.userAgent.toLowerCase(),I=f,D=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];p=1+((192&h[u+2])>>>6);var B=(60&h[u+2])>>>2;if(!(B>D.length-1))return w=(1&h[u+2])<<2,w|=(192&h[u+3])>>>6,G.log("manifest codec:"+f+", ADTS type:"+p+", samplingIndex:"+B),/firefox/i.test(k)?B>=6?(p=5,C=new Array(4),v=B-3):(p=2,C=new Array(2),v=B):k.indexOf("android")!==-1?(p=2,C=new Array(2),v=B):(p=5,C=new Array(4),f&&(f.indexOf("mp4a.40.29")!==-1||f.indexOf("mp4a.40.5")!==-1)||!f&&B>=6?v=B-3:((f&&f.indexOf("mp4a.40.2")!==-1&&(B>=6&&w===1||/vivaldi/i.test(k))||!f&&w===1)&&(p=2,C=new Array(2)),v=B)),C[0]=p<<3,C[0]|=(14&B)>>1,C[1]|=(1&B)<<7,C[1]|=w<<3,p===5&&(C[1]|=(14&v)>>1,C[2]=(1&v)<<7,C[2]|=8,C[3]=0),{config:C,samplerate:D[B],channelCount:w,codec:"mp4a.40."+p,manifestCodec:I};l.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+B})})(s,t,r,a);if(!o)return;d.config=o.config,d.samplerate=o.samplerate,d.channelCount=o.channelCount,d.codec=o.codec,d.manifestCodec=o.manifestCodec,G.log("parsed codec:"+d.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function lg(d){return 9216e4/d}function cg(d,s,t,r,a){var o,l=r+a*lg(d.samplerate),h=(function(k,I){var D=og(k,I);if(I+D<=k.length){var B=bl(k,I)-D;if(B>0)return{headerLength:D,frameLength:B}}})(s,t);if(h){var u=h.frameLength,f=h.headerLength,p=f+u,v=Math.max(0,t+p-s.length);v?(o=new Uint8Array(p-f)).set(s.subarray(t+f,s.length),0):o=s.subarray(t+f,t+p);var w={unit:o,pts:l};return v||d.samples.push(w),{sample:w,length:p,missing:v}}var C=s.length-t;return(o=new Uint8Array(C)).set(s.subarray(t,s.length),0),{sample:{unit:o,pts:l},length:C,missing:-1}}var Em=(function(d){function s(r,a){var o;return(o=d.call(this)||this).observer=void 0,o.config=void 0,o.observer=r,o.config=a,o}X(s,d);var t=s.prototype;return t.resetInitSegment=function(r,a,o,l){d.prototype.resetInitSegment.call(this,r,a,o,l),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:a,duration:l,inputTimeScale:9e4,dropped:0}},s.probe=function(r){if(!r)return!1;for(var a=(kn(r,0)||[]).length,o=r.length;a<o;a++)if(Cm(r,a))return G.log("ADTS sync word found !"),!0;return!1},t.canParse=function(r,a){return(function(o,l){return(function(h,u){return u+5<h.length})(o,l)&&ng(o,l)&&bl(o,l)<=o.length-l})(r,a)},t.appendFrame=function(r,a,o){sg(r,this.observer,a,o,r.manifestCodec);var l=cg(r,a,o,this.basePTS,this.frameIndex);if(l&&l.missing===0)return l},s})(ag),km=/\/emsg[-/]ID3/i,Bm=(function(){function d(t,r){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=r}var s=d.prototype;return s.resetTimeStamp=function(){},s.resetInitSegment=function(t,r,a,o){var l=this.videoTrack=Er("video",1),h=this.audioTrack=Er("audio",1),u=this.txtTrack=Er("text",1);if(this.id3Track=Er("id3",1),this.timeOffset=0,t!=null&&t.byteLength){var f=bu(t);if(f.video){var p=f.video,v=p.id,w=p.timescale,C=p.codec;l.id=v,l.timescale=u.timescale=w,l.codec=C}if(f.audio){var k=f.audio,I=k.id,D=k.timescale,B=k.codec;h.id=I,h.timescale=D,h.codec=B}u.id=mu.text,l.sampleDuration=0,l.duration=h.duration=o}},s.resetContiguity=function(){this.remainderData=null},d.probe=function(t){return Ye(t=t.length>16384?t.subarray(0,16384):t,["moof"]).length>0},s.demux=function(t,r){this.timeOffset=r;var a=t,o=this.videoTrack,l=this.txtTrack;if(this.config.progressive){this.remainderData&&(a=ni(this.remainderData,t));var h=(function(f){var p={valid:null,remainder:null},v=Ye(f,["moof"]);if(!v)return p;if(v.length<2)return p.remainder=f,p;var w=v[v.length-1];return p.valid=ai(f,0,w.byteOffset-8),p.remainder=ai(f,w.byteOffset-8),p})(a);this.remainderData=h.remainder,o.samples=h.valid||new Uint8Array}else o.samples=a;var u=this.extractID3Track(o,r);return l.samples=wu(r,o),{videoTrack:o,audioTrack:this.audioTrack,id3Track:u,textTrack:this.txtTrack}},s.flush=function(){var t=this.timeOffset,r=this.videoTrack,a=this.txtTrack;r.samples=this.remainderData||new Uint8Array,this.remainderData=null;var o=this.extractID3Track(r,this.timeOffset);return a.samples=wu(t,r),{videoTrack:r,audioTrack:Er(),id3Track:o,textTrack:Er()}},s.extractID3Track=function(t,r){var a=this.id3Track;if(t.samples.length){var o=Ye(t.samples,["emsg"]);o&&o.forEach(function(l){var h=(function(v){var w=v[0],C="",k="",I=0,D=0,B=0,T=0,U=0,M=0;if(w===0){for(;yt(v.subarray(M,M+1))!=="\0";)C+=yt(v.subarray(M,M+1)),M+=1;for(C+=yt(v.subarray(M,M+1)),M+=1;yt(v.subarray(M,M+1))!=="\0";)k+=yt(v.subarray(M,M+1)),M+=1;k+=yt(v.subarray(M,M+1)),M+=1,I=Re(v,12),D=Re(v,16),T=Re(v,20),U=Re(v,24),M=28}else if(w===1){I=Re(v,M+=4);var H=Re(v,M+=4),V=Re(v,M+=4);for(M+=4,B=Math.pow(2,32)*H+V,Number.isSafeInteger(B)||(B=Number.MAX_SAFE_INTEGER,G.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),T=Re(v,M),U=Re(v,M+=4),M+=4;yt(v.subarray(M,M+1))!=="\0";)C+=yt(v.subarray(M,M+1)),M+=1;for(C+=yt(v.subarray(M,M+1)),M+=1;yt(v.subarray(M,M+1))!=="\0";)k+=yt(v.subarray(M,M+1)),M+=1;k+=yt(v.subarray(M,M+1)),M+=1}return{schemeIdUri:C,value:k,timeScale:I,presentationTime:B,presentationTimeDelta:D,eventDuration:T,id:U,payload:v.subarray(M,v.byteLength)}})(l);if(km.test(h.schemeIdUri)){var u=se(h.presentationTime)?h.presentationTime/h.timeScale:r+h.presentationTimeDelta/h.timeScale,f=h.eventDuration===4294967295?Number.POSITIVE_INFINITY:h.eventDuration/h.timeScale;f<=.001&&(f=Number.POSITIVE_INFINITY);var p=h.payload;a.samples.push({data:p,len:p.byteLength,dts:u,pts:u,type:va,duration:f})}})}return a},s.demuxSampleAes=function(t,r,a){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},s.destroy=function(){},d})(),Qn=null,Im=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],Sm=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],xm=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Tm=[0,1,1,4];function dg(d,s,t,r,a){if(!(t+24>s.length)){var o=hg(s,t);if(o&&t+o.frameLength<=s.length){var l=r+a*(9e4*o.samplesPerFrame/o.sampleRate),h={unit:s.subarray(t,t+o.frameLength),pts:l,dts:l};return d.config=[],d.channelCount=o.channelCount,d.samplerate=o.sampleRate,d.samples.push(h),{sample:h,length:o.frameLength,missing:0}}}}function hg(d,s){var t=d[s+1]>>3&3,r=d[s+1]>>1&3,a=d[s+2]>>4&15,o=d[s+2]>>2&3;if(t!==1&&a!==0&&a!==15&&o!==3){var l=d[s+2]>>1&1,h=d[s+3]>>6,u=1e3*Im[14*(t===3?3-r:r===3?3:4)+a-1],f=Sm[3*(t===3?0:t===2?1:2)+o],p=h===3?1:2,v=xm[t][r],w=Tm[r],C=8*v*w,k=Math.floor(v*u/f+l)*w;if(Qn===null){var I=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Qn=I?parseInt(I[1]):0}return Qn&&Qn<=87&&r===2&&u>=224e3&&h===0&&(d[s+3]=128|d[s+3]),{sampleRate:f,channelCount:p,frameLength:k,samplesPerFrame:C}}}function yl(d,s){return d[s]===255&&(224&d[s+1])==224&&(6&d[s+1])!=0}function ug(d,s){return s+1<d.length&&yl(d,s)}function Dm(d,s){if(s+1<d.length&&yl(d,s)){var t=hg(d,s),r=4;t!=null&&t.frameLength&&(r=t.frameLength);var a=s+r;return a===d.length||ug(d,a)}return!1}var gg=(function(){function d(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}var s=d.prototype;return s.loadWord=function(){var t=this.data,r=this.bytesAvailable,a=t.byteLength-r,o=new Uint8Array(4),l=Math.min(4,r);if(l===0)throw new Error("no bytes available");o.set(t.subarray(a,a+l)),this.word=new DataView(o.buffer).getUint32(0),this.bitsAvailable=8*l,this.bytesAvailable-=l},s.skipBits=function(t){var r;t=Math.min(t,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,t-=(r=t>>3)<<3,this.bytesAvailable-=r,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},s.readBits=function(t){var r=Math.min(this.bitsAvailable,t),a=this.word>>>32-r;if(t>32&&G.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=r,this.bitsAvailable>0)this.word<<=r;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(r=t-r)>0&&this.bitsAvailable?a<<r|this.readBits(r):a},s.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if((this.word&2147483648>>>t)!=0)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},s.skipUEG=function(){this.skipBits(1+this.skipLZ())},s.skipEG=function(){this.skipBits(1+this.skipLZ())},s.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},s.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},s.readBoolean=function(){return this.readBits(1)===1},s.readUByte=function(){return this.readBits(8)},s.readUShort=function(){return this.readBits(16)},s.readUInt=function(){return this.readBits(32)},s.skipScalingList=function(t){for(var r=8,a=8,o=0;o<t;o++)a!==0&&(a=(r+this.readEG()+256)%256),r=a===0?r:a},s.readSPS=function(){var t,r,a,o=0,l=0,h=0,u=0,f=this.readUByte.bind(this),p=this.readBits.bind(this),v=this.readUEG.bind(this),w=this.readBoolean.bind(this),C=this.skipBits.bind(this),k=this.skipEG.bind(this),I=this.skipUEG.bind(this),D=this.skipScalingList.bind(this);f();var B=f();if(p(5),C(3),f(),I(),B===100||B===110||B===122||B===244||B===44||B===83||B===86||B===118||B===128){var T=v();if(T===3&&C(1),I(),I(),C(1),w())for(r=T!==3?8:12,a=0;a<r;a++)w()&&D(a<6?16:64)}I();var U=v();if(U===0)v();else if(U===1)for(C(1),k(),k(),t=v(),a=0;a<t;a++)k();I(),C(1);var M=v(),H=v(),V=p(1);V===0&&C(1),C(1),w()&&(o=v(),l=v(),h=v(),u=v());var W=[1,1];if(w()&&w())switch(f()){case 1:W=[1,1];break;case 2:W=[12,11];break;case 3:W=[10,11];break;case 4:W=[16,11];break;case 5:W=[40,33];break;case 6:W=[24,11];break;case 7:W=[20,11];break;case 8:W=[32,11];break;case 9:W=[80,33];break;case 10:W=[18,11];break;case 11:W=[15,11];break;case 12:W=[64,33];break;case 13:W=[160,99];break;case 14:W=[4,3];break;case 15:W=[3,2];break;case 16:W=[2,1];break;case 255:W=[f()<<8|f(),f()<<8|f()]}return{width:Math.ceil(16*(M+1)-2*o-2*l),height:(2-V)*(H+1)*16-(V?2:4)*(h+u),pixelRatio:W}},s.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},d})(),Rm=(function(){function d(t,r,a){this.keyData=void 0,this.decrypter=void 0,this.keyData=a,this.decrypter=new ml(r,{removePKCS7Padding:!1})}var s=d.prototype;return s.decryptBuffer=function(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)},s.decryptAacSample=function(t,r,a){var o=this,l=t[r].unit;if(!(l.length<=16)){var h=l.subarray(16,l.length-l.length%16),u=h.buffer.slice(h.byteOffset,h.byteOffset+h.length);this.decryptBuffer(u).then(function(f){var p=new Uint8Array(f);l.set(p,16),o.decrypter.isSync()||o.decryptAacSamples(t,r+1,a)})}},s.decryptAacSamples=function(t,r,a){for(;;r++){if(r>=t.length)return void a();if(!(t[r].unit.length<32||(this.decryptAacSample(t,r,a),this.decrypter.isSync())))return}},s.getAvcEncryptedData=function(t){for(var r=16*Math.floor((t.length-48)/160)+16,a=new Int8Array(r),o=0,l=32;l<t.length-16;l+=160,o+=16)a.set(t.subarray(l,l+16),o);return a},s.getAvcDecryptedUnit=function(t,r){for(var a=new Uint8Array(r),o=0,l=32;l<t.length-16;l+=160,o+=16)t.set(a.subarray(o,o+16),l);return t},s.decryptAvcSample=function(t,r,a,o,l){var h=this,u=Eu(l.data),f=this.getAvcEncryptedData(u);this.decryptBuffer(f.buffer).then(function(p){l.data=h.getAvcDecryptedUnit(u,p),h.decrypter.isSync()||h.decryptAvcSamples(t,r,a+1,o)})},s.decryptAvcSamples=function(t,r,a,o){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;r++,a=0){if(r>=t.length)return void o();for(var l=t[r].units;!(a>=l.length);a++){var h=l[a];if(!(h.data.length<=48||h.type!==1&&h.type!==5||(this.decryptAvcSample(t,r,a,o,h),this.decrypter.isSync())))return}}},d})(),Lt=188,Lm=(function(){function d(t,r,a){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=r,this.typeSupported=a}d.probe=function(t){var r=d.syncOffset(t);return r>0&&G.warn("MPEG2-TS detected but first sync word found @ offset "+r),r!==-1},d.syncOffset=function(t){for(var r=t.length,a=Math.min(940,t.length-Lt)+1,o=0;o<a;){for(var l=!1,h=-1,u=0,f=o;f<r;f+=Lt){if(t[f]!==71){if(u)return-1;break}if(u++,h===-1&&(h=f)!==0&&(a=Math.min(h+18612,t.length-Lt)+1),l||(l=wl(t,f)===0),l&&u>1&&(h===0&&u>2||f+Lt>a))return h}o++}return-1},d.createTrack=function(t,r){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:mu[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?r:void 0}};var s=d.prototype;return s.resetInitSegment=function(t,r,a,o){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=d.createTrack("video"),this._audioTrack=d.createTrack("audio",o),this._id3Track=d.createTrack("id3"),this._txtTrack=d.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=a,this._duration=o},s.resetTimeStamp=function(){},s.resetContiguity=function(){var t=this._audioTrack,r=this._avcTrack,a=this._id3Track;t&&(t.pesData=null),r&&(r.pesData=null),a&&(a.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},s.demux=function(t,r,a,o){var l;a===void 0&&(a=!1),o===void 0&&(o=!1),a||(this.sampleAes=null);var h=this._avcTrack,u=this._audioTrack,f=this._id3Track,p=this._txtTrack,v=h.pid,w=h.pesData,C=u.pid,k=f.pid,I=u.pesData,D=f.pesData,B=null,T=this.pmtParsed,U=this._pmtId,M=t.length;if(this.remainderData&&(M=(t=ni(this.remainderData,t)).length,this.remainderData=null),M<Lt&&!o)return this.remainderData=t,{audioTrack:u,videoTrack:h,id3Track:f,textTrack:p};var H=Math.max(0,d.syncOffset(t));(M-=(M-H)%Lt)<t.byteLength&&!o&&(this.remainderData=new Uint8Array(t.buffer,M,t.buffer.byteLength-M));for(var V=0,W=H;W<M;W+=Lt)if(t[W]===71){var $=!!(64&t[W+1]),J=wl(t,W),j=void 0;if((48&t[W+3])>>4>1){if((j=W+5+t[W+4])===W+Lt)continue}else j=W+4;switch(J){case v:$&&(w&&(l=Mi(w))&&this.parseAVCPES(h,p,l,!1),w={data:[],size:0}),w&&(w.data.push(t.subarray(j,W+Lt)),w.size+=W+Lt-j);break;case C:if($){if(I&&(l=Mi(I)))switch(u.segmentCodec){case"aac":this.parseAACPES(u,l);break;case"mp3":this.parseMPEGPES(u,l)}I={data:[],size:0}}I&&(I.data.push(t.subarray(j,W+Lt)),I.size+=W+Lt-j);break;case k:$&&(D&&(l=Mi(D))&&this.parseID3PES(f,l),D={data:[],size:0}),D&&(D.data.push(t.subarray(j,W+Lt)),D.size+=W+Lt-j);break;case 0:$&&(j+=t[j]+1),U=this._pmtId=Mm(t,j);break;case U:$&&(j+=t[j]+1);var le=Fm(t,j,this.typeSupported,a);(v=le.avc)>0&&(h.pid=v),(C=le.audio)>0&&(u.pid=C,u.segmentCodec=le.segmentCodec),(k=le.id3)>0&&(f.pid=k),B===null||T||(G.warn("MPEG-TS PMT found at "+W+" after unknown PID '"+B+"'. Backtracking to sync byte @"+H+" to parse all TS packets."),B=null,W=H-188),T=this.pmtParsed=!0;break;case 17:case 8191:break;default:B=J}}else V++;if(V>0){var ie=new Error("Found "+V+" TS packet/s that do not start with 0x47");this.observer.emit(x.ERROR,x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!1,error:ie,reason:ie.message})}h.pesData=w,u.pesData=I,f.pesData=D;var me={audioTrack:u,videoTrack:h,id3Track:f,textTrack:p};return o&&this.extractRemainingSamples(me),me},s.flush=function(){var t,r=this.remainderData;return this.remainderData=null,t=r?this.demux(r,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},s.extractRemainingSamples=function(t){var r,a=t.audioTrack,o=t.videoTrack,l=t.id3Track,h=t.textTrack,u=o.pesData,f=a.pesData,p=l.pesData;if(u&&(r=Mi(u))?(this.parseAVCPES(o,h,r,!0),o.pesData=null):o.pesData=u,f&&(r=Mi(f))){switch(a.segmentCodec){case"aac":this.parseAACPES(a,r);break;case"mp3":this.parseMPEGPES(a,r)}a.pesData=null}else f!=null&&f.size&&G.log("last AAC PES packet truncated,might overlap between fragments"),a.pesData=f;p&&(r=Mi(p))?(this.parseID3PES(l,r),l.pesData=null):l.pesData=p},s.demuxSampleAes=function(t,r,a){var o=this.demux(t,a,!0,!this.config.progressive),l=this.sampleAes=new Rm(this.observer,this.config,r);return this.decrypt(o,l)},s.decrypt=function(t,r){return new Promise(function(a){var o=t.audioTrack,l=t.videoTrack;o.samples&&o.segmentCodec==="aac"?r.decryptAacSamples(o.samples,0,function(){l.samples?r.decryptAvcSamples(l.samples,0,0,function(){a(t)}):a(t)}):l.samples&&r.decryptAvcSamples(l.samples,0,0,function(){a(t)})})},s.destroy=function(){this._duration=0},s.parseAVCPES=function(t,r,a,o){var l,h=this,u=this.parseAVCNALu(t,a.data),f=this.avcSample,p=!1;a.data=null,f&&u.length&&!t.audFound&&(Ba(f,t),f=this.avcSample=Nn(!1,a.pts,a.dts,"")),u.forEach(function(v){var w;switch(v.type){case 1:var C=!1;l=!0;var k,I=v.data;if(p&&I.length>4){var D=new gg(I).readSliceType();D!==2&&D!==4&&D!==7&&D!==9||(C=!0)}C&&(k=f)!=null&&k.frame&&!f.key&&(Ba(f,t),f=h.avcSample=null),f||(f=h.avcSample=Nn(!0,a.pts,a.dts,"")),f.frame=!0,f.key=C;break;case 5:l=!0,(w=f)!=null&&w.frame&&!f.key&&(Ba(f,t),f=h.avcSample=null),f||(f=h.avcSample=Nn(!0,a.pts,a.dts,"")),f.key=!0,f.frame=!0;break;case 6:l=!0,Cu(v.data,1,a.pts,r.samples);break;case 7:if(l=!0,p=!0,!t.sps){var B=v.data,T=new gg(B).readSPS();t.width=T.width,t.height=T.height,t.pixelRatio=T.pixelRatio,t.sps=[B],t.duration=h._duration;for(var U=B.subarray(1,4),M="avc1.",H=0;H<3;H++){var V=U[H].toString(16);V.length<2&&(V="0"+V),M+=V}t.codec=M}break;case 8:l=!0,t.pps||(t.pps=[v.data]);break;case 9:l=!1,t.audFound=!0,f&&Ba(f,t),f=h.avcSample=Nn(!1,a.pts,a.dts,"");break;case 12:l=!0;break;default:l=!1,f&&(f.debug+="unknown NAL "+v.type+" ")}f&&l&&f.units.push(v)}),o&&f&&(Ba(f,t),this.avcSample=null)},s.getLastNalUnit=function(t){var r,a,o=this.avcSample;if(o&&o.units.length!==0||(o=t[t.length-1]),(r=o)!=null&&r.units){var l=o.units;a=l[l.length-1]}return a},s.parseAVCNALu=function(t,r){var a,o,l=r.byteLength,h=t.naluState||0,u=h,f=[],p=0,v=-1,w=0;for(h===-1&&(v=0,w=31&r[0],h=0,p=1);p<l;)if(a=r[p++],h)if(h!==1)if(a)if(a===1){if(v>=0){var C={data:r.subarray(v,p-h-1),type:w};f.push(C)}else{var k=this.getLastNalUnit(t.samples);if(k&&(u&&p<=4-u&&k.state&&(k.data=k.data.subarray(0,k.data.byteLength-u)),(o=p-h-1)>0)){var I=new Uint8Array(k.data.byteLength+o);I.set(k.data,0),I.set(r.subarray(0,o),k.data.byteLength),k.data=I,k.state=0}}p<l?(v=p,w=31&r[p],h=0):h=-1}else h=0;else h=3;else h=a?0:2;else h=a?0:1;if(v>=0&&h>=0){var D={data:r.subarray(v,l),type:w,state:h};f.push(D)}if(f.length===0){var B=this.getLastNalUnit(t.samples);if(B){var T=new Uint8Array(B.data.byteLength+r.byteLength);T.set(B.data,0),T.set(r,B.data.byteLength),B.data=T}}return t.naluState=h,f},s.parseAACPES=function(t,r){var a,o,l,h=0,u=this.aacOverFlow,f=r.data;if(u){this.aacOverFlow=null;var p=u.missing,v=u.sample.unit.byteLength;if(p===-1){var w=new Uint8Array(v+f.byteLength);w.set(u.sample.unit,0),w.set(f,v),f=w}else{var C=v-p;u.sample.unit.set(f.subarray(0,p),C),t.samples.push(u.sample),h=u.missing}}for(a=h,o=f.length;a<o-1&&!Un(f,a);a++);if(a!==h){var k,I=a<o-1;k=I?"AAC PES did not start with ADTS header,offset:"+a:"No ADTS header found in AAC PES";var D=new Error(k);if(G.warn("parsing error: "+k),this.observer.emit(x.ERROR,x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!1,levelRetry:I,error:D,reason:k}),!I)return}if(sg(t,this.observer,f,a,this.audioCodec),r.pts!==void 0)l=r.pts;else{if(!u)return void G.warn("[tsdemuxer]: AAC PES unknown PTS");var B=lg(t.samplerate);l=u.sample.pts+B}for(var T,U=0;a<o;){if(a+=(T=cg(t,f,a,l,U)).length,T.missing){this.aacOverFlow=T;break}for(U++;a<o-1&&!Un(f,a);a++);}},s.parseMPEGPES=function(t,r){var a=r.data,o=a.length,l=0,h=0,u=r.pts;if(u!==void 0)for(;h<o;)if(ug(a,h)){var f=dg(t,a,h,u,l);if(!f)break;h+=f.length,l++}else h++;else G.warn("[tsdemuxer]: MPEG PES unknown PTS")},s.parseID3PES=function(t,r){if(r.pts!==void 0){var a=Y({},r,{type:this._avcTrack?va:ma,duration:Number.POSITIVE_INFINITY});t.samples.push(a)}else G.warn("[tsdemuxer]: ID3 PES unknown PTS")},d})();function Nn(d,s,t,r){return{key:d,frame:!1,pts:s,dts:t,units:[],debug:r,length:0}}function wl(d,s){return((31&d[s+1])<<8)+d[s+2]}function Mm(d,s){return(31&d[s+10])<<8|d[s+11]}function Fm(d,s,t,r){var a={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},o=s+3+((15&d[s+1])<<8|d[s+2])-4;for(s+=12+((15&d[s+10])<<8|d[s+11]);s<o;){var l=wl(d,s);switch(d[s]){case 207:if(!r){G.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:a.audio===-1&&(a.audio=l);break;case 21:a.id3===-1&&(a.id3=l);break;case 219:if(!r){G.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:a.avc===-1&&(a.avc=l);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?G.log("MPEG audio found, not supported in this browser"):a.audio===-1&&(a.audio=l,a.segmentCodec="mp3");break;case 36:G.warn("Unsupported HEVC stream type found")}s+=5+((15&d[s+3])<<8|d[s+4])}return a}function Mi(d){var s,t,r,a,o,l=0,h=d.data;if(!d||d.size===0)return null;for(;h[0].length<19&&h.length>1;){var u=new Uint8Array(h[0].length+h[1].length);u.set(h[0]),u.set(h[1],h[0].length),h[0]=u,h.splice(1,1)}if(((s=h[0])[0]<<16)+(s[1]<<8)+s[2]===1){if((t=(s[4]<<8)+s[5])&&t>d.size-6)return null;var f=s[7];192&f&&(a=536870912*(14&s[9])+4194304*(255&s[10])+16384*(254&s[11])+128*(255&s[12])+(254&s[13])/2,64&f?a-(o=536870912*(14&s[14])+4194304*(255&s[15])+16384*(254&s[16])+128*(255&s[17])+(254&s[18])/2)>54e5&&(G.warn(Math.round((a-o)/9e4)+"s delta between PTS and DTS, align them"),a=o):o=a);var p=(r=s[8])+9;if(d.size<=p)return null;d.size-=p;for(var v=new Uint8Array(d.size),w=0,C=h.length;w<C;w++){var k=(s=h[w]).byteLength;if(p){if(p>k){p-=k;continue}s=s.subarray(p),k-=p,p=0}v.set(s,l),l+=k}return t&&(t-=r+3),{data:v,pts:a,dts:o,len:t}}return null}function Ba(d,s){if(d.units.length&&d.frame){if(d.pts===void 0){var t=s.samples,r=t.length;if(!r)return void s.dropped++;var a=t[r-1];d.pts=a.pts,d.dts=a.dts}s.samples.push(d)}d.debug.length&&G.log(d.pts+"/"+d.dts+":"+d.debug)}var Om=(function(d){function s(){return d.apply(this,arguments)||this}X(s,d);var t=s.prototype;return t.resetInitSegment=function(r,a,o,l){d.prototype.resetInitSegment.call(this,r,a,o,l),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:a,duration:l,inputTimeScale:9e4,dropped:0}},s.probe=function(r){if(!r)return!1;for(var a=(kn(r,0)||[]).length,o=r.length;a<o;a++)if(Dm(r,a))return G.log("MPEG Audio sync word found !"),!0;return!1},t.canParse=function(r,a){return(function(o,l){return yl(o,l)&&4<=o.length-l})(r,a)},t.appendFrame=function(r,a,o){if(this.basePTS!==null)return dg(r,a,o,this.basePTS,this.frameIndex)},s})(ag),fg=(function(){function d(){}return d.getSilentFrame=function(s,t){if(s==="mp4a.40.2"){if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},d})(),Xr=Math.pow(2,32)-1,wt=(function(){function d(){}return d.init=function(){var s;for(s in d.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},d.types)d.types.hasOwnProperty(s)&&(d.types[s]=[s.charCodeAt(0),s.charCodeAt(1),s.charCodeAt(2),s.charCodeAt(3)]);d.HDLR_TYPES={video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])};var t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]);d.STTS=d.STSC=d.STCO=new Uint8Array([0,0,0,0,0,0,0,0]),d.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),d.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),d.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),d.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var r=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),o=new Uint8Array([0,0,0,1]);d.FTYP=d.box(d.types.ftyp,r,o,r,a),d.DINF=d.box(d.types.dinf,d.box(d.types.dref,t))},d.box=function(s){for(var t=8,r=arguments.length,a=new Array(r>1?r-1:0),o=1;o<r;o++)a[o-1]=arguments[o];for(var l=a.length,h=l;l--;)t+=a[l].byteLength;var u=new Uint8Array(t);for(u[0]=t>>24&255,u[1]=t>>16&255,u[2]=t>>8&255,u[3]=255&t,u.set(s,4),l=0,t=8;l<h;l++)u.set(a[l],t),t+=a[l].byteLength;return u},d.hdlr=function(s){return d.box(d.types.hdlr,d.HDLR_TYPES[s])},d.mdat=function(s){return d.box(d.types.mdat,s)},d.mdhd=function(s,t){t*=s;var r=Math.floor(t/(Xr+1)),a=Math.floor(t%(Xr+1));return d.box(d.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,s>>24&255,s>>16&255,s>>8&255,255&s,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},d.mdia=function(s){return d.box(d.types.mdia,d.mdhd(s.timescale,s.duration),d.hdlr(s.type),d.minf(s))},d.mfhd=function(s){return d.box(d.types.mfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s]))},d.minf=function(s){return s.type==="audio"?d.box(d.types.minf,d.box(d.types.smhd,d.SMHD),d.DINF,d.stbl(s)):d.box(d.types.minf,d.box(d.types.vmhd,d.VMHD),d.DINF,d.stbl(s))},d.moof=function(s,t,r){return d.box(d.types.moof,d.mfhd(s),d.traf(r,t))},d.moov=function(s){for(var t=s.length,r=[];t--;)r[t]=d.trak(s[t]);return d.box.apply(null,[d.types.moov,d.mvhd(s[0].timescale,s[0].duration)].concat(r).concat(d.mvex(s)))},d.mvex=function(s){for(var t=s.length,r=[];t--;)r[t]=d.trex(s[t]);return d.box.apply(null,[d.types.mvex].concat(r))},d.mvhd=function(s,t){t*=s;var r=Math.floor(t/(Xr+1)),a=Math.floor(t%(Xr+1)),o=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,s>>24&255,s>>16&255,s>>8&255,255&s,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a,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 d.box(d.types.mvhd,o)},d.sdtp=function(s){var t,r,a=s.samples||[],o=new Uint8Array(4+a.length);for(t=0;t<a.length;t++)r=a[t].flags,o[t+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return d.box(d.types.sdtp,o)},d.stbl=function(s){return d.box(d.types.stbl,d.stsd(s),d.box(d.types.stts,d.STTS),d.box(d.types.stsc,d.STSC),d.box(d.types.stsz,d.STSZ),d.box(d.types.stco,d.STCO))},d.avc1=function(s){var t,r,a,o=[],l=[];for(t=0;t<s.sps.length;t++)a=(r=s.sps[t]).byteLength,o.push(a>>>8&255),o.push(255&a),o=o.concat(Array.prototype.slice.call(r));for(t=0;t<s.pps.length;t++)a=(r=s.pps[t]).byteLength,l.push(a>>>8&255),l.push(255&a),l=l.concat(Array.prototype.slice.call(r));var h=d.box(d.types.avcC,new Uint8Array([1,o[3],o[4],o[5],255,224|s.sps.length].concat(o).concat([s.pps.length]).concat(l))),u=s.width,f=s.height,p=s.pixelRatio[0],v=s.pixelRatio[1];return d.box(d.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u>>8&255,255&u,f>>8&255,255&f,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),h,d.box(d.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),d.box(d.types.pasp,new Uint8Array([p>>24,p>>16&255,p>>8&255,255&p,v>>24,v>>16&255,v>>8&255,255&v])))},d.esds=function(s){var t=s.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(s.config).concat([6,1,2]))},d.mp4a=function(s){var t=s.samplerate;return d.box(d.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,s.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]),d.box(d.types.esds,d.esds(s)))},d.mp3=function(s){var t=s.samplerate;return d.box(d.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,s.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]))},d.stsd=function(s){return s.type==="audio"?s.segmentCodec==="mp3"&&s.codec==="mp3"?d.box(d.types.stsd,d.STSD,d.mp3(s)):d.box(d.types.stsd,d.STSD,d.mp4a(s)):d.box(d.types.stsd,d.STSD,d.avc1(s))},d.tkhd=function(s){var t=s.id,r=s.duration*s.timescale,a=s.width,o=s.height,l=Math.floor(r/(Xr+1)),h=Math.floor(r%(Xr+1));return d.box(d.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,l>>24,l>>16&255,l>>8&255,255&l,h>>24,h>>16&255,h>>8&255,255&h,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,o>>8&255,255&o,0,0]))},d.traf=function(s,t){var r=d.sdtp(s),a=s.id,o=Math.floor(t/(Xr+1)),l=Math.floor(t%(Xr+1));return d.box(d.types.traf,d.box(d.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),d.box(d.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,l>>24,l>>16&255,l>>8&255,255&l])),d.trun(s,r.length+16+20+8+16+8+8),r)},d.trak=function(s){return s.duration=s.duration||4294967295,d.box(d.types.trak,d.tkhd(s),d.mdia(s))},d.trex=function(s){var t=s.id;return d.box(d.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},d.trun=function(s,t){var r,a,o,l,h,u,f=s.samples||[],p=f.length,v=12+16*p,w=new Uint8Array(v);for(t+=8+v,w.set([s.type==="video"?1:0,0,15,1,p>>>24&255,p>>>16&255,p>>>8&255,255&p,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),r=0;r<p;r++)o=(a=f[r]).duration,l=a.size,h=a.flags,u=a.cts,w.set([o>>>24&255,o>>>16&255,o>>>8&255,255&o,l>>>24&255,l>>>16&255,l>>>8&255,255&l,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,61440&h.degradPrio,15&h.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*r);return d.box(d.types.trun,w)},d.initSegment=function(s){d.types||d.init();var t=d.moov(s),r=new Uint8Array(d.FTYP.byteLength+t.byteLength);return r.set(d.FTYP),r.set(t,d.FTYP.byteLength),r},d})();function Cl(d,s,t,r){t===void 0&&(t=1),r===void 0&&(r=!1);var a=d*s*t;return r?Math.round(a):a}function Ia(d,s){return s===void 0&&(s=!1),Cl(d,1e3,1/9e4,s)}wt.types=void 0,wt.HDLR_TYPES=void 0,wt.STTS=void 0,wt.STSC=void 0,wt.STCO=void 0,wt.STSZ=void 0,wt.VMHD=void 0,wt.SMHD=void 0,wt.STSD=void 0,wt.FTYP=void 0,wt.DINF=void 0;var Hn=null,El=null,kl=(function(){function d(t,r,a,o){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=r,this.typeSupported=a,this.ISGenerated=!1,Hn===null){var l=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Hn=l?parseInt(l[1]):0}if(El===null){var h=navigator.userAgent.match(/Safari\/(\d+)/i);El=h?parseInt(h[1]):0}}var s=d.prototype;return s.destroy=function(){},s.resetTimeStamp=function(t){G.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},s.resetNextTimestamp=function(){G.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},s.resetInitSegment=function(){G.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},s.getVideoStartPts=function(t){var r=!1,a=t.reduce(function(o,l){var h=l.pts-o;return h<-4294967296?(r=!0,Wt(o,l.pts)):h>0?o:l.pts},t[0].pts);return r&&G.debug("PTS rollover detected"),a},s.remux=function(t,r,a,o,l,h,u,f){var p,v,w,C,k,I,D=l,B=l,T=t.pid>-1,U=r.pid>-1,M=r.samples.length,H=t.samples.length>0,V=u&&M>0||M>1;if((!T||H)&&(!U||V)||this.ISGenerated||u){this.ISGenerated||(w=this.generateIS(t,r,l,h));var W,$=this.isVideoContiguous,J=-1;if(V&&(J=(function(we){for(var ve=0;ve<we.length;ve++)if(we[ve].key)return ve;return-1})(r.samples),!$&&this.config.forceKeyFrameOnDiscontinuity))if(I=!0,J>0){G.warn("[mp4-remuxer]: Dropped "+J+" out of "+M+" video samples due to a missing keyframe");var j=this.getVideoStartPts(r.samples);r.samples=r.samples.slice(J),r.dropped+=J,W=B+=(r.samples[0].pts-j)/r.inputTimeScale}else J===-1&&(G.warn("[mp4-remuxer]: No keyframe found out of "+M+" video samples"),I=!1);if(this.ISGenerated){if(H&&V){var le=this.getVideoStartPts(r.samples),ie=(Wt(t.samples[0].pts,le)-le)/r.inputTimeScale;D+=Math.max(0,ie),B+=Math.max(0,-ie)}if(H){if(t.samplerate||(G.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),w=this.generateIS(t,r,l,h)),v=this.remuxAudio(t,D,this.isAudioContiguous,h,U||V||f===Cr?B:void 0),V){var me=v?v.endPTS-v.startPTS:0;r.inputTimeScale||(G.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),w=this.generateIS(t,r,l,h)),p=this.remuxVideo(r,B,$,me)}}else V&&(p=this.remuxVideo(r,B,$,0));p&&(p.firstKeyFrame=J,p.independent=J!==-1,p.firstKeyFramePTS=W)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(a.samples.length&&(k=pg(a,l,this._initPTS,this._initDTS)),o.samples.length&&(C=mg(o,l,this._initPTS))),{audio:v,video:p,initSegment:w,independent:I,text:C,id3:k}},s.generateIS=function(t,r,a,o){var l,h,u,f=t.samples,p=r.samples,v=this.typeSupported,w={},C=this._initPTS,k=!C||o,I="audio/mp4";if(k&&(l=h=1/0),t.config&&f.length&&(t.timescale=t.samplerate,t.segmentCodec==="mp3"&&(v.mpeg?(I="audio/mpeg",t.codec=""):v.mp3&&(t.codec="mp3")),w.audio={id:"audio",container:I,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&v.mpeg?new Uint8Array(0):wt.initSegment([t]),metadata:{channelCount:t.channelCount}},k&&(u=t.inputTimeScale,C&&u===C.timescale?k=!1:l=h=f[0].pts-Math.round(u*a))),r.sps&&r.pps&&p.length&&(r.timescale=r.inputTimeScale,w.video={id:"main",container:"video/mp4",codec:r.codec,initSegment:wt.initSegment([r]),metadata:{width:r.width,height:r.height}},k))if(u=r.inputTimeScale,C&&u===C.timescale)k=!1;else{var D=this.getVideoStartPts(p),B=Math.round(u*a);h=Math.min(h,Wt(p[0].dts,D)-B),l=Math.min(l,D-B)}if(Object.keys(w).length)return this.ISGenerated=!0,k?(this._initPTS={baseTime:l,timescale:u},this._initDTS={baseTime:h,timescale:u}):l=u=void 0,{tracks:w,initPTS:l,timescale:u}},s.remuxVideo=function(t,r,a,o){var l,h,u=t.inputTimeScale,f=t.samples,p=[],v=f.length,w=this._initPTS,C=this.nextAvcDts,k=8,I=this.videoSampleDuration,D=Number.POSITIVE_INFINITY,B=Number.NEGATIVE_INFINITY,T=!1;a&&C!==null||(C=r*u-(f[0].pts-Wt(f[0].dts,f[0].pts)));for(var U=w.baseTime*u/w.timescale,M=0;M<v;M++){var H=f[M];H.pts=Wt(H.pts-U,C),H.dts=Wt(H.dts-U,C),H.dts<f[M>0?M-1:M].dts&&(T=!0)}T&&f.sort(function(Jn,Zg){var M1=Jn.dts-Zg.dts,F1=Jn.pts-Zg.pts;return M1||F1}),l=f[0].dts;var V=(h=f[f.length-1].dts)-l,W=V?Math.round(V/(v-1)):I||t.inputTimeScale/30;if(a){var $=l-C,J=$>W,j=$<-1;if((J||j)&&(J?G.warn("AVC: "+Ia($,!0)+" ms ("+$+"dts) hole between fragments detected, filling it"):G.warn("AVC: "+Ia(-$,!0)+" ms ("+$+"dts) overlapping between fragments detected"),!j||C>=f[0].pts)){l=C;var le=f[0].pts-$;f[0].dts=l,f[0].pts=le,G.log("Video: First PTS/DTS adjusted: "+Ia(le,!0)+"/"+Ia(l,!0)+", delta: "+Ia($,!0)+" ms")}}l=Math.max(0,l);for(var ie=0,me=0,we=0;we<v;we++){for(var ve=f[we],Ae=ve.units,Ie=Ae.length,fe=0,Pe=0;Pe<Ie;Pe++)fe+=Ae[Pe].data.length;me+=fe,ie+=Ie,ve.length=fe,ve.dts=Math.max(ve.dts,l),D=Math.min(ve.pts,D),B=Math.max(ve.pts,B)}h=f[v-1].dts;var Ue,ze=me+4*ie+8;try{Ue=new Uint8Array(ze)}catch(Jn){this.observer.emit(x.ERROR,x.ERROR,{type:ue.MUX_ERROR,details:q.REMUX_ALLOC_ERROR,fatal:!1,error:Jn,bytes:ze,reason:"fail allocating video mdat "+ze});return}var je=new DataView(Ue.buffer);je.setUint32(0,ze),Ue.set(wt.types.mdat,4);for(var mt=!1,Tt=Number.POSITIVE_INFINITY,ir=Number.POSITIVE_INFINITY,Ht=Number.NEGATIVE_INFINITY,Jt=Number.NEGATIVE_INFINITY,pt=0;pt<v;pt++){for(var Ct=f[pt],ar=Ct.units,hi=0,Mt=0,Vn=ar.length;Mt<Vn;Mt++){var Sa=ar[Mt],Wn=Sa.data,Pi=Sa.data.byteLength;je.setUint32(k,Pi),k+=4,Ue.set(Wn,k),k+=Pi,hi+=4+Pi}var ui=void 0;if(pt<v-1)I=f[pt+1].dts-Ct.dts,ui=f[pt+1].pts-Ct.pts;else{var gi=this.config,Xn=pt>0?Ct.dts-f[pt-1].dts:W;if(ui=pt>0?Ct.pts-f[pt-1].pts:W,gi.stretchShortVideoTrack&&this.nextAudioPts!==null){var x1=Math.floor(gi.maxBufferHole*u),zl=(o?D+o*u:this.nextAudioPts)-Ct.pts;zl>x1?((I=zl-Xn)<0?I=Xn:mt=!0,G.log("[mp4-remuxer]: It is approximately "+zl/90+" ms to the next segment; using duration "+I/90+" ms for the last video frame.")):I=Xn}else I=Xn}var T1=Math.round(Ct.pts-Ct.dts);Tt=Math.min(Tt,I),Ht=Math.max(Ht,I),ir=Math.min(ir,ui),Jt=Math.max(Jt,ui),p.push(new vg(Ct.key,I,hi,T1))}if(p.length){if(Hn){if(Hn<70){var Jg=p[0].flags;Jg.dependsOn=2,Jg.isNonSync=0}}else if(El&&Jt-ir<Ht-Tt&&W/Ht<.025&&p[0].cts===0){G.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ql=l,nr=0,_g=p.length;nr<_g;nr++){var jg=ql+p[nr].duration,D1=ql+p[nr].cts;if(nr<_g-1){var R1=jg+p[nr+1].cts;p[nr].duration=R1-D1}else p[nr].duration=nr?p[nr-1].duration:W;p[nr].cts=0,ql=jg}}}I=mt||!I?W:I,this.nextAvcDts=C=h+I,this.videoSampleDuration=I,this.isVideoContiguous=!0;var L1={data1:wt.moof(t.sequenceNumber++,l,Y({},t,{samples:p})),data2:Ue,startPTS:D/u,endPTS:(B+I)/u,startDTS:l/u,endDTS:C/u,type:"video",hasAudio:!1,hasVideo:!0,nb:p.length,dropped:t.dropped};return t.samples=[],t.dropped=0,L1},s.remuxAudio=function(t,r,a,o,l){var h=t.inputTimeScale,u=h/(t.samplerate?t.samplerate:h),f=t.segmentCodec==="aac"?1024:1152,p=f*u,v=this._initPTS,w=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,C=[],k=l!==void 0,I=t.samples,D=w?0:8,B=this.nextAudioPts||-1,T=r*h,U=v.baseTime*h/v.timescale;if(this.isAudioContiguous=a=a||I.length&&B>0&&(o&&Math.abs(T-B)<9e3||Math.abs(Wt(I[0].pts-U,T)-B)<20*p),I.forEach(function(Mt){Mt.pts=Wt(Mt.pts-U,T)}),!a||B<0){if(I=I.filter(function(Mt){return Mt.pts>=0}),!I.length)return;B=l===0?0:o&&!k?Math.max(0,T):I[0].pts}if(t.segmentCodec==="aac")for(var M=this.config.maxAudioFramesDrift,H=0,V=B;H<I.length;H++){var W=I[H],$=W.pts,J=$-V,j=Math.abs(1e3*J/h);if(J<=-M*p&&k)H===0&&(G.warn("Audio frame @ "+($/h).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*J/h)+" ms."),this.nextAudioPts=B=V=$);else if(J>=M*p&&j<1e4&&k){var le=Math.round(J/p);(V=$-le*p)<0&&(le--,V+=p),H===0&&(this.nextAudioPts=B=V),G.warn("[mp4-remuxer]: Injecting "+le+" audio frame @ "+(V/h).toFixed(3)+"s due to "+Math.round(1e3*J/h)+" ms gap.");for(var ie=0;ie<le;ie++){var me=Math.max(V,0),we=fg.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);we||(G.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),we=W.unit.subarray()),I.splice(H,0,{unit:we,pts:me}),V+=p,H++}}W.pts=V,V+=p}for(var ve,Ae=null,Ie=null,fe=0,Pe=I.length;Pe--;)fe+=I[Pe].unit.byteLength;for(var Ue=0,ze=I.length;Ue<ze;Ue++){var je=I[Ue],mt=je.unit,Tt=je.pts;if(Ie!==null)C[Ue-1].duration=Math.round((Tt-Ie)/u);else{if(a&&t.segmentCodec==="aac"&&(Tt=B),Ae=Tt,!(fe>0))return;fe+=D;try{ve=new Uint8Array(fe)}catch(Mt){this.observer.emit(x.ERROR,x.ERROR,{type:ue.MUX_ERROR,details:q.REMUX_ALLOC_ERROR,fatal:!1,error:Mt,bytes:fe,reason:"fail allocating audio mdat "+fe});return}w||(new DataView(ve.buffer).setUint32(0,fe),ve.set(wt.types.mdat,4))}ve.set(mt,D);var ir=mt.byteLength;D+=ir,C.push(new vg(!0,f,ir,0)),Ie=Tt}var Ht=C.length;if(Ht){var Jt=C[C.length-1];this.nextAudioPts=B=Ie+u*Jt.duration;var pt=w?new Uint8Array(0):wt.moof(t.sequenceNumber++,Ae/u,Y({},t,{samples:C}));t.samples=[];var Ct=Ae/h,ar=B/h,hi={data1:pt,data2:ve,startPTS:Ct,endPTS:ar,startDTS:Ct,endDTS:ar,type:"audio",hasAudio:!0,hasVideo:!1,nb:Ht};return this.isAudioContiguous=!0,hi}},s.remuxEmptyAudio=function(t,r,a,o){var l=t.inputTimeScale,h=l/(t.samplerate?t.samplerate:l),u=this.nextAudioPts,f=this._initDTS,p=9e4*f.baseTime/f.timescale,v=(u!==null?u:o.startDTS*l)+p,w=o.endDTS*l+p,C=1024*h,k=Math.ceil((w-v)/C),I=fg.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(G.warn("[mp4-remuxer]: remux empty Audio"),I){for(var D=[],B=0;B<k;B++){var T=v+B*C;D.push({unit:I,pts:T,dts:T})}return t.samples=D,this.remuxAudio(t,r,a,!1)}G.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},d})();function Wt(d,s){var t;if(s===null)return d;for(t=s<d?-8589934592:8589934592;Math.abs(d-s)>4294967296;)d+=t;return d}function pg(d,s,t,r){var a=d.samples.length;if(a){for(var o=d.inputTimeScale,l=0;l<a;l++){var h=d.samples[l];h.pts=Wt(h.pts-t.baseTime*o/t.timescale,s*o)/o,h.dts=Wt(h.dts-r.baseTime*o/r.timescale,s*o)/o}var u=d.samples;return d.samples=[],{samples:u}}}function mg(d,s,t){var r=d.samples.length;if(r){for(var a=d.inputTimeScale,o=0;o<r;o++){var l=d.samples[o];l.pts=Wt(l.pts-t.baseTime*a/t.timescale,s*a)/a}d.samples.sort(function(u,f){return u.pts-f.pts});var h=d.samples;return d.samples=[],{samples:h}}}var Qr,vg=function(d,s,t,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=s,this.size=t,this.cts=r,this.flags=new Pm(d)},Pm=function(d){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=d?2:1,this.isNonSync=d?0:1},Um=(function(){function d(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}var s=d.prototype;return s.destroy=function(){},s.resetTimeStamp=function(t){this.initPTS=t,this.lastEndTime=null},s.resetNextTimestamp=function(){this.lastEndTime=null},s.resetInitSegment=function(t,r,a,o){this.audioCodec=r,this.videoCodec=a,this.generateInitSegment((function(l,h){if(!l||!h)return l;var u=h.keyId;return u&&h.isCommonEncryption&&Ye(l,["moov","trak"]).forEach(function(f){var p=Ye(f,["mdia","minf","stbl","stsd"])[0].subarray(8),v=Ye(p,["enca"]),w=v.length>0;w||(v=Ye(p,["encv"])),v.forEach(function(C){Ye(w?C.subarray(28):C.subarray(78),["sinf"]).forEach(function(k){var I=yu(k);if(I){var D=I.subarray(8,24);D.some(function(B){return B!==0})||(G.log("[eme] Patching keyId in 'enc"+(w?"a":"v")+">sinf>>tenc' box: "+yr(D)+" -> "+yr(u)),I.set(u,8))}})})}),l})(t,o)),this.emitInitSegment=!0},s.generateInitSegment=function(t){var r=this.audioCodec,a=this.videoCodec;if(t==null||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var o=this.initData=bu(t);r||(r=Ag(o.audio,ot)),a||(a=Ag(o.video,bt));var l={};o.audio&&o.video?l.audiovideo={container:"video/mp4",codec:r+","+a,initSegment:t,id:"main"}:o.audio?l.audio={container:"audio/mp4",codec:r,initSegment:t,id:"audio"}:o.video?l.video={container:"video/mp4",codec:a,initSegment:t,id:"main"}:G.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=l},s.remux=function(t,r,a,o,l,h){var u,f,p=this.initPTS,v=this.lastEndTime,w={audio:void 0,video:void 0,text:o,id3:a,initSegment:void 0};se(v)||(v=this.lastEndTime=l||0);var C=r.samples;if(C==null||!C.length)return w;var k={initPTS:void 0,timescale:1},I=this.initData;if((u=I)!=null&&u.length||(this.generateInitSegment(C),I=this.initData),(f=I)==null||!f.length)return G.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),w;this.emitInitSegment&&(k.tracks=this.initTracks,this.emitInitSegment=!1);var D=(function(J,j){for(var le=0,ie=0,me=0,we=Ye(J,["moof","traf"]),ve=0;ve<we.length;ve++){var Ae=we[ve],Ie=Ye(Ae,["tfhd"])[0],fe=j[Re(Ie,4)];if(fe){var Pe=fe.default,Ue=Re(Ie,0)|Pe?.flags,ze=Pe?.duration;8&Ue&&(ze=Re(Ie,2&Ue?12:8));for(var je=fe.timescale||9e4,mt=Ye(Ae,["trun"]),Tt=0;Tt<mt.length;Tt++)!(le=Vp(mt[Tt]))&&ze&&(le=ze*Re(mt[Tt],4)),fe.type===bt?ie+=le/je:fe.type===ot&&(me+=le/je)}}if(ie===0&&me===0){for(var ir=0,Ht=Ye(J,["sidx"]),Jt=0;Jt<Ht.length;Jt++){var pt=qp(Ht[Jt]);pt!=null&&pt.references&&(ir+=pt.references.reduce(function(Ct,ar){return Ct+ar.info.duration||0},0))}return ir}return ie||me})(C,I),B=(function(J,j){return Ye(j,["moof","traf"]).reduce(function(le,ie){var me=Ye(ie,["tfdt"])[0],we=me[0],ve=Ye(ie,["tfhd"]).reduce(function(Ae,Ie){var fe=J[Re(Ie,4)];if(fe){var Pe=Re(me,4);if(we===1){if(Pe===In)return G.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),Ae;Pe*=In+1,Pe+=Re(me,8)}var Ue=Pe/(fe.timescale||9e4);if(isFinite(Ue)&&(Ae===null||Ue<Ae))return Ue}return Ae},null);return ve!==null&&isFinite(ve)&&(le===null||ve<le)?ve:le},null)})(I,C),T=B===null?l:B;((function(J,j,le,ie){if(J===null)return!0;var me=Math.max(ie,1),we=j-J.baseTime/J.timescale;return Math.abs(we-le)>me})(p,T,l,D)||k.timescale!==p.timescale&&h)&&(k.initPTS=T-l,p&&p.timescale===1&&G.warn("Adjusting initPTS by "+(k.initPTS-p.baseTime)),this.initPTS=p={baseTime:k.initPTS,timescale:1});var U=t?T-p.baseTime/p.timescale:v,M=U+D;(function(J,j,le){Ye(j,["moof","traf"]).forEach(function(ie){Ye(ie,["tfhd"]).forEach(function(me){var we=J[Re(me,4)];if(we){var ve=we.timescale||9e4;Ye(ie,["tfdt"]).forEach(function(Ae){var Ie=Ae[0],fe=Re(Ae,4);if(Ie===0)fe-=le*ve,js(Ae,4,fe=Math.max(fe,0));else{fe*=Math.pow(2,32),fe+=Re(Ae,8),fe-=le*ve,fe=Math.max(fe,0);var Pe=Math.floor(fe/(In+1)),Ue=Math.floor(fe%(In+1));js(Ae,4,Pe),js(Ae,8,Ue)}})}})})})(I,C,p.baseTime/p.timescale),D>0?this.lastEndTime=M:(G.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var H=!!I.audio,V=!!I.video,W="";H&&(W+="audio"),V&&(W+="video");var $={data1:C,startPTS:U,startDTS:U,endPTS:M,endDTS:M,type:W,hasAudio:H,hasVideo:V,nb:1,dropped:0};return w.audio=$.type==="audio"?$:void 0,w.video=$.type!=="audio"?$:void 0,w.initSegment=k,w.id3=pg(a,l,p,p),o.samples.length&&(w.text=mg(o,l,p)),w},d})();function Ag(d,s){var t=d?.codec;return t&&t.length>4?t:t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":t==="avc1"||s===bt?"avc1.42e01e":"mp4a.40.5"}try{Qr=self.performance.now.bind(self.performance)}catch{G.debug("Unable to use Performance API on this environment"),Qr=typeof self<"u"&&self.Date.now}var Bl=[{demux:Bm,remux:Um},{demux:Lm,remux:kl},{demux:Em,remux:kl},{demux:Om,remux:kl}],Il=(function(){function d(t,r,a,o,l){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=r,this.config=a,this.vendor=o,this.id=l}var s=d.prototype;return s.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},s.push=function(t,r,a,o){var l=this,h=a.transmuxing;h.executeStart=Qr();var u=new Uint8Array(t),f=this.currentTransmuxState,p=this.transmuxConfig;o&&(this.currentTransmuxState=o);var v=o||f,w=v.contiguous,C=v.discontinuity,k=v.trackSwitch,I=v.accurateTimeOffset,D=v.timeOffset,B=v.initSegmentChange,T=p.audioCodec,U=p.videoCodec,M=p.defaultInitPts,H=p.duration,V=p.initSegmentData,W=(function(we,ve){var Ae=null;return we.byteLength>0&&ve!=null&&ve.key!=null&&ve.iv!==null&&ve.method!=null&&(Ae=ve),Ae})(u,r);if(W&&W.method==="AES-128"){var $=this.getDecrypter();if(!$.isSync())return this.decryptionPromise=$.webCryptoDecrypt(u,W.key.buffer,W.iv.buffer).then(function(we){var ve=l.push(we,null,a);return l.decryptionPromise=null,ve}),this.decryptionPromise;var J=$.softwareDecrypt(u,W.key.buffer,W.iv.buffer);if(a.part>-1&&(J=$.flush()),!J)return h.executeEnd=Qr(),Sl(a);u=new Uint8Array(J)}var j=this.needsProbing(C,k);if(j){var le=this.configureTransmuxer(u);if(le)return G.warn("[transmuxer] "+le.message),this.observer.emit(x.ERROR,x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!1,error:le,reason:le.message}),h.executeEnd=Qr(),Sl(a)}(C||k||B||j)&&this.resetInitSegment(V,T,U,H,r),(C||B||j)&&this.resetInitialTimestamp(M),w||this.resetContiguity();var ie=this.transmux(u,W,D,I,a),me=this.currentTransmuxState;return me.contiguous=!0,me.discontinuity=!1,me.trackSwitch=!1,h.executeEnd=Qr(),ie},s.flush=function(t){var r=this,a=t.transmuxing;a.executeStart=Qr();var o=this.decrypter,l=this.currentTransmuxState,h=this.decryptionPromise;if(h)return h.then(function(){return r.flush(t)});var u=[],f=l.timeOffset;if(o){var p=o.flush();p&&u.push(this.push(p,null,t))}var v=this.demuxer,w=this.remuxer;if(!v||!w)return a.executeEnd=Qr(),[Sl(t)];var C=v.flush(f);return li(C)?C.then(function(k){return r.flushRemux(u,k,t),u}):(this.flushRemux(u,C,t),u)},s.flushRemux=function(t,r,a){var o=r.audioTrack,l=r.videoTrack,h=r.id3Track,u=r.textTrack,f=this.currentTransmuxState,p=f.accurateTimeOffset,v=f.timeOffset;G.log("[transmuxer.ts]: Flushed fragment "+a.sn+(a.part>-1?" p: "+a.part:"")+" of level "+a.level);var w=this.remuxer.remux(o,l,h,u,v,p,!0,this.id);t.push({remuxResult:w,chunkMeta:a}),a.transmuxing.executeEnd=Qr()},s.resetInitialTimestamp=function(t){var r=this.demuxer,a=this.remuxer;r&&a&&(r.resetTimeStamp(t),a.resetTimeStamp(t))},s.resetContiguity=function(){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetContiguity(),r.resetNextTimestamp())},s.resetInitSegment=function(t,r,a,o,l){var h=this.demuxer,u=this.remuxer;h&&u&&(h.resetInitSegment(t,r,a,o),u.resetInitSegment(t,r,a,l))},s.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},s.transmux=function(t,r,a,o,l){return r&&r.method==="SAMPLE-AES"?this.transmuxSampleAes(t,r,a,o,l):this.transmuxUnencrypted(t,a,o,l)},s.transmuxUnencrypted=function(t,r,a,o){var l=this.demuxer.demux(t,r,!1,!this.config.progressive),h=l.audioTrack,u=l.videoTrack,f=l.id3Track,p=l.textTrack;return{remuxResult:this.remuxer.remux(h,u,f,p,r,a,!1,this.id),chunkMeta:o}},s.transmuxSampleAes=function(t,r,a,o,l){var h=this;return this.demuxer.demuxSampleAes(t,r,a).then(function(u){return{remuxResult:h.remuxer.remux(u.audioTrack,u.videoTrack,u.id3Track,u.textTrack,a,o,!1,h.id),chunkMeta:l}})},s.configureTransmuxer=function(t){for(var r,a=this.config,o=this.observer,l=this.typeSupported,h=this.vendor,u=0,f=Bl.length;u<f;u++)if(Bl[u].demux.probe(t)){r=Bl[u];break}if(!r)return new Error("Failed to find demuxer by probing fragment data");var p=this.demuxer,v=this.remuxer,w=r.remux,C=r.demux;v&&v instanceof w||(this.remuxer=new w(o,a,l,h)),p&&p instanceof C||(this.demuxer=new C(o,a,l),this.probe=C.probe)},s.needsProbing=function(t,r){return!this.demuxer||!this.remuxer||t||r},s.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new ml(this.config)),t},d})(),Sl=function(d){return{remuxResult:{},chunkMeta:d}};function li(d){return"then"in d&&d.then instanceof Function}var Qm=function(d,s,t,r,a){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=d,this.videoCodec=s,this.initSegmentData=t,this.duration=r,this.defaultInitPts=a||null},Nm=function(d,s,t,r,a,o){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=d,this.contiguous=s,this.accurateTimeOffset=t,this.trackSwitch=r,this.timeOffset=a,this.initSegmentChange=o},bg={exports:{}};(function(d){var s=Object.prototype.hasOwnProperty,t="~";function r(){}function a(u,f,p){this.fn=u,this.context=f,this.once=p||!1}function o(u,f,p,v,w){if(typeof p!="function")throw new TypeError("The listener must be a function");var C=new a(p,v||u,w),k=t?t+f:f;return u._events[k]?u._events[k].fn?u._events[k]=[u._events[k],C]:u._events[k].push(C):(u._events[k]=C,u._eventsCount++),u}function l(u,f){--u._eventsCount==0?u._events=new r:delete u._events[f]}function h(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1)),h.prototype.eventNames=function(){var u,f,p=[];if(this._eventsCount===0)return p;for(f in u=this._events)s.call(u,f)&&p.push(t?f.slice(1):f);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(u)):p},h.prototype.listeners=function(u){var f=t?t+u:u,p=this._events[f];if(!p)return[];if(p.fn)return[p.fn];for(var v=0,w=p.length,C=new Array(w);v<w;v++)C[v]=p[v].fn;return C},h.prototype.listenerCount=function(u){var f=t?t+u:u,p=this._events[f];return p?p.fn?1:p.length:0},h.prototype.emit=function(u,f,p,v,w,C){var k=t?t+u:u;if(!this._events[k])return!1;var I,D,B=this._events[k],T=arguments.length;if(B.fn){switch(B.once&&this.removeListener(u,B.fn,void 0,!0),T){case 1:return B.fn.call(B.context),!0;case 2:return B.fn.call(B.context,f),!0;case 3:return B.fn.call(B.context,f,p),!0;case 4:return B.fn.call(B.context,f,p,v),!0;case 5:return B.fn.call(B.context,f,p,v,w),!0;case 6:return B.fn.call(B.context,f,p,v,w,C),!0}for(D=1,I=new Array(T-1);D<T;D++)I[D-1]=arguments[D];B.fn.apply(B.context,I)}else{var U,M=B.length;for(D=0;D<M;D++)switch(B[D].once&&this.removeListener(u,B[D].fn,void 0,!0),T){case 1:B[D].fn.call(B[D].context);break;case 2:B[D].fn.call(B[D].context,f);break;case 3:B[D].fn.call(B[D].context,f,p);break;case 4:B[D].fn.call(B[D].context,f,p,v);break;default:if(!I)for(U=1,I=new Array(T-1);U<T;U++)I[U-1]=arguments[U];B[D].fn.apply(B[D].context,I)}}return!0},h.prototype.on=function(u,f,p){return o(this,u,f,p,!1)},h.prototype.once=function(u,f,p){return o(this,u,f,p,!0)},h.prototype.removeListener=function(u,f,p,v){var w=t?t+u:u;if(!this._events[w])return this;if(!f)return l(this,w),this;var C=this._events[w];if(C.fn)C.fn!==f||v&&!C.once||p&&C.context!==p||l(this,w);else{for(var k=0,I=[],D=C.length;k<D;k++)(C[k].fn!==f||v&&!C[k].once||p&&C[k].context!==p)&&I.push(C[k]);I.length?this._events[w]=I.length===1?I[0]:I:l(this,w)}return this},h.prototype.removeAllListeners=function(u){var f;return u?(f=t?t+u:u,this._events[f]&&l(this,f)):(this._events=new r,this._eventsCount=0),this},h.prototype.off=h.prototype.removeListener,h.prototype.addListener=h.prototype.on,h.prefixed=t,h.EventEmitter=h,d.exports=h})(bg);var Gn=Te(bg.exports);function xl(d,s){if(!((t=s.remuxResult).audio||t.video||t.text||t.id3||t.initSegment))return!1;var t,r=[],a=s.remuxResult,o=a.audio,l=a.video;return o&&yg(r,o),l&&yg(r,l),d.postMessage({event:"transmuxComplete",data:s},r),!0}function yg(d,s){s.data1&&d.push(s.data1.buffer),s.data2&&d.push(s.data2.buffer)}function wg(d,s,t){s.reduce(function(r,a){return xl(d,a)||r},!1)||d.postMessage({event:"transmuxComplete",data:s[0]}),d.postMessage({event:"flush",data:t})}c!==void 0&&c&&(function(d){var s=new Gn,t=function(a,o){d.postMessage({event:a,data:o})};s.on(x.FRAG_DECRYPTED,t),s.on(x.ERROR,t);var r=function(){var a=function(l){var h=function(u){t("workerLog",{logType:l,message:u})};G[l]=h};for(var o in G)a(o)};d.addEventListener("message",function(a){var o=a.data;switch(o.cmd){case"init":var l=JSON.parse(o.config);d.transmuxer=new Il(s,o.typeSupported,l,o.vendor,o.id),tr(l.debug,o.id),r(),t("init",null);break;case"configure":d.transmuxer.configure(o.config);break;case"demux":var h=d.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);li(h)?(d.transmuxer.async=!0,h.then(function(p){xl(d,p)}).catch(function(p){t(x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,chunkMeta:o.chunkMeta,fatal:!1,error:p,err:p,reason:"transmuxer-worker push error"})})):(d.transmuxer.async=!1,xl(d,h));break;case"flush":var u=o.chunkMeta,f=d.transmuxer.flush(u);li(f)||d.transmuxer.async?(li(f)||(f=Promise.resolve(f)),f.then(function(p){wg(d,p,u)}).catch(function(p){t(x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,chunkMeta:o.chunkMeta,fatal:!1,error:p,err:p,reason:"transmuxer-worker flush error"})})):wg(d,f,u)}})})(self);var Tl=xn()||{isTypeSupported:function(){return!1}},Cg=(function(){function d(t,r,a,o){var l=this;this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var h=t.config;this.hls=t,this.id=r,this.useWorker=!!h.enableWorker,this.onTransmuxComplete=a,this.onFlush=o;var u=function(D,B){(B=B||{}).frag=l.frag,B.id=l.id,D===x.ERROR&&(l.error=B.error),l.hls.trigger(D,B)};this.observer=new Gn,this.observer.on(x.FRAG_DECRYPTED,u),this.observer.on(x.ERROR,u);var f,p,v,w,C={mp4:Tl.isTypeSupported("video/mp4"),mpeg:Tl.isTypeSupported("audio/mpeg"),mp3:Tl.isTypeSupported('audio/mp4; codecs="mp3"')},k=navigator.vendor;if(!this.useWorker||typeof Worker>"u"||(h.workerPath,0))this.transmuxer=new Il(this.observer,C,h,k,r);else try{h.workerPath?(G.log("loading Web Worker "+h.workerPath+' for "'+r+'"'),this.workerContext=(v=h.workerPath,w=new self.URL(v,self.location.href).href,{worker:new self.Worker(w),scriptURL:w})):(G.log('injecting Web Worker for "'+r+'"'),this.workerContext=(f=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+n.toString()+")(true);"],{type:"text/javascript"}),p=self.URL.createObjectURL(f),{worker:new self.Worker(p),objectURL:p})),this.onwmsg=function(D){return l.onWorkerMessage(D)};var I=this.workerContext.worker;I.addEventListener("message",this.onwmsg),I.onerror=function(D){var B=new Error(D.message+" ("+D.filename+":"+D.lineno+")");h.enableWorker=!1,G.warn('Error in "'+r+'" Web Worker, fallback to inline'),l.hls.trigger(x.ERROR,{type:ue.OTHER_ERROR,details:q.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:B})},I.postMessage({cmd:"init",typeSupported:C,vendor:k,id:r,config:JSON.stringify(h)})}catch(D){G.warn('Error setting up "'+r+'" Web Worker, fallback to inline',D),this.resetWorker(),this.error=null,this.transmuxer=new Il(this.observer,C,h,k,r)}}var s=d.prototype;return s.resetWorker=function(){if(this.workerContext){var t=this.workerContext,r=t.worker,a=t.objectURL;a&&self.URL.revokeObjectURL(a),r.removeEventListener("message",this.onwmsg),r.onerror=null,r.terminate(),this.workerContext=null}},s.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}var r=this.observer;r&&r.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},s.push=function(t,r,a,o,l,h,u,f,p,v){var w,C,k=this;p.transmuxing.start=self.performance.now();var I=this.transmuxer,D=h?h.start:l.start,B=l.decryptdata,T=this.frag,U=!(T&&l.cc===T.cc),M=!(T&&p.level===T.level),H=T?p.sn-T.sn:-1,V=this.part?p.part-this.part.index:-1,W=H===0&&p.id>1&&p.id===T?.stats.chunkCount,$=!M&&(H===1||H===0&&(V===1||W&&V<=0)),J=self.performance.now();(M||H||l.stats.parsing.start===0)&&(l.stats.parsing.start=J),!h||!V&&$||(h.stats.parsing.start=J);var j=!(T&&((w=l.initSegment)==null?void 0:w.url)===((C=T.initSegment)==null?void 0:C.url)),le=new Nm(U,$,f,M,D,j);if(!$||U||j){G.log("[transmuxer-interface, "+l.type+"]: Starting new transmux session for sn: "+p.sn+" p: "+p.part+" level: "+p.level+" id: "+p.id+`
4
+ `,L0=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}",mc=class extends Ve{static get observedAttributes(){return["src","fallback","sheet","alt"]}_image;_container;_shadowDom;constructor(){super(),this._shadowDom=We(this,L0);const e=_e(this._shadowDom,".ran-image",()=>K().class("ran-image").build());this._container=e}get fallback(){return Be(this,"fallback",R0)}set fallback(e){Le(this,"fallback",e,{removeEmpty:!0})}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}get alt(){return Be(this,"alt")}set alt(e){Le(this,"alt",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};listenFallback(e,i){e==="fallback"&&this._image&&(i?this._image.setAttribute("fallback",i):this._image.removeAttribute("fallback"))}updateSrc=()=>{this._image&&(this._image.src=this.getAttribute("src")||"")};connectedCallback(){this.handlerExternalCss(),this._image=new Image,this._image.alt=this.alt,this._image.addEventListener("error",()=>{this._image&&this.fallback&&(this._image.src=this.fallback)}),this._image.addEventListener("load",()=>{this._image&&this._container.appendChild(this._image)}),this.updateSrc()}attributeChangedCallback(e,i,n){i!==n&&(this.listenFallback(e,n),e==="src"&&this.updateSrc(),e==="alt"&&this._image&&(this._image.alt=n??""),e==="sheet"&&this.handlerExternalCss())}};qe("r-img",mc);var M0=`.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{position:var(--ran-input-host-position, relative);display:var(--ran-input-host-display, block);box-sizing:var(--ran-input-host-box-sizing, border-box)}:host([placeholder]) .ran-input-label{transform:var(--ran-input-label-placeholder-transform, translateY( calc(-50% - .43em) ) scale(.8));top:var(--ran-input-label-placeholder-top, 0)}:host .ran-input-label{transform:var(--ran-input-label-transform, translateY(-50%));top:var(--ran-input-label-top, 50%)}.ran-input{box-sizing:var(--ran-input-box-sizing, border-box);position:var(--ran-input-position, relative);display:var(--ran-input-display, flex);width:var(--ran-input-width, 100%);height:var(--ran-input-height, auto);min-width:var(--ran-input-min-width, 0);padding:var(--ran-input-padding, 0px 0px 0px 4px);color:var(--ran-input-color, var(--ran-color-text, #000000d9));font-size:var(--ran-input-font-size, 12px);font-family:var(--ran-input-font-family, var(--ran-skin-font-family, inherit));line-height:var(--ran-input-line-height, 1.5715);background-color:var(--ran-input-background-color, var(--ran-color-bg-elevated, #fff));background-image:var(--ran-input-background-image, none);border:var(--ran-input-border, 1px solid var(--ran-color-border, #eaeaea));border-image-source:var(--ran-input-border-image-source, none);border-image-slice:var(--ran-input-border-image-slice, 8);border-image-width:var(--ran-input-border-image-width, 4px);border-image-outset:0;border-image-repeat:stretch;border-radius:var(--ran-input-border-radius, var(--ran-radius-sm, 6px));transition:var(--ran-input-transition, none);min-height:var(--ran-input-min-height, 32px)}.ran-input .ran-icon{display:var(--ran-input-icon-display, flex);align-items:var(--ran-input-icon-align-items, center);justify-content:var(--ran-input-icon-justify-content, center)}.ran-input:focus-within{border-color:var(--ran-input-active-border-color, var(--ran-color-primary, #006bff));box-shadow:var(--ran-input-active-box-shadow, 0 0 0 2px var(--ran-blue-400, #cae7ff));border-right-width:var(--ran-input-active-border-right-width, 1px);outline:var(--ran-input-active-outline, 0)}.ran-input:hover{border-color:var(--ran-input-hover-border-color, var(--ran-color-primary, #006bff));border-right-width:var(--ran-input-hover-border-right-width, 1px)}.ran-input>.ran-input-content:hover~.ran-input-label{color:var(--ran-input-label-hover-color, var(--ran-color-primary, #006bff))}.ran-input[value]>.ran-input-label{transform:var(--ran-input-label-value-transform, translateY( calc(-50% - .43em) ) scale(.8));color:var(--ran-input-label-value-color, var(--ran-color-text-disabled, #00000040))}.ran-input[status=error] .ran-input-content,.ran-input[status=warning] .ran-input-content{padding-right:var(--ran-input-content-status-padding-right, 28px)}.ran-input[status=error]:after,.ran-input[status=warning]:after{content:"";position:absolute;top:50%;right:10px;width:16px;height:16px;transform:translateY(-50%);pointer-events:none;mask-position:center;mask-repeat:no-repeat;mask-size:contain;-webkit-mask-position:center;-webkit-mask-repeat:no-repeat;-webkit-mask-size:contain}.ran-input[status=error]{border-color:var(--ran-input-status-error-border-color, var(--ran-color-danger, #ff4d4f))}.ran-input[status=error]>.ran-input-content~.ran-input-label{color:var(--ran-input-label-status-error-color, var(--ran-color-danger, #ff4d4f))}.ran-input[status=error]:after{background-color:var(--ran-color-danger, #ff4d4f);mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 3.5h1.5v5h-1.5v-5zM8 11a1 1 0 110 2 1 1 0 010-2z'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 3.5h1.5v5h-1.5v-5zM8 11a1 1 0 110 2 1 1 0 010-2z'/%3E%3C/svg%3E")}.ran-input[status=warning]{border-color:var(--ran-input-status-warning-border-color, var(--ran-color-warning, #faad14))}.ran-input[status=warning]>.ran-input-content~.ran-input-label{color:var(--ran-input-label-status-warning-color, var(--ran-color-warning, #faad14))}.ran-input[status=warning]:after{background-color:var(--ran-color-warning, #faad14);mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.5l6.85 11.86a.5.5 0 01-.43.75H1.58a.5.5 0 01-.43-.75L8 1.5zm-.75 4.25v3.5h1.5v-3.5h-1.5zM8 10.75a1 1 0 110 2 1 1 0 010-2z'/%3E%3C/svg%3E");-webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1.5l6.85 11.86a.5.5 0 01-.43.75H1.58a.5.5 0 01-.43-.75L8 1.5zm-.75 4.25v3.5h1.5v-3.5h-1.5zM8 10.75a1 1 0 110 2 1 1 0 010-2z'/%3E%3C/svg%3E")}.ran-input[disabled]{color:var(--ran-input-disabled-color, var(--ran-color-text-disabled, #00000040));background-color:var(--ran-input-disabled-background-color, var(--ran-color-bg-muted, #f5f5f5));border-color:var(--ran-input-disabled-border-color, var(--ran-color-border, #eaeaea));box-shadow:var(--ran-input-disabled-box-shadow, none);cursor:var(--ran-input-disabled-cursor, not-allowed);opacity:var(--ran-input-disabled-opacity, 1)}.ran-input[disabled]>.ran-input-content{color:var(--ran-input-content-disabled-color, var(--ran-color-text-disabled, #00000040));background-color:var(--ran-input-content-disabled-background-color, var(--ran-color-bg-muted, #f5f5f5));border-color:var(--ran-input-content-disabled-border-color, var(--ran-color-border, #eaeaea));box-shadow:var(--ran-input-content-disabled-box-shadow, none);cursor:var(--ran-input-content-disabled-cursor, not-allowed);opacity:var(--ran-input-content-disabled-opacity, 1)}.ran-input[disabled]>.ran-input-content~.ran-input-label{color:var(--ran-input-label-disabled-color, var(--ran-color-text-disabled, #00000040));background-color:var(--ran-input-label-disabled-background-color, var(--ran-color-bg-muted, #f5f5f5))}.ran-input[disabled]>.ran-input-label{color:var(--ran-input-label-disabled-color, var(--ran-color-text-disabled, #999));border-color:var(--ran-input-label-disabled-border-color, var(--ran-color-border, #eaeaea));box-shadow:var(--ran-input-label-disabled-box-shadow, none);cursor:var(--ran-input-label-disabled-cursor, not-allowed)}.ran-input-content{writing-mode:var(--ran-input-content-writing-mode, horizontal-tb);text-rendering:var(--ran-input-content-text-rendering, auto);letter-spacing:var(--ran-input-content-letter-spacing, normal);word-spacing:var(--ran-input-content-word-spacing, normal);text-transform:var(--ran-input-content-text-transform, none);text-indent:var(--ran-input-content-text-indent, 0px);text-shadow:var(--ran-input-content-text-shadow, none);text-align:var(--ran-input-content-text-align, start);cursor:var(--ran-input-content-cursor, text);touch-action:var(--ran-input-content-touch-action, manipulation);-webkit-appearance:var(--ran-input-content--webkit-appearance, none);text-overflow:var(--ran-input-content-text-overflow, ellipsis);box-sizing:var(--ran-input-content-box-sizing, border-box);margin:var(--ran-input-content-margin, 0);font-variant:var(--ran-input-content-font-variant, tabular-nums);list-style:var(--ran-input-content-list-style, none);font-feature-settings:var(--ran-input-content-font-feature-settings, "tnum");position:var(--ran-input-content-position, relative);border:var(--ran-input-content-border, none);width:var(--ran-input-content-width, 100%);height:var(--ran-input-content-height, 100%);min-height:var(--ran-input-content-min-height, 30px);min-width:var(--ran-input-content-min-width, 0);color:var(--ran-input-content-color, var(--ran-color-text, #000000d9));font-size:var(--ran-input-content-font-size, 14px);line-height:var(--ran-input-content-line-height, 1.48);background-color:var(--ran-input-content-background-color, var(--ran-color-bg-elevated, #fff));background-image:var(--ran-input-content-background-image, none);transition:var(--ran-input-content-transition, none);outline:var(--ran-input-content-outline, none);border-radius:var(--ran-input-content-border-radius, var(--ran-radius-sm, 6px));padding:var(--ran-input-content-padding, 0 0 0 2px);font-weight:var(--ran-input-content-font-weight, 400)}.ran-input-content:focus,.ran-input-content:hover{border:var(--ran-input-content-hover-border, none);outline:var(--ran-input-content-hover-outline, 0)}.ran-input-content::placeholder{color:var(--ran-input-content-placeholder-color, var(--ran-color-text-disabled, #999))}.ran-input-content:placeholder-shown~.ran-input-label{transform:var(--ran-input-content-placeholder-label-transform, translateY( calc(-50% - .43em) ) scale(.8))}.ran-input-content:focus~.ran-input-label{transform:var(--ran-input-content-focus-label-transform, translateY( calc(-50% - .43em) ) scale(.8));top:var(--ran-input-content-focus-label-top, 0px)}.ran-input-content::-webkit-search-cancel-button{display:none;-webkit-appearance:none}.ran-input-label{box-sizing:var(--ran-input-label-box-sizing, border-box);pointer-events:var(--ran-input-label-pointer-events, none);position:var(--ran-input-label-position, absolute);font-size:var(--ran-input-label-font-size, 14px);left:var(--ran-input-label-left, 8px);transition:var(--ran-input-label-transition, transform .3s, top .3s, font-size .3s);transform-origin:var(--ran-input-label-transform-origin, left);padding:var(--ran-input-label-padding, 0 0);color:var(--ran-input-label-color, var(--ran-color-text-disabled, #999));background:var(--ran-input-label-background, var(--ran-color-bg-elevated, #fff));opacity:var(--ran-input-label-opacity, .9)}.ran-input-message{margin-top:var(--ran-input-message-margin-top, 4px);font-size:var(--ran-input-message-font-size, 12px);line-height:var(--ran-input-message-line-height, 1.5);color:var(--ran-input-message-color, var(--ran-color-text-secondary, #8c8c8c))}.ran-input-message:empty{display:none}:host([status="error"]) .ran-input-message{color:var(--ran-input-message-error-color, var(--ran-color-danger, #ff4d4f))}:host([status="warning"]) .ran-input-message{color:var(--ran-input-message-warning-color, var(--ran-color-warning, #faad14))}`,F0=0,vc=class extends Ve{static formAssociated=!0;_internals;static get observedAttributes(){return["label","disabled","name","placeholder","type","icon","value","status","message","min","max","step","required","sheet"]}_events=new vt;_shadowDom;_input;_label;_inputContent;_icon;_message;constructor(){super();try{this._internals=this.attachInternals()}catch{this._internals=void 0}this._shadowDom=We(this,M0);const e=_e(this._shadowDom,".ran-input",()=>K().class("ran-input").part("input").children(to().class("ran-input-content").part("content")).build());this._input=e,this._inputContent=e.querySelector(".ran-input-content"),this._inputContent.id||(this._inputContent.id=`ran-input-${++F0}`)}get value(){return this.getAttribute("value")||""}set value(e){!rt(this)&&e?(this.setAttribute("value",e),this._input.setAttribute("value",e)):(this.removeAttribute("value"),this._input.removeAttribute("value")),this._internals?.setFormValue?.(this.getAttribute("value")??"")}get placeholder(){return this.getAttribute("placeholder")||""}set placeholder(e){e?this.setAttribute("placeholder",e):this.removeAttribute("placeholder")}get required(){return this.hasAttribute("required")}set required(e){!e||e==="false"?this.removeAttribute("required"):this.setAttribute("required","")}get disabled(){return rt(this)}set disabled(e){sr.includes(e)?(this.removeAttribute("disabled"),this._input.removeAttribute("disabled"),this._inputContent.removeAttribute("disabled")):(this.setAttribute("disabled",""),this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled",""))}get label(){return this.getAttribute("label")||""}set label(e){this.setAttribute("label",e)}get status(){return this.getAttribute("status")||""}set status(e){e?(this.setAttribute("status",e),this._input.setAttribute("status",e)):(this.removeAttribute("status"),this._input.removeAttribute("status"))}get message(){return this.getAttribute("message")||""}set message(e){e?this.setAttribute("message",e):this.removeAttribute("message")}get name(){return this.getAttribute("name")||""}set name(e){this.setAttribute("name",e)}get min(){return this.getAttribute("min")||""}set min(e){this.type==="number"&&this.setAttribute("min",e)}get max(){return this.getAttribute("max")||""}set max(e){this.type==="number"&&this.setAttribute("max",e)}get step(){return this.getAttribute("step")||""}set step(e){this.type==="number"&&this.setAttribute("step",e)}get icon(){return this.getAttribute("icon")||""}set icon(e){e?this.setAttribute("icon",e):this.removeAttribute("icon")}get type(){return this.getAttribute("type")||""}set type(e){e?this.setAttribute("type",e):this.removeAttribute("type")}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};customInput=e=>{e.stopPropagation(),e.preventDefault();const{target:i,data:n=""}=e;this.value=i?.value||n||"",this.dispatchEvent(new CustomEvent("input",{detail:{value:this.value}}))};customChange=()=>{this.value=this._inputContent?.value??this.value,this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value}}))};listenPlaceholder=(e,i)=>{e==="placeholder"&&this._inputContent&&(i!=null?this._inputContent.setAttribute("placeholder",i):this._inputContent.removeAttribute("placeholder"))};listenLabel=(e,i)=>{e==="label"&&this._inputContent&&(i!=null?this._label?this._label.innerHTML=i:(this._label=C0().class("ran-input-label").part("label").text(i).build(),this._label.htmlFor=this._inputContent.id,this._input.appendChild(this._label)):(this._input.removeAttribute("label"),this._label&&(this._input.removeChild(this._label),this._label=void 0)))};listenType=(e,i)=>{e==="type"&&this._inputContent&&(i?this._inputContent.setAttribute("type",i):(this._inputContent.removeAttribute("type"),this._inputContent.removeAttribute("min"),this._inputContent.removeAttribute("max"),this._inputContent.removeAttribute("step")))};listenStatus=(e,i)=>{e==="status"&&this._input&&(i?this._input.setAttribute("status",i):this._input.removeAttribute("status"))};listenMessage=(e,i)=>{e==="message"&&(i?(this._message||(this._message=K().class("ran-input-message").part("message").build(),this._shadowDom.appendChild(this._message)),this._message.textContent=i):this._message&&(this._message.remove(),this._message=void 0))};listenNumericConstraint=(e,i)=>{(e==="min"||e==="max"||e==="step")&&this._inputContent&&(this.type==="number"&&i!=null?this._inputContent.setAttribute(e,i):this._inputContent.removeAttribute(e))};listenRequired=(e,i)=>{e==="required"&&this._inputContent&&(i!=null?this._inputContent.setAttribute("required",""):this._inputContent.removeAttribute("required"))};listenDisabled=(e,i)=>{e==="disabled"&&this._input&&(sr.includes(i)?this._input.removeAttribute("disabled"):(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")))};listenIcon=(e,i,n)=>{e==="icon"&&i&&i!==n&&(this.removeAttribute("label"),this.setAttribute("icon",i),this.dealIcon())};dealIcon=()=>{this._icon||(this._icon=Ne("r-icon").class("ran-icon").build(),this._inputContent.insertAdjacentElement("beforebegin",this._icon)),this.icon&&this._icon.setAttribute("name",this.icon)};listenEvent=(e,i,n)=>{this.listenPlaceholder(e,n),this.listenLabel(e,n),this.listenStatus(e,n),this.listenMessage(e,n),this.listenNumericConstraint(e,n),this.listenRequired(e,n),this.listenDisabled(e,n),this.listenIcon(e,n,i),e==="value"&&i!==n&&(this._inputContent.value=n,this._input.setAttribute("value",n))};connectedCallback(){this.handlerExternalCss(),this.value&&(this._inputContent.value=this.value,this._input.setAttribute("value",this.value)),this._internals?.setFormValue?.(this.value),this.status&&this._input.setAttribute("status",this.status),this.message&&this.listenMessage("message",this.message),rt(this)&&(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")),this.type&&this._inputContent.setAttribute("type",this.type),this.type==="number"&&(this.min&&this._inputContent.setAttribute("min",this.min),this.max&&this._inputContent.setAttribute("max",this.max),this.step&&this._inputContent.setAttribute("step",this.step)),this.required&&this._inputContent.setAttribute("required",""),this._events.on(this._inputContent,"input",this.customInput),this._events.on(this._inputContent,"change",this.customChange),document.readyState==="complete"&&this.dealIcon()}disconnectedCallback(){this._events.abort()}attributeChangedCallback(e,i,n){i!==n&&(this.listenEvent(e,i,n),e==="sheet"&&this.handlerExternalCss())}};qe("r-input",vc);var O0='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host([type="toast"]) .ran-message-notice{padding:8px;text-align:center;max-width:90%;margin:0 auto;word-break:break-all}:host([type="toast"]) .ran-message-notice-content{display:inline-block;padding:10px 16px;background:#000000b3;border-radius:7px;pointer-events:all}:host([type="toast"]) .ran-message-notice-content-info{align-items:center;display:flex}:host([type="toast"]) .ran-message-notice-content-info span{margin:0;padding:0;font-size:14px;font-variant:tabular-nums;list-style:none;font-feature-settings:"tnum";z-index:1010;width:100%;pointer-events:none;color:#fff}.ran-message-notice{padding:var(--ran-message-notice-padding, 8px);text-align:var(--ran-message-notice-text-align, center);max-width:var(--ran-message-notice-max-width, 90%);margin:var(--ran-message-notice-margin, 0 auto);word-break:var(--ran-message-notice-word-break, break-all)}.ran-message-notice-content{display:var(--ran-message-notice-content-display, inline-block);padding:var(--ran-message-notice-content-padding, 10px 16px);background:var(--ran-message-notice-content-background, var(--ran-color-bg-elevated, #fff));border-image-source:var(--ran-message-notice-content-border-image-source, none);border-image-slice:var(--ran-message-notice-content-border-image-slice, 8);border-image-width:var(--ran-message-notice-content-border-image-width, 4px);border-image-outset:0;border-image-repeat:stretch;border-radius:var(--ran-message-notice-content-border-radius, var(--ran-radius-md, 12px));box-shadow:var(--ran-message-notice-content-box-shadow, var(--ran-shadow-menu, 0 2px 4px #0000000d, 0 8px 24px -6px #00000024));pointer-events:var(--ran-message-notice-content-pointer-events, all)}.ran-message-notice-content-info{align-items:var(--ran-message-notice-content-info-align-items, center);display:var(--ran-message-notice-content-info-display, flex)}.ran-message-notice-content-info span{margin:var(--ran-message-notice-content-info-span-margin, 0);padding:var(--ran-message-notice-content-info-span-padding, 0);color:var(--ran-message-notice-content-info-span-color, var(--ran-color-text, #000000d9));font-size:var(--ran-message-notice-content-info-span-font-size, 14px);font-variant:var(--ran-message-notice-content-info-span-font-variant, tabular-nums);list-style:var(--ran-message-notice-content-info-span-list-style, none);font-feature-settings:var(--ran-message-notice-content-info-span-font-feature-settings, "tnum");z-index:var(--ran-message-notice-content-info-span-z-index, 1010);width:var(--ran-message-notice-content-info-span-width, 100%);pointer-events:var(--ran-message-notice-content-info-span-pointer-events, none)}@keyframes rotate{to{transform:rotate(360deg)}}@keyframes MessageMoveIn{0%{padding:0;transform:translateY(-100%);opacity:0}to{padding:8px;transform:translateY(0);opacity:1}}@keyframes MessageMoveOut{0%{max-height:150px;padding:8px;opacity:1}to{max-height:0;padding:0;opacity:0}}.ranui-message{box-sizing:var(--ran-message-box-sizing, border-box);margin:var(--ran-message-margin, 0);padding:var(--ran-message-padding, 0);color:var(--ran-message-color, var(--ran-color-text, #000000d9));font-size:var(--ran-message-font-size, 14px);font-variant:var(--ran-message-font-variant, tabular-nums);line-height:var(--ran-message-line-height, 1.5715);list-style:var(--ran-message-ist-style, none);font-feature-settings:var(--ran-message-font-feature-settings, "tnum");position:var(--ran-message-position, fixed);top:var(--ran-message-top, 8px);left:var(--ran-message-left, 0);z-index:var(--ran-message-z-index, var(--ran-z-message, 1200));width:var(--ran-message-width, 100%);pointer-events:var(--ran-message-pointer-events, none)}.ranui-message .message-in{animation-name:var(--ran-message-in-animation-name, MessageMoveIn);animation-duration:var(--ran-message-in-animation-duration, .3s);animation-timing-function:var(--ran-message-in-animation-timing-function, cubic-bezier(.78, .14, .15, .86))}.ranui-message .message-leave{animation-name:var(--ran-message-leave-animation-name, MessageMoveOut);animation-duration:var(--ran-message-leave-animation-duration, .3s);animation-timing-function:var(--ran-message-leave-animation-timing-function, cubic-bezier(.78, .14, .15, .86))}',P0={success:!0,_identification:!0,data:'<svg t="1667965185400" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8572" width="200" height="200"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m193.5 301.7l-210.6 292c-12.7 17.7-39 17.7-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z" p-id="8573"></path></svg>'},U0={success:!0,_identification:!0,data:'<svg t="1667965220951" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8711" width="200" height="200"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m165.4 618.2l-66-0.3L512 563.4l-99.3 118.4-66.1 0.3c-4.4 0-8-3.5-8-8 0-1.9 0.7-3.7 1.9-5.2l130.1-155L340.5 359c-1.2-1.5-1.9-3.3-1.9-5.2 0-4.4 3.6-8 8-8l66.1 0.3L512 464.6l99.3-118.4 66-0.3c4.4 0 8 3.5 8 8 0 1.9-0.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z" p-id="8712"></path></svg>'},Q0={success:!0,_identification:!0,data:'<svg t="1667965239916" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8850" width="200" height="200"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272z m-32-344c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48z" p-id="8851"></path></svg>'},N0={success:!0,_identification:!0,data:'<svg t="1667965273540" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8989" width="200" height="200"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296z m32 440c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48z" p-id="8990"></path></svg>'},Ac="data-ranui-message-host",H0=()=>`[${Ac}="true"]`,G0=(e,i)=>{const n=i?.top??8,c=i?.zIndex??1200;e.style.setProperty("position","fixed"),e.style.setProperty("top",typeof n=="number"?`${n}px`:String(n)),e.style.setProperty("left","0"),e.style.setProperty("width","100%"),e.style.setProperty("z-index",String(c)),e.style.setProperty("pointer-events","none")},Y0=e=>typeof document>"u"?null:e?.getContainer?.()||document.body,K0=e=>{if(typeof document>"u")return null;const i=Y0(e)||document.body;let n=i.querySelector(H0());return n||(n=K().attr(Ac,"true").children(K().class("ranui-message").attr("aria-live","polite").attr("aria-atomic","false")).build(),i.appendChild(n)),G0(n,e),n.querySelector(".ranui-message")},bc=300,yc=3e3;fc({"check-circle-fill":P0,"close-circle-fill":U0,"info-circle-fill":Q0,"warning-circle-fill":N0});var z0=new Map([["success","check-circle-fill"],["warning","warning-circle-fill"],["error","close-circle-fill"],["info","info-circle-fill"],["toast",null]]),q0=new Map([["success","#52c41a"],["warning","#faad14"],["error","#ff4d4f"],["info","#006bff"],["toast","rgba(0, 0, 0, 0.7)"]]),wc=class extends Ve{_info;_notice;_content;_icon;_span;_shadowDom;timeId;close;static get observedAttributes(){return["type","content","sheet"]}constructor(){super(),this._shadowDom=We(this,O0);const e=_e(this._shadowDom,".ran-message-notice",()=>K().class("ran-message-notice").children(K().class("ran-message-notice-content").children(K().class("ran-message-notice-content-info").children(Ne("r-icon"),Hr()))).build());this._notice=e,this._content=e.querySelector(".ran-message-notice-content"),this._info=e.querySelector(".ran-message-notice-content-info"),this._icon=e.querySelector("r-icon"),this._span=e.querySelector("span"),this.handlerExternalCss()}connectedCallback(){Ve.prototype.connectedCallback?.call(this),this.hasAttribute("aria-atomic")||this.setAttribute("aria-atomic","true")}get type(){return this.getAttribute("type")}set type(e){e&&this.setAttribute("type",e)}get content(){return this.getAttribute("content")}set content(e){e&&this.setAttribute("content",e)}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};setA11yRole=e=>{const i=e==="error"||e==="warning";this.setAttribute("role",i?"alert":"status")};setIcon=e=>{const i=z0.get(e),n=q0.get(e);i&&(this._icon?.setAttribute("name",i),this._icon?.style.setProperty("margin-right","8px"),this._icon?.setAttribute("size","18"),n&&this._icon?.setAttribute("color",n))};attributeChangedCallback(e,i,n){i!==n&&(e==="content"&&(this._span.textContent=n),e==="type"&&(this.setIcon(n),this.setA11yRole(n)),e==="sheet"&&this.handlerExternalCss())}};qe("r-message",wc);function V0(){if(typeof window>"u")return null;const e=n=>c=>{const g={},m=Ne("r-message").class("message").build();m.timeId&&clearTimeout(m.timeId),m.setAttribute("type",n);let b=yc,E;if(!c)return;typeof c=="string"?m.setAttribute("content",c):(m.setAttribute("content",c.content),E=c.close,b=c.duration||yc,g.top=c.top,g.zIndex=c.zIndex,g.getContainer=c.getContainer);const R=K0(g);if(!R)return;const F=setTimeout(()=>{m.classList.remove("message-in"),m.classList.add("message-leave"),clearTimeout(F)},b-bc);m.timeId=setTimeout(()=>{m.classList.remove("message-leave"),R.removeChild(m),E&&E()},b),R.appendChild(m),m.classList.add("message-in"),setTimeout(()=>{m.classList.remove("message-in")},bc)},i={info:e("info"),success:e("success"),error:e("error"),warning:e("warning"),toast:e("toast")};return window.message=i,window.ranui||(window.ranui={}),window.ranui.message=i,i}var G1=V0(),W0='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}@keyframes skeleton{0%{transform:translate(-37.5%)}to{transform:translate(37.5%)}}.ran-skeleton{position:relative;z-index:0;overflow:hidden;background:0 0;width:100%;height:var(--ran-skeleton-height, 16px);background:var(--ran-skeleton-background, var(--ran-gray-alpha-200, rgba(0, 0, 0, .06)));border-radius:var(--ran-skeleton-border-radius, var(--ran-radius-sm, 6px))}.ran-skeleton:after{position:absolute;top:0;inset-inline-end:-150%;bottom:0;inset-inline-start:-150%;background:var(--ran-skeleton-shimmer, linear-gradient(90deg, var(--ran-gray-alpha-200, rgba(0, 0, 0, .06)) 25%, var(--ran-gray-alpha-500, rgba(0, 0, 0, .15)) 37%, var(--ran-gray-alpha-200, rgba(0, 0, 0, .06)) 63%));animation-name:skeleton;animation-duration:var(--ran-skeleton-animation-duration, 1.4s);animation-timing-function:ease;animation-iteration-count:infinite;content:""}',Cc=class extends Ve{_div;_shadowDom;static get observedAttributes(){return["sheet"]}constructor(){super(),this._shadowDom=We(this,W0),this._div=_e(this._shadowDom,".ran-skeleton",()=>K().class("ran-skeleton").build())}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};connectedCallback(){this.handlerExternalCss()}attributeChangedCallback(e,i,n){i!==n&&e==="sheet"&&this.handlerExternalCss()}};qe("r-skeleton",Cc);var X0=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}",Ec=class extends Ve{static get observedAttributes(){return["label","key","disabled","icon","effect","iconSize","sheet"]}_events=new vt;_div;parent;_shadowDom;constructor(){super(),this._shadowDom=We(this,X0);const e=_e(this._shadowDom,"slot",()=>gt().part("content").build());this._div=e}get label(){return this.getAttribute("label")||""}set label(e){this.setAttribute("label",e)}get icon(){return this.getAttribute("icon")}set icon(e){!e||e==="false"?this.removeAttribute("icon"):this.setAttribute("icon",e)}get iconSize(){return this.getAttribute("iconSize")}set iconSize(e){!e||e==="false"?this.removeAttribute("iconSize"):this.setAttribute("iconSize",e)}get key(){return this.getAttribute("r-key")}set key(e){e?this.setAttribute("r-key",e):this.removeAttribute("r-key")}get disabled(){return this.getAttribute("disabled")}set disabled(e){!e||e==="false"?this.removeAttribute("disabled"):this.setAttribute("disabled",e)}get effect(){return this.getAttribute("effect")}set effect(e){!e||e==="false"?this.removeAttribute("effect"):this.setAttribute("effect",e)}get sheet(){return this.getAttribute("sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};initAttribute=()=>{this.parent=this.parentNode,this.key&&(this.parent?.updateAttribute(this.key,"icon",this.icon),this.parent?.updateAttribute(this.key,"iconSize",this.iconSize),this.parent?.updateAttribute(this.key,"effect",this.effect))};connectedCallback(){this.handlerExternalCss(),this._events.on(document,"DOMContentLoaded",this.initAttribute)}disconnectedCallback(){this._events.abort()}attributeChangedCallback(e,i,n){i!==n&&(this.key&&this.parent?.updateAttribute&&(e==="icon"&&this.parent?.updateAttribute(this.key,"icon",n),e==="iconSize"&&this.parent?.updateAttribute(this.key,"iconSize",n),e==="effect"&&this.parent?.updateAttribute(this.key,"effect",n),e==="disabled"&&this.parent?.updateAttribute(this.key,"disabled",n)),e==="sheet"&&this.handlerExternalCss())}};qe("r-tab",Ec);var J0='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-tab ::slotted(r-tab){box-sizing:border-box;width:100%;height:100%;padding:10px;flex-shrink:0;overflow:auto;text-align:start}.ran-tab-header{position:relative;overflow:hidden;scroll-behavior:smooth}.ran-tab-header-nav{display:flex;flex-flow:row nowrap;justify-content:flex-start;align-items:center}.ran-tab-header-nav::-webkit-scrollbar{display:none}.ran-tab-header-nav-item{flex-shrink:0}.ran-tab-header-nav .active{color:var(--ran-tab-active-color, var(--ran-color-primary, #006bff))}.ran-tab-header-line{position:absolute;width:0;margin-top:-2px;height:2px;border-radius:2px;background:var(--ran-tab-line-color, var(--ran-color-primary, #006bff));transition:var(--ran-tab-line-transition, left .2s, width .2s, transform .2s)}.ran-tab-content{overflow:hidden}.ran-tab-content-wrap{display:flex;width:100%;height:100%;transition:var(--ran-tab-content-transition, transform .2s)}:host([type="line"]) .ran-tab-header-nav-item{border:solid 1px transparent}:host([type="line"]) .ran-tab-header-nav .active{color:var(--ran-tab-line-color, var(--ran-color-primary, #006bff));border:solid 1px transparent;border-color:var(--ran-tab-border-color, var(--ran-color-border, rgba(0, 0, 0, .2))) var(--ran-tab-border-color, var(--ran-color-border, rgba(0, 0, 0, .2))) transparent;border-radius:var(--ran-tab-border-radius, var(--ran-radius-sm, .25em)) var(--ran-tab-border-radius, var(--ran-radius-sm, .25em)) 0 0}:host([type="line"]) .ran-tab-header-line{transition:none;visibility:hidden}:host([type="line"]) .ran-tab-header-line:after,:host([type="line"]) .ran-tab-header-line:before{content:"";position:absolute;visibility:visible;width:9999px;height:1px;bottom:0;background:var(--ran-tab-border-color, var(--ran-color-border, rgba(0, 0, 0, .2)))}:host([type="line"]) .ran-tab-header-line:after{left:100%}:host([type="line"]) .ran-tab-header-line:before{right:100%}:host([align="center"]) .ran-tab-header-nav{justify-content:center}:host([align="center"]) .ran-tab-header-line{left:50%}:host([align="end"]) .ran-tab-header-nav{justify-content:flex-end}',_0=0,kc=class extends Ve{static get observedAttributes(){return["active","type","align","effect","sheet"]}_events=new vt;_container;_header;_nav;_line;_content;_wrap;_slot;_shadowDom;_tabsId;tabHeaderKeyMapIndex;constructor(){super(),this._tabsId=++_0,this._shadowDom=We(this,J0),this.tabHeaderKeyMapIndex={};const e=_e(this._shadowDom,".ran-tab",()=>K().class("ran-tab").part("tabs").children(K().class("ran-tab-header").part("header").children(K().class("ran-tab-header-nav").part("nav"),K().class("ran-tab-header-line").part("indicator")),K().class("ran-tab-content").part("content").children(K().class("ran-tab-content-wrap").part("content-wrap").children(gt()))).build());this._container=e,this._header=e.querySelector(".ran-tab-header"),this._nav=e.querySelector(".ran-tab-header-nav"),this._line=e.querySelector(".ran-tab-header-line"),this._content=e.querySelector(".ran-tab-content"),this._wrap=e.querySelector(".ran-tab-content-wrap"),this._slot=e.querySelector("slot"),this._nav.setAttribute("role","tablist")}get align(){return Be(this,"align","start")}set align(e){this.setAttribute("align",e)}get type(){return Be(this,"type","flat")}set type(e){this.setAttribute("type",e)}get active(){return this.getAttribute("active")}set active(e){e?(this.setAttribute("active",e),this.setTabLine(e),this.setTabContent(e),this.syncTabsAria()):this.removeAttribute("active")}get effect(){return this.getAttribute("effect")}set effect(e){!e||e==="false"?this.removeAttribute("effect"):this.setAttribute("effect",e)}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};initTabHeaderKeyMapIndex=(e,i)=>{if(this.tabHeaderKeyMapIndex[e])throw new Error("tab 组件的 key 值存在重复,或者某个 tab 组件缺少 key 属性");this.tabHeaderKeyMapIndex[e]=i};createTabHeader(e,i){const n=e.getAttribute("label")||"",c=e.getAttribute("icon")||"",g=e.getAttribute("iconSize")||"",m=e.getAttribute("r-key")||`${i}`,b=e.getAttribute("type")||"text";this.initTabHeaderKeyMapIndex(m,i);const E=Ne("r-button").class("tab-header-nav-item").attr("type",b).attr("r-key",m).text(n);return c&&E.attr("icon",c),g&&E.attr("iconSize",g),rt(e)&&E.attr("disabled",""),this.effect&&(e.setAttribute("effect",this.effect),this._line.style.setProperty("display","none")),e.setAttribute("r-key",m),E.build()}initTabLineAlignCenter=()=>{const{length:e}=this._nav.children;let i=0;for(let n=0;n<e;n++){const{width:c=0}=this._nav.children[n].getBoundingClientRect();i+=c}this._line.style.setProperty("left",`calc(50% - ${i/2}px)`)};initTabLineAlignEnd=()=>{const{length:e}=this._nav.children;let i=0;for(let n=0;n<e;n++){const{width:c=0}=this._nav.children[n].getBoundingClientRect();i+=c}this._line.style.setProperty("left",`calc(100% - ${i}px)`)};setTabLine=e=>{if(e){const i=this.tabHeaderKeyMapIndex[e],{width:n=0}=this._nav.children[i].getBoundingClientRect();this._line.style.setProperty("width",`${n}px`);let c=0;for(let g=0;g<i;g++){const{width:m=0}=this._nav.children[g].getBoundingClientRect();c+=m}this._line.style.setProperty("transform",`translateX(${c}px)`)}};setTabContent=e=>{if(e){const i=this.tabHeaderKeyMapIndex[e];this._wrap.style.setProperty("transform",`translateX(${i*-100}%)`)}};clickTabHead=e=>{const i=e.currentTarget??e.target,n=i.getAttribute("r-key");!rt(i)&&n&&this.activateKey(n)};activateKey=e=>{this.setAttribute("active",e),this.setTabLine(e),this.setTabContent(e),this._nav.querySelectorAll(".active").forEach(n=>n.classList.remove("active"));const i=this.tabHeaderKeyMapIndex[e];this._nav.children[i]?.classList.add("active"),this.syncTabsAria()};tabFocusable=e=>e._btn??e;tabIdFor=e=>`ran-tab-${this._tabsId}-${e}`;panelIdFor=e=>`ran-tabpanel-${this._tabsId}-${e}`;syncTabsAria=()=>{const e=this.active,i=this._slot?.assignedElements?.()??[];[...this._nav.children].forEach((n,c)=>{const g=n.getAttribute("r-key")??`${c}`,m=g===e,b=rt(n),E=this.tabFocusable(n);E.setAttribute("role","tab"),E.id=this.tabIdFor(g),E.setAttribute("aria-controls",this.panelIdFor(g)),E.setAttribute("aria-selected",m?"true":"false"),E.tabIndex=m&&!b?0:-1;const R=i[c];R&&(R.setAttribute("role","tabpanel"),R.id=this.panelIdFor(g),R.setAttribute("aria-labelledby",this.tabIdFor(g)),R.setAttribute("tabindex",m?"0":"-1"),m?R.removeAttribute("aria-hidden"):R.setAttribute("aria-hidden","true"))})};onNavKeydown=e=>{if(!["ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(e.key))return;const i=[...this._nav.children].filter(b=>!rt(b));if(!i.length)return;const n=e.target?.closest?.(".tab-header-nav-item")??e.target;let c=i.findIndex(b=>b===n);c<0&&(c=i.findIndex(b=>b.getAttribute("r-key")===this.active)),c<0&&(c=0);let g=c;e.key==="ArrowRight"||e.key==="ArrowDown"?g=(c+1)%i.length:e.key==="ArrowLeft"||e.key==="ArrowUp"?g=(c-1+i.length)%i.length:e.key==="Home"?g=0:e.key==="End"&&(g=i.length-1),e.preventDefault();const m=i[g].getAttribute("r-key");m&&(this.activateKey(m),this.tabFocusable(i[g]).focus())};updateAttribute=(e,i,n="")=>{const c=this.tabHeaderKeyMapIndex[e];e&&n&&this._nav.children[c]?this._nav.children[c]?.setAttribute(i,n):this._nav.children[c]?.removeAttribute(i)};initActive=()=>{const e=[...this._nav.children],i=e.filter(m=>!rt(m));let n;if(this.active!=null&&(n=i.find(m=>m.getAttribute("r-key")===this.active),n?.setAttribute("r-key",this.active)),n||(n=i.shift()),!n)return;const c=e.findIndex(m=>m===n),g=n?.getAttribute("r-key")||`${c}`;g!=null&&(this.setAttribute("active",`${g}`),n.classList.add("active"),this.setTabContent(g),setTimeout(()=>{this.setTabLine(g)},200))};listenSlotChange=()=>{this._slot.assignedElements().forEach((e,i)=>{const n=this.createTabHeader(e,i);this._nav.appendChild(n),n.addEventListener("click",this.clickTabHead)}),this.initActive(),this.syncTabsAria(),this.align&&(this.align==="center"&&this.initTabLineAlignCenter(),this.align==="end"&&this.initTabLineAlignEnd())};connectedCallback(){this.handlerExternalCss(),this._events.on(this._slot,"slotchange",this.listenSlotChange),this._events.on(this._nav,"keydown",this.onNavKeydown)}disconnectedCallback(){this._events.abort()}attributeChangedCallback(e,i,n){i!==n&&(this.dispatchEvent(new CustomEvent("change",{detail:{active:this.active}})),e==="align"&&(n==="center"&&this.initTabLineAlignCenter(),n==="end"&&this.initTabLineAlignEnd()),e==="effect"&&[...this._nav.children].forEach(c=>{!this.effect||this.effect==="false"?c.removeAttribute("effect"):c.setAttribute("effect",n)}),e==="active"&&this.setAttribute(e,n),e==="sheet"&&this.handlerExternalCss())}};qe("r-tabs",kc);var j0=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{--ran-radar-polygon-color: var(--ran-color-border, #e6e6e6);--ran-radar-line-color: var(--ran-color-border, #e6e6e6);--ran-radar-fill-color: rgba(255, 121, 35, .6);--ran-radar-stroke-color: rgba(255, 121, 35, .6)}.ran-radar{position:var(--ran-radar-position, relative);width:var(--ran-radar-width, 100%);height:var(--ran-radar-height, 100%);display:var(--ran-radar-display, block)}.ran-radar canvas{width:100%;height:100%}",Z0="rgba(0,0,0,0)",$0="rgba(0,0,0,1)",Bc="#e6e6e6",Ic="#e6e6e6",ef="黑体",Sc="rgba(255,121,35,0.60)",xc="rgba(255,121,35,0.60)",Tc=class extends Ve{mData;mCount;mW;mCenter;mRadius;mAngle;static get observedAttributes(){return["abilitys","colorpolygon","colorline","fillcolor","strokecolor","sheet"]}abilityRadarChartContainer;abilityRadarChart;_iconElement;_shadowDom;resizeObserver;constructor(){super(),this._shadowDom=We(this,j0);const e=_e(this._shadowDom,".ran-radar",()=>K().class("ran-radar").children(Ne("canvas").build()).build()),i=e.querySelector("canvas");this.abilityRadarChartContainer=e,this.abilityRadarChart=i,this.resizeObserver=new ResizeObserver(this.resize),this.resizeObserver.observe(this.abilityRadarChartContainer)}resize=()=>{this.refreshData()};get abilitys(){const e=this.getAttribute("abilitys");if(typeof e=="string")try{return JSON.parse(e)}catch(i){return console.error(`Failed to parse the rule in JSON.parse: ${e}, error: ${i}`),e}return e}set abilitys(e){typeof e=="string"?this.setAttribute("abilitys",e||""):this.setAttribute("abilitys",JSON.stringify(e)||"")}_cssVar(e){return typeof getComputedStyle>"u"?"":getComputedStyle(this).getPropertyValue(e).trim()}get colorPolygon(){return this.getAttribute("colorPolygon")||this._cssVar("--ran-radar-polygon-color")||Bc}set colorPolygon(e){this.setAttribute("colorPolygon",e||Bc)}get colorLine(){return this.getAttribute("colorLine")||this._cssVar("--ran-radar-line-color")||Ic}set colorLine(e){this.setAttribute("colorLine",e||Ic)}get fontColor(){return this._cssVar("--ran-color-text")||$0}get fillColor(){return this.getAttribute("fillColor")||this._cssVar("--ran-radar-fill-color")||Sc}set fillColor(e){this.setAttribute("fillColor",e||Sc)}get strokeColor(){return this.getAttribute("strokeColor")||this._cssVar("--ran-radar-stroke-color")||xc}set strokeColor(e){this.setAttribute("strokeColor",e||xc)}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};refreshData(){const e=this.abilityRadarChart.getContext("2d");if(!this.abilityRadarChartContainer||!e)return;const i=Hi(e),n=this.abilityRadarChartContainer.clientWidth*i,c=this.abilityRadarChartContainer.clientHeight*i;this.abilityRadarChart.width=n,this.abilityRadarChart.height=c,this.mW=n,this.mData=this.abilitys,this.mCount=this.mData?.length||1,this.mCenter=this.mW/2,this.mRadius=this.mCenter-50*i,this.mAngle=Math.PI*2/this.mCount,this.drawPolygon(e),this.drawSide(e),this.drawLines(e),this.drawText(e),this.drawRegion(e),this.drawCircle(e)}drawSide(e){if(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle)return;e.save(),e.strokeStyle=this.colorLine;const i=this.mRadius;for(let n=0;n<this.mCount;n++){const c=this.mCenter+i*Math.sin(this.mAngle*n),g=this.mCenter+i*Math.cos(this.mAngle*n);e.lineTo(c,g)}e.closePath(),e.stroke()}drawPolygon(e){if(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle)return;e.save(),e.strokeStyle=this.colorPolygon;const i=this.mRadius/4;e.setLineDash([6,6]);for(let n=0;n<4;n++){e.beginPath();const c=i*(n+1);for(let g=0;g<this.mCount;g++){const m=this.mCenter+c*Math.sin(this.mAngle*g),b=this.mCenter+c*Math.cos(this.mAngle*g);e.lineTo(m,b)}e.closePath(),e.stroke()}e.restore()}drawLines(e){if(!(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle)){e.save(),e.beginPath(),e.strokeStyle=this.colorLine;for(let i=0;i<this.mCount;i++){const n=this.mCenter+this.mRadius*Math.sin(this.mAngle*i),c=this.mCenter+this.mRadius*Math.cos(this.mAngle*i);e.moveTo(this.mCenter,this.mCenter),e.lineTo(n,c)}e.stroke(),e.restore()}}drawText(e){if(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle||!this.mData)return;e.save();const i=Hi(e),n=this.mCenter/12;for(let c=0;c<this.mCount;c++){const g=this.mCenter+this.mRadius*Math.sin(this.mAngle*c),m=this.mCenter+this.mRadius*Math.cos(this.mAngle*c),b=this.mData[c]?.backgroundColor||Z0,E=this.mData[c]?.fontColor||this.fontColor,R=this.mData[c]?.fontFamily||ef,F=this.mData[c]?.fontSize||n;e.font=`${F}px ${R}`,this.mAngle*c>=0&&this.mAngle*c<Math.PI/2?this.drawButton(e,b,g,m,44*i,24*i,12*i,this.mData[c].abilityName,E,R,F):this.mAngle*c>=Math.PI/2&&this.mAngle*c<Math.PI?this.drawButton(e,b,g,m-24*i,44*i,24*i,12*i,this.mData[c].abilityName,E,R,F):this.mAngle*c>=Math.PI&&this.mAngle*c<Math.PI*3/2?this.drawButton(e,b,g-44*i,m-24*i,44*i,24*i,12*i,this.mData[c].abilityName,E,R,F):this.drawButton(e,b,g-44*i,m,44*i,24*i,12*i,this.mData[c].abilityName,E,R,F)}e.restore()}drawButton(e,i,n,c,g,m,b,E,R,F,Q){e.beginPath();const Y=Hi(e);e.fillStyle=i,e.moveTo(n+b,c),e.lineTo(n+g-b,c),e.arc(n+g-b,c+b,b,Math.PI*3/2,Math.PI*2),e.lineTo(n+g,c+m-b),e.arc(n+g-b,c+m-b,b,Math.PI,Math.PI/2),e.lineTo(n+b,c+m),e.arc(n+b,c+m-b,b,Math.PI/2,Math.PI),e.lineTo(n,c+b),e.arc(n+b,c+b,b,Math.PI,Math.PI*3/2),e.fill(),e.closePath(),e.beginPath(),e.fillStyle=R,e.font=`${Q||12*Y}px ${F}`,e.textAlign="center",e.textBaseline="middle",e.fillText(E,n+g/2,c+m/2)}drawRegion(e){if(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle||!this.mData)return;const i=Hi(e);e.save(),e.beginPath();for(let n=0;n<this.mCount;n++){const c=this.mCenter+this.mRadius*Math.sin(this.mAngle*n)*this.mData[n].scoreRate/100,g=this.mCenter+this.mRadius*Math.cos(this.mAngle*n)*this.mData[n].scoreRate/100;e.lineTo(c,g)}e.closePath(),e.fillStyle=this.fillColor,e.fill(),e.strokeStyle=this.strokeColor,e.lineWidth=1*i,e.stroke(),e.restore()}drawCircle(e){if(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle||!this.mData)return;const i=Hi(e);e.save();for(let n=0;n<this.mCount;n++){const c=this.mCenter+this.mRadius*Math.sin(this.mAngle*n)*this.mData[n].scoreRate/100,g=this.mCenter+this.mRadius*Math.cos(this.mAngle*n)*this.mData[n].scoreRate/100;e.beginPath(),e.arc(c,g,3,0,Math.PI*2),e.lineWidth=1.5*i,e.strokeStyle=this.strokeColor,e.stroke()}e.restore()}connectedCallback(){this.handlerExternalCss(),this.refreshData()}disconnectedCallback(){this.resizeObserver.disconnect()}attributeChangedCallback(e,i,n){i!==n&&(["abilitys","colorpolygon","colorline","fillcolor","strokecolor"].includes(e)&&this.abilityRadarChartContainer&&this.refreshData(),e==="sheet"&&this.handlerExternalCss())}};qe("r-radar",Tc);var tf=a0(((e,i)=>{(function n(c){function b(d,s){var t=Object.keys(d);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(d);s&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(d,a).enumerable})),t.push.apply(t,r)}return t}function E(d){for(var s=1;s<arguments.length;s++){var t=arguments[s]!=null?arguments[s]:{};s%2?b(Object(t),!0).forEach(function(r){Q(d,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(t)):b(Object(t)).forEach(function(r){Object.defineProperty(d,r,Object.getOwnPropertyDescriptor(t,r))})}return d}function R(d,s){for(var t=0;t<s.length;t++){var r=s[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(d,Fe(r.key),r)}}function F(d,s,t){return s&&R(d.prototype,s),t&&R(d,t),Object.defineProperty(d,"prototype",{writable:!1}),d}function Q(d,s,t){return(s=Fe(s))in d?Object.defineProperty(d,s,{value:t,enumerable:!0,configurable:!0,writable:!0}):d[s]=t,d}function Y(){return Y=Object.assign?Object.assign.bind():function(d){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(d[r]=t[r])}return d},Y.apply(this,arguments)}function X(d,s){d.prototype=Object.create(s.prototype),d.prototype.constructor=d,ne(d,s)}function _(d){return _=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},_(d)}function ne(d,s){return ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},ne(d,s)}function te(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ge(d,s,t){return ge=te()?Reflect.construct.bind():function(r,a,o){var l=[null];l.push.apply(l,a);var h=new(Function.bind.apply(r,l));return o&&ne(h,o.prototype),h},ge.apply(null,arguments)}function ce(d){var s=typeof Map=="function"?new Map:void 0;return ce=function(t){if(t===null||(r=t,Function.toString.call(r).indexOf("[native code]")===-1))return t;var r;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(s!==void 0){if(s.has(t))return s.get(t);s.set(t,a)}function a(){return ge(t,arguments,_(this).constructor)}return a.prototype=Object.create(t.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),ne(a,t)},ce(d)}function be(d,s){(s==null||s>d.length)&&(s=d.length);for(var t=0,r=new Array(s);t<s;t++)r[t]=d[t];return r}function xe(d,s){var t=typeof Symbol<"u"&&d[Symbol.iterator]||d["@@iterator"];if(t)return(t=t.call(d)).next.bind(t);if(Array.isArray(d)||(t=(function(a,o){if(a){if(typeof a=="string")return be(a,o);var l=Object.prototype.toString.call(a).slice(8,-1);return l==="Object"&&a.constructor&&(l=a.constructor.name),l==="Map"||l==="Set"?Array.from(a):l==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?be(a,o):void 0}})(d))||s&&d&&typeof d.length=="number"){t&&(d=t);var r=0;return function(){return r>=d.length?{done:!0}:{done:!1,value:d[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
5
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Fe(d){var s=(function(t,r){if(typeof t!="object"||t===null)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var o=a.call(t,r||"default");if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)})(d,"string");return typeof s=="symbol"?s:String(s)}function Te(d){return d&&d.__esModule&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d}var De={exports:{}};(function(d,s){var t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,a=/(?:\/|^)\.(?=\/)/g,o=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,l={buildAbsoluteURL:function(h,u,f){if(f=f||{},h=h.trim(),!(u=u.trim())){if(!f.alwaysNormalize)return h;var p=l.parseURL(h);if(!p)throw new Error("Error trying to parse base URL.");return p.path=l.normalizePath(p.path),l.buildURLFromParts(p)}var v=l.parseURL(u);if(!v)throw new Error("Error trying to parse relative URL.");if(v.scheme)return f.alwaysNormalize?(v.path=l.normalizePath(v.path),l.buildURLFromParts(v)):u;var w=l.parseURL(h);if(!w)throw new Error("Error trying to parse base URL.");if(!w.netLoc&&w.path&&w.path[0]!=="/"){var C=r.exec(w.path);w.netLoc=C[1],w.path=C[2]}w.netLoc&&!w.path&&(w.path="/");var k={scheme:w.scheme,netLoc:v.netLoc,path:null,params:v.params,query:v.query,fragment:v.fragment};if(!v.netLoc&&(k.netLoc=w.netLoc,v.path[0]!=="/"))if(v.path){var I=w.path,D=I.substring(0,I.lastIndexOf("/")+1)+v.path;k.path=l.normalizePath(D)}else k.path=w.path,v.params||(k.params=w.params,v.query||(k.query=w.query));return k.path===null&&(k.path=f.alwaysNormalize?l.normalizePath(v.path):v.path),l.buildURLFromParts(k)},parseURL:function(h){var u=t.exec(h);return u?{scheme:u[1]||"",netLoc:u[2]||"",path:u[3]||"",params:u[4]||"",query:u[5]||"",fragment:u[6]||""}:null},normalizePath:function(h){for(h=h.split("").reverse().join("").replace(a,"");h.length!==(h=h.replace(o,"")).length;);return h.split("").reverse().join("")},buildURLFromParts:function(h){return h.scheme+h.netLoc+h.path+h.params+h.query+h.fragment}};d.exports=l})(De);var Ge=De.exports,se=Number.isFinite||function(d){return typeof d=="number"&&isFinite(d)},x=(function(d){return d.MEDIA_ATTACHING="hlsMediaAttaching",d.MEDIA_ATTACHED="hlsMediaAttached",d.MEDIA_DETACHING="hlsMediaDetaching",d.MEDIA_DETACHED="hlsMediaDetached",d.BUFFER_RESET="hlsBufferReset",d.BUFFER_CODECS="hlsBufferCodecs",d.BUFFER_CREATED="hlsBufferCreated",d.BUFFER_APPENDING="hlsBufferAppending",d.BUFFER_APPENDED="hlsBufferAppended",d.BUFFER_EOS="hlsBufferEos",d.BUFFER_FLUSHING="hlsBufferFlushing",d.BUFFER_FLUSHED="hlsBufferFlushed",d.MANIFEST_LOADING="hlsManifestLoading",d.MANIFEST_LOADED="hlsManifestLoaded",d.MANIFEST_PARSED="hlsManifestParsed",d.LEVEL_SWITCHING="hlsLevelSwitching",d.LEVEL_SWITCHED="hlsLevelSwitched",d.LEVEL_LOADING="hlsLevelLoading",d.LEVEL_LOADED="hlsLevelLoaded",d.LEVEL_UPDATED="hlsLevelUpdated",d.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",d.LEVELS_UPDATED="hlsLevelsUpdated",d.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",d.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",d.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",d.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",d.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",d.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",d.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",d.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",d.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",d.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",d.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",d.CUES_PARSED="hlsCuesParsed",d.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",d.INIT_PTS_FOUND="hlsInitPtsFound",d.FRAG_LOADING="hlsFragLoading",d.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",d.FRAG_LOADED="hlsFragLoaded",d.FRAG_DECRYPTED="hlsFragDecrypted",d.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",d.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",d.FRAG_PARSING_METADATA="hlsFragParsingMetadata",d.FRAG_PARSED="hlsFragParsed",d.FRAG_BUFFERED="hlsFragBuffered",d.FRAG_CHANGED="hlsFragChanged",d.FPS_DROP="hlsFpsDrop",d.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",d.ERROR="hlsError",d.DESTROYING="hlsDestroying",d.KEY_LOADING="hlsKeyLoading",d.KEY_LOADED="hlsKeyLoaded",d.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",d.BACK_BUFFER_REACHED="hlsBackBufferReached",d})({}),ue=(function(d){return d.NETWORK_ERROR="networkError",d.MEDIA_ERROR="mediaError",d.KEY_SYSTEM_ERROR="keySystemError",d.MUX_ERROR="muxError",d.OTHER_ERROR="otherError",d})({}),q=(function(d){return d.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",d.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",d.KEY_SYSTEM_NO_SESSION="keySystemNoSession",d.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",d.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",d.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",d.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",d.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",d.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",d.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",d.MANIFEST_LOAD_ERROR="manifestLoadError",d.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",d.MANIFEST_PARSING_ERROR="manifestParsingError",d.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",d.LEVEL_EMPTY_ERROR="levelEmptyError",d.LEVEL_LOAD_ERROR="levelLoadError",d.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",d.LEVEL_PARSING_ERROR="levelParsingError",d.LEVEL_SWITCH_ERROR="levelSwitchError",d.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",d.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",d.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",d.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",d.FRAG_LOAD_ERROR="fragLoadError",d.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",d.FRAG_DECRYPT_ERROR="fragDecryptError",d.FRAG_PARSING_ERROR="fragParsingError",d.FRAG_GAP="fragGap",d.REMUX_ALLOC_ERROR="remuxAllocError",d.KEY_LOAD_ERROR="keyLoadError",d.KEY_LOAD_TIMEOUT="keyLoadTimeOut",d.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",d.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",d.BUFFER_APPEND_ERROR="bufferAppendError",d.BUFFER_APPENDING_ERROR="bufferAppendingError",d.BUFFER_STALLED_ERROR="bufferStalledError",d.BUFFER_FULL_ERROR="bufferFullError",d.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",d.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",d.INTERNAL_EXCEPTION="internalException",d.INTERNAL_ABORTED="aborted",d.UNKNOWN="unknown",d})({}),At=function(){},ut={trace:At,debug:At,log:At,warn:At,info:At,error:At},ft=ut;function Kt(d){var s=self.console[d];return s?s.bind(self.console,"["+d+"] >"):At}function tr(d,s){if(self.console&&d===!0||typeof d=="object"){(function(t){for(var r=arguments.length,a=new Array(r>1?r-1:0),o=1;o<r;o++)a[o-1]=arguments[o];a.forEach(function(l){ft[l]=t[l]?t[l].bind(t):Kt(l)})})(d,"debug","log","info","warn","error");try{ft.log('Debug logs enabled for "'+s+'" in hls.js version 1.4.12')}catch{ft=ut}}else ft=ut}var G=ft,ri=/^(\d+)x(\d+)$/,Nt=/(.+?)=(".*?"|.*?)(?:,|$)/g,Ke=(function(){function d(t){for(var r in typeof t=="string"&&(t=d.parseAttrList(t)),t)t.hasOwnProperty(r)&&(r.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(r)),this[r]=t[r])}var s=d.prototype;return s.decimalInteger=function(t){var r=parseInt(this[t],10);return r>Number.MAX_SAFE_INTEGER?1/0:r},s.hexadecimalInteger=function(t){if(this[t]){var r=(this[t]||"0x").slice(2);r=(1&r.length?"0":"")+r;for(var a=new Uint8Array(r.length/2),o=0;o<r.length/2;o++)a[o]=parseInt(r.slice(2*o,2*o+2),16);return a}return null},s.hexadecimalIntegerAsNumber=function(t){var r=parseInt(this[t],16);return r>Number.MAX_SAFE_INTEGER?1/0:r},s.decimalFloatingPoint=function(t){return parseFloat(this[t])},s.optionalFloat=function(t,r){var a=this[t];return a?parseFloat(a):r},s.enumeratedString=function(t){return this[t]},s.bool=function(t){return this[t]==="YES"},s.decimalResolution=function(t){var r=ri.exec(this[t]);if(r!==null)return{width:parseInt(r[1],10),height:parseInt(r[2],10)}},d.parseAttrList=function(t){var r,a={};for(Nt.lastIndex=0;(r=Nt.exec(t))!==null;){var o=r[2];o.indexOf('"')===0&&o.lastIndexOf('"')===o.length-1&&(o=o.slice(1,-1)),a[r[1].trim()]=o}return a},d})();function It(d){return d==="SCTE35-OUT"||d==="SCTE35-IN"}var mr=(function(){function d(s,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var r=t.attr;for(var a in r)if(Object.prototype.hasOwnProperty.call(s,a)&&s[a]!==r[a]){G.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+s.ID+'"'),this._badValueForSameId=a;break}s=Y(new Ke({}),r,s)}if(this.attr=s,this._startDate=new Date(s["START-DATE"]),"END-DATE"in this.attr){var o=new Date(this.attr["END-DATE"]);se(o.getTime())&&(this._endDate=o)}}return F(d,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var s=this.duration;return s!==null?new Date(this._startDate.getTime()+1e3*s):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var s=this.attr.decimalFloatingPoint("DURATION");if(se(s))return s}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&se(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),d})(),vr=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}},ot="audio",bt="video",zt="audiovideo",rr=(function(){function d(s){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[ot]=null,t[bt]=null,t[zt]=null,t),this.baseurl=s}return d.prototype.setByteRange=function(s,t){var r=s.split("@",2),a=[];r.length===1?a[0]=t?t.byteRangeEndOffset:0:a[0]=parseInt(r[1]),a[1]=parseInt(r[0])+a[0],this._byteRange=a},F(d,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Ge.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(s){this._url=s}}]),d})(),Ar=(function(d){function s(r,a){var o;return(o=d.call(this,a)||this)._decryptdata=null,o.rawProgramDateTime=null,o.programDateTime=null,o.tagList=[],o.duration=0,o.sn=0,o.levelkeys=void 0,o.type=void 0,o.loader=null,o.keyLoader=null,o.level=-1,o.cc=0,o.startPTS=void 0,o.endPTS=void 0,o.startDTS=void 0,o.endDTS=void 0,o.start=0,o.deltaPTS=void 0,o.maxStartPTS=void 0,o.minEndPTS=void 0,o.stats=new vr,o.urlId=0,o.data=void 0,o.bitrateTest=!1,o.title=null,o.initSegment=null,o.endList=void 0,o.gap=void 0,o.type=r,o}X(s,d);var t=s.prototype;return t.setKeyFormat=function(r){if(this.levelkeys){var a=this.levelkeys[r];a&&!this._decryptdata&&(this._decryptdata=a.getDecryptData(this.sn))}},t.abortRequests=function(){var r,a;(r=this.loader)==null||r.abort(),(a=this.keyLoader)==null||a.abort()},t.setElementaryStreamInfo=function(r,a,o,l,h,u){u===void 0&&(u=!1);var f=this.elementaryStreams,p=f[r];p?(p.startPTS=Math.min(p.startPTS,a),p.endPTS=Math.max(p.endPTS,o),p.startDTS=Math.min(p.startDTS,l),p.endDTS=Math.max(p.endDTS,h)):f[r]={startPTS:a,endPTS:o,startDTS:l,endDTS:h,partial:u}},t.clearElementaryStreamInfo=function(){var r=this.elementaryStreams;r[ot]=null,r[bt]=null,r[zt]=null},F(s,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var r=this.levelkeys.identity;if(r)this._decryptdata=r.getDecryptData(this.sn);else{var a=Object.keys(this.levelkeys);if(a.length===1)return this._decryptdata=this.levelkeys[a[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!se(this.programDateTime))return null;var r=se(this.duration)?this.duration:0;return this.programDateTime+1e3*r}},{key:"encrypted",get:function(){var r;if((r=this._decryptdata)!=null&&r.encrypted)return!0;if(this.levelkeys){var a=Object.keys(this.levelkeys),o=a.length;if(o>1||o===1&&this.levelkeys[a[0]].encrypted)return!0}return!1}}]),s})(rr),zr=(function(d){function s(t,r,a,o,l){var h;(h=d.call(this,a)||this).fragOffset=0,h.duration=0,h.gap=!1,h.independent=!1,h.relurl=void 0,h.fragment=void 0,h.index=void 0,h.stats=new vr,h.duration=t.decimalFloatingPoint("DURATION"),h.gap=t.bool("GAP"),h.independent=t.bool("INDEPENDENT"),h.relurl=t.enumeratedString("URI"),h.fragment=r,h.index=o;var u=t.enumeratedString("BYTERANGE");return u&&h.setByteRange(u,l),l&&(h.fragOffset=l.fragOffset+l.duration),h}return X(s,d),F(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}]),s})(rr),ga=(function(){function d(s){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=s}return d.prototype.reloaded=function(s){if(!s)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-s.lastPartSn,r=this.lastPartIndex-s.lastPartIndex;this.updated=this.endSN!==s.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>s.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*s.misses):this.misses=s.misses+1,this.availabilityDelay=s.availabilityDelay},F(d,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&se(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var s=this.driftEndTime-this.driftStartTime;return s>0?1e3*(this.driftEnd-this.driftStart)/s:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var s;return(s=this.partList)!=null&&s.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var s;return(s=this.fragments)!=null&&s.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var s;return(s=this.partList)!=null&&s.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var s;return(s=this.partList)!=null&&s.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),d})();function ii(d){return Uint8Array.from(atob(d),function(s){return s.charCodeAt(0)})}function fa(d){var s,t,r=d.split(":"),a=null;if(r[0]==="data"&&r.length===2){var o=r[1].split(";"),l=o[o.length-1].split(",");if(l.length===2){var h=l[0]==="base64",u=l[1];h?(o.splice(-1,1),a=ii(u)):(s=qr(u).subarray(0,16),(t=new Uint8Array(16)).set(s,16-s.length),a=t)}}return a}function qr(d){return Uint8Array.from(unescape(encodeURIComponent(d)),function(s){return s.charCodeAt(0)})}var $e={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Vr="org.w3.clearkey",Lr="com.apple.streamingkeydelivery",qt="com.microsoft.playready",Mr="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function cu(d){switch(d){case Lr:return $e.FAIRPLAY;case qt:return $e.PLAYREADY;case Mr:return $e.WIDEVINE;case Vr:return $e.CLEARKEY}}var du="edef8ba979d64acea3c827dcd51d21ed";function hu(d){switch(d){case $e.FAIRPLAY:return Lr;case $e.PLAYREADY:return qt;case $e.WIDEVINE:return Mr;case $e.CLEARKEY:return Vr}}function Xs(d){var s=d.drmSystems,t=d.widevineLicenseUrl,r=s?[$e.FAIRPLAY,$e.WIDEVINE,$e.PLAYREADY,$e.CLEARKEY].filter(function(a){return!!s[a]}):[];return!r[$e.WIDEVINE]&&t&&r.push($e.WIDEVINE),r}var uu=typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function ai(d,s,t){return Uint8Array.prototype.slice?d.slice(s,t):new Uint8Array(Array.prototype.slice.call(d,s,t))}var Js,_s=function(d,s){return s+10<=d.length&&d[s]===73&&d[s+1]===68&&d[s+2]===51&&d[s+3]<255&&d[s+4]<255&&d[s+6]<128&&d[s+7]<128&&d[s+8]<128&&d[s+9]<128},gu=function(d,s){return s+10<=d.length&&d[s]===51&&d[s+1]===68&&d[s+2]===73&&d[s+3]<255&&d[s+4]<255&&d[s+6]<128&&d[s+7]<128&&d[s+8]<128&&d[s+9]<128},kn=function(d,s){for(var t=s,r=0;_s(d,s);)r+=10,r+=Bn(d,s+6),gu(d,s+10)&&(r+=10),s+=r;if(r>0)return d.subarray(t,t+r)},Bn=function(d,s){var t=0;return t=(127&d[s])<<21,t|=(127&d[s+1])<<14,t|=(127&d[s+2])<<7,t|=127&d[s+3]},Up=function(d,s){return _s(d,s)&&Bn(d,s+6)+10<=d.length-s},fu=function(d){return d&&d.key==="PRIV"&&d.info==="com.apple.streaming.transportStreamTimestamp"},Qp=function(d){var s=String.fromCharCode(d[0],d[1],d[2],d[3]),t=Bn(d,4);return{type:s,size:t,data:d.subarray(10,10+t)}},pu=function(d){for(var s=0,t=[];_s(d,s);){for(var r=Bn(d,s+6),a=(s+=10)+r;s+8<a;){var o=Qp(d.subarray(s)),l=Np(o);l&&t.push(l),s+=o.size+10}gu(d,s)&&(s+=10)}return t},Np=function(d){return d.type==="PRIV"?Hp(d):d.type[0]==="W"?Yp(d):Gp(d)},Hp=function(d){if(!(d.size<2)){var s=br(d.data,!0),t=new Uint8Array(d.data.subarray(s.length+1));return{key:d.type,info:s,data:t.buffer}}},Gp=function(d){if(!(d.size<2)){if(d.type==="TXXX"){var s=1,t=br(d.data.subarray(s),!0);s+=t.length+1;var r=br(d.data.subarray(s));return{key:d.type,info:t,data:r}}var a=br(d.data.subarray(1));return{key:d.type,data:a}}},Yp=function(d){if(d.type==="WXXX"){if(d.size<2)return;var s=1,t=br(d.data.subarray(s),!0);s+=t.length+1;var r=br(d.data.subarray(s));return{key:d.type,info:t,data:r}}var a=br(d.data);return{key:d.type,data:a}},Kp=function(d){if(d.data.byteLength===8){var s=new Uint8Array(d.data),t=1&s[3],r=(s[4]<<23)+(s[5]<<15)+(s[6]<<7)+s[7];return r/=45,t&&(r+=4772185884e-2),Math.round(r)}},br=function(d,s){s===void 0&&(s=!1);var t=zp();if(t){var r=t.decode(d);if(s){var a=r.indexOf("\0");return a!==-1?r.substring(0,a):r}return r.replace(/\0/g,"")}for(var o,l,h,u=d.length,f="",p=0;p<u;){if((o=d[p++])===0&&s)return f;if(o!==0&&o!==3)switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:f+=String.fromCharCode(o);break;case 12:case 13:l=d[p++],f+=String.fromCharCode((31&o)<<6|63&l);break;case 14:l=d[p++],h=d[p++],f+=String.fromCharCode((15&o)<<12|(63&l)<<6|(63&h)<<0)}}return f};function zp(){return Js||self.TextDecoder===void 0||(Js=new self.TextDecoder("utf-8")),Js}var yr=function(d){for(var s="",t=0;t<d.length;t++){var r=d[t].toString(16);r.length<2&&(r="0"+r),s+=r}return s},In=Math.pow(2,32)-1,qp=[].push,mu={video:1,audio:2,id3:3,text:4};function yt(d){return String.fromCharCode.apply(null,d)}function vu(d,s){var t=d[s]<<8|d[s+1];return t<0?65536+t:t}function Re(d,s){var t=Au(d,s);return t<0?4294967296+t:t}function Au(d,s){return d[s]<<24|d[s+1]<<16|d[s+2]<<8|d[s+3]}function js(d,s,t){d[s]=t>>24,d[s+1]=t>>16&255,d[s+2]=t>>8&255,d[s+3]=255&t}function Ye(d,s){var t=[];if(!s.length)return t;for(var r=d.byteLength,a=0;a<r;){var o=Re(d,a),l=o>1?a+o:r;if(yt(d.subarray(a+4,a+8))===s[0])if(s.length===1)t.push(d.subarray(a+8,l));else{var h=Ye(d.subarray(a+8,l),s.slice(1));h.length&&qp.apply(t,h)}a=l}return t}function Vp(d){var s=[],t=d[0],r=8,a=Re(d,r);r+=4,r+=t===0?8:16,r+=2;var o=d.length+0,l=vu(d,r);r+=2;for(var h=0;h<l;h++){var u=r,f=Re(d,u);u+=4;var p=2147483647&f;if((2147483648&f)>>>31==1)return G.warn("SIDX has hierarchical references (not supported)"),null;var v=Re(d,u);u+=4,s.push({referenceSize:p,subsegmentDuration:v,info:{duration:v/a,start:o,end:o+p-1}}),o+=p,r=u+=4}return{earliestPresentationTime:0,timescale:a,version:t,referencesCount:l,references:s}}function bu(d){for(var s=[],t=Ye(d,["moov","trak"]),r=0;r<t.length;r++){var a=t[r],o=Ye(a,["tkhd"])[0];if(o){var l=o[0],h=l===0?12:20,u=Re(o,h),f=Ye(a,["mdia","mdhd"])[0];if(f){var p=Re(f,h=(l=f[0])===0?12:20),v=Ye(a,["mdia","hdlr"])[0];if(v){var w=yt(v.subarray(8,12)),C={soun:ot,vide:bt}[w];if(C){var k=Ye(a,["mdia","minf","stbl","stsd"])[0],I=void 0;k&&(I=yt(k.subarray(12,16))),s[u]={timescale:p,type:C},s[C]={timescale:p,id:u,codec:I}}}}}}return Ye(d,["moov","mvex","trex"]).forEach(function(D){var B=s[Re(D,4)];B&&(B.default={duration:Re(D,12),flags:Re(D,20)})}),s}function yu(d){var s=Ye(d,["schm"])[0];if(s){var t=yt(s.subarray(4,8));if(t==="cbcs"||t==="cenc")return Ye(d,["schi","tenc"])[0]}return G.error("[eme] missing 'schm' box"),null}function Wp(d){var s=Re(d,0),t=8;1&s&&(t+=4),4&s&&(t+=4);for(var r=0,a=Re(d,4),o=0;o<a;o++)256&s&&(r+=Re(d,t),t+=4),512&s&&(t+=4),1024&s&&(t+=4),2048&s&&(t+=4);return r}function ni(d,s){var t=new Uint8Array(d.length+s.length);return t.set(d),t.set(s,d.length),t}function wu(d,s){var t=[],r=s.samples,a=s.timescale,o=s.id,l=!1;return Ye(r,["moof"]).map(function(h){var u=h.byteOffset-8;Ye(h,["traf"]).map(function(f){var p=Ye(f,["tfdt"]).map(function(v){var w=v[0],C=Re(v,4);return w===1&&(C*=Math.pow(2,32),C+=Re(v,8)),C/a})[0];return p!==void 0&&(d=p),Ye(f,["tfhd"]).map(function(v){var w=Re(v,4),C=16777215&Re(v,0),k=0,I=(16&C)!=0,D=0,B=(32&C)!=0,T=8;w===o&&((1&C)!=0&&(T+=8),(2&C)!=0&&(T+=4),(8&C)!=0&&(k=Re(v,T),T+=4),I&&(D=Re(v,T),T+=4),B&&(T+=4),s.type==="video"&&(l=(function(U){if(!U)return!1;var M=U.indexOf("."),H=M<0?U:U.substring(0,M);return H==="hvc1"||H==="hev1"||H==="dvh1"||H==="dvhe"})(s.codec)),Ye(f,["trun"]).map(function(U){var M=U[0],H=16777215&Re(U,0),V=(1&H)!=0,W=0,$=(4&H)!=0,J=(256&H)!=0,j=0,le=(512&H)!=0,ie=0,me=(1024&H)!=0,we=(2048&H)!=0,ve=0,Ae=Re(U,4),Ie=8;V&&(W=Re(U,Ie),Ie+=4),$&&(Ie+=4);for(var fe=W+u,Pe=0;Pe<Ae;Pe++){if(J?(j=Re(U,Ie),Ie+=4):j=k,le?(ie=Re(U,Ie),Ie+=4):ie=D,me&&(Ie+=4),we&&(ve=M===0?Re(U,Ie):Au(U,Ie),Ie+=4),s.type===bt)for(var Ue=0;Ue<ie;){var ze=Re(r,fe);Xp(l,r[fe+=4])&&Cu(r.subarray(fe,fe+ze),l?2:1,d+ve/a,t),fe+=ze,Ue+=ze+4}d+=j/a}}))})})}),t}function Xp(d,s){if(d){var t=s>>1&63;return t===39||t===40}return(31&s)==6}function Cu(d,s,t,r){var a=Eu(d),o=0;o+=s;for(var l=0,h=0,u=!1,f=0;o<a.length;){l=0;do{if(o>=a.length)break;l+=f=a[o++]}while(f===255);h=0;do{if(o>=a.length)break;h+=f=a[o++]}while(f===255);var p=a.length-o;if(!u&&l===4&&o<a.length){if(u=!0,a[o++]===181){var v=vu(a,o);if(o+=2,v===49){var w=Re(a,o);if(o+=4,w===1195456820){var C=a[o++];if(C===3){var k=a[o++],I=64&k,D=I?2+3*(31&k):0,B=new Uint8Array(D);if(I){B[0]=k;for(var T=1;T<D;T++)B[T]=a[o++]}r.push({type:C,payloadType:l,pts:t,bytes:B})}}}}}else if(l===5&&h<p){if(u=!0,h>16){for(var U=[],M=0;M<16;M++){var H=a[o++].toString(16);U.push(H.length==1?"0"+H:H),M!==3&&M!==5&&M!==7&&M!==9||U.push("-")}for(var V=h-16,W=new Uint8Array(V),$=0;$<V;$++)W[$]=a[o++];r.push({payloadType:l,pts:t,uuid:U.join(""),userData:br(W),userDataBytes:W})}}else if(h<p)o+=h;else if(h>p)break}}function Eu(d){for(var s=d.byteLength,t=[],r=1;r<s-2;)d[r]===0&&d[r+1]===0&&d[r+2]===3?(t.push(r+2),r+=2):r++;if(t.length===0)return d;var a=s-t.length,o=new Uint8Array(a),l=0;for(r=0;r<a;l++,r++)l===t[0]&&(l++,t.shift()),o[r]=d[l];return o}function Jp(d,s,t){if(d.byteLength!==16)throw new RangeError("Invalid system id");var r,a,o;if(s){r=1,a=new Uint8Array(16*s.length);for(var l=0;l<s.length;l++){var h=s[l];if(h.byteLength!==16)throw new RangeError("Invalid key");a.set(h,16*l)}}else r=0,a=new Uint8Array;r>0?(o=new Uint8Array(4),s.length>0&&new DataView(o.buffer).setUint32(0,s.length,!1)):o=new Uint8Array;var u=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(u.buffer).setUint32(0,t.byteLength,!1),(function(f){for(var p=arguments.length,v=new Array(p>1?p-1:0),w=1;w<p;w++)v[w-1]=arguments[w];for(var C=v.length,k=8,I=C;I--;)k+=v[I].byteLength;var D=new Uint8Array(k);for(D[0]=k>>24&255,D[1]=k>>16&255,D[2]=k>>8&255,D[3]=255&k,D.set(f,4),I=0,k=8;I<C;I++)D.set(v[I],k),k+=v[I].byteLength;return D})([112,115,115,104],new Uint8Array([r,0,0,0]),d,o,a,u,t||new Uint8Array)}var Sn={},Zs=(function(){function d(t,r,a,o,l){o===void 0&&(o=[1]),l===void 0&&(l=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=r,this.keyFormat=a,this.keyFormatVersions=o,this.iv=l,this.encrypted=!!t&&t!=="NONE",this.isCommonEncryption=this.encrypted&&t!=="AES-128"}d.clearKeyUriToKeyIdMap=function(){Sn={}};var s=d.prototype;return s.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Lr:case Mr:case qt:case Vr:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},s.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof t!="number"&&(this.method!=="AES-128"||this.iv||G.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0);var r=(function(D){for(var B=new Uint8Array(16),T=12;T<16;T++)B[T]=D>>8*(15-T)&255;return B})(t);return new d(this.method,this.uri,"identity",this.keyFormatVersions,r)}var a=fa(this.uri);if(a)switch(this.keyFormat){case Mr:this.pssh=a,a.length>=22&&(this.keyId=a.subarray(a.length-22,a.length-6));break;case qt:var o=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Jp(o,null,a);var l=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/2),h=String.fromCharCode.apply(null,Array.from(l)),u=h.substring(h.indexOf("<"),h.length),f=new DOMParser().parseFromString(u,"text/xml").getElementsByTagName("KID")[0];if(f){var p=f.childNodes[0]?f.childNodes[0].nodeValue:f.getAttribute("VALUE");if(p){var v=ii(p).subarray(0,16);(function(D){var B=function(T,U,M){var H=T[U];T[U]=T[M],T[M]=H};B(D,0,3),B(D,1,2),B(D,4,5),B(D,6,7)})(v),this.keyId=v}}break;default:var w=a.subarray(0,16);if(w.length!==16){var C=new Uint8Array(16);C.set(w,16-w.length),w=C}this.keyId=w}if(!this.keyId||this.keyId.byteLength!==16){var k=Sn[this.uri];if(!k){var I=Object.keys(Sn).length%Number.MAX_SAFE_INTEGER;k=new Uint8Array(16),new DataView(k.buffer,12,4).setUint32(0,I),Sn[this.uri]=k}this.keyId=k}return this},d})(),ku=/\{\$([a-zA-Z0-9-_]+)\}/g;function Bu(d){return ku.test(d)}function Rt(d,s,t){if(d.variableList!==null||d.hasVariableRefs)for(var r=t.length;r--;){var a=t[r],o=s[a];o&&(s[a]=$s(d,o))}}function $s(d,s){if(d.variableList!==null||d.hasVariableRefs){var t=d.variableList;return s.replace(ku,function(r){var a=r.substring(2,r.length-1),o=t?.[a];return o===void 0?(d.playlistParsingError||(d.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'+a+'"')),r):o})}return s}function Iu(d,s,t){var r,a,o=d.variableList;if(o||(d.variableList=o={}),"QUERYPARAM"in s){r=s.QUERYPARAM;try{var l=new self.URL(t).searchParams;if(!l.has(r))throw new Error('"'+r+'" does not match any query parameter in URI: "'+t+'"');a=l.get(r)}catch(h){d.playlistParsingError||(d.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+h.message))}}else r=s.NAME,a=s.VALUE;r in o?d.playlistParsingError||(d.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'+r+'"')):o[r]=a||""}function _p(d,s,t){var r=s.IMPORT;if(t&&r in t){var a=d.variableList;a||(d.variableList=a={}),a[r]=t[r]}else d.playlistParsingError||(d.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+r+'"'))}function xn(){if(typeof self<"u")return self.MediaSource||self.WebKitMediaSource}var jp={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},Su=xn();function el(d,s){var t;return(t=Su?.isTypeSupported((s||"video")+'/mp4;codecs="'+d+'"'))!=null&&t}var xu=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Tu=/#EXT-X-MEDIA:(.*)/g,Zp=/^#EXT(?:INF|-X-TARGETDURATION):/m,Du=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),$p=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),pa=(function(){function d(){}return d.findGroup=function(s,t){for(var r=0;r<s.length;r++){var a=s[r];if(a.id===t)return a}},d.convertAVC1ToAVCOTI=function(s){var t=s.split(".");if(t.length>2){var r=t.shift()+".";return r+=parseInt(t.shift()).toString(16),r+=("000"+parseInt(t.shift()).toString(16)).slice(-4)}return s},d.resolve=function(s,t){return Ge.buildAbsoluteURL(t,s,{alwaysNormalize:!0})},d.isMediaPlaylist=function(s){return Zp.test(s)},d.parseMasterPlaylist=function(s,t){var r,a={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Bu(s)},o=[];for(xu.lastIndex=0;(r=xu.exec(s))!=null;)if(r[1]){var l,h=new Ke(r[1]);Rt(a,h,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var u=$s(a,r[2]),f={attrs:h,bitrate:h.decimalInteger("AVERAGE-BANDWIDTH")||h.decimalInteger("BANDWIDTH"),name:h.NAME,url:d.resolve(u,t)},p=h.decimalResolution("RESOLUTION");p&&(f.width=p.width,f.height=p.height),em((h.CODECS||"").split(/[ ,]+/).filter(function(T){return T}),f),f.videoCodec&&f.videoCodec.indexOf("avc1")!==-1&&(f.videoCodec=d.convertAVC1ToAVCOTI(f.videoCodec)),(l=f.unknownCodecs)!=null&&l.length||o.push(f),a.levels.push(f)}else if(r[3]){var v=r[3],w=r[4];switch(v){case"SESSION-DATA":var C=new Ke(w);Rt(a,C,["DATA-ID","LANGUAGE","VALUE","URI"]);var k=C["DATA-ID"];k&&(a.sessionData===null&&(a.sessionData={}),a.sessionData[k]=C);break;case"SESSION-KEY":var I=Ru(w,t,a);I.encrypted&&I.isSupported()?(a.sessionKeys===null&&(a.sessionKeys=[]),a.sessionKeys.push(I)):G.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+w+'"');break;case"DEFINE":var D=new Ke(w);Rt(a,D,["NAME","VALUE","QUERYPARAM"]),Iu(a,D,t);break;case"CONTENT-STEERING":var B=new Ke(w);Rt(a,B,["SERVER-URI","PATHWAY-ID"]),a.contentSteering={uri:d.resolve(B["SERVER-URI"],t),pathwayId:B["PATHWAY-ID"]||"."};break;case"START":a.startTimeOffset=Lu(w)}}return a.levels=o.length>0&&o.length<a.levels.length?o:a.levels,a.levels.length===0&&(a.playlistParsingError=new Error("no levels found in manifest")),a},d.parseMasterPlaylistMedia=function(s,t,r){var a,o={},l=r.levels,h={AUDIO:l.map(function(I){return{id:I.attrs.AUDIO,audioCodec:I.audioCodec}}),SUBTITLES:l.map(function(I){return{id:I.attrs.SUBTITLES,textCodec:I.textCodec}}),"CLOSED-CAPTIONS":[]},u=0;for(Tu.lastIndex=0;(a=Tu.exec(s))!==null;){var f=new Ke(a[1]),p=f.TYPE;if(p){var v=h[p],w=o[p]||[];o[p]=w,Rt(r,f,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var C={attrs:f,bitrate:0,id:u++,groupId:f["GROUP-ID"]||"",instreamId:f["INSTREAM-ID"],name:f.NAME||f.LANGUAGE||"",type:p,default:f.bool("DEFAULT"),autoselect:f.bool("AUTOSELECT"),forced:f.bool("FORCED"),lang:f.LANGUAGE,url:f.URI?d.resolve(f.URI,t):""};if(v!=null&&v.length){var k=d.findGroup(v,C.groupId)||v[0];Mu(C,k,"audioCodec"),Mu(C,k,"textCodec")}w.push(C)}}return o},d.parseLevelPlaylist=function(s,t,r,a,o,l){var h,u,f,p=new ga(t),v=p.fragments,w=null,C=0,k=0,I=0,D=0,B=null,T=new Ar(a,t),U=-1,M=!1;for(Du.lastIndex=0,p.m3u8=s,p.hasVariableRefs=Bu(s);(h=Du.exec(s))!==null;){M&&(M=!1,(T=new Ar(a,t)).start=I,T.sn=C,T.cc=D,T.level=r,w&&(T.initSegment=w,T.rawProgramDateTime=w.rawProgramDateTime,w.rawProgramDateTime=null));var H=h[1];if(H){T.duration=parseFloat(H);var V=(" "+h[2]).slice(1);T.title=V||null,T.tagList.push(V?["INF",H,V]:["INF",H])}else if(h[3]){if(se(T.duration)){T.start=I,f&&Pu(T,f,p),T.sn=C,T.level=r,T.cc=D,T.urlId=o,v.push(T);var W=(" "+h[3]).slice(1);T.relurl=$s(p,W),Fu(T,B),B=T,I+=T.duration,C++,k=0,M=!0}}else if(h[4]){var $=(" "+h[4]).slice(1);B?T.setByteRange($,B):T.setByteRange($)}else if(h[5])T.rawProgramDateTime=(" "+h[5]).slice(1),T.tagList.push(["PROGRAM-DATE-TIME",T.rawProgramDateTime]),U===-1&&(U=v.length);else{if(!(h=h[0].match($p))){G.warn("No matches on slow regex match for level playlist!");continue}for(u=1;u<h.length&&h[u]===void 0;u++);var J=(" "+h[u]).slice(1),j=(" "+h[u+1]).slice(1),le=h[u+2]?(" "+h[u+2]).slice(1):"";switch(J){case"PLAYLIST-TYPE":p.type=j.toUpperCase();break;case"MEDIA-SEQUENCE":C=p.startSN=parseInt(j);break;case"SKIP":var ie=new Ke(j);Rt(p,ie,["RECENTLY-REMOVED-DATERANGES"]);var me=ie.decimalInteger("SKIPPED-SEGMENTS");if(se(me)){p.skippedSegments=me;for(var we=me;we--;)v.unshift(null);C+=me}var ve=ie.enumeratedString("RECENTLY-REMOVED-DATERANGES");ve&&(p.recentlyRemovedDateranges=ve.split(" "));break;case"TARGETDURATION":p.targetduration=Math.max(parseInt(j),1);break;case"VERSION":p.version=parseInt(j);break;case"EXTM3U":break;case"ENDLIST":p.live=!1;break;case"#":(j||le)&&T.tagList.push(le?[j,le]:[j]);break;case"DISCONTINUITY":D++,T.tagList.push(["DIS"]);break;case"GAP":T.gap=!0,T.tagList.push([J]);break;case"BITRATE":T.tagList.push([J,j]);break;case"DATERANGE":var Ae=new Ke(j);Rt(p,Ae,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Rt(p,Ae,Ae.clientAttrs);var Ie=new mr(Ae,p.dateRanges[Ae.ID]);Ie.isValid||p.skippedSegments?p.dateRanges[Ie.id]=Ie:G.warn('Ignoring invalid DATERANGE tag: "'+j+'"'),T.tagList.push(["EXT-X-DATERANGE",j]);break;case"DEFINE":var fe=new Ke(j);Rt(p,fe,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in fe?_p(p,fe,l):Iu(p,fe,t);break;case"DISCONTINUITY-SEQUENCE":D=parseInt(j);break;case"KEY":var Pe=Ru(j,t,p);if(Pe.isSupported()){if(Pe.method==="NONE"){f=void 0;break}f||(f={}),f[Pe.keyFormat]&&(f=Y({},f)),f[Pe.keyFormat]=Pe}else G.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+j+'"');break;case"START":p.startTimeOffset=Lu(j);break;case"MAP":var Ue=new Ke(j);if(Rt(p,Ue,["BYTERANGE","URI"]),T.duration){var ze=new Ar(a,t);Ou(ze,Ue,r,f),w=ze,T.initSegment=w,w.rawProgramDateTime&&!T.rawProgramDateTime&&(T.rawProgramDateTime=w.rawProgramDateTime)}else Ou(T,Ue,r,f),w=T,M=!0;break;case"SERVER-CONTROL":var je=new Ke(j);p.canBlockReload=je.bool("CAN-BLOCK-RELOAD"),p.canSkipUntil=je.optionalFloat("CAN-SKIP-UNTIL",0),p.canSkipDateRanges=p.canSkipUntil>0&&je.bool("CAN-SKIP-DATERANGES"),p.partHoldBack=je.optionalFloat("PART-HOLD-BACK",0),p.holdBack=je.optionalFloat("HOLD-BACK",0);break;case"PART-INF":p.partTarget=new Ke(j).decimalFloatingPoint("PART-TARGET");break;case"PART":var mt=p.partList;mt||(mt=p.partList=[]);var Tt=k>0?mt[mt.length-1]:void 0,ir=k++,Ht=new Ke(j);Rt(p,Ht,["BYTERANGE","URI"]);var Jt=new zr(Ht,T,t,ir,Tt);mt.push(Jt),T.duration+=Jt.duration;break;case"PRELOAD-HINT":var pt=new Ke(j);Rt(p,pt,["URI"]),p.preloadHint=pt;break;case"RENDITION-REPORT":var Ct=new Ke(j);Rt(p,Ct,["URI"]),p.renditionReports=p.renditionReports||[],p.renditionReports.push(Ct);break;default:G.warn("line parsed but not handled: "+h)}}}B&&!B.relurl?(v.pop(),I-=B.duration,p.partList&&(p.fragmentHint=B)):p.partList&&(Fu(T,B),T.cc=D,p.fragmentHint=T,f&&Pu(T,f,p));var ar=v.length,hi=v[0],Mt=v[ar-1];if((I+=p.skippedSegments*p.targetduration)>0&&ar&&Mt){p.averagetargetduration=I/ar;var Vn=Mt.sn;p.endSN=Vn!=="initSegment"?Vn:0,p.live||(Mt.endList=!0),hi&&(p.startCC=hi.cc)}else p.endSN=0,p.startCC=0;return p.fragmentHint&&(I+=p.fragmentHint.duration),p.totalduration=I,p.endCC=D,U>0&&(function(Sa,Wn){for(var Pi=Sa[Wn],ui=Wn;ui--;){var gi=Sa[ui];if(!gi)return;gi.programDateTime=Pi.programDateTime-1e3*gi.duration,Pi=gi}})(v,U),p},d})();function Ru(d,s,t){var r,a,o=new Ke(d);Rt(t,o,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var l=(r=o.METHOD)!=null?r:"",h=o.URI,u=o.hexadecimalInteger("IV"),f=o.KEYFORMATVERSIONS,p=(a=o.KEYFORMAT)!=null?a:"identity";return h&&o.IV&&!u&&G.error("Invalid IV: "+o.IV),new Zs(l,h?pa.resolve(h,s):"",p,(f||"1").split("/").map(Number).filter(Number.isFinite),u)}function Lu(d){var s=new Ke(d).decimalFloatingPoint("TIME-OFFSET");return se(s)?s:null}function em(d,s){["video","audio","text"].forEach(function(t){var r=d.filter(function(o){return(function(l,h){var u=jp[h];return!!u&&u[l.slice(0,4)]===!0})(o,t)});if(r.length){var a=r.filter(function(o){return o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0});s[t+"Codec"]=a.length>0?a[0]:r[0],d=d.filter(function(o){return r.indexOf(o)===-1})}}),s.unknownCodecs=d}function Mu(d,s,t){var r=s[t];r&&(d[t]=r)}function Fu(d,s){d.rawProgramDateTime?d.programDateTime=Date.parse(d.rawProgramDateTime):s!=null&&s.programDateTime&&(d.programDateTime=s.endProgramDateTime),se(d.programDateTime)||(d.programDateTime=null,d.rawProgramDateTime=null)}function Ou(d,s,t,r){d.relurl=s.URI,s.BYTERANGE&&d.setByteRange(s.BYTERANGE),d.level=t,d.sn="initSegment",r&&(d.levelkeys=r),d.initSegment=null}function Pu(d,s,t){d.levelkeys=s;var r=t.encryptedFragments;r.length&&r[r.length-1].levelkeys===s||!Object.keys(s).some(function(a){return s[a].isCommonEncryption})||r.push(d)}var Bi="manifest",oi="level",wr="audioTrack",Fr="subtitleTrack",Je="main",Cr="audio",Wr="subtitle";function Uu(d){switch(d.type){case wr:return Cr;case Fr:return Wr;default:return Je}}function tl(d,s){var t=d.url;return t!==void 0&&t.indexOf("data:")!==0||(t=s.url),t}var tm=(function(){function d(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}var s=d.prototype;return s.startLoad=function(t){},s.stopLoad=function(){this.destroyInternalLoaders()},s.registerListeners=function(){var t=this.hls;t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.LEVEL_LOADING,this.onLevelLoading,this),t.on(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},s.unregisterListeners=function(){var t=this.hls;t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.LEVEL_LOADING,this.onLevelLoading,this),t.off(x.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(x.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},s.createInternalLoader=function(t){var r=this.hls.config,a=r.pLoader,o=r.loader,l=new(a||o)(r);return this.loaders[t.type]=l,l},s.getInternalLoader=function(t){return this.loaders[t.type]},s.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},s.destroyInternalLoaders=function(){for(var t in this.loaders){var r=this.loaders[t];r&&r.destroy(),this.resetInternalLoader(t)}},s.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},s.onManifestLoading=function(t,r){var a=r.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Bi,url:a,deliveryDirectives:null})},s.onLevelLoading=function(t,r){var a=r.id,o=r.level,l=r.url,h=r.deliveryDirectives;this.load({id:a,level:o,responseType:"text",type:oi,url:l,deliveryDirectives:h})},s.onAudioTrackLoading=function(t,r){var a=r.id,o=r.groupId,l=r.url,h=r.deliveryDirectives;this.load({id:a,groupId:o,level:null,responseType:"text",type:wr,url:l,deliveryDirectives:h})},s.onSubtitleTrackLoading=function(t,r){var a=r.id,o=r.groupId,l=r.url,h=r.deliveryDirectives;this.load({id:a,groupId:o,level:null,responseType:"text",type:Fr,url:l,deliveryDirectives:h})},s.load=function(t){var r,a,o,l=this,h=this.hls.config,u=this.getInternalLoader(t);if(u){var f=u.context;if(f&&f.url===t.url)return void G.trace("[playlist-loader]: playlist request ongoing");G.log("[playlist-loader]: aborting previous loader for type: "+t.type),u.abort()}if(a=t.type===Bi?h.manifestLoadPolicy.default:Y({},h.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),u=this.createInternalLoader(t),(r=t.deliveryDirectives)!=null&&r.part&&(t.type===oi&&t.level!==null?o=this.hls.levels[t.level].details:t.type===wr&&t.id!==null?o=this.hls.audioTracks[t.id].details:t.type===Fr&&t.id!==null&&(o=this.hls.subtitleTracks[t.id].details),o)){var p=o.partTarget,v=o.targetduration;if(p&&v){var w=1e3*Math.max(3*p,.8*v);a=Y({},a,{maxTimeToFirstByteMs:Math.min(w,a.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(w,a.maxTimeToFirstByteMs)})}}var C=a.errorRetry||a.timeoutRetry||{},k={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:C.maxNumRetry||0,retryDelay:C.retryDelayMs||0,maxRetryDelay:C.maxRetryDelayMs||0};u.load(t,k,{onSuccess:function(I,D,B,T){var U=l.getInternalLoader(B);l.resetInternalLoader(B.type);var M=I.data;M.indexOf("#EXTM3U")===0?(D.parsing.start=performance.now(),pa.isMediaPlaylist(M)?l.handleTrackOrLevelPlaylist(I,D,B,T||null,U):l.handleMasterPlaylist(I,D,B,T)):l.handleManifestParsingError(I,B,new Error("no EXTM3U delimiter"),T||null,D)},onError:function(I,D,B,T){l.handleNetworkError(D,B,!1,I,T)},onTimeout:function(I,D,B){l.handleNetworkError(D,B,!0,void 0,I)}})},s.handleMasterPlaylist=function(t,r,a,o){var l=this.hls,h=t.data,u=tl(t,a),f=pa.parseMasterPlaylist(h,u);if(f.playlistParsingError)this.handleManifestParsingError(t,a,f.playlistParsingError,o,r);else{var p=f.contentSteering,v=f.levels,w=f.sessionData,C=f.sessionKeys,k=f.startTimeOffset,I=f.variableList;this.variableList=I;var D=pa.parseMasterPlaylistMedia(h,u,f),B=D.AUDIO,T=B===void 0?[]:B,U=D.SUBTITLES,M=D["CLOSED-CAPTIONS"];T.length&&(T.some(function(H){return!H.url})||!v[0].audioCodec||v[0].attrs.AUDIO||(G.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),T.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Ke({}),bitrate:0,url:""}))),l.trigger(x.MANIFEST_LOADED,{levels:v,audioTracks:T,subtitles:U,captions:M,contentSteering:p,url:u,stats:r,networkDetails:o,sessionData:w,sessionKeys:C,startTimeOffset:k,variableList:I})}},s.handleTrackOrLevelPlaylist=function(t,r,a,o,l){var h=this.hls,u=a.id,f=a.level,p=a.type,v=tl(t,a),w=se(u)?u:0,C=se(f)?f:w,k=Uu(a),I=pa.parseLevelPlaylist(t.data,v,C,k,w,this.variableList);if(p===Bi){var D={attrs:new Ke({}),bitrate:0,details:I,name:"",url:v};h.trigger(x.MANIFEST_LOADED,{levels:[D],audioTracks:[],url:v,stats:r,networkDetails:o,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}r.parsing.end=performance.now(),a.levelDetails=I,this.handlePlaylistLoaded(I,t,r,a,o,l)},s.handleManifestParsingError=function(t,r,a,o,l){this.hls.trigger(x.ERROR,{type:ue.NETWORK_ERROR,details:q.MANIFEST_PARSING_ERROR,fatal:r.type===Bi,url:t.url,err:a,error:a,reason:a.message,response:t,context:r,networkDetails:o,stats:l})},s.handleNetworkError=function(t,r,a,o,l){a===void 0&&(a=!1);var h="A network "+(a?"timeout":"error"+(o?" (status "+o.code+")":""))+" occurred while loading "+t.type;t.type===oi?h+=": "+t.level+" id: "+t.id:t.type!==wr&&t.type!==Fr||(h+=" id: "+t.id+' group-id: "'+t.groupId+'"');var u=new Error(h);G.warn("[playlist-loader]: "+h);var f=q.UNKNOWN,p=!1,v=this.getInternalLoader(t);switch(t.type){case Bi:f=a?q.MANIFEST_LOAD_TIMEOUT:q.MANIFEST_LOAD_ERROR,p=!0;break;case oi:f=a?q.LEVEL_LOAD_TIMEOUT:q.LEVEL_LOAD_ERROR,p=!1;break;case wr:f=a?q.AUDIO_TRACK_LOAD_TIMEOUT:q.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case Fr:f=a?q.SUBTITLE_TRACK_LOAD_TIMEOUT:q.SUBTITLE_LOAD_ERROR,p=!1}v&&this.resetInternalLoader(t.type);var w={type:ue.NETWORK_ERROR,details:f,fatal:p,url:t.url,loader:v,context:t,error:u,networkDetails:r,stats:l};o&&(w.response=E({url:r?.url||t.url,data:void 0},o)),this.hls.trigger(x.ERROR,w)},s.handlePlaylistLoaded=function(t,r,a,o,l,h){var u=this.hls,f=o.type,p=o.level,v=o.id,w=o.groupId,C=o.deliveryDirectives,k=tl(r,o),I=Uu(o),D=typeof o.level=="number"&&I===Je?p:void 0;if(t.fragments.length){t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));var B=t.playlistParsingError;if(B)u.trigger(x.ERROR,{type:ue.NETWORK_ERROR,details:q.LEVEL_PARSING_ERROR,fatal:!1,url:k,error:B,reason:B.message,response:r,context:o,level:D,parent:I,networkDetails:l,stats:a});else switch(t.live&&h&&(h.getCacheAge&&(t.ageHeader=h.getCacheAge()||0),h.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),f){case Bi:case oi:u.trigger(x.LEVEL_LOADED,{details:t,level:D||0,id:v||0,stats:a,networkDetails:l,deliveryDirectives:C});break;case wr:u.trigger(x.AUDIO_TRACK_LOADED,{details:t,id:v||0,groupId:w||"",stats:a,networkDetails:l,deliveryDirectives:C});break;case Fr:u.trigger(x.SUBTITLE_TRACK_LOADED,{details:t,id:v||0,groupId:w||"",stats:a,networkDetails:l,deliveryDirectives:C})}}else{var T=new Error("No Segments found in Playlist");u.trigger(x.ERROR,{type:ue.NETWORK_ERROR,details:q.LEVEL_EMPTY_ERROR,fatal:!1,url:k,error:T,reason:T.message,response:r,context:o,level:D,parent:I,networkDetails:l,stats:a})}},d})();function Qu(d,s){var t;try{t=new Event("addtrack")}catch{(t=document.createEvent("Event")).initEvent("addtrack",!1,!1)}t.track=d,s.dispatchEvent(t)}function Nu(d,s){var t=d.mode;if(t==="disabled"&&(d.mode="hidden"),d.cues&&!d.cues.getCueById(s.id))try{if(d.addCue(s),!d.cues.getCueById(s.id))throw new Error("addCue is failed for: "+s)}catch(a){G.debug("[texttrack-utils]: "+a);try{var r=new self.TextTrackCue(s.startTime,s.endTime,s.text);r.id=s.id,d.addCue(r)}catch(o){G.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+o)}}t==="disabled"&&(d.mode=t)}function Ii(d){var s=d.mode;if(s==="disabled"&&(d.mode="hidden"),d.cues)for(var t=d.cues.length;t--;)d.removeCue(d.cues[t]);s==="disabled"&&(d.mode=s)}function rl(d,s,t,r){var a=d.mode;if(a==="disabled"&&(d.mode="hidden"),d.cues&&d.cues.length>0)for(var o=(function(h,u,f){var p=[],v=(function(I,D){if(D<I[0].startTime)return 0;var B=I.length-1;if(D>I[B].endTime)return-1;for(var T=0,U=B;T<=U;){var M=Math.floor((U+T)/2);if(D<I[M].startTime)U=M-1;else{if(!(D>I[M].startTime&&T<B))return M;T=M+1}}return I[T].startTime-D<D-I[U].startTime?T:U})(h,u);if(v>-1)for(var w=v,C=h.length;w<C;w++){var k=h[w];if(k.startTime>=u&&k.endTime<=f)p.push(k);else if(k.startTime>f)return p}return p})(d.cues,s,t),l=0;l<o.length;l++)r&&!r(o[l])||d.removeCue(o[l]);a==="disabled"&&(d.mode=a)}var ma="org.id3",rm="com.apple.quicktime.HLS",va="https://aomedia.org/emsg/ID3";function il(){if(typeof self<"u")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var Tn=(function(){var d=il();try{new d(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function al(d,s){return d.getTime()/1e3-s}var im=(function(){function d(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}var s=d.prototype;return s.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},s._registerListeners=function(){var t=this.hls;t.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(x.LEVEL_UPDATED,this.onLevelUpdated,this)},s._unregisterListeners=function(){var t=this.hls;t.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(x.LEVEL_UPDATED,this.onLevelUpdated,this)},s.onMediaAttached=function(t,r){this.media=r.media},s.onMediaDetaching=function(){this.id3Track&&(Ii(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},s.onManifestLoading=function(){this.dateRangeCuesAppended={}},s.createTrack=function(t){var r=this.getID3Track(t.textTracks);return r.mode="hidden",r},s.getID3Track=function(t){if(this.media){for(var r=0;r<t.length;r++){var a=t[r];if(a.kind==="metadata"&&a.label==="id3")return Qu(a,this.media),a}return this.media.addTextTrack("metadata","id3")}},s.onFragParsingMetadata=function(t,r){if(this.media){var a=this.hls.config,o=a.enableEmsgMetadataCues,l=a.enableID3MetadataCues;if(o||l){var h=r.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var u=il(),f=0;f<h.length;f++){var p=h[f].type;if((p!==va||o)&&l){var v=pu(h[f].data);if(v){var w=h[f].pts,C=w+h[f].duration;C>Tn&&(C=Tn),C-w<=0&&(C=w+.25);for(var k=0;k<v.length;k++){var I=v[k];if(!fu(I)){this.updateId3CueEnds(w,p);var D=new u(w,C,"");D.value=I,p&&(D.type=p),this.id3Track.addCue(D)}}}}}}}},s.updateId3CueEnds=function(t,r){var a,o=(a=this.id3Track)==null?void 0:a.cues;if(o)for(var l=o.length;l--;){var h=o[l];h.type===r&&h.startTime<t&&h.endTime===Tn&&(h.endTime=t)}},s.onBufferFlushing=function(t,r){var a=r.startOffset,o=r.endOffset,l=r.type,h=this.id3Track,u=this.hls;if(u){var f=u.config,p=f.enableEmsgMetadataCues,v=f.enableID3MetadataCues;h&&(p||v)&&rl(h,a,o,l==="audio"?function(w){return w.type===ma&&v}:l==="video"?function(w){return w.type===va&&p}:function(w){return w.type===ma&&v||w.type===va&&p})}},s.onLevelUpdated=function(t,r){var a=this,o=r.details;if(this.media&&o.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var l=this.dateRangeCuesAppended,h=this.id3Track,u=o.dateRanges,f=Object.keys(u);if(h)for(var p=Object.keys(l).filter(function(T){return!f.includes(T)}),v=function(){var T=p[w];Object.keys(l[T].cues).forEach(function(U){h.removeCue(l[T].cues[U])}),delete l[T]},w=p.length;w--;)v();var C=o.fragments[o.fragments.length-1];if(f.length!==0&&se(C?.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var k=C.programDateTime/1e3-C.start,I=il(),D=function(){var T=f[B],U=u[T],M=l[T],H=M?.cues||{},V=M?.durationKnown||!1,W=al(U.startDate,k),$=Tn,J=U.endDate;if(J)$=al(J,k),V=!0;else if(U.endOnNext&&!V){var j=f.reduce(function(fe,Pe){var Ue=u[Pe];return Ue.class===U.class&&Ue.id!==Pe&&Ue.startDate>U.startDate&&fe.push(Ue),fe},[]).sort(function(fe,Pe){return fe.startDate.getTime()-Pe.startDate.getTime()})[0];j&&($=al(j.startDate,k),V=!0)}for(var le,ie,me=Object.keys(U.attr),we=0;we<me.length;we++){var ve=me[we];if((ie=ve)!=="ID"&&ie!=="CLASS"&&ie!=="START-DATE"&&ie!=="DURATION"&&ie!=="END-DATE"&&ie!=="END-ON-NEXT"){var Ae=H[ve];if(Ae)V&&!M.durationKnown&&(Ae.endTime=$);else{var Ie=U.attr[ve];Ae=new I(W,$,""),It(ve)&&(le=Ie,Ie=Uint8Array.from(le.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),Ae.value={key:ve,data:Ie},Ae.type=rm,Ae.id=T,a.id3Track.addCue(Ae),H[ve]=Ae}}}l[T]={cues:H,dateRange:U,durationKnown:V}},B=0;B<f.length;B++)D()}}},d})(),am=(function(){function d(t){var r=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return r.timeupdate()},this.hls=t,this.config=t.config,this.registerListeners()}var s=d.prototype;return s.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},s.registerListeners=function(){this.hls.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(x.ERROR,this.onError,this)},s.unregisterListeners=function(){this.hls.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(x.ERROR,this.onError,this)},s.onMediaAttached=function(t,r){this.media=r.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},s.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},s.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},s.onLevelUpdated=function(t,r){var a=r.details;this.levelDetails=a,a.advanced&&this.timeupdate(),!a.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},s.onError=function(t,r){var a;r.details===q.BUFFER_STALLED_ERROR&&(this.stallCount++,(a=this.levelDetails)!=null&&a.live&&G.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},s.timeupdate=function(){var t=this.media,r=this.levelDetails;if(t&&r){this.currentTime=t.currentTime;var a=this.computeLatency();if(a!==null){this._latency=a;var o=this.config,l=o.lowLatencyMode,h=o.maxLiveSyncPlaybackRate;if(l&&h!==1){var u=this.targetLatency;if(u!==null){var f=a-u,p=f<Math.min(this.maxLatency,u+r.targetduration);if(r.live&&p&&f>.05&&this.forwardBufferLength>1){var v=Math.min(2,Math.max(1,h)),w=Math.round(2/(1+Math.exp(-.75*f-this.edgeStalled))*20)/20;t.playbackRate=Math.min(v,Math.max(1,w))}else t.playbackRate!==1&&t.playbackRate!==0&&(t.playbackRate=1)}}}}},s.estimateLiveEdge=function(){var t=this.levelDetails;return t===null?null:t.edge+t.age},s.computeLatency=function(){var t=this.estimateLiveEdge();return t===null?null:t-this.currentTime},F(d,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config,r=this.levelDetails;return t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:r?t.liveMaxLatencyDurationCount*r.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(t===null)return null;var r=t.holdBack,a=t.partHoldBack,o=t.targetduration,l=this.config,h=l.liveSyncDuration,u=l.liveSyncDurationCount,f=l.lowLatencyMode,p=this.hls.userConfig,v=f&&a||r;(p.liveSyncDuration||p.liveSyncDurationCount||v===0)&&(v=h!==void 0?h:u*o);var w=o;return v+Math.min(1*this.stallCount,w)}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),r=this.targetLatency,a=this.levelDetails;if(t===null||r===null||a===null)return null;var o=a.edge,l=t-r-this.edgeStalled,h=o-a.totalduration,u=o-(this.config.lowLatencyMode&&a.partTarget||a.targetduration);return Math.min(Math.max(h,l),u)}},{key:"drift",get:function(){var t=this.levelDetails;return t===null?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;if(t===null)return 0;var r=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-r,0)}},{key:"forwardBufferLength",get:function(){var t=this.media,r=this.levelDetails;if(!t||!r)return 0;var a=t.buffered.length;return(a?t.buffered.end(a-1):r.edge)-this.currentTime}}]),d})(),nl=["NONE","TYPE-0","TYPE-1",null],ol="",nm="YES",om="v2",Hu=(function(){function d(s,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=s,this.part=t,this.skip=r}return d.prototype.addDirectives=function(s){var t=new self.URL(s);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},d})(),Aa=(function(){function d(s){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[s.url],this._attrs=[s.attrs],this.bitrate=s.bitrate,s.details&&(this.details=s.details),this.id=s.id||0,this.name=s.name,this.width=s.width||0,this.height=s.height||0,this.audioCodec=s.audioCodec,this.videoCodec=s.videoCodec,this.unknownCodecs=s.unknownCodecs,this.codecSet=[s.videoCodec,s.audioCodec].filter(function(t){return t}).join(",").replace(/\.[^.,]+/g,"")}return d.prototype.addFallback=function(s){this.url.push(s.url),this._attrs.push(s.attrs)},F(d,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"attrs",get:function(){return this._attrs[this._urlId]}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(s){var t=s%this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}},{key:"audioGroupId",get:function(){var s;return(s=this.audioGroupIds)==null?void 0:s[this.urlId]}},{key:"textGroupId",get:function(){var s;return(s=this.textGroupIds)==null?void 0:s[this.urlId]}}]),d})();function sl(d,s){var t=s.startPTS;if(se(t)){var r,a=0;s.sn>d.sn?(a=t-d.start,r=d):(a=d.start-t,r=s),r.duration!==a&&(r.duration=a)}else s.sn>d.sn?d.cc===s.cc&&d.minEndPTS?s.start=d.start+(d.minEndPTS-d.start):s.start=d.start+d.duration:s.start=Math.max(d.start-s.duration,0)}function Gu(d,s,t,r,a,o){r-t<=0&&(G.warn("Fragment should have a positive duration",s),r=t+s.duration,o=a+s.duration);var l=t,h=r,u=s.startPTS,f=s.endPTS;if(se(u)){var p=Math.abs(u-t);se(s.deltaPTS)?s.deltaPTS=Math.max(p,s.deltaPTS):s.deltaPTS=p,l=Math.max(t,u),t=Math.min(t,u),a=Math.min(a,s.startDTS),h=Math.min(r,f),r=Math.max(r,f),o=Math.max(o,s.endDTS)}var v=t-s.start;s.start!==0&&(s.start=t),s.duration=r-s.start,s.startPTS=t,s.maxStartPTS=l,s.startDTS=a,s.endPTS=r,s.minEndPTS=h,s.endDTS=o;var w,C=s.sn;if(!d||C<d.startSN||C>d.endSN)return 0;var k=C-d.startSN,I=d.fragments;for(I[k]=s,w=k;w>0;w--)sl(I[w],I[w-1]);for(w=k;w<I.length-1;w++)sl(I[w],I[w+1]);return d.fragmentHint&&sl(I[I.length-1],d.fragmentHint),d.PTSKnown=d.alignedSliding=!0,v}function sm(d,s){for(var t=null,r=d.fragments,a=r.length-1;a>=0;a--){var o=r[a].initSegment;if(o){t=o;break}}d.fragmentHint&&delete d.fragmentHint.endPTS;var l,h,u,f,p,v=0;if((function(B,T,U){for(var M=T.skippedSegments,H=Math.max(B.startSN,T.startSN)-T.startSN,V=(B.fragmentHint?1:0)+(M?T.endSN:Math.min(B.endSN,T.endSN))-T.startSN,W=T.startSN-B.startSN,$=T.fragmentHint?T.fragments.concat(T.fragmentHint):T.fragments,J=B.fragmentHint?B.fragments.concat(B.fragmentHint):B.fragments,j=H;j<=V;j++){var le=J[W+j],ie=$[j];M&&!ie&&j<M&&(ie=T.fragments[j]=le),le&&ie&&U(le,ie)}})(d,s,function(B,T){B.relurl&&(v=B.cc-T.cc),se(B.startPTS)&&se(B.endPTS)&&(T.start=T.startPTS=B.startPTS,T.startDTS=B.startDTS,T.maxStartPTS=B.maxStartPTS,T.endPTS=B.endPTS,T.endDTS=B.endDTS,T.minEndPTS=B.minEndPTS,T.duration=B.endPTS-B.startPTS,T.duration&&(l=T),s.PTSKnown=s.alignedSliding=!0),T.elementaryStreams=B.elementaryStreams,T.loader=B.loader,T.stats=B.stats,T.urlId=B.urlId,B.initSegment&&(T.initSegment=B.initSegment,t=B.initSegment)}),t&&(s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments).forEach(function(B){var T;B.initSegment&&B.initSegment.relurl!==((T=t)==null?void 0:T.relurl)||(B.initSegment=t)}),s.skippedSegments)if(s.deltaUpdateFailed=s.fragments.some(function(B){return!B}),s.deltaUpdateFailed){G.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var w=s.skippedSegments;w--;)s.fragments.shift();s.startSN=s.fragments[0].sn,s.startCC=s.fragments[0].cc}else s.canSkipDateRanges&&(s.dateRanges=(h=d.dateRanges,u=s.dateRanges,f=s.recentlyRemovedDateranges,p=Y({},h),f&&f.forEach(function(B){delete p[B]}),Object.keys(u).forEach(function(B){var T=new mr(u[B].attr,p[B]);T.isValid?p[B]=T:G.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(u[B].attr)+'"')}),p));var C=s.fragments;if(v){G.warn("discontinuity sliding from playlist, take drift into account");for(var k=0;k<C.length;k++)C[k].cc+=v}s.skippedSegments&&(s.startCC=s.fragments[0].cc),(function(B,T,U){if(B&&T)for(var M=0,H=0,V=B.length;H<=V;H++){var W=B[H],$=T[H+M];W&&$&&W.index===$.index&&W.fragment.sn===$.fragment.sn?U(W,$):M--}})(d.partList,s.partList,function(B,T){T.elementaryStreams=B.elementaryStreams,T.stats=B.stats}),l?Gu(s,l,l.startPTS,l.endPTS,l.startDTS,l.endDTS):Yu(d,s),C.length&&(s.totalduration=s.edge-C[0].start),s.driftStartTime=d.driftStartTime,s.driftStart=d.driftStart;var I=s.advancedDateTime;if(s.advanced&&I){var D=s.edge;s.driftStart||(s.driftStartTime=I,s.driftStart=D),s.driftEndTime=I,s.driftEnd=D}else s.driftEndTime=d.driftEndTime,s.driftEnd=d.driftEnd,s.advancedDateTime=d.advancedDateTime}function Yu(d,s){var t=s.startSN+s.skippedSegments-d.startSN,r=d.fragments;t<0||t>=r.length||ll(s,r[t].start)}function ll(d,s){if(s){for(var t=d.fragments,r=d.skippedSegments;r<t.length;r++)t[r].start+=s;d.fragmentHint&&(d.fragmentHint.start+=s)}}function Ku(d,s,t){var r;return d!=null&&d.details?zu((r=d.details)==null?void 0:r.partList,s,t):null}function zu(d,s,t){if(d)for(var r=d.length;r--;){var a=d[r];if(a.index===t&&a.fragment.sn===s)return a}return null}function Dn(d){switch(d.details){case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_TIMEOUT:case q.LEVEL_LOAD_TIMEOUT:case q.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function qu(d,s){var t=Dn(s);return d.default[(t?"timeout":"error")+"Retry"]}function cl(d,s){var t=d.backoff==="linear"?1:Math.pow(2,s);return Math.min(t*d.retryDelayMs,d.maxRetryDelayMs)}function Vu(d){return E(E({},d),{errorRetry:null,timeoutRetry:null})}function Rn(d,s,t,r){return!!d&&s<d.maxNumRetry&&((function(a){return a===0&&navigator.onLine===!1||!!a&&(a<400||a>499)})(r)||!!t)}var Wu=function(d,s){for(var t=0,r=d.length-1,a=null,o=null;t<=r;){var l=s(o=d[a=(t+r)/2|0]);if(l>0)t=a+1;else{if(!(l<0))return o;r=a-1}}return null};function ba(d,s,t,r){t===void 0&&(t=0),r===void 0&&(r=0);var a=null;if(d?a=s[d.sn-s[0].sn+1]||null:t===0&&s[0].start===0&&(a=s[0]),a&&dl(t,r,a)===0)return a;var o=Wu(s,dl.bind(null,t,r));return!o||o===d&&a?a:o}function dl(d,s,t){if(d===void 0&&(d=0),s===void 0&&(s=0),t.start<=d&&t.start+t.duration>d)return 0;var r=Math.min(s,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-r<=d?1:t.start-r>d&&t.start?-1:0}function lm(d,s,t){var r=1e3*Math.min(s,t.duration+(t.deltaPTS?t.deltaPTS:0));return(t.endProgramDateTime||0)-r>d}var hl,cm=3e5,ul=0,Or=2,Ln=5,Si=0,Mn=1,Xu=2,dm=(function(){function d(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=G.log.bind(G,"[info]:"),this.warn=G.warn.bind(G,"[warning]:"),this.error=G.error.bind(G,"[error]:"),this.registerListeners()}var s=d.prototype;return s.registerListeners=function(){var t=this.hls;t.on(x.ERROR,this.onError,this),t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.LEVEL_UPDATED,this.onLevelUpdated,this)},s.unregisterListeners=function(){var t=this.hls;t&&(t.off(x.ERROR,this.onError,this),t.off(x.ERROR,this.onErrorOut,this),t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.LEVEL_UPDATED,this.onLevelUpdated,this))},s.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},s.startLoad=function(t){this.playlistError=0},s.stopLoad=function(){},s.getVariantLevelIndex=function(t){return t?.type===Je?t.level:this.hls.loadLevel},s.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},s.onLevelUpdated=function(){this.playlistError=0},s.onError=function(t,r){var a,o;if(!r.fatal){var l=this.hls,h=r.context;switch(r.details){case q.FRAG_LOAD_ERROR:case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_ERROR:case q.KEY_LOAD_TIMEOUT:r.errorAction=this.getFragRetryOrSwitchAction(r);return;case q.FRAG_PARSING_ERROR:if((a=r.frag)!=null&&a.gap)return void(r.errorAction={action:ul,flags:Si});case q.FRAG_GAP:case q.FRAG_DECRYPT_ERROR:r.errorAction=this.getFragRetryOrSwitchAction(r),r.errorAction.action=Or;return;case q.LEVEL_EMPTY_ERROR:case q.LEVEL_PARSING_ERROR:var u,f,p=r.parent===Je?r.level:l.loadLevel;r.details===q.LEVEL_EMPTY_ERROR&&(u=r.context)!=null&&(f=u.levelDetails)!=null&&f.live?r.errorAction=this.getPlaylistRetryOrSwitchAction(r,p):(r.levelRetry=!1,r.errorAction=this.getLevelSwitchAction(r,p));return;case q.LEVEL_LOAD_ERROR:case q.LEVEL_LOAD_TIMEOUT:typeof h?.level=="number"&&(r.errorAction=this.getPlaylistRetryOrSwitchAction(r,h.level));return;case q.AUDIO_TRACK_LOAD_ERROR:case q.AUDIO_TRACK_LOAD_TIMEOUT:case q.SUBTITLE_LOAD_ERROR:case q.SUBTITLE_TRACK_LOAD_TIMEOUT:if(h){var v=l.levels[l.loadLevel];if(v&&(h.type===wr&&h.groupId===v.audioGroupId||h.type===Fr&&h.groupId===v.textGroupId))return r.errorAction=this.getPlaylistRetryOrSwitchAction(r,l.loadLevel),r.errorAction.action=Or,void(r.errorAction.flags=Mn)}return;case q.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var w=l.levels[l.loadLevel],C=w?.attrs["HDCP-LEVEL"];C&&(r.errorAction={action:Or,flags:Xu,hdcpLevel:C});return;case q.BUFFER_ADD_CODEC_ERROR:case q.REMUX_ALLOC_ERROR:r.errorAction=this.getLevelSwitchAction(r,(o=r.level)!=null?o:l.loadLevel);return;case q.INTERNAL_EXCEPTION:case q.BUFFER_APPENDING_ERROR:case q.BUFFER_APPEND_ERROR:case q.BUFFER_FULL_ERROR:case q.LEVEL_SWITCH_ERROR:case q.BUFFER_STALLED_ERROR:case q.BUFFER_SEEK_OVER_HOLE:case q.BUFFER_NUDGE_ON_STALL:r.errorAction={action:ul,flags:Si};return}if(r.type===ue.KEY_SYSTEM_ERROR){var k=this.getVariantLevelIndex(r.frag);r.levelRetry=!1,r.errorAction=this.getLevelSwitchAction(r,k);return}}},s.getPlaylistRetryOrSwitchAction=function(t,r){var a,o=qu(this.hls.config.playlistLoadPolicy,t),l=this.playlistError++,h=(a=t.response)==null?void 0:a.code;if(Rn(o,l,Dn(t),h))return{action:Ln,flags:Si,retryConfig:o,retryCount:l};var u=this.getLevelSwitchAction(t,r);return o&&(u.retryConfig=o,u.retryCount=l),u},s.getFragRetryOrSwitchAction=function(t){var r=this.hls,a=this.getVariantLevelIndex(t.frag),o=r.levels[a],l=r.config,h=l.fragLoadPolicy,u=l.keyLoadPolicy,f=qu(t.details.startsWith("key")?u:h,t),p=r.levels.reduce(function(k,I){return k+I.fragmentError},0);if(o){var v;t.details!==q.FRAG_GAP&&o.fragmentError++;var w=(v=t.response)==null?void 0:v.code;if(Rn(f,p,Dn(t),w))return{action:Ln,flags:Si,retryConfig:f,retryCount:p}}var C=this.getLevelSwitchAction(t,a);return f&&(C.retryConfig=f,C.retryCount=p),C},s.getLevelSwitchAction=function(t,r){var a=this.hls;r??=a.loadLevel;var o=this.hls.levels[r];if(o&&(o.loadError++,a.autoLevelEnabled)){for(var l,h,u=-1,f=a.levels,p=a.loadLevel,v=a.minAutoLevel,w=a.maxAutoLevel,C=(l=t.frag)==null?void 0:l.type,k=(h=t.context)!=null?h:{},I=k.type,D=k.groupId,B=f.length;B--;){var T=(B+p)%f.length;if(T!==p&&T>=v&&T<=w&&f[T].loadError===0){var U=f[T];if(t.details===q.FRAG_GAP&&t.frag){var M=f[T].details;if(M){var H=ba(t.frag,M.fragments,t.frag.start);if(H!=null&&H.gap)continue}}else if(I===wr&&D===U.audioGroupId||I===Fr&&D===U.textGroupId||C===Cr&&o.audioGroupId===U.audioGroupId||C===Wr&&o.textGroupId===U.textGroupId)continue;u=T;break}}if(u>-1&&a.loadLevel!==u)return t.levelRetry=!0,this.playlistError=0,{action:Or,flags:Si,nextAutoLevel:u}}return{action:Or,flags:Mn}},s.onErrorOut=function(t,r){var a;switch((a=r.errorAction)==null?void 0:a.action){case ul:break;case Or:this.sendAlternateToPenaltyBox(r),r.errorAction.resolved||r.details===q.FRAG_GAP||(r.fatal=!0)}r.fatal&&this.hls.stopLoad()},s.sendAlternateToPenaltyBox=function(t){var r=this.hls,a=t.errorAction;if(a){var o=a.flags,l=a.hdcpLevel,h=a.nextAutoLevel;switch(o){case Si:this.switchLevel(t,h);break;case Mn:a.resolved||(a.resolved=this.redundantFailover(t));break;case Xu:l&&(r.maxHdcpLevel=nl[nl.indexOf(l)-1],a.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+r.maxHdcpLevel+'" or lower')}a.resolved||this.switchLevel(t,h)}},s.switchLevel=function(t,r){r!==void 0&&t.errorAction&&(this.warn("switching to level "+r+" after "+t.details),this.hls.nextAutoLevel=r,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},s.redundantFailover=function(t){var r=this,a=this.hls,o=this.penalizedRenditions,l=t.parent===Je?t.level:a.loadLevel,h=a.levels[l],u=h.url.length,f=t.frag?t.frag.urlId:h.urlId;h.urlId!==f||t.frag&&!h.details||this.penalizeRendition(h,t);for(var p=function(){var C=(f+v)%u,k=o[C];if(!k||(function(I,D,B){if(performance.now()-I.lastErrorPerfMs>cm)return!0;var T=I.details;if(D.details===q.FRAG_GAP&&T&&D.frag){var U=D.frag.start,M=ba(null,T.fragments,U);if(M&&!M.gap)return!0}if(B&&I.errors.length<B.errors.length){var H=I.errors[I.errors.length-1];if(T&&H.frag&&D.frag&&Math.abs(H.frag.start-D.frag.start)>3*T.targetduration)return!0}return!1})(k,t,o[f]))return r.warn("Switching to Redundant Stream "+(C+1)+"/"+u+': "'+h.url[C]+'" after '+t.details),r.playlistError=0,a.levels.forEach(function(I){I.urlId=C}),a.nextLoadLevel=l,{v:!0}},v=1;v<u;v++){var w=p();if(typeof w=="object")return w.v}return!1},s.penalizeRendition=function(t,r){var a=this.penalizedRenditions,o=a[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};o.lastErrorPerfMs=performance.now(),o.errors.push(r),o.details=t.details,a[t.urlId]=o},d})(),gl=(function(){function d(t,r){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=G.log.bind(G,r+":"),this.warn=G.warn.bind(G,r+":"),this.hls=t}var s=d.prototype;return s.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},s.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},s.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},s.stopLoad=function(){this.canLoad=!1,this.clearTimer()},s.switchParams=function(t,r){var a=r?.renditionReports;if(a){for(var o=-1,l=0;l<a.length;l++){var h=a[l],u=void 0;try{u=new self.URL(h.URI,r.url).href}catch(C){G.warn("Could not construct new URL for Rendition Report: "+C),u=h.URI||""}if(u===t){o=l;break}u===t.substring(0,u.length)&&(o=l)}if(o!==-1){var f=a[o],p=parseInt(f["LAST-MSN"])||r?.lastPartSn,v=parseInt(f["LAST-PART"])||r?.lastPartIndex;if(this.hls.config.lowLatencyMode){var w=Math.min(r.age-r.partTarget,r.targetduration);v>=0&&w>r.partTarget&&(v+=1)}return new Hu(p,v>=0?v:void 0,ol)}}},s.loadPlaylist=function(t){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},s.shouldLoadPlaylist=function(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)},s.shouldReloadPlaylist=function(t){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(t)},s.playlistLoaded=function(t,r,a){var o=this,l=r.details,h=r.stats,u=self.performance.now(),f=h.loading.first?Math.max(0,u-h.loading.first):0;if(l.advancedDateTime=Date.now()-f,l.live||a!=null&&a.live){if(l.reloaded(a),a&&this.log("live playlist "+t+" "+(l.advanced?"REFRESHED "+l.lastPartSn+"-"+l.lastPartIndex:l.updated?"UPDATED":"MISSED")),a&&l.fragments.length>0&&sm(a,l),!this.canLoad||!l.live)return;var p,v=void 0,w=void 0;if(l.canBlockReload&&l.endSN&&l.advanced){var C=this.hls.config.lowLatencyMode,k=l.lastPartSn,I=l.endSN,D=l.lastPartIndex,B=k===I;D!==-1?(v=B?I+1:k,w=B?C?0:D:D+1):v=I+1;var T=l.age,U=T+l.ageHeader,M=Math.min(U-l.partTarget,1.5*l.targetduration);if(M>0){if(a&&M>a.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+a.tuneInGoal+" to: "+M+" with playlist age: "+l.age),M=0;else{var H=Math.floor(M/l.targetduration);v+=H,w!==void 0&&(w+=Math.round(M%l.targetduration/l.partTarget)),this.log("CDN Tune-in age: "+l.ageHeader+"s last advanced "+T.toFixed(2)+"s goal: "+M+" skip sn "+H+" to part "+w)}l.tuneInGoal=M}if(p=this.getDeliveryDirectives(l,r.deliveryDirectives,v,w),C||!B)return void this.loadPlaylist(p)}else(l.canBlockReload||l.canSkipUntil)&&(p=this.getDeliveryDirectives(l,r.deliveryDirectives,v,w));var V=this.hls.mainForwardBufferInfo,W=V?V.end-V.len:0,$=(function(j,le){le===void 0&&(le=1/0);var ie=1e3*j.targetduration;if(j.updated){var me=j.fragments;if(me.length&&4*ie>le){var we=1e3*me[me.length-1].duration;we<ie&&(ie=we)}}else ie/=2;return Math.round(ie)})(l,1e3*(l.edge-W));l.updated&&u>this.requestScheduled+$&&(this.requestScheduled=h.loading.start),v!==void 0&&l.canBlockReload?this.requestScheduled=h.loading.first+$-(1e3*l.partTarget||1e3):this.requestScheduled===-1||this.requestScheduled+$<u?this.requestScheduled=u:this.requestScheduled-u<=0&&(this.requestScheduled+=$);var J=this.requestScheduled-u;J=Math.max(0,J),this.log("reload live playlist "+t+" in "+Math.round(J)+" ms"),this.timer=self.setTimeout(function(){return o.loadPlaylist(p)},J)}else this.clearTimer()},s.getDeliveryDirectives=function(t,r,a,o){var l=(function(h,u){var f=h.canSkipUntil,p=h.canSkipDateRanges,v=h.endSN;return f&&(u!==void 0?u-v:0)<f?p?om:nm:ol})(t,a);return r!=null&&r.skip&&t.deltaUpdateFailed&&(a=r.msn,o=r.part,l=ol),new Hu(a,o,l)},s.checkRetry=function(t){var r=this,a=t.details,o=Dn(t),l=t.errorAction,h=l||{},u=h.action,f=h.retryCount,p=f===void 0?0:f,v=h.retryConfig,w=!!l&&!!v&&(u===Ln||!l.resolved&&u===Or);if(w){var C;if(this.requestScheduled=-1,p>=v.maxNumRetry)return!1;if(o&&(C=t.context)!=null&&C.deliveryDirectives)this.warn("Retrying playlist loading "+(p+1)+"/"+v.maxNumRetry+' after "'+a+'" without delivery-directives'),this.loadPlaylist();else{var k=cl(v,p);this.timer=self.setTimeout(function(){return r.loadPlaylist()},k),this.warn("Retrying playlist loading "+(p+1)+"/"+v.maxNumRetry+' after "'+a+'" in '+k+"ms")}t.levelRetry=!0,l.resolved=!0}return w},d})(),hm=(function(d){function s(r,a){var o;return(o=d.call(this,r,"[level-controller]")||this)._levels=[],o._firstLevel=-1,o._startLevel=void 0,o.currentLevel=null,o.currentLevelIndex=-1,o.manualLevelIndex=-1,o.steering=void 0,o.onParsedComplete=void 0,o.steering=a,o._registerListeners(),o}X(s,d);var t=s.prototype;return t._registerListeners=function(){var r=this.hls;r.on(x.MANIFEST_LOADING,this.onManifestLoading,this),r.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),r.on(x.LEVEL_LOADED,this.onLevelLoaded,this),r.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(x.FRAG_LOADED,this.onFragLoaded,this),r.on(x.ERROR,this.onError,this)},t._unregisterListeners=function(){var r=this.hls;r.off(x.MANIFEST_LOADING,this.onManifestLoading,this),r.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),r.off(x.LEVEL_LOADED,this.onLevelLoaded,this),r.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(x.FRAG_LOADED,this.onFragLoaded,this),r.off(x.ERROR,this.onError,this)},t.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),d.prototype.destroy.call(this)},t.startLoad=function(){this._levels.forEach(function(r){r.loadError=0,r.fragmentError=0}),d.prototype.startLoad.call(this)},t.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]},t.onManifestLoading=function(r,a){this.resetLevels()},t.onManifestLoaded=function(r,a){var o,l=[],h={};a.levels.forEach(function(u){var f,p=u.attrs;((f=u.audioCodec)==null?void 0:f.indexOf("mp4a.40.34"))!==-1&&(hl||(hl=/chrome|firefox/i.test(navigator.userAgent)),hl&&(u.audioCodec=void 0));var v=p.AUDIO,w=p.CODECS,C=p["FRAME-RATE"],k=p["PATHWAY-ID"],I=p.RESOLUTION,D=p.SUBTITLES,B=(k||".")+"-"+u.bitrate+"-"+I+"-"+C+"-"+w;(o=h[B])?o.addFallback(u):(o=new Aa(u),h[B]=o,l.push(o)),Fn(o,"audio",v),Fn(o,"text",D)}),this.filterAndSortMediaOptions(l,a)},t.filterAndSortMediaOptions=function(r,a){var o=this,l=[],h=[],u=!1,f=!1,p=!1,v=r.filter(function(T){var U=T.audioCodec,M=T.videoCodec,H=T.width,V=T.height,W=T.unknownCodecs;return u||(u=!(!H||!V)),f||(f=!!M),p||(p=!!U),!(W!=null&&W.length)&&(!U||el(U,"audio"))&&(!M||el(M,"video"))});if((u||f)&&p&&(v=v.filter(function(T){var U=T.videoCodec,M=T.width,H=T.height;return!!U||!(!M||!H)})),v.length!==0){a.audioTracks&&Ju(l=a.audioTracks.filter(function(T){return!T.audioCodec||el(T.audioCodec,"audio")})),a.subtitles&&Ju(h=a.subtitles);var w=v.slice(0);v.sort(function(T,U){return T.attrs["HDCP-LEVEL"]!==U.attrs["HDCP-LEVEL"]?(T.attrs["HDCP-LEVEL"]||"")>(U.attrs["HDCP-LEVEL"]||"")?1:-1:T.bitrate!==U.bitrate?T.bitrate-U.bitrate:T.attrs["FRAME-RATE"]!==U.attrs["FRAME-RATE"]?T.attrs.decimalFloatingPoint("FRAME-RATE")-U.attrs.decimalFloatingPoint("FRAME-RATE"):T.attrs.SCORE!==U.attrs.SCORE?T.attrs.decimalFloatingPoint("SCORE")-U.attrs.decimalFloatingPoint("SCORE"):u&&T.height!==U.height?T.height-U.height:0});var C=w[0];if(this.steering&&(v=this.steering.filterParsedLevels(v)).length!==w.length){for(var k=0;k<w.length;k++)if(w[k].pathwayId===v[0].pathwayId){C=w[k];break}}this._levels=v;for(var I=0;I<v.length;I++)if(v[I]===C){this._firstLevel=I,this.log("manifest loaded, "+v.length+" level(s) found, first bitrate: "+C.bitrate);break}var D=p&&!f,B={levels:v,audioTracks:l,subtitleTracks:h,sessionData:a.sessionData,sessionKeys:a.sessionKeys,firstLevel:this._firstLevel,stats:a.stats,audio:p,video:f,altAudio:!D&&l.some(function(T){return!!T.url})};this.hls.trigger(x.MANIFEST_PARSED,B),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then(function(){if(o.hls){var T=new Error("no level with compatible codecs found in manifest");o.hls.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:a.url,error:T,reason:T.message})}})},t.onError=function(r,a){!a.fatal&&a.context&&a.context.type===oi&&a.context.level===this.level&&this.checkRetry(a)},t.onFragLoaded=function(r,a){var o=a.frag;if(o!==void 0&&o.type===Je){var l=this._levels[o.level];l!==void 0&&(l.loadError=0)}},t.onLevelLoaded=function(r,a){var o,l,h=a.level,u=a.details,f=this._levels[h];if(!f)return this.warn("Invalid level index "+h),void((l=a.deliveryDirectives)!=null&&l.skip&&(u.deltaUpdateFailed=!0));h===this.currentLevelIndex?(f.fragmentError===0&&(f.loadError=0),this.playlistLoaded(h,a,f.details)):(o=a.deliveryDirectives)!=null&&o.skip&&(u.deltaUpdateFailed=!0)},t.onAudioTrackSwitched=function(r,a){var o=this.currentLevel;if(o){var l=this.hls.audioTracks[a.id].groupId;if(o.audioGroupIds&&o.audioGroupId!==l){for(var h=-1,u=0;u<o.audioGroupIds.length;u++)if(o.audioGroupIds[u]===l){h=u;break}h!==-1&&h!==o.urlId&&(o.urlId=h,this.canLoad&&this.startLoad())}}},t.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var a=this.currentLevelIndex,o=this.currentLevel;if(o&&this.shouldLoadPlaylist(o)){var l=o.urlId,h=o.uri;if(r)try{h=r.addDirectives(h)}catch(f){this.warn("Could not construct new URL with HLS Delivery Directives: "+f)}var u=o.attrs["PATHWAY-ID"];this.log("Loading level index "+a+(r?.msn!==void 0?" at sn "+r.msn+" part "+r.part:"")+" with"+(u?" Pathway "+u:"")+" URI "+(l+1)+"/"+o.url.length+" "+h),this.clearTimer(),this.hls.trigger(x.LEVEL_LOADING,{url:h,level:a,id:l,deliveryDirectives:r||null})}},t.removeLevel=function(r,a){var o=this,l=function(u,f){return f!==a},h=this._levels.filter(function(u,f){return f!==r||(u.url.length>1&&a!==void 0?(u.url=u.url.filter(l),u.audioGroupIds&&(u.audioGroupIds=u.audioGroupIds.filter(l)),u.textGroupIds&&(u.textGroupIds=u.textGroupIds.filter(l)),u.urlId=0,!0):(o.steering&&o.steering.removeLevel(u),!1))});this.hls.trigger(x.LEVELS_UPDATED,{levels:h})},t.onLevelsUpdated=function(r,a){var o=a.levels;o.forEach(function(l,h){var u=l.details;u!=null&&u.fragments&&u.fragments.forEach(function(f){f.level=h})}),this._levels=o},F(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(r){var a=this._levels;if(a.length!==0){if(r<0||r>=a.length){var o=new Error("invalid level idx"),l=r<0;if(this.hls.trigger(x.ERROR,{type:ue.OTHER_ERROR,details:q.LEVEL_SWITCH_ERROR,level:r,fatal:l,error:o,reason:o.message}),l)return;r=Math.min(r,a.length-1)}var h=this.currentLevelIndex,u=this.currentLevel,f=u?u.attrs["PATHWAY-ID"]:void 0,p=a[r],v=p.attrs["PATHWAY-ID"];if(this.currentLevelIndex=r,this.currentLevel=p,h!==r||!p.details||!u||f!==v){this.log("Switching to level "+r+(v?" with Pathway "+v:"")+" from level "+h+(f?" with Pathway "+f:""));var w=Y({},p,{level:r,maxBitrate:p.maxBitrate,attrs:p.attrs,uri:p.uri,urlId:p.urlId});delete w._attrs,delete w._urlId,this.hls.trigger(x.LEVEL_SWITCHING,w);var C=p.details;if(!C||C.live){var k=this.switchParams(p.uri,u?.details);this.loadPlaylist(k)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(r){this.manualLevelIndex=r,this._startLevel===void 0&&(this._startLevel=r),r!==-1&&(this.level=r)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(r){this._firstLevel=r}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var r=this.hls.config.startLevel;return r!==void 0?r:this._firstLevel}return this._startLevel},set:function(r){this._startLevel=r}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(r){this.level=r,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=r)}}]),s})(gl);function Fn(d,s,t){t&&(s==="audio"?(d.audioGroupIds||(d.audioGroupIds=[]),d.audioGroupIds[d.url.length-1]=t):s==="text"&&(d.textGroupIds||(d.textGroupIds=[]),d.textGroupIds[d.url.length-1]=t))}function Ju(d){var s={};d.forEach(function(t){var r=t.groupId||"";t.id=s[r]=s[r]||0,s[r]++})}var ya="NOT_LOADED",_u="APPENDING",xi="PARTIAL",wa="OK",um=(function(){function d(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}var s=d.prototype;return s._registerListeners=function(){var t=this.hls;t.on(x.BUFFER_APPENDED,this.onBufferAppended,this),t.on(x.FRAG_BUFFERED,this.onFragBuffered,this),t.on(x.FRAG_LOADED,this.onFragLoaded,this)},s._unregisterListeners=function(){var t=this.hls;t.off(x.BUFFER_APPENDED,this.onBufferAppended,this),t.off(x.FRAG_BUFFERED,this.onFragBuffered,this),t.off(x.FRAG_LOADED,this.onFragLoaded,this)},s.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},s.getAppendedFrag=function(t,r){var a=this.activePartLists[r];if(a)for(var o=a.length;o--;){var l=a[o];if(!l)break;var h=l.end;if(l.start<=t&&h!==null&&t<=h)return l}return this.getBufferedFrag(t,r)},s.getBufferedFrag=function(t,r){for(var a=this.fragments,o=Object.keys(a),l=o.length;l--;){var h=a[o[l]];if(h?.body.type===r&&h.buffered){var u=h.body;if(u.start<=t&&t<=u.end)return u}}return null},s.detectEvictedFragments=function(t,r,a,o){var l=this;this.timeRanges&&(this.timeRanges[t]=r);var h=o?.fragment.sn||-1;Object.keys(this.fragments).forEach(function(u){var f=l.fragments[u];if(f&&!(h>=f.body.sn))if(f.buffered||f.loaded){var p=f.range[t];p&&p.time.some(function(v){var w=!l.isTimeBuffered(v.startPTS,v.endPTS,r);return w&&l.removeFragment(f.body),w})}else f.body.type===a&&l.removeFragment(f.body)})},s.detectPartialFragments=function(t){var r=this,a=this.timeRanges,o=t.frag,l=t.part;if(a&&o.sn!=="initSegment"){var h=Ti(o),u=this.fragments[h];if(!(!u||u.buffered&&o.gap)){var f=!o.relurl;Object.keys(a).forEach(function(p){var v=o.elementaryStreams[p];if(v){var w=a[p],C=f||v.partial===!0;u.range[p]=r.getBufferedTimes(o,l,C,w)}}),u.loaded=null,Object.keys(u.range).length?(u.buffered=!0,(u.body.endList=o.endList||u.body.endList)&&(this.endListFragments[u.body.type]=u),On(u)||this.removeParts(o.sn-1,o.type)):this.removeFragment(u.body)}}},s.removeParts=function(t,r){var a=this.activePartLists[r];a&&(this.activePartLists[r]=a.filter(function(o){return o.fragment.sn>=t}))},s.fragBuffered=function(t,r){var a=Ti(t),o=this.fragments[a];!o&&r&&(o=this.fragments[a]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),o&&(o.loaded=null,o.buffered=!0)},s.getBufferedTimes=function(t,r,a,o){for(var l={time:[],partial:a},h=t.start,u=t.end,f=t.minEndPTS||u,p=t.maxStartPTS||h,v=0;v<o.length;v++){var w=o.start(v)-this.bufferPadding,C=o.end(v)+this.bufferPadding;if(p>=w&&f<=C){l.time.push({startPTS:Math.max(h,o.start(v)),endPTS:Math.min(u,o.end(v))});break}if(h<C&&u>w)l.partial=!0,l.time.push({startPTS:Math.max(h,o.start(v)),endPTS:Math.min(u,o.end(v))});else if(u<=w)break}return l},s.getPartialFragment=function(t){var r,a,o,l=null,h=0,u=this.bufferPadding,f=this.fragments;return Object.keys(f).forEach(function(p){var v=f[p];v&&On(v)&&(a=v.body.start-u,o=v.body.end+u,t>=a&&t<=o&&(r=Math.min(t-a,o-t),h<=r&&(l=v.body,h=r)))}),l},s.isEndListAppended=function(t){var r=this.endListFragments[t];return r!==void 0&&(r.buffered||On(r))},s.getState=function(t){var r=Ti(t),a=this.fragments[r];return a?a.buffered?On(a)?xi:wa:_u:ya},s.isTimeBuffered=function(t,r,a){for(var o,l,h=0;h<a.length;h++){if(o=a.start(h)-this.bufferPadding,l=a.end(h)+this.bufferPadding,t>=o&&r<=l)return!0;if(r<=o)return!1}return!1},s.onFragLoaded=function(t,r){var a=r.frag,o=r.part;if(a.sn!=="initSegment"&&!a.bitrateTest){var l=o?null:r,h=Ti(a);this.fragments[h]={body:a,appendedPTS:null,loaded:l,buffered:!1,range:Object.create(null)}}},s.onBufferAppended=function(t,r){var a=this,o=r.frag,l=r.part,h=r.timeRanges;if(o.sn!=="initSegment"){var u=o.type;if(l){var f=this.activePartLists[u];f||(this.activePartLists[u]=f=[]),f.push(l)}this.timeRanges=h,Object.keys(h).forEach(function(p){var v=h[p];a.detectEvictedFragments(p,v,u,l)})}},s.onFragBuffered=function(t,r){this.detectPartialFragments(r)},s.hasFragment=function(t){var r=Ti(t);return!!this.fragments[r]},s.hasParts=function(t){var r;return!((r=this.activePartLists[t])==null||!r.length)},s.removeFragmentsInRange=function(t,r,a,o,l){var h=this;o&&!this.hasGaps||Object.keys(this.fragments).forEach(function(u){var f=h.fragments[u];if(f){var p=f.body;p.type!==a||o&&!p.gap||p.start<r&&p.end>t&&(f.buffered||l)&&h.removeFragment(p)}})},s.removeFragment=function(t){var r=Ti(t);t.stats.loaded=0,t.clearElementaryStreamInfo();var a=this.activePartLists[t.type];if(a){var o=t.sn;this.activePartLists[t.type]=a.filter(function(l){return l.fragment.sn!==o})}delete this.fragments[r],t.endList&&delete this.endListFragments[t.type]},s.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},d})();function On(d){var s,t,r;return d.buffered&&(d.body.gap||((s=d.range.video)==null?void 0:s.partial)||((t=d.range.audio)==null?void 0:t.partial)||((r=d.range.audiovideo)==null?void 0:r.partial))}function Ti(d){return d.type+"_"+d.level+"_"+d.urlId+"_"+d.sn}var ju=Math.pow(2,17),gm=(function(){function d(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var s=d.prototype;return s.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},s.abort=function(){this.loader&&this.loader.abort()},s.load=function(t,r){var a=this,o=t.url;if(!o)return Promise.reject(new Pr({type:ue.NETWORK_ERROR,details:q.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a "+(o?"part list":"url")),networkDetails:null}));this.abort();var l=this.config,h=l.fLoader,u=l.loader;return new Promise(function(f,p){if(a.loader&&a.loader.destroy(),t.gap){if(t.tagList.some(function(I){return I[0]==="GAP"}))return void p($u(t));t.gap=!1}var v=a.loader=t.loader=h?new h(l):new u(l),w=Zu(t),C=Vu(l.fragLoadPolicy.default),k={loadPolicy:C,timeout:C.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:ju};t.stats=v.stats,v.load(w,k,{onSuccess:function(I,D,B,T){a.resetLoader(t,v);var U=I.data;B.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(U.slice(0,16)),U=U.slice(16)),f({frag:t,part:null,payload:U,networkDetails:T})},onError:function(I,D,B,T){a.resetLoader(t,v),p(new Pr({type:ue.NETWORK_ERROR,details:q.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:E({url:o,data:void 0},I),error:new Error("HTTP Error "+I.code+" "+I.text),networkDetails:B,stats:T}))},onAbort:function(I,D,B){a.resetLoader(t,v),p(new Pr({type:ue.NETWORK_ERROR,details:q.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:B,stats:I}))},onTimeout:function(I,D,B){a.resetLoader(t,v),p(new Pr({type:ue.NETWORK_ERROR,details:q.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error("Timeout after "+k.timeout+"ms"),networkDetails:B,stats:I}))},onProgress:function(I,D,B,T){r&&r({frag:t,part:null,payload:B,networkDetails:T})}})})},s.loadPart=function(t,r,a){var o=this;this.abort();var l=this.config,h=l.fLoader,u=l.loader;return new Promise(function(f,p){if(o.loader&&o.loader.destroy(),t.gap||r.gap)p($u(t,r));else{var v=o.loader=t.loader=h?new h(l):new u(l),w=Zu(t,r),C=Vu(l.fragLoadPolicy.default),k={loadPolicy:C,timeout:C.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:ju};r.stats=v.stats,v.load(w,k,{onSuccess:function(I,D,B,T){o.resetLoader(t,v),o.updateStatsFromPart(t,r);var U={frag:t,part:r,payload:I.data,networkDetails:T};a(U),f(U)},onError:function(I,D,B,T){o.resetLoader(t,v),p(new Pr({type:ue.NETWORK_ERROR,details:q.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:r,response:E({url:w.url,data:void 0},I),error:new Error("HTTP Error "+I.code+" "+I.text),networkDetails:B,stats:T}))},onAbort:function(I,D,B){t.stats.aborted=r.stats.aborted,o.resetLoader(t,v),p(new Pr({type:ue.NETWORK_ERROR,details:q.INTERNAL_ABORTED,fatal:!1,frag:t,part:r,error:new Error("Aborted"),networkDetails:B,stats:I}))},onTimeout:function(I,D,B){o.resetLoader(t,v),p(new Pr({type:ue.NETWORK_ERROR,details:q.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:r,error:new Error("Timeout after "+k.timeout+"ms"),networkDetails:B,stats:I}))}})}})},s.updateStatsFromPart=function(t,r){var a=t.stats,o=r.stats,l=o.total;if(a.loaded+=o.loaded,l){var h=Math.round(t.duration/r.duration),u=Math.min(Math.round(a.loaded/l),h),f=(h-u)*Math.round(a.loaded/u);a.total=a.loaded+f}else a.total=Math.max(a.loaded,a.total);var p=a.loading,v=o.loading;p.start?p.first+=v.first-v.start:(p.start=v.start,p.first=v.first),p.end=v.end},s.resetLoader=function(t,r){t.loader=null,this.loader===r&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),r.destroy()},d})();function Zu(d,s){s===void 0&&(s=null);var t=s||d,r={frag:d,part:s,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},a=t.byteRangeStartOffset,o=t.byteRangeEndOffset;if(se(a)&&se(o)){var l,h=a,u=o;if(d.sn==="initSegment"&&((l=d.decryptdata)==null?void 0:l.method)==="AES-128"){var f=o-a;f%16&&(u=o+(16-f%16)),a!==0&&(r.resetIV=!0,h=a-16)}r.rangeStart=h,r.rangeEnd=u}return r}function $u(d,s){var t=new Error("GAP "+(d.gap?"tag":"attribute")+" found"),r={type:ue.MEDIA_ERROR,details:q.FRAG_GAP,fatal:!1,frag:d,error:t,networkDetails:null};return s&&(r.part=s),(s||d).stats.aborted=!0,new Pr(r)}var Pr=(function(d){function s(t){var r;return(r=d.call(this,t.error.message)||this).data=void 0,r.data=t,r}return X(s,d),s})(ce(Error)),fm=(function(){function d(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}var s=d.prototype;return s.abort=function(t){for(var r in this.keyUriToKeyInfo){var a=this.keyUriToKeyInfo[r].loader;if(a){if(t&&t!==a.context.frag.type)return;a.abort()}}},s.detach=function(){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t];(r.mediaKeySessionContext||r.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}},s.destroy=function(){for(var t in this.detach(),this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;r&&r.destroy()}this.keyUriToKeyInfo={}},s.createKeyLoadError=function(t,r,a,o,l){return r===void 0&&(r=q.KEY_LOAD_ERROR),new Pr({type:ue.NETWORK_ERROR,details:r,fatal:!1,frag:t,response:l,error:a,networkDetails:o})},s.loadClear=function(t,r){var a=this;if(this.emeController&&this.config.emeEnabled)for(var o=t.sn,l=t.cc,h=function(){var f=r[u];if(l<=f.cc&&(o==="initSegment"||f.sn==="initSegment"||o<f.sn))return a.emeController.selectKeySystemFormat(f).then(function(p){f.setKeyFormat(p)}),"break"},u=0;u<r.length&&h()!=="break";u++);},s.load=function(t){var r=this;return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then(function(a){return r.loadInternal(t,a)}):this.loadInternal(t)},s.loadInternal=function(t,r){var a,o;r&&t.setKeyFormat(r);var l=t.decryptdata;if(!l){var h=new Error(r?"Expected frag.decryptdata to be defined after setting format "+r:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,q.KEY_LOAD_ERROR,h))}var u=l.uri;if(!u)return Promise.reject(this.createKeyLoadError(t,q.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+u+'"')));var f,p=this.keyUriToKeyInfo[u];if((a=p)!=null&&a.decryptdata.key)return l.key=p.decryptdata.key,Promise.resolve({frag:t,keyInfo:p});if((o=p)!=null&&o.keyLoadPromise)switch((f=p.mediaKeySessionContext)==null?void 0:f.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return p.keyLoadPromise.then(function(v){return l.key=v.keyInfo.decryptdata.key,{frag:t,keyInfo:p}})}switch(p=this.keyUriToKeyInfo[u]={decryptdata:l,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},l.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return l.keyFormat==="identity"?this.loadKeyHTTP(p,t):this.loadKeyEME(p,t);case"AES-128":return this.loadKeyHTTP(p,t);default:return Promise.reject(this.createKeyLoadError(t,q.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+l.method+'"')))}},s.loadKeyEME=function(t,r){var a={frag:r,keyInfo:t};if(this.emeController&&this.config.emeEnabled){var o=this.emeController.loadKey(a);if(o)return(t.keyLoadPromise=o.then(function(l){return t.mediaKeySessionContext=l,a})).catch(function(l){throw t.keyLoadPromise=null,l})}return Promise.resolve(a)},s.loadKeyHTTP=function(t,r){var a=this,o=this.config,l=new o.loader(o);return r.keyLoader=t.loader=l,t.keyLoadPromise=new Promise(function(h,u){var f={keyInfo:t,frag:r,responseType:"arraybuffer",url:t.decryptdata.uri},p=o.keyLoadPolicy.default,v={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};l.load(f,v,{onSuccess:function(w,C,k,I){var D=k.frag,B=k.keyInfo,T=k.url;if(!D.decryptdata||B!==a.keyUriToKeyInfo[T])return u(a.createKeyLoadError(D,q.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),I));B.decryptdata.key=D.decryptdata.key=new Uint8Array(w.data),D.keyLoader=null,B.loader=null,h({frag:D,keyInfo:B})},onError:function(w,C,k,I){a.resetLoader(C),u(a.createKeyLoadError(r,q.KEY_LOAD_ERROR,new Error("HTTP Error "+w.code+" loading key "+w.text),k,E({url:f.url,data:void 0},w)))},onTimeout:function(w,C,k){a.resetLoader(C),u(a.createKeyLoadError(r,q.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),k))},onAbort:function(w,C,k){a.resetLoader(C),u(a.createKeyLoadError(r,q.INTERNAL_ABORTED,new Error("key loading aborted"),k))}})})},s.resetLoader=function(t){var r=t.frag,a=t.keyInfo,o=t.url,l=a.loader;r.keyLoader===l&&(r.keyLoader=null,a.loader=null),delete this.keyUriToKeyInfo[o],l&&l.destroy()},d})(),pm=(function(){function d(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var s=d.prototype;return s.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},s.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},s.onHandlerDestroyed=function(){},s.hasInterval=function(){return!!this._tickInterval},s.hasNextTick=function(){return!!this._tickTimer},s.setInterval=function(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)},s.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},s.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},s.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},s.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},s.doTick=function(){},d})(),mm={length:0,start:function(){return 0},end:function(){return 0}},ct=(function(){function d(){}return d.isBuffered=function(s,t){try{if(s){for(var r=d.getBuffered(s),a=0;a<r.length;a++)if(t>=r.start(a)&&t<=r.end(a))return!0}}catch{}return!1},d.bufferInfo=function(s,t,r){try{if(s){var a,o=d.getBuffered(s),l=[];for(a=0;a<o.length;a++)l.push({start:o.start(a),end:o.end(a)});return this.bufferedInfo(l,t,r)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}},d.bufferedInfo=function(s,t,r){t=Math.max(0,t),s.sort(function(I,D){return I.start-D.start||D.end-I.end});var a=[];if(r)for(var o=0;o<s.length;o++){var l=a.length;if(l){var h=a[l-1].end;s[o].start-h<r?s[o].end>h&&(a[l-1].end=s[o].end):a.push(s[o])}else a.push(s[o])}else a=s;for(var u,f=0,p=t,v=t,w=0;w<a.length;w++){var C=a[w].start,k=a[w].end;if(t+r>=C&&t<k)p=C,f=(v=k)-t;else if(t+r<C){u=C;break}}return{len:f,start:p||0,end:v||0,nextStart:u}},d.getBuffered=function(s){try{return s.buffered}catch(t){return G.log("failed to get media.buffered",t),mm}},d})(),fl=function(d,s,t,r,a,o){r===void 0&&(r=0),a===void 0&&(a=-1),o===void 0&&(o=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=d,this.sn=s,this.id=t,this.size=r,this.part=a,this.partial=o};function eg(d,s){for(var t=null,r=0,a=d.length;r<a;r++){var o=d[r];if(o&&o.cc===s){t=o;break}}return t}function tg(d,s){if(d){var t=d.start+s;d.start=d.startPTS=t,d.endPTS=t+d.duration}}function pl(d,s){for(var t=s.fragments,r=0,a=t.length;r<a;r++)tg(t[r],d);s.fragmentHint&&tg(s.fragmentHint,d),s.alignedSliding=!0}function vm(d,s,t){s&&((function(r,a,o){if((function(h,u,f){return!(!u.details||!(f.endCC>f.startCC||h&&h.cc<f.startCC))})(r,o,a)){var l=(function(h,u,f){var p=h.fragments,v=u.fragments;if(v.length&&p.length){var w=eg(p,v[0].cc);if(w&&(!w||w.startPTS))return w;G.log("No frag in previous level to align on")}else G.log("No fragments to align")})(o.details,a);l&&se(l.start)&&(G.log("Adjusting PTS using last level due to CC increase within current level "+a.url),pl(l.start,a))}})(d,t,s),!t.alignedSliding&&s.details&&(function(r,a){if(a.fragments.length&&r.hasProgramDateTime&&a.hasProgramDateTime){var o=a.fragments[0].programDateTime,l=r.fragments[0].programDateTime,h=(l-o)/1e3+a.fragments[0].start;h&&se(h)&&(G.log("Adjusting PTS using programDateTime delta "+(l-o)+"ms, sliding:"+h.toFixed(3)+" "+r.url+" "),pl(h,r))}})(t,s.details),t.alignedSliding||!s.details||t.skippedSegments||Yu(s.details,t))}function rg(d,s){if(d.hasProgramDateTime&&s.hasProgramDateTime){var t=d.fragments,r=s.fragments;if(t.length&&r.length){var a=r[Math.round(r.length/2)-1],o=eg(t,a.cc)||t[Math.round(t.length/2)-1],l=a.programDateTime,h=o.programDateTime;l!==null&&h!==null&&pl((h-l)/1e3-(o.start-a.start),d)}}}var Am=(function(){function d(s,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=s,this.aesIV=t}return d.prototype.decrypt=function(s,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,s)},d})(),bm=(function(){function d(s,t){this.subtle=void 0,this.key=void 0,this.subtle=s,this.key=t}return d.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},d})(),ym=(function(){function d(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var s=d.prototype;return s.uint8ArrayToUint32Array_=function(t){for(var r=new DataView(t),a=new Uint32Array(4),o=0;o<4;o++)a[o]=r.getUint32(4*o);return a},s.initTable=function(){var t=this.sBox,r=this.invSBox,a=this.subMix,o=a[0],l=a[1],h=a[2],u=a[3],f=this.invSubMix,p=f[0],v=f[1],w=f[2],C=f[3],k=new Uint32Array(256),I=0,D=0,B=0;for(B=0;B<256;B++)k[B]=B<128?B<<1:B<<1^283;for(B=0;B<256;B++){var T=D^D<<1^D<<2^D<<3^D<<4;T=T>>>8^255&T^99,t[I]=T,r[T]=I;var U=k[I],M=k[U],H=k[M],V=257*k[T]^16843008*T;o[I]=V<<24|V>>>8,l[I]=V<<16|V>>>16,h[I]=V<<8|V>>>24,u[I]=V,V=16843009*H^65537*M^257*U^16843008*I,p[T]=V<<24|V>>>8,v[T]=V<<16|V>>>16,w[T]=V<<8|V>>>24,C[T]=V,I?(I=U^k[k[k[H^U]]],D^=k[k[D]]):I=D=1}},s.expandKey=function(t){for(var r=this.uint8ArrayToUint32Array_(t),a=!0,o=0;o<r.length&&a;)a=r[o]===this.key[o],o++;if(!a){this.key=r;var l=this.keySize=r.length;if(l!==4&&l!==6&&l!==8)throw new Error("Invalid aes key size="+l);var h,u,f,p,v=this.ksRows=4*(l+6+1),w=this.keySchedule=new Uint32Array(v),C=this.invKeySchedule=new Uint32Array(v),k=this.sBox,I=this.rcon,D=this.invSubMix,B=D[0],T=D[1],U=D[2],M=D[3];for(h=0;h<v;h++)h<l?f=w[h]=r[h]:(p=f,h%l==0?(p=k[(p=p<<8|p>>>24)>>>24]<<24|k[p>>>16&255]<<16|k[p>>>8&255]<<8|k[255&p],p^=I[h/l|0]<<24):l>6&&h%l==4&&(p=k[p>>>24]<<24|k[p>>>16&255]<<16|k[p>>>8&255]<<8|k[255&p]),w[h]=f=(w[h-l]^p)>>>0);for(u=0;u<v;u++)h=v-u,p=3&u?w[h]:w[h-4],C[u]=u<4||h<=4?p:B[k[p>>>24]]^T[k[p>>>16&255]]^U[k[p>>>8&255]]^M[k[255&p]],C[u]=C[u]>>>0}},s.networkToHostOrderSwap=function(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24},s.decrypt=function(t,r,a){for(var o,l,h,u,f,p,v,w,C,k,I,D,B,T,U=this.keySize+6,M=this.invKeySchedule,H=this.invSBox,V=this.invSubMix,W=V[0],$=V[1],J=V[2],j=V[3],le=this.uint8ArrayToUint32Array_(a),ie=le[0],me=le[1],we=le[2],ve=le[3],Ae=new Int32Array(t),Ie=new Int32Array(Ae.length),fe=this.networkToHostOrderSwap;r<Ae.length;){for(C=fe(Ae[r]),k=fe(Ae[r+1]),I=fe(Ae[r+2]),D=fe(Ae[r+3]),f=C^M[0],p=D^M[1],v=I^M[2],w=k^M[3],B=4,T=1;T<U;T++)o=W[f>>>24]^$[p>>16&255]^J[v>>8&255]^j[255&w]^M[B],l=W[p>>>24]^$[v>>16&255]^J[w>>8&255]^j[255&f]^M[B+1],h=W[v>>>24]^$[w>>16&255]^J[f>>8&255]^j[255&p]^M[B+2],u=W[w>>>24]^$[f>>16&255]^J[p>>8&255]^j[255&v]^M[B+3],f=o,p=l,v=h,w=u,B+=4;o=H[f>>>24]<<24^H[p>>16&255]<<16^H[v>>8&255]<<8^H[255&w]^M[B],l=H[p>>>24]<<24^H[v>>16&255]<<16^H[w>>8&255]<<8^H[255&f]^M[B+1],h=H[v>>>24]<<24^H[w>>16&255]<<16^H[f>>8&255]<<8^H[255&p]^M[B+2],u=H[w>>>24]<<24^H[f>>16&255]<<16^H[p>>8&255]<<8^H[255&v]^M[B+3],Ie[r]=fe(o^ie),Ie[r+1]=fe(u^me),Ie[r+2]=fe(h^we),Ie[r+3]=fe(l^ve),ie=C,me=k,we=I,ve=D,r+=4}return Ie.buffer},d})(),ml=(function(){function d(t,r){var a=(r===void 0?{}:r).removePKCS7Padding,o=a===void 0||a;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=o,o)try{var l=self.crypto;l&&(this.subtle=l.subtle||l.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var s=d.prototype;return s.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},s.isSync=function(){return this.useSoftware},s.flush=function(){var t=this.currentResult,r=this.remainderData;if(!t||r)return this.reset(),null;var a,o,l,h=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?(o=(a=h).byteLength,(l=o&&new DataView(a.buffer).getUint8(o-1))?ai(a,0,o-l):a):h},s.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},s.decrypt=function(t,r,a){var o=this;return this.useSoftware?new Promise(function(l,h){o.softwareDecrypt(new Uint8Array(t),r,a);var u=o.flush();u?l(u.buffer):h(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),r,a)},s.softwareDecrypt=function(t,r,a){var o=this.currentIV,l=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(t=ni(h,t),this.remainderData=null);var u=this.getValidChunk(t);if(!u.length)return null;o&&(a=o);var f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new ym),f.expandKey(r);var p=l;return this.currentResult=f.decrypt(u.buffer,0,a),this.currentIV=ai(u,-16).buffer,p||null},s.webCryptoDecrypt=function(t,r,a){var o=this,l=this.subtle;return this.key===r&&this.fastAesKey||(this.key=r,this.fastAesKey=new bm(l,r)),this.fastAesKey.expandKey().then(function(h){return l?(o.logOnce("WebCrypto AES decrypt"),new Am(l,new Uint8Array(a)).decrypt(t.buffer,h)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(h){return G.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+h.name+": "+h.message),o.onWebCryptoError(t,r,a)})},s.onWebCryptoError=function(t,r,a){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,r,a);var o=this.flush();if(o)return o.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},s.getValidChunk=function(t){var r=t,a=t.length-t.length%16;return a!==t.length&&(r=ai(t,0,a),this.remainderData=ai(t,a)),r},s.logOnce=function(t){this.logEnabled&&(G.log("[decrypter]: "+t),this.logEnabled=!1)},d})(),wm=function(d){for(var s="",t=d.length,r=0;r<t;r++)s+="["+d.start(r).toFixed(3)+"-"+d.end(r).toFixed(3)+"]";return s},Vt="STOPPED",Qe="IDLE",vl="KEY_LOADING",Di="FRAG_LOADING",Ri="FRAG_LOADING_WAITING_RETRY",Ca="WAITING_TRACK",Ur="PARSING",Pn="PARSED",Ea="ENDED",Li="ERROR",ka="WAITING_INIT_PTS",si="WAITING_LEVEL",Al=(function(d){function s(r,a,o,l,h){var u;return(u=d.call(this)||this).hls=void 0,u.fragPrevious=null,u.fragCurrent=null,u.fragmentTracker=void 0,u.transmuxer=null,u._state=Vt,u.playlistType=void 0,u.media=null,u.mediaBuffer=null,u.config=void 0,u.bitrateTest=!1,u.lastCurrentTime=0,u.nextLoadPosition=0,u.startPosition=0,u.startTimeOffset=null,u.loadedmetadata=!1,u.retryDate=0,u.levels=null,u.fragmentLoader=void 0,u.keyLoader=void 0,u.levelLastLoaded=null,u.startFragRequested=!1,u.decrypter=void 0,u.initPTS=[],u.onvseeking=null,u.onvended=null,u.logPrefix="",u.log=void 0,u.warn=void 0,u.playlistType=h,u.logPrefix=l,u.log=G.log.bind(G,l+":"),u.warn=G.warn.bind(G,l+":"),u.hls=r,u.fragmentLoader=new gm(r.config),u.keyLoader=o,u.fragmentTracker=a,u.config=r.config,u.decrypter=new ml(r.config),r.on(x.MANIFEST_LOADED,u.onManifestLoaded,(function(f){if(f===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return f})(u)),u}X(s,d);var t=s.prototype;return t.doTick=function(){this.onTickEnd()},t.onTickEnd=function(){},t.startLoad=function(r){},t.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var r=this.fragCurrent;r!=null&&r.loader&&(r.abortRequests(),this.fragmentTracker.removeFragment(r)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Vt},t._streamEnded=function(r,a){if(a.live||r.nextStart||!r.end||!this.media)return!1;var o=a.partList;if(o!=null&&o.length){var l=o[o.length-1];return ct.isBuffered(this.media,l.start+l.duration/2)}var h=a.fragments[a.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(h)},t.getLevelDetails=function(){var r;if(this.levels&&this.levelLastLoaded!==null)return(r=this.levels[this.levelLastLoaded])==null?void 0:r.details},t.onMediaAttached=function(r,a){var o=this.media=this.mediaBuffer=a.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),o.addEventListener("seeking",this.onvseeking),o.addEventListener("ended",this.onvended);var l=this.config;this.levels&&l.autoStartLoad&&this.state===Vt&&this.startLoad(l.startPosition)},t.onMediaDetaching=function(){var r=this.media;r!=null&&r.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),r&&this.onvseeking&&this.onvended&&(r.removeEventListener("seeking",this.onvseeking),r.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},t.onMediaSeeking=function(){var r=this.config,a=this.fragCurrent,o=this.media,l=this.mediaBuffer,h=this.state,u=o?o.currentTime:0,f=ct.bufferInfo(l||o,u,r.maxBufferHole);if(this.log("media seeking to "+(se(u)?u.toFixed(3):u)+", state: "+h),this.state===Ea)this.resetLoadingState();else if(a){var p=r.maxFragLookUpTolerance,v=a.start-p,w=a.start+a.duration+p;if(!f.len||w<f.start||v>f.end){var C=u>w;(u<v||C)&&(C&&a.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),a.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}o&&(this.fragmentTracker.removeFragmentsInRange(u,1/0,this.playlistType,!0),this.lastCurrentTime=u),this.loadedmetadata||f.len||(this.nextLoadPosition=this.startPosition=u),this.tickImmediate()},t.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},t.onManifestLoaded=function(r,a){this.startTimeOffset=a.startTimeOffset,this.initPTS=[]},t.onHandlerDestroying=function(){this.stopLoad(),d.prototype.onHandlerDestroying.call(this)},t.onHandlerDestroyed=function(){this.state=Vt,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,d.prototype.onHandlerDestroyed.call(this)},t.loadFragment=function(r,a,o){this._loadFragForPlayback(r,a,o)},t._loadFragForPlayback=function(r,a,o){var l=this;this._doFragLoad(r,a,o,function(h){if(l.fragContextChanged(r))return l.warn("Fragment "+r.sn+(h.part?" p: "+h.part.index:"")+" of level "+r.level+" was dropped during download."),void l.fragmentTracker.removeFragment(r);r.stats.chunkCount++,l._handleFragmentLoadProgress(h)}).then(function(h){if(h){var u=l.state;l.fragContextChanged(r)?(u===Di||!l.fragCurrent&&u===Ur)&&(l.fragmentTracker.removeFragment(r),l.state=Qe):("payload"in h&&(l.log("Loaded fragment "+r.sn+" of level "+r.level),l.hls.trigger(x.FRAG_LOADED,h)),l._handleFragmentLoadComplete(h))}}).catch(function(h){l.state!==Vt&&l.state!==Li&&(l.warn(h),l.resetFragmentLoading(r))})},t.clearTrackerIfNeeded=function(r){var a,o=this.fragmentTracker;if(o.getState(r)===_u){var l=r.type,h=this.getFwdBufferInfo(this.mediaBuffer,l),u=Math.max(r.duration,h?h.len:this.config.maxBufferLength);this.reduceMaxBufferLength(u)&&o.removeFragment(r)}else((a=this.mediaBuffer)==null?void 0:a.buffered.length)===0?o.removeAllFragments():o.hasParts(r.type)&&(o.detectPartialFragments({frag:r,part:null,stats:r.stats,id:r.type}),o.getState(r)===xi&&o.removeFragment(r))},t.checkLiveUpdate=function(r){if(r.updated&&!r.live){var a=r.fragments[r.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:a,part:null,stats:a.stats,id:a.type})}r.fragments[0]||(r.deltaUpdateFailed=!0)},t.flushMainBuffer=function(r,a,o){if(o===void 0&&(o=null),r-a){var l={startOffset:r,endOffset:a,type:o};this.hls.trigger(x.BUFFER_FLUSHING,l)}},t._loadInitSegment=function(r,a){var o=this;this._doFragLoad(r,a).then(function(l){if(!l||o.fragContextChanged(r)||!o.levels)throw new Error("init load aborted");return l}).then(function(l){var h=o.hls,u=l.payload,f=r.decryptdata;if(u&&u.byteLength>0&&f&&f.key&&f.iv&&f.method==="AES-128"){var p=self.performance.now();return o.decrypter.decrypt(new Uint8Array(u),f.key.buffer,f.iv.buffer).catch(function(v){throw h.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_DECRYPT_ERROR,fatal:!1,error:v,reason:v.message,frag:r}),v}).then(function(v){var w=self.performance.now();return h.trigger(x.FRAG_DECRYPTED,{frag:r,payload:v,stats:{tstart:p,tdecrypt:w}}),l.payload=v,l})}return l}).then(function(l){var h=o.fragCurrent,u=o.hls;if(!o.levels)throw new Error("init load aborted, missing levels");var f=r.stats;o.state=Qe,a.fragmentError=0,r.data=new Uint8Array(l.payload),f.parsing.start=f.buffering.start=self.performance.now(),f.parsing.end=f.buffering.end=self.performance.now(),l.frag===h&&u.trigger(x.FRAG_BUFFERED,{stats:f,frag:h,part:null,id:r.type}),o.tick()}).catch(function(l){o.state!==Vt&&o.state!==Li&&(o.warn(l),o.resetFragmentLoading(r))})},t.fragContextChanged=function(r){var a=this.fragCurrent;return!r||!a||r.level!==a.level||r.sn!==a.sn||r.urlId!==a.urlId},t.fragBufferedComplete=function(r,a){var o,l,h,u,f=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+r.type+" sn: "+r.sn+(a?" part: "+a.index:"")+" of "+(this.playlistType===Je?"level":"track")+" "+r.level+" (frag:["+((o=r.startPTS)!=null?o:NaN).toFixed(3)+"-"+((l=r.endPTS)!=null?l:NaN).toFixed(3)+"] > buffer:"+(f?wm(ct.getBuffered(f)):"(detached)")+")"),this.state=Qe,f&&(!this.loadedmetadata&&r.type==Je&&f.buffered.length&&((h=this.fragCurrent)==null?void 0:h.sn)===((u=this.fragPrevious)==null?void 0:u.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},t.seekToStartPos=function(){},t._handleFragmentLoadComplete=function(r){var a=this.transmuxer;if(a){var o=r.frag,l=r.part,h=r.partsLoaded,u=!h||h.length===0||h.some(function(p){return!p}),f=new fl(o.level,o.sn,o.stats.chunkCount+1,0,l?l.index:-1,!u);a.flush(f)}},t._handleFragmentLoadProgress=function(r){},t._doFragLoad=function(r,a,o,l){var h,u=this;o===void 0&&(o=null);var f=a?.details;if(!this.levels||!f)throw new Error("frag load aborted, missing level"+(f?"":" detail")+"s");var p=null;if(!r.encrypted||(h=r.decryptdata)!=null&&h.key?!r.encrypted&&f.encryptedFragments.length&&this.keyLoader.loadClear(r,f.encryptedFragments):(this.log("Loading key for "+r.sn+" of ["+f.startSN+"-"+f.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+r.level),this.state=vl,this.fragCurrent=r,p=this.keyLoader.load(r).then(function(B){if(!u.fragContextChanged(B.frag))return u.hls.trigger(x.KEY_LOADED,B),u.state===vl&&(u.state=Qe),B}),this.hls.trigger(x.KEY_LOADING,{frag:r}),this.fragCurrent===null&&(p=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),o=Math.max(r.start,o||0),this.config.lowLatencyMode&&r.sn!=="initSegment"){var v=f.partList;if(v&&l){o>r.end&&f.fragmentHint&&(r=f.fragmentHint);var w=this.getNextPart(v,r,o);if(w>-1){var C,k=v[w];return this.log("Loading part sn: "+r.sn+" p: "+k.index+" cc: "+r.cc+" of playlist ["+f.startSN+"-"+f.endSN+"] parts [0-"+w+"-"+(v.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+r.level+", target: "+parseFloat(o.toFixed(3))),this.nextLoadPosition=k.start+k.duration,this.state=Di,C=p?p.then(function(B){return!B||u.fragContextChanged(B.frag)?null:u.doFragPartsLoad(r,k,a,l)}).catch(function(B){return u.handleFragLoadError(B)}):this.doFragPartsLoad(r,k,a,l).catch(function(B){return u.handleFragLoadError(B)}),this.hls.trigger(x.FRAG_LOADING,{frag:r,part:k,targetBufferTime:o}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):C}if(!r.url||this.loadedEndOfParts(v,o))return Promise.resolve(null)}}this.log("Loading fragment "+r.sn+" cc: "+r.cc+" "+(f?"of ["+f.startSN+"-"+f.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+r.level+", target: "+parseFloat(o.toFixed(3))),se(r.sn)&&!this.bitrateTest&&(this.nextLoadPosition=r.start+r.duration),this.state=Di;var I,D=this.config.progressive;return I=D&&p?p.then(function(B){return!B||u.fragContextChanged(B?.frag)?null:u.fragmentLoader.load(r,l)}).catch(function(B){return u.handleFragLoadError(B)}):Promise.all([this.fragmentLoader.load(r,D?l:void 0),p]).then(function(B){var T=B[0];return!D&&T&&l&&l(T),T}).catch(function(B){return u.handleFragLoadError(B)}),this.hls.trigger(x.FRAG_LOADING,{frag:r,targetBufferTime:o}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):I},t.doFragPartsLoad=function(r,a,o,l){var h=this;return new Promise(function(u,f){var p,v=[],w=(p=o.details)==null?void 0:p.partList;(function C(k){h.fragmentLoader.loadPart(r,k,l).then(function(I){v[k.index]=I;var D=I.part;h.hls.trigger(x.FRAG_LOADED,I);var B=Ku(o,r.sn,k.index+1)||zu(w,r.sn,k.index+1);if(!B)return u({frag:r,part:D,partsLoaded:v});C(B)}).catch(f)})(a)})},t.handleFragLoadError=function(r){if("data"in r){var a=r.data;r.data&&a.details===q.INTERNAL_ABORTED?this.handleFragLoadAborted(a.frag,a.part):this.hls.trigger(x.ERROR,a)}else this.hls.trigger(x.ERROR,{type:ue.OTHER_ERROR,details:q.INTERNAL_EXCEPTION,err:r,error:r,fatal:!0});return null},t._handleTransmuxerFlush=function(r){var a=this.getCurrentContext(r);if(a&&this.state===Ur){var o=a.frag,l=a.part,h=a.level,u=self.performance.now();o.stats.parsing.end=u,l&&(l.stats.parsing.end=u),this.updateLevelTiming(o,l,h,r.partial)}else this.fragCurrent||this.state===Vt||this.state===Li||(this.state=Qe)},t.getCurrentContext=function(r){var a=this.levels,o=this.fragCurrent,l=r.level,h=r.sn,u=r.part;if(a==null||!a[l])return this.warn("Levels object was unset while buffering fragment "+h+" of level "+l+". The current chunk will not be buffered."),null;var f=a[l],p=u>-1?Ku(f,h,u):null,v=p?p.fragment:(function(w,C,k){if(w==null||!w.details)return null;var I=w.details,D=I.fragments[C-I.startSN];return D||((D=I.fragmentHint)&&D.sn===C?D:C<I.startSN&&k&&k.sn===C?k:null)})(f,h,o);return v?(o&&o!==v&&(v.stats=o.stats),{frag:v,part:p,level:f}):null},t.bufferFragmentData=function(r,a,o,l,h){var u;if(r&&this.state===Ur){var f=r.data1,p=r.data2,v=f;if(f&&p&&(v=ni(f,p)),(u=v)!=null&&u.length){var w={type:r.type,frag:a,part:o,chunkMeta:l,parent:a.type,data:v};if(this.hls.trigger(x.BUFFER_APPENDING,w),r.dropped&&r.independent&&!o){if(h)return;this.flushBufferGap(a)}}}},t.flushBufferGap=function(r){var a=this.media;if(a)if(ct.isBuffered(a,a.currentTime)){var o=a.currentTime,l=ct.bufferInfo(a,o,0),h=r.duration,u=Math.min(2*this.config.maxFragLookUpTolerance,.25*h),f=Math.max(Math.min(r.start-u,l.end-u),o+u);r.start-f>u&&this.flushMainBuffer(f,r.start)}else this.flushMainBuffer(0,r.start)},t.getFwdBufferInfo=function(r,a){var o=this.getLoadPosition();return se(o)?this.getFwdBufferInfoAtPos(r,o,a):null},t.getFwdBufferInfoAtPos=function(r,a,o){var l=this.config.maxBufferHole,h=ct.bufferInfo(r,a,l);if(h.len===0&&h.nextStart!==void 0){var u=this.fragmentTracker.getBufferedFrag(a,o);if(u&&h.nextStart<u.end)return ct.bufferInfo(r,a,Math.max(h.nextStart,l))}return h},t.getMaxBufferLength=function(r){var a,o=this.config;return a=r?Math.max(8*o.maxBufferSize/r,o.maxBufferLength):o.maxBufferLength,Math.min(a,o.maxMaxBufferLength)},t.reduceMaxBufferLength=function(r){var a=this.config,o=r||a.maxBufferLength;return a.maxMaxBufferLength>=o&&(a.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+a.maxMaxBufferLength+"s"),!0)},t.getAppendedFrag=function(r,a){var o=this.fragmentTracker.getAppendedFrag(r,Je);return o&&"fragment"in o?o.fragment:o},t.getNextFragment=function(r,a){var o=a.fragments,l=o.length;if(!l)return null;var h,u=this.config,f=o[0].start;if(a.live){var p=u.initialLiveManifestSize;if(l<p)return this.warn("Not enough fragments to start playback (have: "+l+", need: "+p+")"),null;a.PTSKnown||this.startFragRequested||this.startPosition!==-1||(h=this.getInitialLiveFragment(a,o),this.startPosition=h?this.hls.liveSyncPosition||h.start:r)}else r<=f&&(h=o[0]);if(!h){var v=u.lowLatencyMode?a.partEnd:a.fragmentEnd;h=this.getFragmentAtPosition(r,v,a)}return this.mapToInitFragWhenRequired(h)},t.isLoopLoading=function(r,a){var o=this.fragmentTracker.getState(r);return(o===wa||o===xi&&!!r.gap)&&this.nextLoadPosition>a},t.getNextFragmentLoopLoading=function(r,a,o,l,h){var u=r.gap,f=this.getNextFragment(this.nextLoadPosition,a);if(f===null)return f;if(r=f,u&&r&&!r.gap&&o.nextStart){var p=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,o.nextStart,l);if(p!==null&&o.len+p.len>=h)return this.log('buffer full after gaps in "'+l+'" playlist starting at sn: '+r.sn),null}return r},t.mapToInitFragWhenRequired=function(r){return r==null||!r.initSegment||r!=null&&r.initSegment.data||this.bitrateTest?r:r.initSegment},t.getNextPart=function(r,a,o){for(var l=-1,h=!1,u=!0,f=0,p=r.length;f<p;f++){var v=r[f];if(u=u&&!v.independent,l>-1&&o<v.start)break;var w=v.loaded;w?l=-1:(h||v.independent||u)&&v.fragment===a&&(l=f),h=w}return l},t.loadedEndOfParts=function(r,a){var o=r[r.length-1];return o&&a>o.start&&o.loaded},t.getInitialLiveFragment=function(r,a){var o=this.fragPrevious,l=null;if(o){if(r.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+o.programDateTime),l=(function(p,v,w){if(v===null||!Array.isArray(p)||!p.length||!se(v)||v<(p[0].programDateTime||0)||v>=(p[p.length-1].endProgramDateTime||0))return null;w=w||0;for(var C=0;C<p.length;++C){var k=p[C];if(lm(v,w,k))return k}return null})(a,o.endProgramDateTime,this.config.maxFragLookUpTolerance)),!l){var h=o.sn+1;if(h>=r.startSN&&h<=r.endSN){var u=a[h-r.startSN];o.cc===u.cc&&(l=u,this.log("Live playlist, switching playlist, load frag with next SN: "+l.sn))}l||(l=(function(p,v){return Wu(p,function(w){return w.cc<v?1:w.cc>v?-1:0})})(a,o.cc),l&&this.log("Live playlist, switching playlist, load frag with same CC: "+l.sn))}}else{var f=this.hls.liveSyncPosition;f!==null&&(l=this.getFragmentAtPosition(f,this.bitrateTest?r.fragmentEnd:r.edge,r))}return l},t.getFragmentAtPosition=function(r,a,o){var l,h=this.config,u=this.fragPrevious,f=o.fragments,p=o.endSN,v=o.fragmentHint,w=h.maxFragLookUpTolerance,C=o.partList,k=!!(h.lowLatencyMode&&C!=null&&C.length&&v);if(k&&v&&!this.bitrateTest&&(f=f.concat(v),p=v.sn),l=r<a?ba(u,f,r,r>a-w?0:w):f[f.length-1]){var I=l.sn-o.startSN,D=this.fragmentTracker.getState(l);if((D===wa||D===xi&&l.gap)&&(u=l),u&&l.sn===u.sn&&(!k||C[0].fragment.sn>l.sn)&&u&&l.level===u.level){var B=f[I+1];l=l.sn<p&&this.fragmentTracker.getState(B)!==wa?B:null}}return l},t.synchronizeToLiveEdge=function(r){var a=this.config,o=this.media;if(o){var l=this.hls.liveSyncPosition,h=o.currentTime,u=r.fragments[0].start,f=r.edge,p=h>=u-a.maxFragLookUpTolerance&&h<=f;if(l!==null&&o.duration>l&&(h<l||!p)){var v=a.liveMaxLatencyDuration!==void 0?a.liveMaxLatencyDuration:a.liveMaxLatencyDurationCount*r.targetduration;(!p&&o.readyState<4||h<f-v)&&(this.loadedmetadata||(this.nextLoadPosition=l),o.readyState&&(this.warn("Playback: "+h.toFixed(3)+" is located too far from the end of live sliding playlist: "+f+", reset currentTime to : "+l.toFixed(3)),o.currentTime=l))}}},t.alignPlaylists=function(r,a){var o=this.levels,l=this.levelLastLoaded,h=this.fragPrevious,u=l!==null?o[l]:null,f=r.fragments.length;if(!f)return this.warn("No fragments in live playlist"),0;var p=r.fragments[0].start,v=!a,w=r.alignedSliding&&se(p);if(v||!w&&!p){vm(h,u,r);var C=r.fragments[0].start;return this.log("Live playlist sliding: "+C.toFixed(2)+" start-sn: "+(a?a.startSN:"na")+"->"+r.startSN+" prev-sn: "+(h?h.sn:"na")+" fragments: "+f),C}return p},t.waitForCdnTuneIn=function(r){return r.live&&r.canBlockReload&&r.partTarget&&r.tuneInGoal>Math.max(r.partHoldBack,3*r.partTarget)},t.setStartPosition=function(r,a){var o=this.startPosition;if(o<a&&(o=-1),o===-1||this.lastCurrentTime===-1){var l=this.startTimeOffset!==null,h=l?this.startTimeOffset:r.startTimeOffset;h!==null&&se(h)?(o=a+h,h<0&&(o+=r.totalduration),o=Math.min(Math.max(a,o),a+r.totalduration),this.log("Start time offset "+h+" found in "+(l?"multivariant":"media")+" playlist, adjust startPosition to "+o),this.startPosition=o):r.live?o=this.hls.liveSyncPosition||a:this.startPosition=o=0,this.lastCurrentTime=o}this.nextLoadPosition=o},t.getLoadPosition=function(){var r=this.media,a=0;return this.loadedmetadata&&r?a=r.currentTime:this.nextLoadPosition&&(a=this.nextLoadPosition),a},t.handleFragLoadAborted=function(r,a){this.transmuxer&&r.sn!=="initSegment"&&r.stats.aborted&&(this.warn("Fragment "+r.sn+(a?" part "+a.index:"")+" of level "+r.level+" was aborted"),this.resetFragmentLoading(r))},t.resetFragmentLoading=function(r){this.fragCurrent&&(this.fragContextChanged(r)||this.state===Ri)||(this.state=Qe)},t.onFragmentOrKeyLoadError=function(r,a){if(a.chunkMeta&&!a.frag){var o=this.getCurrentContext(a.chunkMeta);o&&(a.frag=o.frag)}var l=a.frag;if(l&&l.type===r&&this.levels)if(this.fragContextChanged(l)){var h;this.warn("Frag load error must match current frag to retry "+l.url+" > "+((h=this.fragCurrent)==null?void 0:h.url))}else{var u=a.details===q.FRAG_GAP;u&&this.fragmentTracker.fragBuffered(l,!0);var f=a.errorAction,p=f||{},v=p.action,w=p.retryCount,C=w===void 0?0:w,k=p.retryConfig;if(f&&v===Ln&&k){var I;this.resetStartWhenNotLoaded((I=this.levelLastLoaded)!=null?I:l.level);var D=cl(k,C);this.warn("Fragment "+l.sn+" of "+r+" "+l.level+" errored with "+a.details+", retrying loading "+(C+1)+"/"+k.maxNumRetry+" in "+D+"ms"),f.resolved=!0,this.retryDate=self.performance.now()+D,this.state=Ri}else k&&f?(this.resetFragmentErrors(r),C<k.maxNumRetry?u||(f.resolved=!0):G.warn(a.details+" reached or exceeded max retry ("+C+")")):f?.action===Or?this.state=si:this.state=Li;this.tickImmediate()}},t.reduceLengthAndFlushBuffer=function(r){if(this.state===Ur||this.state===Pn){var a=r.parent,o=this.getFwdBufferInfo(this.mediaBuffer,a),l=o&&o.len>.5;l&&this.reduceMaxBufferLength(o.len);var h=!l;return h&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+a+" buffer"),r.frag&&(this.fragmentTracker.removeFragment(r.frag),this.nextLoadPosition=r.frag.start),this.resetLoadingState(),h}return!1},t.resetFragmentErrors=function(r){r===Cr&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Vt&&(this.state=Qe)},t.afterBufferFlushed=function(r,a,o){if(r){var l=ct.getBuffered(r);this.fragmentTracker.detectEvictedFragments(a,l,o),this.state===Ea&&this.resetLoadingState()}},t.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Qe},t.resetStartWhenNotLoaded=function(r){if(!this.loadedmetadata){this.startFragRequested=!1;var a=this.levels?this.levels[r].details:null;a!=null&&a.live?(this.startPosition=-1,this.setStartPosition(a,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},t.resetWhenMissingContext=function(r){var a;this.warn("The loading context changed while buffering fragment "+r.sn+" of level "+r.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((a=this.levelLastLoaded)!=null?a:r.level),this.resetLoadingState()},t.removeUnbufferedFrags=function(r){r===void 0&&(r=0),this.fragmentTracker.removeFragmentsInRange(r,1/0,this.playlistType,!1,!0)},t.updateLevelTiming=function(r,a,o,l){var h,u=this,f=o.details;if(f){if(Object.keys(r.elementaryStreams).reduce(function(v,w){var C=r.elementaryStreams[w];if(C){var k=C.endPTS-C.startPTS;if(k<=0)return u.warn("Could not parse fragment "+r.sn+" "+w+" duration reliably ("+k+")"),v||!1;var I=l?0:Gu(f,r,C.startPTS,C.endPTS,C.startDTS,C.endDTS);return u.hls.trigger(x.LEVEL_PTS_UPDATED,{details:f,level:o,drift:I,type:w,frag:r,start:C.startPTS,end:C.endPTS}),!0}return v},!1))o.fragmentError=0;else if(((h=this.transmuxer)==null?void 0:h.error)===null){var p=new Error("Found no media in fragment "+r.sn+" of level "+r.level+" resetting transmuxer to fallback to playlist timing");if(o.fragmentError===0&&(o.fragmentError++,r.gap=!0,this.fragmentTracker.removeFragment(r),this.fragmentTracker.fragBuffered(r,!0)),this.warn(p.message),this.hls.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!1,error:p,frag:r,reason:"Found no media in msn "+r.sn+' of level "'+o.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=Pn,this.hls.trigger(x.FRAG_PARSED,{frag:r,part:a})}else this.warn("level.details undefined")},t.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},t.recoverWorkerError=function(r){var a,o,l;r.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((a=(o=this.levelLastLoaded)!=null?o:(l=this.fragCurrent)==null?void 0:l.level)!=null?a:0),this.resetLoadingState())},F(s,[{key:"state",get:function(){return this._state},set:function(r){var a=this._state;a!==r&&(this._state=r,this.log(a+"->"+r))}}]),s})(pm);function ig(){return self.SourceBuffer||self.WebKitSourceBuffer}function Er(d,s){return d===void 0&&(d=""),s===void 0&&(s=9e4),{type:d,id:-1,pid:-1,inputTimeScale:s,sequenceNumber:-1,samples:[],dropped:0}}var ag=(function(){function d(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var s=d.prototype;return s.resetInitSegment=function(t,r,a,o){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},s.resetTimeStamp=function(t){this.initPTS=t,this.resetContiguity()},s.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},s.canParse=function(t,r){return!1},s.appendFrame=function(t,r,a){},s.demux=function(t,r){this.cachedData&&(t=ni(this.cachedData,t),this.cachedData=null);var a,o=kn(t,0),l=o?o.length:0,h=this._audioTrack,u=this._id3Track,f=o?(function(C){for(var k=pu(C),I=0;I<k.length;I++){var D=k[I];if(fu(D))return Kp(D)}})(o):void 0,p=t.length;for((this.basePTS===null||this.frameIndex===0&&se(f))&&(this.basePTS=Cm(f,r,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),o&&o.length>0&&u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:o,type:ma,duration:Number.POSITIVE_INFINITY});l<p;){if(this.canParse(t,l)){var v=this.appendFrame(h,t,l);v?(this.frameIndex++,this.lastPTS=v.sample.pts,a=l+=v.length):l=p}else Up(t,l)?(o=kn(t,l),u.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:o,type:ma,duration:Number.POSITIVE_INFINITY}),a=l+=o.length):l++;if(l===p&&a!==p){var w=ai(t,a);this.cachedData?this.cachedData=ni(this.cachedData,w):this.cachedData=w}}return{audioTrack:h,videoTrack:Er(),id3Track:u,textTrack:Er()}},s.demuxSampleAes=function(t,r,a){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},s.flush=function(t){var r=this.cachedData;return r&&(this.cachedData=null,this.demux(r,0)),{audioTrack:this._audioTrack,videoTrack:Er(),id3Track:this._id3Track,textTrack:Er()}},s.destroy=function(){},d})(),Cm=function(d,s,t){return se(d)?90*d:9e4*s+(t?9e4*t.baseTime/t.timescale:0)};function ng(d,s){return d[s]===255&&(246&d[s+1])==240}function og(d,s){return 1&d[s+1]?7:9}function bl(d,s){return(3&d[s+3])<<11|d[s+4]<<3|(224&d[s+5])>>>5}function Un(d,s){return s+1<d.length&&ng(d,s)}function Em(d,s){if(Un(d,s)){var t=og(d,s);if(s+t>=d.length)return!1;var r=bl(d,s);if(r<=t)return!1;var a=s+r;return a===d.length||Un(d,a)}return!1}function sg(d,s,t,r,a){if(!d.samplerate){var o=(function(l,h,u,f){var p,v,w,C,k=navigator.userAgent.toLowerCase(),I=f,D=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];p=1+((192&h[u+2])>>>6);var B=(60&h[u+2])>>>2;if(!(B>D.length-1))return w=(1&h[u+2])<<2,w|=(192&h[u+3])>>>6,G.log("manifest codec:"+f+", ADTS type:"+p+", samplingIndex:"+B),/firefox/i.test(k)?B>=6?(p=5,C=new Array(4),v=B-3):(p=2,C=new Array(2),v=B):k.indexOf("android")!==-1?(p=2,C=new Array(2),v=B):(p=5,C=new Array(4),f&&(f.indexOf("mp4a.40.29")!==-1||f.indexOf("mp4a.40.5")!==-1)||!f&&B>=6?v=B-3:((f&&f.indexOf("mp4a.40.2")!==-1&&(B>=6&&w===1||/vivaldi/i.test(k))||!f&&w===1)&&(p=2,C=new Array(2)),v=B)),C[0]=p<<3,C[0]|=(14&B)>>1,C[1]|=(1&B)<<7,C[1]|=w<<3,p===5&&(C[1]|=(14&v)>>1,C[2]=(1&v)<<7,C[2]|=8,C[3]=0),{config:C,samplerate:D[B],channelCount:w,codec:"mp4a.40."+p,manifestCodec:I};l.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+B})})(s,t,r,a);if(!o)return;d.config=o.config,d.samplerate=o.samplerate,d.channelCount=o.channelCount,d.codec=o.codec,d.manifestCodec=o.manifestCodec,G.log("parsed codec:"+d.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function lg(d){return 9216e4/d}function cg(d,s,t,r,a){var o,l=r+a*lg(d.samplerate),h=(function(k,I){var D=og(k,I);if(I+D<=k.length){var B=bl(k,I)-D;if(B>0)return{headerLength:D,frameLength:B}}})(s,t);if(h){var u=h.frameLength,f=h.headerLength,p=f+u,v=Math.max(0,t+p-s.length);v?(o=new Uint8Array(p-f)).set(s.subarray(t+f,s.length),0):o=s.subarray(t+f,t+p);var w={unit:o,pts:l};return v||d.samples.push(w),{sample:w,length:p,missing:v}}var C=s.length-t;return(o=new Uint8Array(C)).set(s.subarray(t,s.length),0),{sample:{unit:o,pts:l},length:C,missing:-1}}var km=(function(d){function s(r,a){var o;return(o=d.call(this)||this).observer=void 0,o.config=void 0,o.observer=r,o.config=a,o}X(s,d);var t=s.prototype;return t.resetInitSegment=function(r,a,o,l){d.prototype.resetInitSegment.call(this,r,a,o,l),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:a,duration:l,inputTimeScale:9e4,dropped:0}},s.probe=function(r){if(!r)return!1;for(var a=(kn(r,0)||[]).length,o=r.length;a<o;a++)if(Em(r,a))return G.log("ADTS sync word found !"),!0;return!1},t.canParse=function(r,a){return(function(o,l){return(function(h,u){return u+5<h.length})(o,l)&&ng(o,l)&&bl(o,l)<=o.length-l})(r,a)},t.appendFrame=function(r,a,o){sg(r,this.observer,a,o,r.manifestCodec);var l=cg(r,a,o,this.basePTS,this.frameIndex);if(l&&l.missing===0)return l},s})(ag),Bm=/\/emsg[-/]ID3/i,Im=(function(){function d(t,r){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=r}var s=d.prototype;return s.resetTimeStamp=function(){},s.resetInitSegment=function(t,r,a,o){var l=this.videoTrack=Er("video",1),h=this.audioTrack=Er("audio",1),u=this.txtTrack=Er("text",1);if(this.id3Track=Er("id3",1),this.timeOffset=0,t!=null&&t.byteLength){var f=bu(t);if(f.video){var p=f.video,v=p.id,w=p.timescale,C=p.codec;l.id=v,l.timescale=u.timescale=w,l.codec=C}if(f.audio){var k=f.audio,I=k.id,D=k.timescale,B=k.codec;h.id=I,h.timescale=D,h.codec=B}u.id=mu.text,l.sampleDuration=0,l.duration=h.duration=o}},s.resetContiguity=function(){this.remainderData=null},d.probe=function(t){return Ye(t=t.length>16384?t.subarray(0,16384):t,["moof"]).length>0},s.demux=function(t,r){this.timeOffset=r;var a=t,o=this.videoTrack,l=this.txtTrack;if(this.config.progressive){this.remainderData&&(a=ni(this.remainderData,t));var h=(function(f){var p={valid:null,remainder:null},v=Ye(f,["moof"]);if(!v)return p;if(v.length<2)return p.remainder=f,p;var w=v[v.length-1];return p.valid=ai(f,0,w.byteOffset-8),p.remainder=ai(f,w.byteOffset-8),p})(a);this.remainderData=h.remainder,o.samples=h.valid||new Uint8Array}else o.samples=a;var u=this.extractID3Track(o,r);return l.samples=wu(r,o),{videoTrack:o,audioTrack:this.audioTrack,id3Track:u,textTrack:this.txtTrack}},s.flush=function(){var t=this.timeOffset,r=this.videoTrack,a=this.txtTrack;r.samples=this.remainderData||new Uint8Array,this.remainderData=null;var o=this.extractID3Track(r,this.timeOffset);return a.samples=wu(t,r),{videoTrack:r,audioTrack:Er(),id3Track:o,textTrack:Er()}},s.extractID3Track=function(t,r){var a=this.id3Track;if(t.samples.length){var o=Ye(t.samples,["emsg"]);o&&o.forEach(function(l){var h=(function(v){var w=v[0],C="",k="",I=0,D=0,B=0,T=0,U=0,M=0;if(w===0){for(;yt(v.subarray(M,M+1))!=="\0";)C+=yt(v.subarray(M,M+1)),M+=1;for(C+=yt(v.subarray(M,M+1)),M+=1;yt(v.subarray(M,M+1))!=="\0";)k+=yt(v.subarray(M,M+1)),M+=1;k+=yt(v.subarray(M,M+1)),M+=1,I=Re(v,12),D=Re(v,16),T=Re(v,20),U=Re(v,24),M=28}else if(w===1){I=Re(v,M+=4);var H=Re(v,M+=4),V=Re(v,M+=4);for(M+=4,B=Math.pow(2,32)*H+V,Number.isSafeInteger(B)||(B=Number.MAX_SAFE_INTEGER,G.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),T=Re(v,M),U=Re(v,M+=4),M+=4;yt(v.subarray(M,M+1))!=="\0";)C+=yt(v.subarray(M,M+1)),M+=1;for(C+=yt(v.subarray(M,M+1)),M+=1;yt(v.subarray(M,M+1))!=="\0";)k+=yt(v.subarray(M,M+1)),M+=1;k+=yt(v.subarray(M,M+1)),M+=1}return{schemeIdUri:C,value:k,timeScale:I,presentationTime:B,presentationTimeDelta:D,eventDuration:T,id:U,payload:v.subarray(M,v.byteLength)}})(l);if(Bm.test(h.schemeIdUri)){var u=se(h.presentationTime)?h.presentationTime/h.timeScale:r+h.presentationTimeDelta/h.timeScale,f=h.eventDuration===4294967295?Number.POSITIVE_INFINITY:h.eventDuration/h.timeScale;f<=.001&&(f=Number.POSITIVE_INFINITY);var p=h.payload;a.samples.push({data:p,len:p.byteLength,dts:u,pts:u,type:va,duration:f})}})}return a},s.demuxSampleAes=function(t,r,a){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},s.destroy=function(){},d})(),Qn=null,Sm=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],xm=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Tm=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Dm=[0,1,1,4];function dg(d,s,t,r,a){if(!(t+24>s.length)){var o=hg(s,t);if(o&&t+o.frameLength<=s.length){var l=r+a*(9e4*o.samplesPerFrame/o.sampleRate),h={unit:s.subarray(t,t+o.frameLength),pts:l,dts:l};return d.config=[],d.channelCount=o.channelCount,d.samplerate=o.sampleRate,d.samples.push(h),{sample:h,length:o.frameLength,missing:0}}}}function hg(d,s){var t=d[s+1]>>3&3,r=d[s+1]>>1&3,a=d[s+2]>>4&15,o=d[s+2]>>2&3;if(t!==1&&a!==0&&a!==15&&o!==3){var l=d[s+2]>>1&1,h=d[s+3]>>6,u=1e3*Sm[14*(t===3?3-r:r===3?3:4)+a-1],f=xm[3*(t===3?0:t===2?1:2)+o],p=h===3?1:2,v=Tm[t][r],w=Dm[r],C=8*v*w,k=Math.floor(v*u/f+l)*w;if(Qn===null){var I=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Qn=I?parseInt(I[1]):0}return Qn&&Qn<=87&&r===2&&u>=224e3&&h===0&&(d[s+3]=128|d[s+3]),{sampleRate:f,channelCount:p,frameLength:k,samplesPerFrame:C}}}function yl(d,s){return d[s]===255&&(224&d[s+1])==224&&(6&d[s+1])!=0}function ug(d,s){return s+1<d.length&&yl(d,s)}function Rm(d,s){if(s+1<d.length&&yl(d,s)){var t=hg(d,s),r=4;t!=null&&t.frameLength&&(r=t.frameLength);var a=s+r;return a===d.length||ug(d,a)}return!1}var gg=(function(){function d(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}var s=d.prototype;return s.loadWord=function(){var t=this.data,r=this.bytesAvailable,a=t.byteLength-r,o=new Uint8Array(4),l=Math.min(4,r);if(l===0)throw new Error("no bytes available");o.set(t.subarray(a,a+l)),this.word=new DataView(o.buffer).getUint32(0),this.bitsAvailable=8*l,this.bytesAvailable-=l},s.skipBits=function(t){var r;t=Math.min(t,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,t-=(r=t>>3)<<3,this.bytesAvailable-=r,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},s.readBits=function(t){var r=Math.min(this.bitsAvailable,t),a=this.word>>>32-r;if(t>32&&G.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=r,this.bitsAvailable>0)this.word<<=r;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(r=t-r)>0&&this.bitsAvailable?a<<r|this.readBits(r):a},s.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if((this.word&2147483648>>>t)!=0)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},s.skipUEG=function(){this.skipBits(1+this.skipLZ())},s.skipEG=function(){this.skipBits(1+this.skipLZ())},s.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},s.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},s.readBoolean=function(){return this.readBits(1)===1},s.readUByte=function(){return this.readBits(8)},s.readUShort=function(){return this.readBits(16)},s.readUInt=function(){return this.readBits(32)},s.skipScalingList=function(t){for(var r=8,a=8,o=0;o<t;o++)a!==0&&(a=(r+this.readEG()+256)%256),r=a===0?r:a},s.readSPS=function(){var t,r,a,o=0,l=0,h=0,u=0,f=this.readUByte.bind(this),p=this.readBits.bind(this),v=this.readUEG.bind(this),w=this.readBoolean.bind(this),C=this.skipBits.bind(this),k=this.skipEG.bind(this),I=this.skipUEG.bind(this),D=this.skipScalingList.bind(this);f();var B=f();if(p(5),C(3),f(),I(),B===100||B===110||B===122||B===244||B===44||B===83||B===86||B===118||B===128){var T=v();if(T===3&&C(1),I(),I(),C(1),w())for(r=T!==3?8:12,a=0;a<r;a++)w()&&D(a<6?16:64)}I();var U=v();if(U===0)v();else if(U===1)for(C(1),k(),k(),t=v(),a=0;a<t;a++)k();I(),C(1);var M=v(),H=v(),V=p(1);V===0&&C(1),C(1),w()&&(o=v(),l=v(),h=v(),u=v());var W=[1,1];if(w()&&w())switch(f()){case 1:W=[1,1];break;case 2:W=[12,11];break;case 3:W=[10,11];break;case 4:W=[16,11];break;case 5:W=[40,33];break;case 6:W=[24,11];break;case 7:W=[20,11];break;case 8:W=[32,11];break;case 9:W=[80,33];break;case 10:W=[18,11];break;case 11:W=[15,11];break;case 12:W=[64,33];break;case 13:W=[160,99];break;case 14:W=[4,3];break;case 15:W=[3,2];break;case 16:W=[2,1];break;case 255:W=[f()<<8|f(),f()<<8|f()]}return{width:Math.ceil(16*(M+1)-2*o-2*l),height:(2-V)*(H+1)*16-(V?2:4)*(h+u),pixelRatio:W}},s.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},d})(),Lm=(function(){function d(t,r,a){this.keyData=void 0,this.decrypter=void 0,this.keyData=a,this.decrypter=new ml(r,{removePKCS7Padding:!1})}var s=d.prototype;return s.decryptBuffer=function(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)},s.decryptAacSample=function(t,r,a){var o=this,l=t[r].unit;if(!(l.length<=16)){var h=l.subarray(16,l.length-l.length%16),u=h.buffer.slice(h.byteOffset,h.byteOffset+h.length);this.decryptBuffer(u).then(function(f){var p=new Uint8Array(f);l.set(p,16),o.decrypter.isSync()||o.decryptAacSamples(t,r+1,a)})}},s.decryptAacSamples=function(t,r,a){for(;;r++){if(r>=t.length)return void a();if(!(t[r].unit.length<32||(this.decryptAacSample(t,r,a),this.decrypter.isSync())))return}},s.getAvcEncryptedData=function(t){for(var r=16*Math.floor((t.length-48)/160)+16,a=new Int8Array(r),o=0,l=32;l<t.length-16;l+=160,o+=16)a.set(t.subarray(l,l+16),o);return a},s.getAvcDecryptedUnit=function(t,r){for(var a=new Uint8Array(r),o=0,l=32;l<t.length-16;l+=160,o+=16)t.set(a.subarray(o,o+16),l);return t},s.decryptAvcSample=function(t,r,a,o,l){var h=this,u=Eu(l.data),f=this.getAvcEncryptedData(u);this.decryptBuffer(f.buffer).then(function(p){l.data=h.getAvcDecryptedUnit(u,p),h.decrypter.isSync()||h.decryptAvcSamples(t,r,a+1,o)})},s.decryptAvcSamples=function(t,r,a,o){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;r++,a=0){if(r>=t.length)return void o();for(var l=t[r].units;!(a>=l.length);a++){var h=l[a];if(!(h.data.length<=48||h.type!==1&&h.type!==5||(this.decryptAvcSample(t,r,a,o,h),this.decrypter.isSync())))return}}},d})(),Lt=188,Mm=(function(){function d(t,r,a){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=r,this.typeSupported=a}d.probe=function(t){var r=d.syncOffset(t);return r>0&&G.warn("MPEG2-TS detected but first sync word found @ offset "+r),r!==-1},d.syncOffset=function(t){for(var r=t.length,a=Math.min(940,t.length-Lt)+1,o=0;o<a;){for(var l=!1,h=-1,u=0,f=o;f<r;f+=Lt){if(t[f]!==71){if(u)return-1;break}if(u++,h===-1&&(h=f)!==0&&(a=Math.min(h+18612,t.length-Lt)+1),l||(l=wl(t,f)===0),l&&u>1&&(h===0&&u>2||f+Lt>a))return h}o++}return-1},d.createTrack=function(t,r){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:mu[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?r:void 0}};var s=d.prototype;return s.resetInitSegment=function(t,r,a,o){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=d.createTrack("video"),this._audioTrack=d.createTrack("audio",o),this._id3Track=d.createTrack("id3"),this._txtTrack=d.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=a,this._duration=o},s.resetTimeStamp=function(){},s.resetContiguity=function(){var t=this._audioTrack,r=this._avcTrack,a=this._id3Track;t&&(t.pesData=null),r&&(r.pesData=null),a&&(a.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},s.demux=function(t,r,a,o){var l;a===void 0&&(a=!1),o===void 0&&(o=!1),a||(this.sampleAes=null);var h=this._avcTrack,u=this._audioTrack,f=this._id3Track,p=this._txtTrack,v=h.pid,w=h.pesData,C=u.pid,k=f.pid,I=u.pesData,D=f.pesData,B=null,T=this.pmtParsed,U=this._pmtId,M=t.length;if(this.remainderData&&(M=(t=ni(this.remainderData,t)).length,this.remainderData=null),M<Lt&&!o)return this.remainderData=t,{audioTrack:u,videoTrack:h,id3Track:f,textTrack:p};var H=Math.max(0,d.syncOffset(t));(M-=(M-H)%Lt)<t.byteLength&&!o&&(this.remainderData=new Uint8Array(t.buffer,M,t.buffer.byteLength-M));for(var V=0,W=H;W<M;W+=Lt)if(t[W]===71){var $=!!(64&t[W+1]),J=wl(t,W),j=void 0;if((48&t[W+3])>>4>1){if((j=W+5+t[W+4])===W+Lt)continue}else j=W+4;switch(J){case v:$&&(w&&(l=Mi(w))&&this.parseAVCPES(h,p,l,!1),w={data:[],size:0}),w&&(w.data.push(t.subarray(j,W+Lt)),w.size+=W+Lt-j);break;case C:if($){if(I&&(l=Mi(I)))switch(u.segmentCodec){case"aac":this.parseAACPES(u,l);break;case"mp3":this.parseMPEGPES(u,l)}I={data:[],size:0}}I&&(I.data.push(t.subarray(j,W+Lt)),I.size+=W+Lt-j);break;case k:$&&(D&&(l=Mi(D))&&this.parseID3PES(f,l),D={data:[],size:0}),D&&(D.data.push(t.subarray(j,W+Lt)),D.size+=W+Lt-j);break;case 0:$&&(j+=t[j]+1),U=this._pmtId=Fm(t,j);break;case U:$&&(j+=t[j]+1);var le=Om(t,j,this.typeSupported,a);(v=le.avc)>0&&(h.pid=v),(C=le.audio)>0&&(u.pid=C,u.segmentCodec=le.segmentCodec),(k=le.id3)>0&&(f.pid=k),B===null||T||(G.warn("MPEG-TS PMT found at "+W+" after unknown PID '"+B+"'. Backtracking to sync byte @"+H+" to parse all TS packets."),B=null,W=H-188),T=this.pmtParsed=!0;break;case 17:case 8191:break;default:B=J}}else V++;if(V>0){var ie=new Error("Found "+V+" TS packet/s that do not start with 0x47");this.observer.emit(x.ERROR,x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!1,error:ie,reason:ie.message})}h.pesData=w,u.pesData=I,f.pesData=D;var me={audioTrack:u,videoTrack:h,id3Track:f,textTrack:p};return o&&this.extractRemainingSamples(me),me},s.flush=function(){var t,r=this.remainderData;return this.remainderData=null,t=r?this.demux(r,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},s.extractRemainingSamples=function(t){var r,a=t.audioTrack,o=t.videoTrack,l=t.id3Track,h=t.textTrack,u=o.pesData,f=a.pesData,p=l.pesData;if(u&&(r=Mi(u))?(this.parseAVCPES(o,h,r,!0),o.pesData=null):o.pesData=u,f&&(r=Mi(f))){switch(a.segmentCodec){case"aac":this.parseAACPES(a,r);break;case"mp3":this.parseMPEGPES(a,r)}a.pesData=null}else f!=null&&f.size&&G.log("last AAC PES packet truncated,might overlap between fragments"),a.pesData=f;p&&(r=Mi(p))?(this.parseID3PES(l,r),l.pesData=null):l.pesData=p},s.demuxSampleAes=function(t,r,a){var o=this.demux(t,a,!0,!this.config.progressive),l=this.sampleAes=new Lm(this.observer,this.config,r);return this.decrypt(o,l)},s.decrypt=function(t,r){return new Promise(function(a){var o=t.audioTrack,l=t.videoTrack;o.samples&&o.segmentCodec==="aac"?r.decryptAacSamples(o.samples,0,function(){l.samples?r.decryptAvcSamples(l.samples,0,0,function(){a(t)}):a(t)}):l.samples&&r.decryptAvcSamples(l.samples,0,0,function(){a(t)})})},s.destroy=function(){this._duration=0},s.parseAVCPES=function(t,r,a,o){var l,h=this,u=this.parseAVCNALu(t,a.data),f=this.avcSample,p=!1;a.data=null,f&&u.length&&!t.audFound&&(Ba(f,t),f=this.avcSample=Nn(!1,a.pts,a.dts,"")),u.forEach(function(v){var w;switch(v.type){case 1:var C=!1;l=!0;var k,I=v.data;if(p&&I.length>4){var D=new gg(I).readSliceType();D!==2&&D!==4&&D!==7&&D!==9||(C=!0)}C&&(k=f)!=null&&k.frame&&!f.key&&(Ba(f,t),f=h.avcSample=null),f||(f=h.avcSample=Nn(!0,a.pts,a.dts,"")),f.frame=!0,f.key=C;break;case 5:l=!0,(w=f)!=null&&w.frame&&!f.key&&(Ba(f,t),f=h.avcSample=null),f||(f=h.avcSample=Nn(!0,a.pts,a.dts,"")),f.key=!0,f.frame=!0;break;case 6:l=!0,Cu(v.data,1,a.pts,r.samples);break;case 7:if(l=!0,p=!0,!t.sps){var B=v.data,T=new gg(B).readSPS();t.width=T.width,t.height=T.height,t.pixelRatio=T.pixelRatio,t.sps=[B],t.duration=h._duration;for(var U=B.subarray(1,4),M="avc1.",H=0;H<3;H++){var V=U[H].toString(16);V.length<2&&(V="0"+V),M+=V}t.codec=M}break;case 8:l=!0,t.pps||(t.pps=[v.data]);break;case 9:l=!1,t.audFound=!0,f&&Ba(f,t),f=h.avcSample=Nn(!1,a.pts,a.dts,"");break;case 12:l=!0;break;default:l=!1,f&&(f.debug+="unknown NAL "+v.type+" ")}f&&l&&f.units.push(v)}),o&&f&&(Ba(f,t),this.avcSample=null)},s.getLastNalUnit=function(t){var r,a,o=this.avcSample;if(o&&o.units.length!==0||(o=t[t.length-1]),(r=o)!=null&&r.units){var l=o.units;a=l[l.length-1]}return a},s.parseAVCNALu=function(t,r){var a,o,l=r.byteLength,h=t.naluState||0,u=h,f=[],p=0,v=-1,w=0;for(h===-1&&(v=0,w=31&r[0],h=0,p=1);p<l;)if(a=r[p++],h)if(h!==1)if(a)if(a===1){if(v>=0){var C={data:r.subarray(v,p-h-1),type:w};f.push(C)}else{var k=this.getLastNalUnit(t.samples);if(k&&(u&&p<=4-u&&k.state&&(k.data=k.data.subarray(0,k.data.byteLength-u)),(o=p-h-1)>0)){var I=new Uint8Array(k.data.byteLength+o);I.set(k.data,0),I.set(r.subarray(0,o),k.data.byteLength),k.data=I,k.state=0}}p<l?(v=p,w=31&r[p],h=0):h=-1}else h=0;else h=3;else h=a?0:2;else h=a?0:1;if(v>=0&&h>=0){var D={data:r.subarray(v,l),type:w,state:h};f.push(D)}if(f.length===0){var B=this.getLastNalUnit(t.samples);if(B){var T=new Uint8Array(B.data.byteLength+r.byteLength);T.set(B.data,0),T.set(r,B.data.byteLength),B.data=T}}return t.naluState=h,f},s.parseAACPES=function(t,r){var a,o,l,h=0,u=this.aacOverFlow,f=r.data;if(u){this.aacOverFlow=null;var p=u.missing,v=u.sample.unit.byteLength;if(p===-1){var w=new Uint8Array(v+f.byteLength);w.set(u.sample.unit,0),w.set(f,v),f=w}else{var C=v-p;u.sample.unit.set(f.subarray(0,p),C),t.samples.push(u.sample),h=u.missing}}for(a=h,o=f.length;a<o-1&&!Un(f,a);a++);if(a!==h){var k,I=a<o-1;k=I?"AAC PES did not start with ADTS header,offset:"+a:"No ADTS header found in AAC PES";var D=new Error(k);if(G.warn("parsing error: "+k),this.observer.emit(x.ERROR,x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!1,levelRetry:I,error:D,reason:k}),!I)return}if(sg(t,this.observer,f,a,this.audioCodec),r.pts!==void 0)l=r.pts;else{if(!u)return void G.warn("[tsdemuxer]: AAC PES unknown PTS");var B=lg(t.samplerate);l=u.sample.pts+B}for(var T,U=0;a<o;){if(a+=(T=cg(t,f,a,l,U)).length,T.missing){this.aacOverFlow=T;break}for(U++;a<o-1&&!Un(f,a);a++);}},s.parseMPEGPES=function(t,r){var a=r.data,o=a.length,l=0,h=0,u=r.pts;if(u!==void 0)for(;h<o;)if(ug(a,h)){var f=dg(t,a,h,u,l);if(!f)break;h+=f.length,l++}else h++;else G.warn("[tsdemuxer]: MPEG PES unknown PTS")},s.parseID3PES=function(t,r){if(r.pts!==void 0){var a=Y({},r,{type:this._avcTrack?va:ma,duration:Number.POSITIVE_INFINITY});t.samples.push(a)}else G.warn("[tsdemuxer]: ID3 PES unknown PTS")},d})();function Nn(d,s,t,r){return{key:d,frame:!1,pts:s,dts:t,units:[],debug:r,length:0}}function wl(d,s){return((31&d[s+1])<<8)+d[s+2]}function Fm(d,s){return(31&d[s+10])<<8|d[s+11]}function Om(d,s,t,r){var a={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},o=s+3+((15&d[s+1])<<8|d[s+2])-4;for(s+=12+((15&d[s+10])<<8|d[s+11]);s<o;){var l=wl(d,s);switch(d[s]){case 207:if(!r){G.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:a.audio===-1&&(a.audio=l);break;case 21:a.id3===-1&&(a.id3=l);break;case 219:if(!r){G.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:a.avc===-1&&(a.avc=l);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?G.log("MPEG audio found, not supported in this browser"):a.audio===-1&&(a.audio=l,a.segmentCodec="mp3");break;case 36:G.warn("Unsupported HEVC stream type found")}s+=5+((15&d[s+3])<<8|d[s+4])}return a}function Mi(d){var s,t,r,a,o,l=0,h=d.data;if(!d||d.size===0)return null;for(;h[0].length<19&&h.length>1;){var u=new Uint8Array(h[0].length+h[1].length);u.set(h[0]),u.set(h[1],h[0].length),h[0]=u,h.splice(1,1)}if(((s=h[0])[0]<<16)+(s[1]<<8)+s[2]===1){if((t=(s[4]<<8)+s[5])&&t>d.size-6)return null;var f=s[7];192&f&&(a=536870912*(14&s[9])+4194304*(255&s[10])+16384*(254&s[11])+128*(255&s[12])+(254&s[13])/2,64&f?a-(o=536870912*(14&s[14])+4194304*(255&s[15])+16384*(254&s[16])+128*(255&s[17])+(254&s[18])/2)>54e5&&(G.warn(Math.round((a-o)/9e4)+"s delta between PTS and DTS, align them"),a=o):o=a);var p=(r=s[8])+9;if(d.size<=p)return null;d.size-=p;for(var v=new Uint8Array(d.size),w=0,C=h.length;w<C;w++){var k=(s=h[w]).byteLength;if(p){if(p>k){p-=k;continue}s=s.subarray(p),k-=p,p=0}v.set(s,l),l+=k}return t&&(t-=r+3),{data:v,pts:a,dts:o,len:t}}return null}function Ba(d,s){if(d.units.length&&d.frame){if(d.pts===void 0){var t=s.samples,r=t.length;if(!r)return void s.dropped++;var a=t[r-1];d.pts=a.pts,d.dts=a.dts}s.samples.push(d)}d.debug.length&&G.log(d.pts+"/"+d.dts+":"+d.debug)}var Pm=(function(d){function s(){return d.apply(this,arguments)||this}X(s,d);var t=s.prototype;return t.resetInitSegment=function(r,a,o,l){d.prototype.resetInitSegment.call(this,r,a,o,l),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:a,duration:l,inputTimeScale:9e4,dropped:0}},s.probe=function(r){if(!r)return!1;for(var a=(kn(r,0)||[]).length,o=r.length;a<o;a++)if(Rm(r,a))return G.log("MPEG Audio sync word found !"),!0;return!1},t.canParse=function(r,a){return(function(o,l){return yl(o,l)&&4<=o.length-l})(r,a)},t.appendFrame=function(r,a,o){if(this.basePTS!==null)return dg(r,a,o,this.basePTS,this.frameIndex)},s})(ag),fg=(function(){function d(){}return d.getSilentFrame=function(s,t){if(s==="mp4a.40.2"){if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},d})(),Xr=Math.pow(2,32)-1,wt=(function(){function d(){}return d.init=function(){var s;for(s in d.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},d.types)d.types.hasOwnProperty(s)&&(d.types[s]=[s.charCodeAt(0),s.charCodeAt(1),s.charCodeAt(2),s.charCodeAt(3)]);d.HDLR_TYPES={video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])};var t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]);d.STTS=d.STSC=d.STCO=new Uint8Array([0,0,0,0,0,0,0,0]),d.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),d.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),d.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),d.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var r=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),o=new Uint8Array([0,0,0,1]);d.FTYP=d.box(d.types.ftyp,r,o,r,a),d.DINF=d.box(d.types.dinf,d.box(d.types.dref,t))},d.box=function(s){for(var t=8,r=arguments.length,a=new Array(r>1?r-1:0),o=1;o<r;o++)a[o-1]=arguments[o];for(var l=a.length,h=l;l--;)t+=a[l].byteLength;var u=new Uint8Array(t);for(u[0]=t>>24&255,u[1]=t>>16&255,u[2]=t>>8&255,u[3]=255&t,u.set(s,4),l=0,t=8;l<h;l++)u.set(a[l],t),t+=a[l].byteLength;return u},d.hdlr=function(s){return d.box(d.types.hdlr,d.HDLR_TYPES[s])},d.mdat=function(s){return d.box(d.types.mdat,s)},d.mdhd=function(s,t){t*=s;var r=Math.floor(t/(Xr+1)),a=Math.floor(t%(Xr+1));return d.box(d.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,s>>24&255,s>>16&255,s>>8&255,255&s,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},d.mdia=function(s){return d.box(d.types.mdia,d.mdhd(s.timescale,s.duration),d.hdlr(s.type),d.minf(s))},d.mfhd=function(s){return d.box(d.types.mfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s]))},d.minf=function(s){return s.type==="audio"?d.box(d.types.minf,d.box(d.types.smhd,d.SMHD),d.DINF,d.stbl(s)):d.box(d.types.minf,d.box(d.types.vmhd,d.VMHD),d.DINF,d.stbl(s))},d.moof=function(s,t,r){return d.box(d.types.moof,d.mfhd(s),d.traf(r,t))},d.moov=function(s){for(var t=s.length,r=[];t--;)r[t]=d.trak(s[t]);return d.box.apply(null,[d.types.moov,d.mvhd(s[0].timescale,s[0].duration)].concat(r).concat(d.mvex(s)))},d.mvex=function(s){for(var t=s.length,r=[];t--;)r[t]=d.trex(s[t]);return d.box.apply(null,[d.types.mvex].concat(r))},d.mvhd=function(s,t){t*=s;var r=Math.floor(t/(Xr+1)),a=Math.floor(t%(Xr+1)),o=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,s>>24&255,s>>16&255,s>>8&255,255&s,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a,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 d.box(d.types.mvhd,o)},d.sdtp=function(s){var t,r,a=s.samples||[],o=new Uint8Array(4+a.length);for(t=0;t<a.length;t++)r=a[t].flags,o[t+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return d.box(d.types.sdtp,o)},d.stbl=function(s){return d.box(d.types.stbl,d.stsd(s),d.box(d.types.stts,d.STTS),d.box(d.types.stsc,d.STSC),d.box(d.types.stsz,d.STSZ),d.box(d.types.stco,d.STCO))},d.avc1=function(s){var t,r,a,o=[],l=[];for(t=0;t<s.sps.length;t++)a=(r=s.sps[t]).byteLength,o.push(a>>>8&255),o.push(255&a),o=o.concat(Array.prototype.slice.call(r));for(t=0;t<s.pps.length;t++)a=(r=s.pps[t]).byteLength,l.push(a>>>8&255),l.push(255&a),l=l.concat(Array.prototype.slice.call(r));var h=d.box(d.types.avcC,new Uint8Array([1,o[3],o[4],o[5],255,224|s.sps.length].concat(o).concat([s.pps.length]).concat(l))),u=s.width,f=s.height,p=s.pixelRatio[0],v=s.pixelRatio[1];return d.box(d.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,u>>8&255,255&u,f>>8&255,255&f,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),h,d.box(d.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),d.box(d.types.pasp,new Uint8Array([p>>24,p>>16&255,p>>8&255,255&p,v>>24,v>>16&255,v>>8&255,255&v])))},d.esds=function(s){var t=s.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(s.config).concat([6,1,2]))},d.mp4a=function(s){var t=s.samplerate;return d.box(d.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,s.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]),d.box(d.types.esds,d.esds(s)))},d.mp3=function(s){var t=s.samplerate;return d.box(d.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,s.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]))},d.stsd=function(s){return s.type==="audio"?s.segmentCodec==="mp3"&&s.codec==="mp3"?d.box(d.types.stsd,d.STSD,d.mp3(s)):d.box(d.types.stsd,d.STSD,d.mp4a(s)):d.box(d.types.stsd,d.STSD,d.avc1(s))},d.tkhd=function(s){var t=s.id,r=s.duration*s.timescale,a=s.width,o=s.height,l=Math.floor(r/(Xr+1)),h=Math.floor(r%(Xr+1));return d.box(d.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,l>>24,l>>16&255,l>>8&255,255&l,h>>24,h>>16&255,h>>8&255,255&h,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,o>>8&255,255&o,0,0]))},d.traf=function(s,t){var r=d.sdtp(s),a=s.id,o=Math.floor(t/(Xr+1)),l=Math.floor(t%(Xr+1));return d.box(d.types.traf,d.box(d.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),d.box(d.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,l>>24,l>>16&255,l>>8&255,255&l])),d.trun(s,r.length+16+20+8+16+8+8),r)},d.trak=function(s){return s.duration=s.duration||4294967295,d.box(d.types.trak,d.tkhd(s),d.mdia(s))},d.trex=function(s){var t=s.id;return d.box(d.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},d.trun=function(s,t){var r,a,o,l,h,u,f=s.samples||[],p=f.length,v=12+16*p,w=new Uint8Array(v);for(t+=8+v,w.set([s.type==="video"?1:0,0,15,1,p>>>24&255,p>>>16&255,p>>>8&255,255&p,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),r=0;r<p;r++)o=(a=f[r]).duration,l=a.size,h=a.flags,u=a.cts,w.set([o>>>24&255,o>>>16&255,o>>>8&255,255&o,l>>>24&255,l>>>16&255,l>>>8&255,255&l,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,61440&h.degradPrio,15&h.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*r);return d.box(d.types.trun,w)},d.initSegment=function(s){d.types||d.init();var t=d.moov(s),r=new Uint8Array(d.FTYP.byteLength+t.byteLength);return r.set(d.FTYP),r.set(t,d.FTYP.byteLength),r},d})();function Cl(d,s,t,r){t===void 0&&(t=1),r===void 0&&(r=!1);var a=d*s*t;return r?Math.round(a):a}function Ia(d,s){return s===void 0&&(s=!1),Cl(d,1e3,1/9e4,s)}wt.types=void 0,wt.HDLR_TYPES=void 0,wt.STTS=void 0,wt.STSC=void 0,wt.STCO=void 0,wt.STSZ=void 0,wt.VMHD=void 0,wt.SMHD=void 0,wt.STSD=void 0,wt.FTYP=void 0,wt.DINF=void 0;var Hn=null,El=null,kl=(function(){function d(t,r,a,o){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=r,this.typeSupported=a,this.ISGenerated=!1,Hn===null){var l=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Hn=l?parseInt(l[1]):0}if(El===null){var h=navigator.userAgent.match(/Safari\/(\d+)/i);El=h?parseInt(h[1]):0}}var s=d.prototype;return s.destroy=function(){},s.resetTimeStamp=function(t){G.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},s.resetNextTimestamp=function(){G.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},s.resetInitSegment=function(){G.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},s.getVideoStartPts=function(t){var r=!1,a=t.reduce(function(o,l){var h=l.pts-o;return h<-4294967296?(r=!0,Wt(o,l.pts)):h>0?o:l.pts},t[0].pts);return r&&G.debug("PTS rollover detected"),a},s.remux=function(t,r,a,o,l,h,u,f){var p,v,w,C,k,I,D=l,B=l,T=t.pid>-1,U=r.pid>-1,M=r.samples.length,H=t.samples.length>0,V=u&&M>0||M>1;if((!T||H)&&(!U||V)||this.ISGenerated||u){this.ISGenerated||(w=this.generateIS(t,r,l,h));var W,$=this.isVideoContiguous,J=-1;if(V&&(J=(function(we){for(var ve=0;ve<we.length;ve++)if(we[ve].key)return ve;return-1})(r.samples),!$&&this.config.forceKeyFrameOnDiscontinuity))if(I=!0,J>0){G.warn("[mp4-remuxer]: Dropped "+J+" out of "+M+" video samples due to a missing keyframe");var j=this.getVideoStartPts(r.samples);r.samples=r.samples.slice(J),r.dropped+=J,W=B+=(r.samples[0].pts-j)/r.inputTimeScale}else J===-1&&(G.warn("[mp4-remuxer]: No keyframe found out of "+M+" video samples"),I=!1);if(this.ISGenerated){if(H&&V){var le=this.getVideoStartPts(r.samples),ie=(Wt(t.samples[0].pts,le)-le)/r.inputTimeScale;D+=Math.max(0,ie),B+=Math.max(0,-ie)}if(H){if(t.samplerate||(G.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),w=this.generateIS(t,r,l,h)),v=this.remuxAudio(t,D,this.isAudioContiguous,h,U||V||f===Cr?B:void 0),V){var me=v?v.endPTS-v.startPTS:0;r.inputTimeScale||(G.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),w=this.generateIS(t,r,l,h)),p=this.remuxVideo(r,B,$,me)}}else V&&(p=this.remuxVideo(r,B,$,0));p&&(p.firstKeyFrame=J,p.independent=J!==-1,p.firstKeyFramePTS=W)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(a.samples.length&&(k=pg(a,l,this._initPTS,this._initDTS)),o.samples.length&&(C=mg(o,l,this._initPTS))),{audio:v,video:p,initSegment:w,independent:I,text:C,id3:k}},s.generateIS=function(t,r,a,o){var l,h,u,f=t.samples,p=r.samples,v=this.typeSupported,w={},C=this._initPTS,k=!C||o,I="audio/mp4";if(k&&(l=h=1/0),t.config&&f.length&&(t.timescale=t.samplerate,t.segmentCodec==="mp3"&&(v.mpeg?(I="audio/mpeg",t.codec=""):v.mp3&&(t.codec="mp3")),w.audio={id:"audio",container:I,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&v.mpeg?new Uint8Array(0):wt.initSegment([t]),metadata:{channelCount:t.channelCount}},k&&(u=t.inputTimeScale,C&&u===C.timescale?k=!1:l=h=f[0].pts-Math.round(u*a))),r.sps&&r.pps&&p.length&&(r.timescale=r.inputTimeScale,w.video={id:"main",container:"video/mp4",codec:r.codec,initSegment:wt.initSegment([r]),metadata:{width:r.width,height:r.height}},k))if(u=r.inputTimeScale,C&&u===C.timescale)k=!1;else{var D=this.getVideoStartPts(p),B=Math.round(u*a);h=Math.min(h,Wt(p[0].dts,D)-B),l=Math.min(l,D-B)}if(Object.keys(w).length)return this.ISGenerated=!0,k?(this._initPTS={baseTime:l,timescale:u},this._initDTS={baseTime:h,timescale:u}):l=u=void 0,{tracks:w,initPTS:l,timescale:u}},s.remuxVideo=function(t,r,a,o){var l,h,u=t.inputTimeScale,f=t.samples,p=[],v=f.length,w=this._initPTS,C=this.nextAvcDts,k=8,I=this.videoSampleDuration,D=Number.POSITIVE_INFINITY,B=Number.NEGATIVE_INFINITY,T=!1;a&&C!==null||(C=r*u-(f[0].pts-Wt(f[0].dts,f[0].pts)));for(var U=w.baseTime*u/w.timescale,M=0;M<v;M++){var H=f[M];H.pts=Wt(H.pts-U,C),H.dts=Wt(H.dts-U,C),H.dts<f[M>0?M-1:M].dts&&(T=!0)}T&&f.sort(function(Jn,Zg){var F1=Jn.dts-Zg.dts,O1=Jn.pts-Zg.pts;return F1||O1}),l=f[0].dts;var V=(h=f[f.length-1].dts)-l,W=V?Math.round(V/(v-1)):I||t.inputTimeScale/30;if(a){var $=l-C,J=$>W,j=$<-1;if((J||j)&&(J?G.warn("AVC: "+Ia($,!0)+" ms ("+$+"dts) hole between fragments detected, filling it"):G.warn("AVC: "+Ia(-$,!0)+" ms ("+$+"dts) overlapping between fragments detected"),!j||C>=f[0].pts)){l=C;var le=f[0].pts-$;f[0].dts=l,f[0].pts=le,G.log("Video: First PTS/DTS adjusted: "+Ia(le,!0)+"/"+Ia(l,!0)+", delta: "+Ia($,!0)+" ms")}}l=Math.max(0,l);for(var ie=0,me=0,we=0;we<v;we++){for(var ve=f[we],Ae=ve.units,Ie=Ae.length,fe=0,Pe=0;Pe<Ie;Pe++)fe+=Ae[Pe].data.length;me+=fe,ie+=Ie,ve.length=fe,ve.dts=Math.max(ve.dts,l),D=Math.min(ve.pts,D),B=Math.max(ve.pts,B)}h=f[v-1].dts;var Ue,ze=me+4*ie+8;try{Ue=new Uint8Array(ze)}catch(Jn){this.observer.emit(x.ERROR,x.ERROR,{type:ue.MUX_ERROR,details:q.REMUX_ALLOC_ERROR,fatal:!1,error:Jn,bytes:ze,reason:"fail allocating video mdat "+ze});return}var je=new DataView(Ue.buffer);je.setUint32(0,ze),Ue.set(wt.types.mdat,4);for(var mt=!1,Tt=Number.POSITIVE_INFINITY,ir=Number.POSITIVE_INFINITY,Ht=Number.NEGATIVE_INFINITY,Jt=Number.NEGATIVE_INFINITY,pt=0;pt<v;pt++){for(var Ct=f[pt],ar=Ct.units,hi=0,Mt=0,Vn=ar.length;Mt<Vn;Mt++){var Sa=ar[Mt],Wn=Sa.data,Pi=Sa.data.byteLength;je.setUint32(k,Pi),k+=4,Ue.set(Wn,k),k+=Pi,hi+=4+Pi}var ui=void 0;if(pt<v-1)I=f[pt+1].dts-Ct.dts,ui=f[pt+1].pts-Ct.pts;else{var gi=this.config,Xn=pt>0?Ct.dts-f[pt-1].dts:W;if(ui=pt>0?Ct.pts-f[pt-1].pts:W,gi.stretchShortVideoTrack&&this.nextAudioPts!==null){var T1=Math.floor(gi.maxBufferHole*u),zl=(o?D+o*u:this.nextAudioPts)-Ct.pts;zl>T1?((I=zl-Xn)<0?I=Xn:mt=!0,G.log("[mp4-remuxer]: It is approximately "+zl/90+" ms to the next segment; using duration "+I/90+" ms for the last video frame.")):I=Xn}else I=Xn}var D1=Math.round(Ct.pts-Ct.dts);Tt=Math.min(Tt,I),Ht=Math.max(Ht,I),ir=Math.min(ir,ui),Jt=Math.max(Jt,ui),p.push(new vg(Ct.key,I,hi,D1))}if(p.length){if(Hn){if(Hn<70){var Jg=p[0].flags;Jg.dependsOn=2,Jg.isNonSync=0}}else if(El&&Jt-ir<Ht-Tt&&W/Ht<.025&&p[0].cts===0){G.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ql=l,nr=0,_g=p.length;nr<_g;nr++){var jg=ql+p[nr].duration,R1=ql+p[nr].cts;if(nr<_g-1){var L1=jg+p[nr+1].cts;p[nr].duration=L1-R1}else p[nr].duration=nr?p[nr-1].duration:W;p[nr].cts=0,ql=jg}}}I=mt||!I?W:I,this.nextAvcDts=C=h+I,this.videoSampleDuration=I,this.isVideoContiguous=!0;var M1={data1:wt.moof(t.sequenceNumber++,l,Y({},t,{samples:p})),data2:Ue,startPTS:D/u,endPTS:(B+I)/u,startDTS:l/u,endDTS:C/u,type:"video",hasAudio:!1,hasVideo:!0,nb:p.length,dropped:t.dropped};return t.samples=[],t.dropped=0,M1},s.remuxAudio=function(t,r,a,o,l){var h=t.inputTimeScale,u=h/(t.samplerate?t.samplerate:h),f=t.segmentCodec==="aac"?1024:1152,p=f*u,v=this._initPTS,w=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,C=[],k=l!==void 0,I=t.samples,D=w?0:8,B=this.nextAudioPts||-1,T=r*h,U=v.baseTime*h/v.timescale;if(this.isAudioContiguous=a=a||I.length&&B>0&&(o&&Math.abs(T-B)<9e3||Math.abs(Wt(I[0].pts-U,T)-B)<20*p),I.forEach(function(Mt){Mt.pts=Wt(Mt.pts-U,T)}),!a||B<0){if(I=I.filter(function(Mt){return Mt.pts>=0}),!I.length)return;B=l===0?0:o&&!k?Math.max(0,T):I[0].pts}if(t.segmentCodec==="aac")for(var M=this.config.maxAudioFramesDrift,H=0,V=B;H<I.length;H++){var W=I[H],$=W.pts,J=$-V,j=Math.abs(1e3*J/h);if(J<=-M*p&&k)H===0&&(G.warn("Audio frame @ "+($/h).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*J/h)+" ms."),this.nextAudioPts=B=V=$);else if(J>=M*p&&j<1e4&&k){var le=Math.round(J/p);(V=$-le*p)<0&&(le--,V+=p),H===0&&(this.nextAudioPts=B=V),G.warn("[mp4-remuxer]: Injecting "+le+" audio frame @ "+(V/h).toFixed(3)+"s due to "+Math.round(1e3*J/h)+" ms gap.");for(var ie=0;ie<le;ie++){var me=Math.max(V,0),we=fg.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);we||(G.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),we=W.unit.subarray()),I.splice(H,0,{unit:we,pts:me}),V+=p,H++}}W.pts=V,V+=p}for(var ve,Ae=null,Ie=null,fe=0,Pe=I.length;Pe--;)fe+=I[Pe].unit.byteLength;for(var Ue=0,ze=I.length;Ue<ze;Ue++){var je=I[Ue],mt=je.unit,Tt=je.pts;if(Ie!==null)C[Ue-1].duration=Math.round((Tt-Ie)/u);else{if(a&&t.segmentCodec==="aac"&&(Tt=B),Ae=Tt,!(fe>0))return;fe+=D;try{ve=new Uint8Array(fe)}catch(Mt){this.observer.emit(x.ERROR,x.ERROR,{type:ue.MUX_ERROR,details:q.REMUX_ALLOC_ERROR,fatal:!1,error:Mt,bytes:fe,reason:"fail allocating audio mdat "+fe});return}w||(new DataView(ve.buffer).setUint32(0,fe),ve.set(wt.types.mdat,4))}ve.set(mt,D);var ir=mt.byteLength;D+=ir,C.push(new vg(!0,f,ir,0)),Ie=Tt}var Ht=C.length;if(Ht){var Jt=C[C.length-1];this.nextAudioPts=B=Ie+u*Jt.duration;var pt=w?new Uint8Array(0):wt.moof(t.sequenceNumber++,Ae/u,Y({},t,{samples:C}));t.samples=[];var Ct=Ae/h,ar=B/h,hi={data1:pt,data2:ve,startPTS:Ct,endPTS:ar,startDTS:Ct,endDTS:ar,type:"audio",hasAudio:!0,hasVideo:!1,nb:Ht};return this.isAudioContiguous=!0,hi}},s.remuxEmptyAudio=function(t,r,a,o){var l=t.inputTimeScale,h=l/(t.samplerate?t.samplerate:l),u=this.nextAudioPts,f=this._initDTS,p=9e4*f.baseTime/f.timescale,v=(u!==null?u:o.startDTS*l)+p,w=o.endDTS*l+p,C=1024*h,k=Math.ceil((w-v)/C),I=fg.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(G.warn("[mp4-remuxer]: remux empty Audio"),I){for(var D=[],B=0;B<k;B++){var T=v+B*C;D.push({unit:I,pts:T,dts:T})}return t.samples=D,this.remuxAudio(t,r,a,!1)}G.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},d})();function Wt(d,s){var t;if(s===null)return d;for(t=s<d?-8589934592:8589934592;Math.abs(d-s)>4294967296;)d+=t;return d}function pg(d,s,t,r){var a=d.samples.length;if(a){for(var o=d.inputTimeScale,l=0;l<a;l++){var h=d.samples[l];h.pts=Wt(h.pts-t.baseTime*o/t.timescale,s*o)/o,h.dts=Wt(h.dts-r.baseTime*o/r.timescale,s*o)/o}var u=d.samples;return d.samples=[],{samples:u}}}function mg(d,s,t){var r=d.samples.length;if(r){for(var a=d.inputTimeScale,o=0;o<r;o++){var l=d.samples[o];l.pts=Wt(l.pts-t.baseTime*a/t.timescale,s*a)/a}d.samples.sort(function(u,f){return u.pts-f.pts});var h=d.samples;return d.samples=[],{samples:h}}}var Qr,vg=function(d,s,t,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=s,this.size=t,this.cts=r,this.flags=new Um(d)},Um=function(d){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=d?2:1,this.isNonSync=d?0:1},Qm=(function(){function d(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}var s=d.prototype;return s.destroy=function(){},s.resetTimeStamp=function(t){this.initPTS=t,this.lastEndTime=null},s.resetNextTimestamp=function(){this.lastEndTime=null},s.resetInitSegment=function(t,r,a,o){this.audioCodec=r,this.videoCodec=a,this.generateInitSegment((function(l,h){if(!l||!h)return l;var u=h.keyId;return u&&h.isCommonEncryption&&Ye(l,["moov","trak"]).forEach(function(f){var p=Ye(f,["mdia","minf","stbl","stsd"])[0].subarray(8),v=Ye(p,["enca"]),w=v.length>0;w||(v=Ye(p,["encv"])),v.forEach(function(C){Ye(w?C.subarray(28):C.subarray(78),["sinf"]).forEach(function(k){var I=yu(k);if(I){var D=I.subarray(8,24);D.some(function(B){return B!==0})||(G.log("[eme] Patching keyId in 'enc"+(w?"a":"v")+">sinf>>tenc' box: "+yr(D)+" -> "+yr(u)),I.set(u,8))}})})}),l})(t,o)),this.emitInitSegment=!0},s.generateInitSegment=function(t){var r=this.audioCodec,a=this.videoCodec;if(t==null||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var o=this.initData=bu(t);r||(r=Ag(o.audio,ot)),a||(a=Ag(o.video,bt));var l={};o.audio&&o.video?l.audiovideo={container:"video/mp4",codec:r+","+a,initSegment:t,id:"main"}:o.audio?l.audio={container:"audio/mp4",codec:r,initSegment:t,id:"audio"}:o.video?l.video={container:"video/mp4",codec:a,initSegment:t,id:"main"}:G.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=l},s.remux=function(t,r,a,o,l,h){var u,f,p=this.initPTS,v=this.lastEndTime,w={audio:void 0,video:void 0,text:o,id3:a,initSegment:void 0};se(v)||(v=this.lastEndTime=l||0);var C=r.samples;if(C==null||!C.length)return w;var k={initPTS:void 0,timescale:1},I=this.initData;if((u=I)!=null&&u.length||(this.generateInitSegment(C),I=this.initData),(f=I)==null||!f.length)return G.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),w;this.emitInitSegment&&(k.tracks=this.initTracks,this.emitInitSegment=!1);var D=(function(J,j){for(var le=0,ie=0,me=0,we=Ye(J,["moof","traf"]),ve=0;ve<we.length;ve++){var Ae=we[ve],Ie=Ye(Ae,["tfhd"])[0],fe=j[Re(Ie,4)];if(fe){var Pe=fe.default,Ue=Re(Ie,0)|Pe?.flags,ze=Pe?.duration;8&Ue&&(ze=Re(Ie,2&Ue?12:8));for(var je=fe.timescale||9e4,mt=Ye(Ae,["trun"]),Tt=0;Tt<mt.length;Tt++)!(le=Wp(mt[Tt]))&&ze&&(le=ze*Re(mt[Tt],4)),fe.type===bt?ie+=le/je:fe.type===ot&&(me+=le/je)}}if(ie===0&&me===0){for(var ir=0,Ht=Ye(J,["sidx"]),Jt=0;Jt<Ht.length;Jt++){var pt=Vp(Ht[Jt]);pt!=null&&pt.references&&(ir+=pt.references.reduce(function(Ct,ar){return Ct+ar.info.duration||0},0))}return ir}return ie||me})(C,I),B=(function(J,j){return Ye(j,["moof","traf"]).reduce(function(le,ie){var me=Ye(ie,["tfdt"])[0],we=me[0],ve=Ye(ie,["tfhd"]).reduce(function(Ae,Ie){var fe=J[Re(Ie,4)];if(fe){var Pe=Re(me,4);if(we===1){if(Pe===In)return G.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),Ae;Pe*=In+1,Pe+=Re(me,8)}var Ue=Pe/(fe.timescale||9e4);if(isFinite(Ue)&&(Ae===null||Ue<Ae))return Ue}return Ae},null);return ve!==null&&isFinite(ve)&&(le===null||ve<le)?ve:le},null)})(I,C),T=B===null?l:B;((function(J,j,le,ie){if(J===null)return!0;var me=Math.max(ie,1),we=j-J.baseTime/J.timescale;return Math.abs(we-le)>me})(p,T,l,D)||k.timescale!==p.timescale&&h)&&(k.initPTS=T-l,p&&p.timescale===1&&G.warn("Adjusting initPTS by "+(k.initPTS-p.baseTime)),this.initPTS=p={baseTime:k.initPTS,timescale:1});var U=t?T-p.baseTime/p.timescale:v,M=U+D;(function(J,j,le){Ye(j,["moof","traf"]).forEach(function(ie){Ye(ie,["tfhd"]).forEach(function(me){var we=J[Re(me,4)];if(we){var ve=we.timescale||9e4;Ye(ie,["tfdt"]).forEach(function(Ae){var Ie=Ae[0],fe=Re(Ae,4);if(Ie===0)fe-=le*ve,js(Ae,4,fe=Math.max(fe,0));else{fe*=Math.pow(2,32),fe+=Re(Ae,8),fe-=le*ve,fe=Math.max(fe,0);var Pe=Math.floor(fe/(In+1)),Ue=Math.floor(fe%(In+1));js(Ae,4,Pe),js(Ae,8,Ue)}})}})})})(I,C,p.baseTime/p.timescale),D>0?this.lastEndTime=M:(G.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var H=!!I.audio,V=!!I.video,W="";H&&(W+="audio"),V&&(W+="video");var $={data1:C,startPTS:U,startDTS:U,endPTS:M,endDTS:M,type:W,hasAudio:H,hasVideo:V,nb:1,dropped:0};return w.audio=$.type==="audio"?$:void 0,w.video=$.type!=="audio"?$:void 0,w.initSegment=k,w.id3=pg(a,l,p,p),o.samples.length&&(w.text=mg(o,l,p)),w},d})();function Ag(d,s){var t=d?.codec;return t&&t.length>4?t:t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":t==="avc1"||s===bt?"avc1.42e01e":"mp4a.40.5"}try{Qr=self.performance.now.bind(self.performance)}catch{G.debug("Unable to use Performance API on this environment"),Qr=typeof self<"u"&&self.Date.now}var Bl=[{demux:Im,remux:Qm},{demux:Mm,remux:kl},{demux:km,remux:kl},{demux:Pm,remux:kl}],Il=(function(){function d(t,r,a,o,l){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=r,this.config=a,this.vendor=o,this.id=l}var s=d.prototype;return s.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},s.push=function(t,r,a,o){var l=this,h=a.transmuxing;h.executeStart=Qr();var u=new Uint8Array(t),f=this.currentTransmuxState,p=this.transmuxConfig;o&&(this.currentTransmuxState=o);var v=o||f,w=v.contiguous,C=v.discontinuity,k=v.trackSwitch,I=v.accurateTimeOffset,D=v.timeOffset,B=v.initSegmentChange,T=p.audioCodec,U=p.videoCodec,M=p.defaultInitPts,H=p.duration,V=p.initSegmentData,W=(function(we,ve){var Ae=null;return we.byteLength>0&&ve!=null&&ve.key!=null&&ve.iv!==null&&ve.method!=null&&(Ae=ve),Ae})(u,r);if(W&&W.method==="AES-128"){var $=this.getDecrypter();if(!$.isSync())return this.decryptionPromise=$.webCryptoDecrypt(u,W.key.buffer,W.iv.buffer).then(function(we){var ve=l.push(we,null,a);return l.decryptionPromise=null,ve}),this.decryptionPromise;var J=$.softwareDecrypt(u,W.key.buffer,W.iv.buffer);if(a.part>-1&&(J=$.flush()),!J)return h.executeEnd=Qr(),Sl(a);u=new Uint8Array(J)}var j=this.needsProbing(C,k);if(j){var le=this.configureTransmuxer(u);if(le)return G.warn("[transmuxer] "+le.message),this.observer.emit(x.ERROR,x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,fatal:!1,error:le,reason:le.message}),h.executeEnd=Qr(),Sl(a)}(C||k||B||j)&&this.resetInitSegment(V,T,U,H,r),(C||B||j)&&this.resetInitialTimestamp(M),w||this.resetContiguity();var ie=this.transmux(u,W,D,I,a),me=this.currentTransmuxState;return me.contiguous=!0,me.discontinuity=!1,me.trackSwitch=!1,h.executeEnd=Qr(),ie},s.flush=function(t){var r=this,a=t.transmuxing;a.executeStart=Qr();var o=this.decrypter,l=this.currentTransmuxState,h=this.decryptionPromise;if(h)return h.then(function(){return r.flush(t)});var u=[],f=l.timeOffset;if(o){var p=o.flush();p&&u.push(this.push(p,null,t))}var v=this.demuxer,w=this.remuxer;if(!v||!w)return a.executeEnd=Qr(),[Sl(t)];var C=v.flush(f);return li(C)?C.then(function(k){return r.flushRemux(u,k,t),u}):(this.flushRemux(u,C,t),u)},s.flushRemux=function(t,r,a){var o=r.audioTrack,l=r.videoTrack,h=r.id3Track,u=r.textTrack,f=this.currentTransmuxState,p=f.accurateTimeOffset,v=f.timeOffset;G.log("[transmuxer.ts]: Flushed fragment "+a.sn+(a.part>-1?" p: "+a.part:"")+" of level "+a.level);var w=this.remuxer.remux(o,l,h,u,v,p,!0,this.id);t.push({remuxResult:w,chunkMeta:a}),a.transmuxing.executeEnd=Qr()},s.resetInitialTimestamp=function(t){var r=this.demuxer,a=this.remuxer;r&&a&&(r.resetTimeStamp(t),a.resetTimeStamp(t))},s.resetContiguity=function(){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetContiguity(),r.resetNextTimestamp())},s.resetInitSegment=function(t,r,a,o,l){var h=this.demuxer,u=this.remuxer;h&&u&&(h.resetInitSegment(t,r,a,o),u.resetInitSegment(t,r,a,l))},s.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},s.transmux=function(t,r,a,o,l){return r&&r.method==="SAMPLE-AES"?this.transmuxSampleAes(t,r,a,o,l):this.transmuxUnencrypted(t,a,o,l)},s.transmuxUnencrypted=function(t,r,a,o){var l=this.demuxer.demux(t,r,!1,!this.config.progressive),h=l.audioTrack,u=l.videoTrack,f=l.id3Track,p=l.textTrack;return{remuxResult:this.remuxer.remux(h,u,f,p,r,a,!1,this.id),chunkMeta:o}},s.transmuxSampleAes=function(t,r,a,o,l){var h=this;return this.demuxer.demuxSampleAes(t,r,a).then(function(u){return{remuxResult:h.remuxer.remux(u.audioTrack,u.videoTrack,u.id3Track,u.textTrack,a,o,!1,h.id),chunkMeta:l}})},s.configureTransmuxer=function(t){for(var r,a=this.config,o=this.observer,l=this.typeSupported,h=this.vendor,u=0,f=Bl.length;u<f;u++)if(Bl[u].demux.probe(t)){r=Bl[u];break}if(!r)return new Error("Failed to find demuxer by probing fragment data");var p=this.demuxer,v=this.remuxer,w=r.remux,C=r.demux;v&&v instanceof w||(this.remuxer=new w(o,a,l,h)),p&&p instanceof C||(this.demuxer=new C(o,a,l),this.probe=C.probe)},s.needsProbing=function(t,r){return!this.demuxer||!this.remuxer||t||r},s.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new ml(this.config)),t},d})(),Sl=function(d){return{remuxResult:{},chunkMeta:d}};function li(d){return"then"in d&&d.then instanceof Function}var Nm=function(d,s,t,r,a){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=d,this.videoCodec=s,this.initSegmentData=t,this.duration=r,this.defaultInitPts=a||null},Hm=function(d,s,t,r,a,o){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=d,this.contiguous=s,this.accurateTimeOffset=t,this.trackSwitch=r,this.timeOffset=a,this.initSegmentChange=o},bg={exports:{}};(function(d){var s=Object.prototype.hasOwnProperty,t="~";function r(){}function a(u,f,p){this.fn=u,this.context=f,this.once=p||!1}function o(u,f,p,v,w){if(typeof p!="function")throw new TypeError("The listener must be a function");var C=new a(p,v||u,w),k=t?t+f:f;return u._events[k]?u._events[k].fn?u._events[k]=[u._events[k],C]:u._events[k].push(C):(u._events[k]=C,u._eventsCount++),u}function l(u,f){--u._eventsCount==0?u._events=new r:delete u._events[f]}function h(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1)),h.prototype.eventNames=function(){var u,f,p=[];if(this._eventsCount===0)return p;for(f in u=this._events)s.call(u,f)&&p.push(t?f.slice(1):f);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(u)):p},h.prototype.listeners=function(u){var f=t?t+u:u,p=this._events[f];if(!p)return[];if(p.fn)return[p.fn];for(var v=0,w=p.length,C=new Array(w);v<w;v++)C[v]=p[v].fn;return C},h.prototype.listenerCount=function(u){var f=t?t+u:u,p=this._events[f];return p?p.fn?1:p.length:0},h.prototype.emit=function(u,f,p,v,w,C){var k=t?t+u:u;if(!this._events[k])return!1;var I,D,B=this._events[k],T=arguments.length;if(B.fn){switch(B.once&&this.removeListener(u,B.fn,void 0,!0),T){case 1:return B.fn.call(B.context),!0;case 2:return B.fn.call(B.context,f),!0;case 3:return B.fn.call(B.context,f,p),!0;case 4:return B.fn.call(B.context,f,p,v),!0;case 5:return B.fn.call(B.context,f,p,v,w),!0;case 6:return B.fn.call(B.context,f,p,v,w,C),!0}for(D=1,I=new Array(T-1);D<T;D++)I[D-1]=arguments[D];B.fn.apply(B.context,I)}else{var U,M=B.length;for(D=0;D<M;D++)switch(B[D].once&&this.removeListener(u,B[D].fn,void 0,!0),T){case 1:B[D].fn.call(B[D].context);break;case 2:B[D].fn.call(B[D].context,f);break;case 3:B[D].fn.call(B[D].context,f,p);break;case 4:B[D].fn.call(B[D].context,f,p,v);break;default:if(!I)for(U=1,I=new Array(T-1);U<T;U++)I[U-1]=arguments[U];B[D].fn.apply(B[D].context,I)}}return!0},h.prototype.on=function(u,f,p){return o(this,u,f,p,!1)},h.prototype.once=function(u,f,p){return o(this,u,f,p,!0)},h.prototype.removeListener=function(u,f,p,v){var w=t?t+u:u;if(!this._events[w])return this;if(!f)return l(this,w),this;var C=this._events[w];if(C.fn)C.fn!==f||v&&!C.once||p&&C.context!==p||l(this,w);else{for(var k=0,I=[],D=C.length;k<D;k++)(C[k].fn!==f||v&&!C[k].once||p&&C[k].context!==p)&&I.push(C[k]);I.length?this._events[w]=I.length===1?I[0]:I:l(this,w)}return this},h.prototype.removeAllListeners=function(u){var f;return u?(f=t?t+u:u,this._events[f]&&l(this,f)):(this._events=new r,this._eventsCount=0),this},h.prototype.off=h.prototype.removeListener,h.prototype.addListener=h.prototype.on,h.prefixed=t,h.EventEmitter=h,d.exports=h})(bg);var Gn=Te(bg.exports);function xl(d,s){if(!((t=s.remuxResult).audio||t.video||t.text||t.id3||t.initSegment))return!1;var t,r=[],a=s.remuxResult,o=a.audio,l=a.video;return o&&yg(r,o),l&&yg(r,l),d.postMessage({event:"transmuxComplete",data:s},r),!0}function yg(d,s){s.data1&&d.push(s.data1.buffer),s.data2&&d.push(s.data2.buffer)}function wg(d,s,t){s.reduce(function(r,a){return xl(d,a)||r},!1)||d.postMessage({event:"transmuxComplete",data:s[0]}),d.postMessage({event:"flush",data:t})}c!==void 0&&c&&(function(d){var s=new Gn,t=function(a,o){d.postMessage({event:a,data:o})};s.on(x.FRAG_DECRYPTED,t),s.on(x.ERROR,t);var r=function(){var a=function(l){var h=function(u){t("workerLog",{logType:l,message:u})};G[l]=h};for(var o in G)a(o)};d.addEventListener("message",function(a){var o=a.data;switch(o.cmd){case"init":var l=JSON.parse(o.config);d.transmuxer=new Il(s,o.typeSupported,l,o.vendor,o.id),tr(l.debug,o.id),r(),t("init",null);break;case"configure":d.transmuxer.configure(o.config);break;case"demux":var h=d.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);li(h)?(d.transmuxer.async=!0,h.then(function(p){xl(d,p)}).catch(function(p){t(x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,chunkMeta:o.chunkMeta,fatal:!1,error:p,err:p,reason:"transmuxer-worker push error"})})):(d.transmuxer.async=!1,xl(d,h));break;case"flush":var u=o.chunkMeta,f=d.transmuxer.flush(u);li(f)||d.transmuxer.async?(li(f)||(f=Promise.resolve(f)),f.then(function(p){wg(d,p,u)}).catch(function(p){t(x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,chunkMeta:o.chunkMeta,fatal:!1,error:p,err:p,reason:"transmuxer-worker flush error"})})):wg(d,f,u)}})})(self);var Tl=xn()||{isTypeSupported:function(){return!1}},Cg=(function(){function d(t,r,a,o){var l=this;this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var h=t.config;this.hls=t,this.id=r,this.useWorker=!!h.enableWorker,this.onTransmuxComplete=a,this.onFlush=o;var u=function(D,B){(B=B||{}).frag=l.frag,B.id=l.id,D===x.ERROR&&(l.error=B.error),l.hls.trigger(D,B)};this.observer=new Gn,this.observer.on(x.FRAG_DECRYPTED,u),this.observer.on(x.ERROR,u);var f,p,v,w,C={mp4:Tl.isTypeSupported("video/mp4"),mpeg:Tl.isTypeSupported("audio/mpeg"),mp3:Tl.isTypeSupported('audio/mp4; codecs="mp3"')},k=navigator.vendor;if(!this.useWorker||typeof Worker>"u"||(h.workerPath,0))this.transmuxer=new Il(this.observer,C,h,k,r);else try{h.workerPath?(G.log("loading Web Worker "+h.workerPath+' for "'+r+'"'),this.workerContext=(v=h.workerPath,w=new self.URL(v,self.location.href).href,{worker:new self.Worker(w),scriptURL:w})):(G.log('injecting Web Worker for "'+r+'"'),this.workerContext=(f=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+n.toString()+")(true);"],{type:"text/javascript"}),p=self.URL.createObjectURL(f),{worker:new self.Worker(p),objectURL:p})),this.onwmsg=function(D){return l.onWorkerMessage(D)};var I=this.workerContext.worker;I.addEventListener("message",this.onwmsg),I.onerror=function(D){var B=new Error(D.message+" ("+D.filename+":"+D.lineno+")");h.enableWorker=!1,G.warn('Error in "'+r+'" Web Worker, fallback to inline'),l.hls.trigger(x.ERROR,{type:ue.OTHER_ERROR,details:q.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:B})},I.postMessage({cmd:"init",typeSupported:C,vendor:k,id:r,config:JSON.stringify(h)})}catch(D){G.warn('Error setting up "'+r+'" Web Worker, fallback to inline',D),this.resetWorker(),this.error=null,this.transmuxer=new Il(this.observer,C,h,k,r)}}var s=d.prototype;return s.resetWorker=function(){if(this.workerContext){var t=this.workerContext,r=t.worker,a=t.objectURL;a&&self.URL.revokeObjectURL(a),r.removeEventListener("message",this.onwmsg),r.onerror=null,r.terminate(),this.workerContext=null}},s.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}var r=this.observer;r&&r.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},s.push=function(t,r,a,o,l,h,u,f,p,v){var w,C,k=this;p.transmuxing.start=self.performance.now();var I=this.transmuxer,D=h?h.start:l.start,B=l.decryptdata,T=this.frag,U=!(T&&l.cc===T.cc),M=!(T&&p.level===T.level),H=T?p.sn-T.sn:-1,V=this.part?p.part-this.part.index:-1,W=H===0&&p.id>1&&p.id===T?.stats.chunkCount,$=!M&&(H===1||H===0&&(V===1||W&&V<=0)),J=self.performance.now();(M||H||l.stats.parsing.start===0)&&(l.stats.parsing.start=J),!h||!V&&$||(h.stats.parsing.start=J);var j=!(T&&((w=l.initSegment)==null?void 0:w.url)===((C=T.initSegment)==null?void 0:C.url)),le=new Hm(U,$,f,M,D,j);if(!$||U||j){G.log("[transmuxer-interface, "+l.type+"]: Starting new transmux session for sn: "+p.sn+" p: "+p.part+" level: "+p.level+" id: "+p.id+`
6
6
  discontinuity: `+U+`
7
7
  trackSwitch: `+M+`
8
8
  contiguous: `+$+`
9
9
  accurateTimeOffset: `+f+`
10
10
  timeOffset: `+D+`
11
- initSegmentChange: `+j);var ie=new Qm(a,o,r,u,v);this.configureTransmuxer(ie)}if(this.frag=l,this.part=h,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:B,chunkMeta:p,state:le},t instanceof ArrayBuffer?[t]:[]);else if(I){var me=I.push(t,B,p,le);li(me)?(I.async=!0,me.then(function(we){k.handleTransmuxComplete(we)}).catch(function(we){k.transmuxerError(we,p,"transmuxer-interface push error")})):(I.async=!1,this.handleTransmuxComplete(me))}},s.flush=function(t){var r=this;t.transmuxing.start=self.performance.now();var a=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(a){var o=a.flush(t);li(o)||a.async?(li(o)||(o=Promise.resolve(o)),o.then(function(l){r.handleFlushResult(l,t)}).catch(function(l){r.transmuxerError(l,t,"transmuxer-interface flush error")})):this.handleFlushResult(o,t)}},s.transmuxerError=function(t,r,a){this.hls&&(this.error=t,this.hls.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,chunkMeta:r,fatal:!1,error:t,err:t,reason:a}))},s.handleFlushResult=function(t,r){var a=this;t.forEach(function(o){a.handleTransmuxComplete(o)}),this.onFlush(r)},s.onWorkerMessage=function(t){var r=t.data,a=this.hls;switch(r.event){case"init":var o,l=(o=this.workerContext)==null?void 0:o.objectURL;l&&self.URL.revokeObjectURL(l);break;case"transmuxComplete":this.handleTransmuxComplete(r.data);break;case"flush":this.onFlush(r.data);break;case"workerLog":G[r.data.logType]&&G[r.data.logType](r.data.message);break;default:r.data=r.data||{},r.data.frag=this.frag,r.data.id=this.id,a.trigger(r.event,r.data)}},s.configureTransmuxer=function(t){var r=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):r&&r.configure(t)},s.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},d})(),Hm=(function(){function d(t,r,a,o){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=r,this.fragmentTracker=a,this.hls=o}var s=d.prototype;return s.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},s.poll=function(t,r){var a=this.config,o=this.media,l=this.stalled;if(o!==null){var h=o.currentTime,u=o.seeking,f=this.seeking&&!u,p=!this.seeking&&u;if(this.seeking=u,h===t){if(p||f)this.stalled=null;else if(!(o.paused&&!u||o.ended||o.playbackRate===0)&&ct.getBuffered(o).length){var v=ct.bufferInfo(o,h,0),w=v.len>0,C=v.nextStart||0;if(w||C){if(u){var k=v.len>2,I=!C||r&&r.start<=h||C-h>2&&!this.fragmentTracker.getPartialFragment(h);if(k||I)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var D,B=Math.max(C,v.start||0)-h,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,U=!(T==null||(D=T.details)==null)&&D.live?2*T.details.targetduration:2,M=this.fragmentTracker.getPartialFragment(h);if(B>0&&(B<=U||M))return void this._trySkipBufferHole(M)}var H=self.performance.now();if(l!==null){var V=H-l;if(u||!(V>=250)||(this._reportStall(v),this.media)){var W=ct.bufferInfo(o,h,a.maxBufferHole);this._tryFixBufferStall(W,V)}}else this.stalled=H}}}else if(this.moved=!0,l!==null){if(this.stallReported){var $=self.performance.now()-l;G.warn("playback not stuck anymore @"+h+", after "+Math.round($)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},s._tryFixBufferStall=function(t,r){var a=this.config,o=this.fragmentTracker,l=this.media;if(l!==null){var h=l.currentTime,u=o.getPartialFragment(h);if(u&&(this._trySkipBufferHole(u)||!this.media))return;(t.len>a.maxBufferHole||t.nextStart&&t.nextStart-h<a.maxBufferHole)&&r>1e3*a.highBufferWatchdogPeriod&&(G.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},s._reportStall=function(t){var r=this.hls,a=this.media;if(!this.stallReported&&a){this.stallReported=!0;var o=new Error("Playback stalling at @"+a.currentTime+" due to low buffer ("+JSON.stringify(t)+")");G.warn(o.message),r.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.BUFFER_STALLED_ERROR,fatal:!1,error:o,buffer:t.len})}},s._trySkipBufferHole=function(t){var r=this.config,a=this.hls,o=this.media;if(o===null)return 0;var l=o.currentTime,h=ct.bufferInfo(o,l,0),u=l<h.start?h.start:h.nextStart;if(u){var f=h.len<=r.maxBufferHole,p=h.len>0&&h.len<1&&o.readyState<3,v=u-l;if(v>0&&(f||p)){if(v>r.maxBufferHole){var w=this.fragmentTracker,C=!1;if(l===0){var k=w.getAppendedFrag(0,Je);k&&u<k.end&&(C=!0)}if(!C){var I=t||w.getAppendedFrag(l,Je);if(I){for(var D=!1,B=I.end;B<u;){var T=w.getPartialFragment(B);if(!T){D=!0;break}B+=T.duration}if(D)return 0}}}var U=Math.max(u+.05,l+.1);if(G.warn("skipping hole, adjusting currentTime from "+l+" to "+U),this.moved=!0,this.stalled=null,o.currentTime=U,t&&!t.gap){var M=new Error("fragment loaded with buffer holes, seeking from "+l+" to "+U);a.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:M,reason:M.message,frag:t})}return U}}return 0},s._tryNudgeBuffer=function(){var t=this.config,r=this.hls,a=this.media,o=this.nudgeRetry;if(a!==null){var l=a.currentTime;if(this.nudgeRetry++,o<t.nudgeMaxRetry){var h=l+(o+1)*t.nudgeOffset,u=new Error("Nudging 'currentTime' from "+l+" to "+h);G.warn(u.message),a.currentTime=h,r.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.BUFFER_NUDGE_ON_STALL,error:u,fatal:!1})}else{var f=new Error("Playhead still not moving while enough data buffered @"+l+" after "+t.nudgeMaxRetry+" nudges");G.error(f.message),r.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.BUFFER_STALLED_ERROR,error:f,fatal:!0})}}},d})(),Gm=(function(d){function s(r,a,o){var l;return(l=d.call(this,r,a,o,"[stream-controller]",Je)||this).audioCodecSwap=!1,l.gapController=null,l.level=-1,l._forceStartLoad=!1,l.altAudio=!1,l.audioOnly=!1,l.fragPlaying=null,l.onvplaying=null,l.onvseeked=null,l.fragLastKbps=0,l.couldBacktrack=!1,l.backtrackFragment=null,l.audioCodecSwitch=!1,l.videoBuffer=null,l._registerListeners(),l}X(s,d);var t=s.prototype;return t._registerListeners=function(){var r=this.hls;r.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(x.MANIFEST_LOADING,this.onManifestLoading,this),r.on(x.MANIFEST_PARSED,this.onManifestParsed,this),r.on(x.LEVEL_LOADING,this.onLevelLoading,this),r.on(x.LEVEL_LOADED,this.onLevelLoaded,this),r.on(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(x.ERROR,this.onError,this),r.on(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(x.BUFFER_CREATED,this.onBufferCreated,this),r.on(x.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(x.FRAG_BUFFERED,this.onFragBuffered,this)},t._unregisterListeners=function(){var r=this.hls;r.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(x.MANIFEST_LOADING,this.onManifestLoading,this),r.off(x.MANIFEST_PARSED,this.onManifestParsed,this),r.off(x.LEVEL_LOADED,this.onLevelLoaded,this),r.off(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(x.ERROR,this.onError,this),r.off(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(x.BUFFER_CREATED,this.onBufferCreated,this),r.off(x.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(x.FRAG_BUFFERED,this.onFragBuffered,this)},t.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},t.startLoad=function(r){if(this.levels){var a=this.lastCurrentTime,o=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var l=o.startLevel;l===-1&&(o.config.testBandwidth&&this.levels.length>1?(l=0,this.bitrateTest=!0):l=o.nextAutoLevel),this.level=o.nextLoadLevel=l,this.loadedmetadata=!1}a>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),r=a),this.state=Qe,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=Vt},t.stopLoad=function(){this._forceStartLoad=!1,d.prototype.stopLoad.call(this)},t.doTick=function(){switch(this.state){case si:var r,a=this.levels,o=this.level,l=a==null||(r=a[o])==null?void 0:r.details;if(l&&(!l.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(l))break;this.state=Qe;break}if(this.hls.nextLoadLevel!==this.level){this.state=Qe;break}break;case Ri:var h,u=self.performance.now(),f=this.retryDate;(!f||u>=f||(h=this.media)!=null&&h.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Qe)}this.state===Qe&&this.doTickIdle(),this.onTickEnd()},t.onTickEnd=function(){d.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},t.doTickIdle=function(){var r=this.hls,a=this.levelLastLoaded,o=this.levels,l=this.media,h=r.config,u=r.nextLoadLevel;if(a!==null&&(l||!this.startFragRequested&&h.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&o!=null&&o[u]){var f=o[u],p=this.getMainFwdBufferInfo();if(p!==null){var v=this.getLevelDetails();if(v&&this._streamEnded(p,v)){var w={};this.altAudio&&(w.type="video"),this.hls.trigger(x.BUFFER_EOS,w),this.state=Ea;return}r.loadLevel!==u&&r.manualLevel===-1&&this.log("Adapting to level "+u+" from level "+this.level),this.level=r.nextLoadLevel=u;var C=f.details;if(!C||this.state===si||C.live&&this.levelLastLoaded!==u)return this.level=u,void(this.state=si);var k=p.len,I=this.getMaxBufferLength(f.maxBitrate);if(!(k>=I)){this.backtrackFragment&&this.backtrackFragment.start>p.end&&(this.backtrackFragment=null);var D=this.backtrackFragment?this.backtrackFragment.start:p.end,B=this.getNextFragment(D,C);if(this.couldBacktrack&&!this.fragPrevious&&B&&B.sn!=="initSegment"&&this.fragmentTracker.getState(B)!==wa){var T,U=((T=this.backtrackFragment)!=null?T:B).sn-C.startSN,M=C.fragments[U-1];M&&B.cc===M.cc&&(B=M,this.fragmentTracker.removeFragment(M))}else this.backtrackFragment&&p.len&&(this.backtrackFragment=null);if(B&&this.isLoopLoading(B,D)){if(!B.gap){var H=this.audioOnly&&!this.altAudio?ot:bt,V=(H===bt?this.videoBuffer:this.mediaBuffer)||this.media;V&&this.afterBufferFlushed(V,H,Je)}B=this.getNextFragmentLoopLoading(B,C,p,Je,I)}B&&(!B.initSegment||B.initSegment.data||this.bitrateTest||(B=B.initSegment),this.loadFragment(B,f,D))}}}},t.loadFragment=function(r,a,o){var l=this.fragmentTracker.getState(r);this.fragCurrent=r,l===ya||l===xi?r.sn==="initSegment"?this._loadInitSegment(r,a):this.bitrateTest?(this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r,a)):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,a,o)):this.clearTrackerIfNeeded(r)},t.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,Je)},t.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},t.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},t.nextLevelSwitch=function(){var r=this.levels,a=this.media;if(a!=null&&a.readyState){var o,l=this.getAppendedFrag(a.currentTime);l&&l.start>1&&this.flushMainBuffer(0,l.start-1);var h=this.getLevelDetails();if(h!=null&&h.live){var u=this.getMainFwdBufferInfo();if(!u||u.len<2*h.targetduration)return}if(!a.paused&&r){var f=r[this.hls.nextLoadLevel],p=this.fragLastKbps;o=p&&this.fragCurrent?this.fragCurrent.duration*f.maxBitrate/(1e3*p)+1:0}else o=0;var v=this.getBufferedFrag(a.currentTime+o);if(v){var w=this.followingBufferedFrag(v);if(w){this.abortCurrentFrag();var C=w.maxStartPTS?w.maxStartPTS:w.start,k=w.duration,I=Math.max(v.end,C+Math.min(Math.max(k-this.config.maxFragLookUpTolerance,.5*k),.75*k));this.flushMainBuffer(I,Number.POSITIVE_INFINITY)}}}},t.abortCurrentFrag=function(){var r=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,r&&(r.abortRequests(),this.fragmentTracker.removeFragment(r)),this.state){case vl:case Di:case Ri:case Ur:case Pn:this.state=Qe}this.nextLoadPosition=this.getLoadPosition()},t.flushMainBuffer=function(r,a){d.prototype.flushMainBuffer.call(this,r,a,this.altAudio?"video":null)},t.onMediaAttached=function(r,a){d.prototype.onMediaAttached.call(this,r,a);var o=a.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),o.addEventListener("playing",this.onvplaying),o.addEventListener("seeked",this.onvseeked),this.gapController=new Hm(this.config,o,this.fragmentTracker,this.hls)},t.onMediaDetaching=function(){var r=this.media;r&&this.onvplaying&&this.onvseeked&&(r.removeEventListener("playing",this.onvplaying),r.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),d.prototype.onMediaDetaching.call(this)},t.onMediaPlaying=function(){this.tick()},t.onMediaSeeked=function(){var r=this.media,a=r?r.currentTime:null;se(a)&&this.log("Media seeked to "+a.toFixed(3));var o=this.getMainFwdBufferInfo();o!==null&&o.len!==0?this.tick():this.warn('Main forward buffer length on "seeked" event '+(o?o.len:"empty")+")")},t.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(x.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1},t.onManifestParsed=function(r,a){var o,l,h,u=!1,f=!1;a.levels.forEach(function(p){(o=p.audioCodec)&&(o.indexOf("mp4a.40.2")!==-1&&(u=!0),o.indexOf("mp4a.40.5")!==-1&&(f=!0))}),this.audioCodecSwitch=u&&f&&typeof((h=ig())==null||(l=h.prototype)==null?void 0:l.changeType)!="function",this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=a.levels,this.startFragRequested=!1},t.onLevelLoading=function(r,a){var o=this.levels;if(o&&this.state===Qe){var l=o[a.level];(!l.details||l.details.live&&this.levelLastLoaded!==a.level||this.waitForCdnTuneIn(l.details))&&(this.state=si)}},t.onLevelLoaded=function(r,a){var o,l=this.levels,h=a.level,u=a.details,f=u.totalduration;if(l){this.log("Level "+h+" loaded ["+u.startSN+","+u.endSN+"]"+(u.lastPartSn?"[part-"+u.lastPartSn+"-"+u.lastPartIndex+"]":"")+", cc ["+u.startCC+", "+u.endCC+"] duration:"+f);var p=l[h],v=this.fragCurrent;!v||this.state!==Di&&this.state!==Ri||v.level===a.level&&v.urlId===p.urlId||!v.loader||this.abortCurrentFrag();var w=0;if(u.live||(o=p.details)!=null&&o.live){if(this.checkLiveUpdate(u),u.deltaUpdateFailed)return;w=this.alignPlaylists(u,p.details)}if(p.details=u,this.levelLastLoaded=h,this.hls.trigger(x.LEVEL_UPDATED,{details:u,level:h}),this.state===si){if(this.waitForCdnTuneIn(u))return;this.state=Qe}this.startFragRequested?u.live&&this.synchronizeToLiveEdge(u):this.setStartPosition(u,w),this.tick()}else this.warn("Levels were reset while loading level "+h)},t._handleFragmentLoadProgress=function(r){var a,o=r.frag,l=r.part,h=r.payload,u=this.levels;if(u){var f=u[o.level],p=f.details;if(!p)return this.warn("Dropping fragment "+o.sn+" of level "+o.level+" after level details were reset"),void this.fragmentTracker.removeFragment(o);var v=f.videoCodec,w=p.PTSKnown||!p.live,C=(a=o.initSegment)==null?void 0:a.data,k=this._getAudioCodec(f),I=this.transmuxer=this.transmuxer||new Cg(this.hls,Je,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),D=l?l.index:-1,B=D!==-1,T=new fl(o.level,o.sn,o.stats.chunkCount,h.byteLength,D,B),U=this.initPTS[o.cc];I.push(h,C,k,v,o,l,p.totalduration,w,T,U)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered")},t.onAudioTrackSwitching=function(r,a){var o=this.altAudio;if(!a.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var l=this.fragCurrent;l&&(this.log("Switching to main audio track, cancel main fragment load"),l.abortRequests(),this.fragmentTracker.removeFragment(l)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var h=this.hls;o&&(h.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),h.trigger(x.AUDIO_TRACK_SWITCHED,a)}},t.onAudioTrackSwitched=function(r,a){var o=a.id,l=!!this.hls.audioTracks[o].url;if(l){var h=this.videoBuffer;h&&this.mediaBuffer!==h&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=h)}this.altAudio=l,this.tick()},t.onBufferCreated=function(r,a){var o,l,h=a.tracks,u=!1;for(var f in h){var p=h[f];if(p.id==="main"){if(l=f,o=p,f==="video"){var v=h[f];v&&(this.videoBuffer=v.buffer)}}else u=!0}u&&o?(this.log("Alternate track found, use "+l+".buffered to schedule main fragment loading"),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media},t.onFragBuffered=function(r,a){var o=a.frag,l=a.part;if(!o||o.type===Je){if(this.fragContextChanged(o))return this.warn("Fragment "+o.sn+(l?" p: "+l.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===Pn&&(this.state=Qe));var h=l?l.stats:o.stats;this.fragLastKbps=Math.round(8*h.total/(h.buffering.end-h.loading.first)),o.sn!=="initSegment"&&(this.fragPrevious=o),this.fragBufferedComplete(o,l)}},t.onError=function(r,a){var o;if(a.fatal)this.state=Li;else switch(a.details){case q.FRAG_GAP:case q.FRAG_PARSING_ERROR:case q.FRAG_DECRYPT_ERROR:case q.FRAG_LOAD_ERROR:case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_ERROR:case q.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Je,a);break;case q.LEVEL_LOAD_ERROR:case q.LEVEL_LOAD_TIMEOUT:case q.LEVEL_PARSING_ERROR:a.levelRetry||this.state!==si||((o=a.context)==null?void 0:o.type)!==oi||(this.state=Qe);break;case q.BUFFER_FULL_ERROR:if(!a.parent||a.parent!=="main")return;this.reduceLengthAndFlushBuffer(a)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case q.INTERNAL_EXCEPTION:this.recoverWorkerError(a)}},t.checkBuffer=function(){var r=this.media,a=this.gapController;if(r&&a&&r.readyState){if(this.loadedmetadata||!ct.getBuffered(r).length){var o=this.state!==Qe?this.fragCurrent:null;a.poll(this.lastCurrentTime,o)}this.lastCurrentTime=r.currentTime}},t.onFragLoadEmergencyAborted=function(){this.state=Qe,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},t.onBufferFlushed=function(r,a){var o=a.type;if(o!==ot||this.audioOnly&&!this.altAudio){var l=(o===bt?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(l,o,Je)}},t.onLevelsUpdated=function(r,a){this.levels=a.levels},t.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},t.seekToStartPos=function(){var r=this.media;if(r){var a=r.currentTime,o=this.startPosition;if(o>=0&&a<o){if(r.seeking)return void this.log("could not seek to "+o+", already seeking at "+a);var l=ct.getBuffered(r),h=(l.length?l.start(0):0)-o;h>0&&(h<this.config.maxBufferHole||h<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+h+" to match buffer start"),o+=h,this.startPosition=o),this.log("seek to target start position "+o+" from current time "+a),r.currentTime=o}}},t._getAudioCodec=function(r){var a=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&a&&(this.log("Swapping audio codec"),a=a.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),a},t._loadBitrateTestFrag=function(r,a){var o=this;r.bitrateTest=!0,this._doFragLoad(r,a).then(function(l){var h=o.hls;if(l&&!o.fragContextChanged(r)){a.fragmentError=0,o.state=Qe,o.startFragRequested=!1,o.bitrateTest=!1;var u=r.stats;u.parsing.start=u.parsing.end=u.buffering.start=u.buffering.end=self.performance.now(),h.trigger(x.FRAG_LOADED,l),r.bitrateTest=!1}})},t._handleTransmuxComplete=function(r){var a,o="main",l=this.hls,h=r.remuxResult,u=r.chunkMeta,f=this.getCurrentContext(u);if(f){var p=f.frag,v=f.part,w=f.level,C=h.video,k=h.text,I=h.id3,D=h.initSegment,B=w.details,T=this.altAudio?void 0:h.audio;if(this.fragContextChanged(p))this.fragmentTracker.removeFragment(p);else{if(this.state=Ur,D){if(D!=null&&D.tracks){var U=p.initSegment||p;this._bufferInitSegment(w,D.tracks,U,u),l.trigger(x.FRAG_PARSING_INIT_SEGMENT,{frag:U,id:o,tracks:D.tracks})}var M=D.initPTS,H=D.timescale;se(M)&&(this.initPTS[p.cc]={baseTime:M,timescale:H},l.trigger(x.INIT_PTS_FOUND,{frag:p,id:o,initPTS:M,timescale:H}))}if(C&&B&&p.sn!=="initSegment"){var V=B.fragments[p.sn-1-B.startSN],W=p.sn===B.startSN,$=!V||p.cc>V.cc;if(h.independent!==!1){var J=C.startPTS,j=C.endPTS,le=C.startDTS,ie=C.endDTS;if(v)v.elementaryStreams[C.type]={startPTS:J,endPTS:j,startDTS:le,endDTS:ie};else if(C.firstKeyFrame&&C.independent&&u.id===1&&!$&&(this.couldBacktrack=!0),C.dropped&&C.independent){var me=this.getMainFwdBufferInfo(),we=(me?me.end:this.getLoadPosition())+this.config.maxBufferHole,ve=C.firstKeyFramePTS?C.firstKeyFramePTS:J;if(!W&&we<ve-this.config.maxBufferHole&&!$)return void this.backtrack(p);$&&(p.gap=!0),p.setElementaryStreamInfo(C.type,p.start,j,p.start,ie,!0)}p.setElementaryStreamInfo(C.type,J,j,le,ie),this.backtrackFragment&&(this.backtrackFragment=p),this.bufferFragmentData(C,p,v,u,W||$)}else{if(!W&&!$)return void this.backtrack(p);p.gap=!0}}if(T){var Ae=T.startPTS,Ie=T.endPTS,fe=T.startDTS,Pe=T.endDTS;v&&(v.elementaryStreams[ot]={startPTS:Ae,endPTS:Ie,startDTS:fe,endDTS:Pe}),p.setElementaryStreamInfo(ot,Ae,Ie,fe,Pe),this.bufferFragmentData(T,p,v,u)}if(B&&I!=null&&(a=I.samples)!=null&&a.length){var Ue={id:o,frag:p,details:B,samples:I.samples};l.trigger(x.FRAG_PARSING_METADATA,Ue)}if(B&&k){var ze={id:o,frag:p,details:B,samples:k.samples};l.trigger(x.FRAG_PARSING_USERDATA,ze)}}}else this.resetWhenMissingContext(u)},t._bufferInitSegment=function(r,a,o,l){var h=this;if(this.state===Ur){this.audioOnly=!!a.audio&&!a.video,this.altAudio&&!this.audioOnly&&delete a.audio;var u=a.audio,f=a.video,p=a.audiovideo;if(u){var v=r.audioCodec,w=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(v&&(v=v.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),u.metadata.channelCount!==1&&w.indexOf("firefox")===-1&&(v="mp4a.40.5")),w.indexOf("android")!==-1&&u.container!=="audio/mpeg"&&(v="mp4a.40.2",this.log("Android: force audio codec to "+v)),r.audioCodec&&r.audioCodec!==v&&this.log('Swapping manifest audio codec "'+r.audioCodec+'" for "'+v+'"'),u.levelCodec=v,u.id="main",this.log("Init audio buffer, container:"+u.container+", codecs[selected/level/parsed]=["+(v||"")+"/"+(r.audioCodec||"")+"/"+u.codec+"]")}f&&(f.levelCodec=r.videoCodec,f.id="main",this.log("Init video buffer, container:"+f.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+f.codec+"]")),p&&this.log("Init audiovideo buffer, container:"+p.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+p.codec+"]"),this.hls.trigger(x.BUFFER_CODECS,a),Object.keys(a).forEach(function(C){var k=a[C].initSegment;k!=null&&k.byteLength&&h.hls.trigger(x.BUFFER_APPENDING,{type:C,data:k,frag:o,part:null,chunkMeta:l,parent:o.type})}),this.tick()}},t.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Je)},t.backtrack=function(r){this.couldBacktrack=!0,this.backtrackFragment=r,this.resetTransmuxer(),this.flushBufferGap(r),this.fragmentTracker.removeFragment(r),this.fragPrevious=null,this.nextLoadPosition=r.start,this.state=Qe},t.checkFragmentChanged=function(){var r=this.media,a=null;if(r&&r.readyState>1&&r.seeking===!1){var o=r.currentTime;if(ct.isBuffered(r,o)?a=this.getAppendedFrag(o):ct.isBuffered(r,o+.1)&&(a=this.getAppendedFrag(o+.1)),a){this.backtrackFragment=null;var l=this.fragPlaying,h=a.level;l&&a.sn===l.sn&&l.level===h&&a.urlId===l.urlId||(this.fragPlaying=a,this.hls.trigger(x.FRAG_CHANGED,{frag:a}),l&&l.level===h||this.hls.trigger(x.LEVEL_SWITCHED,{level:h}))}}},F(s,[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentFrag",get:function(){var r=this.media;return r?this.fragPlaying||this.getAppendedFrag(r.currentTime):null}},{key:"currentProgramDateTime",get:function(){var r=this.media;if(r){var a=r.currentTime,o=this.currentFrag;if(o&&se(a)&&se(o.programDateTime)){var l=o.programDateTime+1e3*(a-o.start);return new Date(l)}}return null}},{key:"currentLevel",get:function(){var r=this.currentFrag;return r?r.level:-1}},{key:"nextBufferedFrag",get:function(){var r=this.currentFrag;return r?this.followingBufferedFrag(r):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),s})(Al),Fi=(function(){function d(t,r,a){r===void 0&&(r=0),a===void 0&&(a=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=r,this.totalWeight_=a}var s=d.prototype;return s.sample=function(t,r){var a=Math.pow(this.alpha_,t);this.estimate_=r*(1-a)+a*this.estimate_,this.totalWeight_+=t},s.getTotalWeight=function(){return this.totalWeight_},s.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},d})(),Ym=(function(){function d(t,r,a,o){o===void 0&&(o=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=a,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Fi(t),this.fast_=new Fi(r),this.defaultTTFB_=o,this.ttfb_=new Fi(t)}var s=d.prototype;return s.update=function(t,r){var a=this.slow_,o=this.fast_,l=this.ttfb_;a.halfLife!==t&&(this.slow_=new Fi(t,a.getEstimate(),a.getTotalWeight())),o.halfLife!==r&&(this.fast_=new Fi(r,o.getEstimate(),o.getTotalWeight())),l.halfLife!==t&&(this.ttfb_=new Fi(t,l.getEstimate(),l.getTotalWeight()))},s.sample=function(t,r){var a=(t=Math.max(t,this.minDelayMs_))/1e3,o=8*r/a;this.fast_.sample(a,o),this.slow_.sample(a,o)},s.sampleTTFB=function(t){var r=t/1e3,a=Math.sqrt(2)*Math.exp(-Math.pow(r,2)/2);this.ttfb_.sample(a,Math.max(t,5))},s.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},s.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},s.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},s.destroy=function(){},d})(),Km=(function(){function d(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;var r=t.config;this.bwEstimator=new Ym(r.abrEwmaSlowVoD,r.abrEwmaFastVoD,r.abrEwmaDefaultEstimate),this.registerListeners()}var s=d.prototype;return s.registerListeners=function(){var t=this.hls;t.on(x.FRAG_LOADING,this.onFragLoading,this),t.on(x.FRAG_LOADED,this.onFragLoaded,this),t.on(x.FRAG_BUFFERED,this.onFragBuffered,this),t.on(x.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(x.LEVEL_LOADED,this.onLevelLoaded,this)},s.unregisterListeners=function(){var t=this.hls;t.off(x.FRAG_LOADING,this.onFragLoading,this),t.off(x.FRAG_LOADED,this.onFragLoaded,this),t.off(x.FRAG_BUFFERED,this.onFragBuffered,this),t.off(x.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(x.LEVEL_LOADED,this.onLevelLoaded,this)},s.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},s.onFragLoading=function(t,r){var a,o=r.frag;this.ignoreFragment(o)||(this.fragCurrent=o,this.partCurrent=(a=r.part)!=null?a:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))},s.onLevelSwitching=function(t,r){this.clearTimer()},s.getTimeToLoadFrag=function(t,r,a,o){return t+a/r+(o?this.lastLevelLoadSec:0)},s.onLevelLoaded=function(t,r){var a=this.hls.config,o=r.stats,l=o.total,h=o.bwEstimate;se(l)&&se(h)&&(this.lastLevelLoadSec=8*l/h),r.details.live?this.bwEstimator.update(a.abrEwmaSlowLive,a.abrEwmaFastLive):this.bwEstimator.update(a.abrEwmaSlowVoD,a.abrEwmaFastVoD)},s._abandonRulesCheck=function(){var t=this.fragCurrent,r=this.partCurrent,a=this.hls,o=a.autoLevelEnabled,l=a.media;if(t&&l){var h=performance.now(),u=r?r.stats:t.stats,f=r?r.duration:t.duration,p=h-u.loading.start;if(u.aborted||u.loaded&&u.loaded===u.total||t.level===0)return this.clearTimer(),void(this._nextAutoLevel=-1);if(o&&!l.paused&&l.playbackRate&&l.readyState){var v=a.mainForwardBufferInfo;if(v!==null){var w=this.bwEstimator.getEstimateTTFB(),C=Math.abs(l.playbackRate);if(!(p<=Math.max(w,f/(2*C)*1e3))){var k=v.len/C;if(!(k>=2*f/C)){var I=u.loading.first?u.loading.first-u.loading.start:-1,D=u.loaded&&I>-1,B=this.bwEstimator.getEstimate(),T=a.levels,U=a.minAutoLevel,M=T[t.level],H=u.total||Math.max(u.loaded,Math.round(f*M.maxBitrate/8)),V=p-I;V<1&&D&&(V=Math.min(p,8*u.loaded/B));var W=D?1e3*u.loaded/V:0,$=W?(H-u.loaded)/W:8*H/B+w/1e3;if(!($<=k)){var J,j=W?8*W:B,le=Number.POSITIVE_INFINITY;for(J=t.level-1;J>U;J--){var ie=T[J].maxBitrate;if((le=this.getTimeToLoadFrag(w/1e3,j,f*ie,!T[J].details))<k)break}le>=$||le>10*f||(a.nextLoadLevel=J,D?this.bwEstimator.sample(p-Math.min(w,I),u.loaded):this.bwEstimator.sampleTTFB(p),this.clearTimer(),G.warn("[abr] Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+` is loading too slowly;
11
+ initSegmentChange: `+j);var ie=new Nm(a,o,r,u,v);this.configureTransmuxer(ie)}if(this.frag=l,this.part=h,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:B,chunkMeta:p,state:le},t instanceof ArrayBuffer?[t]:[]);else if(I){var me=I.push(t,B,p,le);li(me)?(I.async=!0,me.then(function(we){k.handleTransmuxComplete(we)}).catch(function(we){k.transmuxerError(we,p,"transmuxer-interface push error")})):(I.async=!1,this.handleTransmuxComplete(me))}},s.flush=function(t){var r=this;t.transmuxing.start=self.performance.now();var a=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(a){var o=a.flush(t);li(o)||a.async?(li(o)||(o=Promise.resolve(o)),o.then(function(l){r.handleFlushResult(l,t)}).catch(function(l){r.transmuxerError(l,t,"transmuxer-interface flush error")})):this.handleFlushResult(o,t)}},s.transmuxerError=function(t,r,a){this.hls&&(this.error=t,this.hls.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_PARSING_ERROR,chunkMeta:r,fatal:!1,error:t,err:t,reason:a}))},s.handleFlushResult=function(t,r){var a=this;t.forEach(function(o){a.handleTransmuxComplete(o)}),this.onFlush(r)},s.onWorkerMessage=function(t){var r=t.data,a=this.hls;switch(r.event){case"init":var o,l=(o=this.workerContext)==null?void 0:o.objectURL;l&&self.URL.revokeObjectURL(l);break;case"transmuxComplete":this.handleTransmuxComplete(r.data);break;case"flush":this.onFlush(r.data);break;case"workerLog":G[r.data.logType]&&G[r.data.logType](r.data.message);break;default:r.data=r.data||{},r.data.frag=this.frag,r.data.id=this.id,a.trigger(r.event,r.data)}},s.configureTransmuxer=function(t){var r=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):r&&r.configure(t)},s.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},d})(),Gm=(function(){function d(t,r,a,o){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=r,this.fragmentTracker=a,this.hls=o}var s=d.prototype;return s.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},s.poll=function(t,r){var a=this.config,o=this.media,l=this.stalled;if(o!==null){var h=o.currentTime,u=o.seeking,f=this.seeking&&!u,p=!this.seeking&&u;if(this.seeking=u,h===t){if(p||f)this.stalled=null;else if(!(o.paused&&!u||o.ended||o.playbackRate===0)&&ct.getBuffered(o).length){var v=ct.bufferInfo(o,h,0),w=v.len>0,C=v.nextStart||0;if(w||C){if(u){var k=v.len>2,I=!C||r&&r.start<=h||C-h>2&&!this.fragmentTracker.getPartialFragment(h);if(k||I)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var D,B=Math.max(C,v.start||0)-h,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,U=!(T==null||(D=T.details)==null)&&D.live?2*T.details.targetduration:2,M=this.fragmentTracker.getPartialFragment(h);if(B>0&&(B<=U||M))return void this._trySkipBufferHole(M)}var H=self.performance.now();if(l!==null){var V=H-l;if(u||!(V>=250)||(this._reportStall(v),this.media)){var W=ct.bufferInfo(o,h,a.maxBufferHole);this._tryFixBufferStall(W,V)}}else this.stalled=H}}}else if(this.moved=!0,l!==null){if(this.stallReported){var $=self.performance.now()-l;G.warn("playback not stuck anymore @"+h+", after "+Math.round($)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},s._tryFixBufferStall=function(t,r){var a=this.config,o=this.fragmentTracker,l=this.media;if(l!==null){var h=l.currentTime,u=o.getPartialFragment(h);if(u&&(this._trySkipBufferHole(u)||!this.media))return;(t.len>a.maxBufferHole||t.nextStart&&t.nextStart-h<a.maxBufferHole)&&r>1e3*a.highBufferWatchdogPeriod&&(G.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},s._reportStall=function(t){var r=this.hls,a=this.media;if(!this.stallReported&&a){this.stallReported=!0;var o=new Error("Playback stalling at @"+a.currentTime+" due to low buffer ("+JSON.stringify(t)+")");G.warn(o.message),r.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.BUFFER_STALLED_ERROR,fatal:!1,error:o,buffer:t.len})}},s._trySkipBufferHole=function(t){var r=this.config,a=this.hls,o=this.media;if(o===null)return 0;var l=o.currentTime,h=ct.bufferInfo(o,l,0),u=l<h.start?h.start:h.nextStart;if(u){var f=h.len<=r.maxBufferHole,p=h.len>0&&h.len<1&&o.readyState<3,v=u-l;if(v>0&&(f||p)){if(v>r.maxBufferHole){var w=this.fragmentTracker,C=!1;if(l===0){var k=w.getAppendedFrag(0,Je);k&&u<k.end&&(C=!0)}if(!C){var I=t||w.getAppendedFrag(l,Je);if(I){for(var D=!1,B=I.end;B<u;){var T=w.getPartialFragment(B);if(!T){D=!0;break}B+=T.duration}if(D)return 0}}}var U=Math.max(u+.05,l+.1);if(G.warn("skipping hole, adjusting currentTime from "+l+" to "+U),this.moved=!0,this.stalled=null,o.currentTime=U,t&&!t.gap){var M=new Error("fragment loaded with buffer holes, seeking from "+l+" to "+U);a.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:M,reason:M.message,frag:t})}return U}}return 0},s._tryNudgeBuffer=function(){var t=this.config,r=this.hls,a=this.media,o=this.nudgeRetry;if(a!==null){var l=a.currentTime;if(this.nudgeRetry++,o<t.nudgeMaxRetry){var h=l+(o+1)*t.nudgeOffset,u=new Error("Nudging 'currentTime' from "+l+" to "+h);G.warn(u.message),a.currentTime=h,r.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.BUFFER_NUDGE_ON_STALL,error:u,fatal:!1})}else{var f=new Error("Playhead still not moving while enough data buffered @"+l+" after "+t.nudgeMaxRetry+" nudges");G.error(f.message),r.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.BUFFER_STALLED_ERROR,error:f,fatal:!0})}}},d})(),Ym=(function(d){function s(r,a,o){var l;return(l=d.call(this,r,a,o,"[stream-controller]",Je)||this).audioCodecSwap=!1,l.gapController=null,l.level=-1,l._forceStartLoad=!1,l.altAudio=!1,l.audioOnly=!1,l.fragPlaying=null,l.onvplaying=null,l.onvseeked=null,l.fragLastKbps=0,l.couldBacktrack=!1,l.backtrackFragment=null,l.audioCodecSwitch=!1,l.videoBuffer=null,l._registerListeners(),l}X(s,d);var t=s.prototype;return t._registerListeners=function(){var r=this.hls;r.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(x.MANIFEST_LOADING,this.onManifestLoading,this),r.on(x.MANIFEST_PARSED,this.onManifestParsed,this),r.on(x.LEVEL_LOADING,this.onLevelLoading,this),r.on(x.LEVEL_LOADED,this.onLevelLoaded,this),r.on(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(x.ERROR,this.onError,this),r.on(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(x.BUFFER_CREATED,this.onBufferCreated,this),r.on(x.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(x.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(x.FRAG_BUFFERED,this.onFragBuffered,this)},t._unregisterListeners=function(){var r=this.hls;r.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(x.MANIFEST_LOADING,this.onManifestLoading,this),r.off(x.MANIFEST_PARSED,this.onManifestParsed,this),r.off(x.LEVEL_LOADED,this.onLevelLoaded,this),r.off(x.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(x.ERROR,this.onError,this),r.off(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(x.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(x.BUFFER_CREATED,this.onBufferCreated,this),r.off(x.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(x.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(x.FRAG_BUFFERED,this.onFragBuffered,this)},t.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},t.startLoad=function(r){if(this.levels){var a=this.lastCurrentTime,o=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var l=o.startLevel;l===-1&&(o.config.testBandwidth&&this.levels.length>1?(l=0,this.bitrateTest=!0):l=o.nextAutoLevel),this.level=o.nextLoadLevel=l,this.loadedmetadata=!1}a>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),r=a),this.state=Qe,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=Vt},t.stopLoad=function(){this._forceStartLoad=!1,d.prototype.stopLoad.call(this)},t.doTick=function(){switch(this.state){case si:var r,a=this.levels,o=this.level,l=a==null||(r=a[o])==null?void 0:r.details;if(l&&(!l.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(l))break;this.state=Qe;break}if(this.hls.nextLoadLevel!==this.level){this.state=Qe;break}break;case Ri:var h,u=self.performance.now(),f=this.retryDate;(!f||u>=f||(h=this.media)!=null&&h.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Qe)}this.state===Qe&&this.doTickIdle(),this.onTickEnd()},t.onTickEnd=function(){d.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},t.doTickIdle=function(){var r=this.hls,a=this.levelLastLoaded,o=this.levels,l=this.media,h=r.config,u=r.nextLoadLevel;if(a!==null&&(l||!this.startFragRequested&&h.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&o!=null&&o[u]){var f=o[u],p=this.getMainFwdBufferInfo();if(p!==null){var v=this.getLevelDetails();if(v&&this._streamEnded(p,v)){var w={};this.altAudio&&(w.type="video"),this.hls.trigger(x.BUFFER_EOS,w),this.state=Ea;return}r.loadLevel!==u&&r.manualLevel===-1&&this.log("Adapting to level "+u+" from level "+this.level),this.level=r.nextLoadLevel=u;var C=f.details;if(!C||this.state===si||C.live&&this.levelLastLoaded!==u)return this.level=u,void(this.state=si);var k=p.len,I=this.getMaxBufferLength(f.maxBitrate);if(!(k>=I)){this.backtrackFragment&&this.backtrackFragment.start>p.end&&(this.backtrackFragment=null);var D=this.backtrackFragment?this.backtrackFragment.start:p.end,B=this.getNextFragment(D,C);if(this.couldBacktrack&&!this.fragPrevious&&B&&B.sn!=="initSegment"&&this.fragmentTracker.getState(B)!==wa){var T,U=((T=this.backtrackFragment)!=null?T:B).sn-C.startSN,M=C.fragments[U-1];M&&B.cc===M.cc&&(B=M,this.fragmentTracker.removeFragment(M))}else this.backtrackFragment&&p.len&&(this.backtrackFragment=null);if(B&&this.isLoopLoading(B,D)){if(!B.gap){var H=this.audioOnly&&!this.altAudio?ot:bt,V=(H===bt?this.videoBuffer:this.mediaBuffer)||this.media;V&&this.afterBufferFlushed(V,H,Je)}B=this.getNextFragmentLoopLoading(B,C,p,Je,I)}B&&(!B.initSegment||B.initSegment.data||this.bitrateTest||(B=B.initSegment),this.loadFragment(B,f,D))}}}},t.loadFragment=function(r,a,o){var l=this.fragmentTracker.getState(r);this.fragCurrent=r,l===ya||l===xi?r.sn==="initSegment"?this._loadInitSegment(r,a):this.bitrateTest?(this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r,a)):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,a,o)):this.clearTrackerIfNeeded(r)},t.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,Je)},t.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},t.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},t.nextLevelSwitch=function(){var r=this.levels,a=this.media;if(a!=null&&a.readyState){var o,l=this.getAppendedFrag(a.currentTime);l&&l.start>1&&this.flushMainBuffer(0,l.start-1);var h=this.getLevelDetails();if(h!=null&&h.live){var u=this.getMainFwdBufferInfo();if(!u||u.len<2*h.targetduration)return}if(!a.paused&&r){var f=r[this.hls.nextLoadLevel],p=this.fragLastKbps;o=p&&this.fragCurrent?this.fragCurrent.duration*f.maxBitrate/(1e3*p)+1:0}else o=0;var v=this.getBufferedFrag(a.currentTime+o);if(v){var w=this.followingBufferedFrag(v);if(w){this.abortCurrentFrag();var C=w.maxStartPTS?w.maxStartPTS:w.start,k=w.duration,I=Math.max(v.end,C+Math.min(Math.max(k-this.config.maxFragLookUpTolerance,.5*k),.75*k));this.flushMainBuffer(I,Number.POSITIVE_INFINITY)}}}},t.abortCurrentFrag=function(){var r=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,r&&(r.abortRequests(),this.fragmentTracker.removeFragment(r)),this.state){case vl:case Di:case Ri:case Ur:case Pn:this.state=Qe}this.nextLoadPosition=this.getLoadPosition()},t.flushMainBuffer=function(r,a){d.prototype.flushMainBuffer.call(this,r,a,this.altAudio?"video":null)},t.onMediaAttached=function(r,a){d.prototype.onMediaAttached.call(this,r,a);var o=a.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),o.addEventListener("playing",this.onvplaying),o.addEventListener("seeked",this.onvseeked),this.gapController=new Gm(this.config,o,this.fragmentTracker,this.hls)},t.onMediaDetaching=function(){var r=this.media;r&&this.onvplaying&&this.onvseeked&&(r.removeEventListener("playing",this.onvplaying),r.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),d.prototype.onMediaDetaching.call(this)},t.onMediaPlaying=function(){this.tick()},t.onMediaSeeked=function(){var r=this.media,a=r?r.currentTime:null;se(a)&&this.log("Media seeked to "+a.toFixed(3));var o=this.getMainFwdBufferInfo();o!==null&&o.len!==0?this.tick():this.warn('Main forward buffer length on "seeked" event '+(o?o.len:"empty")+")")},t.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(x.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1},t.onManifestParsed=function(r,a){var o,l,h,u=!1,f=!1;a.levels.forEach(function(p){(o=p.audioCodec)&&(o.indexOf("mp4a.40.2")!==-1&&(u=!0),o.indexOf("mp4a.40.5")!==-1&&(f=!0))}),this.audioCodecSwitch=u&&f&&typeof((h=ig())==null||(l=h.prototype)==null?void 0:l.changeType)!="function",this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=a.levels,this.startFragRequested=!1},t.onLevelLoading=function(r,a){var o=this.levels;if(o&&this.state===Qe){var l=o[a.level];(!l.details||l.details.live&&this.levelLastLoaded!==a.level||this.waitForCdnTuneIn(l.details))&&(this.state=si)}},t.onLevelLoaded=function(r,a){var o,l=this.levels,h=a.level,u=a.details,f=u.totalduration;if(l){this.log("Level "+h+" loaded ["+u.startSN+","+u.endSN+"]"+(u.lastPartSn?"[part-"+u.lastPartSn+"-"+u.lastPartIndex+"]":"")+", cc ["+u.startCC+", "+u.endCC+"] duration:"+f);var p=l[h],v=this.fragCurrent;!v||this.state!==Di&&this.state!==Ri||v.level===a.level&&v.urlId===p.urlId||!v.loader||this.abortCurrentFrag();var w=0;if(u.live||(o=p.details)!=null&&o.live){if(this.checkLiveUpdate(u),u.deltaUpdateFailed)return;w=this.alignPlaylists(u,p.details)}if(p.details=u,this.levelLastLoaded=h,this.hls.trigger(x.LEVEL_UPDATED,{details:u,level:h}),this.state===si){if(this.waitForCdnTuneIn(u))return;this.state=Qe}this.startFragRequested?u.live&&this.synchronizeToLiveEdge(u):this.setStartPosition(u,w),this.tick()}else this.warn("Levels were reset while loading level "+h)},t._handleFragmentLoadProgress=function(r){var a,o=r.frag,l=r.part,h=r.payload,u=this.levels;if(u){var f=u[o.level],p=f.details;if(!p)return this.warn("Dropping fragment "+o.sn+" of level "+o.level+" after level details were reset"),void this.fragmentTracker.removeFragment(o);var v=f.videoCodec,w=p.PTSKnown||!p.live,C=(a=o.initSegment)==null?void 0:a.data,k=this._getAudioCodec(f),I=this.transmuxer=this.transmuxer||new Cg(this.hls,Je,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),D=l?l.index:-1,B=D!==-1,T=new fl(o.level,o.sn,o.stats.chunkCount,h.byteLength,D,B),U=this.initPTS[o.cc];I.push(h,C,k,v,o,l,p.totalduration,w,T,U)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered")},t.onAudioTrackSwitching=function(r,a){var o=this.altAudio;if(!a.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var l=this.fragCurrent;l&&(this.log("Switching to main audio track, cancel main fragment load"),l.abortRequests(),this.fragmentTracker.removeFragment(l)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var h=this.hls;o&&(h.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),h.trigger(x.AUDIO_TRACK_SWITCHED,a)}},t.onAudioTrackSwitched=function(r,a){var o=a.id,l=!!this.hls.audioTracks[o].url;if(l){var h=this.videoBuffer;h&&this.mediaBuffer!==h&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=h)}this.altAudio=l,this.tick()},t.onBufferCreated=function(r,a){var o,l,h=a.tracks,u=!1;for(var f in h){var p=h[f];if(p.id==="main"){if(l=f,o=p,f==="video"){var v=h[f];v&&(this.videoBuffer=v.buffer)}}else u=!0}u&&o?(this.log("Alternate track found, use "+l+".buffered to schedule main fragment loading"),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media},t.onFragBuffered=function(r,a){var o=a.frag,l=a.part;if(!o||o.type===Je){if(this.fragContextChanged(o))return this.warn("Fragment "+o.sn+(l?" p: "+l.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===Pn&&(this.state=Qe));var h=l?l.stats:o.stats;this.fragLastKbps=Math.round(8*h.total/(h.buffering.end-h.loading.first)),o.sn!=="initSegment"&&(this.fragPrevious=o),this.fragBufferedComplete(o,l)}},t.onError=function(r,a){var o;if(a.fatal)this.state=Li;else switch(a.details){case q.FRAG_GAP:case q.FRAG_PARSING_ERROR:case q.FRAG_DECRYPT_ERROR:case q.FRAG_LOAD_ERROR:case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_ERROR:case q.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Je,a);break;case q.LEVEL_LOAD_ERROR:case q.LEVEL_LOAD_TIMEOUT:case q.LEVEL_PARSING_ERROR:a.levelRetry||this.state!==si||((o=a.context)==null?void 0:o.type)!==oi||(this.state=Qe);break;case q.BUFFER_FULL_ERROR:if(!a.parent||a.parent!=="main")return;this.reduceLengthAndFlushBuffer(a)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case q.INTERNAL_EXCEPTION:this.recoverWorkerError(a)}},t.checkBuffer=function(){var r=this.media,a=this.gapController;if(r&&a&&r.readyState){if(this.loadedmetadata||!ct.getBuffered(r).length){var o=this.state!==Qe?this.fragCurrent:null;a.poll(this.lastCurrentTime,o)}this.lastCurrentTime=r.currentTime}},t.onFragLoadEmergencyAborted=function(){this.state=Qe,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},t.onBufferFlushed=function(r,a){var o=a.type;if(o!==ot||this.audioOnly&&!this.altAudio){var l=(o===bt?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(l,o,Je)}},t.onLevelsUpdated=function(r,a){this.levels=a.levels},t.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},t.seekToStartPos=function(){var r=this.media;if(r){var a=r.currentTime,o=this.startPosition;if(o>=0&&a<o){if(r.seeking)return void this.log("could not seek to "+o+", already seeking at "+a);var l=ct.getBuffered(r),h=(l.length?l.start(0):0)-o;h>0&&(h<this.config.maxBufferHole||h<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+h+" to match buffer start"),o+=h,this.startPosition=o),this.log("seek to target start position "+o+" from current time "+a),r.currentTime=o}}},t._getAudioCodec=function(r){var a=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&a&&(this.log("Swapping audio codec"),a=a.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),a},t._loadBitrateTestFrag=function(r,a){var o=this;r.bitrateTest=!0,this._doFragLoad(r,a).then(function(l){var h=o.hls;if(l&&!o.fragContextChanged(r)){a.fragmentError=0,o.state=Qe,o.startFragRequested=!1,o.bitrateTest=!1;var u=r.stats;u.parsing.start=u.parsing.end=u.buffering.start=u.buffering.end=self.performance.now(),h.trigger(x.FRAG_LOADED,l),r.bitrateTest=!1}})},t._handleTransmuxComplete=function(r){var a,o="main",l=this.hls,h=r.remuxResult,u=r.chunkMeta,f=this.getCurrentContext(u);if(f){var p=f.frag,v=f.part,w=f.level,C=h.video,k=h.text,I=h.id3,D=h.initSegment,B=w.details,T=this.altAudio?void 0:h.audio;if(this.fragContextChanged(p))this.fragmentTracker.removeFragment(p);else{if(this.state=Ur,D){if(D!=null&&D.tracks){var U=p.initSegment||p;this._bufferInitSegment(w,D.tracks,U,u),l.trigger(x.FRAG_PARSING_INIT_SEGMENT,{frag:U,id:o,tracks:D.tracks})}var M=D.initPTS,H=D.timescale;se(M)&&(this.initPTS[p.cc]={baseTime:M,timescale:H},l.trigger(x.INIT_PTS_FOUND,{frag:p,id:o,initPTS:M,timescale:H}))}if(C&&B&&p.sn!=="initSegment"){var V=B.fragments[p.sn-1-B.startSN],W=p.sn===B.startSN,$=!V||p.cc>V.cc;if(h.independent!==!1){var J=C.startPTS,j=C.endPTS,le=C.startDTS,ie=C.endDTS;if(v)v.elementaryStreams[C.type]={startPTS:J,endPTS:j,startDTS:le,endDTS:ie};else if(C.firstKeyFrame&&C.independent&&u.id===1&&!$&&(this.couldBacktrack=!0),C.dropped&&C.independent){var me=this.getMainFwdBufferInfo(),we=(me?me.end:this.getLoadPosition())+this.config.maxBufferHole,ve=C.firstKeyFramePTS?C.firstKeyFramePTS:J;if(!W&&we<ve-this.config.maxBufferHole&&!$)return void this.backtrack(p);$&&(p.gap=!0),p.setElementaryStreamInfo(C.type,p.start,j,p.start,ie,!0)}p.setElementaryStreamInfo(C.type,J,j,le,ie),this.backtrackFragment&&(this.backtrackFragment=p),this.bufferFragmentData(C,p,v,u,W||$)}else{if(!W&&!$)return void this.backtrack(p);p.gap=!0}}if(T){var Ae=T.startPTS,Ie=T.endPTS,fe=T.startDTS,Pe=T.endDTS;v&&(v.elementaryStreams[ot]={startPTS:Ae,endPTS:Ie,startDTS:fe,endDTS:Pe}),p.setElementaryStreamInfo(ot,Ae,Ie,fe,Pe),this.bufferFragmentData(T,p,v,u)}if(B&&I!=null&&(a=I.samples)!=null&&a.length){var Ue={id:o,frag:p,details:B,samples:I.samples};l.trigger(x.FRAG_PARSING_METADATA,Ue)}if(B&&k){var ze={id:o,frag:p,details:B,samples:k.samples};l.trigger(x.FRAG_PARSING_USERDATA,ze)}}}else this.resetWhenMissingContext(u)},t._bufferInitSegment=function(r,a,o,l){var h=this;if(this.state===Ur){this.audioOnly=!!a.audio&&!a.video,this.altAudio&&!this.audioOnly&&delete a.audio;var u=a.audio,f=a.video,p=a.audiovideo;if(u){var v=r.audioCodec,w=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(v&&(v=v.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),u.metadata.channelCount!==1&&w.indexOf("firefox")===-1&&(v="mp4a.40.5")),w.indexOf("android")!==-1&&u.container!=="audio/mpeg"&&(v="mp4a.40.2",this.log("Android: force audio codec to "+v)),r.audioCodec&&r.audioCodec!==v&&this.log('Swapping manifest audio codec "'+r.audioCodec+'" for "'+v+'"'),u.levelCodec=v,u.id="main",this.log("Init audio buffer, container:"+u.container+", codecs[selected/level/parsed]=["+(v||"")+"/"+(r.audioCodec||"")+"/"+u.codec+"]")}f&&(f.levelCodec=r.videoCodec,f.id="main",this.log("Init video buffer, container:"+f.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+f.codec+"]")),p&&this.log("Init audiovideo buffer, container:"+p.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+p.codec+"]"),this.hls.trigger(x.BUFFER_CODECS,a),Object.keys(a).forEach(function(C){var k=a[C].initSegment;k!=null&&k.byteLength&&h.hls.trigger(x.BUFFER_APPENDING,{type:C,data:k,frag:o,part:null,chunkMeta:l,parent:o.type})}),this.tick()}},t.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Je)},t.backtrack=function(r){this.couldBacktrack=!0,this.backtrackFragment=r,this.resetTransmuxer(),this.flushBufferGap(r),this.fragmentTracker.removeFragment(r),this.fragPrevious=null,this.nextLoadPosition=r.start,this.state=Qe},t.checkFragmentChanged=function(){var r=this.media,a=null;if(r&&r.readyState>1&&r.seeking===!1){var o=r.currentTime;if(ct.isBuffered(r,o)?a=this.getAppendedFrag(o):ct.isBuffered(r,o+.1)&&(a=this.getAppendedFrag(o+.1)),a){this.backtrackFragment=null;var l=this.fragPlaying,h=a.level;l&&a.sn===l.sn&&l.level===h&&a.urlId===l.urlId||(this.fragPlaying=a,this.hls.trigger(x.FRAG_CHANGED,{frag:a}),l&&l.level===h||this.hls.trigger(x.LEVEL_SWITCHED,{level:h}))}}},F(s,[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentFrag",get:function(){var r=this.media;return r?this.fragPlaying||this.getAppendedFrag(r.currentTime):null}},{key:"currentProgramDateTime",get:function(){var r=this.media;if(r){var a=r.currentTime,o=this.currentFrag;if(o&&se(a)&&se(o.programDateTime)){var l=o.programDateTime+1e3*(a-o.start);return new Date(l)}}return null}},{key:"currentLevel",get:function(){var r=this.currentFrag;return r?r.level:-1}},{key:"nextBufferedFrag",get:function(){var r=this.currentFrag;return r?this.followingBufferedFrag(r):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),s})(Al),Fi=(function(){function d(t,r,a){r===void 0&&(r=0),a===void 0&&(a=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=r,this.totalWeight_=a}var s=d.prototype;return s.sample=function(t,r){var a=Math.pow(this.alpha_,t);this.estimate_=r*(1-a)+a*this.estimate_,this.totalWeight_+=t},s.getTotalWeight=function(){return this.totalWeight_},s.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},d})(),Km=(function(){function d(t,r,a,o){o===void 0&&(o=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=a,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Fi(t),this.fast_=new Fi(r),this.defaultTTFB_=o,this.ttfb_=new Fi(t)}var s=d.prototype;return s.update=function(t,r){var a=this.slow_,o=this.fast_,l=this.ttfb_;a.halfLife!==t&&(this.slow_=new Fi(t,a.getEstimate(),a.getTotalWeight())),o.halfLife!==r&&(this.fast_=new Fi(r,o.getEstimate(),o.getTotalWeight())),l.halfLife!==t&&(this.ttfb_=new Fi(t,l.getEstimate(),l.getTotalWeight()))},s.sample=function(t,r){var a=(t=Math.max(t,this.minDelayMs_))/1e3,o=8*r/a;this.fast_.sample(a,o),this.slow_.sample(a,o)},s.sampleTTFB=function(t){var r=t/1e3,a=Math.sqrt(2)*Math.exp(-Math.pow(r,2)/2);this.ttfb_.sample(a,Math.max(t,5))},s.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},s.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},s.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},s.destroy=function(){},d})(),zm=(function(){function d(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;var r=t.config;this.bwEstimator=new Km(r.abrEwmaSlowVoD,r.abrEwmaFastVoD,r.abrEwmaDefaultEstimate),this.registerListeners()}var s=d.prototype;return s.registerListeners=function(){var t=this.hls;t.on(x.FRAG_LOADING,this.onFragLoading,this),t.on(x.FRAG_LOADED,this.onFragLoaded,this),t.on(x.FRAG_BUFFERED,this.onFragBuffered,this),t.on(x.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(x.LEVEL_LOADED,this.onLevelLoaded,this)},s.unregisterListeners=function(){var t=this.hls;t.off(x.FRAG_LOADING,this.onFragLoading,this),t.off(x.FRAG_LOADED,this.onFragLoaded,this),t.off(x.FRAG_BUFFERED,this.onFragBuffered,this),t.off(x.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(x.LEVEL_LOADED,this.onLevelLoaded,this)},s.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},s.onFragLoading=function(t,r){var a,o=r.frag;this.ignoreFragment(o)||(this.fragCurrent=o,this.partCurrent=(a=r.part)!=null?a:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))},s.onLevelSwitching=function(t,r){this.clearTimer()},s.getTimeToLoadFrag=function(t,r,a,o){return t+a/r+(o?this.lastLevelLoadSec:0)},s.onLevelLoaded=function(t,r){var a=this.hls.config,o=r.stats,l=o.total,h=o.bwEstimate;se(l)&&se(h)&&(this.lastLevelLoadSec=8*l/h),r.details.live?this.bwEstimator.update(a.abrEwmaSlowLive,a.abrEwmaFastLive):this.bwEstimator.update(a.abrEwmaSlowVoD,a.abrEwmaFastVoD)},s._abandonRulesCheck=function(){var t=this.fragCurrent,r=this.partCurrent,a=this.hls,o=a.autoLevelEnabled,l=a.media;if(t&&l){var h=performance.now(),u=r?r.stats:t.stats,f=r?r.duration:t.duration,p=h-u.loading.start;if(u.aborted||u.loaded&&u.loaded===u.total||t.level===0)return this.clearTimer(),void(this._nextAutoLevel=-1);if(o&&!l.paused&&l.playbackRate&&l.readyState){var v=a.mainForwardBufferInfo;if(v!==null){var w=this.bwEstimator.getEstimateTTFB(),C=Math.abs(l.playbackRate);if(!(p<=Math.max(w,f/(2*C)*1e3))){var k=v.len/C;if(!(k>=2*f/C)){var I=u.loading.first?u.loading.first-u.loading.start:-1,D=u.loaded&&I>-1,B=this.bwEstimator.getEstimate(),T=a.levels,U=a.minAutoLevel,M=T[t.level],H=u.total||Math.max(u.loaded,Math.round(f*M.maxBitrate/8)),V=p-I;V<1&&D&&(V=Math.min(p,8*u.loaded/B));var W=D?1e3*u.loaded/V:0,$=W?(H-u.loaded)/W:8*H/B+w/1e3;if(!($<=k)){var J,j=W?8*W:B,le=Number.POSITIVE_INFINITY;for(J=t.level-1;J>U;J--){var ie=T[J].maxBitrate;if((le=this.getTimeToLoadFrag(w/1e3,j,f*ie,!T[J].details))<k)break}le>=$||le>10*f||(a.nextLoadLevel=J,D?this.bwEstimator.sample(p-Math.min(w,I),u.loaded):this.bwEstimator.sampleTTFB(p),this.clearTimer(),G.warn("[abr] Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+` is loading too slowly;
12
12
  Time to underbuffer: `+k.toFixed(3)+` s
13
13
  Estimated load time for current fragment: `+$.toFixed(3)+` s
14
14
  Estimated load time for down switch fragment: `+le.toFixed(3)+` s
15
15
  TTFB estimate: `+I+`
16
16
  Current BW estimate: `+(se(B)?(B/1024).toFixed(3):"Unknown")+` Kb/s
17
17
  New BW estimate: `+(this.bwEstimator.getEstimate()/1024).toFixed(3)+` Kb/s
18
- Aborting and switching to level `+J),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),a.trigger(x.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:u}))}}}}}}},s.onFragLoaded=function(t,r){var a=r.frag,o=r.part,l=o?o.stats:a.stats;if(a.type===Je&&this.bwEstimator.sampleTTFB(l.loading.first-l.loading.start),!this.ignoreFragment(a)){if(this.clearTimer(),this.lastLoadedFragLevel=a.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var h=o?o.duration:a.duration,u=this.hls.levels[a.level],f=(u.loaded?u.loaded.bytes:0)+l.loaded,p=(u.loaded?u.loaded.duration:0)+h;u.loaded={bytes:f,duration:p},u.realBitrate=Math.round(8*f/p)}if(a.bitrateTest){var v={stats:l,frag:a,part:o,id:a.type};this.onFragBuffered(x.FRAG_BUFFERED,v),a.bitrateTest=!1}}},s.onFragBuffered=function(t,r){var a=r.frag,o=r.part,l=o!=null&&o.stats.loaded?o.stats:a.stats;if(!l.aborted&&!this.ignoreFragment(a)){var h=l.parsing.end-l.loading.start-Math.min(l.loading.first-l.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(h,l.loaded),l.bwEstimate=this.bwEstimator.getEstimate(),a.bitrateTest?this.bitrateTestDelay=h/1e3:this.bitrateTestDelay=0}},s.ignoreFragment=function(t){return t.type!==Je||t.sn==="initSegment"},s.clearTimer=function(){self.clearInterval(this.timer)},s.getNextABRAutoLevel=function(){var t=this.fragCurrent,r=this.partCurrent,a=this.hls,o=a.maxAutoLevel,l=a.config,h=a.minAutoLevel,u=a.media,f=r?r.duration:t?t.duration:0,p=u&&u.playbackRate!==0?Math.abs(u.playbackRate):1,v=this.bwEstimator?this.bwEstimator.getEstimate():l.abrEwmaDefaultEstimate,w=a.mainForwardBufferInfo,C=(w?w.len:0)/p,k=this.findBestLevel(v,h,o,C,l.abrBandWidthFactor,l.abrBandWidthUpFactor);if(k>=0)return k;G.trace("[abr] "+(C?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var I=f?Math.min(f,l.maxStarvationDelay):l.maxStarvationDelay,D=l.abrBandWidthFactor,B=l.abrBandWidthUpFactor;if(!C){var T=this.bitrateTestDelay;T&&(I=(f?Math.min(f,l.maxLoadingDelay):l.maxLoadingDelay)-T,G.trace("[abr] bitrate test took "+Math.round(1e3*T)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*I)+" ms"),D=B=1)}return k=this.findBestLevel(v,h,o,C+I,D,B),Math.max(k,0)},s.findBestLevel=function(t,r,a,o,l,h){for(var u,f=this.fragCurrent,p=this.partCurrent,v=this.lastLoadedFragLevel,w=this.hls.levels,C=w[v],k=!(C==null||(u=C.details)==null||!u.live),I=C?.codecSet,D=p?p.duration:f?f.duration:0,B=this.bwEstimator.getEstimateTTFB()/1e3,T=r,U=-1,M=a;M>=r;M--){var H=w[M];if(!H||I&&H.codecSet!==I)H&&(T=Math.min(M,T),U=Math.max(M,U));else{U!==-1&&G.trace("[abr] Skipped level(s) "+T+"-"+U+' with CODECS:"'+w[U].attrs.CODECS+'"; not compatible with "'+C.attrs.CODECS+'"');var V=H.details,W=(p?V?.partTarget:V?.averagetargetduration)||D,$=void 0;$=M<=v?l*t:h*t;var J=w[M].maxBitrate,j=this.getTimeToLoadFrag(B,$,J*W,V===void 0);if(G.trace("[abr] level:"+M+" adjustedbw-bitrate:"+Math.round($-J)+" avgDuration:"+W.toFixed(1)+" maxFetchDuration:"+o.toFixed(1)+" fetchDuration:"+j.toFixed(1)),$>J&&(j===0||!se(j)||k&&!this.bitrateTestDelay||j<o))return M}}return-1},F(d,[{key:"nextAutoLevel",get:function(){var t=this._nextAutoLevel,r=this.bwEstimator;if(t!==-1&&!r.canEstimate())return t;var a=this.getNextABRAutoLevel();if(t!==-1){var o=this.hls.levels;if(o.length>Math.max(t,a)&&o[t].loadError<=o[a].loadError)return t}return t!==-1&&(a=Math.min(t,a)),a},set:function(t){this._nextAutoLevel=t}}]),d})(),Eg=(function(){function d(){this.chunks=[],this.dataLength=0}var s=d.prototype;return s.push=function(t){this.chunks.push(t),this.dataLength+=t.length},s.flush=function(){var t,r=this.chunks,a=this.dataLength;return r.length?(t=r.length===1?r[0]:(function(o,l){for(var h=new Uint8Array(l),u=0,f=0;f<o.length;f++){var p=o[f];h.set(p,u),u+=p.length}return h})(r,a),this.reset(),t):new Uint8Array(0)},s.reset=function(){this.chunks.length=0,this.dataLength=0},d})(),zm=(function(d){function s(r,a,o){var l;return(l=d.call(this,r,a,o,"[audio-stream-controller]",Cr)||this).videoBuffer=null,l.videoTrackCC=-1,l.waitingVideoCC=-1,l.bufferedTrack=null,l.switchingTrack=null,l.trackId=-1,l.waitingData=null,l.mainDetails=null,l.bufferFlushed=!1,l.cachedTrackLoadedData=null,l._registerListeners(),l}X(s,d);var t=s.prototype;return t.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null},t._registerListeners=function(){var r=this.hls;r.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(x.MANIFEST_LOADING,this.onManifestLoading,this),r.on(x.LEVEL_LOADED,this.onLevelLoaded,this),r.on(x.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),r.on(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(x.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.on(x.ERROR,this.onError,this),r.on(x.BUFFER_RESET,this.onBufferReset,this),r.on(x.BUFFER_CREATED,this.onBufferCreated,this),r.on(x.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(x.INIT_PTS_FOUND,this.onInitPtsFound,this),r.on(x.FRAG_BUFFERED,this.onFragBuffered,this)},t._unregisterListeners=function(){var r=this.hls;r.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(x.MANIFEST_LOADING,this.onManifestLoading,this),r.off(x.LEVEL_LOADED,this.onLevelLoaded,this),r.off(x.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),r.off(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(x.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.off(x.ERROR,this.onError,this),r.off(x.BUFFER_RESET,this.onBufferReset,this),r.off(x.BUFFER_CREATED,this.onBufferCreated,this),r.off(x.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(x.INIT_PTS_FOUND,this.onInitPtsFound,this),r.off(x.FRAG_BUFFERED,this.onFragBuffered,this)},t.onInitPtsFound=function(r,a){var o=a.frag,l=a.id,h=a.initPTS,u=a.timescale;if(l==="main"){var f=o.cc;this.initPTS[o.cc]={baseTime:h,timescale:u},this.log("InitPTS for cc: "+f+" found from main: "+h),this.videoTrackCC=f,this.state===ka&&this.tick()}},t.startLoad=function(r){if(!this.levels)return this.startPosition=r,void(this.state=Vt);var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),a>0&&r===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),r=a,this.state=Qe):(this.loadedmetadata=!1,this.state=Ca),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()},t.doTick=function(){switch(this.state){case Qe:this.doTickIdle();break;case Ca:var r,a=this.levels,o=this.trackId,l=a==null||(r=a[o])==null?void 0:r.details;if(l){if(this.waitForCdnTuneIn(l))break;this.state=ka}break;case Ri:var h,u=performance.now(),f=this.retryDate;(!f||u>=f||(h=this.media)!=null&&h.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Qe);break;case ka:var p=this.waitingData;if(p){var v=p.frag,w=p.part,C=p.cache,k=p.complete;if(this.initPTS[v.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=Di;var I={frag:v,part:w,payload:C.flush(),networkDetails:null};this._handleFragmentLoadProgress(I),k&&d.prototype._handleFragmentLoadComplete.call(this,I)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+v.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var D=this.getLoadPosition(),B=ct.bufferInfo(this.mediaBuffer,D,this.config.maxBufferHole);dl(B.end,this.config.maxFragLookUpTolerance,v)<0&&(this.log("Waiting fragment cc ("+v.cc+") @ "+v.start+" cancelled because another fragment at "+B.end+" is needed"),this.clearWaitingFragment())}}else this.state=Qe}this.onTickEnd()},t.clearWaitingFragment=function(){var r=this.waitingData;r&&(this.fragmentTracker.removeFragment(r.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Qe)},t.resetLoadingState=function(){this.clearWaitingFragment(),d.prototype.resetLoadingState.call(this)},t.onTickEnd=function(){var r=this.media;r!=null&&r.readyState&&(this.lastCurrentTime=r.currentTime)},t.doTickIdle=function(){var r=this.hls,a=this.levels,o=this.media,l=this.trackId,h=r.config;if(a!=null&&a[l]&&(o||!this.startFragRequested&&h.startFragPrefetch)){var u=a[l],f=u.details;if(!f||f.live&&this.levelLastLoaded!==l||this.waitForCdnTuneIn(f))this.state=Ca;else{var p=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&p&&(this.bufferFlushed=!1,this.afterBufferFlushed(p,ot,Cr));var v=this.getFwdBufferInfo(p,Cr);if(v!==null){var w=this.bufferedTrack,C=this.switchingTrack;if(!C&&this._streamEnded(v,f))return r.trigger(x.BUFFER_EOS,{type:"audio"}),void(this.state=Ea);var k=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Je),I=v.len,D=this.getMaxBufferLength(k?.len);if(!(I>=D)||C){var B=f.fragments[0].start,T=v.end;if(C&&o){var U=this.getLoadPosition();w&&C.attrs!==w.attrs&&(T=U),f.PTSKnown&&U<B&&(v.end>B||v.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),o.currentTime=B+.05)}var M=this.getNextFragment(T,f),H=!1;if(M&&this.isLoopLoading(M,T)&&(H=!!M.gap,M=this.getNextFragmentLoopLoading(M,f,v,Je,D)),M){var V=k&&M.start>k.end+f.targetduration;if(V||(k==null||!k.len)&&v.len){var W=this.getAppendedFrag(M.start,Je);if(W===null||(H||(H=!!W.gap||!!V&&k.len===0),V&&!H||H&&v.nextStart&&v.nextStart<W.end))return}this.loadFragment(M,u,T)}else this.bufferFlushed=!0}}}}},t.getMaxBufferLength=function(r){var a=d.prototype.getMaxBufferLength.call(this);return r?Math.min(Math.max(a,r),this.config.maxMaxBufferLength):a},t.onMediaDetaching=function(){this.videoBuffer=null,d.prototype.onMediaDetaching.call(this)},t.onAudioTracksUpdated=function(r,a){var o=a.audioTracks;this.resetTransmuxer(),this.levels=o.map(function(l){return new Aa(l)})},t.onAudioTrackSwitching=function(r,a){var o=!!a.url;this.trackId=a.id;var l=this.fragCurrent;l&&(l.abortRequests(),this.removeUnbufferedFrags(l.start)),this.resetLoadingState(),o?this.setInterval(100):this.resetTransmuxer(),o?(this.switchingTrack=a,this.state=Qe):(this.switchingTrack=null,this.bufferedTrack=a,this.state=Vt),this.tick()},t.onManifestLoading=function(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1},t.onLevelLoaded=function(r,a){this.mainDetails=a.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(x.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},t.onAudioTrackLoaded=function(r,a){var o;if(this.mainDetails!=null){var l=this.levels,h=a.details,u=a.id;if(l){this.log("Track "+u+" loaded ["+h.startSN+","+h.endSN+"]"+(h.lastPartSn?"[part-"+h.lastPartSn+"-"+h.lastPartIndex+"]":"")+",duration:"+h.totalduration);var f=l[u],p=0;if(h.live||(o=f.details)!=null&&o.live){this.checkLiveUpdate(h);var v=this.mainDetails;if(h.deltaUpdateFailed||!v)return;!f.details&&h.hasProgramDateTime&&v.hasProgramDateTime?(rg(h,v),p=h.fragments[0].start):p=this.alignPlaylists(h,f.details)}f.details=h,this.levelLastLoaded=u,this.startFragRequested||!this.mainDetails&&h.live||this.setStartPosition(f.details,p),this.state!==Ca||this.waitForCdnTuneIn(h)||(this.state=Qe),this.tick()}else this.warn("Audio tracks were reset while loading level "+u)}else this.cachedTrackLoadedData=a},t._handleFragmentLoadProgress=function(r){var a,o=r.frag,l=r.part,h=r.payload,u=this.config,f=this.trackId,p=this.levels;if(p){var v=p[f];if(v){var w=v.details;if(!w)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(o.start);var C=u.defaultAudioCodec||v.audioCodec||"mp4a.40.2",k=this.transmuxer;k||(k=this.transmuxer=new Cg(this.hls,Cr,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var I=this.initPTS[o.cc],D=(a=o.initSegment)==null?void 0:a.data;if(I!==void 0){var B=l?l.index:-1,T=B!==-1,U=new fl(o.level,o.sn,o.stats.chunkCount,h.byteLength,B,T);k.push(h,D,C,"",o,l,w.totalduration,!1,U,I)}else this.log("Unknown video PTS for cc "+o.cc+", waiting for video PTS before demuxing audio frag "+o.sn+" of ["+w.startSN+" ,"+w.endSN+"],track "+f),(this.waitingData=this.waitingData||{frag:o,part:l,cache:new Eg,complete:!1}).cache.push(new Uint8Array(h)),this.waitingVideoCC=this.videoTrackCC,this.state=ka}else this.warn("Audio track is undefined on fragment load progress")}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered")},t._handleFragmentLoadComplete=function(r){this.waitingData?this.waitingData.complete=!0:d.prototype._handleFragmentLoadComplete.call(this,r)},t.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},t.onBufferCreated=function(r,a){var o=a.tracks.audio;o&&(this.mediaBuffer=o.buffer||null),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer||null)},t.onFragBuffered=function(r,a){var o=a.frag,l=a.part;if(o.type===Cr)if(this.fragContextChanged(o))this.warn("Fragment "+o.sn+(l?" p: "+l.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+(this.switchingTrack?this.switchingTrack.name:"false"));else{if(o.sn!=="initSegment"){this.fragPrevious=o;var h=this.switchingTrack;h&&(this.bufferedTrack=h,this.switchingTrack=null,this.hls.trigger(x.AUDIO_TRACK_SWITCHED,E({},h)))}this.fragBufferedComplete(o,l)}else if(!this.loadedmetadata&&o.type===Je){var u=this.videoBuffer||this.media;u&&ct.getBuffered(u).length&&(this.loadedmetadata=!0)}},t.onError=function(r,a){var o;if(a.fatal)this.state=Li;else switch(a.details){case q.FRAG_GAP:case q.FRAG_PARSING_ERROR:case q.FRAG_DECRYPT_ERROR:case q.FRAG_LOAD_ERROR:case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_ERROR:case q.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Cr,a);break;case q.AUDIO_TRACK_LOAD_ERROR:case q.AUDIO_TRACK_LOAD_TIMEOUT:case q.LEVEL_PARSING_ERROR:a.levelRetry||this.state!==Ca||((o=a.context)==null?void 0:o.type)!==wr||(this.state=Qe);break;case q.BUFFER_FULL_ERROR:if(!a.parent||a.parent!=="audio")return;this.reduceLengthAndFlushBuffer(a)&&(this.bufferedTrack=null,d.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case q.INTERNAL_EXCEPTION:this.recoverWorkerError(a)}},t.onBufferFlushed=function(r,a){a.type===ot&&(this.bufferFlushed=!0,this.state===Ea&&(this.state=Qe))},t._handleTransmuxComplete=function(r){var a,o="audio",l=this.hls,h=r.remuxResult,u=r.chunkMeta,f=this.getCurrentContext(u);if(f){var p=f.frag,v=f.part,w=f.level.details,C=h.audio,k=h.text,I=h.id3,D=h.initSegment;if(!this.fragContextChanged(p)&&w){if(this.state=Ur,this.switchingTrack&&C&&this.completeAudioSwitch(this.switchingTrack),D!=null&&D.tracks){var B=p.initSegment||p;this._bufferInitSegment(D.tracks,B,u),l.trigger(x.FRAG_PARSING_INIT_SEGMENT,{frag:B,id:o,tracks:D.tracks})}if(C){var T=C.startPTS,U=C.endPTS,M=C.startDTS,H=C.endDTS;v&&(v.elementaryStreams[ot]={startPTS:T,endPTS:U,startDTS:M,endDTS:H}),p.setElementaryStreamInfo(ot,T,U,M,H),this.bufferFragmentData(C,p,v,u)}if(I!=null&&(a=I.samples)!=null&&a.length){var V=Y({id:o,frag:p,details:w},I);l.trigger(x.FRAG_PARSING_METADATA,V)}if(k){var W=Y({id:o,frag:p,details:w},k);l.trigger(x.FRAG_PARSING_USERDATA,W)}}else this.fragmentTracker.removeFragment(p)}else this.resetWhenMissingContext(u)},t._bufferInitSegment=function(r,a,o){if(this.state===Ur){r.video&&delete r.video;var l=r.audio;if(l){l.levelCodec=l.codec,l.id="audio",this.log("Init audio buffer, container:"+l.container+", codecs[parsed]=["+l.codec+"]"),this.hls.trigger(x.BUFFER_CODECS,r);var h=l.initSegment;if(h!=null&&h.byteLength){var u={type:"audio",frag:a,part:null,chunkMeta:o,parent:a.type,data:h};this.hls.trigger(x.BUFFER_APPENDING,u)}this.tick()}}},t.loadFragment=function(r,a,o){var l,h=this.fragmentTracker.getState(r);this.fragCurrent=r,this.switchingTrack||h===ya||h===xi?r.sn==="initSegment"?this._loadInitSegment(r,a):(l=a.details)!=null&&l.live&&!this.initPTS[r.cc]?(this.log("Waiting for video PTS in continuity counter "+r.cc+" of live stream before loading audio fragment "+r.sn+" of level "+this.trackId),this.state=ka):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,a,o)):this.clearTrackerIfNeeded(r)},t.completeAudioSwitch=function(r){var a=this.hls,o=this.media,l=this.bufferedTrack,h=l?.attrs,u=r.attrs;o&&h&&(h.CHANNELS!==u.CHANNELS||h.NAME!==u.NAME||h.LANGUAGE!==u.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),d.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=r,this.switchingTrack=null,a.trigger(x.AUDIO_TRACK_SWITCHED,E({},r))},s})(Al),qm=(function(d){function s(r){var a;return(a=d.call(this,r,"[audio-track-controller]")||this).tracks=[],a.groupId=null,a.tracksInGroup=[],a.trackId=-1,a.currentTrack=null,a.selectDefaultTrack=!0,a.registerListeners(),a}X(s,d);var t=s.prototype;return t.registerListeners=function(){var r=this.hls;r.on(x.MANIFEST_LOADING,this.onManifestLoading,this),r.on(x.MANIFEST_PARSED,this.onManifestParsed,this),r.on(x.LEVEL_LOADING,this.onLevelLoading,this),r.on(x.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(x.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.on(x.ERROR,this.onError,this)},t.unregisterListeners=function(){var r=this.hls;r.off(x.MANIFEST_LOADING,this.onManifestLoading,this),r.off(x.MANIFEST_PARSED,this.onManifestParsed,this),r.off(x.LEVEL_LOADING,this.onLevelLoading,this),r.off(x.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(x.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.off(x.ERROR,this.onError,this)},t.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,d.prototype.destroy.call(this)},t.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0},t.onManifestParsed=function(r,a){this.tracks=a.audioTracks||[]},t.onAudioTrackLoaded=function(r,a){var o=a.id,l=a.groupId,h=a.details,u=this.tracksInGroup[o];if(u&&u.groupId===l){var f=u.details;u.details=a.details,this.log("audio-track "+o+' "'+u.name+'" lang:'+u.lang+" group:"+l+" loaded ["+h.startSN+"-"+h.endSN+"]"),o===this.trackId&&this.playlistLoaded(o,a,f)}else this.warn("Track with id:"+o+" and group:"+l+" not found in active group "+u.groupId)},t.onLevelLoading=function(r,a){this.switchLevel(a.level)},t.onLevelSwitching=function(r,a){this.switchLevel(a.level)},t.switchLevel=function(r){var a=this.hls.levels[r];if(a!=null&&a.audioGroupIds){var o=a.audioGroupIds[a.urlId];if(this.groupId!==o){this.groupId=o||null;var l=this.tracks.filter(function(u){return!o||u.groupId===o});this.selectDefaultTrack&&!l.some(function(u){return u.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=l;var h={audioTracks:l};this.log("Updating audio tracks, "+l.length+" track(s) found in group:"+o),this.hls.trigger(x.AUDIO_TRACKS_UPDATED,h),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}},t.onError=function(r,a){!a.fatal&&a.context&&a.context.type===wr&&a.context.id===this.trackId&&a.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(a))},t.setAudioTrack=function(r){var a=this.tracksInGroup;if(r<0||r>=a.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var o=this.currentTrack;a[this.trackId];var l=a[r],h=l.groupId,u=l.name;if(this.log("Switching to audio-track "+r+' "'+u+'" lang:'+l.lang+" group:"+h),this.trackId=r,this.currentTrack=l,this.selectDefaultTrack=!1,this.hls.trigger(x.AUDIO_TRACK_SWITCHING,E({},l)),!l.details||l.details.live){var f=this.switchParams(l.url,o?.details);this.loadPlaylist(f)}}},t.selectInitialTrack=function(){var r=this.tracksInGroup,a=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(a!==-1)this.setAudioTrack(a);else{var o=new Error("No track found for running audio group-ID: "+this.groupId+" track count: "+r.length);this.warn(o.message),this.hls.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:o})}},t.findTrackId=function(r){for(var a=this.tracksInGroup,o=0;o<a.length;o++){var l=a[o];if((!this.selectDefaultTrack||l.default)&&(!r||r.attrs["STABLE-RENDITION-ID"]!==void 0&&r.attrs["STABLE-RENDITION-ID"]===l.attrs["STABLE-RENDITION-ID"]||r.name===l.name&&r.lang===l.lang))return l.id}return-1},t.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var a=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(a)){var o=a.id,l=a.groupId,h=a.url;if(r)try{h=r.addDirectives(h)}catch(u){this.warn("Could not construct new URL with HLS Delivery Directives: "+u)}this.log("loading audio-track playlist "+o+' "'+a.name+'" lang:'+a.lang+" group:"+l),this.clearTimer(),this.hls.trigger(x.AUDIO_TRACK_LOADING,{url:h,id:o,groupId:l,deliveryDirectives:r||null})}},F(s,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1,this.setAudioTrack(r)}}]),s})(gl);function kg(d,s){if(d.length!==s.length)return!1;for(var t=0;t<d.length;t++)if(!Vm(d[t].attrs,s[t].attrs))return!1;return!0}function Vm(d,s){var t=d["STABLE-RENDITION-ID"];return t?t===s["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(function(r){return d[r]!==s[r]})}var Wm=(function(d){function s(r,a,o){var l;return(l=d.call(this,r,a,o,"[subtitle-stream-controller]",Wr)||this).levels=[],l.currentTrackId=-1,l.tracksBuffered=[],l.mainDetails=null,l._registerListeners(),l}X(s,d);var t=s.prototype;return t.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},t._registerListeners=function(){var r=this.hls;r.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(x.MANIFEST_LOADING,this.onManifestLoading,this),r.on(x.LEVEL_LOADED,this.onLevelLoaded,this),r.on(x.ERROR,this.onError,this),r.on(x.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.on(x.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),r.on(x.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(x.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),r.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),r.on(x.FRAG_BUFFERED,this.onFragBuffered,this)},t._unregisterListeners=function(){var r=this.hls;r.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(x.MANIFEST_LOADING,this.onManifestLoading,this),r.off(x.LEVEL_LOADED,this.onLevelLoaded,this),r.off(x.ERROR,this.onError,this),r.off(x.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.off(x.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),r.off(x.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(x.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),r.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),r.off(x.FRAG_BUFFERED,this.onFragBuffered,this)},t.startLoad=function(r){this.stopLoad(),this.state=Qe,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()},t.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},t.onMediaDetaching=function(){this.tracksBuffered=[],d.prototype.onMediaDetaching.call(this)},t.onLevelLoaded=function(r,a){this.mainDetails=a.details},t.onSubtitleFragProcessed=function(r,a){var o=a.frag,l=a.success;if(this.fragPrevious=o,this.state=Qe,l){var h=this.tracksBuffered[this.currentTrackId];if(h){for(var u,f=o.start,p=0;p<h.length;p++)if(f>=h[p].start&&f<=h[p].end){u=h[p];break}var v=o.start+o.duration;u?u.end=v:(u={start:f,end:v},h.push(u)),this.fragmentTracker.fragBuffered(o)}}},t.onBufferFlushing=function(r,a){var o=a.startOffset,l=a.endOffset;if(o===0&&l!==Number.POSITIVE_INFINITY){var h=l-1;if(h<=0)return;a.endOffsetSubtitles=Math.max(0,h),this.tracksBuffered.forEach(function(u){for(var f=0;f<u.length;)if(u[f].end<=h)u.shift();else{if(!(u[f].start<h))break;u[f].start=h,f++}}),this.fragmentTracker.removeFragmentsInRange(o,h,Wr)}},t.onFragBuffered=function(r,a){var o;this.loadedmetadata||a.frag.type!==Je||(o=this.media)!=null&&o.buffered.length&&(this.loadedmetadata=!0)},t.onError=function(r,a){var o=a.frag;o?.type===Wr&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Vt&&(this.state=Qe))},t.onSubtitleTracksUpdated=function(r,a){var o=this,l=a.subtitleTracks;kg(this.levels,l)?this.levels=l.map(function(h){return new Aa(h)}):(this.tracksBuffered=[],this.levels=l.map(function(h){var u=new Aa(h);return o.tracksBuffered[u.id]=[],u}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Wr),this.fragPrevious=null,this.mediaBuffer=null)},t.onSubtitleTrackSwitch=function(r,a){if(this.currentTrackId=a.id,this.levels.length&&this.currentTrackId!==-1){var o=this.levels[this.currentTrackId];o!=null&&o.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,o&&this.setInterval(500)}else this.clearInterval()},t.onSubtitleTrackLoaded=function(r,a){var o,l=a.details,h=a.id,u=this.currentTrackId,f=this.levels;if(f.length){var p=f[u];if(!(h>=f.length||h!==u)&&p){this.mediaBuffer=this.mediaBufferTimeRanges;var v=0;if(l.live||(o=p.details)!=null&&o.live){var w=this.mainDetails;if(l.deltaUpdateFailed||!w)return;var C=w.fragments[0];p.details?(v=this.alignPlaylists(l,p.details))===0&&C&&ll(l,v=C.start):l.hasProgramDateTime&&w.hasProgramDateTime?(rg(l,w),v=l.fragments[0].start):C&&ll(l,v=C.start)}p.details=l,this.levelLastLoaded=h,this.startFragRequested||!this.mainDetails&&l.live||this.setStartPosition(p.details,v),this.tick(),l.live&&!this.fragCurrent&&this.media&&this.state===Qe&&(ba(null,l.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),p.details=void 0))}}},t._handleFragmentLoadComplete=function(r){var a=this,o=r.frag,l=r.payload,h=o.decryptdata,u=this.hls;if(!this.fragContextChanged(o)&&l&&l.byteLength>0&&h&&h.key&&h.iv&&h.method==="AES-128"){var f=performance.now();this.decrypter.decrypt(new Uint8Array(l),h.key.buffer,h.iv.buffer).catch(function(p){throw u.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_DECRYPT_ERROR,fatal:!1,error:p,reason:p.message,frag:o}),p}).then(function(p){var v=performance.now();u.trigger(x.FRAG_DECRYPTED,{frag:o,payload:p,stats:{tstart:f,tdecrypt:v}})}).catch(function(p){a.warn(p.name+": "+p.message),a.state=Qe})}},t.doTick=function(){if(this.media){if(this.state===Qe){var r=this.currentTrackId,a=this.levels,o=a[r];if(!a.length||!o||!o.details)return;var l=this.config,h=this.getLoadPosition(),u=ct.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],h,l.maxBufferHole),f=u.end,p=u.len,v=this.getFwdBufferInfo(this.media,Je),w=o.details;if(p>this.getMaxBufferLength(v?.len)+w.levelTargetDuration)return;var C=w.fragments,k=C.length,I=w.edge,D=null,B=this.fragPrevious;if(f<I){var T=l.maxFragLookUpTolerance,U=f>I-T?0:T;!(D=ba(B,C,Math.max(C[0].start,f),U))&&B&&B.start<C[0].start&&(D=C[0])}else D=C[k-1];if(!D)return;if((D=this.mapToInitFragWhenRequired(D)).sn!=="initSegment"){var M=C[D.sn-w.startSN-1];M&&M.cc===D.cc&&this.fragmentTracker.getState(M)===ya&&(D=M)}this.fragmentTracker.getState(D)===ya&&this.loadFragment(D,o,f)}}else this.state=Qe},t.getMaxBufferLength=function(r){var a=d.prototype.getMaxBufferLength.call(this);return r?Math.max(a,r):a},t.loadFragment=function(r,a,o){this.fragCurrent=r,r.sn==="initSegment"?this._loadInitSegment(r,a):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,a,o))},F(s,[{key:"mediaBufferTimeRanges",get:function(){return new Xm(this.tracksBuffered[this.currentTrackId]||[])}}]),s})(Al),Xm=function(d){this.buffered=void 0;var s=function(t,r,a){if((r>>>=0)>a-1)throw new DOMException("Failed to execute '"+t+"' on 'TimeRanges': The index provided ("+r+") is greater than the maximum bound ("+a+")");return d[r][t]};this.buffered={get length(){return d.length},end:function(t){return s("end",t,d.length)},start:function(t){return s("start",t,d.length)}}},Jm=(function(d){function s(r){var a;return(a=d.call(this,r,"[subtitle-track-controller]")||this).media=null,a.tracks=[],a.groupId=null,a.tracksInGroup=[],a.trackId=-1,a.selectDefaultTrack=!0,a.queuedDefaultTrack=-1,a.trackChangeListener=function(){return a.onTextTracksChanged()},a.asyncPollTrackChange=function(){return a.pollTrackChange(0)},a.useTextTrackPolling=!1,a.subtitlePollingInterval=-1,a._subtitleDisplay=!0,a.registerListeners(),a}X(s,d);var t=s.prototype;return t.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,d.prototype.destroy.call(this)},t.registerListeners=function(){var r=this.hls;r.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(x.MANIFEST_LOADING,this.onManifestLoading,this),r.on(x.MANIFEST_PARSED,this.onManifestParsed,this),r.on(x.LEVEL_LOADING,this.onLevelLoading,this),r.on(x.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(x.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(x.ERROR,this.onError,this)},t.unregisterListeners=function(){var r=this.hls;r.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(x.MANIFEST_LOADING,this.onManifestLoading,this),r.off(x.MANIFEST_PARSED,this.onManifestParsed,this),r.off(x.LEVEL_LOADING,this.onLevelLoading,this),r.off(x.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(x.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(x.ERROR,this.onError,this)},t.onMediaAttached=function(r,a){this.media=a.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},t.pollTrackChange=function(r){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,r)},t.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Dl(this.media.textTracks).forEach(function(r){Ii(r)}),this.subtitleTrack=-1,this.media=null)},t.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},t.onManifestParsed=function(r,a){this.tracks=a.subtitleTracks},t.onSubtitleTrackLoaded=function(r,a){var o=a.id,l=a.details,h=this.trackId,u=this.tracksInGroup[h];if(u){var f=u.details;u.details=a.details,this.log("subtitle track "+o+" loaded ["+l.startSN+"-"+l.endSN+"]"),o===this.trackId&&this.playlistLoaded(o,a,f)}else this.warn("Invalid subtitle track id "+o)},t.onLevelLoading=function(r,a){this.switchLevel(a.level)},t.onLevelSwitching=function(r,a){this.switchLevel(a.level)},t.switchLevel=function(r){var a=this.hls.levels[r];if(a!=null&&a.textGroupIds){var o=a.textGroupIds[a.urlId],l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==o){var h=this.tracks.filter(function(p){return!o||p.groupId===o});this.tracksInGroup=h;var u=this.findTrackId(l?.name)||this.findTrackId();this.groupId=o||null;var f={subtitleTracks:h};this.log("Updating subtitle tracks, "+h.length+' track(s) found in "'+o+'" group-id'),this.hls.trigger(x.SUBTITLE_TRACKS_UPDATED,f),u!==-1&&this.setSubtitleTrack(u,l)}else this.shouldReloadPlaylist(l)&&this.setSubtitleTrack(this.trackId,l)}},t.findTrackId=function(r){for(var a=this.tracksInGroup,o=0;o<a.length;o++){var l=a[o];if((!this.selectDefaultTrack||l.default)&&(!r||r===l.name))return l.id}return-1},t.onError=function(r,a){!a.fatal&&a.context&&a.context.type===Fr&&a.context.id===this.trackId&&a.context.groupId===this.groupId&&this.checkRetry(a)},t.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var a=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(a)){var o=a.id,l=a.groupId,h=a.url;if(r)try{h=r.addDirectives(h)}catch(u){this.warn("Could not construct new URL with HLS Delivery Directives: "+u)}this.log("Loading subtitle playlist for id "+o),this.hls.trigger(x.SUBTITLE_TRACK_LOADING,{url:h,id:o,groupId:l,deliveryDirectives:r||null})}},t.toggleTrackModes=function(r){var a=this,o=this.media,l=this.trackId;if(o){var h=Dl(o.textTracks),u=h.filter(function(v){return v.groupId===a.groupId});if(r===-1)[].slice.call(h).forEach(function(v){v.mode="disabled"});else{var f=u[l];f&&(f.mode="disabled")}var p=u[r];p&&(p.mode=this.subtitleDisplay?"showing":"hidden")}},t.setSubtitleTrack=function(r,a){var o,l=this.tracksInGroup;if(this.media){if(this.trackId!==r&&this.toggleTrackModes(r),!(this.trackId===r&&(r===-1||(o=l[r])!=null&&o.details)||r<-1||r>=l.length)){this.clearTimer();var h=l[r];if(this.log("Switching to subtitle-track "+r+(h?' "'+h.name+'" lang:'+h.lang+" group:"+h.groupId:"")),this.trackId=r,h){var u=h.id,f=h.groupId,p=f===void 0?"":f,v=h.name,w=h.type,C=h.url;this.hls.trigger(x.SUBTITLE_TRACK_SWITCH,{id:u,groupId:p,name:v,type:w,url:C});var k=this.switchParams(h.url,a?.details);this.loadPlaylist(k)}else this.hls.trigger(x.SUBTITLE_TRACK_SWITCH,{id:r})}}else this.queuedDefaultTrack=r},t.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var r=-1,a=Dl(this.media.textTracks),o=0;o<a.length;o++)if(a[o].mode==="hidden")r=o;else if(a[o].mode==="showing"){r=o;break}this.subtitleTrack!==r&&(this.subtitleTrack=r)}},F(s,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(r){this._subtitleDisplay=r,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1;var a=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(r,a)}}]),s})(gl);function Dl(d){for(var s=[],t=0;t<d.length;t++){var r=d[t];r.kind!=="subtitles"&&r.kind!=="captions"||!r.label||s.push(d[t])}return s}var _m=(function(){function d(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}var s=d.prototype;return s.append=function(t,r){var a=this.queues[r];a.push(t),a.length===1&&this.buffers[r]&&this.executeNext(r)},s.insertAbort=function(t,r){this.queues[r].unshift(t),this.executeNext(r)},s.appendBlocker=function(t){var r,a=new Promise(function(l){r=l}),o={execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(o,t),a},s.executeNext=function(t){var r=this.buffers,a=this.queues,o=r[t],l=a[t];if(l.length){var h=l[0];try{h.execute()}catch(u){G.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),h.onError(u),o!=null&&o.updating||(l.shift(),this.executeNext(t))}}},s.shiftAndExecuteNext=function(t){this.queues[t].shift(),this.executeNext(t)},s.current=function(t){return this.queues[t][0]},d})(),Bg=xn(),Ig=/([ha]vc.)(?:\.[^.,]+)+/,jm=(function(){function d(t){var r=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var a=r.media,o=r.mediaSource;G.log("[buffer-controller]: Media source opened"),a&&(a.removeEventListener("emptied",r._onMediaEmptied),r.updateMediaElementDuration(),r.hls.trigger(x.MEDIA_ATTACHED,{media:a})),o&&o.removeEventListener("sourceopen",r._onMediaSourceOpen),r.checkPendingTracks()},this._onMediaSourceClose=function(){G.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){G.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=function(){var a=r.media,o=r._objectUrl;a&&a.src!==o&&G.error("Media element src was set while attaching MediaSource ("+o+" > "+a.src+")")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var s=d.prototype;return s.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},s.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},s.registerListeners=function(){var t=this.hls;t.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.MANIFEST_PARSED,this.onManifestParsed,this),t.on(x.BUFFER_RESET,this.onBufferReset,this),t.on(x.BUFFER_APPENDING,this.onBufferAppending,this),t.on(x.BUFFER_CODECS,this.onBufferCodecs,this),t.on(x.BUFFER_EOS,this.onBufferEos,this),t.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(x.FRAG_PARSED,this.onFragParsed,this),t.on(x.FRAG_CHANGED,this.onFragChanged,this)},s.unregisterListeners=function(){var t=this.hls;t.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.MANIFEST_PARSED,this.onManifestParsed,this),t.off(x.BUFFER_RESET,this.onBufferReset,this),t.off(x.BUFFER_APPENDING,this.onBufferAppending,this),t.off(x.BUFFER_CODECS,this.onBufferCodecs,this),t.off(x.BUFFER_EOS,this.onBufferEos,this),t.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(x.FRAG_PARSED,this.onFragParsed,this),t.off(x.FRAG_CHANGED,this.onFragChanged,this)},s._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new _m(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},s.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},s.onManifestParsed=function(t,r){var a=2;(r.audio&&!r.video||!r.altAudio)&&(a=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=a,G.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},s.onMediaAttaching=function(t,r){var a=this.media=r.media;if(a&&Bg){var o=this.mediaSource=new Bg;o.addEventListener("sourceopen",this._onMediaSourceOpen),o.addEventListener("sourceended",this._onMediaSourceEnded),o.addEventListener("sourceclose",this._onMediaSourceClose),a.src=self.URL.createObjectURL(o),this._objectUrl=a.src,a.addEventListener("emptied",this._onMediaEmptied)}},s.onMediaDetaching=function(){var t=this.media,r=this.mediaSource,a=this._objectUrl;if(r){if(G.log("[buffer-controller]: media source detaching"),r.readyState==="open")try{r.endOfStream()}catch(o){G.warn("[buffer-controller]: onMediaDetaching: "+o.message+" while calling endOfStream")}this.onBufferReset(),r.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("sourceended",this._onMediaSourceEnded),r.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),a&&self.URL.revokeObjectURL(a),t.src===a?(t.removeAttribute("src"),t.load()):G.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(x.MEDIA_DETACHED,void 0)},s.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach(function(r){var a=t.sourceBuffer[r];try{a&&(t.removeBufferListeners(r),t.mediaSource&&t.mediaSource.removeSourceBuffer(a),t.sourceBuffer[r]=void 0)}catch(o){G.warn("[buffer-controller]: Failed to reset the "+r+" buffer",o)}}),this._initSourceBuffer()},s.onBufferCodecs=function(t,r){var a=this,o=this.getSourceBufferTypes().length;Object.keys(r).forEach(function(l){if(o){var h=a.tracks[l];if(h&&typeof h.buffer.changeType=="function"){var u=r[l],f=u.id,p=u.codec,v=u.levelCodec,w=u.container,C=u.metadata,k=(h.levelCodec||h.codec).replace(Ig,"$1"),I=(v||p).replace(Ig,"$1");if(k!==I){var D=w+";codecs="+(v||p);a.appendChangeType(l,D),G.log("[buffer-controller]: switching codec "+k+" to "+I),a.tracks[l]={buffer:h.buffer,codec:p,container:w,levelCodec:v,metadata:C,id:f}}}}else a.pendingTracks[l]=r[l]}),o||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},s.appendChangeType=function(t,r){var a=this,o=this.operationQueue;o.append({execute:function(){var l=a.sourceBuffer[t];l&&(G.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+r),l.changeType(r)),o.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(l){G.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",l)}},t)},s.onBufferAppending=function(t,r){var a=this,o=this.hls,l=this.operationQueue,h=this.tracks,u=r.data,f=r.type,p=r.frag,v=r.part,w=r.chunkMeta,C=w.buffering[f],k=self.performance.now();C.start=k;var I=p.stats.buffering,D=v?v.stats.buffering:null;I.start===0&&(I.start=k),D&&D.start===0&&(D.start=k);var B=h.audio,T=!1;f==="audio"&&B?.container==="audio/mpeg"&&(T=!this.lastMpegAudioChunk||w.id===1||this.lastMpegAudioChunk.sn!==w.sn,this.lastMpegAudioChunk=w);var U=p.start;l.append({execute:function(){if(C.executeStart=self.performance.now(),T){var M=a.sourceBuffer[f];if(M){var H=U-M.timestampOffset;Math.abs(H)>=.1&&(G.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+U+" (delta: "+H+") sn: "+p.sn+")"),M.timestampOffset=U)}}a.appendExecutor(u,f)},onStart:function(){},onComplete:function(){var M=self.performance.now();C.executeEnd=C.end=M,I.first===0&&(I.first=M),D&&D.first===0&&(D.first=M);var H=a.sourceBuffer,V={};for(var W in H)V[W]=ct.getBuffered(H[W]);a.appendError=0,a.hls.trigger(x.BUFFER_APPENDED,{type:f,frag:p,part:v,chunkMeta:w,parent:p.type,timeRanges:V})},onError:function(M){G.error("[buffer-controller]: Error encountered while trying to append to the "+f+" SourceBuffer",M);var H={type:ue.MEDIA_ERROR,parent:p.type,details:q.BUFFER_APPEND_ERROR,frag:p,part:v,chunkMeta:w,error:M,err:M,fatal:!1};M.code===DOMException.QUOTA_EXCEEDED_ERR?H.details=q.BUFFER_FULL_ERROR:(a.appendError++,H.details=q.BUFFER_APPEND_ERROR,a.appendError>o.config.appendErrorMaxRetry&&(G.error("[buffer-controller]: Failed "+o.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),H.fatal=!0)),o.trigger(x.ERROR,H)}},f)},s.onBufferFlushing=function(t,r){var a=this,o=this.operationQueue,l=function(h){return{execute:a.removeExecutor.bind(a,h,r.startOffset,r.endOffset),onStart:function(){},onComplete:function(){a.hls.trigger(x.BUFFER_FLUSHED,{type:h})},onError:function(u){G.warn("[buffer-controller]: Failed to remove from "+h+" SourceBuffer",u)}}};r.type?o.append(l(r.type),r.type):this.getSourceBufferTypes().forEach(function(h){o.append(l(h),h)})},s.onFragParsed=function(t,r){var a=this,o=r.frag,l=r.part,h=[],u=l?l.elementaryStreams:o.elementaryStreams;u[zt]?h.push("audiovideo"):(u[ot]&&h.push("audio"),u[bt]&&h.push("video")),h.length===0&&G.warn("Fragments must have at least one ElementaryStreamType set. type: "+o.type+" level: "+o.level+" sn: "+o.sn),this.blockBuffers(function(){var f=self.performance.now();o.stats.buffering.end=f,l&&(l.stats.buffering.end=f);var p=l?l.stats:o.stats;a.hls.trigger(x.FRAG_BUFFERED,{frag:o,part:l,stats:p,id:o.type})},h)},s.onFragChanged=function(t,r){this.flushBackBuffer()},s.onBufferEos=function(t,r){var a=this;this.getSourceBufferTypes().reduce(function(o,l){var h=a.sourceBuffer[l];return!h||r.type&&r.type!==l||(h.ending=!0,h.ended||(h.ended=!0,G.log("[buffer-controller]: "+l+" sourceBuffer now EOS"))),o&&!(h&&!h.ended)},!0)&&(G.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){a.getSourceBufferTypes().forEach(function(l){var h=a.sourceBuffer[l];h&&(h.ending=!1)});var o=a.mediaSource;o&&o.readyState==="open"?(G.log("[buffer-controller]: Calling mediaSource.endOfStream()"),o.endOfStream()):o&&G.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+o.readyState)}))},s.onLevelUpdated=function(t,r){var a=r.details;a.fragments.length&&(this.details=a,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},s.flushBackBuffer=function(){var t=this.hls,r=this.details,a=this.media,o=this.sourceBuffer;if(a&&r!==null){var l=this.getSourceBufferTypes();if(l.length){var h=r.live&&t.config.liveBackBufferLength!==null?t.config.liveBackBufferLength:t.config.backBufferLength;if(se(h)&&!(h<0)){var u=a.currentTime,f=r.levelTargetDuration,p=Math.max(h,f),v=Math.floor(u/f)*f-p;l.forEach(function(w){var C=o[w];if(C){var k=ct.getBuffered(C);if(k.length>0&&v>k.start(0)){if(t.trigger(x.BACK_BUFFER_REACHED,{bufferEnd:v}),r.live)t.trigger(x.LIVE_BACK_BUFFER_REACHED,{bufferEnd:v});else if(C.ended&&k.end(k.length-1)-u<2*f)return void G.info("[buffer-controller]: Cannot flush "+w+" back buffer while SourceBuffer is in ended state");t.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:v,type:w})}}})}}}},s.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&this.mediaSource.readyState==="open"){var t=this.details,r=this.hls,a=this.media,o=this.mediaSource,l=t.fragments[0].start+t.totalduration,h=a.duration,u=se(o.duration)?o.duration:0;t.live&&r.config.liveDurationInfinity?(G.log("[buffer-controller]: Media Source duration is set to Infinity"),o.duration=1/0,this.updateSeekableRange(t)):(l>u&&l>h||!se(h))&&(G.log("[buffer-controller]: Updating Media Source duration to "+l.toFixed(3)),o.duration=l)}},s.updateSeekableRange=function(t){var r=this.mediaSource,a=t.fragments;if(a.length&&t.live&&r!=null&&r.setLiveSeekableRange){var o=Math.max(0,a[0].start),l=Math.max(o,o+t.totalduration);r.setLiveSeekableRange(o,l)}},s.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,r=this.operationQueue,a=this.pendingTracks,o=Object.keys(a).length;if(o&&!t||o===2){this.createSourceBuffers(a),this.pendingTracks={};var l=this.getSourceBufferTypes();if(l.length)this.hls.trigger(x.BUFFER_CREATED,{tracks:this.tracks}),l.forEach(function(u){r.executeNext(u)});else{var h=new Error("could not create source buffer for media codec(s)");this.hls.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:h,reason:h.message})}}},s.createSourceBuffers=function(t){var r=this.sourceBuffer,a=this.mediaSource;if(!a)throw Error("createSourceBuffers called when mediaSource was null");for(var o in t)if(!r[o]){var l=t[o];if(!l)throw Error("source buffer exists for track "+o+", however track does not");var h=l.levelCodec||l.codec,u=l.container+";codecs="+h;G.log("[buffer-controller]: creating sourceBuffer("+u+")");try{var f=r[o]=a.addSourceBuffer(u),p=o;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[o]={buffer:f,codec:h,container:l.container,levelCodec:l.levelCodec,metadata:l.metadata,id:l.id}}catch(v){G.error("[buffer-controller]: error while trying to add sourceBuffer: "+v.message),this.hls.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:v,mimeType:u})}}},s._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},s._onSBUpdateEnd=function(t){var r=this.operationQueue;r.current(t).onComplete(),r.shiftAndExecuteNext(t)},s._onSBUpdateError=function(t,r){var a=new Error(t+" SourceBuffer error");G.error("[buffer-controller]: "+a,r),this.hls.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.BUFFER_APPENDING_ERROR,error:a,fatal:!1});var o=this.operationQueue.current(t);o&&o.onError(r)},s.removeExecutor=function(t,r,a){var o=this.media,l=this.mediaSource,h=this.operationQueue,u=this.sourceBuffer[t];if(!o||!l||!u)return G.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void h.shiftAndExecuteNext(t);var f=se(o.duration)?o.duration:1/0,p=se(l.duration)?l.duration:1/0,v=Math.max(0,r),w=Math.min(a,f,p);w>v&&!u.ending?(u.ended=!1,G.log("[buffer-controller]: Removing ["+v+","+w+"] from the "+t+" SourceBuffer"),u.remove(v,w)):h.shiftAndExecuteNext(t)},s.appendExecutor=function(t,r){var a=this.operationQueue,o=this.sourceBuffer[r];if(!o)return G.warn("[buffer-controller]: Attempting to append to the "+r+" SourceBuffer, but it does not exist"),void a.shiftAndExecuteNext(r);o.ended=!1,o.appendBuffer(t)},s.blockBuffers=function(t,r){var a=this;if(r===void 0&&(r=this.getSourceBufferTypes()),!r.length)return G.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(t);var o=this.operationQueue,l=r.map(function(h){return o.appendBlocker(h)});Promise.all(l).then(function(){t(),r.forEach(function(h){var u=a.sourceBuffer[h];u!=null&&u.updating||o.shiftAndExecuteNext(h)})})},s.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},s.addBufferListener=function(t,r,a){var o=this.sourceBuffer[t];if(o){var l=a.bind(this,t);this.listeners[t].push({event:r,listener:l}),o.addEventListener(r,l)}},s.removeBufferListeners=function(t){var r=this.sourceBuffer[t];r&&this.listeners[t].forEach(function(a){r.removeEventListener(a.event,a.listener)})},d})(),Sg={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},xg=function(d){var s=d;return Sg.hasOwnProperty(d)&&(s=Sg[d]),String.fromCharCode(s)},ci=15,Nr=100,Zm={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},$m={17:2,18:4,21:6,22:8,23:10,19:13,20:15},e1={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},t1={25:2,26:4,29:6,30:8,31:10,27:13,28:15},r1=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],i1=(function(){function d(){this.time=null,this.verboseLevel=0}return d.prototype.log=function(s,t){if(this.verboseLevel>=s){var r=typeof t=="function"?t():t;G.log(this.time+" ["+s+"] "+r)}},d})(),di=function(d){for(var s=[],t=0;t<d.length;t++)s.push(d[t].toString(16));return s},Tg=(function(){function d(t,r,a,o,l){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=r||!1,this.italics=a||!1,this.background=o||"black",this.flash=l||!1}var s=d.prototype;return s.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},s.setStyles=function(t){for(var r=["foreground","underline","italics","background","flash"],a=0;a<r.length;a++){var o=r[a];t.hasOwnProperty(o)&&(this[o]=t[o])}},s.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},s.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},s.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},s.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},d})(),a1=(function(){function d(t,r,a,o,l,h){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new Tg(r,a,o,l,h)}var s=d.prototype;return s.reset=function(){this.uchar=" ",this.penState.reset()},s.setChar=function(t,r){this.uchar=t,this.penState.copy(r)},s.setPenState=function(t){this.penState.copy(t)},s.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},s.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},s.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},d})(),n1=(function(){function d(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var r=0;r<Nr;r++)this.chars.push(new a1);this.logger=t,this.pos=0,this.currPenState=new Tg}var s=d.prototype;return s.equals=function(t){for(var r=!0,a=0;a<Nr;a++)if(!this.chars[a].equals(t.chars[a])){r=!1;break}return r},s.copy=function(t){for(var r=0;r<Nr;r++)this.chars[r].copy(t.chars[r])},s.isEmpty=function(){for(var t=!0,r=0;r<Nr;r++)if(!this.chars[r].isEmpty()){t=!1;break}return t},s.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Nr&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Nr)},s.moveCursor=function(t){var r=this.pos+t;if(t>1)for(var a=this.pos+1;a<r+1;a++)this.chars[a].setPenState(this.currPenState);this.setCursor(r)},s.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},s.insertChar=function(t){var r=this;t>=144&&this.backSpace();var a=xg(t);this.pos>=Nr?this.logger.log(0,function(){return"Cannot insert "+t.toString(16)+" ("+a+") at position "+r.pos+". Skipping it!"}):(this.chars[this.pos].setChar(a,this.currPenState),this.moveCursor(1))},s.clearFromPos=function(t){var r;for(r=t;r<Nr;r++)this.chars[r].reset()},s.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},s.clearToEndOfRow=function(){this.clearFromPos(this.pos)},s.getTextString=function(){for(var t=[],r=!0,a=0;a<Nr;a++){var o=this.chars[a].uchar;o!==" "&&(r=!1),t.push(o)}return r?"":t.join("")},s.setPenStyles=function(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)},d})(),Rl=(function(){function d(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var r=0;r<ci;r++)this.rows.push(new n1(t));this.logger=t,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var s=d.prototype;return s.reset=function(){for(var t=0;t<ci;t++)this.rows[t].clear();this.currRow=14},s.equals=function(t){for(var r=!0,a=0;a<ci;a++)if(!this.rows[a].equals(t.rows[a])){r=!1;break}return r},s.copy=function(t){for(var r=0;r<ci;r++)this.rows[r].copy(t.rows[r])},s.isEmpty=function(){for(var t=!0,r=0;r<ci;r++)if(!this.rows[r].isEmpty()){t=!1;break}return t},s.backSpace=function(){this.rows[this.currRow].backSpace()},s.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},s.insertChar=function(t){this.rows[this.currRow].insertChar(t)},s.setPen=function(t){this.rows[this.currRow].setPenStyles(t)},s.moveCursor=function(t){this.rows[this.currRow].moveCursor(t)},s.setCursor=function(t){this.logger.log(2,"setCursor: "+t),this.rows[this.currRow].setCursor(t)},s.setPAC=function(t){this.logger.log(2,function(){return"pacData = "+JSON.stringify(t)});var r=t.row-1;if(this.nrRollUpRows&&r<this.nrRollUpRows-1&&(r=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==r){for(var a=0;a<ci;a++)this.rows[a].clear();var o=this.currRow+1-this.nrRollUpRows,l=this.lastOutputScreen;if(l){var h=l.rows[o].cueStartTime,u=this.logger.time;if(h&&u!==null&&h<u)for(var f=0;f<this.nrRollUpRows;f++)this.rows[r-this.nrRollUpRows+f+1].copy(l.rows[o+f])}}this.currRow=r;var p=this.rows[this.currRow];if(t.indent!==null){var v=t.indent,w=Math.max(v-1,0);p.setCursor(t.indent),t.color=p.chars[w].penState.foreground}var C={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(C)},s.setBkgData=function(t){this.logger.log(2,function(){return"bkgData = "+JSON.stringify(t)}),this.backSpace(),this.setPen(t),this.insertChar(32)},s.setRollUpRows=function(t){this.nrRollUpRows=t},s.rollUp=function(){var t=this;if(this.nrRollUpRows!==null){this.logger.log(1,function(){return t.getDisplayText()});var r=this.currRow+1-this.nrRollUpRows,a=this.rows.splice(r,1)[0];a.clear(),this.rows.splice(this.currRow,0,a),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")},s.getDisplayText=function(t){t=t||!1;for(var r=[],a="",o=-1,l=0;l<ci;l++){var h=this.rows[l].getTextString();h&&(o=l+1,t?r.push("Row "+o+": '"+h+"'"):r.push(h.trim()))}return r.length>0&&(a=t?"["+r.join(" | ")+"]":r.join(`
19
- `)),a},s.getTextAndFormat=function(){return this.rows},d})(),Dg=(function(){function d(t,r,a){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=r,this.mode=null,this.verbose=0,this.displayedMemory=new Rl(a),this.nonDisplayedMemory=new Rl(a),this.lastOutputScreen=new Rl(a),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=a}var s=d.prototype;return s.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},s.getHandler=function(){return this.outputFilter},s.setHandler=function(t){this.outputFilter=t},s.setPAC=function(t){this.writeScreen.setPAC(t)},s.setBkgData=function(t){this.writeScreen.setBkgData(t)},s.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(2,function(){return"MODE="+t}),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)},s.insertChars=function(t){for(var r=this,a=0;a<t.length;a++)this.writeScreen.insertChar(t[a]);var o=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,function(){return o+": "+r.writeScreen.getDisplayText(!0)}),this.mode!=="MODE_PAINT-ON"&&this.mode!=="MODE_ROLL-UP"||(this.logger.log(1,function(){return"DISPLAYED: "+r.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},s.ccRCL=function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},s.ccBS=function(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},s.ccAOF=function(){},s.ccAON=function(){},s.ccDER=function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},s.ccRU=function(t){this.logger.log(2,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},s.ccFON=function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},s.ccRDC=function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},s.ccTR=function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")},s.ccRTD=function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")},s.ccEDM=function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},s.ccCR=function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},s.ccENM=function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},s.ccEOC=function(){var t=this;if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var r=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=r,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,function(){return"DISP: "+t.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},s.ccTO=function(t){this.logger.log(2,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)},s.ccMIDROW=function(t){var r={flash:!1};r.underline=t%2==1,r.italics=t>=46,r.italics?r.foreground="white":r.foreground=["white","green","blue","cyan","red","yellow","magenta"][Math.floor(t/2)-16],this.logger.log(2,"MIDROW: "+JSON.stringify(r)),this.writeScreen.setPen(r)},s.outputDataUpdate=function(t){t===void 0&&(t=!1);var r=this.logger.time;r!==null&&this.outputFilter&&(this.cueStartTime!==null||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,r,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:r):this.cueStartTime=r,this.lastOutputScreen.copy(this.displayedMemory))},s.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},d})(),Rg=(function(){function d(t,r,a){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var o=new i1;this.channels=[null,new Dg(t,r,o),new Dg(t+1,a,o)],this.cmdHistory={a:null,b:null},this.logger=o}var s=d.prototype;return s.getHandler=function(t){return this.channels[t].getHandler()},s.setHandler=function(t,r){this.channels[t].setHandler(r)},s.addData=function(t,r){var a,o,l,h=!1;this.logger.time=t;for(var u=0;u<r.length;u+=2)if(o=127&r[u],l=127&r[u+1],o!==0||l!==0){if(this.logger.log(3,"["+di([r[u],r[u+1]])+"] -> ("+di([o,l])+")"),(a=this.parseCmd(o,l))||(a=this.parseMidrow(o,l)),a||(a=this.parsePAC(o,l)),a||(a=this.parseBackgroundAttributes(o,l)),!a&&(h=this.parseChars(o,l))){var f=this.currentChannel;f&&f>0?this.channels[f].insertChars(h):this.logger.log(2,"No channel found yet. TEXT-MODE?")}a||h||this.logger.log(2,"Couldn't parse cleaned data "+di([o,l])+" orig: "+di([r[u],r[u+1]]))}},s.parseCmd=function(t,r){var a=this.cmdHistory;if(!((t===20||t===28||t===21||t===29)&&r>=32&&r<=47||(t===23||t===31)&&r>=33&&r<=35))return!1;if(Lg(t,r,a))return Oi(null,null,a),this.logger.log(3,"Repeated command ("+di([t,r])+") is dropped"),!0;var o=t===20||t===21||t===23?1:2,l=this.channels[o];return t===20||t===21||t===28||t===29?r===32?l.ccRCL():r===33?l.ccBS():r===34?l.ccAOF():r===35?l.ccAON():r===36?l.ccDER():r===37?l.ccRU(2):r===38?l.ccRU(3):r===39?l.ccRU(4):r===40?l.ccFON():r===41?l.ccRDC():r===42?l.ccTR():r===43?l.ccRTD():r===44?l.ccEDM():r===45?l.ccCR():r===46?l.ccENM():r===47&&l.ccEOC():l.ccTO(r-32),Oi(t,r,a),this.currentChannel=o,!0},s.parseMidrow=function(t,r){var a=0;if((t===17||t===25)&&r>=32&&r<=47){if((a=t===17?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var o=this.channels[a];return!!o&&(o.ccMIDROW(r),this.logger.log(3,"MIDROW ("+di([t,r])+")"),!0)}return!1},s.parsePAC=function(t,r){var a,o=this.cmdHistory;if(!((t>=17&&t<=23||t>=25&&t<=31)&&r>=64&&r<=127||(t===16||t===24)&&r>=64&&r<=95))return!1;if(Lg(t,r,o))return Oi(null,null,o),!0;var l=t<=23?1:2;a=r>=64&&r<=95?l===1?Zm[t]:e1[t]:l===1?$m[t]:t1[t];var h=this.channels[l];return!!h&&(h.setPAC(this.interpretPAC(a,r)),Oi(t,r,o),this.currentChannel=l,!0)},s.interpretPAC=function(t,r){var a,o={color:null,italics:!1,indent:null,underline:!1,row:t};return a=r>95?r-96:r-64,o.underline=(1&a)==1,a<=13?o.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(a/2)]:a<=15?(o.italics=!0,o.color="white"):o.indent=4*Math.floor((a-16)/2),o},s.parseChars=function(t,r){var a,o,l=null,h=null;if(t>=25?(a=2,h=t-8):(a=1,h=t),h>=17&&h<=19?(o=h===17?r+80:h===18?r+112:r+144,this.logger.log(2,"Special char '"+xg(o)+"' in channel "+a),l=[o]):t>=32&&t<=127&&(l=r===0?[t]:[t,r]),l){var u=di(l);this.logger.log(3,"Char codes = "+u.join(",")),Oi(t,r,this.cmdHistory)}return l},s.parseBackgroundAttributes=function(t,r){var a;if(!((t===16||t===24)&&r>=32&&r<=47||(t===23||t===31)&&r>=45&&r<=47))return!1;var o={};t===16||t===24?(a=Math.floor((r-32)/2),o.background=r1[a],r%2==1&&(o.background=o.background+"_semi")):r===45?o.background="transparent":(o.foreground="black",r===47&&(o.underline=!0));var l=t<=23?1:2;return this.channels[l].setBkgData(o),Oi(t,r,this.cmdHistory),!0},s.reset=function(){for(var t=0;t<Object.keys(this.channels).length;t++){var r=this.channels[t];r&&r.reset()}this.cmdHistory={a:null,b:null}},s.cueSplitAtTime=function(t){for(var r=0;r<this.channels.length;r++){var a=this.channels[r];a&&a.cueSplitAtTime(t)}},d})();function Oi(d,s,t){t.a=d,t.b=s}function Lg(d,s,t){return t.a===d&&t.b===s}var Yn=(function(){function d(t,r){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=r}var s=d.prototype;return s.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},s.newCue=function(t,r,a){(this.startTime===null||this.startTime>t)&&(this.startTime=t),this.endTime=r,this.screen=a,this.timelineController.createCaptionsTrack(this.trackName)},s.reset=function(){this.cueRanges=[],this.startTime=null},d})(),Ll=(function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;var d=["","lr","rl"],s=["start","middle","end","left","right"];function t(l,h){if(typeof h!="string"||!Array.isArray(l))return!1;var u=h.toLowerCase();return!!~l.indexOf(u)&&u}function r(l){return t(s,l)}function a(l){for(var h=arguments.length,u=new Array(h>1?h-1:0),f=1;f<h;f++)u[f-1]=arguments[f];for(var p=1;p<arguments.length;p++){var v=arguments[p];for(var w in v)l[w]=v[w]}return l}function o(l,h,u){var f=this,p={enumerable:!0};f.hasBeenReset=!1;var v="",w=!1,C=l,k=h,I=u,D=null,B="",T=!0,U="auto",M="start",H=50,V="middle",W=50,$="middle";Object.defineProperty(f,"id",a({},p,{get:function(){return v},set:function(J){v=""+J}})),Object.defineProperty(f,"pauseOnExit",a({},p,{get:function(){return w},set:function(J){w=!!J}})),Object.defineProperty(f,"startTime",a({},p,{get:function(){return C},set:function(J){if(typeof J!="number")throw new TypeError("Start time must be set to a number.");C=J,this.hasBeenReset=!0}})),Object.defineProperty(f,"endTime",a({},p,{get:function(){return k},set:function(J){if(typeof J!="number")throw new TypeError("End time must be set to a number.");k=J,this.hasBeenReset=!0}})),Object.defineProperty(f,"text",a({},p,{get:function(){return I},set:function(J){I=""+J,this.hasBeenReset=!0}})),Object.defineProperty(f,"region",a({},p,{get:function(){return D},set:function(J){D=J,this.hasBeenReset=!0}})),Object.defineProperty(f,"vertical",a({},p,{get:function(){return B},set:function(J){var j=(function(le){return t(d,le)})(J);if(j===!1)throw new SyntaxError("An invalid or illegal string was specified.");B=j,this.hasBeenReset=!0}})),Object.defineProperty(f,"snapToLines",a({},p,{get:function(){return T},set:function(J){T=!!J,this.hasBeenReset=!0}})),Object.defineProperty(f,"line",a({},p,{get:function(){return U},set:function(J){if(typeof J!="number"&&J!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");U=J,this.hasBeenReset=!0}})),Object.defineProperty(f,"lineAlign",a({},p,{get:function(){return M},set:function(J){var j=r(J);if(!j)throw new SyntaxError("An invalid or illegal string was specified.");M=j,this.hasBeenReset=!0}})),Object.defineProperty(f,"position",a({},p,{get:function(){return H},set:function(J){if(J<0||J>100)throw new Error("Position must be between 0 and 100.");H=J,this.hasBeenReset=!0}})),Object.defineProperty(f,"positionAlign",a({},p,{get:function(){return V},set:function(J){var j=r(J);if(!j)throw new SyntaxError("An invalid or illegal string was specified.");V=j,this.hasBeenReset=!0}})),Object.defineProperty(f,"size",a({},p,{get:function(){return W},set:function(J){if(J<0||J>100)throw new Error("Size must be between 0 and 100.");W=J,this.hasBeenReset=!0}})),Object.defineProperty(f,"align",a({},p,{get:function(){return $},set:function(J){var j=r(J);if(!j)throw new SyntaxError("An invalid or illegal string was specified.");$=j,this.hasBeenReset=!0}})),f.displayState=void 0}return o.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},o})(),o1=(function(){function d(){}return d.prototype.decode=function(s,t){if(!s)return"";if(typeof s!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(s))},d})();function Mg(d){function s(r,a,o,l){return 3600*(0|r)+60*(0|a)+(0|o)+parseFloat(l||0)}var t=d.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?s(t[2],t[3],0,t[4]):s(t[1],t[2],t[3],t[4]):null}var s1=(function(){function d(){this.values=Object.create(null)}var s=d.prototype;return s.set=function(t,r){this.get(t)||r===""||(this.values[t]=r)},s.get=function(t,r,a){return a?this.has(t)?this.values[t]:r[a]:this.has(t)?this.values[t]:r},s.has=function(t){return t in this.values},s.alt=function(t,r,a){for(var o=0;o<a.length;++o)if(r===a[o]){this.set(t,r);break}},s.integer=function(t,r){/^-?\d+$/.test(r)&&this.set(t,parseInt(r,10))},s.percent=function(t,r){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(r)){var a=parseFloat(r);if(a>=0&&a<=100)return this.set(t,a),!0}return!1},d})();function Fg(d,s,t,r){var a=r?d.split(r):[d];for(var o in a)if(typeof a[o]=="string"){var l=a[o].split(t);l.length===2&&s(l[0],l[1])}}var Ml=new Ll(0,0,""),Kn=Ml.align==="middle"?"middle":"center";function l1(d,s,t){var r=d;function a(){var l=Mg(d);if(l===null)throw new Error("Malformed timestamp: "+r);return d=d.replace(/^[^\sa-zA-Z-]+/,""),l}function o(){d=d.replace(/^\s+/,"")}if(o(),s.startTime=a(),o(),d.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);d=d.slice(3),o(),s.endTime=a(),o(),(function(l,h){var u=new s1;Fg(l,function(v,w){var C;switch(v){case"region":for(var k=t.length-1;k>=0;k--)if(t[k].id===w){u.set(v,t[k].region);break}break;case"vertical":u.alt(v,w,["rl","lr"]);break;case"line":C=w.split(","),u.integer(v,C[0]),u.percent(v,C[0])&&u.set("snapToLines",!1),u.alt(v,C[0],["auto"]),C.length===2&&u.alt("lineAlign",C[1],["start",Kn,"end"]);break;case"position":C=w.split(","),u.percent(v,C[0]),C.length===2&&u.alt("positionAlign",C[1],["start",Kn,"end","line-left","line-right","auto"]);break;case"size":u.percent(v,w);break;case"align":u.alt(v,w,["start",Kn,"end","left","right"])}},/:/,/\s/),h.region=u.get("region",null),h.vertical=u.get("vertical","");var f=u.get("line","auto");f==="auto"&&Ml.line===-1&&(f=-1),h.line=f,h.lineAlign=u.get("lineAlign","start"),h.snapToLines=u.get("snapToLines",!0),h.size=u.get("size",100),h.align=u.get("align",Kn);var p=u.get("position","auto");p==="auto"&&Ml.position===50&&(p=h.align==="start"||h.align==="left"?0:h.align==="end"||h.align==="right"?100:50),h.position=p})(d,s)}function Og(d){return d.replace(/<br(?: \/)?>/gi,`
20
- `)}var c1=(function(){function d(){this.state="INITIAL",this.buffer="",this.decoder=new o1,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var s=d.prototype;return s.parse=function(t){var r=this;function a(){var f=r.buffer,p=0;for(f=Og(f);p<f.length&&f[p]!=="\r"&&f[p]!==`
18
+ Aborting and switching to level `+J),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),a.trigger(x.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:u}))}}}}}}},s.onFragLoaded=function(t,r){var a=r.frag,o=r.part,l=o?o.stats:a.stats;if(a.type===Je&&this.bwEstimator.sampleTTFB(l.loading.first-l.loading.start),!this.ignoreFragment(a)){if(this.clearTimer(),this.lastLoadedFragLevel=a.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var h=o?o.duration:a.duration,u=this.hls.levels[a.level],f=(u.loaded?u.loaded.bytes:0)+l.loaded,p=(u.loaded?u.loaded.duration:0)+h;u.loaded={bytes:f,duration:p},u.realBitrate=Math.round(8*f/p)}if(a.bitrateTest){var v={stats:l,frag:a,part:o,id:a.type};this.onFragBuffered(x.FRAG_BUFFERED,v),a.bitrateTest=!1}}},s.onFragBuffered=function(t,r){var a=r.frag,o=r.part,l=o!=null&&o.stats.loaded?o.stats:a.stats;if(!l.aborted&&!this.ignoreFragment(a)){var h=l.parsing.end-l.loading.start-Math.min(l.loading.first-l.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(h,l.loaded),l.bwEstimate=this.bwEstimator.getEstimate(),a.bitrateTest?this.bitrateTestDelay=h/1e3:this.bitrateTestDelay=0}},s.ignoreFragment=function(t){return t.type!==Je||t.sn==="initSegment"},s.clearTimer=function(){self.clearInterval(this.timer)},s.getNextABRAutoLevel=function(){var t=this.fragCurrent,r=this.partCurrent,a=this.hls,o=a.maxAutoLevel,l=a.config,h=a.minAutoLevel,u=a.media,f=r?r.duration:t?t.duration:0,p=u&&u.playbackRate!==0?Math.abs(u.playbackRate):1,v=this.bwEstimator?this.bwEstimator.getEstimate():l.abrEwmaDefaultEstimate,w=a.mainForwardBufferInfo,C=(w?w.len:0)/p,k=this.findBestLevel(v,h,o,C,l.abrBandWidthFactor,l.abrBandWidthUpFactor);if(k>=0)return k;G.trace("[abr] "+(C?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var I=f?Math.min(f,l.maxStarvationDelay):l.maxStarvationDelay,D=l.abrBandWidthFactor,B=l.abrBandWidthUpFactor;if(!C){var T=this.bitrateTestDelay;T&&(I=(f?Math.min(f,l.maxLoadingDelay):l.maxLoadingDelay)-T,G.trace("[abr] bitrate test took "+Math.round(1e3*T)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*I)+" ms"),D=B=1)}return k=this.findBestLevel(v,h,o,C+I,D,B),Math.max(k,0)},s.findBestLevel=function(t,r,a,o,l,h){for(var u,f=this.fragCurrent,p=this.partCurrent,v=this.lastLoadedFragLevel,w=this.hls.levels,C=w[v],k=!(C==null||(u=C.details)==null||!u.live),I=C?.codecSet,D=p?p.duration:f?f.duration:0,B=this.bwEstimator.getEstimateTTFB()/1e3,T=r,U=-1,M=a;M>=r;M--){var H=w[M];if(!H||I&&H.codecSet!==I)H&&(T=Math.min(M,T),U=Math.max(M,U));else{U!==-1&&G.trace("[abr] Skipped level(s) "+T+"-"+U+' with CODECS:"'+w[U].attrs.CODECS+'"; not compatible with "'+C.attrs.CODECS+'"');var V=H.details,W=(p?V?.partTarget:V?.averagetargetduration)||D,$=void 0;$=M<=v?l*t:h*t;var J=w[M].maxBitrate,j=this.getTimeToLoadFrag(B,$,J*W,V===void 0);if(G.trace("[abr] level:"+M+" adjustedbw-bitrate:"+Math.round($-J)+" avgDuration:"+W.toFixed(1)+" maxFetchDuration:"+o.toFixed(1)+" fetchDuration:"+j.toFixed(1)),$>J&&(j===0||!se(j)||k&&!this.bitrateTestDelay||j<o))return M}}return-1},F(d,[{key:"nextAutoLevel",get:function(){var t=this._nextAutoLevel,r=this.bwEstimator;if(t!==-1&&!r.canEstimate())return t;var a=this.getNextABRAutoLevel();if(t!==-1){var o=this.hls.levels;if(o.length>Math.max(t,a)&&o[t].loadError<=o[a].loadError)return t}return t!==-1&&(a=Math.min(t,a)),a},set:function(t){this._nextAutoLevel=t}}]),d})(),Eg=(function(){function d(){this.chunks=[],this.dataLength=0}var s=d.prototype;return s.push=function(t){this.chunks.push(t),this.dataLength+=t.length},s.flush=function(){var t,r=this.chunks,a=this.dataLength;return r.length?(t=r.length===1?r[0]:(function(o,l){for(var h=new Uint8Array(l),u=0,f=0;f<o.length;f++){var p=o[f];h.set(p,u),u+=p.length}return h})(r,a),this.reset(),t):new Uint8Array(0)},s.reset=function(){this.chunks.length=0,this.dataLength=0},d})(),qm=(function(d){function s(r,a,o){var l;return(l=d.call(this,r,a,o,"[audio-stream-controller]",Cr)||this).videoBuffer=null,l.videoTrackCC=-1,l.waitingVideoCC=-1,l.bufferedTrack=null,l.switchingTrack=null,l.trackId=-1,l.waitingData=null,l.mainDetails=null,l.bufferFlushed=!1,l.cachedTrackLoadedData=null,l._registerListeners(),l}X(s,d);var t=s.prototype;return t.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null},t._registerListeners=function(){var r=this.hls;r.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(x.MANIFEST_LOADING,this.onManifestLoading,this),r.on(x.LEVEL_LOADED,this.onLevelLoaded,this),r.on(x.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),r.on(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(x.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.on(x.ERROR,this.onError,this),r.on(x.BUFFER_RESET,this.onBufferReset,this),r.on(x.BUFFER_CREATED,this.onBufferCreated,this),r.on(x.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(x.INIT_PTS_FOUND,this.onInitPtsFound,this),r.on(x.FRAG_BUFFERED,this.onFragBuffered,this)},t._unregisterListeners=function(){var r=this.hls;r.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(x.MANIFEST_LOADING,this.onManifestLoading,this),r.off(x.LEVEL_LOADED,this.onLevelLoaded,this),r.off(x.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),r.off(x.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(x.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.off(x.ERROR,this.onError,this),r.off(x.BUFFER_RESET,this.onBufferReset,this),r.off(x.BUFFER_CREATED,this.onBufferCreated,this),r.off(x.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(x.INIT_PTS_FOUND,this.onInitPtsFound,this),r.off(x.FRAG_BUFFERED,this.onFragBuffered,this)},t.onInitPtsFound=function(r,a){var o=a.frag,l=a.id,h=a.initPTS,u=a.timescale;if(l==="main"){var f=o.cc;this.initPTS[o.cc]={baseTime:h,timescale:u},this.log("InitPTS for cc: "+f+" found from main: "+h),this.videoTrackCC=f,this.state===ka&&this.tick()}},t.startLoad=function(r){if(!this.levels)return this.startPosition=r,void(this.state=Vt);var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),a>0&&r===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),r=a,this.state=Qe):(this.loadedmetadata=!1,this.state=Ca),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()},t.doTick=function(){switch(this.state){case Qe:this.doTickIdle();break;case Ca:var r,a=this.levels,o=this.trackId,l=a==null||(r=a[o])==null?void 0:r.details;if(l){if(this.waitForCdnTuneIn(l))break;this.state=ka}break;case Ri:var h,u=performance.now(),f=this.retryDate;(!f||u>=f||(h=this.media)!=null&&h.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Qe);break;case ka:var p=this.waitingData;if(p){var v=p.frag,w=p.part,C=p.cache,k=p.complete;if(this.initPTS[v.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=Di;var I={frag:v,part:w,payload:C.flush(),networkDetails:null};this._handleFragmentLoadProgress(I),k&&d.prototype._handleFragmentLoadComplete.call(this,I)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+v.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var D=this.getLoadPosition(),B=ct.bufferInfo(this.mediaBuffer,D,this.config.maxBufferHole);dl(B.end,this.config.maxFragLookUpTolerance,v)<0&&(this.log("Waiting fragment cc ("+v.cc+") @ "+v.start+" cancelled because another fragment at "+B.end+" is needed"),this.clearWaitingFragment())}}else this.state=Qe}this.onTickEnd()},t.clearWaitingFragment=function(){var r=this.waitingData;r&&(this.fragmentTracker.removeFragment(r.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Qe)},t.resetLoadingState=function(){this.clearWaitingFragment(),d.prototype.resetLoadingState.call(this)},t.onTickEnd=function(){var r=this.media;r!=null&&r.readyState&&(this.lastCurrentTime=r.currentTime)},t.doTickIdle=function(){var r=this.hls,a=this.levels,o=this.media,l=this.trackId,h=r.config;if(a!=null&&a[l]&&(o||!this.startFragRequested&&h.startFragPrefetch)){var u=a[l],f=u.details;if(!f||f.live&&this.levelLastLoaded!==l||this.waitForCdnTuneIn(f))this.state=Ca;else{var p=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&p&&(this.bufferFlushed=!1,this.afterBufferFlushed(p,ot,Cr));var v=this.getFwdBufferInfo(p,Cr);if(v!==null){var w=this.bufferedTrack,C=this.switchingTrack;if(!C&&this._streamEnded(v,f))return r.trigger(x.BUFFER_EOS,{type:"audio"}),void(this.state=Ea);var k=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Je),I=v.len,D=this.getMaxBufferLength(k?.len);if(!(I>=D)||C){var B=f.fragments[0].start,T=v.end;if(C&&o){var U=this.getLoadPosition();w&&C.attrs!==w.attrs&&(T=U),f.PTSKnown&&U<B&&(v.end>B||v.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),o.currentTime=B+.05)}var M=this.getNextFragment(T,f),H=!1;if(M&&this.isLoopLoading(M,T)&&(H=!!M.gap,M=this.getNextFragmentLoopLoading(M,f,v,Je,D)),M){var V=k&&M.start>k.end+f.targetduration;if(V||(k==null||!k.len)&&v.len){var W=this.getAppendedFrag(M.start,Je);if(W===null||(H||(H=!!W.gap||!!V&&k.len===0),V&&!H||H&&v.nextStart&&v.nextStart<W.end))return}this.loadFragment(M,u,T)}else this.bufferFlushed=!0}}}}},t.getMaxBufferLength=function(r){var a=d.prototype.getMaxBufferLength.call(this);return r?Math.min(Math.max(a,r),this.config.maxMaxBufferLength):a},t.onMediaDetaching=function(){this.videoBuffer=null,d.prototype.onMediaDetaching.call(this)},t.onAudioTracksUpdated=function(r,a){var o=a.audioTracks;this.resetTransmuxer(),this.levels=o.map(function(l){return new Aa(l)})},t.onAudioTrackSwitching=function(r,a){var o=!!a.url;this.trackId=a.id;var l=this.fragCurrent;l&&(l.abortRequests(),this.removeUnbufferedFrags(l.start)),this.resetLoadingState(),o?this.setInterval(100):this.resetTransmuxer(),o?(this.switchingTrack=a,this.state=Qe):(this.switchingTrack=null,this.bufferedTrack=a,this.state=Vt),this.tick()},t.onManifestLoading=function(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1},t.onLevelLoaded=function(r,a){this.mainDetails=a.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(x.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},t.onAudioTrackLoaded=function(r,a){var o;if(this.mainDetails!=null){var l=this.levels,h=a.details,u=a.id;if(l){this.log("Track "+u+" loaded ["+h.startSN+","+h.endSN+"]"+(h.lastPartSn?"[part-"+h.lastPartSn+"-"+h.lastPartIndex+"]":"")+",duration:"+h.totalduration);var f=l[u],p=0;if(h.live||(o=f.details)!=null&&o.live){this.checkLiveUpdate(h);var v=this.mainDetails;if(h.deltaUpdateFailed||!v)return;!f.details&&h.hasProgramDateTime&&v.hasProgramDateTime?(rg(h,v),p=h.fragments[0].start):p=this.alignPlaylists(h,f.details)}f.details=h,this.levelLastLoaded=u,this.startFragRequested||!this.mainDetails&&h.live||this.setStartPosition(f.details,p),this.state!==Ca||this.waitForCdnTuneIn(h)||(this.state=Qe),this.tick()}else this.warn("Audio tracks were reset while loading level "+u)}else this.cachedTrackLoadedData=a},t._handleFragmentLoadProgress=function(r){var a,o=r.frag,l=r.part,h=r.payload,u=this.config,f=this.trackId,p=this.levels;if(p){var v=p[f];if(v){var w=v.details;if(!w)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(o.start);var C=u.defaultAudioCodec||v.audioCodec||"mp4a.40.2",k=this.transmuxer;k||(k=this.transmuxer=new Cg(this.hls,Cr,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var I=this.initPTS[o.cc],D=(a=o.initSegment)==null?void 0:a.data;if(I!==void 0){var B=l?l.index:-1,T=B!==-1,U=new fl(o.level,o.sn,o.stats.chunkCount,h.byteLength,B,T);k.push(h,D,C,"",o,l,w.totalduration,!1,U,I)}else this.log("Unknown video PTS for cc "+o.cc+", waiting for video PTS before demuxing audio frag "+o.sn+" of ["+w.startSN+" ,"+w.endSN+"],track "+f),(this.waitingData=this.waitingData||{frag:o,part:l,cache:new Eg,complete:!1}).cache.push(new Uint8Array(h)),this.waitingVideoCC=this.videoTrackCC,this.state=ka}else this.warn("Audio track is undefined on fragment load progress")}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered")},t._handleFragmentLoadComplete=function(r){this.waitingData?this.waitingData.complete=!0:d.prototype._handleFragmentLoadComplete.call(this,r)},t.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},t.onBufferCreated=function(r,a){var o=a.tracks.audio;o&&(this.mediaBuffer=o.buffer||null),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer||null)},t.onFragBuffered=function(r,a){var o=a.frag,l=a.part;if(o.type===Cr)if(this.fragContextChanged(o))this.warn("Fragment "+o.sn+(l?" p: "+l.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+(this.switchingTrack?this.switchingTrack.name:"false"));else{if(o.sn!=="initSegment"){this.fragPrevious=o;var h=this.switchingTrack;h&&(this.bufferedTrack=h,this.switchingTrack=null,this.hls.trigger(x.AUDIO_TRACK_SWITCHED,E({},h)))}this.fragBufferedComplete(o,l)}else if(!this.loadedmetadata&&o.type===Je){var u=this.videoBuffer||this.media;u&&ct.getBuffered(u).length&&(this.loadedmetadata=!0)}},t.onError=function(r,a){var o;if(a.fatal)this.state=Li;else switch(a.details){case q.FRAG_GAP:case q.FRAG_PARSING_ERROR:case q.FRAG_DECRYPT_ERROR:case q.FRAG_LOAD_ERROR:case q.FRAG_LOAD_TIMEOUT:case q.KEY_LOAD_ERROR:case q.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Cr,a);break;case q.AUDIO_TRACK_LOAD_ERROR:case q.AUDIO_TRACK_LOAD_TIMEOUT:case q.LEVEL_PARSING_ERROR:a.levelRetry||this.state!==Ca||((o=a.context)==null?void 0:o.type)!==wr||(this.state=Qe);break;case q.BUFFER_FULL_ERROR:if(!a.parent||a.parent!=="audio")return;this.reduceLengthAndFlushBuffer(a)&&(this.bufferedTrack=null,d.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case q.INTERNAL_EXCEPTION:this.recoverWorkerError(a)}},t.onBufferFlushed=function(r,a){a.type===ot&&(this.bufferFlushed=!0,this.state===Ea&&(this.state=Qe))},t._handleTransmuxComplete=function(r){var a,o="audio",l=this.hls,h=r.remuxResult,u=r.chunkMeta,f=this.getCurrentContext(u);if(f){var p=f.frag,v=f.part,w=f.level.details,C=h.audio,k=h.text,I=h.id3,D=h.initSegment;if(!this.fragContextChanged(p)&&w){if(this.state=Ur,this.switchingTrack&&C&&this.completeAudioSwitch(this.switchingTrack),D!=null&&D.tracks){var B=p.initSegment||p;this._bufferInitSegment(D.tracks,B,u),l.trigger(x.FRAG_PARSING_INIT_SEGMENT,{frag:B,id:o,tracks:D.tracks})}if(C){var T=C.startPTS,U=C.endPTS,M=C.startDTS,H=C.endDTS;v&&(v.elementaryStreams[ot]={startPTS:T,endPTS:U,startDTS:M,endDTS:H}),p.setElementaryStreamInfo(ot,T,U,M,H),this.bufferFragmentData(C,p,v,u)}if(I!=null&&(a=I.samples)!=null&&a.length){var V=Y({id:o,frag:p,details:w},I);l.trigger(x.FRAG_PARSING_METADATA,V)}if(k){var W=Y({id:o,frag:p,details:w},k);l.trigger(x.FRAG_PARSING_USERDATA,W)}}else this.fragmentTracker.removeFragment(p)}else this.resetWhenMissingContext(u)},t._bufferInitSegment=function(r,a,o){if(this.state===Ur){r.video&&delete r.video;var l=r.audio;if(l){l.levelCodec=l.codec,l.id="audio",this.log("Init audio buffer, container:"+l.container+", codecs[parsed]=["+l.codec+"]"),this.hls.trigger(x.BUFFER_CODECS,r);var h=l.initSegment;if(h!=null&&h.byteLength){var u={type:"audio",frag:a,part:null,chunkMeta:o,parent:a.type,data:h};this.hls.trigger(x.BUFFER_APPENDING,u)}this.tick()}}},t.loadFragment=function(r,a,o){var l,h=this.fragmentTracker.getState(r);this.fragCurrent=r,this.switchingTrack||h===ya||h===xi?r.sn==="initSegment"?this._loadInitSegment(r,a):(l=a.details)!=null&&l.live&&!this.initPTS[r.cc]?(this.log("Waiting for video PTS in continuity counter "+r.cc+" of live stream before loading audio fragment "+r.sn+" of level "+this.trackId),this.state=ka):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,a,o)):this.clearTrackerIfNeeded(r)},t.completeAudioSwitch=function(r){var a=this.hls,o=this.media,l=this.bufferedTrack,h=l?.attrs,u=r.attrs;o&&h&&(h.CHANNELS!==u.CHANNELS||h.NAME!==u.NAME||h.LANGUAGE!==u.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),d.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=r,this.switchingTrack=null,a.trigger(x.AUDIO_TRACK_SWITCHED,E({},r))},s})(Al),Vm=(function(d){function s(r){var a;return(a=d.call(this,r,"[audio-track-controller]")||this).tracks=[],a.groupId=null,a.tracksInGroup=[],a.trackId=-1,a.currentTrack=null,a.selectDefaultTrack=!0,a.registerListeners(),a}X(s,d);var t=s.prototype;return t.registerListeners=function(){var r=this.hls;r.on(x.MANIFEST_LOADING,this.onManifestLoading,this),r.on(x.MANIFEST_PARSED,this.onManifestParsed,this),r.on(x.LEVEL_LOADING,this.onLevelLoading,this),r.on(x.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(x.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.on(x.ERROR,this.onError,this)},t.unregisterListeners=function(){var r=this.hls;r.off(x.MANIFEST_LOADING,this.onManifestLoading,this),r.off(x.MANIFEST_PARSED,this.onManifestParsed,this),r.off(x.LEVEL_LOADING,this.onLevelLoading,this),r.off(x.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(x.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.off(x.ERROR,this.onError,this)},t.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,d.prototype.destroy.call(this)},t.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0},t.onManifestParsed=function(r,a){this.tracks=a.audioTracks||[]},t.onAudioTrackLoaded=function(r,a){var o=a.id,l=a.groupId,h=a.details,u=this.tracksInGroup[o];if(u&&u.groupId===l){var f=u.details;u.details=a.details,this.log("audio-track "+o+' "'+u.name+'" lang:'+u.lang+" group:"+l+" loaded ["+h.startSN+"-"+h.endSN+"]"),o===this.trackId&&this.playlistLoaded(o,a,f)}else this.warn("Track with id:"+o+" and group:"+l+" not found in active group "+u.groupId)},t.onLevelLoading=function(r,a){this.switchLevel(a.level)},t.onLevelSwitching=function(r,a){this.switchLevel(a.level)},t.switchLevel=function(r){var a=this.hls.levels[r];if(a!=null&&a.audioGroupIds){var o=a.audioGroupIds[a.urlId];if(this.groupId!==o){this.groupId=o||null;var l=this.tracks.filter(function(u){return!o||u.groupId===o});this.selectDefaultTrack&&!l.some(function(u){return u.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=l;var h={audioTracks:l};this.log("Updating audio tracks, "+l.length+" track(s) found in group:"+o),this.hls.trigger(x.AUDIO_TRACKS_UPDATED,h),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}},t.onError=function(r,a){!a.fatal&&a.context&&a.context.type===wr&&a.context.id===this.trackId&&a.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(a))},t.setAudioTrack=function(r){var a=this.tracksInGroup;if(r<0||r>=a.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var o=this.currentTrack;a[this.trackId];var l=a[r],h=l.groupId,u=l.name;if(this.log("Switching to audio-track "+r+' "'+u+'" lang:'+l.lang+" group:"+h),this.trackId=r,this.currentTrack=l,this.selectDefaultTrack=!1,this.hls.trigger(x.AUDIO_TRACK_SWITCHING,E({},l)),!l.details||l.details.live){var f=this.switchParams(l.url,o?.details);this.loadPlaylist(f)}}},t.selectInitialTrack=function(){var r=this.tracksInGroup,a=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(a!==-1)this.setAudioTrack(a);else{var o=new Error("No track found for running audio group-ID: "+this.groupId+" track count: "+r.length);this.warn(o.message),this.hls.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:o})}},t.findTrackId=function(r){for(var a=this.tracksInGroup,o=0;o<a.length;o++){var l=a[o];if((!this.selectDefaultTrack||l.default)&&(!r||r.attrs["STABLE-RENDITION-ID"]!==void 0&&r.attrs["STABLE-RENDITION-ID"]===l.attrs["STABLE-RENDITION-ID"]||r.name===l.name&&r.lang===l.lang))return l.id}return-1},t.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var a=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(a)){var o=a.id,l=a.groupId,h=a.url;if(r)try{h=r.addDirectives(h)}catch(u){this.warn("Could not construct new URL with HLS Delivery Directives: "+u)}this.log("loading audio-track playlist "+o+' "'+a.name+'" lang:'+a.lang+" group:"+l),this.clearTimer(),this.hls.trigger(x.AUDIO_TRACK_LOADING,{url:h,id:o,groupId:l,deliveryDirectives:r||null})}},F(s,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1,this.setAudioTrack(r)}}]),s})(gl);function kg(d,s){if(d.length!==s.length)return!1;for(var t=0;t<d.length;t++)if(!Wm(d[t].attrs,s[t].attrs))return!1;return!0}function Wm(d,s){var t=d["STABLE-RENDITION-ID"];return t?t===s["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(function(r){return d[r]!==s[r]})}var Xm=(function(d){function s(r,a,o){var l;return(l=d.call(this,r,a,o,"[subtitle-stream-controller]",Wr)||this).levels=[],l.currentTrackId=-1,l.tracksBuffered=[],l.mainDetails=null,l._registerListeners(),l}X(s,d);var t=s.prototype;return t.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},t._registerListeners=function(){var r=this.hls;r.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(x.MANIFEST_LOADING,this.onManifestLoading,this),r.on(x.LEVEL_LOADED,this.onLevelLoaded,this),r.on(x.ERROR,this.onError,this),r.on(x.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.on(x.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),r.on(x.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(x.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),r.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),r.on(x.FRAG_BUFFERED,this.onFragBuffered,this)},t._unregisterListeners=function(){var r=this.hls;r.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(x.MANIFEST_LOADING,this.onManifestLoading,this),r.off(x.LEVEL_LOADED,this.onLevelLoaded,this),r.off(x.ERROR,this.onError,this),r.off(x.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.off(x.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),r.off(x.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(x.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),r.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),r.off(x.FRAG_BUFFERED,this.onFragBuffered,this)},t.startLoad=function(r){this.stopLoad(),this.state=Qe,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()},t.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},t.onMediaDetaching=function(){this.tracksBuffered=[],d.prototype.onMediaDetaching.call(this)},t.onLevelLoaded=function(r,a){this.mainDetails=a.details},t.onSubtitleFragProcessed=function(r,a){var o=a.frag,l=a.success;if(this.fragPrevious=o,this.state=Qe,l){var h=this.tracksBuffered[this.currentTrackId];if(h){for(var u,f=o.start,p=0;p<h.length;p++)if(f>=h[p].start&&f<=h[p].end){u=h[p];break}var v=o.start+o.duration;u?u.end=v:(u={start:f,end:v},h.push(u)),this.fragmentTracker.fragBuffered(o)}}},t.onBufferFlushing=function(r,a){var o=a.startOffset,l=a.endOffset;if(o===0&&l!==Number.POSITIVE_INFINITY){var h=l-1;if(h<=0)return;a.endOffsetSubtitles=Math.max(0,h),this.tracksBuffered.forEach(function(u){for(var f=0;f<u.length;)if(u[f].end<=h)u.shift();else{if(!(u[f].start<h))break;u[f].start=h,f++}}),this.fragmentTracker.removeFragmentsInRange(o,h,Wr)}},t.onFragBuffered=function(r,a){var o;this.loadedmetadata||a.frag.type!==Je||(o=this.media)!=null&&o.buffered.length&&(this.loadedmetadata=!0)},t.onError=function(r,a){var o=a.frag;o?.type===Wr&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Vt&&(this.state=Qe))},t.onSubtitleTracksUpdated=function(r,a){var o=this,l=a.subtitleTracks;kg(this.levels,l)?this.levels=l.map(function(h){return new Aa(h)}):(this.tracksBuffered=[],this.levels=l.map(function(h){var u=new Aa(h);return o.tracksBuffered[u.id]=[],u}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Wr),this.fragPrevious=null,this.mediaBuffer=null)},t.onSubtitleTrackSwitch=function(r,a){if(this.currentTrackId=a.id,this.levels.length&&this.currentTrackId!==-1){var o=this.levels[this.currentTrackId];o!=null&&o.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,o&&this.setInterval(500)}else this.clearInterval()},t.onSubtitleTrackLoaded=function(r,a){var o,l=a.details,h=a.id,u=this.currentTrackId,f=this.levels;if(f.length){var p=f[u];if(!(h>=f.length||h!==u)&&p){this.mediaBuffer=this.mediaBufferTimeRanges;var v=0;if(l.live||(o=p.details)!=null&&o.live){var w=this.mainDetails;if(l.deltaUpdateFailed||!w)return;var C=w.fragments[0];p.details?(v=this.alignPlaylists(l,p.details))===0&&C&&ll(l,v=C.start):l.hasProgramDateTime&&w.hasProgramDateTime?(rg(l,w),v=l.fragments[0].start):C&&ll(l,v=C.start)}p.details=l,this.levelLastLoaded=h,this.startFragRequested||!this.mainDetails&&l.live||this.setStartPosition(p.details,v),this.tick(),l.live&&!this.fragCurrent&&this.media&&this.state===Qe&&(ba(null,l.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),p.details=void 0))}}},t._handleFragmentLoadComplete=function(r){var a=this,o=r.frag,l=r.payload,h=o.decryptdata,u=this.hls;if(!this.fragContextChanged(o)&&l&&l.byteLength>0&&h&&h.key&&h.iv&&h.method==="AES-128"){var f=performance.now();this.decrypter.decrypt(new Uint8Array(l),h.key.buffer,h.iv.buffer).catch(function(p){throw u.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.FRAG_DECRYPT_ERROR,fatal:!1,error:p,reason:p.message,frag:o}),p}).then(function(p){var v=performance.now();u.trigger(x.FRAG_DECRYPTED,{frag:o,payload:p,stats:{tstart:f,tdecrypt:v}})}).catch(function(p){a.warn(p.name+": "+p.message),a.state=Qe})}},t.doTick=function(){if(this.media){if(this.state===Qe){var r=this.currentTrackId,a=this.levels,o=a[r];if(!a.length||!o||!o.details)return;var l=this.config,h=this.getLoadPosition(),u=ct.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],h,l.maxBufferHole),f=u.end,p=u.len,v=this.getFwdBufferInfo(this.media,Je),w=o.details;if(p>this.getMaxBufferLength(v?.len)+w.levelTargetDuration)return;var C=w.fragments,k=C.length,I=w.edge,D=null,B=this.fragPrevious;if(f<I){var T=l.maxFragLookUpTolerance,U=f>I-T?0:T;!(D=ba(B,C,Math.max(C[0].start,f),U))&&B&&B.start<C[0].start&&(D=C[0])}else D=C[k-1];if(!D)return;if((D=this.mapToInitFragWhenRequired(D)).sn!=="initSegment"){var M=C[D.sn-w.startSN-1];M&&M.cc===D.cc&&this.fragmentTracker.getState(M)===ya&&(D=M)}this.fragmentTracker.getState(D)===ya&&this.loadFragment(D,o,f)}}else this.state=Qe},t.getMaxBufferLength=function(r){var a=d.prototype.getMaxBufferLength.call(this);return r?Math.max(a,r):a},t.loadFragment=function(r,a,o){this.fragCurrent=r,r.sn==="initSegment"?this._loadInitSegment(r,a):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,a,o))},F(s,[{key:"mediaBufferTimeRanges",get:function(){return new Jm(this.tracksBuffered[this.currentTrackId]||[])}}]),s})(Al),Jm=function(d){this.buffered=void 0;var s=function(t,r,a){if((r>>>=0)>a-1)throw new DOMException("Failed to execute '"+t+"' on 'TimeRanges': The index provided ("+r+") is greater than the maximum bound ("+a+")");return d[r][t]};this.buffered={get length(){return d.length},end:function(t){return s("end",t,d.length)},start:function(t){return s("start",t,d.length)}}},_m=(function(d){function s(r){var a;return(a=d.call(this,r,"[subtitle-track-controller]")||this).media=null,a.tracks=[],a.groupId=null,a.tracksInGroup=[],a.trackId=-1,a.selectDefaultTrack=!0,a.queuedDefaultTrack=-1,a.trackChangeListener=function(){return a.onTextTracksChanged()},a.asyncPollTrackChange=function(){return a.pollTrackChange(0)},a.useTextTrackPolling=!1,a.subtitlePollingInterval=-1,a._subtitleDisplay=!0,a.registerListeners(),a}X(s,d);var t=s.prototype;return t.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,d.prototype.destroy.call(this)},t.registerListeners=function(){var r=this.hls;r.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(x.MANIFEST_LOADING,this.onManifestLoading,this),r.on(x.MANIFEST_PARSED,this.onManifestParsed,this),r.on(x.LEVEL_LOADING,this.onLevelLoading,this),r.on(x.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(x.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(x.ERROR,this.onError,this)},t.unregisterListeners=function(){var r=this.hls;r.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(x.MANIFEST_LOADING,this.onManifestLoading,this),r.off(x.MANIFEST_PARSED,this.onManifestParsed,this),r.off(x.LEVEL_LOADING,this.onLevelLoading,this),r.off(x.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(x.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(x.ERROR,this.onError,this)},t.onMediaAttached=function(r,a){this.media=a.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},t.pollTrackChange=function(r){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,r)},t.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Dl(this.media.textTracks).forEach(function(r){Ii(r)}),this.subtitleTrack=-1,this.media=null)},t.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},t.onManifestParsed=function(r,a){this.tracks=a.subtitleTracks},t.onSubtitleTrackLoaded=function(r,a){var o=a.id,l=a.details,h=this.trackId,u=this.tracksInGroup[h];if(u){var f=u.details;u.details=a.details,this.log("subtitle track "+o+" loaded ["+l.startSN+"-"+l.endSN+"]"),o===this.trackId&&this.playlistLoaded(o,a,f)}else this.warn("Invalid subtitle track id "+o)},t.onLevelLoading=function(r,a){this.switchLevel(a.level)},t.onLevelSwitching=function(r,a){this.switchLevel(a.level)},t.switchLevel=function(r){var a=this.hls.levels[r];if(a!=null&&a.textGroupIds){var o=a.textGroupIds[a.urlId],l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==o){var h=this.tracks.filter(function(p){return!o||p.groupId===o});this.tracksInGroup=h;var u=this.findTrackId(l?.name)||this.findTrackId();this.groupId=o||null;var f={subtitleTracks:h};this.log("Updating subtitle tracks, "+h.length+' track(s) found in "'+o+'" group-id'),this.hls.trigger(x.SUBTITLE_TRACKS_UPDATED,f),u!==-1&&this.setSubtitleTrack(u,l)}else this.shouldReloadPlaylist(l)&&this.setSubtitleTrack(this.trackId,l)}},t.findTrackId=function(r){for(var a=this.tracksInGroup,o=0;o<a.length;o++){var l=a[o];if((!this.selectDefaultTrack||l.default)&&(!r||r===l.name))return l.id}return-1},t.onError=function(r,a){!a.fatal&&a.context&&a.context.type===Fr&&a.context.id===this.trackId&&a.context.groupId===this.groupId&&this.checkRetry(a)},t.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var a=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(a)){var o=a.id,l=a.groupId,h=a.url;if(r)try{h=r.addDirectives(h)}catch(u){this.warn("Could not construct new URL with HLS Delivery Directives: "+u)}this.log("Loading subtitle playlist for id "+o),this.hls.trigger(x.SUBTITLE_TRACK_LOADING,{url:h,id:o,groupId:l,deliveryDirectives:r||null})}},t.toggleTrackModes=function(r){var a=this,o=this.media,l=this.trackId;if(o){var h=Dl(o.textTracks),u=h.filter(function(v){return v.groupId===a.groupId});if(r===-1)[].slice.call(h).forEach(function(v){v.mode="disabled"});else{var f=u[l];f&&(f.mode="disabled")}var p=u[r];p&&(p.mode=this.subtitleDisplay?"showing":"hidden")}},t.setSubtitleTrack=function(r,a){var o,l=this.tracksInGroup;if(this.media){if(this.trackId!==r&&this.toggleTrackModes(r),!(this.trackId===r&&(r===-1||(o=l[r])!=null&&o.details)||r<-1||r>=l.length)){this.clearTimer();var h=l[r];if(this.log("Switching to subtitle-track "+r+(h?' "'+h.name+'" lang:'+h.lang+" group:"+h.groupId:"")),this.trackId=r,h){var u=h.id,f=h.groupId,p=f===void 0?"":f,v=h.name,w=h.type,C=h.url;this.hls.trigger(x.SUBTITLE_TRACK_SWITCH,{id:u,groupId:p,name:v,type:w,url:C});var k=this.switchParams(h.url,a?.details);this.loadPlaylist(k)}else this.hls.trigger(x.SUBTITLE_TRACK_SWITCH,{id:r})}}else this.queuedDefaultTrack=r},t.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var r=-1,a=Dl(this.media.textTracks),o=0;o<a.length;o++)if(a[o].mode==="hidden")r=o;else if(a[o].mode==="showing"){r=o;break}this.subtitleTrack!==r&&(this.subtitleTrack=r)}},F(s,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(r){this._subtitleDisplay=r,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1;var a=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(r,a)}}]),s})(gl);function Dl(d){for(var s=[],t=0;t<d.length;t++){var r=d[t];r.kind!=="subtitles"&&r.kind!=="captions"||!r.label||s.push(d[t])}return s}var jm=(function(){function d(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}var s=d.prototype;return s.append=function(t,r){var a=this.queues[r];a.push(t),a.length===1&&this.buffers[r]&&this.executeNext(r)},s.insertAbort=function(t,r){this.queues[r].unshift(t),this.executeNext(r)},s.appendBlocker=function(t){var r,a=new Promise(function(l){r=l}),o={execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(o,t),a},s.executeNext=function(t){var r=this.buffers,a=this.queues,o=r[t],l=a[t];if(l.length){var h=l[0];try{h.execute()}catch(u){G.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),h.onError(u),o!=null&&o.updating||(l.shift(),this.executeNext(t))}}},s.shiftAndExecuteNext=function(t){this.queues[t].shift(),this.executeNext(t)},s.current=function(t){return this.queues[t][0]},d})(),Bg=xn(),Ig=/([ha]vc.)(?:\.[^.,]+)+/,Zm=(function(){function d(t){var r=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var a=r.media,o=r.mediaSource;G.log("[buffer-controller]: Media source opened"),a&&(a.removeEventListener("emptied",r._onMediaEmptied),r.updateMediaElementDuration(),r.hls.trigger(x.MEDIA_ATTACHED,{media:a})),o&&o.removeEventListener("sourceopen",r._onMediaSourceOpen),r.checkPendingTracks()},this._onMediaSourceClose=function(){G.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){G.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=function(){var a=r.media,o=r._objectUrl;a&&a.src!==o&&G.error("Media element src was set while attaching MediaSource ("+o+" > "+a.src+")")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var s=d.prototype;return s.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},s.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},s.registerListeners=function(){var t=this.hls;t.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.MANIFEST_PARSED,this.onManifestParsed,this),t.on(x.BUFFER_RESET,this.onBufferReset,this),t.on(x.BUFFER_APPENDING,this.onBufferAppending,this),t.on(x.BUFFER_CODECS,this.onBufferCodecs,this),t.on(x.BUFFER_EOS,this.onBufferEos,this),t.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(x.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(x.FRAG_PARSED,this.onFragParsed,this),t.on(x.FRAG_CHANGED,this.onFragChanged,this)},s.unregisterListeners=function(){var t=this.hls;t.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.MANIFEST_PARSED,this.onManifestParsed,this),t.off(x.BUFFER_RESET,this.onBufferReset,this),t.off(x.BUFFER_APPENDING,this.onBufferAppending,this),t.off(x.BUFFER_CODECS,this.onBufferCodecs,this),t.off(x.BUFFER_EOS,this.onBufferEos,this),t.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(x.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(x.FRAG_PARSED,this.onFragParsed,this),t.off(x.FRAG_CHANGED,this.onFragChanged,this)},s._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new jm(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},s.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},s.onManifestParsed=function(t,r){var a=2;(r.audio&&!r.video||!r.altAudio)&&(a=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=a,G.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},s.onMediaAttaching=function(t,r){var a=this.media=r.media;if(a&&Bg){var o=this.mediaSource=new Bg;o.addEventListener("sourceopen",this._onMediaSourceOpen),o.addEventListener("sourceended",this._onMediaSourceEnded),o.addEventListener("sourceclose",this._onMediaSourceClose),a.src=self.URL.createObjectURL(o),this._objectUrl=a.src,a.addEventListener("emptied",this._onMediaEmptied)}},s.onMediaDetaching=function(){var t=this.media,r=this.mediaSource,a=this._objectUrl;if(r){if(G.log("[buffer-controller]: media source detaching"),r.readyState==="open")try{r.endOfStream()}catch(o){G.warn("[buffer-controller]: onMediaDetaching: "+o.message+" while calling endOfStream")}this.onBufferReset(),r.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("sourceended",this._onMediaSourceEnded),r.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),a&&self.URL.revokeObjectURL(a),t.src===a?(t.removeAttribute("src"),t.load()):G.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(x.MEDIA_DETACHED,void 0)},s.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach(function(r){var a=t.sourceBuffer[r];try{a&&(t.removeBufferListeners(r),t.mediaSource&&t.mediaSource.removeSourceBuffer(a),t.sourceBuffer[r]=void 0)}catch(o){G.warn("[buffer-controller]: Failed to reset the "+r+" buffer",o)}}),this._initSourceBuffer()},s.onBufferCodecs=function(t,r){var a=this,o=this.getSourceBufferTypes().length;Object.keys(r).forEach(function(l){if(o){var h=a.tracks[l];if(h&&typeof h.buffer.changeType=="function"){var u=r[l],f=u.id,p=u.codec,v=u.levelCodec,w=u.container,C=u.metadata,k=(h.levelCodec||h.codec).replace(Ig,"$1"),I=(v||p).replace(Ig,"$1");if(k!==I){var D=w+";codecs="+(v||p);a.appendChangeType(l,D),G.log("[buffer-controller]: switching codec "+k+" to "+I),a.tracks[l]={buffer:h.buffer,codec:p,container:w,levelCodec:v,metadata:C,id:f}}}}else a.pendingTracks[l]=r[l]}),o||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},s.appendChangeType=function(t,r){var a=this,o=this.operationQueue;o.append({execute:function(){var l=a.sourceBuffer[t];l&&(G.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+r),l.changeType(r)),o.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(l){G.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",l)}},t)},s.onBufferAppending=function(t,r){var a=this,o=this.hls,l=this.operationQueue,h=this.tracks,u=r.data,f=r.type,p=r.frag,v=r.part,w=r.chunkMeta,C=w.buffering[f],k=self.performance.now();C.start=k;var I=p.stats.buffering,D=v?v.stats.buffering:null;I.start===0&&(I.start=k),D&&D.start===0&&(D.start=k);var B=h.audio,T=!1;f==="audio"&&B?.container==="audio/mpeg"&&(T=!this.lastMpegAudioChunk||w.id===1||this.lastMpegAudioChunk.sn!==w.sn,this.lastMpegAudioChunk=w);var U=p.start;l.append({execute:function(){if(C.executeStart=self.performance.now(),T){var M=a.sourceBuffer[f];if(M){var H=U-M.timestampOffset;Math.abs(H)>=.1&&(G.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+U+" (delta: "+H+") sn: "+p.sn+")"),M.timestampOffset=U)}}a.appendExecutor(u,f)},onStart:function(){},onComplete:function(){var M=self.performance.now();C.executeEnd=C.end=M,I.first===0&&(I.first=M),D&&D.first===0&&(D.first=M);var H=a.sourceBuffer,V={};for(var W in H)V[W]=ct.getBuffered(H[W]);a.appendError=0,a.hls.trigger(x.BUFFER_APPENDED,{type:f,frag:p,part:v,chunkMeta:w,parent:p.type,timeRanges:V})},onError:function(M){G.error("[buffer-controller]: Error encountered while trying to append to the "+f+" SourceBuffer",M);var H={type:ue.MEDIA_ERROR,parent:p.type,details:q.BUFFER_APPEND_ERROR,frag:p,part:v,chunkMeta:w,error:M,err:M,fatal:!1};M.code===DOMException.QUOTA_EXCEEDED_ERR?H.details=q.BUFFER_FULL_ERROR:(a.appendError++,H.details=q.BUFFER_APPEND_ERROR,a.appendError>o.config.appendErrorMaxRetry&&(G.error("[buffer-controller]: Failed "+o.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),H.fatal=!0)),o.trigger(x.ERROR,H)}},f)},s.onBufferFlushing=function(t,r){var a=this,o=this.operationQueue,l=function(h){return{execute:a.removeExecutor.bind(a,h,r.startOffset,r.endOffset),onStart:function(){},onComplete:function(){a.hls.trigger(x.BUFFER_FLUSHED,{type:h})},onError:function(u){G.warn("[buffer-controller]: Failed to remove from "+h+" SourceBuffer",u)}}};r.type?o.append(l(r.type),r.type):this.getSourceBufferTypes().forEach(function(h){o.append(l(h),h)})},s.onFragParsed=function(t,r){var a=this,o=r.frag,l=r.part,h=[],u=l?l.elementaryStreams:o.elementaryStreams;u[zt]?h.push("audiovideo"):(u[ot]&&h.push("audio"),u[bt]&&h.push("video")),h.length===0&&G.warn("Fragments must have at least one ElementaryStreamType set. type: "+o.type+" level: "+o.level+" sn: "+o.sn),this.blockBuffers(function(){var f=self.performance.now();o.stats.buffering.end=f,l&&(l.stats.buffering.end=f);var p=l?l.stats:o.stats;a.hls.trigger(x.FRAG_BUFFERED,{frag:o,part:l,stats:p,id:o.type})},h)},s.onFragChanged=function(t,r){this.flushBackBuffer()},s.onBufferEos=function(t,r){var a=this;this.getSourceBufferTypes().reduce(function(o,l){var h=a.sourceBuffer[l];return!h||r.type&&r.type!==l||(h.ending=!0,h.ended||(h.ended=!0,G.log("[buffer-controller]: "+l+" sourceBuffer now EOS"))),o&&!(h&&!h.ended)},!0)&&(G.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){a.getSourceBufferTypes().forEach(function(l){var h=a.sourceBuffer[l];h&&(h.ending=!1)});var o=a.mediaSource;o&&o.readyState==="open"?(G.log("[buffer-controller]: Calling mediaSource.endOfStream()"),o.endOfStream()):o&&G.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+o.readyState)}))},s.onLevelUpdated=function(t,r){var a=r.details;a.fragments.length&&(this.details=a,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},s.flushBackBuffer=function(){var t=this.hls,r=this.details,a=this.media,o=this.sourceBuffer;if(a&&r!==null){var l=this.getSourceBufferTypes();if(l.length){var h=r.live&&t.config.liveBackBufferLength!==null?t.config.liveBackBufferLength:t.config.backBufferLength;if(se(h)&&!(h<0)){var u=a.currentTime,f=r.levelTargetDuration,p=Math.max(h,f),v=Math.floor(u/f)*f-p;l.forEach(function(w){var C=o[w];if(C){var k=ct.getBuffered(C);if(k.length>0&&v>k.start(0)){if(t.trigger(x.BACK_BUFFER_REACHED,{bufferEnd:v}),r.live)t.trigger(x.LIVE_BACK_BUFFER_REACHED,{bufferEnd:v});else if(C.ended&&k.end(k.length-1)-u<2*f)return void G.info("[buffer-controller]: Cannot flush "+w+" back buffer while SourceBuffer is in ended state");t.trigger(x.BUFFER_FLUSHING,{startOffset:0,endOffset:v,type:w})}}})}}}},s.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&this.mediaSource.readyState==="open"){var t=this.details,r=this.hls,a=this.media,o=this.mediaSource,l=t.fragments[0].start+t.totalduration,h=a.duration,u=se(o.duration)?o.duration:0;t.live&&r.config.liveDurationInfinity?(G.log("[buffer-controller]: Media Source duration is set to Infinity"),o.duration=1/0,this.updateSeekableRange(t)):(l>u&&l>h||!se(h))&&(G.log("[buffer-controller]: Updating Media Source duration to "+l.toFixed(3)),o.duration=l)}},s.updateSeekableRange=function(t){var r=this.mediaSource,a=t.fragments;if(a.length&&t.live&&r!=null&&r.setLiveSeekableRange){var o=Math.max(0,a[0].start),l=Math.max(o,o+t.totalduration);r.setLiveSeekableRange(o,l)}},s.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,r=this.operationQueue,a=this.pendingTracks,o=Object.keys(a).length;if(o&&!t||o===2){this.createSourceBuffers(a),this.pendingTracks={};var l=this.getSourceBufferTypes();if(l.length)this.hls.trigger(x.BUFFER_CREATED,{tracks:this.tracks}),l.forEach(function(u){r.executeNext(u)});else{var h=new Error("could not create source buffer for media codec(s)");this.hls.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:h,reason:h.message})}}},s.createSourceBuffers=function(t){var r=this.sourceBuffer,a=this.mediaSource;if(!a)throw Error("createSourceBuffers called when mediaSource was null");for(var o in t)if(!r[o]){var l=t[o];if(!l)throw Error("source buffer exists for track "+o+", however track does not");var h=l.levelCodec||l.codec,u=l.container+";codecs="+h;G.log("[buffer-controller]: creating sourceBuffer("+u+")");try{var f=r[o]=a.addSourceBuffer(u),p=o;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[o]={buffer:f,codec:h,container:l.container,levelCodec:l.levelCodec,metadata:l.metadata,id:l.id}}catch(v){G.error("[buffer-controller]: error while trying to add sourceBuffer: "+v.message),this.hls.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:v,mimeType:u})}}},s._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},s._onSBUpdateEnd=function(t){var r=this.operationQueue;r.current(t).onComplete(),r.shiftAndExecuteNext(t)},s._onSBUpdateError=function(t,r){var a=new Error(t+" SourceBuffer error");G.error("[buffer-controller]: "+a,r),this.hls.trigger(x.ERROR,{type:ue.MEDIA_ERROR,details:q.BUFFER_APPENDING_ERROR,error:a,fatal:!1});var o=this.operationQueue.current(t);o&&o.onError(r)},s.removeExecutor=function(t,r,a){var o=this.media,l=this.mediaSource,h=this.operationQueue,u=this.sourceBuffer[t];if(!o||!l||!u)return G.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void h.shiftAndExecuteNext(t);var f=se(o.duration)?o.duration:1/0,p=se(l.duration)?l.duration:1/0,v=Math.max(0,r),w=Math.min(a,f,p);w>v&&!u.ending?(u.ended=!1,G.log("[buffer-controller]: Removing ["+v+","+w+"] from the "+t+" SourceBuffer"),u.remove(v,w)):h.shiftAndExecuteNext(t)},s.appendExecutor=function(t,r){var a=this.operationQueue,o=this.sourceBuffer[r];if(!o)return G.warn("[buffer-controller]: Attempting to append to the "+r+" SourceBuffer, but it does not exist"),void a.shiftAndExecuteNext(r);o.ended=!1,o.appendBuffer(t)},s.blockBuffers=function(t,r){var a=this;if(r===void 0&&(r=this.getSourceBufferTypes()),!r.length)return G.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(t);var o=this.operationQueue,l=r.map(function(h){return o.appendBlocker(h)});Promise.all(l).then(function(){t(),r.forEach(function(h){var u=a.sourceBuffer[h];u!=null&&u.updating||o.shiftAndExecuteNext(h)})})},s.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},s.addBufferListener=function(t,r,a){var o=this.sourceBuffer[t];if(o){var l=a.bind(this,t);this.listeners[t].push({event:r,listener:l}),o.addEventListener(r,l)}},s.removeBufferListeners=function(t){var r=this.sourceBuffer[t];r&&this.listeners[t].forEach(function(a){r.removeEventListener(a.event,a.listener)})},d})(),Sg={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},xg=function(d){var s=d;return Sg.hasOwnProperty(d)&&(s=Sg[d]),String.fromCharCode(s)},ci=15,Nr=100,$m={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},e1={17:2,18:4,21:6,22:8,23:10,19:13,20:15},t1={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},r1={25:2,26:4,29:6,30:8,31:10,27:13,28:15},i1=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],a1=(function(){function d(){this.time=null,this.verboseLevel=0}return d.prototype.log=function(s,t){if(this.verboseLevel>=s){var r=typeof t=="function"?t():t;G.log(this.time+" ["+s+"] "+r)}},d})(),di=function(d){for(var s=[],t=0;t<d.length;t++)s.push(d[t].toString(16));return s},Tg=(function(){function d(t,r,a,o,l){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=r||!1,this.italics=a||!1,this.background=o||"black",this.flash=l||!1}var s=d.prototype;return s.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},s.setStyles=function(t){for(var r=["foreground","underline","italics","background","flash"],a=0;a<r.length;a++){var o=r[a];t.hasOwnProperty(o)&&(this[o]=t[o])}},s.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},s.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},s.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},s.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},d})(),n1=(function(){function d(t,r,a,o,l,h){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new Tg(r,a,o,l,h)}var s=d.prototype;return s.reset=function(){this.uchar=" ",this.penState.reset()},s.setChar=function(t,r){this.uchar=t,this.penState.copy(r)},s.setPenState=function(t){this.penState.copy(t)},s.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},s.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},s.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},d})(),o1=(function(){function d(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var r=0;r<Nr;r++)this.chars.push(new n1);this.logger=t,this.pos=0,this.currPenState=new Tg}var s=d.prototype;return s.equals=function(t){for(var r=!0,a=0;a<Nr;a++)if(!this.chars[a].equals(t.chars[a])){r=!1;break}return r},s.copy=function(t){for(var r=0;r<Nr;r++)this.chars[r].copy(t.chars[r])},s.isEmpty=function(){for(var t=!0,r=0;r<Nr;r++)if(!this.chars[r].isEmpty()){t=!1;break}return t},s.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Nr&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Nr)},s.moveCursor=function(t){var r=this.pos+t;if(t>1)for(var a=this.pos+1;a<r+1;a++)this.chars[a].setPenState(this.currPenState);this.setCursor(r)},s.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},s.insertChar=function(t){var r=this;t>=144&&this.backSpace();var a=xg(t);this.pos>=Nr?this.logger.log(0,function(){return"Cannot insert "+t.toString(16)+" ("+a+") at position "+r.pos+". Skipping it!"}):(this.chars[this.pos].setChar(a,this.currPenState),this.moveCursor(1))},s.clearFromPos=function(t){var r;for(r=t;r<Nr;r++)this.chars[r].reset()},s.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},s.clearToEndOfRow=function(){this.clearFromPos(this.pos)},s.getTextString=function(){for(var t=[],r=!0,a=0;a<Nr;a++){var o=this.chars[a].uchar;o!==" "&&(r=!1),t.push(o)}return r?"":t.join("")},s.setPenStyles=function(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)},d})(),Rl=(function(){function d(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var r=0;r<ci;r++)this.rows.push(new o1(t));this.logger=t,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var s=d.prototype;return s.reset=function(){for(var t=0;t<ci;t++)this.rows[t].clear();this.currRow=14},s.equals=function(t){for(var r=!0,a=0;a<ci;a++)if(!this.rows[a].equals(t.rows[a])){r=!1;break}return r},s.copy=function(t){for(var r=0;r<ci;r++)this.rows[r].copy(t.rows[r])},s.isEmpty=function(){for(var t=!0,r=0;r<ci;r++)if(!this.rows[r].isEmpty()){t=!1;break}return t},s.backSpace=function(){this.rows[this.currRow].backSpace()},s.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},s.insertChar=function(t){this.rows[this.currRow].insertChar(t)},s.setPen=function(t){this.rows[this.currRow].setPenStyles(t)},s.moveCursor=function(t){this.rows[this.currRow].moveCursor(t)},s.setCursor=function(t){this.logger.log(2,"setCursor: "+t),this.rows[this.currRow].setCursor(t)},s.setPAC=function(t){this.logger.log(2,function(){return"pacData = "+JSON.stringify(t)});var r=t.row-1;if(this.nrRollUpRows&&r<this.nrRollUpRows-1&&(r=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==r){for(var a=0;a<ci;a++)this.rows[a].clear();var o=this.currRow+1-this.nrRollUpRows,l=this.lastOutputScreen;if(l){var h=l.rows[o].cueStartTime,u=this.logger.time;if(h&&u!==null&&h<u)for(var f=0;f<this.nrRollUpRows;f++)this.rows[r-this.nrRollUpRows+f+1].copy(l.rows[o+f])}}this.currRow=r;var p=this.rows[this.currRow];if(t.indent!==null){var v=t.indent,w=Math.max(v-1,0);p.setCursor(t.indent),t.color=p.chars[w].penState.foreground}var C={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(C)},s.setBkgData=function(t){this.logger.log(2,function(){return"bkgData = "+JSON.stringify(t)}),this.backSpace(),this.setPen(t),this.insertChar(32)},s.setRollUpRows=function(t){this.nrRollUpRows=t},s.rollUp=function(){var t=this;if(this.nrRollUpRows!==null){this.logger.log(1,function(){return t.getDisplayText()});var r=this.currRow+1-this.nrRollUpRows,a=this.rows.splice(r,1)[0];a.clear(),this.rows.splice(this.currRow,0,a),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")},s.getDisplayText=function(t){t=t||!1;for(var r=[],a="",o=-1,l=0;l<ci;l++){var h=this.rows[l].getTextString();h&&(o=l+1,t?r.push("Row "+o+": '"+h+"'"):r.push(h.trim()))}return r.length>0&&(a=t?"["+r.join(" | ")+"]":r.join(`
19
+ `)),a},s.getTextAndFormat=function(){return this.rows},d})(),Dg=(function(){function d(t,r,a){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=r,this.mode=null,this.verbose=0,this.displayedMemory=new Rl(a),this.nonDisplayedMemory=new Rl(a),this.lastOutputScreen=new Rl(a),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=a}var s=d.prototype;return s.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},s.getHandler=function(){return this.outputFilter},s.setHandler=function(t){this.outputFilter=t},s.setPAC=function(t){this.writeScreen.setPAC(t)},s.setBkgData=function(t){this.writeScreen.setBkgData(t)},s.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(2,function(){return"MODE="+t}),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)},s.insertChars=function(t){for(var r=this,a=0;a<t.length;a++)this.writeScreen.insertChar(t[a]);var o=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,function(){return o+": "+r.writeScreen.getDisplayText(!0)}),this.mode!=="MODE_PAINT-ON"&&this.mode!=="MODE_ROLL-UP"||(this.logger.log(1,function(){return"DISPLAYED: "+r.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},s.ccRCL=function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},s.ccBS=function(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},s.ccAOF=function(){},s.ccAON=function(){},s.ccDER=function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},s.ccRU=function(t){this.logger.log(2,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},s.ccFON=function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},s.ccRDC=function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},s.ccTR=function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")},s.ccRTD=function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")},s.ccEDM=function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},s.ccCR=function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},s.ccENM=function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},s.ccEOC=function(){var t=this;if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var r=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=r,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,function(){return"DISP: "+t.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},s.ccTO=function(t){this.logger.log(2,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)},s.ccMIDROW=function(t){var r={flash:!1};r.underline=t%2==1,r.italics=t>=46,r.italics?r.foreground="white":r.foreground=["white","green","blue","cyan","red","yellow","magenta"][Math.floor(t/2)-16],this.logger.log(2,"MIDROW: "+JSON.stringify(r)),this.writeScreen.setPen(r)},s.outputDataUpdate=function(t){t===void 0&&(t=!1);var r=this.logger.time;r!==null&&this.outputFilter&&(this.cueStartTime!==null||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,r,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:r):this.cueStartTime=r,this.lastOutputScreen.copy(this.displayedMemory))},s.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},d})(),Rg=(function(){function d(t,r,a){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var o=new a1;this.channels=[null,new Dg(t,r,o),new Dg(t+1,a,o)],this.cmdHistory={a:null,b:null},this.logger=o}var s=d.prototype;return s.getHandler=function(t){return this.channels[t].getHandler()},s.setHandler=function(t,r){this.channels[t].setHandler(r)},s.addData=function(t,r){var a,o,l,h=!1;this.logger.time=t;for(var u=0;u<r.length;u+=2)if(o=127&r[u],l=127&r[u+1],o!==0||l!==0){if(this.logger.log(3,"["+di([r[u],r[u+1]])+"] -> ("+di([o,l])+")"),(a=this.parseCmd(o,l))||(a=this.parseMidrow(o,l)),a||(a=this.parsePAC(o,l)),a||(a=this.parseBackgroundAttributes(o,l)),!a&&(h=this.parseChars(o,l))){var f=this.currentChannel;f&&f>0?this.channels[f].insertChars(h):this.logger.log(2,"No channel found yet. TEXT-MODE?")}a||h||this.logger.log(2,"Couldn't parse cleaned data "+di([o,l])+" orig: "+di([r[u],r[u+1]]))}},s.parseCmd=function(t,r){var a=this.cmdHistory;if(!((t===20||t===28||t===21||t===29)&&r>=32&&r<=47||(t===23||t===31)&&r>=33&&r<=35))return!1;if(Lg(t,r,a))return Oi(null,null,a),this.logger.log(3,"Repeated command ("+di([t,r])+") is dropped"),!0;var o=t===20||t===21||t===23?1:2,l=this.channels[o];return t===20||t===21||t===28||t===29?r===32?l.ccRCL():r===33?l.ccBS():r===34?l.ccAOF():r===35?l.ccAON():r===36?l.ccDER():r===37?l.ccRU(2):r===38?l.ccRU(3):r===39?l.ccRU(4):r===40?l.ccFON():r===41?l.ccRDC():r===42?l.ccTR():r===43?l.ccRTD():r===44?l.ccEDM():r===45?l.ccCR():r===46?l.ccENM():r===47&&l.ccEOC():l.ccTO(r-32),Oi(t,r,a),this.currentChannel=o,!0},s.parseMidrow=function(t,r){var a=0;if((t===17||t===25)&&r>=32&&r<=47){if((a=t===17?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var o=this.channels[a];return!!o&&(o.ccMIDROW(r),this.logger.log(3,"MIDROW ("+di([t,r])+")"),!0)}return!1},s.parsePAC=function(t,r){var a,o=this.cmdHistory;if(!((t>=17&&t<=23||t>=25&&t<=31)&&r>=64&&r<=127||(t===16||t===24)&&r>=64&&r<=95))return!1;if(Lg(t,r,o))return Oi(null,null,o),!0;var l=t<=23?1:2;a=r>=64&&r<=95?l===1?$m[t]:t1[t]:l===1?e1[t]:r1[t];var h=this.channels[l];return!!h&&(h.setPAC(this.interpretPAC(a,r)),Oi(t,r,o),this.currentChannel=l,!0)},s.interpretPAC=function(t,r){var a,o={color:null,italics:!1,indent:null,underline:!1,row:t};return a=r>95?r-96:r-64,o.underline=(1&a)==1,a<=13?o.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(a/2)]:a<=15?(o.italics=!0,o.color="white"):o.indent=4*Math.floor((a-16)/2),o},s.parseChars=function(t,r){var a,o,l=null,h=null;if(t>=25?(a=2,h=t-8):(a=1,h=t),h>=17&&h<=19?(o=h===17?r+80:h===18?r+112:r+144,this.logger.log(2,"Special char '"+xg(o)+"' in channel "+a),l=[o]):t>=32&&t<=127&&(l=r===0?[t]:[t,r]),l){var u=di(l);this.logger.log(3,"Char codes = "+u.join(",")),Oi(t,r,this.cmdHistory)}return l},s.parseBackgroundAttributes=function(t,r){var a;if(!((t===16||t===24)&&r>=32&&r<=47||(t===23||t===31)&&r>=45&&r<=47))return!1;var o={};t===16||t===24?(a=Math.floor((r-32)/2),o.background=i1[a],r%2==1&&(o.background=o.background+"_semi")):r===45?o.background="transparent":(o.foreground="black",r===47&&(o.underline=!0));var l=t<=23?1:2;return this.channels[l].setBkgData(o),Oi(t,r,this.cmdHistory),!0},s.reset=function(){for(var t=0;t<Object.keys(this.channels).length;t++){var r=this.channels[t];r&&r.reset()}this.cmdHistory={a:null,b:null}},s.cueSplitAtTime=function(t){for(var r=0;r<this.channels.length;r++){var a=this.channels[r];a&&a.cueSplitAtTime(t)}},d})();function Oi(d,s,t){t.a=d,t.b=s}function Lg(d,s,t){return t.a===d&&t.b===s}var Yn=(function(){function d(t,r){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=r}var s=d.prototype;return s.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},s.newCue=function(t,r,a){(this.startTime===null||this.startTime>t)&&(this.startTime=t),this.endTime=r,this.screen=a,this.timelineController.createCaptionsTrack(this.trackName)},s.reset=function(){this.cueRanges=[],this.startTime=null},d})(),Ll=(function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;var d=["","lr","rl"],s=["start","middle","end","left","right"];function t(l,h){if(typeof h!="string"||!Array.isArray(l))return!1;var u=h.toLowerCase();return!!~l.indexOf(u)&&u}function r(l){return t(s,l)}function a(l){for(var h=arguments.length,u=new Array(h>1?h-1:0),f=1;f<h;f++)u[f-1]=arguments[f];for(var p=1;p<arguments.length;p++){var v=arguments[p];for(var w in v)l[w]=v[w]}return l}function o(l,h,u){var f=this,p={enumerable:!0};f.hasBeenReset=!1;var v="",w=!1,C=l,k=h,I=u,D=null,B="",T=!0,U="auto",M="start",H=50,V="middle",W=50,$="middle";Object.defineProperty(f,"id",a({},p,{get:function(){return v},set:function(J){v=""+J}})),Object.defineProperty(f,"pauseOnExit",a({},p,{get:function(){return w},set:function(J){w=!!J}})),Object.defineProperty(f,"startTime",a({},p,{get:function(){return C},set:function(J){if(typeof J!="number")throw new TypeError("Start time must be set to a number.");C=J,this.hasBeenReset=!0}})),Object.defineProperty(f,"endTime",a({},p,{get:function(){return k},set:function(J){if(typeof J!="number")throw new TypeError("End time must be set to a number.");k=J,this.hasBeenReset=!0}})),Object.defineProperty(f,"text",a({},p,{get:function(){return I},set:function(J){I=""+J,this.hasBeenReset=!0}})),Object.defineProperty(f,"region",a({},p,{get:function(){return D},set:function(J){D=J,this.hasBeenReset=!0}})),Object.defineProperty(f,"vertical",a({},p,{get:function(){return B},set:function(J){var j=(function(le){return t(d,le)})(J);if(j===!1)throw new SyntaxError("An invalid or illegal string was specified.");B=j,this.hasBeenReset=!0}})),Object.defineProperty(f,"snapToLines",a({},p,{get:function(){return T},set:function(J){T=!!J,this.hasBeenReset=!0}})),Object.defineProperty(f,"line",a({},p,{get:function(){return U},set:function(J){if(typeof J!="number"&&J!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");U=J,this.hasBeenReset=!0}})),Object.defineProperty(f,"lineAlign",a({},p,{get:function(){return M},set:function(J){var j=r(J);if(!j)throw new SyntaxError("An invalid or illegal string was specified.");M=j,this.hasBeenReset=!0}})),Object.defineProperty(f,"position",a({},p,{get:function(){return H},set:function(J){if(J<0||J>100)throw new Error("Position must be between 0 and 100.");H=J,this.hasBeenReset=!0}})),Object.defineProperty(f,"positionAlign",a({},p,{get:function(){return V},set:function(J){var j=r(J);if(!j)throw new SyntaxError("An invalid or illegal string was specified.");V=j,this.hasBeenReset=!0}})),Object.defineProperty(f,"size",a({},p,{get:function(){return W},set:function(J){if(J<0||J>100)throw new Error("Size must be between 0 and 100.");W=J,this.hasBeenReset=!0}})),Object.defineProperty(f,"align",a({},p,{get:function(){return $},set:function(J){var j=r(J);if(!j)throw new SyntaxError("An invalid or illegal string was specified.");$=j,this.hasBeenReset=!0}})),f.displayState=void 0}return o.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},o})(),s1=(function(){function d(){}return d.prototype.decode=function(s,t){if(!s)return"";if(typeof s!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(s))},d})();function Mg(d){function s(r,a,o,l){return 3600*(0|r)+60*(0|a)+(0|o)+parseFloat(l||0)}var t=d.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?s(t[2],t[3],0,t[4]):s(t[1],t[2],t[3],t[4]):null}var l1=(function(){function d(){this.values=Object.create(null)}var s=d.prototype;return s.set=function(t,r){this.get(t)||r===""||(this.values[t]=r)},s.get=function(t,r,a){return a?this.has(t)?this.values[t]:r[a]:this.has(t)?this.values[t]:r},s.has=function(t){return t in this.values},s.alt=function(t,r,a){for(var o=0;o<a.length;++o)if(r===a[o]){this.set(t,r);break}},s.integer=function(t,r){/^-?\d+$/.test(r)&&this.set(t,parseInt(r,10))},s.percent=function(t,r){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(r)){var a=parseFloat(r);if(a>=0&&a<=100)return this.set(t,a),!0}return!1},d})();function Fg(d,s,t,r){var a=r?d.split(r):[d];for(var o in a)if(typeof a[o]=="string"){var l=a[o].split(t);l.length===2&&s(l[0],l[1])}}var Ml=new Ll(0,0,""),Kn=Ml.align==="middle"?"middle":"center";function c1(d,s,t){var r=d;function a(){var l=Mg(d);if(l===null)throw new Error("Malformed timestamp: "+r);return d=d.replace(/^[^\sa-zA-Z-]+/,""),l}function o(){d=d.replace(/^\s+/,"")}if(o(),s.startTime=a(),o(),d.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);d=d.slice(3),o(),s.endTime=a(),o(),(function(l,h){var u=new l1;Fg(l,function(v,w){var C;switch(v){case"region":for(var k=t.length-1;k>=0;k--)if(t[k].id===w){u.set(v,t[k].region);break}break;case"vertical":u.alt(v,w,["rl","lr"]);break;case"line":C=w.split(","),u.integer(v,C[0]),u.percent(v,C[0])&&u.set("snapToLines",!1),u.alt(v,C[0],["auto"]),C.length===2&&u.alt("lineAlign",C[1],["start",Kn,"end"]);break;case"position":C=w.split(","),u.percent(v,C[0]),C.length===2&&u.alt("positionAlign",C[1],["start",Kn,"end","line-left","line-right","auto"]);break;case"size":u.percent(v,w);break;case"align":u.alt(v,w,["start",Kn,"end","left","right"])}},/:/,/\s/),h.region=u.get("region",null),h.vertical=u.get("vertical","");var f=u.get("line","auto");f==="auto"&&Ml.line===-1&&(f=-1),h.line=f,h.lineAlign=u.get("lineAlign","start"),h.snapToLines=u.get("snapToLines",!0),h.size=u.get("size",100),h.align=u.get("align",Kn);var p=u.get("position","auto");p==="auto"&&Ml.position===50&&(p=h.align==="start"||h.align==="left"?0:h.align==="end"||h.align==="right"?100:50),h.position=p})(d,s)}function Og(d){return d.replace(/<br(?: \/)?>/gi,`
20
+ `)}var d1=(function(){function d(){this.state="INITIAL",this.buffer="",this.decoder=new s1,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var s=d.prototype;return s.parse=function(t){var r=this;function a(){var f=r.buffer,p=0;for(f=Og(f);p<f.length&&f[p]!=="\r"&&f[p]!==`
21
21
  `;)++p;var v=f.slice(0,p);return f[p]==="\r"&&++p,f[p]===`
22
- `&&++p,r.buffer=f.slice(p),v}t&&(r.buffer+=r.decoder.decode(t,{stream:!0}));try{var o="";if(r.state==="INITIAL"){if(!/\r\n|\n/.test(r.buffer))return this;var l=(o=a()).match(/^()?WEBVTT([ \t].*)?$/);if(l==null||!l[0])throw new Error("Malformed WebVTT signature.");r.state="HEADER"}for(var h=!1;r.buffer;){if(!/\r\n|\n/.test(r.buffer))return this;switch(h?h=!1:o=a(),r.state){case"HEADER":/:/.test(o)?Fg(o,function(f,p){},/:/):o||(r.state="ID");continue;case"NOTE":o||(r.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(o)){r.state="NOTE";break}if(!o)continue;if(r.cue=new Ll(0,0,""),r.state="CUE",o.indexOf("-->")===-1){r.cue.id=o;continue}case"CUE":if(!r.cue){r.state="BADCUE";continue}try{l1(o,r.cue,r.regionList)}catch{r.cue=null,r.state="BADCUE";continue}r.state="CUETEXT";continue;case"CUETEXT":var u=o.indexOf("-->")!==-1;if(!o||u&&(h=!0)){r.oncue&&r.cue&&r.oncue(r.cue),r.cue=null,r.state="ID";continue}if(r.cue===null)continue;r.cue.text&&(r.cue.text+=`
22
+ `&&++p,r.buffer=f.slice(p),v}t&&(r.buffer+=r.decoder.decode(t,{stream:!0}));try{var o="";if(r.state==="INITIAL"){if(!/\r\n|\n/.test(r.buffer))return this;var l=(o=a()).match(/^()?WEBVTT([ \t].*)?$/);if(l==null||!l[0])throw new Error("Malformed WebVTT signature.");r.state="HEADER"}for(var h=!1;r.buffer;){if(!/\r\n|\n/.test(r.buffer))return this;switch(h?h=!1:o=a(),r.state){case"HEADER":/:/.test(o)?Fg(o,function(f,p){},/:/):o||(r.state="ID");continue;case"NOTE":o||(r.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(o)){r.state="NOTE";break}if(!o)continue;if(r.cue=new Ll(0,0,""),r.state="CUE",o.indexOf("-->")===-1){r.cue.id=o;continue}case"CUE":if(!r.cue){r.state="BADCUE";continue}try{c1(o,r.cue,r.regionList)}catch{r.cue=null,r.state="BADCUE";continue}r.state="CUETEXT";continue;case"CUETEXT":var u=o.indexOf("-->")!==-1;if(!o||u&&(h=!0)){r.oncue&&r.cue&&r.oncue(r.cue),r.cue=null,r.state="ID";continue}if(r.cue===null)continue;r.cue.text&&(r.cue.text+=`
23
23
  `),r.cue.text+=o;continue;case"BADCUE":o||(r.state="ID")}}}catch{r.state==="CUETEXT"&&r.cue&&r.oncue&&r.oncue(r.cue),r.cue=null,r.state=r.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},s.flush=function(){var t=this;try{if((t.cue||t.state==="HEADER")&&(t.buffer+=`
24
24
 
25
- `,t.parse()),t.state==="INITIAL"||t.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(r){t.onparsingerror&&t.onparsingerror(r)}return t.onflush&&t.onflush(),this},d})(),d1=/\r\n|\n\r|\n|\r/g,Fl=function(d,s,t){return t===void 0&&(t=0),d.slice(t,t+s.length)===s},Ol=function(d){for(var s=5381,t=d.length;t;)s=33*s^d.charCodeAt(--t);return(s>>>0).toString()};function Pl(d,s,t){return Ol(d.toString())+Ol(s.toString())+Ol(t)}function h1(d,s,t,r,a,o,l){var h,u,f,p=new c1,v=br(new Uint8Array(d)).trim().replace(d1,`
25
+ `,t.parse()),t.state==="INITIAL"||t.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(r){t.onparsingerror&&t.onparsingerror(r)}return t.onflush&&t.onflush(),this},d})(),h1=/\r\n|\n\r|\n|\r/g,Fl=function(d,s,t){return t===void 0&&(t=0),d.slice(t,t+s.length)===s},Ol=function(d){for(var s=5381,t=d.length;t;)s=33*s^d.charCodeAt(--t);return(s>>>0).toString()};function Pl(d,s,t){return Ol(d.toString())+Ol(s.toString())+Ol(t)}function u1(d,s,t,r,a,o,l){var h,u,f,p=new d1,v=br(new Uint8Array(d)).trim().replace(h1,`
26
26
  `).split(`
27
27
  `),w=[],C=s?(h=s.baseTime,(u=s.timescale)===void 0&&(u=1),Cl(h,9e4,1/u)):0,k="00:00.000",I=0,D=0,B=!0;p.oncue=function(T){var U=t[r],M=t.ccOffset,H=(I-C)/9e4;if(U!=null&&U.new&&(D!==void 0?M=t.ccOffset=U.start:(function(J,j,le){var ie=J[j],me=J[ie.prevCC];if(!me||!me.new&&ie.new)return J.ccOffset=J.presentationOffset=ie.start,void(ie.new=!1);for(;(we=me)!=null&&we.new;){var we;J.ccOffset+=ie.start-me.start,ie.new=!1,me=J[(ie=me).prevCC]}J.presentationOffset=le})(t,r,H)),H){if(!s)return void(f=new Error("Missing initPTS for VTT MPEGTS"));M=H-t.presentationOffset}var V=T.endTime-T.startTime,W=Wt(9e4*(T.startTime+M-D),9e4*a)/9e4;T.startTime=Math.max(W,0),T.endTime=Math.max(W+V,0);var $=T.text.trim();T.text=decodeURIComponent(encodeURIComponent($)),T.id||(T.id=Pl(T.startTime,T.endTime,$)),T.endTime>0&&w.push(T)},p.onparsingerror=function(T){f=T},p.onflush=function(){f?l(f):o(w)},v.forEach(function(T){if(B){if(Fl(T,"X-TIMESTAMP-MAP=")){B=!1,T.slice(16).split(",").forEach(function(U){Fl(U,"LOCAL:")?k=U.slice(6):Fl(U,"MPEGTS:")&&(I=parseInt(U.slice(7)))});try{D=(function(U){var M=parseInt(U.slice(-3)),H=parseInt(U.slice(-6,-4)),V=parseInt(U.slice(-9,-7)),W=U.length>9?parseInt(U.substring(0,U.indexOf(":"))):0;if(!(se(M)&&se(H)&&se(V)&&se(W)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+U);return M+=1e3*H,(M+=6e4*V)+36e5*W})(k)/1e3}catch(U){f=U}return}T===""&&(B=!1)}p.parse(T+`
28
- `)}),p.flush()}var Ul="stpp.ttml.im1t",Pg=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Ug=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,u1={left:"start",center:"center",right:"end",start:"start",end:"end"};function Qg(d,s,t,r){var a=Ye(new Uint8Array(d),["mdat"]);if(a.length!==0){var o,l,h,u,f=a.map(function(v){return br(v)}),p=(o=s.baseTime,l=1,(h=s.timescale)===void 0&&(h=1),u===void 0&&(u=!1),Cl(o,l,1/h,u));try{f.forEach(function(v){return t((function(w,C){var k=new DOMParser().parseFromString(w,"text/xml").getElementsByTagName("tt")[0];if(!k)throw new Error("Invalid ttml");var I={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},D=Object.keys(I).reduce(function(H,V){return H[V]=k.getAttribute("ttp:"+V)||I[V],H},{}),B=k.getAttribute("xml:space")!=="preserve",T=Ng(Ql(k,"styling","style")),U=Ng(Ql(k,"layout","region")),M=Ql(k,"body","[begin]");return[].map.call(M,function(H){var V=Hg(H,B);if(!V||!H.hasAttribute("begin"))return null;var W=Hl(H.getAttribute("begin"),D),$=Hl(H.getAttribute("dur"),D),J=Hl(H.getAttribute("end"),D);if(W===null)throw Gg(H);if(J===null){if($===null)throw Gg(H);J=W+$}var j=new Ll(W-C,J-C,V);j.id=Pl(j.startTime,j.endTime,j.text);var le=(function(we,ve,Ae){var Ie="http://www.w3.org/ns/ttml#styling",fe=null,Pe=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],Ue=we!=null&&we.hasAttribute("style")?we.getAttribute("style"):null;return Ue&&Ae.hasOwnProperty(Ue)&&(fe=Ae[Ue]),Pe.reduce(function(ze,je){var mt=Nl(ve,Ie,je)||Nl(we,Ie,je)||Nl(fe,Ie,je);return mt&&(ze[je]=mt),ze},{})})(U[H.getAttribute("region")],T[H.getAttribute("style")],T),ie=le.textAlign;if(ie){var me=u1[ie];me&&(j.lineAlign=me),j.align=ie}return Y(j,le),j}).filter(function(H){return H!==null})})(v,p))})}catch(v){r(v)}}else r(new Error("Could not parse IMSC1 mdat"))}function Ql(d,s,t){var r=d.getElementsByTagName(s)[0];return r?[].slice.call(r.querySelectorAll(t)):[]}function Ng(d){return d.reduce(function(s,t){var r=t.getAttribute("xml:id");return r&&(s[r]=t),s},{})}function Hg(d,s){return[].slice.call(d.childNodes).reduce(function(t,r,a){var o;return r.nodeName==="br"&&a?t+`
29
- `:(o=r.childNodes)!=null&&o.length?Hg(r,s):s?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function Nl(d,s,t){return d&&d.hasAttributeNS(s,t)?d.getAttributeNS(s,t):null}function Gg(d){return new Error("Could not parse ttml timestamp "+d)}function Hl(d,s){if(!d)return null;var t=Mg(d);return t===null&&(Pg.test(d)?t=(function(r,a){var o=Pg.exec(r),l=(0|o[4])+(0|o[5])/a.subFrameRate;return 3600*(0|o[1])+60*(0|o[2])+(0|o[3])+l/a.frameRate})(d,s):Ug.test(d)&&(t=(function(r,a){var o=Ug.exec(r),l=Number(o[1]);switch(o[2]){case"h":return 3600*l;case"m":return 60*l;case"ms":return 1e3*l;case"f":return l/a.frameRate;case"t":return l/a.tickRate}return l})(d,s))),t}var g1=(function(){function d(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var r=new Yn(this,"textTrack1"),a=new Yn(this,"textTrack2"),o=new Yn(this,"textTrack3"),l=new Yn(this,"textTrack4");this.cea608Parser1=new Rg(1,r,a),this.cea608Parser2=new Rg(3,o,l)}t.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(x.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(x.FRAG_LOADING,this.onFragLoading,this),t.on(x.FRAG_LOADED,this.onFragLoaded,this),t.on(x.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(x.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(x.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(x.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this)}var s=d.prototype;return s.destroy=function(){var t=this.hls;t.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(x.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(x.FRAG_LOADING,this.onFragLoading,this),t.off(x.FRAG_LOADED,this.onFragLoaded,this),t.off(x.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(x.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(x.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(x.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},s.addCues=function(t,r,a,o,l){for(var h,u,f,p,v=!1,w=l.length;w--;){var C=l[w],k=(h=C[0],u=C[1],f=r,p=a,Math.min(u,p)-Math.max(h,f));if(k>=0&&(C[0]=Math.min(C[0],r),C[1]=Math.max(C[1],a),v=!0,k/(a-r)>.5))return}if(v||l.push([r,a]),this.config.renderTextTracksNatively){var I=this.captionsTracks[t];this.Cues.newCue(I,r,a,o)}else{var D=this.Cues.newCue(null,r,a,o);this.hls.trigger(x.CUES_PARSED,{type:"captions",cues:D,track:t})}},s.onInitPtsFound=function(t,r){var a=this,o=r.frag,l=r.id,h=r.initPTS,u=r.timescale,f=this.unparsedVttFrags;l==="main"&&(this.initPTS[o.cc]={baseTime:h,timescale:u}),f.length&&(this.unparsedVttFrags=[],f.forEach(function(p){a.onFragLoaded(x.FRAG_LOADED,p)}))},s.getExistingTrack=function(t){var r=this.media;if(r)for(var a=0;a<r.textTracks.length;a++){var o=r.textTracks[a];if(o[t])return o}return null},s.createCaptionsTrack=function(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)},s.createNativeTrack=function(t){if(!this.captionsTracks[t]){var r=this.captionsProperties,a=this.captionsTracks,o=this.media,l=r[t],h=l.label,u=l.languageCode,f=this.getExistingTrack(t);if(f)a[t]=f,Ii(a[t]),Qu(a[t],o);else{var p=this.createTextTrack("captions",h,u);p&&(p[t]=!0,a[t]=p)}}},s.createNonNativeTrack=function(t){if(!this.nonNativeCaptionsTracks[t]){var r=this.captionsProperties[t];if(r){var a={_id:t,label:r.label,kind:"captions",default:!!r.media&&!!r.media.default,closedCaptions:r.media};this.nonNativeCaptionsTracks[t]=a,this.hls.trigger(x.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[a]})}}},s.createTextTrack=function(t,r,a){var o=this.media;if(o)return o.addTextTrack(t,r,a)},s.onMediaAttaching=function(t,r){this.media=r.media,this._cleanTracks()},s.onMediaDetaching=function(){var t=this.captionsTracks;Object.keys(t).forEach(function(r){Ii(t[r]),delete t[r]}),this.nonNativeCaptionsTracks={}},s.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},s._cleanTracks=function(){var t=this.media;if(t){var r=t.textTracks;if(r)for(var a=0;a<r.length;a++)Ii(r[a])}},s.onSubtitleTracksUpdated=function(t,r){var a=this,o=r.subtitleTracks||[],l=o.some(function(f){return f.textCodec===Ul});if(this.config.enableWebVTT||l&&this.config.enableIMSC1){if(kg(this.tracks,o))return void(this.tracks=o);if(this.textTracks=[],this.tracks=o,this.config.renderTextTracksNatively){var h=this.media?this.media.textTracks:null;this.tracks.forEach(function(f,p){var v;if(h&&p<h.length){for(var w=null,C=0;C<h.length;C++)if(f1(h[C],f)){w=h[C];break}w&&(v=w)}if(v)Ii(v);else{var k=a._captionsOrSubtitlesFromCharacteristics(f);(v=a.createTextTrack(k,f.name,f.lang))&&(v.mode="disabled")}v&&(v.groupId=f.groupId,a.textTracks.push(v))})}else if(this.tracks.length){var u=this.tracks.map(function(f){return{label:f.name,kind:f.type.toLowerCase(),default:f.default,subtitleTrack:f}});this.hls.trigger(x.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:u})}}},s._captionsOrSubtitlesFromCharacteristics=function(t){if(t.attrs.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),a=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(r&&a)return"captions"}return"subtitles"},s.onManifestLoaded=function(t,r){var a=this;this.config.enableCEA708Captions&&r.captions&&r.captions.forEach(function(o){var l=/(?:CC|SERVICE)([1-4])/.exec(o.instreamId);if(l){var h="textTrack"+l[1],u=a.captionsProperties[h];u&&(u.label=o.name,o.lang&&(u.languageCode=o.lang),u.media=o)}})},s.closedCaptionsForLevel=function(t){var r=this.hls.levels[t.level];return r?.attrs["CLOSED-CAPTIONS"]},s.onFragLoading=function(t,r){var a=this.cea608Parser1,o=this.cea608Parser2,l=this.lastSn,h=this.lastPartIndex;if(this.enabled&&a&&o&&r.frag.type===Je){var u,f,p=r.frag.sn,v=(u=r==null||(f=r.part)==null?void 0:f.index)!=null?u:-1;p===l+1||p===l&&v===h+1||(a.reset(),o.reset()),this.lastSn=p,this.lastPartIndex=v}},s.onFragLoaded=function(t,r){var a=r.frag,o=r.payload;if(a.type===Wr)if(o.byteLength){var l=a.decryptdata,h="stats"in r;if(l==null||!l.encrypted||h){var u=this.tracks[a.level],f=this.vttCCs;f[a.cc]||(f[a.cc]={start:a.start,prevCC:this.prevCC,new:!0},this.prevCC=a.cc),u&&u.textCodec===Ul?this._parseIMSC1(a,o):this._parseVTTs(r)}}else this.hls.trigger(x.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:a,error:new Error("Empty subtitle payload")})},s._parseIMSC1=function(t,r){var a=this,o=this.hls;Qg(r,this.initPTS[t.cc],function(l){a._appendCues(l,t.level),o.trigger(x.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},function(l){G.log("Failed to parse IMSC1: "+l),o.trigger(x.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:l})})},s._parseVTTs=function(t){var r,a=this,o=t.frag,l=t.payload,h=this.initPTS,u=this.unparsedVttFrags,f=h.length-1;if(h[o.cc]||f!==-1){var p=this.hls;h1((r=o.initSegment)!=null&&r.data?ni(o.initSegment.data,new Uint8Array(l)):l,this.initPTS[o.cc],this.vttCCs,o.cc,o.start,function(v){a._appendCues(v,o.level),p.trigger(x.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:o})},function(v){var w=v.message==="Missing initPTS for VTT MPEGTS";w?u.push(t):a._fallbackToIMSC1(o,l),G.log("Failed to parse VTT cue: "+v),w&&f>o.cc||p.trigger(x.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:v})})}else u.push(t)},s._fallbackToIMSC1=function(t,r){var a=this,o=this.tracks[t.level];o.textCodec||Qg(r,this.initPTS[t.cc],function(){o.textCodec=Ul,a._parseIMSC1(t,r)},function(){o.textCodec="wvtt"})},s._appendCues=function(t,r){var a=this.hls;if(this.config.renderTextTracksNatively){var o=this.textTracks[r];if(!o||o.mode==="disabled")return;t.forEach(function(u){return Nu(o,u)})}else{var l=this.tracks[r];if(!l)return;var h=l.default?"default":"subtitles"+r;a.trigger(x.CUES_PARSED,{type:"subtitles",cues:t,track:h})}},s.onFragDecrypted=function(t,r){r.frag.type===Wr&&this.onFragLoaded(x.FRAG_LOADED,r)},s.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},s.onFragParsingUserdata=function(t,r){var a=this.cea608Parser1,o=this.cea608Parser2;if(this.enabled&&a&&o){var l=r.frag,h=r.samples;if(l.type!==Je||this.closedCaptionsForLevel(l)!=="NONE")for(var u=0;u<h.length;u++){var f=h[u].bytes;if(f){var p=this.extractCea608Data(f);a.addData(h[u].pts,p[0]),o.addData(h[u].pts,p[1])}}}},s.onBufferFlushing=function(t,r){var a=r.startOffset,o=r.endOffset,l=r.endOffsetSubtitles,h=r.type,u=this.media;if(u&&!(u.currentTime<o)){if(!h||h==="video"){var f=this.captionsTracks;Object.keys(f).forEach(function(v){return rl(f[v],a,o)})}if(this.config.renderTextTracksNatively&&a===0&&l!==void 0){var p=this.textTracks;Object.keys(p).forEach(function(v){return rl(p[v],a,l)})}}},s.extractCea608Data=function(t){for(var r=[[],[]],a=31&t[0],o=2,l=0;l<a;l++){var h=t[o++],u=127&t[o++],f=127&t[o++];if((u!==0||f!==0)&&(4&h)!=0){var p=3&h;p!==0&&p!==1||(r[p].push(u),r[p].push(f))}}return r},d})();function f1(d,s){return!!d&&d.label===s.name&&!(d.textTrack1||d.textTrack2)}var p1=(function(){function d(t){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var s=d.prototype;return s.setStreamController=function(t){this.streamController=t},s.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},s.registerListeners=function(){var t=this.hls;t.on(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(x.MANIFEST_PARSED,this.onManifestParsed,this),t.on(x.BUFFER_CODECS,this.onBufferCodecs,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListener=function(){var t=this.hls;t.off(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(x.MANIFEST_PARSED,this.onManifestParsed,this),t.off(x.BUFFER_CODECS,this.onBufferCodecs,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this)},s.onFpsDropLevelCapping=function(t,r){var a=this.hls.levels[r.droppedLevel];this.isLevelAllowed(a)&&this.restrictedLevels.push({bitrate:a.bitrate,height:a.height,width:a.width})},s.onMediaAttaching=function(t,r){this.media=r.media instanceof HTMLVideoElement?r.media:null,this.clientRect=null},s.onManifestParsed=function(t,r){var a=this.hls;this.restrictedLevels=[],this.firstLevel=r.firstLevel,a.config.capLevelToPlayerSize&&r.video&&this.startCapping()},s.onBufferCodecs=function(t,r){this.hls.config.capLevelToPlayerSize&&r.video&&this.startCapping()},s.onMediaDetaching=function(){this.stopCapping()},s.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var t=this.hls.levels;if(t.length){var r=this.hls;r.autoLevelCapping=this.getMaxLevel(t.length-1),r.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=r.autoLevelCapping}}},s.getMaxLevel=function(t){var r=this,a=this.hls.levels;if(!a.length)return-1;var o=a.filter(function(l,h){return r.isLevelAllowed(l)&&h<=t});return this.clientRect=null,d.getMaxLevelByMediaSize(o,this.mediaWidth,this.mediaHeight)},s.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},s.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},s.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,r={width:0,height:0};if(t){var a=t.getBoundingClientRect();r.width=a.width,r.height=a.height,r.width||r.height||(r.width=a.right-a.left||t.width||0,r.height=a.bottom-a.top||t.height||0)}return this.clientRect=r,r},s.isLevelAllowed=function(t){return!this.restrictedLevels.some(function(r){return t.bitrate===r.bitrate&&t.width===r.width&&t.height===r.height})},d.getMaxLevelByMediaSize=function(t,r,a){if(t==null||!t.length)return-1;for(var o,l,h=t.length-1,u=0;u<t.length;u+=1){var f=t[u];if((f.width>=r||f.height>=a)&&(o=f,!(l=t[u+1])||o.width!==l.width||o.height!==l.height)){h=u;break}}return h},F(d,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch{}return t}}]),d})(),m1=(function(){function d(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}var s=d.prototype;return s.setStreamController=function(t){this.streamController=t},s.registerListeners=function(){this.hls.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this)},s.unregisterListeners=function(){this.hls.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this)},s.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},s.onMediaAttaching=function(t,r){var a=this.hls.config;if(a.capLevelOnFPSDrop){var o=r.media instanceof self.HTMLVideoElement?r.media:null;this.media=o,o&&typeof o.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),a.fpsDroppedMonitoringPeriod)}},s.checkFPS=function(t,r,a){var o=performance.now();if(r){if(this.lastTime){var l=o-this.lastTime,h=a-this.lastDroppedFrames,u=r-this.lastDecodedFrames,f=1e3*h/l,p=this.hls;if(p.trigger(x.FPS_DROP,{currentDropped:h,currentDecoded:u,totalDroppedFrames:a}),f>0&&h>p.config.fpsDroppedMonitoringThreshold*u){var v=p.currentLevel;G.warn("drop FPS ratio greater than max allowed value for currentLevel: "+v),v>0&&(p.autoLevelCapping===-1||p.autoLevelCapping>=v)&&(v-=1,p.trigger(x.FPS_DROP_LEVEL_CAPPING,{level:v,droppedLevel:p.currentLevel}),p.autoLevelCapping=v,this.streamController.nextLevelSwitch())}}this.lastTime=o,this.lastDroppedFrames=a,this.lastDecodedFrames=r}},s.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var r=t.getVideoPlaybackQuality();this.checkFPS(t,r.totalVideoFrames,r.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},d})(),zn="[eme]",Yg=(function(){function d(t){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=d.CDMCleanupPromise?[d.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=G.debug.bind(G,zn),this.log=G.log.bind(G,zn),this.warn=G.warn.bind(G,zn),this.error=G.error.bind(G,zn),this.hls=t,this.config=t.config,this.registerListeners()}var s=d.prototype;return s.destroy=function(){this.unregisterListeners(),this.onMediaDetached();var t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null},s.registerListeners=function(){this.hls.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(x.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(x.MANIFEST_LOADED,this.onManifestLoaded,this)},s.unregisterListeners=function(){this.hls.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(x.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(x.MANIFEST_LOADED,this.onManifestLoaded,this)},s.getLicenseServerUrl=function(t){var r=this.config,a=r.drmSystems,o=r.widevineLicenseUrl,l=a[t];if(l)return l.licenseUrl;if(t===$e.WIDEVINE&&o)return o;throw new Error('no license server URL configured for key-system "'+t+'"')},s.getServerCertificateUrl=function(t){var r=this.config.drmSystems[t];if(r)return r.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+t+'"]')},s.attemptKeySystemAccess=function(t){var r=this,a=this.hls.levels,o=function(u,f,p){return!!u&&p.indexOf(u)===f},l=a.map(function(u){return u.audioCodec}).filter(o),h=a.map(function(u){return u.videoCodec}).filter(o);return l.length+h.length===0&&h.push("avc1.42e01e"),new Promise(function(u,f){(function p(v){var w=v.shift();r.getMediaKeysPromise(w,l,h).then(function(C){return u({keySystem:w,mediaKeys:C})}).catch(function(C){v.length?p(v):f(C instanceof Xt?C:new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_ACCESS,error:C,fatal:!0},C.message))})})(t)})},s.requestMediaKeySystemAccess=function(t,r){var a=this.config.requestMediaKeySystemAccessFunc;if(typeof a!="function"){var o="Configured requestMediaKeySystemAccess is not a function "+a;return uu===null&&self.location.protocol==="http:"&&(o="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(o))}return a(t,r)},s.getMediaKeysPromise=function(t,r,a){var o=this,l=(function(p,v,w,C){var k;switch(p){case $e.FAIRPLAY:k=["cenc","sinf"];break;case $e.WIDEVINE:case $e.PLAYREADY:k=["cenc"];break;case $e.CLEARKEY:k=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+p)}return(function(I,D,B,T){return[{initDataTypes:I,persistentState:T.persistentState||"not-allowed",distinctiveIdentifier:T.distinctiveIdentifier||"not-allowed",sessionTypes:T.sessionTypes||[T.sessionType||"temporary"],audioCapabilities:D.map(function(U){return{contentType:'audio/mp4; codecs="'+U+'"',robustness:T.audioRobustness||"",encryptionScheme:T.audioEncryptionScheme||null}}),videoCapabilities:B.map(function(U){return{contentType:'video/mp4; codecs="'+U+'"',robustness:T.videoRobustness||"",encryptionScheme:T.videoEncryptionScheme||null}})}]})(k,v,w,C)})(t,r,a,this.config.drmSystemOptions),h=this.keySystemAccessPromises[t],u=h?.keySystemAccess;if(!u){this.log('Requesting encrypted media "'+t+'" key-system access with config: '+JSON.stringify(l)),u=this.requestMediaKeySystemAccess(t,l);var f=this.keySystemAccessPromises[t]={keySystemAccess:u};return u.catch(function(p){o.log('Failed to obtain access to key-system "'+t+'": '+p)}),u.then(function(p){o.log('Access for key-system "'+p.keySystem+'" obtained');var v=o.fetchServerCertificate(t);return o.log('Create media-keys for "'+t+'"'),f.mediaKeys=p.createMediaKeys().then(function(w){return o.log('Media-keys created for "'+t+'"'),v.then(function(C){return C?o.setMediaKeysServerCertificate(w,t,C):w})}),f.mediaKeys.catch(function(w){o.error('Failed to create media-keys for "'+t+'"}: '+w)}),f.mediaKeys})}return u.then(function(){return h.mediaKeys})},s.createMediaKeySessionContext=function(t){var r=t.decryptdata,a=t.keySystem,o=t.mediaKeys;this.log('Creating key-system session "'+a+'" keyId: '+yr(r.keyId||[]));var l={decryptdata:r,keySystem:a,mediaKeys:o,mediaKeysSession:o.createSession(),keyStatus:"status-pending"};return this.mediaKeySessions.push(l),l},s.renewKeySession=function(t){var r=t.decryptdata;if(r.pssh){var a=this.createMediaKeySessionContext(t),o=this.getKeyIdString(r);this.keyIdToKeySessionPromise[o]=this.generateRequestWithPreferredKeySession(a,"cenc",r.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)},s.getKeyIdString=function(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(t.keyId===null)throw new Error("keyId is null");return yr(t.keyId)},s.updateKeySession=function(t,r){var a,o=t.mediaKeysSession;return this.log('Updating key-session "'+o.sessionId+'" for keyID '+yr(((a=t.decryptdata)==null?void 0:a.keyId)||[])+`
30
- } (data length: `+(r&&r.byteLength)+")"),o.update(r)},s.selectKeySystemFormat=function(t){var r=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+t.sn+" "+t.type+": "+t.level+") key formats "+r.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(r)),this.keyFormatPromise},s.getKeyFormatPromise=function(t){var r=this;return new Promise(function(a,o){var l=Xs(r.config),h=t.map(cu).filter(function(u){return!!u&&l.indexOf(u)!==-1});return r.getKeySystemSelectionPromise(h).then(function(u){var f=u.keySystem,p=hu(f);p?a(p):o(new Error('Unable to find format for key-system "'+f+'"'))}).catch(o)})},s.loadKey=function(t){var r=this,a=t.keyInfo.decryptdata,o=this.getKeyIdString(a),l="(keyId: "+o+' format: "'+a.keyFormat+'" method: '+a.method+" uri: "+a.uri+")";this.log("Starting session for key "+l);var h=this.keyIdToKeySessionPromise[o];return h||(h=this.keyIdToKeySessionPromise[o]=this.getKeySystemForKeyPromise(a).then(function(u){var f=u.keySystem,p=u.mediaKeys;return r.throwIfDestroyed(),r.log("Handle encrypted media sn: "+t.frag.sn+" "+t.frag.type+": "+t.frag.level+" using key "+l),r.attemptSetMediaKeys(f,p).then(function(){r.throwIfDestroyed();var v=r.createMediaKeySessionContext({keySystem:f,mediaKeys:p,decryptdata:a});return r.generateRequestWithPreferredKeySession(v,"cenc",a.pssh,"playlist-key")})})).catch(function(u){return r.handleError(u)}),h},s.throwIfDestroyed=function(t){if(!this.hls)throw new Error("invalid state")},s.handleError=function(t){this.hls&&(this.error(t.message),t instanceof Xt?this.hls.trigger(x.ERROR,t.data):this.hls.trigger(x.ERROR,{type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))},s.getKeySystemForKeyPromise=function(t){var r=this.getKeyIdString(t),a=this.keyIdToKeySessionPromise[r];if(!a){var o=cu(t.keyFormat),l=o?[o]:Xs(this.config);return this.attemptKeySystemAccess(l)}return a},s.getKeySystemSelectionPromise=function(t){if(t.length||(t=Xs(this.config)),t.length===0)throw new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(t)},s._onMediaEncrypted=function(t){var r=this,a=t.initDataType,o=t.initData;if(this.debug('"'+t.type+'" event: init data type: "'+a+'"'),o!==null){var l,h;if(a==="sinf"&&this.config.drmSystems[$e.FAIRPLAY]){var u=yt(new Uint8Array(o));try{var f=ii(JSON.parse(u).sinf),p=yu(new Uint8Array(f));if(!p)return;l=p.subarray(8,24),h=$e.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{var v=(function(U){if(!(U instanceof ArrayBuffer)||U.byteLength<32)return null;var M={version:0,systemId:"",kids:null,data:null},H=new DataView(U),V=H.getUint32(0);if(U.byteLength!==V&&V>44||H.getUint32(4)!==1886614376||(M.version=H.getUint32(8)>>>24,M.version>1))return null;M.systemId=yr(new Uint8Array(U,12,16));var W=H.getUint32(28);if(M.version===0){if(V-32<W)return null;M.data=new Uint8Array(U,32,W)}else if(M.version===1){M.kids=[];for(var $=0;$<W;$++)M.kids.push(new Uint8Array(U,32+16*$,16))}return M})(o);if(v===null)return;v.version===0&&v.systemId===du&&v.data&&(l=v.data.subarray(8,24)),h=(function(U){if(U===du)return $e.WIDEVINE})(v.systemId)}if(h&&l){for(var w=yr(l),C=this.keyIdToKeySessionPromise,k=this.mediaKeySessions,I=C[w],D=function(){var U=k[B],M=U.decryptdata;if(M.pssh||!M.keyId)return"continue";var H=yr(M.keyId);return w===H||M.uri.replace(/-/g,"").indexOf(w)!==-1?(I=C[H],delete C[H],M.pssh=new Uint8Array(o),M.keyId=l,I=C[w]=I.then(function(){return r.generateRequestWithPreferredKeySession(U,a,o,"encrypted-event-key-match")}),"break"):void 0},B=0;B<k.length;B++){var T=D();if(T!=="continue"&&T==="break")break}I||(I=C[w]=this.getKeySystemSelectionPromise([h]).then(function(U){var M,H=U.keySystem,V=U.mediaKeys;r.throwIfDestroyed();var W=new Zs("ISO-23001-7",w,(M=hu(H))!=null?M:"");return W.pssh=new Uint8Array(o),W.keyId=l,r.attemptSetMediaKeys(H,V).then(function(){r.throwIfDestroyed();var $=r.createMediaKeySessionContext({decryptdata:W,keySystem:H,mediaKeys:V});return r.generateRequestWithPreferredKeySession($,a,o,"encrypted-event-no-match")})})),I.catch(function(U){return r.handleError(U)})}}},s._onWaitingForKey=function(t){this.log('"'+t.type+'" event')},s.attemptSetMediaKeys=function(t,r){var a=this,o=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+t+'"');var l=Promise.all(o).then(function(){if(!a.media)throw new Error("Attempted to set mediaKeys without media element attached");return a.media.setMediaKeys(r)});return this.setMediaKeysQueue.push(l),l.then(function(){a.log('Media-keys set for "'+t+'"'),o.push(l),a.setMediaKeysQueue=a.setMediaKeysQueue.filter(function(h){return o.indexOf(h)===-1})})},s.generateRequestWithPreferredKeySession=function(t,r,a,o){var l,h,u=this,f=(l=this.config.drmSystems)==null||(h=l[t.keySystem])==null?void 0:h.generateRequest;if(f)try{var p=f.call(this.hls,r,a,t);if(!p)throw new Error("Invalid response from configured generateRequest filter");r=p.initDataType,a=t.decryptdata.pssh=p.initData?new Uint8Array(p.initData):null}catch(I){var v;if(this.warn(I.message),(v=this.hls)!=null&&v.config.debug)throw I}if(a===null)return this.log('Skipping key-session request for "'+o+'" (no initData)'),Promise.resolve(t);var w=this.getKeyIdString(t.decryptdata);this.log('Generating key-session request for "'+o+'": '+w+" (init data type: "+r+" length: "+(a?a.byteLength:null)+")");var C=new Gn;t.mediaKeysSession.onmessage=function(I){var D=t.mediaKeysSession;if(D){var B=I.messageType,T=I.message;u.log('"'+B+'" message event for session "'+D.sessionId+'" message size: '+T.byteLength),B==="license-request"||B==="license-renewal"?u.renewLicense(t,T).catch(function(U){u.handleError(U),C.emit("error",U)}):B==="license-release"?t.keySystem===$e.FAIRPLAY&&(u.updateKeySession(t,qr("acknowledged")),u.removeSession(t)):u.warn('unhandled media key message type "'+B+'"')}else C.emit("error",new Error("invalid state"))},t.mediaKeysSession.onkeystatuseschange=function(I){if(t.mediaKeysSession){u.onKeyStatusChange(t);var D=t.keyStatus;C.emit("keyStatus",D),D==="expired"&&(u.warn(t.keySystem+" expired for key "+w),u.renewKeySession(t))}else C.emit("error",new Error("invalid state"))};var k=new Promise(function(I,D){C.on("error",D),C.on("keyStatus",function(B){B.startsWith("usable")?I():B==="output-restricted"?D(new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):B==="internal-error"?D(new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+B+'"')):B==="expired"?D(new Error("key expired while generating request")):u.warn('unhandled key status change "'+B+'"')})});return t.mediaKeysSession.generateRequest(r,a).then(function(){var I;u.log('Request generated for key-session "'+((I=t.mediaKeysSession)==null?void 0:I.sessionId)+'" keyId: '+w)}).catch(function(I){throw new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_SESSION,error:I,fatal:!1},"Error generating key-session request: "+I)}).then(function(){return k}).catch(function(I){throw C.removeAllListeners(),u.removeSession(t),I}).then(function(){return C.removeAllListeners(),t})},s.onKeyStatusChange=function(t){var r=this;t.mediaKeysSession.keyStatuses.forEach(function(a,o){r.log('key status change "'+a+'" for keyStatuses keyId: '+yr("buffer"in o?new Uint8Array(o.buffer,o.byteOffset,o.byteLength):new Uint8Array(o))+" session keyId: "+yr(new Uint8Array(t.decryptdata.keyId||[]))+" uri: "+t.decryptdata.uri),t.keyStatus=a})},s.fetchServerCertificate=function(t){var r=this.config,a=new r.loader(r),o=this.getServerCertificateUrl(t);return o?(this.log('Fetching serverCertificate for "'+t+'"'),new Promise(function(l,h){var u={responseType:"arraybuffer",url:o},f=r.certLoadPolicy.default,p={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};a.load(u,p,{onSuccess:function(v,w,C,k){l(v.data)},onError:function(v,w,C,k){h(new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:C,response:E({url:u.url,data:void 0},v)},'"'+t+'" certificate request failed ('+o+"). Status: "+v.code+" ("+v.text+")"))},onTimeout:function(v,w,C){h(new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:C,response:{url:u.url,data:void 0}},'"'+t+'" certificate request timed out ('+o+")"))},onAbort:function(v,w,C){h(new Error("aborted"))}})})):Promise.resolve()},s.setMediaKeysServerCertificate=function(t,r,a){var o=this;return new Promise(function(l,h){t.setServerCertificate(a).then(function(u){o.log("setServerCertificate "+(u?"success":"not supported by CDM")+" ("+a?.byteLength+') on "'+r+'"'),l(t)}).catch(function(u){h(new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:u,fatal:!0},u.message))})})},s.renewLicense=function(t,r){var a=this;return this.requestLicense(t,new Uint8Array(r)).then(function(o){return a.updateKeySession(t,new Uint8Array(o)).catch(function(l){throw new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:l,fatal:!0},l.message)})})},s.setupLicenseXHR=function(t,r,a,o){var l=this,h=this.config.licenseXhrSetup;return h?Promise.resolve().then(function(){if(!a.decryptdata)throw new Error("Key removed");return h.call(l.hls,t,r,a,o)}).catch(function(u){if(!a.decryptdata)throw u;return t.open("POST",r,!0),h.call(l.hls,t,r,a,o)}).then(function(u){return t.readyState||t.open("POST",r,!0),{xhr:t,licenseChallenge:u||o}}):(t.open("POST",r,!0),Promise.resolve({xhr:t,licenseChallenge:o}))},s.requestLicense=function(t,r){var a=this,o=this.config.keyLoadPolicy.default;return new Promise(function(l,h){var u=a.getLicenseServerUrl(t.keySystem);a.log("Sending license request to URL: "+u);var f=new XMLHttpRequest;f.responseType="arraybuffer",f.onreadystatechange=function(){if(!a.hls||!t.mediaKeysSession)return h(new Error("invalid state"));if(f.readyState===4)if(f.status===200){a._requestLicenseFailureCount=0;var p=f.response;a.log("License received "+(p instanceof ArrayBuffer?p.byteLength:p));var v=a.config.licenseResponseCallback;if(v)try{p=v.call(a.hls,f,u,t)}catch(I){a.error(I)}l(p)}else{var w=o.errorRetry,C=w?w.maxNumRetry:0;if(a._requestLicenseFailureCount++,a._requestLicenseFailureCount>C||f.status>=400&&f.status<500)h(new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:f,response:{url:u,data:void 0,code:f.status,text:f.statusText}},"License Request XHR failed ("+u+"). Status: "+f.status+" ("+f.statusText+")"));else{var k=C-a._requestLicenseFailureCount+1;a.warn("Retrying license request, "+k+" attempts left"),a.requestLicense(t,r).then(l,h)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=f,a.setupLicenseXHR(f,u,t,r).then(function(p){var v=p.xhr,w=p.licenseChallenge;v.send(w)})})},s.onMediaAttached=function(t,r){if(this.config.emeEnabled){var a=r.media;this.media=a,a.addEventListener("encrypted",this.onMediaEncrypted),a.addEventListener("waitingforkey",this.onWaitingForKey)}},s.onMediaDetached=function(){var t=this,r=this.media,a=this.mediaKeySessions;r&&(r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Zs.clearKeyUriToKeyIdMap();var o=a.length;d.CDMCleanupPromise=Promise.all(a.map(function(l){return t.removeSession(l)}).concat(r?.setMediaKeys(null).catch(function(l){t.log("Could not clear media keys: "+l+". media.src: "+r?.src)}))).then(function(){o&&(t.log("finished closing key sessions and clearing media keys"),a.length=0)}).catch(function(l){t.log("Could not close sessions and clear media keys: "+l+". media.src: "+r?.src)})},s.onManifestLoading=function(){this.keyFormatPromise=null},s.onManifestLoaded=function(t,r){var a=r.sessionKeys;if(a&&this.config.emeEnabled&&!this.keyFormatPromise){var o=a.reduce(function(l,h){return l.indexOf(h.keyFormat)===-1&&l.push(h.keyFormat),l},[]);this.log("Selecting key-system from session-keys "+o.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(o)}},s.removeSession=function(t){var r=this,a=t.mediaKeysSession,o=t.licenseXhr;if(a){this.log("Remove licenses and keys and close session "+a.sessionId),a.onmessage=null,a.onkeystatuseschange=null,o&&o.readyState!==XMLHttpRequest.DONE&&o.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;var l=this.mediaKeySessions.indexOf(t);return l>-1&&this.mediaKeySessions.splice(l,1),a.remove().catch(function(h){r.log("Could not remove session: "+h)}).then(function(){return a.close()}).catch(function(h){r.log("Could not close session: "+h)})}},d})();Yg.CDMCleanupPromise=void 0;var Xt=(function(d){function s(t,r){var a;return(a=d.call(this,r)||this).data=void 0,t.error||(t.error=new Error(r)),a.data=t,t.err=t.error,a}return X(s,d),s})(ce(Error)),v1="m",qn="a",Gl="v",Yl="av",Kg="i",A1="tt",b1=(function(){function d(t){var r=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(l){try{r.apply(l,{ot:v1,su:!r.initialized})}catch(h){G.warn("Could not generate manifest CMCD data.",h)}},this.applyFragmentData=function(l){try{var h=l.frag,u=r.hls.levels[h.level],f=r.getObjectType(h),p={d:1e3*h.duration,ot:f};f!==Gl&&f!==qn&&f!=Yl||(p.br=u.bitrate/1e3,p.tb=r.getTopBandwidth(f)/1e3,p.bl=r.getBufferLength(f)),r.apply(l,p)}catch(v){G.warn("Could not generate segment CMCD data.",v)}},this.hls=t;var a=this.config=t.config,o=a.cmcd;o!=null&&(a.pLoader=this.createPlaylistLoader(),a.fLoader=this.createFragmentLoader(),this.sid=o.sessionId||d.uuid(),this.cid=o.contentId,this.useHeaders=o.useHeaders===!0,this.registerListeners())}var s=d.prototype;return s.registerListeners=function(){var t=this.hls;t.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(x.MEDIA_DETACHED,this.onMediaDetached,this),t.on(x.BUFFER_CREATED,this.onBufferCreated,this)},s.unregisterListeners=function(){var t=this.hls;t.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(x.MEDIA_DETACHED,this.onMediaDetached,this),t.off(x.BUFFER_CREATED,this.onBufferCreated,this)},s.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},s.onMediaAttached=function(t,r){this.media=r.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},s.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},s.onBufferCreated=function(t,r){var a,o;this.audioBuffer=(a=r.tracks.audio)==null?void 0:a.buffer,this.videoBuffer=(o=r.tracks.video)==null?void 0:o.buffer},s.createData=function(){var t;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},s.apply=function(t,r){r===void 0&&(r={}),Y(r,this.createData());var a=r.ot===Kg||r.ot===Gl||r.ot===Yl;if(this.starved&&a&&(r.bs=!0,r.su=!0,this.starved=!1),r.su??(r.su=this.buffering),this.useHeaders){var o=d.toHeaders(r);if(!Object.keys(o).length)return;t.headers||(t.headers={}),Y(t.headers,o)}else{var l=d.toQuery(r);if(!l)return;t.url=d.appendQueryToUri(t.url,l)}},s.getObjectType=function(t){var r=t.type;return r==="subtitle"?A1:t.sn==="initSegment"?Kg:r==="audio"?qn:r==="main"?this.hls.audioTracks.length?Gl:Yl:void 0},s.getTopBandwidth=function(t){var r,a=0,o=this.hls;if(t===qn)r=o.audioTracks;else{var l=o.maxAutoLevel,h=l>-1?l+1:o.levels.length;r=o.levels.slice(0,h)}for(var u,f=xe(r);!(u=f()).done;){var p=u.value;p.bitrate>a&&(a=p.bitrate)}return a>0?a:NaN},s.getBufferLength=function(t){var r=this.hls.media,a=t===qn?this.audioBuffer:this.videoBuffer;return a&&r?1e3*ct.bufferInfo(a,r.currentTime,this.config.maxBufferHole).len:NaN},s.createPlaylistLoader=function(){var t=this.config.pLoader,r=this.applyPlaylistData,a=t||this.config.loader;return(function(){function o(h){this.loader=void 0,this.loader=new a(h)}var l=o.prototype;return l.destroy=function(){this.loader.destroy()},l.abort=function(){this.loader.abort()},l.load=function(h,u,f){r(h),this.loader.load(h,u,f)},F(o,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),o})()},s.createFragmentLoader=function(){var t=this.config.fLoader,r=this.applyFragmentData,a=t||this.config.loader;return(function(){function o(h){this.loader=void 0,this.loader=new a(h)}var l=o.prototype;return l.destroy=function(){this.loader.destroy()},l.abort=function(){this.loader.abort()},l.load=function(h,u,f){r(h),this.loader.load(h,u,f)},F(o,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),o})()},d.uuid=function(){var t=URL.createObjectURL(new Blob),r=t.toString();return URL.revokeObjectURL(t),r.slice(r.lastIndexOf("/")+1)},d.serialize=function(t){for(var r,a=[],o=function(I){return!Number.isNaN(I)&&I!=null&&I!==""&&I!==!1},l=function(I){return Math.round(I)},h=function(I){return 100*l(I/100)},u={br:l,d:l,bl:h,dl:h,mtp:h,nor:function(I){return encodeURIComponent(I)},rtp:h,tb:l},f=xe(Object.keys(t||{}).sort());!(r=f()).done;){var p=r.value,v=t[p];if(o(v)&&!(p==="v"&&v===1||p=="pr"&&v===1)){var w=u[p];w&&(v=w(v));var C=typeof v,k=void 0;k=p==="ot"||p==="sf"||p==="st"?p+"="+v:C==="boolean"?p:C==="number"?p+"="+v:p+"="+JSON.stringify(v),a.push(k)}}return a.join(",")},d.toHeaders=function(t){for(var r={},a=["Object","Request","Session","Status"],o=[{},{},{},{}],l={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},h=0,u=Object.keys(t);h<u.length;h++){var f=u[h];o[l[f]!=null?l[f]:1][f]=t[f]}for(var p=0;p<o.length;p++){var v=d.serialize(o[p]);v&&(r["CMCD-"+a[p]]=v)}return r},d.toQuery=function(t){return"CMCD="+encodeURIComponent(d.serialize(t))},d.appendQueryToUri=function(t,r){if(!r)return t;var a=t.includes("?")?"&":"?";return""+t+a+r},d})(),y1=(function(){function d(t){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=t,this.log=G.log.bind(G,"[content-steering]:"),this.registerListeners()}var s=d.prototype;return s.registerListeners=function(){var t=this.hls;t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(x.MANIFEST_PARSED,this.onManifestParsed,this),t.on(x.ERROR,this.onError,this)},s.unregisterListeners=function(){var t=this.hls;t&&(t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(x.MANIFEST_PARSED,this.onManifestParsed,this),t.off(x.ERROR,this.onError,this))},s.startLoad=function(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){var t=Math.max(1e3*this.timeToLoad-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,t)}else this.loadSteeringManifest(this.uri)},s.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)},s.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},s.removeLevel=function(t){var r=this.levels;r&&(this.levels=r.filter(function(a){return a!==t}))},s.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},s.onManifestLoaded=function(t,r){var a=r.contentSteering;a!==null&&(this.pathwayId=a.pathwayId,this.uri=a.uri,this.started&&this.startLoad())},s.onManifestParsed=function(t,r){this.audioTracks=r.audioTracks,this.subtitleTracks=r.subtitleTracks},s.onError=function(t,r){var a=r.errorAction;if(a?.action===Or&&a.flags===Mn){var o=this.pathwayPriority,l=this.pathwayId;this.penalizedPathways[l]||(this.penalizedPathways[l]=performance.now()),!o&&this.levels&&(o=this.levels.reduce(function(h,u){return h.indexOf(u.pathwayId)===-1&&h.push(u.pathwayId),h},[])),o&&o.length>1&&(this.updatePathwayPriority(o),a.resolved=this.pathwayId!==l)}},s.filterParsedLevels=function(t){this.levels=t;var r=this.getLevelsForPathway(this.pathwayId);if(r.length===0){var a=t[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+a+'"'),r=this.getLevelsForPathway(a),this.pathwayId=a}return r.length!==t.length?(this.log("Found "+r.length+"/"+t.length+' levels in Pathway "'+this.pathwayId+'"'),r):t},s.getLevelsForPathway=function(t){return this.levels===null?[]:this.levels.filter(function(r){return t===r.pathwayId})},s.updatePathwayPriority=function(t){var r;this.pathwayPriority=t;var a=this.penalizedPathways,o=performance.now();Object.keys(a).forEach(function(v){o-a[v]>3e5&&delete a[v]});for(var l=0;l<t.length;l++){var h=t[l];if(!a[h]){if(h===this.pathwayId)return;var u=this.hls.nextLoadLevel,f=this.hls.levels[u];if((r=this.getLevelsForPathway(h)).length>0){this.log('Setting Pathway to "'+h+'"'),this.pathwayId=h,this.hls.trigger(x.LEVELS_UPDATED,{levels:r});var p=this.hls.levels[u];f&&p&&this.levels&&(p.attrs["STABLE-VARIANT-ID"]!==f.attrs["STABLE-VARIANT-ID"]&&p.bitrate!==f.bitrate&&this.log("Unstable Pathways change from bitrate "+f.bitrate+" to "+p.bitrate),this.hls.nextLoadLevel=u);break}}}},s.clonePathways=function(t){var r=this,a=this.levels;if(a){var o={},l={};t.forEach(function(h){var u=h.ID,f=h["BASE-ID"],p=h["URI-REPLACEMENT"];if(!a.some(function(w){return w.pathwayId===u})){var v=r.getLevelsForPathway(f).map(function(w){var C=Y({},w);C.details=void 0,C.url=qg(w.uri,w.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",p);var k=new Ke(w.attrs);k["PATHWAY-ID"]=u;var I=k.AUDIO&&k.AUDIO+"_clone_"+u,D=k.SUBTITLES&&k.SUBTITLES+"_clone_"+u;I&&(o[k.AUDIO]=I,k.AUDIO=I),D&&(l[k.SUBTITLES]=D,k.SUBTITLES=D),C.attrs=k;var B=new Aa(C);return Fn(B,"audio",I),Fn(B,"text",D),B});a.push.apply(a,v),zg(r.audioTracks,o,p,u),zg(r.subtitleTracks,l,p,u)}})}},s.loadSteeringManifest=function(t){var r,a=this,o=this.hls.config,l=o.loader;this.loader&&this.loader.destroy(),this.loader=new l(o);try{r=new self.URL(t)}catch{this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+t);return}if(r.protocol!=="data:"){var h=0|(this.hls.bandwidthEstimate||o.abrEwmaDefaultEstimate);r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+h)}var u={responseType:"json",url:r.href},f=o.steeringManifestLoadPolicy.default,p=f.errorRetry||f.timeoutRetry||{},v={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:p.maxNumRetry||0,retryDelay:p.retryDelayMs||0,maxRetryDelay:p.maxRetryDelayMs||0};this.log("Requesting steering manifest: "+r),this.loader.load(u,v,{onSuccess:function(w,C,k,I){a.log('Loaded steering manifest: "'+r+'"');var D=w.data;if(D.VERSION===1){a.updated=performance.now(),a.timeToLoad=D.TTL;var B=D["RELOAD-URI"],T=D["PATHWAY-CLONES"],U=D["PATHWAY-PRIORITY"];if(B)try{a.uri=new self.URL(B,r).href}catch{a.enabled=!1,a.log("Failed to parse Steering Manifest RELOAD-URI: "+B);return}a.scheduleRefresh(a.uri||k.url),T&&a.clonePathways(T),U&&a.updatePathwayPriority(U)}else a.log("Steering VERSION "+D.VERSION+" not supported!")},onError:function(w,C,k,I){if(a.log("Error loading steering manifest: "+w.code+" "+w.text+" ("+C.url+")"),a.stopLoad(),w.code===410)return a.enabled=!1,void a.log("Steering manifest "+C.url+" no longer available");var D=1e3*a.timeToLoad;if(w.code!==429)a.scheduleRefresh(a.uri||C.url,D);else{var B=a.loader;if(typeof B?.getResponseHeader=="function"){var T=B.getResponseHeader("Retry-After");T&&(D=1e3*parseFloat(T))}a.log("Steering manifest "+C.url+" rate limited")}},onTimeout:function(w,C,k){a.log("Timeout loading steering manifest ("+C.url+")"),a.scheduleRefresh(a.uri||C.url)}})},s.scheduleRefresh=function(t,r){var a=this;r===void 0&&(r=1e3*this.timeToLoad),self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(function(){a.loadSteeringManifest(t)},r)},d})();function zg(d,s,t,r){d&&Object.keys(s).forEach(function(a){var o=d.filter(function(l){return l.groupId===a}).map(function(l){var h=Y({},l);return h.details=void 0,h.attrs=new Ke(h.attrs),h.url=h.attrs.URI=qg(l.url,l.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),h.groupId=h.attrs["GROUP-ID"]=s[a],h.attrs["PATHWAY-ID"]=r,h});d.push.apply(d,o)})}function qg(d,s,t,r){var a,o=r.HOST,l=r.PARAMS,h=r[t];s&&(a=h?.[s])&&(d=a);var u=new self.URL(d);return o&&!a&&(u.host=o),l&&Object.keys(l).sort().forEach(function(f){f&&u.searchParams.set(f,l[f])}),u.href}var w1=/^age:\s*[\d.]+\s*$/im,Vg=(function(){function d(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new vr,this.retryDelay=0}var s=d.prototype;return s.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},s.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,t.readyState!==4&&(this.stats.aborted=!0,t.abort()))},s.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},s.load=function(t,r,a){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=r,this.callbacks=a,this.loadInternal()},s.loadInternal=function(){var t=this,r=this.config,a=this.context;if(r){var o=this.loader=new self.XMLHttpRequest,l=this.stats;l.loading.first=0,l.loaded=0,l.aborted=!1;var h=this.xhrSetup;h?Promise.resolve().then(function(){if(!t.stats.aborted)return h(o,a.url)}).catch(function(u){return o.open("GET",a.url,!0),h(o,a.url)}).then(function(){t.stats.aborted||t.openAndSendXhr(o,a,r)}).catch(function(u){t.callbacks.onError({code:o.status,text:u.message},a,o,l)}):this.openAndSendXhr(o,a,r)}},s.openAndSendXhr=function(t,r,a){t.readyState||t.open("GET",r.url,!0);var o=this.context.headers,l=a.loadPolicy,h=l.maxTimeToFirstByteMs,u=l.maxLoadTimeMs;if(o)for(var f in o)t.setRequestHeader(f,o[f]);r.rangeEnd&&t.setRequestHeader("Range","bytes="+r.rangeStart+"-"+(r.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=r.responseType,self.clearTimeout(this.requestTimeout),a.timeout=h&&se(h)?h:u,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout),t.send()},s.readystatechange=function(){var t=this.context,r=this.loader,a=this.stats;if(t&&r){var o=r.readyState,l=this.config;if(!a.aborted&&o>=2&&(a.loading.first===0&&(a.loading.first=Math.max(self.performance.now(),a.loading.start),l.timeout!==l.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),l.timeout=l.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),l.loadPolicy.maxLoadTimeMs-(a.loading.first-a.loading.start)))),o===4)){self.clearTimeout(this.requestTimeout),r.onreadystatechange=null,r.onprogress=null;var h=r.status,u=r.responseType!=="text";if(h>=200&&h<300&&(u&&r.response||r.responseText!==null)){a.loading.end=Math.max(self.performance.now(),a.loading.first);var f=u?r.response:r.responseText;if(a.loaded=a.total=r.responseType==="arraybuffer"?f.byteLength:f.length,a.bwEstimate=8e3*a.total/(a.loading.end-a.loading.first),!this.callbacks)return;var p=this.callbacks.onProgress;if(p&&p(a,t,f,r),!this.callbacks)return;var v={url:r.responseURL,data:f,code:h};this.callbacks.onSuccess(v,a,t,r)}else{var w=l.loadPolicy.errorRetry;Rn(w,a.retry,!1,h)?this.retry(w):(G.error(h+" while loading "+t.url),this.callbacks.onError({code:h,text:r.statusText},t,r,a))}}}},s.loadtimeout=function(){var t,r=(t=this.config)==null?void 0:t.loadPolicy.timeoutRetry;if(Rn(r,this.stats.retry,!0))this.retry(r);else{G.warn("timeout while loading "+this.context.url);var a=this.callbacks;a&&(this.abortInternal(),a.onTimeout(this.stats,this.context,this.loader))}},s.retry=function(t){var r=this.context,a=this.stats;this.retryDelay=cl(t,a.retry),a.retry++,G.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+r.url+", retrying "+a.retry+"/"+t.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},s.loadprogress=function(t){var r=this.stats;r.loaded=t.loaded,t.lengthComputable&&(r.total=t.total)},s.getCacheAge=function(){var t=null;if(this.loader&&w1.test(this.loader.getAllResponseHeaders())){var r=this.loader.getResponseHeader("age");t=r?parseFloat(r):null}return t},s.getResponseHeader=function(t){return this.loader&&new RegExp("^"+t+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null},d})(),C1=/(\d+)-(\d+)\/(\d+)/,Wg=(function(){function d(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||E1,this.controller=new self.AbortController,this.stats=new vr}var s=d.prototype;return s.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},s.abortInternal=function(){var t=this.response;t!=null&&t.ok||(this.stats.aborted=!0,this.controller.abort())},s.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},s.load=function(t,r,a){var o=this,l=this.stats;if(l.loading.start)throw new Error("Loader can only be used once.");l.loading.start=self.performance.now();var h=(function(k,I){var D={method:"GET",mode:"cors",credentials:"same-origin",signal:I,headers:new self.Headers(Y({},k.headers))};return k.rangeEnd&&D.headers.set("Range","bytes="+k.rangeStart+"-"+String(k.rangeEnd-1)),D})(t,this.controller.signal),u=a.onProgress,f=t.responseType==="arraybuffer",p=f?"byteLength":"length",v=r.loadPolicy,w=v.maxTimeToFirstByteMs,C=v.maxLoadTimeMs;this.context=t,this.config=r,this.callbacks=a,this.request=this.fetchSetup(t,h),self.clearTimeout(this.requestTimeout),r.timeout=w&&se(w)?w:C,this.requestTimeout=self.setTimeout(function(){o.abortInternal(),a.onTimeout(l,t,o.response)},r.timeout),self.fetch(this.request).then(function(k){o.response=o.loader=k;var I=Math.max(self.performance.now(),l.loading.start);if(self.clearTimeout(o.requestTimeout),r.timeout=C,o.requestTimeout=self.setTimeout(function(){o.abortInternal(),a.onTimeout(l,t,o.response)},C-(I-l.loading.start)),!k.ok){var D=k.status,B=k.statusText;throw new k1(B||"fetch, bad network response",D,k)}return l.loading.first=I,l.total=(function(T){var U=T.get("Content-Range");if(U){var M=(function(V){var W=C1.exec(V);if(W)return parseInt(W[2])-parseInt(W[1])+1})(U);if(se(M))return M}var H=T.get("Content-Length");if(H)return parseInt(H)})(k.headers)||l.total,u&&se(r.highWaterMark)?o.loadProgressively(k,l,t,r.highWaterMark,u):f?k.arrayBuffer():t.responseType==="json"?k.json():k.text()}).then(function(k){var I=o.response;self.clearTimeout(o.requestTimeout),l.loading.end=Math.max(self.performance.now(),l.loading.first);var D=k[p];D&&(l.loaded=l.total=D);var B={url:I.url,data:k,code:I.status};u&&!se(r.highWaterMark)&&u(l,t,k,I),a.onSuccess(B,l,t,I)}).catch(function(k){if(self.clearTimeout(o.requestTimeout),!l.aborted){var I=k&&k.code||0,D=k?k.message:null;a.onError({code:I,text:D},t,k?k.details:null,l)}})},s.getCacheAge=function(){var t=null;if(this.response){var r=this.response.headers.get("age");t=r?parseFloat(r):null}return t},s.getResponseHeader=function(t){return this.response?this.response.headers.get(t):null},s.loadProgressively=function(t,r,a,o,l){o===void 0&&(o=0);var h=new Eg,u=t.body.getReader();return(function f(){return u.read().then(function(p){if(p.done)return h.dataLength&&l(r,a,h.flush(),t),Promise.resolve(new ArrayBuffer(0));var v=p.value,w=v.length;return r.loaded+=w,w<o||h.dataLength?(h.push(v),h.dataLength>=o&&l(r,a,h.flush(),t)):l(r,a,v,t),f()}).catch(function(){return Promise.reject()})})()},d})();function E1(d,s){return new self.Request(d.url,s)}var k1=(function(d){function s(t,r,a){var o;return(o=d.call(this,t)||this).code=void 0,o.details=void 0,o.code=r,o.details=a,o}return X(s,d),s})(ce(Error)),B1=/\s/,I1=E(E({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Vg,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Km,bufferController:jm,capLevelController:p1,errorController:cm,fpsController:m1,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:uu,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:{newCue:function(d,s,t,r){for(var a,o,l,h,u,f=[],p=self.VTTCue||self.TextTrackCue,v=0;v<r.rows.length;v++)if(l=!0,h=0,u="",!(a=r.rows[v]).isEmpty()){for(var w,C=0;C<a.chars.length;C++)B1.test(a.chars[C].uchar)&&l?h++:(u+=a.chars[C].uchar,l=!1);a.cueStartTime=s,s===t&&(t+=1e-4),h>=16?h--:h++;var k=Og(u.trim()),I=Pl(s,t,k);d!=null&&(w=d.cues)!=null&&w.getCueById(I)||((o=new p(s,t,k)).id=I,o.line=v+1,o.align="left",o.position=10+Math.min(80,10*Math.floor(8*h/32)),f.push(o))}return d&&f.length&&(f.sort(function(D,B){return D.line==="auto"||B.line==="auto"?0:D.line>8&&B.line>8?B.line-D.line:D.line-B.line}),f.forEach(function(D){return Nu(d,D)})),f}},enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:Wm,subtitleTrackController:Jm,timelineController:g1,audioStreamController:zm,audioTrackController:qm,emeController:Yg,cmcdController:b1,contentSteeringController:y1});function Kl(d){return d&&typeof d=="object"?Array.isArray(d)?d.map(Kl):Object.keys(d).reduce(function(s,t){return s[t]=Kl(d[t]),s},{}):d}function S1(d){var s=d.loader;s!==Wg&&s!==Vg?(G.log("[config]: Custom loader detected, cannot enable progressive streaming"),d.progressive=!1):(function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1})()&&(d.loader=Wg,d.progressive=!0,d.enableSoftwareAES=!0,G.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Xg=(function(){function d(t){t===void 0&&(t={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Gn,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,tr(t.debug||!1,"Hls instance");var r=this.config=(function(le,ie){if((ie.liveSyncDurationCount||ie.liveMaxLatencyDurationCount)&&(ie.liveSyncDuration||ie.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(ie.liveMaxLatencyDurationCount!==void 0&&(ie.liveSyncDurationCount===void 0||ie.liveMaxLatencyDurationCount<=ie.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(ie.liveMaxLatencyDuration!==void 0&&(ie.liveSyncDuration===void 0||ie.liveMaxLatencyDuration<=ie.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var me=Kl(le),we=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(ve){var Ae=(ve==="level"?"playlist":ve)+"LoadPolicy",Ie=ie[Ae]===void 0,fe=[];we.forEach(function(Pe){var Ue=ve+"Loading"+Pe,ze=ie[Ue];if(ze!==void 0&&Ie){fe.push(Ue);var je=me[Ae].default;switch(ie[Ae]={default:je},Pe){case"TimeOut":je.maxLoadTimeMs=ze,je.maxTimeToFirstByteMs=ze;break;case"MaxRetry":je.errorRetry.maxNumRetry=ze,je.timeoutRetry.maxNumRetry=ze;break;case"RetryDelay":je.errorRetry.retryDelayMs=ze,je.timeoutRetry.retryDelayMs=ze;break;case"MaxRetryTimeout":je.errorRetry.maxRetryDelayMs=ze,je.timeoutRetry.maxRetryDelayMs=ze}}}),fe.length&&G.warn('hls.js config: "'+fe.join('", "')+'" setting(s) are deprecated, use "'+Ae+'": '+JSON.stringify(ie[Ae]))}),E(E({},me),ie)})(d.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,r.progressive&&S1(r);var a=r.abrController,o=r.bufferController,l=r.capLevelController,h=r.errorController,u=r.fpsController,f=new h(this),p=this.abrController=new a(this),v=this.bufferController=new o(this),w=this.capLevelController=new l(this),C=new u(this),k=new em(this),I=new rm(this),D=r.contentSteeringController,B=D?new D(this):null,T=this.levelController=new dm(this,B),U=new hm(this),M=new gm(this.config),H=this.streamController=new Gm(this,U,M);w.setStreamController(H),C.setStreamController(H);var V=[k,T,H];B&&V.splice(1,0,B),this.networkControllers=V;var W=[p,v,w,C,I,U];this.audioTrackController=this.createController(r.audioTrackController,V);var $=r.audioStreamController;$&&V.push(new $(this,U,M)),this.subtitleTrackController=this.createController(r.subtitleTrackController,V);var J=r.subtitleStreamController;J&&V.push(new J(this,U,M)),this.createController(r.timelineController,W),M.emeController=this.emeController=this.createController(r.emeController,W),this.cmcdController=this.createController(r.cmcdController,W),this.latencyController=this.createController(im,W),this.coreComponents=W,V.push(f);var j=f.onErrorOut;typeof j=="function"&&this.on(x.ERROR,j,f)}d.isSupported=function(){return(function(){var t=xn();if(!t)return!1;var r=ig(),a=t&&typeof t.isTypeSupported=="function"&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),o=!r||r.prototype&&typeof r.prototype.appendBuffer=="function"&&typeof r.prototype.remove=="function";return!!a&&!!o})()};var s=d.prototype;return s.createController=function(t,r){if(t){var a=new t(this);return r&&r.push(a),a}return null},s.on=function(t,r,a){a===void 0&&(a=this),this._emitter.on(t,r,a)},s.once=function(t,r,a){a===void 0&&(a=this),this._emitter.once(t,r,a)},s.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},s.off=function(t,r,a,o){a===void 0&&(a=this),this._emitter.off(t,r,a,o)},s.listeners=function(t){return this._emitter.listeners(t)},s.emit=function(t,r,a){return this._emitter.emit(t,r,a)},s.trigger=function(t,r){if(this.config.debug)return this.emit(t,t,r);try{return this.emit(t,t,r)}catch(a){G.error("An internal error happened while handling event "+t+'. Error message: "'+a.message+'". Here is a stacktrace:',a),this.trigger(x.ERROR,{type:ue.OTHER_ERROR,details:q.INTERNAL_EXCEPTION,fatal:!1,event:t,error:a})}return!1},s.listenerCount=function(t){return this._emitter.listenerCount(t)},s.destroy=function(){G.log("destroy"),this.trigger(x.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(r){return r.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(r){return r.destroy()}),this.coreComponents.length=0;var t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null},s.attachMedia=function(t){G.log("attachMedia"),this._media=t,this.trigger(x.MEDIA_ATTACHING,{media:t})},s.detachMedia=function(){G.log("detachMedia"),this.trigger(x.MEDIA_DETACHING,void 0),this._media=null},s.loadSource=function(t){this.stopLoad();var r=this.media,a=this.url,o=this.url=Ge.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});G.log("loadSource:"+o),r&&a&&(a!==o||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(r)),this.trigger(x.MANIFEST_LOADING,{url:t})},s.startLoad=function(t){t===void 0&&(t=-1),G.log("startLoad("+t+")"),this.networkControllers.forEach(function(r){r.startLoad(t)})},s.stopLoad=function(){G.log("stopLoad"),this.networkControllers.forEach(function(t){t.stopLoad()})},s.swapAudioCodec=function(){G.log("swapAudioCodec"),this.streamController.swapAudioCodec()},s.recoverMediaError=function(){G.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},s.removeLevel=function(t,r){r===void 0&&(r=0),this.levelController.removeLevel(t,r)},F(d,[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){G.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){G.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){G.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){G.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){G.log("set startLevel:"+t),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var r=!!t;r!==this.config.capLevelToPlayerSize&&(r?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=r)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(G.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"ttfbEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(t){nl.indexOf(t)>-1&&(this._maxHdcpLevel=t)}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,r=this.config.minAutoBitrate;if(!t)return 0;for(var a=t.length,o=0;o<a;o++)if(t[o].maxBitrate>=r)return o;return 0}},{key:"maxAutoLevel",get:function(){var t,r=this.levels,a=this.autoLevelCapping,o=this.maxHdcpLevel;if(t=a===-1&&r&&r.length?r.length-1:a,o)for(var l=t;l--;){var h=r[l].attrs["HDCP-LEVEL"];if(h&&h<=o)return l}return t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var r=this.audioTrackController;r&&(r.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var r=this.subtitleTrackController;r&&(r.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},set:function(t){var r=this.subtitleTrackController;r&&(r.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.4.12"}},{key:"Events",get:function(){return x}},{key:"ErrorTypes",get:function(){return ue}},{key:"ErrorDetails",get:function(){return q}},{key:"DefaultConfig",get:function(){return d.defaultConfig?d.defaultConfig:I1},set:function(t){d.defaultConfig=t}}]),d})();return Xg.defaultConfig=void 0,Xg};typeof e=="object"&&typeof i<"u"?i.exports=m():typeof define=="function"&&define.amd?define(m):(g=typeof globalThis<"u"?globalThis:g||self).Hls=m()})(!1)})),G1=tf(),rf='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{position:var(--ran-select-host-position, relative);display:var(--ran-select-host-display, inline-block);cursor:var(--ran-select-host-cursor, pointer);height:var(--ran-select-host-height, 32px);outline:var(--ran-select-host-outline, 0);-webkit-tap-highlight-color:var(--ran-select-host-tap-highlight-color, transparent)}:host,:host(:focus),:host(:active){outline:var(--ran-select-host-focus-outline, 0);-webkit-tap-highlight-color:transparent}:host ::slotted(r-option){display:var(--ran-select-option-display, none)}:host([disabled]){cursor:var(--ran-select-host-disabled-cursor, not-allowed);pointer-events:var(--ran-select-host-disabled-pointer-events, all);opacity:var(--ran-select-host-disabled-opacity, .6)}:host(:not([disabled]):hover) .ran-select{cursor:var(--ran-select-host-hover-cursor, pointer)}:host(:not([disabled],[type="text"]):hover) .selection{border:var(--ran-select-selection-hover-border, 1px solid var(--ran-color-primary, #006bff))}:host(:not([disabled],[type="text"]):hover) .selection-search{cursor:var(--ran-select-selection-hover-search-cursor, pointer)}:host(:not([disabled],[type="text"]):hover) .selection-item{cursor:var(--ran-select-selection-hover-item-cursor, pointer);color:var(--ran-select-selection-hover-item-color, var(--ran-color-text-disabled, #bfbfbf))}:host([type="text"]) .selection{border:var(--ran-select-selection-text-border, none);background:var(--ran-select-selection-text-background, transparent)}:host([type="text"]) .icon{display:var(--ran-select-icon-text-display, none)}:host(:not([disabled],[type="text"]):focus) .selection{border:var(--ran-select-selection-focus-border, 1px solid var(--ran-color-primary, #006bff))}:host(:not([disabled],[type="text"]):focus) .selection-search{cursor:var(--ran-select-selection-focus-search-cursor, pointer)}:host(:not([disabled],[type="text"]):focus) .selection-item{cursor:var(--ran-select-selection-focus-item-cursor, pointer);color:var(--ran-select-selection-focus-item-color, var(--ran-color-text-disabled, #bfbfbf))}:host .selection-search{display:var(--ran-select-selection-search-display, none)}:host([showSearch]:not([disabled])) .selection-search{cursor:var(--ran-select-selection-search-visible-cursor, text);display:var(--ran-select-selection-search-visible-display, block)}:host([showSearch]:not([disabled])) .selection-item{cursor:var(--ran-select-selection-search-visible-item-cursor, pointer)}:host([showSearch]:not([disabled]):focus) .selection-search{display:var(--ran-select-selection-search-visible-display, block);cursor:var(--ran-select-selection-search-visible-cursor, text);opacity:var(--ran-select-selection-search-visible-opacity, 1)}.ran-select{width:var(--ran-select-root-width, 100%);height:var(--ran-select-root-height, 100%);font-size:var(--ran-select-root-font-size, 14px);box-sizing:var(--ran-select-root-box-sizing, border-box);margin:var(--ran-select-root-margin, 0);padding:var(--ran-select-root-padding, 0);color:var(--ran-select-root-color, var(--ran-color-text, rgba(0, 0, 0, .88)));line-height:var(--ran-select-root-line-height, 1.57142857);list-style:var(--ran-select-root-list-style, none);font-family:var(--ran-select-root-font-family, var(--ran-skin-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"));position:var(--ran-select-root-position, relative);display:var(--ran-select-root-display, inline-block)}.ran-select .selection{position:var(--ran-select-selection-position, relative);background-color:var(--ran-select-selection-background-color, var(--ran-color-bg-elevated, #ffffff));background-image:var(--ran-select-selection-background-image, none);border:var(--ran-select-selection-border, 1px solid var(--ran-color-border, #eaeaea));transition:var(--ran-select-selection-transition, none);width:var(--ran-select-selection-width, 100%);height:var(--ran-select-selection-height, 100%);padding:var(--ran-select-selection-padding, 0 11px);box-sizing:var(--ran-select-selection-box-sizing, border-box);margin:var(--ran-select-selection-margin, 0);color:var(--ran-select-selection-color, var(--ran-color-text, rgba(0, 0, 0, .88)));font-size:var(--ran-select-selection-font-size, 14px);line-height:var(--ran-select-selection-line-height, 1.57142857);list-style:var(--ran-select-selection-list-style, none);font-family:var(--ran-select-selection-font-family, inherit);display:var(--ran-select-selection-display, flex);border-radius:var(--ran-select-selection-border-radius, var(--ran-radius-sm, 6px))}.ran-select .selection-search{position:var(--ran-select-selection-search-position, absolute);opacity:var(--ran-select-selection-search-opacity, 0);top:var(--ran-select-selection-search-top, 0);left:var(--ran-select-selection-search-left, 0);height:var(--ran-select-selection-search-height, 100%);inset-inline-start:var(--ran-select-selection-search-inset-inline-start, 11px);inset-inline-end:var(--ran-select-selection-search-inset-inline-end, 11px);margin:var(--ran-select-selection-search-margin, 0);padding:var(--ran-select-selection-search-padding, 0);background:var(--ran-select-selection-search-background, transparent);border:var(--ran-select-selection-search-border, none);outline:var(--ran-select-selection-search-outline, none);appearance:var(--ran-select-selection-search-appearance, none);font-family:var(--ran-select-selection-search-font-family, inherit);cursor:var(--ran-select-selection-search-cursor, not-allowed)}.ran-select .selection-search::-webkit-search-cancel-button{display:var(--ran-select-selection-search-cancel-display, none);-webkit-appearance:var(--ran-select-selection-search-cancel-appearance, none)}.ran-select .selection-search::part(input){border:var(--ran-select-selection-search-input-border, none);padding:var(--ran-select-selection-search-input-padding, 0);height:100%;min-height:100%;box-sizing:border-box;outline:var(--ran-select-selection-search-input-outline, none)}.ran-select .selection-search::part(input):active{border:var(--ran-select-selection-search-input-active-border, none);padding:var(--ran-select-selection-search-input-active-padding, 0);height:var(--ran-select-selection-search-input-active-height, 100%);outline:var(--ran-select-selection-search-input-active-outline, none);border-color:var(--ran-select-selection-search-input-active-border-color, transparent);box-shadow:var(--ran-select-selection-search-input-active-box-shadow, none);border-right-width:var(--ran-select-selection-search-input-active-border-right-width, 0px)}.ran-select .selection-search::part(content){min-height:var(--ran-select-selection-search-input-content-min-height, 0)}.ran-select .selection-item{position:var(--ran-select-selection-item-position, absolute);top:var(--ran-select-selection-item-top, 0);left:var(--ran-select-selection-item-left, 12px);right:var(--ran-select-selection-item-right, 28px);margin:var(--ran-select-selection-item-margin, 0);padding:var(--ran-select-selection-item-padding, 0);background:var(--ran-select-selection-item-background, transparent);border:var(--ran-select-selection-item-border, none);outline:var(--ran-select-selection-item-outline, none);appearance:var(--ran-select-selection-item-appearance, none);font-family:var(--ran-select-selection-item-font-family, inherit);height:var(--ran-select-selection-item-height, 100%);display:var(--ran-select-selection-item-display, flex);align-items:var(--ran-select-selection-item-align-items, center);-webkit-user-select:var(--ran-select-selection-item-user-select, none);user-select:var(--ran-select-selection-item-user-select, none);overflow:var(--ran-select-selection-item-overflow, hidden);white-space:var(--ran-select-selection-item-white-space, nowrap);text-overflow:var(--ran-select-selection-item-text-overflow, ellipsis);cursor:var(--ran-select-selection-item-cursor, pointer)}.ran-select .selection-select{color:var(--ran-select-selection-select-color, var(--ran-color-text-disabled, rgba(0, 0, 0, .25)))}.ran-select .selection .icon{display:var(--ran-select-selection-icon-display, flex);align-items:var(--ran-select-selection-icon-align-items, center);color:var(--ran-select-selection-icon-color, var(--ran-color-text-disabled, rgba(0, 0, 0, .25)));font-style:var(--ran-select-selection-icon-font-style, normal);text-align:var(--ran-select-selection-icon-text-align, center);text-transform:var(--ran-select-selection-icon-text-transform, none);text-rendering:var(--ran-select-selection-icon-text-rendering, optimizeLegibility);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;position:var(--ran-select-selection-icon-position, absolute);top:var(--ran-select-selection-icon-top, 50%);inset-inline-start:var(--ran-select-selection-icon-inset-inline-start, auto);inset-inline-end:var(--ran-select-selection-icon-inset-inline-end, 8px);height:var(--ran-select-selection-icon-height, 16px);transform:var(--ran-select-selection-icon-transform, translateY(-50%));margin-top:var(--ran-select-selection-icon-margin-top, 0);font-size:var(--ran-select-selection-icon-font-size, 12px);pointer-events:var(--ran-select-selection-icon-pointer-events, none)}',af={success:!0,_identification:!0,data:`<svg viewBox="0 0 1024 1024" width="200" height="200" version="1.1"
28
+ `)}),p.flush()}var Ul="stpp.ttml.im1t",Pg=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Ug=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,g1={left:"start",center:"center",right:"end",start:"start",end:"end"};function Qg(d,s,t,r){var a=Ye(new Uint8Array(d),["mdat"]);if(a.length!==0){var o,l,h,u,f=a.map(function(v){return br(v)}),p=(o=s.baseTime,l=1,(h=s.timescale)===void 0&&(h=1),u===void 0&&(u=!1),Cl(o,l,1/h,u));try{f.forEach(function(v){return t((function(w,C){var k=new DOMParser().parseFromString(w,"text/xml").getElementsByTagName("tt")[0];if(!k)throw new Error("Invalid ttml");var I={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},D=Object.keys(I).reduce(function(H,V){return H[V]=k.getAttribute("ttp:"+V)||I[V],H},{}),B=k.getAttribute("xml:space")!=="preserve",T=Ng(Ql(k,"styling","style")),U=Ng(Ql(k,"layout","region")),M=Ql(k,"body","[begin]");return[].map.call(M,function(H){var V=Hg(H,B);if(!V||!H.hasAttribute("begin"))return null;var W=Hl(H.getAttribute("begin"),D),$=Hl(H.getAttribute("dur"),D),J=Hl(H.getAttribute("end"),D);if(W===null)throw Gg(H);if(J===null){if($===null)throw Gg(H);J=W+$}var j=new Ll(W-C,J-C,V);j.id=Pl(j.startTime,j.endTime,j.text);var le=(function(we,ve,Ae){var Ie="http://www.w3.org/ns/ttml#styling",fe=null,Pe=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],Ue=we!=null&&we.hasAttribute("style")?we.getAttribute("style"):null;return Ue&&Ae.hasOwnProperty(Ue)&&(fe=Ae[Ue]),Pe.reduce(function(ze,je){var mt=Nl(ve,Ie,je)||Nl(we,Ie,je)||Nl(fe,Ie,je);return mt&&(ze[je]=mt),ze},{})})(U[H.getAttribute("region")],T[H.getAttribute("style")],T),ie=le.textAlign;if(ie){var me=g1[ie];me&&(j.lineAlign=me),j.align=ie}return Y(j,le),j}).filter(function(H){return H!==null})})(v,p))})}catch(v){r(v)}}else r(new Error("Could not parse IMSC1 mdat"))}function Ql(d,s,t){var r=d.getElementsByTagName(s)[0];return r?[].slice.call(r.querySelectorAll(t)):[]}function Ng(d){return d.reduce(function(s,t){var r=t.getAttribute("xml:id");return r&&(s[r]=t),s},{})}function Hg(d,s){return[].slice.call(d.childNodes).reduce(function(t,r,a){var o;return r.nodeName==="br"&&a?t+`
29
+ `:(o=r.childNodes)!=null&&o.length?Hg(r,s):s?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function Nl(d,s,t){return d&&d.hasAttributeNS(s,t)?d.getAttributeNS(s,t):null}function Gg(d){return new Error("Could not parse ttml timestamp "+d)}function Hl(d,s){if(!d)return null;var t=Mg(d);return t===null&&(Pg.test(d)?t=(function(r,a){var o=Pg.exec(r),l=(0|o[4])+(0|o[5])/a.subFrameRate;return 3600*(0|o[1])+60*(0|o[2])+(0|o[3])+l/a.frameRate})(d,s):Ug.test(d)&&(t=(function(r,a){var o=Ug.exec(r),l=Number(o[1]);switch(o[2]){case"h":return 3600*l;case"m":return 60*l;case"ms":return 1e3*l;case"f":return l/a.frameRate;case"t":return l/a.tickRate}return l})(d,s))),t}var f1=(function(){function d(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var r=new Yn(this,"textTrack1"),a=new Yn(this,"textTrack2"),o=new Yn(this,"textTrack3"),l=new Yn(this,"textTrack4");this.cea608Parser1=new Rg(1,r,a),this.cea608Parser2=new Rg(3,o,l)}t.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(x.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(x.FRAG_LOADING,this.onFragLoading,this),t.on(x.FRAG_LOADED,this.onFragLoaded,this),t.on(x.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(x.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(x.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(x.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(x.BUFFER_FLUSHING,this.onBufferFlushing,this)}var s=d.prototype;return s.destroy=function(){var t=this.hls;t.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(x.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(x.FRAG_LOADING,this.onFragLoading,this),t.off(x.FRAG_LOADED,this.onFragLoaded,this),t.off(x.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(x.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(x.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(x.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(x.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},s.addCues=function(t,r,a,o,l){for(var h,u,f,p,v=!1,w=l.length;w--;){var C=l[w],k=(h=C[0],u=C[1],f=r,p=a,Math.min(u,p)-Math.max(h,f));if(k>=0&&(C[0]=Math.min(C[0],r),C[1]=Math.max(C[1],a),v=!0,k/(a-r)>.5))return}if(v||l.push([r,a]),this.config.renderTextTracksNatively){var I=this.captionsTracks[t];this.Cues.newCue(I,r,a,o)}else{var D=this.Cues.newCue(null,r,a,o);this.hls.trigger(x.CUES_PARSED,{type:"captions",cues:D,track:t})}},s.onInitPtsFound=function(t,r){var a=this,o=r.frag,l=r.id,h=r.initPTS,u=r.timescale,f=this.unparsedVttFrags;l==="main"&&(this.initPTS[o.cc]={baseTime:h,timescale:u}),f.length&&(this.unparsedVttFrags=[],f.forEach(function(p){a.onFragLoaded(x.FRAG_LOADED,p)}))},s.getExistingTrack=function(t){var r=this.media;if(r)for(var a=0;a<r.textTracks.length;a++){var o=r.textTracks[a];if(o[t])return o}return null},s.createCaptionsTrack=function(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)},s.createNativeTrack=function(t){if(!this.captionsTracks[t]){var r=this.captionsProperties,a=this.captionsTracks,o=this.media,l=r[t],h=l.label,u=l.languageCode,f=this.getExistingTrack(t);if(f)a[t]=f,Ii(a[t]),Qu(a[t],o);else{var p=this.createTextTrack("captions",h,u);p&&(p[t]=!0,a[t]=p)}}},s.createNonNativeTrack=function(t){if(!this.nonNativeCaptionsTracks[t]){var r=this.captionsProperties[t];if(r){var a={_id:t,label:r.label,kind:"captions",default:!!r.media&&!!r.media.default,closedCaptions:r.media};this.nonNativeCaptionsTracks[t]=a,this.hls.trigger(x.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[a]})}}},s.createTextTrack=function(t,r,a){var o=this.media;if(o)return o.addTextTrack(t,r,a)},s.onMediaAttaching=function(t,r){this.media=r.media,this._cleanTracks()},s.onMediaDetaching=function(){var t=this.captionsTracks;Object.keys(t).forEach(function(r){Ii(t[r]),delete t[r]}),this.nonNativeCaptionsTracks={}},s.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},s._cleanTracks=function(){var t=this.media;if(t){var r=t.textTracks;if(r)for(var a=0;a<r.length;a++)Ii(r[a])}},s.onSubtitleTracksUpdated=function(t,r){var a=this,o=r.subtitleTracks||[],l=o.some(function(f){return f.textCodec===Ul});if(this.config.enableWebVTT||l&&this.config.enableIMSC1){if(kg(this.tracks,o))return void(this.tracks=o);if(this.textTracks=[],this.tracks=o,this.config.renderTextTracksNatively){var h=this.media?this.media.textTracks:null;this.tracks.forEach(function(f,p){var v;if(h&&p<h.length){for(var w=null,C=0;C<h.length;C++)if(p1(h[C],f)){w=h[C];break}w&&(v=w)}if(v)Ii(v);else{var k=a._captionsOrSubtitlesFromCharacteristics(f);(v=a.createTextTrack(k,f.name,f.lang))&&(v.mode="disabled")}v&&(v.groupId=f.groupId,a.textTracks.push(v))})}else if(this.tracks.length){var u=this.tracks.map(function(f){return{label:f.name,kind:f.type.toLowerCase(),default:f.default,subtitleTrack:f}});this.hls.trigger(x.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:u})}}},s._captionsOrSubtitlesFromCharacteristics=function(t){if(t.attrs.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),a=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(r&&a)return"captions"}return"subtitles"},s.onManifestLoaded=function(t,r){var a=this;this.config.enableCEA708Captions&&r.captions&&r.captions.forEach(function(o){var l=/(?:CC|SERVICE)([1-4])/.exec(o.instreamId);if(l){var h="textTrack"+l[1],u=a.captionsProperties[h];u&&(u.label=o.name,o.lang&&(u.languageCode=o.lang),u.media=o)}})},s.closedCaptionsForLevel=function(t){var r=this.hls.levels[t.level];return r?.attrs["CLOSED-CAPTIONS"]},s.onFragLoading=function(t,r){var a=this.cea608Parser1,o=this.cea608Parser2,l=this.lastSn,h=this.lastPartIndex;if(this.enabled&&a&&o&&r.frag.type===Je){var u,f,p=r.frag.sn,v=(u=r==null||(f=r.part)==null?void 0:f.index)!=null?u:-1;p===l+1||p===l&&v===h+1||(a.reset(),o.reset()),this.lastSn=p,this.lastPartIndex=v}},s.onFragLoaded=function(t,r){var a=r.frag,o=r.payload;if(a.type===Wr)if(o.byteLength){var l=a.decryptdata,h="stats"in r;if(l==null||!l.encrypted||h){var u=this.tracks[a.level],f=this.vttCCs;f[a.cc]||(f[a.cc]={start:a.start,prevCC:this.prevCC,new:!0},this.prevCC=a.cc),u&&u.textCodec===Ul?this._parseIMSC1(a,o):this._parseVTTs(r)}}else this.hls.trigger(x.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:a,error:new Error("Empty subtitle payload")})},s._parseIMSC1=function(t,r){var a=this,o=this.hls;Qg(r,this.initPTS[t.cc],function(l){a._appendCues(l,t.level),o.trigger(x.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},function(l){G.log("Failed to parse IMSC1: "+l),o.trigger(x.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:l})})},s._parseVTTs=function(t){var r,a=this,o=t.frag,l=t.payload,h=this.initPTS,u=this.unparsedVttFrags,f=h.length-1;if(h[o.cc]||f!==-1){var p=this.hls;u1((r=o.initSegment)!=null&&r.data?ni(o.initSegment.data,new Uint8Array(l)):l,this.initPTS[o.cc],this.vttCCs,o.cc,o.start,function(v){a._appendCues(v,o.level),p.trigger(x.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:o})},function(v){var w=v.message==="Missing initPTS for VTT MPEGTS";w?u.push(t):a._fallbackToIMSC1(o,l),G.log("Failed to parse VTT cue: "+v),w&&f>o.cc||p.trigger(x.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:o,error:v})})}else u.push(t)},s._fallbackToIMSC1=function(t,r){var a=this,o=this.tracks[t.level];o.textCodec||Qg(r,this.initPTS[t.cc],function(){o.textCodec=Ul,a._parseIMSC1(t,r)},function(){o.textCodec="wvtt"})},s._appendCues=function(t,r){var a=this.hls;if(this.config.renderTextTracksNatively){var o=this.textTracks[r];if(!o||o.mode==="disabled")return;t.forEach(function(u){return Nu(o,u)})}else{var l=this.tracks[r];if(!l)return;var h=l.default?"default":"subtitles"+r;a.trigger(x.CUES_PARSED,{type:"subtitles",cues:t,track:h})}},s.onFragDecrypted=function(t,r){r.frag.type===Wr&&this.onFragLoaded(x.FRAG_LOADED,r)},s.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},s.onFragParsingUserdata=function(t,r){var a=this.cea608Parser1,o=this.cea608Parser2;if(this.enabled&&a&&o){var l=r.frag,h=r.samples;if(l.type!==Je||this.closedCaptionsForLevel(l)!=="NONE")for(var u=0;u<h.length;u++){var f=h[u].bytes;if(f){var p=this.extractCea608Data(f);a.addData(h[u].pts,p[0]),o.addData(h[u].pts,p[1])}}}},s.onBufferFlushing=function(t,r){var a=r.startOffset,o=r.endOffset,l=r.endOffsetSubtitles,h=r.type,u=this.media;if(u&&!(u.currentTime<o)){if(!h||h==="video"){var f=this.captionsTracks;Object.keys(f).forEach(function(v){return rl(f[v],a,o)})}if(this.config.renderTextTracksNatively&&a===0&&l!==void 0){var p=this.textTracks;Object.keys(p).forEach(function(v){return rl(p[v],a,l)})}}},s.extractCea608Data=function(t){for(var r=[[],[]],a=31&t[0],o=2,l=0;l<a;l++){var h=t[o++],u=127&t[o++],f=127&t[o++];if((u!==0||f!==0)&&(4&h)!=0){var p=3&h;p!==0&&p!==1||(r[p].push(u),r[p].push(f))}}return r},d})();function p1(d,s){return!!d&&d.label===s.name&&!(d.textTrack1||d.textTrack2)}var m1=(function(){function d(t){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var s=d.prototype;return s.setStreamController=function(t){this.streamController=t},s.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},s.registerListeners=function(){var t=this.hls;t.on(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(x.MANIFEST_PARSED,this.onManifestParsed,this),t.on(x.BUFFER_CODECS,this.onBufferCodecs,this),t.on(x.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListener=function(){var t=this.hls;t.off(x.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(x.MANIFEST_PARSED,this.onManifestParsed,this),t.off(x.BUFFER_CODECS,this.onBufferCodecs,this),t.off(x.MEDIA_DETACHING,this.onMediaDetaching,this)},s.onFpsDropLevelCapping=function(t,r){var a=this.hls.levels[r.droppedLevel];this.isLevelAllowed(a)&&this.restrictedLevels.push({bitrate:a.bitrate,height:a.height,width:a.width})},s.onMediaAttaching=function(t,r){this.media=r.media instanceof HTMLVideoElement?r.media:null,this.clientRect=null},s.onManifestParsed=function(t,r){var a=this.hls;this.restrictedLevels=[],this.firstLevel=r.firstLevel,a.config.capLevelToPlayerSize&&r.video&&this.startCapping()},s.onBufferCodecs=function(t,r){this.hls.config.capLevelToPlayerSize&&r.video&&this.startCapping()},s.onMediaDetaching=function(){this.stopCapping()},s.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var t=this.hls.levels;if(t.length){var r=this.hls;r.autoLevelCapping=this.getMaxLevel(t.length-1),r.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=r.autoLevelCapping}}},s.getMaxLevel=function(t){var r=this,a=this.hls.levels;if(!a.length)return-1;var o=a.filter(function(l,h){return r.isLevelAllowed(l)&&h<=t});return this.clientRect=null,d.getMaxLevelByMediaSize(o,this.mediaWidth,this.mediaHeight)},s.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},s.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},s.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,r={width:0,height:0};if(t){var a=t.getBoundingClientRect();r.width=a.width,r.height=a.height,r.width||r.height||(r.width=a.right-a.left||t.width||0,r.height=a.bottom-a.top||t.height||0)}return this.clientRect=r,r},s.isLevelAllowed=function(t){return!this.restrictedLevels.some(function(r){return t.bitrate===r.bitrate&&t.width===r.width&&t.height===r.height})},d.getMaxLevelByMediaSize=function(t,r,a){if(t==null||!t.length)return-1;for(var o,l,h=t.length-1,u=0;u<t.length;u+=1){var f=t[u];if((f.width>=r||f.height>=a)&&(o=f,!(l=t[u+1])||o.width!==l.width||o.height!==l.height)){h=u;break}}return h},F(d,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch{}return t}}]),d})(),v1=(function(){function d(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}var s=d.prototype;return s.setStreamController=function(t){this.streamController=t},s.registerListeners=function(){this.hls.on(x.MEDIA_ATTACHING,this.onMediaAttaching,this)},s.unregisterListeners=function(){this.hls.off(x.MEDIA_ATTACHING,this.onMediaAttaching,this)},s.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},s.onMediaAttaching=function(t,r){var a=this.hls.config;if(a.capLevelOnFPSDrop){var o=r.media instanceof self.HTMLVideoElement?r.media:null;this.media=o,o&&typeof o.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),a.fpsDroppedMonitoringPeriod)}},s.checkFPS=function(t,r,a){var o=performance.now();if(r){if(this.lastTime){var l=o-this.lastTime,h=a-this.lastDroppedFrames,u=r-this.lastDecodedFrames,f=1e3*h/l,p=this.hls;if(p.trigger(x.FPS_DROP,{currentDropped:h,currentDecoded:u,totalDroppedFrames:a}),f>0&&h>p.config.fpsDroppedMonitoringThreshold*u){var v=p.currentLevel;G.warn("drop FPS ratio greater than max allowed value for currentLevel: "+v),v>0&&(p.autoLevelCapping===-1||p.autoLevelCapping>=v)&&(v-=1,p.trigger(x.FPS_DROP_LEVEL_CAPPING,{level:v,droppedLevel:p.currentLevel}),p.autoLevelCapping=v,this.streamController.nextLevelSwitch())}}this.lastTime=o,this.lastDroppedFrames=a,this.lastDecodedFrames=r}},s.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var r=t.getVideoPlaybackQuality();this.checkFPS(t,r.totalVideoFrames,r.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},d})(),zn="[eme]",Yg=(function(){function d(t){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=d.CDMCleanupPromise?[d.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=G.debug.bind(G,zn),this.log=G.log.bind(G,zn),this.warn=G.warn.bind(G,zn),this.error=G.error.bind(G,zn),this.hls=t,this.config=t.config,this.registerListeners()}var s=d.prototype;return s.destroy=function(){this.unregisterListeners(),this.onMediaDetached();var t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null},s.registerListeners=function(){this.hls.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(x.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(x.MANIFEST_LOADED,this.onManifestLoaded,this)},s.unregisterListeners=function(){this.hls.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(x.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(x.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(x.MANIFEST_LOADED,this.onManifestLoaded,this)},s.getLicenseServerUrl=function(t){var r=this.config,a=r.drmSystems,o=r.widevineLicenseUrl,l=a[t];if(l)return l.licenseUrl;if(t===$e.WIDEVINE&&o)return o;throw new Error('no license server URL configured for key-system "'+t+'"')},s.getServerCertificateUrl=function(t){var r=this.config.drmSystems[t];if(r)return r.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+t+'"]')},s.attemptKeySystemAccess=function(t){var r=this,a=this.hls.levels,o=function(u,f,p){return!!u&&p.indexOf(u)===f},l=a.map(function(u){return u.audioCodec}).filter(o),h=a.map(function(u){return u.videoCodec}).filter(o);return l.length+h.length===0&&h.push("avc1.42e01e"),new Promise(function(u,f){(function p(v){var w=v.shift();r.getMediaKeysPromise(w,l,h).then(function(C){return u({keySystem:w,mediaKeys:C})}).catch(function(C){v.length?p(v):f(C instanceof Xt?C:new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_ACCESS,error:C,fatal:!0},C.message))})})(t)})},s.requestMediaKeySystemAccess=function(t,r){var a=this.config.requestMediaKeySystemAccessFunc;if(typeof a!="function"){var o="Configured requestMediaKeySystemAccess is not a function "+a;return uu===null&&self.location.protocol==="http:"&&(o="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(o))}return a(t,r)},s.getMediaKeysPromise=function(t,r,a){var o=this,l=(function(p,v,w,C){var k;switch(p){case $e.FAIRPLAY:k=["cenc","sinf"];break;case $e.WIDEVINE:case $e.PLAYREADY:k=["cenc"];break;case $e.CLEARKEY:k=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+p)}return(function(I,D,B,T){return[{initDataTypes:I,persistentState:T.persistentState||"not-allowed",distinctiveIdentifier:T.distinctiveIdentifier||"not-allowed",sessionTypes:T.sessionTypes||[T.sessionType||"temporary"],audioCapabilities:D.map(function(U){return{contentType:'audio/mp4; codecs="'+U+'"',robustness:T.audioRobustness||"",encryptionScheme:T.audioEncryptionScheme||null}}),videoCapabilities:B.map(function(U){return{contentType:'video/mp4; codecs="'+U+'"',robustness:T.videoRobustness||"",encryptionScheme:T.videoEncryptionScheme||null}})}]})(k,v,w,C)})(t,r,a,this.config.drmSystemOptions),h=this.keySystemAccessPromises[t],u=h?.keySystemAccess;if(!u){this.log('Requesting encrypted media "'+t+'" key-system access with config: '+JSON.stringify(l)),u=this.requestMediaKeySystemAccess(t,l);var f=this.keySystemAccessPromises[t]={keySystemAccess:u};return u.catch(function(p){o.log('Failed to obtain access to key-system "'+t+'": '+p)}),u.then(function(p){o.log('Access for key-system "'+p.keySystem+'" obtained');var v=o.fetchServerCertificate(t);return o.log('Create media-keys for "'+t+'"'),f.mediaKeys=p.createMediaKeys().then(function(w){return o.log('Media-keys created for "'+t+'"'),v.then(function(C){return C?o.setMediaKeysServerCertificate(w,t,C):w})}),f.mediaKeys.catch(function(w){o.error('Failed to create media-keys for "'+t+'"}: '+w)}),f.mediaKeys})}return u.then(function(){return h.mediaKeys})},s.createMediaKeySessionContext=function(t){var r=t.decryptdata,a=t.keySystem,o=t.mediaKeys;this.log('Creating key-system session "'+a+'" keyId: '+yr(r.keyId||[]));var l={decryptdata:r,keySystem:a,mediaKeys:o,mediaKeysSession:o.createSession(),keyStatus:"status-pending"};return this.mediaKeySessions.push(l),l},s.renewKeySession=function(t){var r=t.decryptdata;if(r.pssh){var a=this.createMediaKeySessionContext(t),o=this.getKeyIdString(r);this.keyIdToKeySessionPromise[o]=this.generateRequestWithPreferredKeySession(a,"cenc",r.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)},s.getKeyIdString=function(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(t.keyId===null)throw new Error("keyId is null");return yr(t.keyId)},s.updateKeySession=function(t,r){var a,o=t.mediaKeysSession;return this.log('Updating key-session "'+o.sessionId+'" for keyID '+yr(((a=t.decryptdata)==null?void 0:a.keyId)||[])+`
30
+ } (data length: `+(r&&r.byteLength)+")"),o.update(r)},s.selectKeySystemFormat=function(t){var r=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+t.sn+" "+t.type+": "+t.level+") key formats "+r.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(r)),this.keyFormatPromise},s.getKeyFormatPromise=function(t){var r=this;return new Promise(function(a,o){var l=Xs(r.config),h=t.map(cu).filter(function(u){return!!u&&l.indexOf(u)!==-1});return r.getKeySystemSelectionPromise(h).then(function(u){var f=u.keySystem,p=hu(f);p?a(p):o(new Error('Unable to find format for key-system "'+f+'"'))}).catch(o)})},s.loadKey=function(t){var r=this,a=t.keyInfo.decryptdata,o=this.getKeyIdString(a),l="(keyId: "+o+' format: "'+a.keyFormat+'" method: '+a.method+" uri: "+a.uri+")";this.log("Starting session for key "+l);var h=this.keyIdToKeySessionPromise[o];return h||(h=this.keyIdToKeySessionPromise[o]=this.getKeySystemForKeyPromise(a).then(function(u){var f=u.keySystem,p=u.mediaKeys;return r.throwIfDestroyed(),r.log("Handle encrypted media sn: "+t.frag.sn+" "+t.frag.type+": "+t.frag.level+" using key "+l),r.attemptSetMediaKeys(f,p).then(function(){r.throwIfDestroyed();var v=r.createMediaKeySessionContext({keySystem:f,mediaKeys:p,decryptdata:a});return r.generateRequestWithPreferredKeySession(v,"cenc",a.pssh,"playlist-key")})})).catch(function(u){return r.handleError(u)}),h},s.throwIfDestroyed=function(t){if(!this.hls)throw new Error("invalid state")},s.handleError=function(t){this.hls&&(this.error(t.message),t instanceof Xt?this.hls.trigger(x.ERROR,t.data):this.hls.trigger(x.ERROR,{type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))},s.getKeySystemForKeyPromise=function(t){var r=this.getKeyIdString(t),a=this.keyIdToKeySessionPromise[r];if(!a){var o=cu(t.keyFormat),l=o?[o]:Xs(this.config);return this.attemptKeySystemAccess(l)}return a},s.getKeySystemSelectionPromise=function(t){if(t.length||(t=Xs(this.config)),t.length===0)throw new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(t)},s._onMediaEncrypted=function(t){var r=this,a=t.initDataType,o=t.initData;if(this.debug('"'+t.type+'" event: init data type: "'+a+'"'),o!==null){var l,h;if(a==="sinf"&&this.config.drmSystems[$e.FAIRPLAY]){var u=yt(new Uint8Array(o));try{var f=ii(JSON.parse(u).sinf),p=yu(new Uint8Array(f));if(!p)return;l=p.subarray(8,24),h=$e.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{var v=(function(U){if(!(U instanceof ArrayBuffer)||U.byteLength<32)return null;var M={version:0,systemId:"",kids:null,data:null},H=new DataView(U),V=H.getUint32(0);if(U.byteLength!==V&&V>44||H.getUint32(4)!==1886614376||(M.version=H.getUint32(8)>>>24,M.version>1))return null;M.systemId=yr(new Uint8Array(U,12,16));var W=H.getUint32(28);if(M.version===0){if(V-32<W)return null;M.data=new Uint8Array(U,32,W)}else if(M.version===1){M.kids=[];for(var $=0;$<W;$++)M.kids.push(new Uint8Array(U,32+16*$,16))}return M})(o);if(v===null)return;v.version===0&&v.systemId===du&&v.data&&(l=v.data.subarray(8,24)),h=(function(U){if(U===du)return $e.WIDEVINE})(v.systemId)}if(h&&l){for(var w=yr(l),C=this.keyIdToKeySessionPromise,k=this.mediaKeySessions,I=C[w],D=function(){var U=k[B],M=U.decryptdata;if(M.pssh||!M.keyId)return"continue";var H=yr(M.keyId);return w===H||M.uri.replace(/-/g,"").indexOf(w)!==-1?(I=C[H],delete C[H],M.pssh=new Uint8Array(o),M.keyId=l,I=C[w]=I.then(function(){return r.generateRequestWithPreferredKeySession(U,a,o,"encrypted-event-key-match")}),"break"):void 0},B=0;B<k.length;B++){var T=D();if(T!=="continue"&&T==="break")break}I||(I=C[w]=this.getKeySystemSelectionPromise([h]).then(function(U){var M,H=U.keySystem,V=U.mediaKeys;r.throwIfDestroyed();var W=new Zs("ISO-23001-7",w,(M=hu(H))!=null?M:"");return W.pssh=new Uint8Array(o),W.keyId=l,r.attemptSetMediaKeys(H,V).then(function(){r.throwIfDestroyed();var $=r.createMediaKeySessionContext({decryptdata:W,keySystem:H,mediaKeys:V});return r.generateRequestWithPreferredKeySession($,a,o,"encrypted-event-no-match")})})),I.catch(function(U){return r.handleError(U)})}}},s._onWaitingForKey=function(t){this.log('"'+t.type+'" event')},s.attemptSetMediaKeys=function(t,r){var a=this,o=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+t+'"');var l=Promise.all(o).then(function(){if(!a.media)throw new Error("Attempted to set mediaKeys without media element attached");return a.media.setMediaKeys(r)});return this.setMediaKeysQueue.push(l),l.then(function(){a.log('Media-keys set for "'+t+'"'),o.push(l),a.setMediaKeysQueue=a.setMediaKeysQueue.filter(function(h){return o.indexOf(h)===-1})})},s.generateRequestWithPreferredKeySession=function(t,r,a,o){var l,h,u=this,f=(l=this.config.drmSystems)==null||(h=l[t.keySystem])==null?void 0:h.generateRequest;if(f)try{var p=f.call(this.hls,r,a,t);if(!p)throw new Error("Invalid response from configured generateRequest filter");r=p.initDataType,a=t.decryptdata.pssh=p.initData?new Uint8Array(p.initData):null}catch(I){var v;if(this.warn(I.message),(v=this.hls)!=null&&v.config.debug)throw I}if(a===null)return this.log('Skipping key-session request for "'+o+'" (no initData)'),Promise.resolve(t);var w=this.getKeyIdString(t.decryptdata);this.log('Generating key-session request for "'+o+'": '+w+" (init data type: "+r+" length: "+(a?a.byteLength:null)+")");var C=new Gn;t.mediaKeysSession.onmessage=function(I){var D=t.mediaKeysSession;if(D){var B=I.messageType,T=I.message;u.log('"'+B+'" message event for session "'+D.sessionId+'" message size: '+T.byteLength),B==="license-request"||B==="license-renewal"?u.renewLicense(t,T).catch(function(U){u.handleError(U),C.emit("error",U)}):B==="license-release"?t.keySystem===$e.FAIRPLAY&&(u.updateKeySession(t,qr("acknowledged")),u.removeSession(t)):u.warn('unhandled media key message type "'+B+'"')}else C.emit("error",new Error("invalid state"))},t.mediaKeysSession.onkeystatuseschange=function(I){if(t.mediaKeysSession){u.onKeyStatusChange(t);var D=t.keyStatus;C.emit("keyStatus",D),D==="expired"&&(u.warn(t.keySystem+" expired for key "+w),u.renewKeySession(t))}else C.emit("error",new Error("invalid state"))};var k=new Promise(function(I,D){C.on("error",D),C.on("keyStatus",function(B){B.startsWith("usable")?I():B==="output-restricted"?D(new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):B==="internal-error"?D(new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+B+'"')):B==="expired"?D(new Error("key expired while generating request")):u.warn('unhandled key status change "'+B+'"')})});return t.mediaKeysSession.generateRequest(r,a).then(function(){var I;u.log('Request generated for key-session "'+((I=t.mediaKeysSession)==null?void 0:I.sessionId)+'" keyId: '+w)}).catch(function(I){throw new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_NO_SESSION,error:I,fatal:!1},"Error generating key-session request: "+I)}).then(function(){return k}).catch(function(I){throw C.removeAllListeners(),u.removeSession(t),I}).then(function(){return C.removeAllListeners(),t})},s.onKeyStatusChange=function(t){var r=this;t.mediaKeysSession.keyStatuses.forEach(function(a,o){r.log('key status change "'+a+'" for keyStatuses keyId: '+yr("buffer"in o?new Uint8Array(o.buffer,o.byteOffset,o.byteLength):new Uint8Array(o))+" session keyId: "+yr(new Uint8Array(t.decryptdata.keyId||[]))+" uri: "+t.decryptdata.uri),t.keyStatus=a})},s.fetchServerCertificate=function(t){var r=this.config,a=new r.loader(r),o=this.getServerCertificateUrl(t);return o?(this.log('Fetching serverCertificate for "'+t+'"'),new Promise(function(l,h){var u={responseType:"arraybuffer",url:o},f=r.certLoadPolicy.default,p={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};a.load(u,p,{onSuccess:function(v,w,C,k){l(v.data)},onError:function(v,w,C,k){h(new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:C,response:E({url:u.url,data:void 0},v)},'"'+t+'" certificate request failed ('+o+"). Status: "+v.code+" ("+v.text+")"))},onTimeout:function(v,w,C){h(new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:C,response:{url:u.url,data:void 0}},'"'+t+'" certificate request timed out ('+o+")"))},onAbort:function(v,w,C){h(new Error("aborted"))}})})):Promise.resolve()},s.setMediaKeysServerCertificate=function(t,r,a){var o=this;return new Promise(function(l,h){t.setServerCertificate(a).then(function(u){o.log("setServerCertificate "+(u?"success":"not supported by CDM")+" ("+a?.byteLength+') on "'+r+'"'),l(t)}).catch(function(u){h(new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:u,fatal:!0},u.message))})})},s.renewLicense=function(t,r){var a=this;return this.requestLicense(t,new Uint8Array(r)).then(function(o){return a.updateKeySession(t,new Uint8Array(o)).catch(function(l){throw new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:l,fatal:!0},l.message)})})},s.setupLicenseXHR=function(t,r,a,o){var l=this,h=this.config.licenseXhrSetup;return h?Promise.resolve().then(function(){if(!a.decryptdata)throw new Error("Key removed");return h.call(l.hls,t,r,a,o)}).catch(function(u){if(!a.decryptdata)throw u;return t.open("POST",r,!0),h.call(l.hls,t,r,a,o)}).then(function(u){return t.readyState||t.open("POST",r,!0),{xhr:t,licenseChallenge:u||o}}):(t.open("POST",r,!0),Promise.resolve({xhr:t,licenseChallenge:o}))},s.requestLicense=function(t,r){var a=this,o=this.config.keyLoadPolicy.default;return new Promise(function(l,h){var u=a.getLicenseServerUrl(t.keySystem);a.log("Sending license request to URL: "+u);var f=new XMLHttpRequest;f.responseType="arraybuffer",f.onreadystatechange=function(){if(!a.hls||!t.mediaKeysSession)return h(new Error("invalid state"));if(f.readyState===4)if(f.status===200){a._requestLicenseFailureCount=0;var p=f.response;a.log("License received "+(p instanceof ArrayBuffer?p.byteLength:p));var v=a.config.licenseResponseCallback;if(v)try{p=v.call(a.hls,f,u,t)}catch(I){a.error(I)}l(p)}else{var w=o.errorRetry,C=w?w.maxNumRetry:0;if(a._requestLicenseFailureCount++,a._requestLicenseFailureCount>C||f.status>=400&&f.status<500)h(new Xt({type:ue.KEY_SYSTEM_ERROR,details:q.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:f,response:{url:u,data:void 0,code:f.status,text:f.statusText}},"License Request XHR failed ("+u+"). Status: "+f.status+" ("+f.statusText+")"));else{var k=C-a._requestLicenseFailureCount+1;a.warn("Retrying license request, "+k+" attempts left"),a.requestLicense(t,r).then(l,h)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=f,a.setupLicenseXHR(f,u,t,r).then(function(p){var v=p.xhr,w=p.licenseChallenge;v.send(w)})})},s.onMediaAttached=function(t,r){if(this.config.emeEnabled){var a=r.media;this.media=a,a.addEventListener("encrypted",this.onMediaEncrypted),a.addEventListener("waitingforkey",this.onWaitingForKey)}},s.onMediaDetached=function(){var t=this,r=this.media,a=this.mediaKeySessions;r&&(r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Zs.clearKeyUriToKeyIdMap();var o=a.length;d.CDMCleanupPromise=Promise.all(a.map(function(l){return t.removeSession(l)}).concat(r?.setMediaKeys(null).catch(function(l){t.log("Could not clear media keys: "+l+". media.src: "+r?.src)}))).then(function(){o&&(t.log("finished closing key sessions and clearing media keys"),a.length=0)}).catch(function(l){t.log("Could not close sessions and clear media keys: "+l+". media.src: "+r?.src)})},s.onManifestLoading=function(){this.keyFormatPromise=null},s.onManifestLoaded=function(t,r){var a=r.sessionKeys;if(a&&this.config.emeEnabled&&!this.keyFormatPromise){var o=a.reduce(function(l,h){return l.indexOf(h.keyFormat)===-1&&l.push(h.keyFormat),l},[]);this.log("Selecting key-system from session-keys "+o.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(o)}},s.removeSession=function(t){var r=this,a=t.mediaKeysSession,o=t.licenseXhr;if(a){this.log("Remove licenses and keys and close session "+a.sessionId),a.onmessage=null,a.onkeystatuseschange=null,o&&o.readyState!==XMLHttpRequest.DONE&&o.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;var l=this.mediaKeySessions.indexOf(t);return l>-1&&this.mediaKeySessions.splice(l,1),a.remove().catch(function(h){r.log("Could not remove session: "+h)}).then(function(){return a.close()}).catch(function(h){r.log("Could not close session: "+h)})}},d})();Yg.CDMCleanupPromise=void 0;var Xt=(function(d){function s(t,r){var a;return(a=d.call(this,r)||this).data=void 0,t.error||(t.error=new Error(r)),a.data=t,t.err=t.error,a}return X(s,d),s})(ce(Error)),A1="m",qn="a",Gl="v",Yl="av",Kg="i",b1="tt",y1=(function(){function d(t){var r=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(l){try{r.apply(l,{ot:A1,su:!r.initialized})}catch(h){G.warn("Could not generate manifest CMCD data.",h)}},this.applyFragmentData=function(l){try{var h=l.frag,u=r.hls.levels[h.level],f=r.getObjectType(h),p={d:1e3*h.duration,ot:f};f!==Gl&&f!==qn&&f!=Yl||(p.br=u.bitrate/1e3,p.tb=r.getTopBandwidth(f)/1e3,p.bl=r.getBufferLength(f)),r.apply(l,p)}catch(v){G.warn("Could not generate segment CMCD data.",v)}},this.hls=t;var a=this.config=t.config,o=a.cmcd;o!=null&&(a.pLoader=this.createPlaylistLoader(),a.fLoader=this.createFragmentLoader(),this.sid=o.sessionId||d.uuid(),this.cid=o.contentId,this.useHeaders=o.useHeaders===!0,this.registerListeners())}var s=d.prototype;return s.registerListeners=function(){var t=this.hls;t.on(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(x.MEDIA_DETACHED,this.onMediaDetached,this),t.on(x.BUFFER_CREATED,this.onBufferCreated,this)},s.unregisterListeners=function(){var t=this.hls;t.off(x.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(x.MEDIA_DETACHED,this.onMediaDetached,this),t.off(x.BUFFER_CREATED,this.onBufferCreated,this)},s.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},s.onMediaAttached=function(t,r){this.media=r.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},s.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},s.onBufferCreated=function(t,r){var a,o;this.audioBuffer=(a=r.tracks.audio)==null?void 0:a.buffer,this.videoBuffer=(o=r.tracks.video)==null?void 0:o.buffer},s.createData=function(){var t;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},s.apply=function(t,r){r===void 0&&(r={}),Y(r,this.createData());var a=r.ot===Kg||r.ot===Gl||r.ot===Yl;if(this.starved&&a&&(r.bs=!0,r.su=!0,this.starved=!1),r.su??(r.su=this.buffering),this.useHeaders){var o=d.toHeaders(r);if(!Object.keys(o).length)return;t.headers||(t.headers={}),Y(t.headers,o)}else{var l=d.toQuery(r);if(!l)return;t.url=d.appendQueryToUri(t.url,l)}},s.getObjectType=function(t){var r=t.type;return r==="subtitle"?b1:t.sn==="initSegment"?Kg:r==="audio"?qn:r==="main"?this.hls.audioTracks.length?Gl:Yl:void 0},s.getTopBandwidth=function(t){var r,a=0,o=this.hls;if(t===qn)r=o.audioTracks;else{var l=o.maxAutoLevel,h=l>-1?l+1:o.levels.length;r=o.levels.slice(0,h)}for(var u,f=xe(r);!(u=f()).done;){var p=u.value;p.bitrate>a&&(a=p.bitrate)}return a>0?a:NaN},s.getBufferLength=function(t){var r=this.hls.media,a=t===qn?this.audioBuffer:this.videoBuffer;return a&&r?1e3*ct.bufferInfo(a,r.currentTime,this.config.maxBufferHole).len:NaN},s.createPlaylistLoader=function(){var t=this.config.pLoader,r=this.applyPlaylistData,a=t||this.config.loader;return(function(){function o(h){this.loader=void 0,this.loader=new a(h)}var l=o.prototype;return l.destroy=function(){this.loader.destroy()},l.abort=function(){this.loader.abort()},l.load=function(h,u,f){r(h),this.loader.load(h,u,f)},F(o,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),o})()},s.createFragmentLoader=function(){var t=this.config.fLoader,r=this.applyFragmentData,a=t||this.config.loader;return(function(){function o(h){this.loader=void 0,this.loader=new a(h)}var l=o.prototype;return l.destroy=function(){this.loader.destroy()},l.abort=function(){this.loader.abort()},l.load=function(h,u,f){r(h),this.loader.load(h,u,f)},F(o,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),o})()},d.uuid=function(){var t=URL.createObjectURL(new Blob),r=t.toString();return URL.revokeObjectURL(t),r.slice(r.lastIndexOf("/")+1)},d.serialize=function(t){for(var r,a=[],o=function(I){return!Number.isNaN(I)&&I!=null&&I!==""&&I!==!1},l=function(I){return Math.round(I)},h=function(I){return 100*l(I/100)},u={br:l,d:l,bl:h,dl:h,mtp:h,nor:function(I){return encodeURIComponent(I)},rtp:h,tb:l},f=xe(Object.keys(t||{}).sort());!(r=f()).done;){var p=r.value,v=t[p];if(o(v)&&!(p==="v"&&v===1||p=="pr"&&v===1)){var w=u[p];w&&(v=w(v));var C=typeof v,k=void 0;k=p==="ot"||p==="sf"||p==="st"?p+"="+v:C==="boolean"?p:C==="number"?p+"="+v:p+"="+JSON.stringify(v),a.push(k)}}return a.join(",")},d.toHeaders=function(t){for(var r={},a=["Object","Request","Session","Status"],o=[{},{},{},{}],l={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},h=0,u=Object.keys(t);h<u.length;h++){var f=u[h];o[l[f]!=null?l[f]:1][f]=t[f]}for(var p=0;p<o.length;p++){var v=d.serialize(o[p]);v&&(r["CMCD-"+a[p]]=v)}return r},d.toQuery=function(t){return"CMCD="+encodeURIComponent(d.serialize(t))},d.appendQueryToUri=function(t,r){if(!r)return t;var a=t.includes("?")?"&":"?";return""+t+a+r},d})(),w1=(function(){function d(t){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=t,this.log=G.log.bind(G,"[content-steering]:"),this.registerListeners()}var s=d.prototype;return s.registerListeners=function(){var t=this.hls;t.on(x.MANIFEST_LOADING,this.onManifestLoading,this),t.on(x.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(x.MANIFEST_PARSED,this.onManifestParsed,this),t.on(x.ERROR,this.onError,this)},s.unregisterListeners=function(){var t=this.hls;t&&(t.off(x.MANIFEST_LOADING,this.onManifestLoading,this),t.off(x.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(x.MANIFEST_PARSED,this.onManifestParsed,this),t.off(x.ERROR,this.onError,this))},s.startLoad=function(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){var t=Math.max(1e3*this.timeToLoad-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,t)}else this.loadSteeringManifest(this.uri)},s.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)},s.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},s.removeLevel=function(t){var r=this.levels;r&&(this.levels=r.filter(function(a){return a!==t}))},s.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},s.onManifestLoaded=function(t,r){var a=r.contentSteering;a!==null&&(this.pathwayId=a.pathwayId,this.uri=a.uri,this.started&&this.startLoad())},s.onManifestParsed=function(t,r){this.audioTracks=r.audioTracks,this.subtitleTracks=r.subtitleTracks},s.onError=function(t,r){var a=r.errorAction;if(a?.action===Or&&a.flags===Mn){var o=this.pathwayPriority,l=this.pathwayId;this.penalizedPathways[l]||(this.penalizedPathways[l]=performance.now()),!o&&this.levels&&(o=this.levels.reduce(function(h,u){return h.indexOf(u.pathwayId)===-1&&h.push(u.pathwayId),h},[])),o&&o.length>1&&(this.updatePathwayPriority(o),a.resolved=this.pathwayId!==l)}},s.filterParsedLevels=function(t){this.levels=t;var r=this.getLevelsForPathway(this.pathwayId);if(r.length===0){var a=t[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+a+'"'),r=this.getLevelsForPathway(a),this.pathwayId=a}return r.length!==t.length?(this.log("Found "+r.length+"/"+t.length+' levels in Pathway "'+this.pathwayId+'"'),r):t},s.getLevelsForPathway=function(t){return this.levels===null?[]:this.levels.filter(function(r){return t===r.pathwayId})},s.updatePathwayPriority=function(t){var r;this.pathwayPriority=t;var a=this.penalizedPathways,o=performance.now();Object.keys(a).forEach(function(v){o-a[v]>3e5&&delete a[v]});for(var l=0;l<t.length;l++){var h=t[l];if(!a[h]){if(h===this.pathwayId)return;var u=this.hls.nextLoadLevel,f=this.hls.levels[u];if((r=this.getLevelsForPathway(h)).length>0){this.log('Setting Pathway to "'+h+'"'),this.pathwayId=h,this.hls.trigger(x.LEVELS_UPDATED,{levels:r});var p=this.hls.levels[u];f&&p&&this.levels&&(p.attrs["STABLE-VARIANT-ID"]!==f.attrs["STABLE-VARIANT-ID"]&&p.bitrate!==f.bitrate&&this.log("Unstable Pathways change from bitrate "+f.bitrate+" to "+p.bitrate),this.hls.nextLoadLevel=u);break}}}},s.clonePathways=function(t){var r=this,a=this.levels;if(a){var o={},l={};t.forEach(function(h){var u=h.ID,f=h["BASE-ID"],p=h["URI-REPLACEMENT"];if(!a.some(function(w){return w.pathwayId===u})){var v=r.getLevelsForPathway(f).map(function(w){var C=Y({},w);C.details=void 0,C.url=qg(w.uri,w.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",p);var k=new Ke(w.attrs);k["PATHWAY-ID"]=u;var I=k.AUDIO&&k.AUDIO+"_clone_"+u,D=k.SUBTITLES&&k.SUBTITLES+"_clone_"+u;I&&(o[k.AUDIO]=I,k.AUDIO=I),D&&(l[k.SUBTITLES]=D,k.SUBTITLES=D),C.attrs=k;var B=new Aa(C);return Fn(B,"audio",I),Fn(B,"text",D),B});a.push.apply(a,v),zg(r.audioTracks,o,p,u),zg(r.subtitleTracks,l,p,u)}})}},s.loadSteeringManifest=function(t){var r,a=this,o=this.hls.config,l=o.loader;this.loader&&this.loader.destroy(),this.loader=new l(o);try{r=new self.URL(t)}catch{this.enabled=!1,this.log("Failed to parse Steering Manifest URI: "+t);return}if(r.protocol!=="data:"){var h=0|(this.hls.bandwidthEstimate||o.abrEwmaDefaultEstimate);r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+h)}var u={responseType:"json",url:r.href},f=o.steeringManifestLoadPolicy.default,p=f.errorRetry||f.timeoutRetry||{},v={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:p.maxNumRetry||0,retryDelay:p.retryDelayMs||0,maxRetryDelay:p.maxRetryDelayMs||0};this.log("Requesting steering manifest: "+r),this.loader.load(u,v,{onSuccess:function(w,C,k,I){a.log('Loaded steering manifest: "'+r+'"');var D=w.data;if(D.VERSION===1){a.updated=performance.now(),a.timeToLoad=D.TTL;var B=D["RELOAD-URI"],T=D["PATHWAY-CLONES"],U=D["PATHWAY-PRIORITY"];if(B)try{a.uri=new self.URL(B,r).href}catch{a.enabled=!1,a.log("Failed to parse Steering Manifest RELOAD-URI: "+B);return}a.scheduleRefresh(a.uri||k.url),T&&a.clonePathways(T),U&&a.updatePathwayPriority(U)}else a.log("Steering VERSION "+D.VERSION+" not supported!")},onError:function(w,C,k,I){if(a.log("Error loading steering manifest: "+w.code+" "+w.text+" ("+C.url+")"),a.stopLoad(),w.code===410)return a.enabled=!1,void a.log("Steering manifest "+C.url+" no longer available");var D=1e3*a.timeToLoad;if(w.code!==429)a.scheduleRefresh(a.uri||C.url,D);else{var B=a.loader;if(typeof B?.getResponseHeader=="function"){var T=B.getResponseHeader("Retry-After");T&&(D=1e3*parseFloat(T))}a.log("Steering manifest "+C.url+" rate limited")}},onTimeout:function(w,C,k){a.log("Timeout loading steering manifest ("+C.url+")"),a.scheduleRefresh(a.uri||C.url)}})},s.scheduleRefresh=function(t,r){var a=this;r===void 0&&(r=1e3*this.timeToLoad),self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(function(){a.loadSteeringManifest(t)},r)},d})();function zg(d,s,t,r){d&&Object.keys(s).forEach(function(a){var o=d.filter(function(l){return l.groupId===a}).map(function(l){var h=Y({},l);return h.details=void 0,h.attrs=new Ke(h.attrs),h.url=h.attrs.URI=qg(l.url,l.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),h.groupId=h.attrs["GROUP-ID"]=s[a],h.attrs["PATHWAY-ID"]=r,h});d.push.apply(d,o)})}function qg(d,s,t,r){var a,o=r.HOST,l=r.PARAMS,h=r[t];s&&(a=h?.[s])&&(d=a);var u=new self.URL(d);return o&&!a&&(u.host=o),l&&Object.keys(l).sort().forEach(function(f){f&&u.searchParams.set(f,l[f])}),u.href}var C1=/^age:\s*[\d.]+\s*$/im,Vg=(function(){function d(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new vr,this.retryDelay=0}var s=d.prototype;return s.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},s.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,t.readyState!==4&&(this.stats.aborted=!0,t.abort()))},s.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},s.load=function(t,r,a){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=r,this.callbacks=a,this.loadInternal()},s.loadInternal=function(){var t=this,r=this.config,a=this.context;if(r){var o=this.loader=new self.XMLHttpRequest,l=this.stats;l.loading.first=0,l.loaded=0,l.aborted=!1;var h=this.xhrSetup;h?Promise.resolve().then(function(){if(!t.stats.aborted)return h(o,a.url)}).catch(function(u){return o.open("GET",a.url,!0),h(o,a.url)}).then(function(){t.stats.aborted||t.openAndSendXhr(o,a,r)}).catch(function(u){t.callbacks.onError({code:o.status,text:u.message},a,o,l)}):this.openAndSendXhr(o,a,r)}},s.openAndSendXhr=function(t,r,a){t.readyState||t.open("GET",r.url,!0);var o=this.context.headers,l=a.loadPolicy,h=l.maxTimeToFirstByteMs,u=l.maxLoadTimeMs;if(o)for(var f in o)t.setRequestHeader(f,o[f]);r.rangeEnd&&t.setRequestHeader("Range","bytes="+r.rangeStart+"-"+(r.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=r.responseType,self.clearTimeout(this.requestTimeout),a.timeout=h&&se(h)?h:u,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout),t.send()},s.readystatechange=function(){var t=this.context,r=this.loader,a=this.stats;if(t&&r){var o=r.readyState,l=this.config;if(!a.aborted&&o>=2&&(a.loading.first===0&&(a.loading.first=Math.max(self.performance.now(),a.loading.start),l.timeout!==l.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),l.timeout=l.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),l.loadPolicy.maxLoadTimeMs-(a.loading.first-a.loading.start)))),o===4)){self.clearTimeout(this.requestTimeout),r.onreadystatechange=null,r.onprogress=null;var h=r.status,u=r.responseType!=="text";if(h>=200&&h<300&&(u&&r.response||r.responseText!==null)){a.loading.end=Math.max(self.performance.now(),a.loading.first);var f=u?r.response:r.responseText;if(a.loaded=a.total=r.responseType==="arraybuffer"?f.byteLength:f.length,a.bwEstimate=8e3*a.total/(a.loading.end-a.loading.first),!this.callbacks)return;var p=this.callbacks.onProgress;if(p&&p(a,t,f,r),!this.callbacks)return;var v={url:r.responseURL,data:f,code:h};this.callbacks.onSuccess(v,a,t,r)}else{var w=l.loadPolicy.errorRetry;Rn(w,a.retry,!1,h)?this.retry(w):(G.error(h+" while loading "+t.url),this.callbacks.onError({code:h,text:r.statusText},t,r,a))}}}},s.loadtimeout=function(){var t,r=(t=this.config)==null?void 0:t.loadPolicy.timeoutRetry;if(Rn(r,this.stats.retry,!0))this.retry(r);else{G.warn("timeout while loading "+this.context.url);var a=this.callbacks;a&&(this.abortInternal(),a.onTimeout(this.stats,this.context,this.loader))}},s.retry=function(t){var r=this.context,a=this.stats;this.retryDelay=cl(t,a.retry),a.retry++,G.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+r.url+", retrying "+a.retry+"/"+t.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},s.loadprogress=function(t){var r=this.stats;r.loaded=t.loaded,t.lengthComputable&&(r.total=t.total)},s.getCacheAge=function(){var t=null;if(this.loader&&C1.test(this.loader.getAllResponseHeaders())){var r=this.loader.getResponseHeader("age");t=r?parseFloat(r):null}return t},s.getResponseHeader=function(t){return this.loader&&new RegExp("^"+t+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null},d})(),E1=/(\d+)-(\d+)\/(\d+)/,Wg=(function(){function d(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||k1,this.controller=new self.AbortController,this.stats=new vr}var s=d.prototype;return s.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},s.abortInternal=function(){var t=this.response;t!=null&&t.ok||(this.stats.aborted=!0,this.controller.abort())},s.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},s.load=function(t,r,a){var o=this,l=this.stats;if(l.loading.start)throw new Error("Loader can only be used once.");l.loading.start=self.performance.now();var h=(function(k,I){var D={method:"GET",mode:"cors",credentials:"same-origin",signal:I,headers:new self.Headers(Y({},k.headers))};return k.rangeEnd&&D.headers.set("Range","bytes="+k.rangeStart+"-"+String(k.rangeEnd-1)),D})(t,this.controller.signal),u=a.onProgress,f=t.responseType==="arraybuffer",p=f?"byteLength":"length",v=r.loadPolicy,w=v.maxTimeToFirstByteMs,C=v.maxLoadTimeMs;this.context=t,this.config=r,this.callbacks=a,this.request=this.fetchSetup(t,h),self.clearTimeout(this.requestTimeout),r.timeout=w&&se(w)?w:C,this.requestTimeout=self.setTimeout(function(){o.abortInternal(),a.onTimeout(l,t,o.response)},r.timeout),self.fetch(this.request).then(function(k){o.response=o.loader=k;var I=Math.max(self.performance.now(),l.loading.start);if(self.clearTimeout(o.requestTimeout),r.timeout=C,o.requestTimeout=self.setTimeout(function(){o.abortInternal(),a.onTimeout(l,t,o.response)},C-(I-l.loading.start)),!k.ok){var D=k.status,B=k.statusText;throw new B1(B||"fetch, bad network response",D,k)}return l.loading.first=I,l.total=(function(T){var U=T.get("Content-Range");if(U){var M=(function(V){var W=E1.exec(V);if(W)return parseInt(W[2])-parseInt(W[1])+1})(U);if(se(M))return M}var H=T.get("Content-Length");if(H)return parseInt(H)})(k.headers)||l.total,u&&se(r.highWaterMark)?o.loadProgressively(k,l,t,r.highWaterMark,u):f?k.arrayBuffer():t.responseType==="json"?k.json():k.text()}).then(function(k){var I=o.response;self.clearTimeout(o.requestTimeout),l.loading.end=Math.max(self.performance.now(),l.loading.first);var D=k[p];D&&(l.loaded=l.total=D);var B={url:I.url,data:k,code:I.status};u&&!se(r.highWaterMark)&&u(l,t,k,I),a.onSuccess(B,l,t,I)}).catch(function(k){if(self.clearTimeout(o.requestTimeout),!l.aborted){var I=k&&k.code||0,D=k?k.message:null;a.onError({code:I,text:D},t,k?k.details:null,l)}})},s.getCacheAge=function(){var t=null;if(this.response){var r=this.response.headers.get("age");t=r?parseFloat(r):null}return t},s.getResponseHeader=function(t){return this.response?this.response.headers.get(t):null},s.loadProgressively=function(t,r,a,o,l){o===void 0&&(o=0);var h=new Eg,u=t.body.getReader();return(function f(){return u.read().then(function(p){if(p.done)return h.dataLength&&l(r,a,h.flush(),t),Promise.resolve(new ArrayBuffer(0));var v=p.value,w=v.length;return r.loaded+=w,w<o||h.dataLength?(h.push(v),h.dataLength>=o&&l(r,a,h.flush(),t)):l(r,a,v,t),f()}).catch(function(){return Promise.reject()})})()},d})();function k1(d,s){return new self.Request(d.url,s)}var B1=(function(d){function s(t,r,a){var o;return(o=d.call(this,t)||this).code=void 0,o.details=void 0,o.code=r,o.details=a,o}return X(s,d),s})(ce(Error)),I1=/\s/,S1=E(E({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Vg,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:zm,bufferController:Zm,capLevelController:m1,errorController:dm,fpsController:v1,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:uu,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:{newCue:function(d,s,t,r){for(var a,o,l,h,u,f=[],p=self.VTTCue||self.TextTrackCue,v=0;v<r.rows.length;v++)if(l=!0,h=0,u="",!(a=r.rows[v]).isEmpty()){for(var w,C=0;C<a.chars.length;C++)I1.test(a.chars[C].uchar)&&l?h++:(u+=a.chars[C].uchar,l=!1);a.cueStartTime=s,s===t&&(t+=1e-4),h>=16?h--:h++;var k=Og(u.trim()),I=Pl(s,t,k);d!=null&&(w=d.cues)!=null&&w.getCueById(I)||((o=new p(s,t,k)).id=I,o.line=v+1,o.align="left",o.position=10+Math.min(80,10*Math.floor(8*h/32)),f.push(o))}return d&&f.length&&(f.sort(function(D,B){return D.line==="auto"||B.line==="auto"?0:D.line>8&&B.line>8?B.line-D.line:D.line-B.line}),f.forEach(function(D){return Nu(d,D)})),f}},enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:Xm,subtitleTrackController:_m,timelineController:f1,audioStreamController:qm,audioTrackController:Vm,emeController:Yg,cmcdController:y1,contentSteeringController:w1});function Kl(d){return d&&typeof d=="object"?Array.isArray(d)?d.map(Kl):Object.keys(d).reduce(function(s,t){return s[t]=Kl(d[t]),s},{}):d}function x1(d){var s=d.loader;s!==Wg&&s!==Vg?(G.log("[config]: Custom loader detected, cannot enable progressive streaming"),d.progressive=!1):(function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1})()&&(d.loader=Wg,d.progressive=!0,d.enableSoftwareAES=!0,G.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Xg=(function(){function d(t){t===void 0&&(t={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Gn,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,tr(t.debug||!1,"Hls instance");var r=this.config=(function(le,ie){if((ie.liveSyncDurationCount||ie.liveMaxLatencyDurationCount)&&(ie.liveSyncDuration||ie.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(ie.liveMaxLatencyDurationCount!==void 0&&(ie.liveSyncDurationCount===void 0||ie.liveMaxLatencyDurationCount<=ie.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(ie.liveMaxLatencyDuration!==void 0&&(ie.liveSyncDuration===void 0||ie.liveMaxLatencyDuration<=ie.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var me=Kl(le),we=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(ve){var Ae=(ve==="level"?"playlist":ve)+"LoadPolicy",Ie=ie[Ae]===void 0,fe=[];we.forEach(function(Pe){var Ue=ve+"Loading"+Pe,ze=ie[Ue];if(ze!==void 0&&Ie){fe.push(Ue);var je=me[Ae].default;switch(ie[Ae]={default:je},Pe){case"TimeOut":je.maxLoadTimeMs=ze,je.maxTimeToFirstByteMs=ze;break;case"MaxRetry":je.errorRetry.maxNumRetry=ze,je.timeoutRetry.maxNumRetry=ze;break;case"RetryDelay":je.errorRetry.retryDelayMs=ze,je.timeoutRetry.retryDelayMs=ze;break;case"MaxRetryTimeout":je.errorRetry.maxRetryDelayMs=ze,je.timeoutRetry.maxRetryDelayMs=ze}}}),fe.length&&G.warn('hls.js config: "'+fe.join('", "')+'" setting(s) are deprecated, use "'+Ae+'": '+JSON.stringify(ie[Ae]))}),E(E({},me),ie)})(d.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,r.progressive&&x1(r);var a=r.abrController,o=r.bufferController,l=r.capLevelController,h=r.errorController,u=r.fpsController,f=new h(this),p=this.abrController=new a(this),v=this.bufferController=new o(this),w=this.capLevelController=new l(this),C=new u(this),k=new tm(this),I=new im(this),D=r.contentSteeringController,B=D?new D(this):null,T=this.levelController=new hm(this,B),U=new um(this),M=new fm(this.config),H=this.streamController=new Ym(this,U,M);w.setStreamController(H),C.setStreamController(H);var V=[k,T,H];B&&V.splice(1,0,B),this.networkControllers=V;var W=[p,v,w,C,I,U];this.audioTrackController=this.createController(r.audioTrackController,V);var $=r.audioStreamController;$&&V.push(new $(this,U,M)),this.subtitleTrackController=this.createController(r.subtitleTrackController,V);var J=r.subtitleStreamController;J&&V.push(new J(this,U,M)),this.createController(r.timelineController,W),M.emeController=this.emeController=this.createController(r.emeController,W),this.cmcdController=this.createController(r.cmcdController,W),this.latencyController=this.createController(am,W),this.coreComponents=W,V.push(f);var j=f.onErrorOut;typeof j=="function"&&this.on(x.ERROR,j,f)}d.isSupported=function(){return(function(){var t=xn();if(!t)return!1;var r=ig(),a=t&&typeof t.isTypeSupported=="function"&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),o=!r||r.prototype&&typeof r.prototype.appendBuffer=="function"&&typeof r.prototype.remove=="function";return!!a&&!!o})()};var s=d.prototype;return s.createController=function(t,r){if(t){var a=new t(this);return r&&r.push(a),a}return null},s.on=function(t,r,a){a===void 0&&(a=this),this._emitter.on(t,r,a)},s.once=function(t,r,a){a===void 0&&(a=this),this._emitter.once(t,r,a)},s.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},s.off=function(t,r,a,o){a===void 0&&(a=this),this._emitter.off(t,r,a,o)},s.listeners=function(t){return this._emitter.listeners(t)},s.emit=function(t,r,a){return this._emitter.emit(t,r,a)},s.trigger=function(t,r){if(this.config.debug)return this.emit(t,t,r);try{return this.emit(t,t,r)}catch(a){G.error("An internal error happened while handling event "+t+'. Error message: "'+a.message+'". Here is a stacktrace:',a),this.trigger(x.ERROR,{type:ue.OTHER_ERROR,details:q.INTERNAL_EXCEPTION,fatal:!1,event:t,error:a})}return!1},s.listenerCount=function(t){return this._emitter.listenerCount(t)},s.destroy=function(){G.log("destroy"),this.trigger(x.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(r){return r.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(r){return r.destroy()}),this.coreComponents.length=0;var t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null},s.attachMedia=function(t){G.log("attachMedia"),this._media=t,this.trigger(x.MEDIA_ATTACHING,{media:t})},s.detachMedia=function(){G.log("detachMedia"),this.trigger(x.MEDIA_DETACHING,void 0),this._media=null},s.loadSource=function(t){this.stopLoad();var r=this.media,a=this.url,o=this.url=Ge.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});G.log("loadSource:"+o),r&&a&&(a!==o||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(r)),this.trigger(x.MANIFEST_LOADING,{url:t})},s.startLoad=function(t){t===void 0&&(t=-1),G.log("startLoad("+t+")"),this.networkControllers.forEach(function(r){r.startLoad(t)})},s.stopLoad=function(){G.log("stopLoad"),this.networkControllers.forEach(function(t){t.stopLoad()})},s.swapAudioCodec=function(){G.log("swapAudioCodec"),this.streamController.swapAudioCodec()},s.recoverMediaError=function(){G.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},s.removeLevel=function(t,r){r===void 0&&(r=0),this.levelController.removeLevel(t,r)},F(d,[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){G.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){G.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){G.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){G.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){G.log("set startLevel:"+t),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var r=!!t;r!==this.config.capLevelToPlayerSize&&(r?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=r)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(G.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"ttfbEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(t){nl.indexOf(t)>-1&&(this._maxHdcpLevel=t)}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,r=this.config.minAutoBitrate;if(!t)return 0;for(var a=t.length,o=0;o<a;o++)if(t[o].maxBitrate>=r)return o;return 0}},{key:"maxAutoLevel",get:function(){var t,r=this.levels,a=this.autoLevelCapping,o=this.maxHdcpLevel;if(t=a===-1&&r&&r.length?r.length-1:a,o)for(var l=t;l--;){var h=r[l].attrs["HDCP-LEVEL"];if(h&&h<=o)return l}return t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var r=this.audioTrackController;r&&(r.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var r=this.subtitleTrackController;r&&(r.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},set:function(t){var r=this.subtitleTrackController;r&&(r.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.4.12"}},{key:"Events",get:function(){return x}},{key:"ErrorTypes",get:function(){return ue}},{key:"ErrorDetails",get:function(){return q}},{key:"DefaultConfig",get:function(){return d.defaultConfig?d.defaultConfig:S1},set:function(t){d.defaultConfig=t}}]),d})();return Xg.defaultConfig=void 0,Xg};typeof e=="object"&&typeof i<"u"?i.exports=m():typeof define=="function"&&define.amd?define(m):(g=typeof globalThis<"u"?globalThis:g||self).Hls=m()})(!1)})),Y1=tf(),rf='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{position:var(--ran-select-host-position, relative);display:var(--ran-select-host-display, inline-block);cursor:var(--ran-select-host-cursor, pointer);height:var(--ran-select-host-height, 32px);outline:var(--ran-select-host-outline, 0);-webkit-tap-highlight-color:var(--ran-select-host-tap-highlight-color, transparent)}:host,:host(:focus),:host(:active){outline:var(--ran-select-host-focus-outline, 0);-webkit-tap-highlight-color:transparent}:host ::slotted(r-option){display:var(--ran-select-option-display, none)}:host([disabled]){cursor:var(--ran-select-host-disabled-cursor, not-allowed);pointer-events:var(--ran-select-host-disabled-pointer-events, all);opacity:var(--ran-select-host-disabled-opacity, .6)}:host(:not([disabled]):hover) .ran-select{cursor:var(--ran-select-host-hover-cursor, pointer)}:host(:not([disabled],[type="text"]):hover) .selection{border:var(--ran-select-selection-hover-border, 1px solid var(--ran-color-primary, #006bff))}:host(:not([disabled],[type="text"]):hover) .selection-search{cursor:var(--ran-select-selection-hover-search-cursor, pointer)}:host(:not([disabled],[type="text"]):hover) .selection-item{cursor:var(--ran-select-selection-hover-item-cursor, pointer);color:var(--ran-select-selection-hover-item-color, var(--ran-color-text-disabled, #bfbfbf))}:host([type="text"]) .selection{border:var(--ran-select-selection-text-border, none);background:var(--ran-select-selection-text-background, transparent)}:host([type="text"]) .icon{display:var(--ran-select-icon-text-display, none)}:host(:not([disabled],[type="text"]):focus) .selection{border:var(--ran-select-selection-focus-border, 1px solid var(--ran-color-primary, #006bff))}:host(:not([disabled],[type="text"]):focus) .selection-search{cursor:var(--ran-select-selection-focus-search-cursor, pointer)}:host(:not([disabled],[type="text"]):focus) .selection-item{cursor:var(--ran-select-selection-focus-item-cursor, pointer);color:var(--ran-select-selection-focus-item-color, var(--ran-color-text-disabled, #bfbfbf))}:host .selection-search{display:var(--ran-select-selection-search-display, none)}:host([showSearch]:not([disabled])) .selection-search{cursor:var(--ran-select-selection-search-visible-cursor, text);display:var(--ran-select-selection-search-visible-display, block)}:host([showSearch]:not([disabled])) .selection-item{cursor:var(--ran-select-selection-search-visible-item-cursor, pointer)}:host([showSearch]:not([disabled]):focus) .selection-search{display:var(--ran-select-selection-search-visible-display, block);cursor:var(--ran-select-selection-search-visible-cursor, text);opacity:var(--ran-select-selection-search-visible-opacity, 1)}.ran-select{width:var(--ran-select-root-width, 100%);height:var(--ran-select-root-height, 100%);font-size:var(--ran-select-root-font-size, 14px);box-sizing:var(--ran-select-root-box-sizing, border-box);margin:var(--ran-select-root-margin, 0);padding:var(--ran-select-root-padding, 0);color:var(--ran-select-root-color, var(--ran-color-text, rgba(0, 0, 0, .88)));line-height:var(--ran-select-root-line-height, 1.57142857);list-style:var(--ran-select-root-list-style, none);font-family:var(--ran-select-root-font-family, var(--ran-skin-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"));position:var(--ran-select-root-position, relative);display:var(--ran-select-root-display, inline-block)}.ran-select .selection{position:var(--ran-select-selection-position, relative);background-color:var(--ran-select-selection-background-color, var(--ran-color-bg-elevated, #ffffff));background-image:var(--ran-select-selection-background-image, none);border:var(--ran-select-selection-border, 1px solid var(--ran-color-border, #eaeaea));transition:var(--ran-select-selection-transition, none);width:var(--ran-select-selection-width, 100%);height:var(--ran-select-selection-height, 100%);padding:var(--ran-select-selection-padding, 0 11px);box-sizing:var(--ran-select-selection-box-sizing, border-box);margin:var(--ran-select-selection-margin, 0);color:var(--ran-select-selection-color, var(--ran-color-text, rgba(0, 0, 0, .88)));font-size:var(--ran-select-selection-font-size, 14px);line-height:var(--ran-select-selection-line-height, 1.57142857);list-style:var(--ran-select-selection-list-style, none);font-family:var(--ran-select-selection-font-family, inherit);display:var(--ran-select-selection-display, flex);border-radius:var(--ran-select-selection-border-radius, var(--ran-radius-sm, 6px))}.ran-select .selection-search{position:var(--ran-select-selection-search-position, absolute);opacity:var(--ran-select-selection-search-opacity, 0);top:var(--ran-select-selection-search-top, 0);left:var(--ran-select-selection-search-left, 0);height:var(--ran-select-selection-search-height, 100%);inset-inline-start:var(--ran-select-selection-search-inset-inline-start, 11px);inset-inline-end:var(--ran-select-selection-search-inset-inline-end, 11px);margin:var(--ran-select-selection-search-margin, 0);padding:var(--ran-select-selection-search-padding, 0);background:var(--ran-select-selection-search-background, transparent);border:var(--ran-select-selection-search-border, none);outline:var(--ran-select-selection-search-outline, none);appearance:var(--ran-select-selection-search-appearance, none);font-family:var(--ran-select-selection-search-font-family, inherit);cursor:var(--ran-select-selection-search-cursor, not-allowed)}.ran-select .selection-search::-webkit-search-cancel-button{display:var(--ran-select-selection-search-cancel-display, none);-webkit-appearance:var(--ran-select-selection-search-cancel-appearance, none)}.ran-select .selection-search::part(input){border:var(--ran-select-selection-search-input-border, none);padding:var(--ran-select-selection-search-input-padding, 0);height:100%;min-height:100%;box-sizing:border-box;outline:var(--ran-select-selection-search-input-outline, none)}.ran-select .selection-search::part(input):active{border:var(--ran-select-selection-search-input-active-border, none);padding:var(--ran-select-selection-search-input-active-padding, 0);height:var(--ran-select-selection-search-input-active-height, 100%);outline:var(--ran-select-selection-search-input-active-outline, none);border-color:var(--ran-select-selection-search-input-active-border-color, transparent);box-shadow:var(--ran-select-selection-search-input-active-box-shadow, none);border-right-width:var(--ran-select-selection-search-input-active-border-right-width, 0px)}.ran-select .selection-search::part(content){min-height:var(--ran-select-selection-search-input-content-min-height, 0)}.ran-select .selection-item{position:var(--ran-select-selection-item-position, absolute);top:var(--ran-select-selection-item-top, 0);left:var(--ran-select-selection-item-left, 12px);right:var(--ran-select-selection-item-right, 28px);margin:var(--ran-select-selection-item-margin, 0);padding:var(--ran-select-selection-item-padding, 0);background:var(--ran-select-selection-item-background, transparent);border:var(--ran-select-selection-item-border, none);outline:var(--ran-select-selection-item-outline, none);appearance:var(--ran-select-selection-item-appearance, none);font-family:var(--ran-select-selection-item-font-family, inherit);height:var(--ran-select-selection-item-height, 100%);display:var(--ran-select-selection-item-display, flex);align-items:var(--ran-select-selection-item-align-items, center);-webkit-user-select:var(--ran-select-selection-item-user-select, none);user-select:var(--ran-select-selection-item-user-select, none);overflow:var(--ran-select-selection-item-overflow, hidden);white-space:var(--ran-select-selection-item-white-space, nowrap);text-overflow:var(--ran-select-selection-item-text-overflow, ellipsis);cursor:var(--ran-select-selection-item-cursor, pointer)}.ran-select .selection-select{color:var(--ran-select-selection-select-color, var(--ran-color-text-disabled, rgba(0, 0, 0, .25)))}.ran-select .selection .icon{display:var(--ran-select-selection-icon-display, flex);align-items:var(--ran-select-selection-icon-align-items, center);color:var(--ran-select-selection-icon-color, var(--ran-color-text-disabled, rgba(0, 0, 0, .25)));font-style:var(--ran-select-selection-icon-font-style, normal);text-align:var(--ran-select-selection-icon-text-align, center);text-transform:var(--ran-select-selection-icon-text-transform, none);text-rendering:var(--ran-select-selection-icon-text-rendering, optimizeLegibility);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;position:var(--ran-select-selection-icon-position, absolute);top:var(--ran-select-selection-icon-top, 50%);inset-inline-start:var(--ran-select-selection-icon-inset-inline-start, auto);inset-inline-end:var(--ran-select-selection-icon-inset-inline-end, 8px);height:var(--ran-select-selection-icon-height, 16px);transform:var(--ran-select-selection-icon-transform, translateY(-50%));margin-top:var(--ran-select-selection-icon-margin-top, 0);font-size:var(--ran-select-selection-icon-font-size, 12px);pointer-events:var(--ran-select-selection-icon-pointer-events, none)}',af={success:!0,_identification:!0,data:`<svg viewBox="0 0 1024 1024" width="200" height="200" version="1.1"
31
31
  fill="currentColor" xmlns="http://www.w3.org/2000/svg">
32
32
  <path
33
33
  d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"></path>
@@ -292,4 +292,4 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
292
292
  ?)[ \r ]*`,An="[̀-ͯ]",Fh=new RegExp(An+"+$"),Oh="("+Ts+"+)|"+(Mh+"|")+"([!-\\[\\]-‧‪-퟿豈-￿]"+(An+"*")+"|[\uD800-\uDBFF][\uDC00-\uDFFF]"+(An+"*")+"|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5"+("|"+Lh)+("|"+Rh+")"),Ds=class{constructor(e,i){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=i,this.tokenRegex=new RegExp(Oh,"g"),this.catcodes={"%":14,"~":13}}setCatcode(e,i){this.catcodes[e]=i}lex(){var e=this.input,i=this.tokenRegex.lastIndex;if(i===e.length)return new _t("EOF",new Gt(this,i,i));var n=this.tokenRegex.exec(e);if(n===null||n.index!==i)throw new ae("Unexpected character: '"+e[i]+"'",new _t(e[i],new Gt(this,i,i+1)));var c=n[6]||n[3]||(n[2]?"\\ ":" ");if(this.catcodes[c]===14){var g=e.indexOf(`
293
293
  `,this.tokenRegex.lastIndex);return g===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict("commentAtEnd","% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")):this.tokenRegex.lastIndex=g+1,this.lex()}return new _t(c,new Gt(this,i,this.tokenRegex.lastIndex))}},Ph=class{constructor(e,i){e===void 0&&(e={}),i===void 0&&(i={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=i,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new ae("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");var e=this.undefStack.pop();for(var i in e)e.hasOwnProperty(i)&&(e[i]==null?delete this.current[i]:this.current[i]=e[i])}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return this.current.hasOwnProperty(e)||this.builtins.hasOwnProperty(e)}get(e){return this.current.hasOwnProperty(e)?this.current[e]:this.builtins[e]}set(e,i,n){if(n===void 0&&(n=!1),n){for(var c=0;c<this.undefStack.length;c++)delete this.undefStack[c][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=i)}else{var g=this.undefStack[this.undefStack.length-1];g&&!g.hasOwnProperty(e)&&(g[e]=this.current[e])}i==null?delete this.current[e]:this.current[e]=i}},Uh=ss,L("\\noexpand",function(e){var i=e.popToken();return e.isExpandable(i.text)&&(i.noexpand=!0,i.treatAsRelax=!0),{tokens:[i],numArgs:0}}),L("\\expandafter",function(e){var i=e.popToken();return e.expandOnce(!0),{tokens:[i],numArgs:0}}),L("\\@firstoftwo",function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),L("\\@secondoftwo",function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),L("\\@ifnextchar",function(e){var i=e.consumeArgs(3);e.consumeSpaces();var n=e.future();return i[0].length===1&&i[0][0].text===n.text?{tokens:i[1],numArgs:0}:{tokens:i[2],numArgs:0}}),L("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),L("\\TextOrMath",function(e){var i=e.consumeArgs(2);return e.mode==="text"?{tokens:i[0],numArgs:0}:{tokens:i[1],numArgs:0}}),Rs={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15},L("\\char",function(e){var i=e.popToken(),n,c="";if(i.text==="'")n=8,i=e.popToken();else if(i.text==='"')n=16,i=e.popToken();else if(i.text==="`")if(i=e.popToken(),i.text[0]==="\\")c=i.text.charCodeAt(1);else{if(i.text==="EOF")throw new ae("\\char` missing argument");c=i.text.charCodeAt(0)}else n=10;if(n){if(c=Rs[i.text],c==null||c>=n)throw new ae("Invalid base-"+n+" digit "+i.text);for(var g;(g=Rs[e.future().text])!=null&&g<n;)c*=n,c+=g,e.popToken()}return"\\@char{"+c+"}"}),bn=(e,i,n)=>{var c=e.consumeArg().tokens;if(c.length!==1)throw new ae("\\newcommand's first argument must be a macro name");var g=c[0].text,m=e.isDefined(g);if(m&&!i)throw new ae("\\newcommand{"+g+"} attempting to redefine "+(g+"; use \\renewcommand"));if(!m&&!n)throw new ae("\\renewcommand{"+g+"} when command "+g+" does not yet exist; use \\newcommand");var b=0;if(c=e.consumeArg().tokens,c.length===1&&c[0].text==="["){for(var E="",R=e.expandNextToken();R.text!=="]"&&R.text!=="EOF";)E+=R.text,R=e.expandNextToken();if(!E.match(/^\s*[0-9]+\s*$/))throw new ae("Invalid number of arguments: "+E);b=parseInt(E),c=e.consumeArg().tokens}return e.macros.set(g,{tokens:c,numArgs:b}),""},L("\\newcommand",e=>bn(e,!1,!0)),L("\\renewcommand",e=>bn(e,!0,!1)),L("\\providecommand",e=>bn(e,!0,!0)),L("\\message",e=>(e.consumeArgs(1)[0].reverse().map(i=>i.text).join(""),"")),L("\\errmessage",e=>{var i=e.consumeArgs(1)[0];return console.error(i.reverse().map(n=>n.text).join("")),""}),L("\\show",e=>{var i=e.popToken().text;return e.macros.get(i),Rr[i],et.math[i],et.text[i],""}),L("\\bgroup","{"),L("\\egroup","}"),L("~","\\nobreakspace"),L("\\lq","`"),L("\\rq","'"),L("\\aa","\\r a"),L("\\AA","\\r A"),L("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`©}"),L("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"),L("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"),L("ℬ","\\mathscr{B}"),L("ℰ","\\mathscr{E}"),L("ℱ","\\mathscr{F}"),L("ℋ","\\mathscr{H}"),L("ℐ","\\mathscr{I}"),L("ℒ","\\mathscr{L}"),L("ℳ","\\mathscr{M}"),L("ℛ","\\mathscr{R}"),L("ℭ","\\mathfrak{C}"),L("ℌ","\\mathfrak{H}"),L("ℨ","\\mathfrak{Z}"),L("\\Bbbk","\\Bbb{k}"),L("·","\\cdotp"),L("\\llap","\\mathllap{\\textrm{#1}}"),L("\\rlap","\\mathrlap{\\textrm{#1}}"),L("\\clap","\\mathclap{\\textrm{#1}}"),L("\\mathstrut","\\vphantom{(}"),L("\\underbar","\\underline{\\text{#1}}"),L("\\not",'\\html@mathml{\\mathrel{\\mathrlap\\@not}}{\\char"338}'),L("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"),L("\\ne","\\neq"),L("≠","\\neq"),L("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}"),L("∉","\\notin"),L("≘","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}"),L("≙","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}"),L("≚","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}"),L("≛","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}"),L("≝","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}"),L("≞","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}"),L("≟","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}"),L("⟂","\\perp"),L("‼","\\mathclose{!\\mkern-0.8mu!}"),L("∌","\\notni"),L("⌜","\\ulcorner"),L("⌝","\\urcorner"),L("⌞","\\llcorner"),L("⌟","\\lrcorner"),L("©","\\copyright"),L("®","\\textregistered"),L("️","\\textregistered"),L("\\ulcorner",'\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}'),L("\\urcorner",'\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}'),L("\\llcorner",'\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}'),L("\\lrcorner",'\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}'),L("\\vdots","\\mathord{\\varvdots\\rule{0pt}{15pt}}"),L("⋮","\\vdots"),L("\\varGamma","\\mathit{\\Gamma}"),L("\\varDelta","\\mathit{\\Delta}"),L("\\varTheta","\\mathit{\\Theta}"),L("\\varLambda","\\mathit{\\Lambda}"),L("\\varXi","\\mathit{\\Xi}"),L("\\varPi","\\mathit{\\Pi}"),L("\\varSigma","\\mathit{\\Sigma}"),L("\\varUpsilon","\\mathit{\\Upsilon}"),L("\\varPhi","\\mathit{\\Phi}"),L("\\varPsi","\\mathit{\\Psi}"),L("\\varOmega","\\mathit{\\Omega}"),L("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),L("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"),L("\\boxed","\\fbox{$\\displaystyle{#1}$}"),L("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),L("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),L("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;"),Ls={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcup":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"},L("\\dots",function(e){var i="\\dotso",n=e.expandAfterFuture().text;return n in Ls?i=Ls[n]:(n.slice(0,4)==="\\not"||n in et.math&&ye.contains(["bin","rel"],et.math[n].group))&&(i="\\dotsb"),i}),yn={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0},L("\\dotso",function(e){return e.future().text in yn?"\\ldots\\,":"\\ldots"}),L("\\dotsc",function(e){var i=e.future().text;return i in yn&&i!==","?"\\ldots\\,":"\\ldots"}),L("\\cdots",function(e){return e.future().text in yn?"\\@cdots\\,":"\\@cdots"}),L("\\dotsb","\\cdots"),L("\\dotsm","\\cdots"),L("\\dotsi","\\!\\cdots"),L("\\dotsx","\\ldots\\,"),L("\\DOTSI","\\relax"),L("\\DOTSB","\\relax"),L("\\DOTSX","\\relax"),L("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),L("\\,","\\tmspace+{3mu}{.1667em}"),L("\\thinspace","\\,"),L("\\>","\\mskip{4mu}"),L("\\:","\\tmspace+{4mu}{.2222em}"),L("\\medspace","\\:"),L("\\;","\\tmspace+{5mu}{.2777em}"),L("\\thickspace","\\;"),L("\\!","\\tmspace-{3mu}{.1667em}"),L("\\negthinspace","\\!"),L("\\negmedspace","\\tmspace-{4mu}{.2222em}"),L("\\negthickspace","\\tmspace-{5mu}{.277em}"),L("\\enspace","\\kern.5em "),L("\\enskip","\\hskip.5em\\relax"),L("\\quad","\\hskip1em\\relax"),L("\\qquad","\\hskip2em\\relax"),L("\\tag","\\@ifstar\\tag@literal\\tag@paren"),L("\\tag@paren","\\tag@literal{({#1})}"),L("\\tag@literal",e=>{if(e.macros.get("\\df@tag"))throw new ae("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"}),L("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"),L("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),L("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),L("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),L("\\newline","\\\\\\relax"),L("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}"),Ms=oe(Zt["Main-Regular"][84][1]-.7*Zt["Main-Regular"][65][1]),L("\\LaTeX","\\textrm{\\html@mathml{"+("L\\kern-.36em\\raisebox{"+Ms+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{LaTeX}}"),L("\\KaTeX","\\textrm{\\html@mathml{"+("K\\kern-.17em\\raisebox{"+Ms+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{KaTeX}}"),L("\\hspace","\\@ifstar\\@hspacer\\@hspace"),L("\\@hspace","\\hskip #1\\relax"),L("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),L("\\ordinarycolon",":"),L("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}"),L("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}'),L("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}'),L("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}'),L("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}'),L("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}'),L("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}'),L("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}'),L("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}'),L("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}'),L("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}'),L("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}'),L("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}'),L("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}'),L("∷","\\dblcolon"),L("∹","\\eqcolon"),L("≔","\\coloneqq"),L("≕","\\eqqcolon"),L("⩴","\\Coloneqq"),L("\\ratio","\\vcentcolon"),L("\\coloncolon","\\dblcolon"),L("\\colonequals","\\coloneqq"),L("\\coloncolonequals","\\Coloneqq"),L("\\equalscolon","\\eqqcolon"),L("\\equalscoloncolon","\\Eqqcolon"),L("\\colonminus","\\coloneq"),L("\\coloncolonminus","\\Coloneq"),L("\\minuscolon","\\eqcolon"),L("\\minuscoloncolon","\\Eqcolon"),L("\\coloncolonapprox","\\Colonapprox"),L("\\coloncolonsim","\\Colonsim"),L("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),L("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"),L("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),L("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"),L("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}"),L("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),L("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),L("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),L("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),L("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}"),L("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}"),L("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}"),L("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}"),L("\\gvertneqq","\\html@mathml{\\@gvertneqq}{≩}"),L("\\lvertneqq","\\html@mathml{\\@lvertneqq}{≨}"),L("\\ngeqq","\\html@mathml{\\@ngeqq}{≱}"),L("\\ngeqslant","\\html@mathml{\\@ngeqslant}{≱}"),L("\\nleqq","\\html@mathml{\\@nleqq}{≰}"),L("\\nleqslant","\\html@mathml{\\@nleqslant}{≰}"),L("\\nshortmid","\\html@mathml{\\@nshortmid}{∤}"),L("\\nshortparallel","\\html@mathml{\\@nshortparallel}{∦}"),L("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{⊈}"),L("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{⊉}"),L("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{⊊}"),L("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{⫋}"),L("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{⊋}"),L("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{⫌}"),L("\\imath","\\html@mathml{\\@imath}{ı}"),L("\\jmath","\\html@mathml{\\@jmath}{ȷ}"),L("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}"),L("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}"),L("⟦","\\llbracket"),L("⟧","\\rrbracket"),L("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}"),L("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}"),L("⦃","\\lBrace"),L("⦄","\\rBrace"),L("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}"),L("⦵","\\minuso"),L("\\darr","\\downarrow"),L("\\dArr","\\Downarrow"),L("\\Darr","\\Downarrow"),L("\\lang","\\langle"),L("\\rang","\\rangle"),L("\\uarr","\\uparrow"),L("\\uArr","\\Uparrow"),L("\\Uarr","\\Uparrow"),L("\\N","\\mathbb{N}"),L("\\R","\\mathbb{R}"),L("\\Z","\\mathbb{Z}"),L("\\alef","\\aleph"),L("\\alefsym","\\aleph"),L("\\Alpha","\\mathrm{A}"),L("\\Beta","\\mathrm{B}"),L("\\bull","\\bullet"),L("\\Chi","\\mathrm{X}"),L("\\clubs","\\clubsuit"),L("\\cnums","\\mathbb{C}"),L("\\Complex","\\mathbb{C}"),L("\\Dagger","\\ddagger"),L("\\diamonds","\\diamondsuit"),L("\\empty","\\emptyset"),L("\\Epsilon","\\mathrm{E}"),L("\\Eta","\\mathrm{H}"),L("\\exist","\\exists"),L("\\harr","\\leftrightarrow"),L("\\hArr","\\Leftrightarrow"),L("\\Harr","\\Leftrightarrow"),L("\\hearts","\\heartsuit"),L("\\image","\\Im"),L("\\infin","\\infty"),L("\\Iota","\\mathrm{I}"),L("\\isin","\\in"),L("\\Kappa","\\mathrm{K}"),L("\\larr","\\leftarrow"),L("\\lArr","\\Leftarrow"),L("\\Larr","\\Leftarrow"),L("\\lrarr","\\leftrightarrow"),L("\\lrArr","\\Leftrightarrow"),L("\\Lrarr","\\Leftrightarrow"),L("\\Mu","\\mathrm{M}"),L("\\natnums","\\mathbb{N}"),L("\\Nu","\\mathrm{N}"),L("\\Omicron","\\mathrm{O}"),L("\\plusmn","\\pm"),L("\\rarr","\\rightarrow"),L("\\rArr","\\Rightarrow"),L("\\Rarr","\\Rightarrow"),L("\\real","\\Re"),L("\\reals","\\mathbb{R}"),L("\\Reals","\\mathbb{R}"),L("\\Rho","\\mathrm{P}"),L("\\sdot","\\cdot"),L("\\sect","\\S"),L("\\spades","\\spadesuit"),L("\\sub","\\subset"),L("\\sube","\\subseteq"),L("\\supe","\\supseteq"),L("\\Tau","\\mathrm{T}"),L("\\thetasym","\\vartheta"),L("\\weierp","\\wp"),L("\\Zeta","\\mathrm{Z}"),L("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),L("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),L("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits"),L("\\bra","\\mathinner{\\langle{#1}|}"),L("\\ket","\\mathinner{|{#1}\\rangle}"),L("\\braket","\\mathinner{\\langle{#1}\\rangle}"),L("\\Bra","\\left\\langle#1\\right|"),L("\\Ket","\\left|#1\\right\\rangle"),Fs=e=>i=>{var n=i.consumeArg().tokens,c=i.consumeArg().tokens,g=i.consumeArg().tokens,m=i.consumeArg().tokens,b=i.macros.get("|"),E=i.macros.get("\\|");i.macros.beginGroup();var R=Y=>X=>{e&&(X.macros.set("|",b),g.length&&X.macros.set("\\|",E));var _=Y;return!Y&&g.length&&X.future().text==="|"&&(X.popToken(),_=!0),{tokens:_?g:c,numArgs:0}};i.macros.set("|",R(!1)),g.length&&i.macros.set("\\|",R(!0));var F=i.consumeArg().tokens,Q=i.expandTokens([...m,...F,...n]);return i.macros.endGroup(),{tokens:Q.reverse(),numArgs:0}},L("\\bra@ket",Fs(!1)),L("\\bra@set",Fs(!0)),L("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"),L("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"),L("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"),L("\\angln","{\\angl n}"),L("\\blue","\\textcolor{##6495ed}{#1}"),L("\\orange","\\textcolor{##ffa500}{#1}"),L("\\pink","\\textcolor{##ff00af}{#1}"),L("\\red","\\textcolor{##df0030}{#1}"),L("\\green","\\textcolor{##28ae7b}{#1}"),L("\\gray","\\textcolor{gray}{#1}"),L("\\purple","\\textcolor{##9d38bd}{#1}"),L("\\blueA","\\textcolor{##ccfaff}{#1}"),L("\\blueB","\\textcolor{##80f6ff}{#1}"),L("\\blueC","\\textcolor{##63d9ea}{#1}"),L("\\blueD","\\textcolor{##11accd}{#1}"),L("\\blueE","\\textcolor{##0c7f99}{#1}"),L("\\tealA","\\textcolor{##94fff5}{#1}"),L("\\tealB","\\textcolor{##26edd5}{#1}"),L("\\tealC","\\textcolor{##01d1c1}{#1}"),L("\\tealD","\\textcolor{##01a995}{#1}"),L("\\tealE","\\textcolor{##208170}{#1}"),L("\\greenA","\\textcolor{##b6ffb0}{#1}"),L("\\greenB","\\textcolor{##8af281}{#1}"),L("\\greenC","\\textcolor{##74cf70}{#1}"),L("\\greenD","\\textcolor{##1fab54}{#1}"),L("\\greenE","\\textcolor{##0d923f}{#1}"),L("\\goldA","\\textcolor{##ffd0a9}{#1}"),L("\\goldB","\\textcolor{##ffbb71}{#1}"),L("\\goldC","\\textcolor{##ff9c39}{#1}"),L("\\goldD","\\textcolor{##e07d10}{#1}"),L("\\goldE","\\textcolor{##a75a05}{#1}"),L("\\redA","\\textcolor{##fca9a9}{#1}"),L("\\redB","\\textcolor{##ff8482}{#1}"),L("\\redC","\\textcolor{##f9685d}{#1}"),L("\\redD","\\textcolor{##e84d39}{#1}"),L("\\redE","\\textcolor{##bc2612}{#1}"),L("\\maroonA","\\textcolor{##ffbde0}{#1}"),L("\\maroonB","\\textcolor{##ff92c6}{#1}"),L("\\maroonC","\\textcolor{##ed5fa6}{#1}"),L("\\maroonD","\\textcolor{##ca337c}{#1}"),L("\\maroonE","\\textcolor{##9e034e}{#1}"),L("\\purpleA","\\textcolor{##ddd7ff}{#1}"),L("\\purpleB","\\textcolor{##c6b9fc}{#1}"),L("\\purpleC","\\textcolor{##aa87ff}{#1}"),L("\\purpleD","\\textcolor{##7854ab}{#1}"),L("\\purpleE","\\textcolor{##543b78}{#1}"),L("\\mintA","\\textcolor{##f5f9e8}{#1}"),L("\\mintB","\\textcolor{##edf2df}{#1}"),L("\\mintC","\\textcolor{##e0e5cc}{#1}"),L("\\grayA","\\textcolor{##f6f7f7}{#1}"),L("\\grayB","\\textcolor{##f0f1f2}{#1}"),L("\\grayC","\\textcolor{##e3e5e6}{#1}"),L("\\grayD","\\textcolor{##d6d8da}{#1}"),L("\\grayE","\\textcolor{##babec2}{#1}"),L("\\grayF","\\textcolor{##888d93}{#1}"),L("\\grayG","\\textcolor{##626569}{#1}"),L("\\grayH","\\textcolor{##3b3e40}{#1}"),L("\\grayI","\\textcolor{##21242c}{#1}"),L("\\kaBlue","\\textcolor{##314453}{#1}"),L("\\kaGreen","\\textcolor{##71B307}{#1}"),Os={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},Qh=class{constructor(e,i,n){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=i,this.expansionCount=0,this.feed(e),this.macros=new Ph(Uh,i.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new Ds(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var i,n,c;if(e){if(this.consumeSpaces(),this.future().text!=="[")return null;i=this.popToken(),{tokens:c,end:n}=this.consumeArg(["]"])}else({tokens:c,start:i,end:n}=this.consumeArg());return this.pushToken(new _t("EOF",n.loc)),this.pushTokens(c),i.range(n,"")}consumeSpaces(){for(;this.future().text===" ";)this.stack.pop()}consumeArg(e){var i=[],n=e&&e.length>0;n||this.consumeSpaces();var c=this.future(),g,m=0,b=0;do{if(g=this.popToken(),i.push(g),g.text==="{")++m;else if(g.text==="}"){if(--m,m===-1)throw new ae("Extra }",g)}else if(g.text==="EOF")throw new ae("Unexpected end of input in a macro argument, expected '"+(e&&n?e[b]:"}")+"'",g);if(e&&n)if((m===0||m===1&&e[b]==="{")&&g.text===e[b]){if(++b,b===e.length){i.splice(-b,b);break}}else b=0}while(m!==0||n);return c.text==="{"&&i[i.length-1].text==="}"&&(i.pop(),i.shift()),i.reverse(),{tokens:i,start:c,end:g}}consumeArgs(e,i){if(i){if(i.length!==e+1)throw new ae("The length of delimiters doesn't match the number of args!");for(var n=i[0],c=0;c<n.length;c++){var g=this.popToken();if(n[c]!==g.text)throw new ae("Use of the macro doesn't match its definition",g)}}for(var m=[],b=0;b<e;b++)m.push(this.consumeArg(i&&i[b+1]).tokens);return m}countExpansion(e){if(this.expansionCount+=e,this.expansionCount>this.settings.maxExpand)throw new ae("Too many expansions: infinite loop or need to increase maxExpand setting")}expandOnce(e){var i=this.popToken(),n=i.text,c=i.noexpand?null:this._getExpansion(n);if(c==null||e&&c.unexpandable){if(e&&c==null&&n[0]==="\\"&&!this.isDefined(n))throw new ae("Undefined control sequence: "+n);return this.pushToken(i),!1}this.countExpansion(1);var g=c.tokens,m=this.consumeArgs(c.numArgs,c.delimiters);if(c.numArgs){g=g.slice();for(var b=g.length-1;b>=0;--b){var E=g[b];if(E.text==="#"){if(b===0)throw new ae("Incomplete placeholder at end of macro body",E);if(E=g[--b],E.text==="#")g.splice(b+1,1);else if(/^[1-9]$/.test(E.text))g.splice(b,2,...m[+E.text-1]);else throw new ae("Not a valid argument number",E)}}}return this.pushTokens(g),g.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text="\\relax"),e}throw new Error}expandMacro(e){return this.macros.has(e)?this.expandTokens([new _t(e)]):void 0}expandTokens(e){var i=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){var c=this.stack.pop();c.treatAsRelax&&(c.noexpand=!1,c.treatAsRelax=!1),i.push(c)}return this.countExpansion(i.length),i}expandMacroAsText(e){var i=this.expandMacro(e);return i&&i.map(n=>n.text).join("")}_getExpansion(e){var i=this.macros.get(e);if(i==null)return i;if(e.length===1){var n=this.lexer.catcodes[e];if(n!=null&&n!==13)return}var c=typeof i=="function"?i(this):i;if(typeof c=="string"){var g=0;if(c.indexOf("#")!==-1)for(var m=c.replace(/##/g,"");m.indexOf("#"+(g+1))!==-1;)++g;for(var b=new Ds(c,this.settings),E=[],R=b.lex();R.text!=="EOF";)E.push(R),R=b.lex();return E.reverse(),{tokens:E,numArgs:g}}return c}isDefined(e){return this.macros.has(e)||Rr.hasOwnProperty(e)||et.math.hasOwnProperty(e)||et.text.hasOwnProperty(e)||Os.hasOwnProperty(e)}isExpandable(e){var i=this.macros.get(e);return i!=null?typeof i=="string"||typeof i=="function"||!i.unexpandable:Rr.hasOwnProperty(e)&&!Rr[e].primitive}},Ps=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,ha=Object.freeze({"₊":"+","₋":"-","₌":"=","₍":"(","₎":")","₀":"0","₁":"1","₂":"2","₃":"3","₄":"4","₅":"5","₆":"6","₇":"7","₈":"8","₉":"9","ₐ":"a","ₑ":"e","ₕ":"h","ᵢ":"i","ⱼ":"j","ₖ":"k","ₗ":"l","ₘ":"m","ₙ":"n","ₒ":"o","ₚ":"p","ᵣ":"r","ₛ":"s","ₜ":"t","ᵤ":"u","ᵥ":"v","ₓ":"x","ᵦ":"β","ᵧ":"γ","ᵨ":"ρ","ᵩ":"ϕ","ᵪ":"χ","⁺":"+","⁻":"-","⁼":"=","⁽":"(","⁾":")","⁰":"0","¹":"1","²":"2","³":"3","⁴":"4","⁵":"5","⁶":"6","⁷":"7","⁸":"8","⁹":"9","ᴬ":"A","ᴮ":"B","ᴰ":"D","ᴱ":"E","ᴳ":"G","ᴴ":"H","ᴵ":"I","ᴶ":"J","ᴷ":"K","ᴸ":"L","ᴹ":"M","ᴺ":"N","ᴼ":"O","ᴾ":"P","ᴿ":"R","ᵀ":"T","ᵁ":"U","ⱽ":"V","ᵂ":"W","ᵃ":"a","ᵇ":"b","ᶜ":"c","ᵈ":"d","ᵉ":"e","ᶠ":"f","ᵍ":"g",ʰ:"h","ⁱ":"i",ʲ:"j","ᵏ":"k",ˡ:"l","ᵐ":"m",ⁿ:"n","ᵒ":"o","ᵖ":"p",ʳ:"r",ˢ:"s","ᵗ":"t","ᵘ":"u","ᵛ":"v",ʷ:"w",ˣ:"x",ʸ:"y","ᶻ":"z","ᵝ":"β","ᵞ":"γ","ᵟ":"δ","ᵠ":"ϕ","ᵡ":"χ","ᶿ":"θ"}),wn={"́":{text:"\\'",math:"\\acute"},"̀":{text:"\\`",math:"\\grave"},"̈":{text:'\\"',math:"\\ddot"},"̃":{text:"\\~",math:"\\tilde"},"̄":{text:"\\=",math:"\\bar"},"̆":{text:"\\u",math:"\\breve"},"̌":{text:"\\v",math:"\\check"},"̂":{text:"\\^",math:"\\hat"},"̇":{text:"\\.",math:"\\dot"},"̊":{text:"\\r",math:"\\mathring"},"̋":{text:"\\H"},"̧":{text:"\\c"}},Us={á:"á",à:"à",ä:"ä",ǟ:"ǟ",ã:"ã",ā:"ā",ă:"ă",ắ:"ắ",ằ:"ằ",ẵ:"ẵ",ǎ:"ǎ",â:"â",ấ:"ấ",ầ:"ầ",ẫ:"ẫ",ȧ:"ȧ",ǡ:"ǡ",å:"å",ǻ:"ǻ",ḃ:"ḃ",ć:"ć",ḉ:"ḉ",č:"č",ĉ:"ĉ",ċ:"ċ",ç:"ç",ď:"ď",ḋ:"ḋ",ḑ:"ḑ",é:"é",è:"è",ë:"ë",ẽ:"ẽ",ē:"ē",ḗ:"ḗ",ḕ:"ḕ",ĕ:"ĕ",ḝ:"ḝ",ě:"ě",ê:"ê",ế:"ế",ề:"ề",ễ:"ễ",ė:"ė",ȩ:"ȩ",ḟ:"ḟ",ǵ:"ǵ",ḡ:"ḡ",ğ:"ğ",ǧ:"ǧ",ĝ:"ĝ",ġ:"ġ",ģ:"ģ",ḧ:"ḧ",ȟ:"ȟ",ĥ:"ĥ",ḣ:"ḣ",ḩ:"ḩ",í:"í",ì:"ì",ï:"ï",ḯ:"ḯ",ĩ:"ĩ",ī:"ī",ĭ:"ĭ",ǐ:"ǐ",î:"î",ǰ:"ǰ",ĵ:"ĵ",ḱ:"ḱ",ǩ:"ǩ",ķ:"ķ",ĺ:"ĺ",ľ:"ľ",ļ:"ļ",ḿ:"ḿ",ṁ:"ṁ",ń:"ń",ǹ:"ǹ",ñ:"ñ",ň:"ň",ṅ:"ṅ",ņ:"ņ",ó:"ó",ò:"ò",ö:"ö",ȫ:"ȫ",õ:"õ",ṍ:"ṍ",ṏ:"ṏ",ȭ:"ȭ",ō:"ō",ṓ:"ṓ",ṑ:"ṑ",ŏ:"ŏ",ǒ:"ǒ",ô:"ô",ố:"ố",ồ:"ồ",ỗ:"ỗ",ȯ:"ȯ",ȱ:"ȱ",ő:"ő",ṕ:"ṕ",ṗ:"ṗ",ŕ:"ŕ",ř:"ř",ṙ:"ṙ",ŗ:"ŗ",ś:"ś",ṥ:"ṥ",š:"š",ṧ:"ṧ",ŝ:"ŝ",ṡ:"ṡ",ş:"ş",ẗ:"ẗ",ť:"ť",ṫ:"ṫ",ţ:"ţ",ú:"ú",ù:"ù",ü:"ü",ǘ:"ǘ",ǜ:"ǜ",ǖ:"ǖ",ǚ:"ǚ",ũ:"ũ",ṹ:"ṹ",ū:"ū",ṻ:"ṻ",ŭ:"ŭ",ǔ:"ǔ",û:"û",ů:"ů",ű:"ű",ṽ:"ṽ",ẃ:"ẃ",ẁ:"ẁ",ẅ:"ẅ",ŵ:"ŵ",ẇ:"ẇ",ẘ:"ẘ",ẍ:"ẍ",ẋ:"ẋ",ý:"ý",ỳ:"ỳ",ÿ:"ÿ",ỹ:"ỹ",ȳ:"ȳ",ŷ:"ŷ",ẏ:"ẏ",ẙ:"ẙ",ź:"ź",ž:"ž",ẑ:"ẑ",ż:"ż",Á:"Á",À:"À",Ä:"Ä",Ǟ:"Ǟ",Ã:"Ã",Ā:"Ā",Ă:"Ă",Ắ:"Ắ",Ằ:"Ằ",Ẵ:"Ẵ",Ǎ:"Ǎ",Â:"Â",Ấ:"Ấ",Ầ:"Ầ",Ẫ:"Ẫ",Ȧ:"Ȧ",Ǡ:"Ǡ",Å:"Å",Ǻ:"Ǻ",Ḃ:"Ḃ",Ć:"Ć",Ḉ:"Ḉ",Č:"Č",Ĉ:"Ĉ",Ċ:"Ċ",Ç:"Ç",Ď:"Ď",Ḋ:"Ḋ",Ḑ:"Ḑ",É:"É",È:"È",Ë:"Ë",Ẽ:"Ẽ",Ē:"Ē",Ḗ:"Ḗ",Ḕ:"Ḕ",Ĕ:"Ĕ",Ḝ:"Ḝ",Ě:"Ě",Ê:"Ê",Ế:"Ế",Ề:"Ề",Ễ:"Ễ",Ė:"Ė",Ȩ:"Ȩ",Ḟ:"Ḟ",Ǵ:"Ǵ",Ḡ:"Ḡ",Ğ:"Ğ",Ǧ:"Ǧ",Ĝ:"Ĝ",Ġ:"Ġ",Ģ:"Ģ",Ḧ:"Ḧ",Ȟ:"Ȟ",Ĥ:"Ĥ",Ḣ:"Ḣ",Ḩ:"Ḩ",Í:"Í",Ì:"Ì",Ï:"Ï",Ḯ:"Ḯ",Ĩ:"Ĩ",Ī:"Ī",Ĭ:"Ĭ",Ǐ:"Ǐ",Î:"Î",İ:"İ",Ĵ:"Ĵ",Ḱ:"Ḱ",Ǩ:"Ǩ",Ķ:"Ķ",Ĺ:"Ĺ",Ľ:"Ľ",Ļ:"Ļ",Ḿ:"Ḿ",Ṁ:"Ṁ",Ń:"Ń",Ǹ:"Ǹ",Ñ:"Ñ",Ň:"Ň",Ṅ:"Ṅ",Ņ:"Ņ",Ó:"Ó",Ò:"Ò",Ö:"Ö",Ȫ:"Ȫ",Õ:"Õ",Ṍ:"Ṍ",Ṏ:"Ṏ",Ȭ:"Ȭ",Ō:"Ō",Ṓ:"Ṓ",Ṑ:"Ṑ",Ŏ:"Ŏ",Ǒ:"Ǒ",Ô:"Ô",Ố:"Ố",Ồ:"Ồ",Ỗ:"Ỗ",Ȯ:"Ȯ",Ȱ:"Ȱ",Ő:"Ő",Ṕ:"Ṕ",Ṗ:"Ṗ",Ŕ:"Ŕ",Ř:"Ř",Ṙ:"Ṙ",Ŗ:"Ŗ",Ś:"Ś",Ṥ:"Ṥ",Š:"Š",Ṧ:"Ṧ",Ŝ:"Ŝ",Ṡ:"Ṡ",Ş:"Ş",Ť:"Ť",Ṫ:"Ṫ",Ţ:"Ţ",Ú:"Ú",Ù:"Ù",Ü:"Ü",Ǘ:"Ǘ",Ǜ:"Ǜ",Ǖ:"Ǖ",Ǚ:"Ǚ",Ũ:"Ũ",Ṹ:"Ṹ",Ū:"Ū",Ṻ:"Ṻ",Ŭ:"Ŭ",Ǔ:"Ǔ",Û:"Û",Ů:"Ů",Ű:"Ű",Ṽ:"Ṽ",Ẃ:"Ẃ",Ẁ:"Ẁ",Ẅ:"Ẅ",Ŵ:"Ŵ",Ẇ:"Ẇ",Ẍ:"Ẍ",Ẋ:"Ẋ",Ý:"Ý",Ỳ:"Ỳ",Ÿ:"Ÿ",Ỹ:"Ỹ",Ȳ:"Ȳ",Ŷ:"Ŷ",Ẏ:"Ẏ",Ź:"Ź",Ž:"Ž",Ẑ:"Ẑ",Ż:"Ż",ά:"ά",ὰ:"ὰ",ᾱ:"ᾱ",ᾰ:"ᾰ",έ:"έ",ὲ:"ὲ",ή:"ή",ὴ:"ὴ",ί:"ί",ὶ:"ὶ",ϊ:"ϊ",ΐ:"ΐ",ῒ:"ῒ",ῑ:"ῑ",ῐ:"ῐ",ό:"ό",ὸ:"ὸ",ύ:"ύ",ὺ:"ὺ",ϋ:"ϋ",ΰ:"ΰ",ῢ:"ῢ",ῡ:"ῡ",ῠ:"ῠ",ώ:"ώ",ὼ:"ὼ",Ύ:"Ύ",Ὺ:"Ὺ",Ϋ:"Ϋ",Ῡ:"Ῡ",Ῠ:"Ῠ",Ώ:"Ώ",Ὼ:"Ὼ"},Qs=class i0{constructor(i,n){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode="math",this.gullet=new Qh(i,n,this.mode),this.settings=n,this.leftrightDepth=0}expect(i,n){if(n===void 0&&(n=!0),this.fetch().text!==i)throw new ae("Expected '"+i+"', got '"+this.fetch().text+"'",this.fetch());n&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken==null&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(i){this.mode=i,this.gullet.switchMode(i)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");try{var i=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),i}finally{this.gullet.endGroups()}}subparse(i){var n=this.nextToken;this.consume(),this.gullet.pushToken(new _t("}")),this.gullet.pushTokens(i);var c=this.parseExpression(!1);return this.expect("}"),this.nextToken=n,c}parseExpression(i,n){for(var c=[];;){this.mode==="math"&&this.consumeSpaces();var g=this.fetch();if(i0.endOfExpression.indexOf(g.text)!==-1||n&&g.text===n||i&&Rr[g.text]&&Rr[g.text].infix)break;var m=this.parseAtom(n);if(m){if(m.type==="internal")continue}else break;c.push(m)}return this.mode==="text"&&this.formLigatures(c),this.handleInfixNodes(c)}handleInfixNodes(i){for(var n=-1,c,g=0;g<i.length;g++)if(i[g].type==="infix"){if(n!==-1)throw new ae("only one infix operator per group",i[g].token);n=g,c=i[g].replaceWith}if(n!==-1&&c){var m,b,E=i.slice(0,n),R=i.slice(n+1);E.length===1&&E[0].type==="ordgroup"?m=E[0]:m={type:"ordgroup",mode:this.mode,body:E},R.length===1&&R[0].type==="ordgroup"?b=R[0]:b={type:"ordgroup",mode:this.mode,body:R};var F;return c==="\\\\abovefrac"?F=this.callFunction(c,[m,i[n],b],[]):F=this.callFunction(c,[m,b],[]),[F]}else return i}handleSupSubscript(i){var n=this.fetch(),c=n.text;this.consume(),this.consumeSpaces();var g=this.parseGroup(i);if(!g)throw new ae("Expected group after '"+c+"'",n);return g}formatUnsupportedCmd(i){for(var n=[],c=0;c<i.length;c++)n.push({type:"textord",mode:"text",text:i[c]});var g={type:"text",mode:this.mode,body:n};return{type:"color",mode:this.mode,color:this.settings.errorColor,body:[g]}}parseAtom(i){var n=this.parseGroup("atom",i);if(this.mode==="text")return n;for(var c,g;;){this.consumeSpaces();var m=this.fetch();if(m.text==="\\limits"||m.text==="\\nolimits"){if(n&&n.type==="op")n.limits=m.text==="\\limits",n.alwaysHandleSupSub=!0;else if(n&&n.type==="operatorname")n.alwaysHandleSupSub&&(n.limits=m.text==="\\limits");else throw new ae("Limit controls must follow a math operator",m);this.consume()}else if(m.text==="^"){if(c)throw new ae("Double superscript",m);c=this.handleSupSubscript("superscript")}else if(m.text==="_"){if(g)throw new ae("Double subscript",m);g=this.handleSupSubscript("subscript")}else if(m.text==="'"){if(c)throw new ae("Double superscript",m);var b={type:"textord",mode:this.mode,text:"\\prime"},E=[b];for(this.consume();this.fetch().text==="'";)E.push(b),this.consume();this.fetch().text==="^"&&E.push(this.handleSupSubscript("superscript")),c={type:"ordgroup",mode:this.mode,body:E}}else if(ha[m.text]){var R=Ps.test(m.text),F=[];for(F.push(new _t(ha[m.text])),this.consume();;){var Q=this.fetch().text;if(!ha[Q]||Ps.test(Q)!==R)break;F.unshift(new _t(ha[Q])),this.consume()}var Y=this.subparse(F);R?g={type:"ordgroup",mode:"math",body:Y}:c={type:"ordgroup",mode:"math",body:Y}}else break}return c||g?{type:"supsub",mode:this.mode,base:n,sup:c,sub:g}:n}parseFunction(i,n){var c=this.fetch(),g=c.text,m=Rr[g];if(!m)return null;if(this.consume(),n&&n!=="atom"&&!m.allowedInArgument)throw new ae("Got function '"+g+"' with no arguments"+(n?" as "+n:""),c);if(this.mode==="text"&&!m.allowedInText)throw new ae("Can't use function '"+g+"' in text mode",c);if(this.mode==="math"&&m.allowedInMath===!1)throw new ae("Can't use function '"+g+"' in math mode",c);var{args:b,optArgs:E}=this.parseArguments(g,m);return this.callFunction(g,b,E,c,i)}callFunction(i,n,c,g,m){var b={funcName:i,parser:this,token:g,breakOnTokenText:m},E=Rr[i];if(E&&E.handler)return E.handler(b,n,c);throw new ae("No function handler for "+i)}parseArguments(i,n){var c=n.numArgs+n.numOptionalArgs;if(c===0)return{args:[],optArgs:[]};for(var g=[],m=[],b=0;b<c;b++){var E=n.argTypes&&n.argTypes[b],R=b<n.numOptionalArgs;(n.primitive&&E==null||n.type==="sqrt"&&b===1&&m[0]==null)&&(E="primitive");var F=this.parseGroupOfType("argument to '"+i+"'",E,R);if(R)m.push(F);else if(F!=null)g.push(F);else throw new ae("Null argument, please report this as a bug")}return{args:g,optArgs:m}}parseGroupOfType(i,n,c){switch(n){case"color":return this.parseColorGroup(c);case"size":return this.parseSizeGroup(c);case"url":return this.parseUrlGroup(c);case"math":case"text":return this.parseArgumentGroup(c,n);case"hbox":var g=this.parseArgumentGroup(c,"text");return g!=null?{type:"styling",mode:g.mode,body:[g],style:"text"}:null;case"raw":var m=this.parseStringGroup("raw",c);return m!=null?{type:"raw",mode:"text",string:m.text}:null;case"primitive":if(c)throw new ae("A primitive argument cannot be optional");var b=this.parseGroup(i);if(b==null)throw new ae("Expected group as "+i,this.fetch());return b;case"original":case null:case void 0:return this.parseArgumentGroup(c);default:throw new ae("Unknown group type as "+i,this.fetch())}}consumeSpaces(){for(;this.fetch().text===" ";)this.consume()}parseStringGroup(i,n){var c=this.gullet.scanArgument(n);if(c==null)return null;for(var g="",m;(m=this.fetch()).text!=="EOF";)g+=m.text,this.consume();return this.consume(),c.text=g,c}parseRegexGroup(i,n){for(var c=this.fetch(),g=c,m="",b;(b=this.fetch()).text!=="EOF"&&i.test(m+b.text);)g=b,m+=g.text,this.consume();if(m==="")throw new ae("Invalid "+n+": '"+c.text+"'",c);return c.range(g,m)}parseColorGroup(i){var n=this.parseStringGroup("color",i);if(n==null)return null;var c=/^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i.exec(n.text);if(!c)throw new ae("Invalid color: '"+n.text+"'",n);var g=c[0];return/^[0-9a-f]{6}$/i.test(g)&&(g="#"+g),{type:"color-token",mode:this.mode,color:g}}parseSizeGroup(i){var n,c=!1;if(this.gullet.consumeSpaces(),!i&&this.gullet.future().text!=="{"?n=this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,"size"):n=this.parseStringGroup("size",i),!n)return null;!i&&n.text.length===0&&(n.text="0pt",c=!0);var g=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(n.text);if(!g)throw new ae("Invalid size: '"+n.text+"'",n);var m={number:+(g[1]+g[2]),unit:g[3]};if(!Bo(m))throw new ae("Invalid unit: '"+m.unit+"'",n);return{type:"size",mode:this.mode,value:m,isBlank:c}}parseUrlGroup(i){this.gullet.lexer.setCatcode("%",13),this.gullet.lexer.setCatcode("~",12);var n=this.parseStringGroup("url",i);if(this.gullet.lexer.setCatcode("%",14),this.gullet.lexer.setCatcode("~",13),n==null)return null;var c=n.text.replace(/\\([#$%&~_^{}])/g,"$1");return{type:"url",mode:this.mode,url:c}}parseArgumentGroup(i,n){var c=this.gullet.scanArgument(i);if(c==null)return null;var g=this.mode;n&&this.switchMode(n),this.gullet.beginGroup();var m=this.parseExpression(!1,"EOF");this.expect("EOF"),this.gullet.endGroup();var b={type:"ordgroup",mode:this.mode,loc:c.loc,body:m};return n&&this.switchMode(g),b}parseGroup(i,n){var c=this.fetch(),g=c.text,m;if(g==="{"||g==="\\begingroup"){this.consume();var b=g==="{"?"}":"\\endgroup";this.gullet.beginGroup();var E=this.parseExpression(!1,b),R=this.fetch();this.expect(b),this.gullet.endGroup(),m={type:"ordgroup",mode:this.mode,loc:Gt.range(c,R),body:E,semisimple:g==="\\begingroup"||void 0}}else if(m=this.parseFunction(n,i)||this.parseSymbol(),m==null&&g[0]==="\\"&&!Os.hasOwnProperty(g)){if(this.settings.throwOnError)throw new ae("Undefined control sequence: "+g,c);m=this.formatUnsupportedCmd(g),this.consume()}return m}formLigatures(i){for(var n=i.length-1,c=0;c<n;++c){var g=i[c],m=g.text;m==="-"&&i[c+1].text==="-"&&(c+1<n&&i[c+2].text==="-"?(i.splice(c,3,{type:"textord",mode:"text",loc:Gt.range(g,i[c+2]),text:"---"}),n-=2):(i.splice(c,2,{type:"textord",mode:"text",loc:Gt.range(g,i[c+1]),text:"--"}),n-=1)),(m==="'"||m==="`")&&i[c+1].text===m&&(i.splice(c,2,{type:"textord",mode:"text",loc:Gt.range(g,i[c+1]),text:m+m}),n-=1)}}parseSymbol(){var i=this.fetch(),n=i.text;if(/^\\verb[^a-zA-Z]/.test(n)){this.consume();var c=n.slice(5),g=c.charAt(0)==="*";if(g&&(c=c.slice(1)),c.length<2||c.charAt(0)!==c.slice(-1))throw new ae(`\\verb assertion failed --
294
294
  please report what input caused this bug`);return c=c.slice(1,-1),{type:"verb",mode:"text",body:c,star:g}}Us.hasOwnProperty(n[0])&&!et[this.mode][n[0]]&&(this.settings.strict&&this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Accented Unicode text character "'+n[0]+'" used in math mode',i),n=Us[n[0]]+n.slice(1));var m=Fh.exec(n);m&&(n=n.substring(0,m.index),n==="i"?n="ı":n==="j"&&(n="ȷ"));var b;if(et[this.mode][n]){this.settings.strict&&this.mode==="math"&&Ja.indexOf(n)>=0&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+n[0]+'" used in math mode',i);var E=et[this.mode][n].group,R=Gt.range(i),F;if(Ld.hasOwnProperty(E)){var Q=E;F={type:"atom",mode:this.mode,family:Q,loc:R,text:n}}else F={type:E,mode:this.mode,loc:R,text:n};b=F}else if(n.charCodeAt(0)>=128)this.settings.strict&&(Jc(n.charCodeAt(0))?this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+n[0]+'" used in math mode',i):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+n[0]+'"'+(" ("+n.charCodeAt(0)+")"),i)),b={type:"textord",mode:"text",loc:Gt.range(i),text:n};else return null;if(this.consume(),m)for(var Y=0;Y<m[0].length;Y++){var X=m[0][Y];if(!wn[X])throw new ae("Unknown accent ' "+X+"'",i);var _=wn[X][this.mode]||wn[X].text;if(!_)throw new ae("Accent "+X+" unsupported in "+this.mode+" mode",i);b={type:"accent",mode:this.mode,loc:Gt.range(i),label:_,isStretchy:!1,isShifty:!0,base:b}}return b}},Qs.endOfExpression=["}","\\endgroup","\\end","\\right","&"],Cn=function(i,n){if(!(typeof i=="string"||i instanceof String))throw new TypeError("KaTeX can only parse string typed expression");var c=new Qs(i,n);delete c.gullet.macros.current["\\df@tag"];var g=c.parse();if(delete c.gullet.macros.current["\\current@color"],delete c.gullet.macros.current["\\color"],c.gullet.macros.get("\\df@tag")){if(!n.displayMode)throw new ae("\\tag works only in display equations");g=[{type:"tag",mode:"text",body:g,tag:c.subparse([new _t("\\df@tag")])}]}return g},Ns=function(i,n,c){n.textContent="";var g=En(i,c).toNode();n.appendChild(g)},typeof document<"u"&&document.compatMode!=="CSS1Compat"&&(typeof console<"u"&&console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype."),Ns=function(){throw new ae("KaTeX doesn't work in quirks mode.")}),Nh=function(i,n){return En(i,n).toMarkup()},Hh=function(i,n){return Cn(i,new Na(n))},Hs=function(i,n,c){if(c.throwOnError||!(i instanceof ae))throw i;var g=z.makeSpan(["katex-error"],[new Pt(n)]);return g.setAttribute("title",i.toString()),g.setAttribute("style","color:"+c.errorColor),g},En=function(i,n){var c=new Na(n);try{return eh(Cn(i,c),i,c)}catch(g){return Hs(g,i,c)}},Gs={version:"0.16.11",render:Ns,renderToString:Nh,ParseError:ae,SETTINGS_SCHEMA:Wi,__parse:Hh,__renderToDomTree:En,__renderToHTMLTree:function(i,n){var c=new Na(n);try{return th(Cn(i,c),i,c)}catch(g){return Hs(g,i,c)}},__setFontMetrics:ap,__defineSymbol:A,__defineFunction:de,__defineMacro:L,__domTree:{Span:bi,Anchor:za,SymbolNode:Pt,SvgNode:dr,PathNode:xr,LineNode:qa}}})),dp=n0({default:()=>Ys,renderMathInElement:()=>Ys}),Gh,Yh,Kh,zh,qh,Vh,Ys,hp=Wl((()=>{cp(),Gh=function(i,n,c){for(var g=c,m=0,b=i.length;g<n.length;){var E=n[g];if(m<=0&&n.slice(g,g+b)===i)return g;E==="\\"?g++:E==="{"?m++:E==="}"&&m--,g++}return-1},Yh=function(i){return i.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")},Kh=/^\\begin{/,zh=function(i,n){for(var c,g=[],m=new RegExp("("+n.map(F=>Yh(F.left)).join("|")+")");c=i.search(m),c!==-1;){c>0&&(g.push({type:"text",data:i.slice(0,c)}),i=i.slice(c));var b=n.findIndex(F=>i.startsWith(F.left));if(c=Gh(n[b].right,i,n[b].left.length),c===-1)break;var E=i.slice(0,c+n[b].right.length),R=Kh.test(E)?E:i.slice(n[b].left.length,c);g.push({type:"math",data:R,rawData:E,display:n[b].display}),i=i.slice(c+n[b].right.length)}return i!==""&&g.push({type:"text",data:i}),g},qh=function(i,n){var c=zh(i,n.delimiters);if(c.length===1&&c[0].type==="text")return null;for(var g=document.createDocumentFragment(),m=0;m<c.length;m++)if(c[m].type==="text")g.appendChild(document.createTextNode(c[m].data));else{var b=document.createElement("span"),E=c[m].data;n.displayMode=c[m].display;try{n.preProcess&&(E=n.preProcess(E)),Gs.render(E,b,n)}catch(R){if(!(R instanceof Gs.ParseError))throw R;n.errorCallback("KaTeX auto-render: Failed to parse `"+c[m].data+"` with ",R),g.appendChild(document.createTextNode(c[m].rawData));continue}g.appendChild(b)}return g},Vh=function e(i,n){for(var c=0;c<i.childNodes.length;c++){var g=i.childNodes[c];if(g.nodeType===3){for(var m=g.textContent,b=g.nextSibling,E=0;b&&b.nodeType===Node.TEXT_NODE;)m+=b.textContent,b=b.nextSibling,E++;var R=qh(m,n);if(R){for(var F=0;F<E;F++)g.nextSibling.remove();c+=R.childNodes.length-1,i.replaceChild(R,g)}else c+=E}else g.nodeType===1&&(function(){var Q=" "+g.className+" ";n.ignoredTags.indexOf(g.nodeName.toLowerCase())===-1&&n.ignoredClasses.every(Y=>Q.indexOf(" "+Y+" ")===-1)&&e(g,n)})()}},Ys=function(i,n){if(!i)throw new Error("No element provided to render");var c={};for(var g in n)n.hasOwnProperty(g)&&(c[g]=n[g]);c.delimiters=c.delimiters||[{left:"$$",right:"$$",display:!0},{left:"\\(",right:"\\)",display:!1},{left:"\\begin{equation}",right:"\\end{equation}",display:!0},{left:"\\begin{align}",right:"\\end{align}",display:!0},{left:"\\begin{alignat}",right:"\\end{alignat}",display:!0},{left:"\\begin{gather}",right:"\\end{gather}",display:!0},{left:"\\begin{CD}",right:"\\end{CD}",display:!0},{left:"\\[",right:"\\]",display:!0}],c.ignoredTags=c.ignoredTags||["script","noscript","style","textarea","pre","code","option"],c.ignoredClasses=c.ignoredClasses||[],c.errorCallback=c.errorCallback||console.error,c.macros=c.macros||{},Vh(i,c)}})),Wh=class extends Ve{contain;_shadowDom;static get observedAttributes(){return["latex","sheet"]}constructor(){super(),this._shadowDom=We(this,ep);const e=_e(this._shadowDom,".ran-math",()=>K().class("ran-math").build());this.contain=e}get latex(){const e=Be(this,"latex");return decodeURIComponent(e)}set latex(e){Le(this,"latex",e)}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};render(){this.latex&&Promise.resolve().then(()=>(hp(),dp)).then(e=>{if(this.contain.innerHTML="",this.latex){const i=Hr().text(`$$${this.latex}$$`).build();this.contain.appendChild(i),e.renderMathInElement(this.contain)}}).catch(function(e){console.warn(`ranui math component warning: ${e.message}
295
- ${e}`)})}connectedCallback(){this.handlerExternalCss(),this.render()}attributeChangedCallback(e,i,n){i!==n&&(e==="latex"&&this.render(),e==="sheet"&&this.handlerExternalCss())}};qe("r-math",Wh);var up=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}",Xh=class extends Ve{_form;_shadowDom;static get observedAttributes(){return["sheet"]}constructor(){super(),this._shadowDom=We(this,up),this._form=_e(this._shadowDom,".r-form",()=>Ne("form").class("r-form").children(gt().attr("name","r-form_content")).build())}get value(){return this.getAttribute("value")}set value(e){e!=null&&this.setAttribute("value",e)}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};connectedCallback(){this.handlerExternalCss();const e={},i=new FormData(this._form);i.forEach((n,c)=>{e[c]||(e[c]=i.getAll(c).length>1?i.getAll(c):i.get(c))}),this._form.addEventListener("submit",()=>{this.value=JSON.stringify(e)})}attributeChangedCallback(e,i,n){i!==n&&e==="sheet"&&this.handlerExternalCss()}};qe("r-form",Xh);var gp=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:var(--ran-card-display, block);box-sizing:border-box;min-height:var(--ran-card-min-height, 0)}:host([hoverable]:hover) .ran-card{border-color:var(--ran-card-hover-border-color, var(--ran-color-border-hover, #c9c9c9));box-shadow:var(--ran-card-hover-shadow, var(--ran-shadow-elevated, 0 1px 2px rgba(0, 0, 0, .04)))}.ran-card{display:grid;align-content:start;gap:var(--ran-card-gap, 14px);height:100%;min-width:0;padding:var(--ran-card-padding, 16px);border-width:var(--ran-skin-border-width, 1px);border-style:var(--ran-skin-border-style, solid);border-color:var(--ran-card-border-color, var(--ran-color-border, #eaeaea));border-radius:var(--ran-card-radius, var(--ran-radius-md));background:var(--ran-card-background, var(--ran-color-bg));box-shadow:var(--ran-card-shadow, none);box-sizing:border-box}.ran-card-header{display:flex;align-items:flex-start;justify-content:space-between;gap:14px}.ran-card-title-area{flex:1;min-width:0}.ran-card-title{margin:0;color:var(--ran-card-title-color, var(--ran-color-text));font-size:var(--ran-card-title-font-size, 16px);font-weight:var(--ran-card-title-font-weight, 600);line-height:1.3}.ran-card-title:empty{display:none}.ran-card-description{margin:4px 0 0;color:var(--ran-card-description-color, var(--ran-color-text-secondary));font-size:var(--ran-card-description-font-size, 14px);line-height:1.5}.ran-card-description:empty{display:none}.ran-card-body,.ran-card-footer{min-width:0}:host(:not([title]):not([description])) .ran-card-header{display:none}",Jh=class extends Ve{_shadowDom;_titleEl;_descriptionEl;_headerEl;_footerEl;static get observedAttributes(){return["title","description","sheet","hoverable"]}constructor(){super(),this._shadowDom=We(this,gp);const e=_e(this._shadowDom,".ran-card",()=>K().class("ran-card").attr("part","card").children(K().class("ran-card-header").attr("part","header").children(K().class("ran-card-title-area").children(K().class("ran-card-title").attr("part","title"),K().class("ran-card-description").attr("part","description")),gt().attr("name","extra").attr("part","extra")),K().class("ran-card-body").attr("part","body").children(gt()),K().class("ran-card-footer").attr("part","footer").children(gt().attr("name","footer"))).build());this._headerEl=e.querySelector(".ran-card-header"),this._titleEl=e.querySelector(".ran-card-title"),this._descriptionEl=e.querySelector(".ran-card-description"),this._footerEl=e.querySelector(".ran-card-footer"),this._footerEl.style.display="none";const i=this._footerEl.querySelector('slot[name="footer"]');i.addEventListener("slotchange",()=>{this._footerEl.style.display=i.assignedElements().length>0?"":"none"})}get title(){return Be(this,"title")}set title(e){Le(this,"title",e)}get description(){return Be(this,"description")}set description(e){Le(this,"description",e)}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}get hoverable(){return this.hasAttribute("hoverable")}set hoverable(e){e?this.setAttribute("hoverable",""):this.removeAttribute("hoverable")}_syncTitle(){this._titleEl.textContent=this.getAttribute("title")??""}_syncDescription(){this._descriptionEl.textContent=this.getAttribute("description")??""}connectedCallback(){this._syncTitle(),this._syncDescription(),Xe(this,this._shadowDom,"sheet",null,this.sheet)}attributeChangedCallback(e,i,n){i!==n&&(e==="title"&&this._syncTitle(),e==="description"&&this._syncDescription(),e==="sheet"&&Xe(this,this._shadowDom,e,i,n))}};qe("r-card",Jh);var fp=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:block;scroll-margin-top:96px;border-width:var(--ran-skin-border-width, 1px);border-style:var(--ran-skin-border-style, solid);border-color:var(--ran-section-border-color, var(--ran-color-border, #eaeaea));border-radius:var(--ran-section-radius, var(--ran-radius-md, 8px));background:var(--ran-section-background, var(--ran-color-bg-elevated, #ffffff));box-shadow:var(--ran-section-shadow, var(--ran-shadow-elevated, none));padding:var(--ran-section-padding, 28px);box-sizing:border-box}.ran-section-header{display:grid;gap:8px;max-width:760px;margin-bottom:22px}.ran-section-heading{margin:0;color:var(--ran-section-heading-color, var(--ran-color-text, #0f172a));font-size:var(--ran-section-heading-font-size, 24px);font-weight:var(--ran-section-heading-font-weight, 700);line-height:1.25;letter-spacing:0}.ran-section-heading:empty{display:none}.ran-section-subtitle{max-width:620px;margin:0;color:var(--ran-section-subtitle-color, var(--ran-color-text-secondary, #607086))}.ran-section-subtitle:empty{display:none}.ran-section-body{min-width:0}",_h=class extends Ve{_shadowDom;_headerEl;_headingEl;_subtitleEl;_events=new vt;static get observedAttributes(){return["heading","subtitle","sheet"]}constructor(){super(),this._shadowDom=We(this,fp);const e=_e(this._shadowDom,".ran-section-header",()=>{const i=K().class("ran-section-header").attr("part","header").children(K().class("ran-section-heading").attr("part","heading").attr("role","heading").attr("aria-level","2"),K().class("ran-section-subtitle").attr("part","subtitle")).build(),n=K().class("ran-section-body").attr("part","body").children(gt()).build();return this._shadowDom.appendChild(i),this._shadowDom.appendChild(n),i});this._headerEl=e,this._headingEl=e.querySelector(".ran-section-heading"),this._subtitleEl=e.querySelector(".ran-section-subtitle")}get heading(){return Be(this,"heading")}set heading(e){Le(this,"heading",e)}get subtitle(){return Be(this,"subtitle")}set subtitle(e){Le(this,"subtitle",e)}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}_syncHeading(){this._headingEl.textContent=this.getAttribute("heading")??"",this._headerEl.style.display=this._headingEl.textContent||this._subtitleEl.textContent?"":"none"}_syncSubtitle(){this._subtitleEl.textContent=this.getAttribute("subtitle")??"",this._headerEl.style.display=this._headingEl.textContent||this._subtitleEl.textContent?"":"none"}connectedCallback(){this._syncHeading(),this._syncSubtitle(),Xe(this,this._shadowDom,"sheet",null,this.sheet)}disconnectedCallback(){this._events.abort()}attributeChangedCallback(e,i,n){i!==n&&(e==="heading"&&this._syncHeading(),e==="subtitle"&&this._syncSubtitle(),e==="sheet"&&Xe(this,this._shadowDom,e,i,n))}};qe("r-section",_h);var pp=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:block;width:100%}",Ks=null,ti=null,zs=null;function jh(){return zs}function Zh(e){zs=e}function $h(){zs=null}function mp(e){const i={};return e&&new URLSearchParams(e.startsWith("?")?e.slice(1):e).forEach((n,c)=>{i[c]=n}),i}function vp(){return typeof document<"u"&&"startViewTransition"in document}function Ap(e){vp()?document.startViewTransition(e):e()}function eu(){typeof document>"u"||ti&&document.head.contains(ti)||(ti=document.createElement("style"),ti.textContent="@view-transition { navigation: auto; }",document.head.appendChild(ti))}function tu(){ti?.remove(),ti=null}function bp(e){return e===!0||e==="spa"||e==="both"}function yp(e){return e==="mpa"||e==="both"}var ru=class{_mode;_base;_routes;_vtMode;_beforeGuards=[];_afterGuards=[];_changeHandlers=[];_pageSwapHandlers=[];_pageRevealHandlers=[];_components=new Set;_current=null;_mpaActive=!1;constructor(e={}){this._mode=e.mode??"history",this._base=e.base??"",this._routes=e.routes??[],this._vtMode=e.viewTransition,yp(this._vtMode)&&this._enableMpa()}get mode(){return this._mode}get base(){return this._base}get routes(){return[...this._routes]}get currentRoute(){return this._current}_matchConfigPath(e,i){const n=[],c=i.path.split("/").map(g=>g.startsWith(":")?(n.push(g.slice(1)),"([^/]+)"):g==="*"?"(.*)":g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("/");return(i.exact?new RegExp(`^${c}$`):new RegExp(`^${c}(?:/.*)?$`)).test(e)}matchRoute(e){return this._routes.find(i=>this._matchConfigPath(e,i))??null}getStaticPaths(){return this._routes.map(e=>e.path)}_enableMpa(){this._mpaActive||(this._mpaActive=!0,eu(),typeof window<"u"&&(window.addEventListener("pageswap",this._onPageSwap),window.addEventListener("pagereveal",this._onPageReveal)))}_disableMpa(){this._mpaActive&&(this._mpaActive=!1,tu(),typeof window<"u"&&(window.removeEventListener("pageswap",this._onPageSwap),window.removeEventListener("pagereveal",this._onPageReveal)))}_onPageSwap=e=>{this._pageSwapHandlers.forEach(i=>i(e))};_onPageReveal=e=>{this._pageRevealHandlers.forEach(i=>i(e))};_bind(e){this._components.add(e)}_unbind(e){this._components.delete(e)}_buildLocation(e){const i=e.indexOf("?"),n=i===-1?e:e.slice(0,i),c=i===-1?"":e.slice(i+1);return{path:n||"/",params:{},query:mp(c),fullPath:e||"/"}}_getCurrentPath(){if(typeof window>"u")return"/";if(this._mode==="hash")return window.location.hash.slice(1)||"/";const e=window.location.pathname,i=this._base;return(i&&e.startsWith(i)?e.slice(i.length)||"/":e)+(window.location.search||"")}_notify(){const e=this._buildLocation(this._getCurrentPath()),i=this._current;this._current=e;const n=()=>{this._components.forEach(c=>c._syncRoutes())};bp(this._vtMode)?Ap(n):n(),this._afterGuards.forEach(c=>c(e,i)),this._changeHandlers.forEach(c=>c(e,i))}async _navigate(e,i){const n=this._buildLocation(e),c=this._current;for(const g of this._beforeGuards){const m=await new Promise(b=>{g(n,c,b)});if(m===!1)return;if(typeof m=="string")return this._navigate(m,i)}if(typeof window<"u"){const g=this._mode==="hash"?`#${e}`:this._base+e;i?window.history.replaceState({path:e},"",g):window.history.pushState({path:e},"",g)}this._notify()}push(e){return this._navigate(e,!1)}replace(e){return this._navigate(e,!0)}back(){typeof window<"u"&&window.history.back()}forward(){typeof window<"u"&&window.history.forward()}go(e){typeof window<"u"&&window.history.go(e)}destroy(){this._disableMpa(),this._components.clear()}beforeEach(e){return this._beforeGuards.push(e),()=>{const i=this._beforeGuards.indexOf(e);i!==-1&&this._beforeGuards.splice(i,1)}}afterEach(e){return this._afterGuards.push(e),()=>{const i=this._afterGuards.indexOf(e);i!==-1&&this._afterGuards.splice(i,1)}}onRouteChange(e){return this._changeHandlers.push(e),()=>{const i=this._changeHandlers.indexOf(e);i!==-1&&this._changeHandlers.splice(i,1)}}onPageSwap(e){return this._pageSwapHandlers.push(e),()=>{const i=this._pageSwapHandlers.indexOf(e);i!==-1&&this._pageSwapHandlers.splice(i,1)}}onPageReveal(e){return this._pageRevealHandlers.push(e),()=>{const i=this._pageRevealHandlers.indexOf(e);i!==-1&&this._pageRevealHandlers.splice(i,1)}}};function wp(e){Ks?.destroy();const i=new ru(e);return Ks=i,i}function ua(){return Ks}function Cp(){return eu(),()=>tu()}var iu=class extends Ve{static get observedAttributes(){return["mode","base","sheet"]}_events=new vt;_shadowDom;_slot;_currentPath="";constructor(){super(),this._shadowDom=We(this,pp);const e=_e(this._shadowDom,"slot",()=>gt().build());this._slot=e}get mode(){return this.getAttribute("mode")==="hash"?"hash":"history"}get base(){return Be(this,"base")}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};_getPath(){if(this.mode==="hash")return window.location.hash.slice(1)||"/";const e=this.base,i=window.location.pathname;return e&&i.startsWith(e)?i.slice(e.length)||"/":i}navigate(e,i=!1){const n=this.mode==="hash"?`#${e}`:this.base+e;i?window.history.replaceState(null,"",n):window.history.pushState(null,"",n),this._syncRoutes()}_syncRoutes(){const e=this._getPath();this._currentPath=e,this.querySelectorAll("r-route").forEach(i=>{typeof i._update=="function"&&i._update(e)}),this.dispatchEvent(new CustomEvent("routechange",{detail:{path:e},bubbles:!0}))}_handlePopState=()=>{this._syncRoutes()};_handleNavigate=e=>{const{path:i,replace:n}=e.detail;e.stopPropagation(),this.navigate(i,n)};connectedCallback(){this.handlerExternalCss(),this._events.on(window,"popstate",this._handlePopState),this._events.on(this,"ran-navigate",this._handleNavigate),this._events.on(this._slot,"slotchange",()=>this._syncRoutes());const e=ua();e&&e._bind(this),this._syncRoutes(),typeof customElements<"u"&&customElements.whenDefined("r-route").then(()=>this._syncRoutes())}disconnectedCallback(){const e=ua();e&&e._unbind(this),this._events.abort()}attributeChangedCallback(e,i,n){i!==n&&e==="sheet"&&this.handlerExternalCss()}};qe("r-router",iu);var Ep=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:block}:host([hidden]){display:none!important}",au=class extends Ve{static get observedAttributes(){return["path","exact","sheet"]}_events=new vt;_shadowDom;_params={};constructor(){super(),this._shadowDom=We(this,Ep),_e(this._shadowDom,"slot",()=>gt().build())}get path(){return Be(this,"path","/")}set path(e){Le(this,"path",e)}get exact(){return this.hasAttribute("exact")}get params(){return{...this._params}}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};_matchPath(e){const i=this.path,n={},c=[],g=i.split("/").map(E=>E.startsWith(":")?(c.push(E.slice(1)),"([^/]+)"):E==="*"?"(.*)":E.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("/"),m=this.exact?new RegExp(`^${g}$`):new RegExp(`^${g}(?:/.*)?$`),b=e.match(m);return b?(c.forEach((E,R)=>{n[E]=decodeURIComponent(b[R+1]??"")}),{matched:!0,params:n}):{matched:!1,params:n}}_update(e){const{matched:i,params:n}=this._matchPath(e);this._params=n,this.hidden=!i,i&&this.dispatchEvent(new CustomEvent("routematch",{detail:{path:e,params:n},bubbles:!0}))}_preSerialize(){const e=jh();e!==null&&this._update(e)}connectedCallback(){this.handlerExternalCss();const e=this.closest("r-router");e&&e._currentPath&&this._update(e._currentPath)}disconnectedCallback(){this._events.abort()}attributeChangedCallback(e,i,n){if(i!==n){if(e==="path"||e==="exact"){const c=this.closest("r-router");c&&this._update(c._currentPath)}e==="sheet"&&this.handlerExternalCss()}}};qe("r-route",au);var kp=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:inline}a{color:var(--ran-color-link, #006bff);text-decoration:none;cursor:pointer;font-family:inherit;font-size:inherit;border-radius:var(--ran-radius-sm, 6px)}a:hover{text-decoration:underline;opacity:.85}a:focus-visible{outline:2px solid var(--ran-color-primary, #006bff);outline-offset:2px}:host([active]) a{font-weight:600;text-decoration:underline}",nu=class extends Ve{static get observedAttributes(){return["href","replace","sheet"]}_events=new vt;_shadowDom;_anchor;constructor(){super(),this._shadowDom=We(this,kp);const e=_e(this._shadowDom,"a",()=>{const i=document.createElement("a");return i.appendChild(document.createElement("slot")),i});this._anchor=e}get href(){return Be(this,"href")}set href(e){Le(this,"href",e)}get replace(){return this.hasAttribute("replace")}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};_handleClick=e=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;const i=this.href;if(!i||/^(https?:\/\/|\/\/|mailto:|tel:)/.test(i))return;e.preventDefault();const n=ua();if(n){this.replace?n.replace(i):n.push(i);return}this.dispatchEvent(new CustomEvent("ran-navigate",{detail:{path:i,replace:this.replace},bubbles:!0,composed:!0}))};_syncHref(){this._anchor&&(this._anchor.href=this.href)}connectedCallback(){this.handlerExternalCss(),this._syncHref(),this._events.on(this._anchor,"click",this._handleClick)}disconnectedCallback(){this._events.abort()}attributeChangedCallback(e,i,n){i!==n&&(e==="href"&&this._syncHref(),e==="sheet"&&this.handlerExternalCss())}};qe("r-link",nu);var Bp=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:var(--ran-theme-switch-display, inline-flex);box-sizing:border-box}.ran-theme-switch{display:inline-flex;align-items:center;gap:var(--ran-theme-switch-gap, 2px);padding:var(--ran-theme-switch-padding, 2px);border-width:var(--ran-skin-border-width, 1px);border-style:var(--ran-skin-border-style, solid);border-color:var(--ran-theme-switch-border-color, var(--ran-color-border, #eaeaea));border-radius:var(--ran-theme-switch-radius, var(--ran-radius-full, 9999px));background:var(--ran-theme-switch-background, transparent);box-sizing:border-box}.ran-theme-switch button{width:var(--ran-theme-switch-button-size, 28px);height:var(--ran-theme-switch-button-size, 28px);display:grid;place-items:center;border:none;border-radius:var(--ran-theme-switch-radius, var(--ran-radius-full, 9999px));background:transparent;color:var(--ran-theme-switch-color, var(--ran-color-text-secondary, #4d4d4d));cursor:pointer;padding:0}.ran-theme-switch button:hover{color:var(--ran-theme-switch-hover-color, var(--ran-color-text, #171717))}.ran-theme-switch button[aria-pressed=true]{background:var(--ran-theme-switch-active-background, var(--ran-color-bg-hover, #ebebeb));color:var(--ran-theme-switch-active-color, var(--ran-color-text, #171717))}.ran-theme-switch button:focus-visible{outline:var(--ran-theme-switch-focus-outline, 2px solid var(--ran-color-primary, #006bff));outline-offset:2px}.ran-theme-switch svg{width:var(--ran-theme-switch-icon-size, 16px);height:var(--ran-theme-switch-icon-size, 16px)}",qs=["system","light","dark"],Ip={system:'<svg viewBox="0 0 16 16" aria-hidden="true"><rect x="1.5" y="2.5" width="13" height="9" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M5.5 14h5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',light:'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="3" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M8 1v1.8M8 13.2V15M15 8h-1.8M2.8 8H1m11.4-4.4-1.3 1.3M4.9 11.1l-1.3 1.3m9.8 0-1.3-1.3M4.9 4.9 3.6 3.6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',dark:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M13.5 9.5A6 6 0 0 1 6.5 2.5a6 6 0 1 0 7 7z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>'},Vs="ran-theme-switch-sync",ou=class extends Ve{static get observedAttributes(){return["label-system","label-light","label-dark","sheet"]}_events=new vt;_shadowDom;_group;constructor(){super(),this._shadowDom=We(this,Bp),this._group=_e(this._shadowDom,".ran-theme-switch",()=>{const e=document.createElement("div");e.className="ran-theme-switch",e.setAttribute("part","switch"),e.setAttribute("role","group");for(const i of qs){const n=document.createElement("button");n.type="button",n.dataset.choice=i,n.setAttribute("part",`button ${i}`),n.setAttribute("aria-pressed","false"),n.innerHTML=Ip[i],e.appendChild(n)}return e})}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}get value(){return Jl()||"system"}set value(e){qs.includes(e)&&this._select(e)}_label(e){const i={system:"System theme",light:"Light theme",dark:"Dark theme"}[e];return this.getAttribute(`label-${e}`)||i}_syncLabels(){this._group.setAttribute("aria-label",this.getAttribute("label")||"Theme");for(const e of this._group.querySelectorAll("button"))e.setAttribute("aria-label",this._label(e.dataset.choice))}_reflect(){const e=this.value;for(const i of this._group.querySelectorAll("button"))i.setAttribute("aria-pressed",i.dataset.choice===e?"true":"false")}_select(e){_n(e),this._reflect(),this._syncMeta(e),document.dispatchEvent(new CustomEvent(Vs)),this.dispatchEvent(new CustomEvent("change",{detail:{theme:e},bubbles:!0,composed:!0}))}_syncMeta(e){if(typeof requestAnimationFrame>"u")return;const i=document.querySelectorAll('meta[name="theme-color"]');i.length&&requestAnimationFrame(()=>{for(const n of i)if(n.dataset.ranOriginalContent===void 0&&(n.dataset.ranOriginalContent=n.getAttribute("content")||""),e==="system")n.setAttribute("content",n.dataset.ranOriginalContent);else{const c=getComputedStyle(document.documentElement).getPropertyValue("--ran-color-bg").trim()||getComputedStyle(document.body).backgroundColor;n.setAttribute("content",c)}})}_handleClick=e=>{const i=e.target.closest?.("button")?.dataset.choice;i&&qs.includes(i)&&this._select(i)};_handleSync=()=>this._reflect();handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};connectedCallback(){this.handlerExternalCss(),this._syncLabels(),this._reflect(),this._events.on(this._group,"click",this._handleClick),document.addEventListener(Vs,this._handleSync),typeof window<"u"&&window.addEventListener("storage",this._handleSync)}disconnectedCallback(){this._events.abort(),document.removeEventListener(Vs,this._handleSync),typeof window<"u"&&window.removeEventListener("storage",this._handleSync)}attributeChangedCallback(e,i,n){i!==n&&(e==="sheet"&&this.handlerExternalCss(),e.startsWith("label")&&this._syncLabels())}};qe("r-theme-switch",ou);function su(e,i){Zh(i);try{return B0(e)}finally{$h()}}function Sp(e,i){const n=ua();return(i?.paths??n?.getStaticPaths()??[]).map(c=>({path:c,html:su(e(),c)}))}var xp="ran-locale",Tp=e=>{if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}},Dp=(e,i)=>{if(!(typeof localStorage>"u"))try{localStorage.setItem(e,i)}catch{}},Rp=e=>{if(typeof navigator>"u"||!navigator.language)return null;const i=navigator.language.toLowerCase();return e.find(n=>n.toLowerCase()===i)??e.find(n=>i.startsWith(n.toLowerCase()))??e.find(n=>i.startsWith(`${n.toLowerCase()}-`))??null},lu=class{_locale;_fallback;_messages;_persist;_storageKey;_handlers=new Set;constructor(e={}){this._messages={...e.messages},this._fallback=e.fallbackLocale??"en",this._persist=e.persist??!1,this._storageKey=e.storageKey??xp,this._locale=this._resolveInitialLocale(e)}_resolveInitialLocale(e){const i=Object.keys(this._messages),n=this._persist?Tp(this._storageKey):null;if(n&&(this._messages[n]||i.length===0))return n;if(e.locale)return e.locale;if(e.detectNavigator){const c=Rp(i);if(c)return c}return this._fallback}get locale(){return this._locale}getLocale(){return this._locale}setLocale(e){e!==this._locale&&(this._locale=e,this._persist&&Dp(this._storageKey,e),this._notify())}addMessages(e,i){this._messages[e]={...this._messages[e],...i}}getMessages(e=this._locale){return this._messages[e]??{}}get availableLocales(){return Object.keys(this._messages)}t(e,i){const n=this._messages[this._locale]?.[e]??this._messages[this._fallback]?.[e]??e;return this._interpolate(n,i)}_interpolate(e,i){return i?e.replace(/\{(\w+)\}/g,(n,c)=>i[c]!=null?String(i[c]):n):e}onChange(e){return this._handlers.add(e),()=>{this._handlers.delete(e)}}_notify(){for(const e of this._handlers)e(this._locale)}destroy(){this._handlers.clear()}},Ws=null;function Lp(e={}){return Ws=new lu(e),Ws}function Mp(){return Ws}var Fp=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{position:relative;display:block}.ran-scratch-ticket{position:relative;display:block;width:100%;height:100%}.ran-scratch-ticket-award{position:absolute;top:0;left:0;display:block;width:100%;height:100%;background:#000;z-index:1}.ran-scratch-ticket-canvas{position:absolute;top:0;left:0;display:block;width:100%;height:100%;z-index:2}",Op=class extends Ve{scratchTicketContainer;scratchTicket;state;scratchAward;_shadowDom;static get observedAttributes(){return["disabled","icon","effect","iconSize","sheet"]}constructor(){super(),this._shadowDom=We(this,Fp);const e=_e(this._shadowDom,".ran-scratch-ticket",()=>{const c=Ne("canvas").class("ran-scratch-ticket-canvas").style("width","100%").style("height","100%").build(),g=K().class("ran-scratch-ticket-award").build();return K().class("ran-scratch-ticket").children(c,g).build()}),i=e.querySelector(".ran-scratch-ticket-award"),n=e.querySelector(".ran-scratch-ticket-canvas");this.scratchTicketContainer=e,this.scratchAward=i,this.scratchTicket=n,this.state={touchStart:!1,scratchArea:0}}touchStartScratch=e=>{this.state.touchStart=!0};touchMoveScratch=()=>{if(this.state.touchStart){const e=this.scratchTicket.getContext("2d");if(!e)return;this.state.scratchArea+=30,e.beginPath(),e.arc(100,100,30,0,2*Math.PI),e.globalCompositeOperation="destination-out",e.fill(),e.closePath()}};touchEndScratch=()=>{this.state.touchStart=!1;const{width:e,height:i}=this.scratchTicket,n=this.scratchTicket.getContext("2d");n&&this.state.scratchArea>e*i*.03&&(this.state.scratchArea=0,n.clearRect(0,0,e,i))};drawScratchTicket=()=>{const e=this.scratchTicket.getContext("2d");if(!this.scratchTicketContainer||!e)return;const i=new Image;i.src="",i.onload=()=>{e.drawImage(i,0,0,this.scratchTicket.width,this.scratchTicket.height)},this.scratchTicket.addEventListener("touchstart",this.touchStartScratch),this.scratchTicket.addEventListener("touchmove",this.touchMoveScratch),this.scratchTicket.addEventListener("touchend",this.touchEndScratch)};attributeChangedCallback(){this._shadowDom.contains(this.scratchTicketContainer)||this._shadowDom.appendChild(this.scratchTicketContainer),this.drawScratchTicket()}};return qe("r-scratch",Op),ke.ARROW_TYPE=sf,ke.Button=uc,ke.Card=Jh,ke.CustomMessage=wc,ke.Dropdown=Rc,ke.Form=Xh,ke.I18nCore=lu,ke.ICON_NAME_AMP=$f,ke.Icon=pc,ke.ImageElement=mc,ke.Input=vc,ke.Link=nu,ke.Loading=Xc,ke.Math=Wh,ke.PLACEMENT_TYPE=Jf,ke.Popover=Vc,ke.Progress=Kc,ke.RadarChart=Tc,ke.RanCheckbox=zc,ke.RanColorPicker=Wc,ke.RanModal=Yc,ke.RanPlayer=Pf,ke.Route=au,ke.Router=iu,ke.RouterCore=ru,ke.Section=_h,ke.Select=Fc,ke.Skeleton=Cc,ke.TabPane=Ec,ke.Tabs=kc,ke.ThemeSwitch=ou,ke.clearSSGPath=$h,ke.clearThemeToken=jl,ke.createI18n=Lp,ke.createRouter=wp,ke.enableMpaViewTransitions=Cp,ke.generateStaticPages=Sp,ke.getSSGPath=jh,ke.getTheme=Jl,ke.initTheme=l0,ke.registerIcon=no,ke.registerIcons=fc,ke.renderStaticPage=su,ke.setSSGPath=Zh,ke.setTheme=_n,ke.setThemeToken=_l,ke.setThemeTokens=s0,ke.useI18n=Mp,ke.useRouter=ua,ke})({});
295
+ ${e}`)})}connectedCallback(){this.handlerExternalCss(),this.render()}attributeChangedCallback(e,i,n){i!==n&&(e==="latex"&&this.render(),e==="sheet"&&this.handlerExternalCss())}};qe("r-math",Wh);var up=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}",Xh=class extends Ve{_form;_shadowDom;static get observedAttributes(){return["sheet"]}constructor(){super(),this._shadowDom=We(this,up),this._form=_e(this._shadowDom,".r-form",()=>Ne("form").class("r-form").children(gt().attr("name","r-form_content")).build())}get value(){return this.getAttribute("value")}set value(e){e!=null&&this.setAttribute("value",e)}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};connectedCallback(){this.handlerExternalCss();const e={},i=new FormData(this._form);i.forEach((n,c)=>{e[c]||(e[c]=i.getAll(c).length>1?i.getAll(c):i.get(c))}),this._form.addEventListener("submit",()=>{this.value=JSON.stringify(e)})}attributeChangedCallback(e,i,n){i!==n&&e==="sheet"&&this.handlerExternalCss()}};qe("r-form",Xh);var gp=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:var(--ran-card-display, block);box-sizing:border-box;min-height:var(--ran-card-min-height, 0)}:host([hoverable]:hover) .ran-card{border-color:var(--ran-card-hover-border-color, var(--ran-color-border-hover, #c9c9c9));box-shadow:var(--ran-card-hover-shadow, var(--ran-shadow-elevated, 0 1px 2px rgba(0, 0, 0, .04)))}.ran-card{display:grid;align-content:start;gap:var(--ran-card-gap, 14px);height:100%;min-width:0;padding:var(--ran-card-padding, 16px);border-width:var(--ran-skin-border-width, 1px);border-style:var(--ran-skin-border-style, solid);border-color:var(--ran-card-border-color, var(--ran-color-border, #eaeaea));border-radius:var(--ran-card-radius, var(--ran-radius-md));background:var(--ran-card-background, var(--ran-color-bg));box-shadow:var(--ran-card-shadow, none);box-sizing:border-box}.ran-card-header{display:flex;align-items:flex-start;justify-content:space-between;gap:14px}.ran-card-title-area{flex:1;min-width:0}.ran-card-title{margin:0;color:var(--ran-card-title-color, var(--ran-color-text));font-size:var(--ran-card-title-font-size, 16px);font-weight:var(--ran-card-title-font-weight, 600);line-height:1.3}.ran-card-title:empty{display:none}.ran-card-description{margin:4px 0 0;color:var(--ran-card-description-color, var(--ran-color-text-secondary));font-size:var(--ran-card-description-font-size, 14px);line-height:1.5}.ran-card-description:empty{display:none}.ran-card-body,.ran-card-footer{min-width:0}:host(:not([title]):not([description])) .ran-card-header{display:none}",Jh=class extends Ve{_shadowDom;_titleEl;_descriptionEl;_headerEl;_footerEl;static get observedAttributes(){return["title","description","sheet","hoverable"]}constructor(){super(),this._shadowDom=We(this,gp);const e=_e(this._shadowDom,".ran-card",()=>K().class("ran-card").attr("part","card").children(K().class("ran-card-header").attr("part","header").children(K().class("ran-card-title-area").children(K().class("ran-card-title").attr("part","title"),K().class("ran-card-description").attr("part","description")),gt().attr("name","extra").attr("part","extra")),K().class("ran-card-body").attr("part","body").children(gt()),K().class("ran-card-footer").attr("part","footer").children(gt().attr("name","footer"))).build());this._headerEl=e.querySelector(".ran-card-header"),this._titleEl=e.querySelector(".ran-card-title"),this._descriptionEl=e.querySelector(".ran-card-description"),this._footerEl=e.querySelector(".ran-card-footer"),this._footerEl.style.display="none";const i=this._footerEl.querySelector('slot[name="footer"]');i.addEventListener("slotchange",()=>{this._footerEl.style.display=i.assignedElements().length>0?"":"none"})}get title(){return Be(this,"title")}set title(e){Le(this,"title",e)}get description(){return Be(this,"description")}set description(e){Le(this,"description",e)}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}get hoverable(){return this.hasAttribute("hoverable")}set hoverable(e){e?this.setAttribute("hoverable",""):this.removeAttribute("hoverable")}_syncTitle(){this._titleEl.textContent=this.getAttribute("title")??""}_syncDescription(){this._descriptionEl.textContent=this.getAttribute("description")??""}connectedCallback(){this._syncTitle(),this._syncDescription(),Xe(this,this._shadowDom,"sheet",null,this.sheet)}attributeChangedCallback(e,i,n){i!==n&&(e==="title"&&this._syncTitle(),e==="description"&&this._syncDescription(),e==="sheet"&&Xe(this,this._shadowDom,e,i,n))}};qe("r-card",Jh);var fp=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:block;scroll-margin-top:96px;border-width:var(--ran-skin-border-width, 1px);border-style:var(--ran-skin-border-style, solid);border-color:var(--ran-section-border-color, var(--ran-color-border, #eaeaea));border-radius:var(--ran-section-radius, var(--ran-radius-md, 8px));background:var(--ran-section-background, var(--ran-color-bg-elevated, #ffffff));box-shadow:var(--ran-section-shadow, var(--ran-shadow-elevated, none));padding:var(--ran-section-padding, 28px);box-sizing:border-box}.ran-section-header{display:grid;gap:8px;max-width:760px;margin-bottom:22px}.ran-section-heading{margin:0;color:var(--ran-section-heading-color, var(--ran-color-text, #0f172a));font-size:var(--ran-section-heading-font-size, 24px);font-weight:var(--ran-section-heading-font-weight, 700);line-height:1.25;letter-spacing:0}.ran-section-heading:empty{display:none}.ran-section-subtitle{max-width:620px;margin:0;color:var(--ran-section-subtitle-color, var(--ran-color-text-secondary, #607086))}.ran-section-subtitle:empty{display:none}.ran-section-body{min-width:0}",_h=class extends Ve{_shadowDom;_headerEl;_headingEl;_subtitleEl;_events=new vt;static get observedAttributes(){return["heading","subtitle","sheet"]}constructor(){super(),this._shadowDom=We(this,fp);const e=_e(this._shadowDom,".ran-section-header",()=>{const i=K().class("ran-section-header").attr("part","header").children(K().class("ran-section-heading").attr("part","heading").attr("role","heading").attr("aria-level","2"),K().class("ran-section-subtitle").attr("part","subtitle")).build(),n=K().class("ran-section-body").attr("part","body").children(gt()).build();return this._shadowDom.appendChild(i),this._shadowDom.appendChild(n),i});this._headerEl=e,this._headingEl=e.querySelector(".ran-section-heading"),this._subtitleEl=e.querySelector(".ran-section-subtitle")}get heading(){return Be(this,"heading")}set heading(e){Le(this,"heading",e)}get subtitle(){return Be(this,"subtitle")}set subtitle(e){Le(this,"subtitle",e)}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}_syncHeading(){this._headingEl.textContent=this.getAttribute("heading")??"",this._headerEl.style.display=this._headingEl.textContent||this._subtitleEl.textContent?"":"none"}_syncSubtitle(){this._subtitleEl.textContent=this.getAttribute("subtitle")??"",this._headerEl.style.display=this._headingEl.textContent||this._subtitleEl.textContent?"":"none"}connectedCallback(){this._syncHeading(),this._syncSubtitle(),Xe(this,this._shadowDom,"sheet",null,this.sheet)}disconnectedCallback(){this._events.abort()}attributeChangedCallback(e,i,n){i!==n&&(e==="heading"&&this._syncHeading(),e==="subtitle"&&this._syncSubtitle(),e==="sheet"&&Xe(this,this._shadowDom,e,i,n))}};qe("r-section",_h);var pp=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:block;width:100%}",Ks=null,ti=null,zs=null;function jh(){return zs}function Zh(e){zs=e}function $h(){zs=null}function mp(e){const i={};return e&&new URLSearchParams(e.startsWith("?")?e.slice(1):e).forEach((n,c)=>{i[c]=n}),i}function vp(){return typeof document<"u"&&"startViewTransition"in document}function Ap(e){vp()?document.startViewTransition(e):e()}function eu(){typeof document>"u"||ti&&document.head.contains(ti)||(ti=document.createElement("style"),ti.textContent="@view-transition { navigation: auto; }",document.head.appendChild(ti))}function tu(){ti?.remove(),ti=null}function bp(e){return e===!0||e==="spa"||e==="both"}function yp(e){return e==="mpa"||e==="both"}var ru=class{_mode;_base;_routes;_vtMode;_beforeGuards=[];_afterGuards=[];_changeHandlers=[];_pageSwapHandlers=[];_pageRevealHandlers=[];_components=new Set;_current=null;_mpaActive=!1;constructor(e={}){this._mode=e.mode??"history",this._base=e.base??"",this._routes=e.routes??[],this._vtMode=e.viewTransition,yp(this._vtMode)&&this._enableMpa()}get mode(){return this._mode}get base(){return this._base}get routes(){return[...this._routes]}get currentRoute(){return this._current}_matchConfigPath(e,i){const n=[],c=i.path.split("/").map(g=>g.startsWith(":")?(n.push(g.slice(1)),"([^/]+)"):g==="*"?"(.*)":g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("/");return(i.exact?new RegExp(`^${c}$`):new RegExp(`^${c}(?:/.*)?$`)).test(e)}matchRoute(e){return this._routes.find(i=>this._matchConfigPath(e,i))??null}getStaticPaths(){return this._routes.map(e=>e.path)}_enableMpa(){this._mpaActive||(this._mpaActive=!0,eu(),typeof window<"u"&&(window.addEventListener("pageswap",this._onPageSwap),window.addEventListener("pagereveal",this._onPageReveal)))}_disableMpa(){this._mpaActive&&(this._mpaActive=!1,tu(),typeof window<"u"&&(window.removeEventListener("pageswap",this._onPageSwap),window.removeEventListener("pagereveal",this._onPageReveal)))}_onPageSwap=e=>{this._pageSwapHandlers.forEach(i=>i(e))};_onPageReveal=e=>{this._pageRevealHandlers.forEach(i=>i(e))};_bind(e){this._components.add(e)}_unbind(e){this._components.delete(e)}_buildLocation(e){const i=e.indexOf("?"),n=i===-1?e:e.slice(0,i),c=i===-1?"":e.slice(i+1);return{path:n||"/",params:{},query:mp(c),fullPath:e||"/"}}_getCurrentPath(){if(typeof window>"u")return"/";if(this._mode==="hash")return window.location.hash.slice(1)||"/";const e=window.location.pathname,i=this._base;return(i&&e.startsWith(i)?e.slice(i.length)||"/":e)+(window.location.search||"")}_notify(){const e=this._buildLocation(this._getCurrentPath()),i=this._current;this._current=e;const n=()=>{this._components.forEach(c=>c._syncRoutes())};bp(this._vtMode)?Ap(n):n(),this._afterGuards.forEach(c=>c(e,i)),this._changeHandlers.forEach(c=>c(e,i))}async _navigate(e,i){const n=this._buildLocation(e),c=this._current;for(const g of this._beforeGuards){const m=await new Promise(b=>{g(n,c,b)});if(m===!1)return;if(typeof m=="string")return this._navigate(m,i)}if(typeof window<"u"){const g=this._mode==="hash"?`#${e}`:this._base+e;i?window.history.replaceState({path:e},"",g):window.history.pushState({path:e},"",g)}this._notify()}push(e){return this._navigate(e,!1)}replace(e){return this._navigate(e,!0)}back(){typeof window<"u"&&window.history.back()}forward(){typeof window<"u"&&window.history.forward()}go(e){typeof window<"u"&&window.history.go(e)}destroy(){this._disableMpa(),this._components.clear()}beforeEach(e){return this._beforeGuards.push(e),()=>{const i=this._beforeGuards.indexOf(e);i!==-1&&this._beforeGuards.splice(i,1)}}afterEach(e){return this._afterGuards.push(e),()=>{const i=this._afterGuards.indexOf(e);i!==-1&&this._afterGuards.splice(i,1)}}onRouteChange(e){return this._changeHandlers.push(e),()=>{const i=this._changeHandlers.indexOf(e);i!==-1&&this._changeHandlers.splice(i,1)}}onPageSwap(e){return this._pageSwapHandlers.push(e),()=>{const i=this._pageSwapHandlers.indexOf(e);i!==-1&&this._pageSwapHandlers.splice(i,1)}}onPageReveal(e){return this._pageRevealHandlers.push(e),()=>{const i=this._pageRevealHandlers.indexOf(e);i!==-1&&this._pageRevealHandlers.splice(i,1)}}};function wp(e){Ks?.destroy();const i=new ru(e);return Ks=i,i}function ua(){return Ks}function Cp(){return eu(),()=>tu()}var iu=class extends Ve{static get observedAttributes(){return["mode","base","sheet"]}_events=new vt;_shadowDom;_slot;_currentPath="";constructor(){super(),this._shadowDom=We(this,pp);const e=_e(this._shadowDom,"slot",()=>gt().build());this._slot=e}get mode(){return this.getAttribute("mode")==="hash"?"hash":"history"}get base(){return Be(this,"base")}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};_getPath(){if(this.mode==="hash")return window.location.hash.slice(1)||"/";const e=this.base,i=window.location.pathname;return e&&i.startsWith(e)?i.slice(e.length)||"/":i}navigate(e,i=!1){const n=this.mode==="hash"?`#${e}`:this.base+e;i?window.history.replaceState(null,"",n):window.history.pushState(null,"",n),this._syncRoutes()}_syncRoutes(){const e=this._getPath();this._currentPath=e,this.querySelectorAll("r-route").forEach(i=>{typeof i._update=="function"&&i._update(e)}),this.dispatchEvent(new CustomEvent("routechange",{detail:{path:e},bubbles:!0}))}_handlePopState=()=>{this._syncRoutes()};_handleNavigate=e=>{const{path:i,replace:n}=e.detail;e.stopPropagation(),this.navigate(i,n)};connectedCallback(){this.handlerExternalCss(),this._events.on(window,"popstate",this._handlePopState),this._events.on(this,"ran-navigate",this._handleNavigate),this._events.on(this._slot,"slotchange",()=>this._syncRoutes());const e=ua();e&&e._bind(this),this._syncRoutes(),typeof customElements<"u"&&customElements.whenDefined("r-route").then(()=>this._syncRoutes())}disconnectedCallback(){const e=ua();e&&e._unbind(this),this._events.abort()}attributeChangedCallback(e,i,n){i!==n&&e==="sheet"&&this.handlerExternalCss()}};qe("r-router",iu);var Ep=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:block}:host([hidden]){display:none!important}",au=class extends Ve{static get observedAttributes(){return["path","exact","sheet"]}_events=new vt;_shadowDom;_params={};constructor(){super(),this._shadowDom=We(this,Ep),_e(this._shadowDom,"slot",()=>gt().build())}get path(){return Be(this,"path","/")}set path(e){Le(this,"path",e)}get exact(){return this.hasAttribute("exact")}get params(){return{...this._params}}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};_matchPath(e){const i=this.path,n={},c=[],g=i.split("/").map(E=>E.startsWith(":")?(c.push(E.slice(1)),"([^/]+)"):E==="*"?"(.*)":E.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("/"),m=this.exact?new RegExp(`^${g}$`):new RegExp(`^${g}(?:/.*)?$`),b=e.match(m);return b?(c.forEach((E,R)=>{n[E]=decodeURIComponent(b[R+1]??"")}),{matched:!0,params:n}):{matched:!1,params:n}}_update(e){const{matched:i,params:n}=this._matchPath(e);this._params=n,this.hidden=!i,i&&this.dispatchEvent(new CustomEvent("routematch",{detail:{path:e,params:n},bubbles:!0}))}_preSerialize(){const e=jh();e!==null&&this._update(e)}connectedCallback(){this.handlerExternalCss();const e=this.closest("r-router");e&&e._currentPath&&this._update(e._currentPath)}disconnectedCallback(){this._events.abort()}attributeChangedCallback(e,i,n){if(i!==n){if(e==="path"||e==="exact"){const c=this.closest("r-router");c&&this._update(c._currentPath)}e==="sheet"&&this.handlerExternalCss()}}};qe("r-route",au);var kp=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:inline}a{color:var(--ran-color-link, #006bff);text-decoration:none;cursor:pointer;font-family:inherit;font-size:inherit;border-radius:var(--ran-radius-sm, 6px)}a:hover{text-decoration:underline;opacity:.85}a:focus-visible{outline:2px solid var(--ran-color-primary, #006bff);outline-offset:2px}:host([active]) a{font-weight:600;text-decoration:underline}",nu=class extends Ve{static get observedAttributes(){return["href","replace","sheet"]}_events=new vt;_shadowDom;_anchor;constructor(){super(),this._shadowDom=We(this,kp);const e=_e(this._shadowDom,"a",()=>{const i=document.createElement("a");return i.appendChild(document.createElement("slot")),i});this._anchor=e}get href(){return Be(this,"href")}set href(e){Le(this,"href",e)}get replace(){return this.hasAttribute("replace")}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};_handleClick=e=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;const i=this.href;if(!i||/^(https?:\/\/|\/\/|mailto:|tel:)/.test(i))return;e.preventDefault();const n=ua();if(n){this.replace?n.replace(i):n.push(i);return}this.dispatchEvent(new CustomEvent("ran-navigate",{detail:{path:i,replace:this.replace},bubbles:!0,composed:!0}))};_syncHref(){this._anchor&&(this._anchor.href=this.href)}connectedCallback(){this.handlerExternalCss(),this._syncHref(),this._events.on(this._anchor,"click",this._handleClick)}disconnectedCallback(){this._events.abort()}attributeChangedCallback(e,i,n){i!==n&&(e==="href"&&this._syncHref(),e==="sheet"&&this.handlerExternalCss())}};qe("r-link",nu);var Bp=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{display:var(--ran-theme-switch-display, inline-flex);box-sizing:border-box}.ran-theme-switch{display:inline-flex;align-items:center;gap:var(--ran-theme-switch-gap, 2px);padding:var(--ran-theme-switch-padding, 2px);border-width:var(--ran-skin-border-width, 1px);border-style:var(--ran-skin-border-style, solid);border-color:var(--ran-theme-switch-border-color, var(--ran-color-border, #eaeaea));border-radius:var(--ran-theme-switch-radius, var(--ran-radius-full, 9999px));background:var(--ran-theme-switch-background, transparent);box-sizing:border-box}.ran-theme-switch button{width:var(--ran-theme-switch-button-size, 28px);height:var(--ran-theme-switch-button-size, 28px);display:grid;place-items:center;border:none;border-radius:var(--ran-theme-switch-radius, var(--ran-radius-full, 9999px));background:transparent;color:var(--ran-theme-switch-color, var(--ran-color-text-secondary, #4d4d4d));cursor:pointer;padding:0}.ran-theme-switch button:hover{color:var(--ran-theme-switch-hover-color, var(--ran-color-text, #171717))}.ran-theme-switch button[aria-pressed=true]{background:var(--ran-theme-switch-active-background, var(--ran-color-bg-hover, #ebebeb));color:var(--ran-theme-switch-active-color, var(--ran-color-text, #171717))}.ran-theme-switch button:focus-visible{outline:var(--ran-theme-switch-focus-outline, 2px solid var(--ran-color-primary, #006bff));outline-offset:2px}.ran-theme-switch svg{width:var(--ran-theme-switch-icon-size, 16px);height:var(--ran-theme-switch-icon-size, 16px)}",qs=["system","light","dark"],Ip={system:'<svg viewBox="0 0 16 16" aria-hidden="true"><rect x="1.5" y="2.5" width="13" height="9" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M5.5 14h5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',light:'<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="3" fill="none" stroke="currentColor" stroke-width="1.5"/><path d="M8 1v1.8M8 13.2V15M15 8h-1.8M2.8 8H1m11.4-4.4-1.3 1.3M4.9 11.1l-1.3 1.3m9.8 0-1.3-1.3M4.9 4.9 3.6 3.6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',dark:'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M13.5 9.5A6 6 0 0 1 6.5 2.5a6 6 0 1 0 7 7z" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>'},Vs="ran-theme-switch-sync",ou=class extends Ve{static get observedAttributes(){return["label-system","label-light","label-dark","sheet"]}_events=new vt;_shadowDom;_group;constructor(){super(),this._shadowDom=We(this,Bp),this._group=_e(this._shadowDom,".ran-theme-switch",()=>{const e=document.createElement("div");e.className="ran-theme-switch",e.setAttribute("part","switch"),e.setAttribute("role","group");for(const i of qs){const n=document.createElement("button");n.type="button",n.dataset.choice=i,n.setAttribute("part",`button ${i}`),n.setAttribute("aria-pressed","false"),n.innerHTML=Ip[i],e.appendChild(n)}return e})}get sheet(){return Be(this,"sheet")}set sheet(e){Le(this,"sheet",e)}get value(){return Jl()||"system"}set value(e){qs.includes(e)&&this._select(e)}_label(e){const i={system:"System theme",light:"Light theme",dark:"Dark theme"}[e];return this.getAttribute(`label-${e}`)||i}_syncLabels(){this._group.setAttribute("aria-label",this.getAttribute("label")||"Theme");for(const e of this._group.querySelectorAll("button"))e.setAttribute("aria-label",this._label(e.dataset.choice))}_reflect(){const e=this.value;for(const i of this._group.querySelectorAll("button"))i.setAttribute("aria-pressed",i.dataset.choice===e?"true":"false")}_select(e){_n(e),this._reflect(),this._syncMeta(e),document.dispatchEvent(new CustomEvent(Vs)),this.dispatchEvent(new CustomEvent("change",{detail:{theme:e},bubbles:!0,composed:!0}))}_syncMeta(e){if(typeof requestAnimationFrame>"u")return;const i=document.querySelectorAll('meta[name="theme-color"]');i.length&&requestAnimationFrame(()=>{for(const n of i)if(n.dataset.ranOriginalContent===void 0&&(n.dataset.ranOriginalContent=n.getAttribute("content")||""),e==="system")n.setAttribute("content",n.dataset.ranOriginalContent);else{const c=getComputedStyle(document.documentElement).getPropertyValue("--ran-color-bg").trim()||getComputedStyle(document.body).backgroundColor;n.setAttribute("content",c)}})}_handleClick=e=>{const i=e.target.closest?.("button")?.dataset.choice;i&&qs.includes(i)&&this._select(i)};_handleSync=()=>this._reflect();handlerExternalCss=()=>{Xe(this,this._shadowDom,"sheet",null,this.sheet)};connectedCallback(){this.handlerExternalCss(),this._syncLabels(),this._reflect(),this._events.on(this._group,"click",this._handleClick),document.addEventListener(Vs,this._handleSync),typeof window<"u"&&window.addEventListener("storage",this._handleSync)}disconnectedCallback(){this._events.abort(),document.removeEventListener(Vs,this._handleSync),typeof window<"u"&&window.removeEventListener("storage",this._handleSync)}attributeChangedCallback(e,i,n){i!==n&&(e==="sheet"&&this.handlerExternalCss(),e.startsWith("label")&&this._syncLabels())}};qe("r-theme-switch",ou);function su(e,i){Zh(i);try{return B0(e)}finally{$h()}}function Sp(e,i){const n=ua();return(i?.paths??n?.getStaticPaths()??[]).map(c=>({path:c,html:su(e(),c)}))}var xp="ran-locale",Tp=Object.freeze({}),Dp=e=>{if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}},Rp=(e,i)=>{if(!(typeof localStorage>"u"))try{localStorage.setItem(e,i)}catch{}},Lp=e=>{if(typeof navigator>"u"||!navigator.language)return null;const i=navigator.language.toLowerCase();return e.find(n=>n.toLowerCase()===i)??e.find(n=>i.startsWith(n.toLowerCase()))??e.find(n=>i.startsWith(`${n.toLowerCase()}-`))??null},lu=class{_locale;_fallback;_messages;_persist;_storageKey;_handlers=new Set;constructor(e={}){this._messages={...e.messages},this._fallback=e.fallbackLocale??"en",this._persist=e.persist??!1,this._storageKey=e.storageKey??xp,this._locale=this._resolveInitialLocale(e)}_resolveInitialLocale(e){const i=Object.keys(this._messages),n=this._persist?Dp(this._storageKey):null;if(n&&(this._messages[n]||i.length===0))return n;if(e.locale)return e.locale;if(e.detectNavigator){const c=Lp(i);if(c)return c}return this._fallback}get locale(){return this._locale}getLocale(){return this._locale}setLocale(e){e!==this._locale&&(this._locale=e,this._persist&&Rp(this._storageKey,e),this._notify())}addMessages(e,i){this._messages[e]={...this._messages[e],...i}}getMessages(e=this._locale){return this._messages[e]??{}}get availableLocales(){return Object.keys(this._messages)}t(e,i){const n=this._messages[this._locale]?.[e]??this._messages[this._fallback]?.[e]??e;return this._interpolate(n,i)}_interpolate(e,i){const n=i??Tp;return e.replace(/\{\{|\}\}|\{(\w+)\}/g,(c,g)=>c==="{{"?"{":c==="}}"?"}":n[g]!=null?String(n[g]):c)}onChange(e){return this._handlers.add(e),()=>{this._handlers.delete(e)}}_notify(){for(const e of this._handlers)e(this._locale)}destroy(){this._handlers.clear()}},Ws=null;function Mp(e={}){return Ws=new lu(e),Ws}function Fp(){return Ws}var Op=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{position:relative;display:block}.ran-scratch-ticket{position:relative;display:block;width:100%;height:100%}.ran-scratch-ticket-award{position:absolute;top:0;left:0;display:block;width:100%;height:100%;background:#000;z-index:1}.ran-scratch-ticket-canvas{position:absolute;top:0;left:0;display:block;width:100%;height:100%;z-index:2}",Pp=class extends Ve{scratchTicketContainer;scratchTicket;state;scratchAward;_shadowDom;static get observedAttributes(){return["disabled","icon","effect","iconSize","sheet"]}constructor(){super(),this._shadowDom=We(this,Op);const e=_e(this._shadowDom,".ran-scratch-ticket",()=>{const c=Ne("canvas").class("ran-scratch-ticket-canvas").style("width","100%").style("height","100%").build(),g=K().class("ran-scratch-ticket-award").build();return K().class("ran-scratch-ticket").children(c,g).build()}),i=e.querySelector(".ran-scratch-ticket-award"),n=e.querySelector(".ran-scratch-ticket-canvas");this.scratchTicketContainer=e,this.scratchAward=i,this.scratchTicket=n,this.state={touchStart:!1,scratchArea:0}}touchStartScratch=e=>{this.state.touchStart=!0};touchMoveScratch=()=>{if(this.state.touchStart){const e=this.scratchTicket.getContext("2d");if(!e)return;this.state.scratchArea+=30,e.beginPath(),e.arc(100,100,30,0,2*Math.PI),e.globalCompositeOperation="destination-out",e.fill(),e.closePath()}};touchEndScratch=()=>{this.state.touchStart=!1;const{width:e,height:i}=this.scratchTicket,n=this.scratchTicket.getContext("2d");n&&this.state.scratchArea>e*i*.03&&(this.state.scratchArea=0,n.clearRect(0,0,e,i))};drawScratchTicket=()=>{const e=this.scratchTicket.getContext("2d");if(!this.scratchTicketContainer||!e)return;const i=new Image;i.src="",i.onload=()=>{e.drawImage(i,0,0,this.scratchTicket.width,this.scratchTicket.height)},this.scratchTicket.addEventListener("touchstart",this.touchStartScratch),this.scratchTicket.addEventListener("touchmove",this.touchMoveScratch),this.scratchTicket.addEventListener("touchend",this.touchEndScratch)};attributeChangedCallback(){this._shadowDom.contains(this.scratchTicketContainer)||this._shadowDom.appendChild(this.scratchTicketContainer),this.drawScratchTicket()}};return qe("r-scratch",Pp),ke.ARROW_TYPE=sf,ke.Button=uc,ke.Card=Jh,ke.CustomMessage=wc,ke.Dropdown=Rc,ke.Form=Xh,ke.I18nCore=lu,ke.ICON_NAME_AMP=$f,ke.Icon=pc,ke.ImageElement=mc,ke.Input=vc,ke.Link=nu,ke.Loading=Xc,ke.Math=Wh,ke.PLACEMENT_TYPE=Jf,ke.Popover=Vc,ke.Progress=Kc,ke.RadarChart=Tc,ke.RanCheckbox=zc,ke.RanColorPicker=Wc,ke.RanModal=Yc,ke.RanPlayer=Pf,ke.Route=au,ke.Router=iu,ke.RouterCore=ru,ke.Section=_h,ke.Select=Fc,ke.Skeleton=Cc,ke.TabPane=Ec,ke.Tabs=kc,ke.ThemeSwitch=ou,ke.clearSSGPath=$h,ke.clearThemeToken=jl,ke.createI18n=Mp,ke.createRouter=wp,ke.enableMpaViewTransitions=Cp,ke.generateStaticPages=Sp,ke.getSSGPath=jh,ke.getTheme=Jl,ke.initTheme=l0,ke.registerIcon=no,ke.registerIcons=fc,ke.renderStaticPage=su,ke.setSSGPath=Zh,ke.setTheme=_n,ke.setThemeToken=_l,ke.setThemeTokens=s0,ke.useI18n=Fp,ke.useRouter=ua,ke})({});