@kinxcdn/commerce-player 1.7.0-alpha.0 → 1.7.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commerce-player.min.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/styles.css +2 -2
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -37,4 +37,4 @@ var kr={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24
|
|
|
37
37
|
*
|
|
38
38
|
* This source code is licensed under the ISC license.
|
|
39
39
|
* See the LICENSE file in the root directory of this source tree.
|
|
40
|
-
*/function Qr(t,r=[]){let i=[];const s=()=>{const r=i.map(t=>e.createContext(t));return function(i){const s=i?.[t]||r;return e.useMemo(()=>({[`__scope${t}`]:{...i,[t]:s}}),[i,s])}};return s.scopeName=t,[function(r,s){const n=e.createContext(s),a=i.length;i=[...i,s];const o=r=>{const{scope:i,children:s,...o}=r,l=i?.[t]?.[a]||n,c=e.useMemo(()=>o,Object.values(o));return b(l.Provider,{value:c,children:s})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||n,c=e.useContext(l);if(c)return c;if(void 0!==s)return s;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},Zr(s,...r)]}function Zr(...t){const r=t[0];if(1===t.length)return r;const i=()=>{const i=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const s=i.reduce((e,{useScope:r,scopeName:i})=>({...e,...r(t)[`__scope${i}`]}),{});return e.useMemo(()=>({[`__scope${r.scopeName}`]:s}),[s])}};return i.scopeName=r.scopeName,i}function Jr(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function ei(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Jr(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():Jr(e[t],null)}}}}function ti(...t){return e.useCallback(ei(...t),t)}var ri=e.forwardRef((t,r)=>{const{children:i,...s}=t,n=e.Children.toArray(i),a=n.find(ni);if(a){const t=a.props.children,i=n.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(ii,{...s,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(ii,{...s,ref:r,children:i})});ri.displayName="Slot";var ii=e.forwardRef((t,r)=>{const{children:i,...s}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),n=function(e,t){const r={...t};for(const i in t){const s=e[i],n=t[i];/^on[A-Z]/.test(i)?s&&n?r[i]=(...e)=>{n(...e),s(...e)}:s&&(r[i]=s):"style"===i?r[i]={...s,...n}:"className"===i&&(r[i]=[s,n].filter(Boolean).join(" "))}return{...e,...r}}(s,i.props);return i.type!==e.Fragment&&(n.ref=r?ei(r,t):t),e.cloneElement(i,n)}return e.Children.count(i)>1?e.Children.only(null):null});ii.displayName="SlotClone";var si=({children:e})=>b(E,{children:e});function ni(t){return e.isValidElement(t)&&t.type===si}function ai(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function oi(...e){return t=>{let r=!1;const i=e.map(e=>{const i=ai(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():ai(e[t],null)}}}}function li(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function ci(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}function di({prop:t,defaultProp:r,onChange:i=()=>{}}){const[s,n]=function({defaultProp:t,onChange:r}){const i=e.useState(t),[s]=i,n=e.useRef(s),a=ci(r);return e.useEffect(()=>{n.current!==s&&(a(s),n.current=s)},[s,n,a]),i}({defaultProp:r,onChange:i}),a=void 0!==t,o=a?t:s,l=ci(i);return[o,e.useCallback(e=>{if(a){const r="function"==typeof e?e(t):e;r!==t&&l(r)}else n(e)},[a,t,n,l])]}var ui=e.forwardRef((t,r)=>{const{children:i,...s}=t,n=e.Children.toArray(i),a=n.find(pi);if(a){const t=a.props.children,i=n.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(hi,{...s,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(hi,{...s,ref:r,children:i})});ui.displayName="Slot";var hi=e.forwardRef((t,r)=>{const{children:i,...s}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),n=function(e,t){const r={...t};for(const i in t){const s=e[i],n=t[i];/^on[A-Z]/.test(i)?s&&n?r[i]=(...e)=>{n(...e),s(...e)}:s&&(r[i]=s):"style"===i?r[i]={...s,...n}:"className"===i&&(r[i]=[s,n].filter(Boolean).join(" "))}return{...e,...r}}(s,i.props);return i.type!==e.Fragment&&(n.ref=r?oi(r,t):t),e.cloneElement(i,n)}return e.Children.count(i)>1?e.Children.only(null):null});hi.displayName="SlotClone";var fi=({children:e})=>b(E,{children:e});function pi(t){return e.isValidElement(t)&&t.type===fi}var mi=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((t,r)=>{const i=e.forwardRef((e,t)=>{const{asChild:i,...s}=e,n=i?ui:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(n,{...s,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{}),gi=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{};function vi(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function yi(...e){return t=>{let r=!1;const i=e.map(e=>{const i=vi(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():vi(e[t],null)}}}}function bi(...t){return e.useCallback(yi(...t),t)}var Ei=e.forwardRef((t,r)=>{const{children:i,...s}=t,n=e.Children.toArray(i),a=n.find(Ti);if(a){const t=a.props.children,i=n.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(wi,{...s,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(wi,{...s,ref:r,children:i})});Ei.displayName="Slot";var wi=e.forwardRef((t,r)=>{const{children:i,...s}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),n=function(e,t){const r={...t};for(const i in t){const s=e[i],n=t[i];/^on[A-Z]/.test(i)?s&&n?r[i]=(...e)=>{n(...e),s(...e)}:s&&(r[i]=s):"style"===i?r[i]={...s,...n}:"className"===i&&(r[i]=[s,n].filter(Boolean).join(" "))}return{...e,...r}}(s,i.props);return i.type!==e.Fragment&&(n.ref=r?yi(r,t):t),e.cloneElement(i,n)}return e.Children.count(i)>1?e.Children.only(null):null});wi.displayName="SlotClone";var Si=({children:e})=>b(E,{children:e});function Ti(t){return e.isValidElement(t)&&t.type===Si}var xi=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((t,r)=>{const i=e.forwardRef((e,t)=>{const{asChild:i,...s}=e,n=i?Ei:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(n,{...s,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{});var Ai=t=>{const{present:r,children:i}=t,s=function(t){const[r,i]=e.useState(),s=e.useRef({}),n=e.useRef(t),a=e.useRef("none"),o=t?"mounted":"unmounted",[l,c]=function(t,r){return e.useReducer((e,t)=>r[e][t]??e,t)}(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=ki(s.current);a.current="mounted"===l?e:"none"},[l]),gi(()=>{const e=s.current,r=n.current;if(r!==t){const i=a.current,s=ki(e);if(t)c("MOUNT");else if("none"===s||"none"===e?.display)c("UNMOUNT");else{c(r&&i!==s?"ANIMATION_OUT":"UNMOUNT")}n.current=t}},[t,c]),gi(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=ki(s.current).includes(i.animationName);if(i.target===r&&a&&(c("ANIMATION_END"),!n.current)){const i=r.style.animationFillMode;r.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===r.style.animationFillMode&&(r.style.animationFillMode=i)})}},o=e=>{e.target===r&&(a.current=ki(s.current))};return r.addEventListener("animationstart",o),r.addEventListener("animationcancel",i),r.addEventListener("animationend",i),()=>{t.clearTimeout(e),r.removeEventListener("animationstart",o),r.removeEventListener("animationcancel",i),r.removeEventListener("animationend",i)}}c("ANIMATION_END")},[r,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{e&&(s.current=getComputedStyle(e)),i(e)},[])}}(r),n="function"==typeof i?i({present:s.isPresent}):e.Children.only(i),a=bi(s.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(n));return"function"==typeof i||s.isPresent?e.cloneElement(n,{ref:a}):null};function ki(e){return e?.animationName||"none"}Ai.displayName="Presence";var Li=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{},Ii=e["useId".toString()]||(()=>{}),Ri=0;function Pi(t){const[r,i]=e.useState(Ii());return Li(()=>{i(e=>e??String(Ri++))},[t]),r?`radix-${r}`:""}var Ci="Collapsible",[Di,_i]=Qr(Ci),[Oi,Mi]=Di(Ci),Ni=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,open:s,defaultOpen:n,disabled:a,onOpenChange:o,...l}=t,[c=!1,d]=di({prop:s,defaultProp:n,onChange:o});return b(Oi,{scope:i,disabled:a,contentId:Pi(),open:c,onOpenToggle:e.useCallback(()=>d(e=>!e),[d]),children:b(xi.div,{"data-state":Gi(c),"data-disabled":a?"":void 0,...l,ref:r})})});Ni.displayName=Ci;var Fi="CollapsibleTrigger",$i=e.forwardRef((e,t)=>{const{__scopeCollapsible:r,...i}=e,s=Mi(Fi,r);return b(xi.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":Gi(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...i,ref:t,onClick:li(e.onClick,s.onOpenToggle)})});$i.displayName=Fi;var Bi="CollapsibleContent",Ui=e.forwardRef((e,t)=>{const{forceMount:r,...i}=e,s=Mi(Bi,e.__scopeCollapsible);return b(Ai,{present:r||s.open,children:({present:e})=>b(zi,{...i,ref:t,present:e})})});Ui.displayName=Bi;var zi=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,present:s,children:n,...a}=t,o=Mi(Bi,i),[l,c]=e.useState(s),d=e.useRef(null),u=bi(r,d),h=e.useRef(0),f=h.current,p=e.useRef(0),m=p.current,g=o.open||l,v=e.useRef(g),y=e.useRef(void 0);return e.useEffect(()=>{const e=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(e)},[]),gi(()=>{const e=d.current;if(e){y.current=y.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";const t=e.getBoundingClientRect();h.current=t.height,p.current=t.width,v.current||(e.style.transitionDuration=y.current.transitionDuration,e.style.animationName=y.current.animationName),c(s)}},[o.open,s]),b(xi.div,{"data-state":Gi(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!g,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...t.style},children:g&&n})});function Gi(e){return e?"open":"closed"}var ji=Ni,Hi=$i,Vi=Ui,Wi=e.createContext(void 0);var Yi="Accordion",Ki=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[qi,Xi,Qi]=function(e){const r=e+"CollectionProvider",[i,s]=Qr(r),[n,a]=i(r,{collectionRef:{current:null},itemMap:new Map}),o=e=>{const{scope:r,children:i}=e,s=t.useRef(null),a=t.useRef(new Map).current;return b(n,{scope:r,itemMap:a,collectionRef:s,children:i})};o.displayName=r;const l=e+"CollectionSlot",c=t.forwardRef((e,t)=>{const{scope:r,children:i}=e,s=ti(t,a(l,r).collectionRef);return b(ri,{ref:s,children:i})});c.displayName=l;const d=e+"CollectionItemSlot",u="data-radix-collection-item",h=t.forwardRef((e,r)=>{const{scope:i,children:s,...n}=e,o=t.useRef(null),l=ti(r,o),c=a(d,i);return t.useEffect(()=>(c.itemMap.set(o,{ref:o,...n}),()=>{c.itemMap.delete(o)})),b(ri,{[u]:"",ref:l,children:s})});return h.displayName=d,[{Provider:o,Slot:c,ItemSlot:h},function(r){const i=a(e+"CollectionConsumer",r),s=t.useCallback(()=>{const e=i.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll(`[${u}]`)),r=Array.from(i.itemMap.values()).sort((e,r)=>t.indexOf(e.ref.current)-t.indexOf(r.ref.current));return r},[i.collectionRef,i.itemMap]);return s},s]}(Yi),[Zi,Ji]=Qr(Yi,[Qi,_i]),es=_i(),ts=t.forwardRef((e,t)=>{const{type:r,...i}=e,s=i,n=i;return b(qi.Provider,{scope:e.__scopeAccordion,children:"multiple"===r?b(os,{...n,ref:t}):b(as,{...s,ref:t})})});ts.displayName=Yi;var[rs,is]=Zi(Yi),[ss,ns]=Zi(Yi,{collapsible:!1}),as=t.forwardRef((e,r)=>{const{value:i,defaultValue:s,onValueChange:n=()=>{},collapsible:a=!1,...o}=e,[l,c]=di({prop:i,defaultProp:s,onChange:n});return b(rs,{scope:e.__scopeAccordion,value:l?[l]:[],onItemOpen:c,onItemClose:t.useCallback(()=>a&&c(""),[a,c]),children:b(ss,{scope:e.__scopeAccordion,collapsible:a,children:b(ds,{...o,ref:r})})})}),os=t.forwardRef((e,r)=>{const{value:i,defaultValue:s,onValueChange:n=()=>{},...a}=e,[o=[],l]=di({prop:i,defaultProp:s,onChange:n}),c=t.useCallback(e=>l((t=[])=>[...t,e]),[l]),d=t.useCallback(e=>l((t=[])=>t.filter(t=>t!==e)),[l]);return b(rs,{scope:e.__scopeAccordion,value:o,onItemOpen:c,onItemClose:d,children:b(ss,{scope:e.__scopeAccordion,collapsible:!0,children:b(ds,{...a,ref:r})})})}),[ls,cs]=Zi(Yi),ds=t.forwardRef((r,i)=>{const{__scopeAccordion:s,disabled:n,dir:a,orientation:o="vertical",...l}=r,c=function(...t){return e.useCallback(oi(...t),t)}(t.useRef(null),i),d=Xi(s),u="ltr"===function(t){const r=e.useContext(Wi);return t||r||"ltr"}(a),h=li(r.onKeyDown,e=>{if(!Ki.includes(e.key))return;const t=e.target,r=d().filter(e=>!e.ref.current?.disabled),i=r.findIndex(e=>e.ref.current===t),s=r.length;if(-1===i)return;e.preventDefault();let n=i;const a=s-1,l=()=>{n=i+1,n>a&&(n=0)},c=()=>{n=i-1,n<0&&(n=a)};switch(e.key){case"Home":n=0;break;case"End":n=a;break;case"ArrowRight":"horizontal"===o&&(u?l():c());break;case"ArrowDown":"vertical"===o&&l();break;case"ArrowLeft":"horizontal"===o&&(u?c():l());break;case"ArrowUp":"vertical"===o&&c()}const h=n%s;r[h].ref.current?.focus()});return b(ls,{scope:s,disabled:n,direction:a,orientation:o,children:b(qi.Slot,{scope:s,children:b(mi.div,{...l,"data-orientation":o,ref:c,onKeyDown:n?void 0:h})})})}),us="AccordionItem",[hs,fs]=Zi(us),ps=t.forwardRef((e,t)=>{const{__scopeAccordion:r,value:i,...s}=e,n=cs(us,r),a=is(us,r),o=es(r),l=Pi(),c=i&&a.value.includes(i)||!1,d=n.disabled||e.disabled;return b(hs,{scope:r,open:c,disabled:d,triggerId:l,children:b(ji,{"data-orientation":n.orientation,"data-state":ws(c),...o,...s,ref:t,disabled:d,open:c,onOpenChange:e=>{e?a.onItemOpen(i):a.onItemClose(i)}})})});ps.displayName=us;var ms="AccordionHeader",gs=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,s=cs(Yi,r),n=fs(ms,r);return b(mi.h3,{"data-orientation":s.orientation,"data-state":ws(n.open),"data-disabled":n.disabled?"":void 0,...i,ref:t})});gs.displayName=ms;var vs="AccordionTrigger",ys=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,s=cs(Yi,r),n=fs(vs,r),a=ns(vs,r),o=es(r);return b(qi.ItemSlot,{scope:r,children:b(Hi,{"aria-disabled":n.open&&!a.collapsible||void 0,"data-orientation":s.orientation,id:n.triggerId,...o,...i,ref:t})})});ys.displayName=vs;var bs="AccordionContent",Es=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,s=cs(Yi,r),n=fs(bs,r),a=es(r);return b(Vi,{role:"region","aria-labelledby":n.triggerId,"data-orientation":s.orientation,...a,...i,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});function ws(e){return e?"open":"closed"}Es.displayName=bs;var Ss=ts,Ts=ps,xs=gs,As=ys,ks=Es;function Ls(t){var r=T(t,[]);return e.createElement(Ss,Object.assign({"data-slot":"accordion"},r))}function Is(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(Ts,Object.assign({"data-slot":"accordion-item",className:St("border-b last:border-b-0",r)},i))}function Rs(t){var{className:r,children:i}=t,s=T(t,["className","children"]);return e.createElement(xs,{className:"flex"},e.createElement(As,Object.assign({"data-slot":"accordion-trigger",className:St("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",r)},s),i,e.createElement(Rr,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"})))}function Ps(t){var{className:r,children:i}=t,s=T(t,["className","children"]);return e.createElement(ks,Object.assign({"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"},s),e.createElement("div",{className:St("pt-0 pb-4",r)},i))}const Cs=({title:e,content:r})=>t.createElement(Ls,{style:{borderRadius:"0.625rem"},type:"single",collapsible:!0,className:"bg-white px-4",defaultValue:"item"},t.createElement(Is,{value:"item"},t.createElement(Rs,{className:""},e),t.createElement(Ps,{className:"text-gray-700"},r))),Ds=({logo:e})=>t.createElement("div",{className:"w-full bg-zinc-700 h-[60px] flex"},t.createElement("div",{className:"my-0 mx-auto w-full px-[24px] flex items-center justify-between"},e?t.createElement("div",{className:"h-10 max-w-[160px]"},t.createElement("img",{src:e.thumbPath,alt:e.logoName,width:100,height:100,className:"object-contain w-full h-full"})):t.createElement("div",null),t.createElement("button",{className:"text-white cursor-pointer"},t.createElement(zr,null)))),_s=e=>{const{playerSettings:r,shortform:{description:i,productsInfo:s,logo:n,brand:a,title:o},player:l}=e;return t.createElement("div",{className:"w-full h-full bg-[#f4f4f4] overflow-scroll"},t.createElement(Ds,{logo:n}),t.createElement("div",{className:" w-full h-full flex justify-between p-10 gap-10"},t.createElement("div",{className:""},t.createElement("div",{className:"flex gap-4 w-full mb-2 h-[125px] flex-col"},a?t.createElement("div",{className:"items-center flex gap-3"},a.thumbPath&&t.createElement("div",{className:"w-16 h-16 bg-white rounded-full border "},t.createElement("img",{src:a.thumbPath,alt:a.brandName,width:100,height:100,className:"object-contain w-full h-full rounded-full"})),t.createElement("div",null,t.createElement("p",null,a.brandName),t.createElement("p",{className:"text-lg font-semibold"},o))):t.createElement("p",{className:"text-xl font-semibold"},o),t.createElement(Gr,null)),t.createElement("div",{className:"w-full pb-10 flex gap-4 justify-center"},t.createElement("div",{className:"flex gap-3"},l),t.createElement("div",{className:"flex flex-col gap-4 justify-end"},t.createElement(Kr,{rounded:!0}),t.createElement(qr,{rounded:!0}),t.createElement(Xr,{rounded:!0})))),t.createElement("div",{className:"flex flex-col gap-4 max-w-[40%]"},i&&t.createElement(Cs,{title:"숏클립 안내",content:t.createElement("p",{className:"font-medium"},i)}),t.createElement(Cs,{title:"상품 목록",content:t.createElement(t.Fragment,null,t.createElement("div",{className:"max-h-[300px] overflow-y-auto font-medium"},s.map((e,r)=>t.createElement(t.Fragment,null,t.createElement(Vr,{product:e}),r!==s.length-1&&t.createElement("div",{className:"h-1 w-full border-t my-2"})))),t.createElement("button",{className:"w-full mt-3 border rounded py-2 px-4 cursor-pointer",disabled:!(null==s?void 0:s.length)},"상품 전체 보기"))}),r.comment&&t.createElement(Cs,{title:"댓글",content:t.createElement(Wr,null)}))))};function Os(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function Ms(e,t){void 0===e&&(e={}),void 0===t&&(t={}),Object.keys(t).forEach(r=>{void 0===e[r]?e[r]=t[r]:Os(t[r])&&Os(e[r])&&Object.keys(t[r]).length>0&&Ms(e[r],t[r])})}const Ns={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function Fs(){const e="undefined"!=typeof document?document:{};return Ms(e,Ns),e}const $s={document:Ns,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:e=>"undefined"==typeof setTimeout?(e(),null):setTimeout(e,0),cancelAnimationFrame(e){"undefined"!=typeof setTimeout&&clearTimeout(e)}};function Bs(){const e="undefined"!=typeof window?window:{};return Ms(e,$s),e}function Us(e,t){return void 0===t&&(t=0),setTimeout(e,t)}function zs(){return Date.now()}function Gs(e,t){void 0===t&&(t="x");const r=Bs();let i,s,n;const a=function(e){const t=Bs();let r;return t.getComputedStyle&&(r=t.getComputedStyle(e,null)),!r&&e.currentStyle&&(r=e.currentStyle),r||(r=e.style),r}(e);return r.WebKitCSSMatrix?(s=a.transform||a.webkitTransform,s.split(",").length>6&&(s=s.split(", ").map(e=>e.replace(",",".")).join(", ")),n=new r.WebKitCSSMatrix("none"===s?"":s)):(n=a.MozTransform||a.OTransform||a.MsTransform||a.msTransform||a.transform||a.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),i=n.toString().split(",")),"x"===t&&(s=r.WebKitCSSMatrix?n.m41:16===i.length?parseFloat(i[12]):parseFloat(i[4])),"y"===t&&(s=r.WebKitCSSMatrix?n.m42:16===i.length?parseFloat(i[13]):parseFloat(i[5])),s||0}function js(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function Hs(e){return"undefined"!=typeof window&&void 0!==window.HTMLElement?e instanceof HTMLElement:e&&(1===e.nodeType||11===e.nodeType)}function Vs(){const e=Object(arguments.length<=0?void 0:arguments[0]),t=["__proto__","constructor","prototype"];for(let r=1;r<arguments.length;r+=1){const i=r<0||arguments.length<=r?void 0:arguments[r];if(null!=i&&!Hs(i)){const r=Object.keys(Object(i)).filter(e=>t.indexOf(e)<0);for(let t=0,s=r.length;t<s;t+=1){const s=r[t],n=Object.getOwnPropertyDescriptor(i,s);void 0!==n&&n.enumerable&&(js(e[s])&&js(i[s])?i[s].__swiper__?e[s]=i[s]:Vs(e[s],i[s]):!js(e[s])&&js(i[s])?(e[s]={},i[s].__swiper__?e[s]=i[s]:Vs(e[s],i[s])):e[s]=i[s])}}}return e}function Ws(e,t,r){e.style.setProperty(t,r)}function Ys(e){let{swiper:t,targetPosition:r,side:i}=e;const s=Bs(),n=-t.translate;let a,o=null;const l=t.params.speed;t.wrapperEl.style.scrollSnapType="none",s.cancelAnimationFrame(t.cssModeFrameID);const c=r>n?"next":"prev",d=(e,t)=>"next"===c&&e>=t||"prev"===c&&e<=t,u=()=>{a=(new Date).getTime(),null===o&&(o=a);const e=Math.max(Math.min((a-o)/l,1),0),c=.5-Math.cos(e*Math.PI)/2;let h=n+c*(r-n);if(d(h,r)&&(h=r),t.wrapperEl.scrollTo({[i]:h}),d(h,r))return t.wrapperEl.style.overflow="hidden",t.wrapperEl.style.scrollSnapType="",setTimeout(()=>{t.wrapperEl.style.overflow="",t.wrapperEl.scrollTo({[i]:h})}),void s.cancelAnimationFrame(t.cssModeFrameID);t.cssModeFrameID=s.requestAnimationFrame(u)};u()}function Ks(e){return e.querySelector(".swiper-slide-transform")||e.shadowRoot&&e.shadowRoot.querySelector(".swiper-slide-transform")||e}function qs(e,t){void 0===t&&(t="");const r=[...e.children];return e instanceof HTMLSlotElement&&r.push(...e.assignedElements()),t?r.filter(e=>e.matches(t)):r}function Xs(e){try{return void console.warn(e)}catch(e){}}function Qs(e,t){void 0===t&&(t=[]);const r=document.createElement(e);return r.classList.add(...Array.isArray(t)?t:function(e){return void 0===e&&(e=""),e.trim().split(" ").filter(e=>!!e.trim())}(t)),r}function Zs(e,t){return Bs().getComputedStyle(e,null).getPropertyValue(t)}function Js(e){let t,r=e;if(r){for(t=0;null!==(r=r.previousSibling);)1===r.nodeType&&(t+=1);return t}}function en(e,t,r){const i=Bs();return e["width"===t?"offsetWidth":"offsetHeight"]+parseFloat(i.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-right":"margin-top"))+parseFloat(i.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-left":"margin-bottom"))}function tn(e){return(Array.isArray(e)?e:[e]).filter(e=>!!e)}let rn,sn,nn;function an(){return rn||(rn=function(){const e=Bs(),t=Fs();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}()),rn}function on(e){return void 0===e&&(e={}),sn||(sn=function(e){let{userAgent:t}=void 0===e?{}:e;const r=an(),i=Bs(),s=i.navigator.platform,n=t||i.navigator.userAgent,a={ios:!1,android:!1},o=i.screen.width,l=i.screen.height,c=n.match(/(Android);?[\s\/]+([\d.]+)?/);let d=n.match(/(iPad).*OS\s([\d_]+)/);const u=n.match(/(iPod)(.*OS\s([\d_]+))?/),h=!d&&n.match(/(iPhone\sOS|iOS)\s([\d_]+)/),f="Win32"===s;let p="MacIntel"===s;return!d&&p&&r.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${o}x${l}`)>=0&&(d=n.match(/(Version)\/([\d.]+)/),d||(d=[0,1,"13_0_0"]),p=!1),c&&!f&&(a.os="android",a.android=!0),(d||h||u)&&(a.os="ios",a.ios=!0),a}(e)),sn}function ln(){return nn||(nn=function(){const e=Bs(),t=on();let r=!1;function i(){const t=e.navigator.userAgent.toLowerCase();return t.indexOf("safari")>=0&&t.indexOf("chrome")<0&&t.indexOf("android")<0}if(i()){const t=String(e.navigator.userAgent);if(t.includes("Version/")){const[e,i]=t.split("Version/")[1].split(" ")[0].split(".").map(e=>Number(e));r=e<16||16===e&&i<2}}const s=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),n=i();return{isSafari:r||n,needPerspectiveFix:r,need3dFix:n||s&&t.ios,isWebView:s}}()),nn}var cn={on(e,t,r){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;const s=r?"unshift":"push";return e.split(" ").forEach(e=>{i.eventsListeners[e]||(i.eventsListeners[e]=[]),i.eventsListeners[e][s](t)}),i},once(e,t,r){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;function s(){i.off(e,s),s.__emitterProxy&&delete s.__emitterProxy;for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];t.apply(i,n)}return s.__emitterProxy=t,i.on(e,s,r)},onAny(e,t){const r=this;if(!r.eventsListeners||r.destroyed)return r;if("function"!=typeof e)return r;const i=t?"unshift":"push";return r.eventsAnyListeners.indexOf(e)<0&&r.eventsAnyListeners[i](e),r},offAny(e){const t=this;if(!t.eventsListeners||t.destroyed)return t;if(!t.eventsAnyListeners)return t;const r=t.eventsAnyListeners.indexOf(e);return r>=0&&t.eventsAnyListeners.splice(r,1),t},off(e,t){const r=this;return!r.eventsListeners||r.destroyed?r:r.eventsListeners?(e.split(" ").forEach(e=>{void 0===t?r.eventsListeners[e]=[]:r.eventsListeners[e]&&r.eventsListeners[e].forEach((i,s)=>{(i===t||i.__emitterProxy&&i.__emitterProxy===t)&&r.eventsListeners[e].splice(s,1)})}),r):r},emit(){const e=this;if(!e.eventsListeners||e.destroyed)return e;if(!e.eventsListeners)return e;let t,r,i;for(var s=arguments.length,n=new Array(s),a=0;a<s;a++)n[a]=arguments[a];"string"==typeof n[0]||Array.isArray(n[0])?(t=n[0],r=n.slice(1,n.length),i=e):(t=n[0].events,r=n[0].data,i=n[0].context||e),r.unshift(i);return(Array.isArray(t)?t:t.split(" ")).forEach(t=>{e.eventsAnyListeners&&e.eventsAnyListeners.length&&e.eventsAnyListeners.forEach(e=>{e.apply(i,[t,...r])}),e.eventsListeners&&e.eventsListeners[t]&&e.eventsListeners[t].forEach(e=>{e.apply(i,r)})}),e}};const dn=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const un=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const hn=(e,t)=>{if(!e||e.destroyed||!e.params)return;const r=t.closest(e.isElement?"swiper-slide":`.${e.params.slideClass}`);if(r){let t=r.querySelector(`.${e.params.lazyPreloaderClass}`);!t&&e.isElement&&(r.shadowRoot?t=r.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`):requestAnimationFrame(()=>{r.shadowRoot&&(t=r.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`),t&&t.remove())})),t&&t.remove()}},fn=(e,t)=>{if(!e.slides[t])return;const r=e.slides[t].querySelector('[loading="lazy"]');r&&r.removeAttribute("loading")},pn=e=>{if(!e||e.destroyed||!e.params)return;let t=e.params.lazyPreloadPrevNext;const r=e.slides.length;if(!r||!t||t<0)return;t=Math.min(t,r);const i="auto"===e.params.slidesPerView?e.slidesPerViewDynamic():Math.ceil(e.params.slidesPerView),s=e.activeIndex;if(e.params.grid&&e.params.grid.rows>1){const r=s,n=[r-t];return n.push(...Array.from({length:t}).map((e,t)=>r+i+t)),void e.slides.forEach((t,r)=>{n.includes(t.column)&&fn(e,r)})}const n=s+i-1;if(e.params.rewind||e.params.loop)for(let i=s-t;i<=n+t;i+=1){const t=(i%r+r)%r;(t<s||t>n)&&fn(e,t)}else for(let i=Math.max(s-t,0);i<=Math.min(n+t,r-1);i+=1)i!==s&&(i>n||i<s)&&fn(e,i)};var mn={updateSize:function(){const e=this;let t,r;const i=e.el;t=void 0!==e.params.width&&null!==e.params.width?e.params.width:i.clientWidth,r=void 0!==e.params.height&&null!==e.params.height?e.params.height:i.clientHeight,0===t&&e.isHorizontal()||0===r&&e.isVertical()||(t=t-parseInt(Zs(i,"padding-left")||0,10)-parseInt(Zs(i,"padding-right")||0,10),r=r-parseInt(Zs(i,"padding-top")||0,10)-parseInt(Zs(i,"padding-bottom")||0,10),Number.isNaN(t)&&(t=0),Number.isNaN(r)&&(r=0),Object.assign(e,{width:t,height:r,size:e.isHorizontal()?t:r}))},updateSlides:function(){const e=this;function t(t,r){return parseFloat(t.getPropertyValue(e.getDirectionLabel(r))||0)}const r=e.params,{wrapperEl:i,slidesEl:s,size:n,rtlTranslate:a,wrongRTL:o}=e,l=e.virtual&&r.virtual.enabled,c=l?e.virtual.slides.length:e.slides.length,d=qs(s,`.${e.params.slideClass}, swiper-slide`),u=l?e.virtual.slides.length:d.length;let h=[];const f=[],p=[];let m=r.slidesOffsetBefore;"function"==typeof m&&(m=r.slidesOffsetBefore.call(e));let g=r.slidesOffsetAfter;"function"==typeof g&&(g=r.slidesOffsetAfter.call(e));const v=e.snapGrid.length,y=e.slidesGrid.length;let b=r.spaceBetween,E=-m,w=0,S=0;if(void 0===n)return;"string"==typeof b&&b.indexOf("%")>=0?b=parseFloat(b.replace("%",""))/100*n:"string"==typeof b&&(b=parseFloat(b)),e.virtualSize=-b,d.forEach(e=>{a?e.style.marginLeft="":e.style.marginRight="",e.style.marginBottom="",e.style.marginTop=""}),r.centeredSlides&&r.cssMode&&(Ws(i,"--swiper-centered-offset-before",""),Ws(i,"--swiper-centered-offset-after",""));const T=r.grid&&r.grid.rows>1&&e.grid;let x;T?e.grid.initSlides(d):e.grid&&e.grid.unsetSlides();const A="auto"===r.slidesPerView&&r.breakpoints&&Object.keys(r.breakpoints).filter(e=>void 0!==r.breakpoints[e].slidesPerView).length>0;for(let i=0;i<u;i+=1){let s;if(x=0,d[i]&&(s=d[i]),T&&e.grid.updateSlide(i,s,d),!d[i]||"none"!==Zs(s,"display")){if("auto"===r.slidesPerView){A&&(d[i].style[e.getDirectionLabel("width")]="");const n=getComputedStyle(s),a=s.style.transform,o=s.style.webkitTransform;if(a&&(s.style.transform="none"),o&&(s.style.webkitTransform="none"),r.roundLengths)x=e.isHorizontal()?en(s,"width"):en(s,"height");else{const e=t(n,"width"),r=t(n,"padding-left"),i=t(n,"padding-right"),a=t(n,"margin-left"),o=t(n,"margin-right"),l=n.getPropertyValue("box-sizing");if(l&&"border-box"===l)x=e+a+o;else{const{clientWidth:t,offsetWidth:n}=s;x=e+r+i+a+o+(n-t)}}a&&(s.style.transform=a),o&&(s.style.webkitTransform=o),r.roundLengths&&(x=Math.floor(x))}else x=(n-(r.slidesPerView-1)*b)/r.slidesPerView,r.roundLengths&&(x=Math.floor(x)),d[i]&&(d[i].style[e.getDirectionLabel("width")]=`${x}px`);d[i]&&(d[i].swiperSlideSize=x),p.push(x),r.centeredSlides?(E=E+x/2+w/2+b,0===w&&0!==i&&(E=E-n/2-b),0===i&&(E=E-n/2-b),Math.abs(E)<.001&&(E=0),r.roundLengths&&(E=Math.floor(E)),S%r.slidesPerGroup===0&&h.push(E),f.push(E)):(r.roundLengths&&(E=Math.floor(E)),(S-Math.min(e.params.slidesPerGroupSkip,S))%e.params.slidesPerGroup===0&&h.push(E),f.push(E),E=E+x+b),e.virtualSize+=x+b,w=x,S+=1}}if(e.virtualSize=Math.max(e.virtualSize,n)+g,a&&o&&("slide"===r.effect||"coverflow"===r.effect)&&(i.style.width=`${e.virtualSize+b}px`),r.setWrapperSize&&(i.style[e.getDirectionLabel("width")]=`${e.virtualSize+b}px`),T&&e.grid.updateWrapperSize(x,h),!r.centeredSlides){const t=[];for(let i=0;i<h.length;i+=1){let s=h[i];r.roundLengths&&(s=Math.floor(s)),h[i]<=e.virtualSize-n&&t.push(s)}h=t,Math.floor(e.virtualSize-n)-Math.floor(h[h.length-1])>1&&h.push(e.virtualSize-n)}if(l&&r.loop){const t=p[0]+b;if(r.slidesPerGroup>1){const i=Math.ceil((e.virtual.slidesBefore+e.virtual.slidesAfter)/r.slidesPerGroup),s=t*r.slidesPerGroup;for(let e=0;e<i;e+=1)h.push(h[h.length-1]+s)}for(let i=0;i<e.virtual.slidesBefore+e.virtual.slidesAfter;i+=1)1===r.slidesPerGroup&&h.push(h[h.length-1]+t),f.push(f[f.length-1]+t),e.virtualSize+=t}if(0===h.length&&(h=[0]),0!==b){const t=e.isHorizontal()&&a?"marginLeft":e.getDirectionLabel("marginRight");d.filter((e,t)=>!(r.cssMode&&!r.loop)||t!==d.length-1).forEach(e=>{e.style[t]=`${b}px`})}if(r.centeredSlides&&r.centeredSlidesBounds){let e=0;p.forEach(t=>{e+=t+(b||0)}),e-=b;const t=e>n?e-n:0;h=h.map(e=>e<=0?-m:e>t?t+g:e)}if(r.centerInsufficientSlides){let e=0;p.forEach(t=>{e+=t+(b||0)}),e-=b;const t=(r.slidesOffsetBefore||0)+(r.slidesOffsetAfter||0);if(e+t<n){const r=(n-e-t)/2;h.forEach((e,t)=>{h[t]=e-r}),f.forEach((e,t)=>{f[t]=e+r})}}if(Object.assign(e,{slides:d,snapGrid:h,slidesGrid:f,slidesSizesGrid:p}),r.centeredSlides&&r.cssMode&&!r.centeredSlidesBounds){Ws(i,"--swiper-centered-offset-before",-h[0]+"px"),Ws(i,"--swiper-centered-offset-after",e.size/2-p[p.length-1]/2+"px");const t=-e.snapGrid[0],r=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map(e=>e+t),e.slidesGrid=e.slidesGrid.map(e=>e+r)}if(u!==c&&e.emit("slidesLengthChange"),h.length!==v&&(e.params.watchOverflow&&e.checkOverflow(),e.emit("snapGridLengthChange")),f.length!==y&&e.emit("slidesGridLengthChange"),r.watchSlidesProgress&&e.updateSlidesOffset(),e.emit("slidesUpdated"),!(l||r.cssMode||"slide"!==r.effect&&"fade"!==r.effect)){const t=`${r.containerModifierClass}backface-hidden`,i=e.el.classList.contains(t);u<=r.maxBackfaceHiddenSlides?i||e.el.classList.add(t):i&&e.el.classList.remove(t)}},updateAutoHeight:function(e){const t=this,r=[],i=t.virtual&&t.params.virtual.enabled;let s,n=0;"number"==typeof e?t.setTransition(e):!0===e&&t.setTransition(t.params.speed);const a=e=>i?t.slides[t.getSlideIndexByData(e)]:t.slides[e];if("auto"!==t.params.slidesPerView&&t.params.slidesPerView>1)if(t.params.centeredSlides)(t.visibleSlides||[]).forEach(e=>{r.push(e)});else for(s=0;s<Math.ceil(t.params.slidesPerView);s+=1){const e=t.activeIndex+s;if(e>t.slides.length&&!i)break;r.push(a(e))}else r.push(a(t.activeIndex));for(s=0;s<r.length;s+=1)if(void 0!==r[s]){const e=r[s].offsetHeight;n=e>n?e:n}(n||0===n)&&(t.wrapperEl.style.height=`${n}px`)},updateSlidesOffset:function(){const e=this,t=e.slides,r=e.isElement?e.isHorizontal()?e.wrapperEl.offsetLeft:e.wrapperEl.offsetTop:0;for(let i=0;i<t.length;i+=1)t[i].swiperSlideOffset=(e.isHorizontal()?t[i].offsetLeft:t[i].offsetTop)-r-e.cssOverflowAdjustment()},updateSlidesProgress:function(e){void 0===e&&(e=this&&this.translate||0);const t=this,r=t.params,{slides:i,rtlTranslate:s,snapGrid:n}=t;if(0===i.length)return;void 0===i[0].swiperSlideOffset&&t.updateSlidesOffset();let a=-e;s&&(a=e),t.visibleSlidesIndexes=[],t.visibleSlides=[];let o=r.spaceBetween;"string"==typeof o&&o.indexOf("%")>=0?o=parseFloat(o.replace("%",""))/100*t.size:"string"==typeof o&&(o=parseFloat(o));for(let e=0;e<i.length;e+=1){const l=i[e];let c=l.swiperSlideOffset;r.cssMode&&r.centeredSlides&&(c-=i[0].swiperSlideOffset);const d=(a+(r.centeredSlides?t.minTranslate():0)-c)/(l.swiperSlideSize+o),u=(a-n[0]+(r.centeredSlides?t.minTranslate():0)-c)/(l.swiperSlideSize+o),h=-(a-c),f=h+t.slidesSizesGrid[e],p=h>=0&&h<=t.size-t.slidesSizesGrid[e],m=h>=0&&h<t.size-1||f>1&&f<=t.size||h<=0&&f>=t.size;m&&(t.visibleSlides.push(l),t.visibleSlidesIndexes.push(e)),dn(l,m,r.slideVisibleClass),dn(l,p,r.slideFullyVisibleClass),l.progress=s?-d:d,l.originalProgress=s?-u:u}},updateProgress:function(e){const t=this;if(void 0===e){const r=t.rtlTranslate?-1:1;e=t&&t.translate&&t.translate*r||0}const r=t.params,i=t.maxTranslate()-t.minTranslate();let{progress:s,isBeginning:n,isEnd:a,progressLoop:o}=t;const l=n,c=a;if(0===i)s=0,n=!0,a=!0;else{s=(e-t.minTranslate())/i;const r=Math.abs(e-t.minTranslate())<1,o=Math.abs(e-t.maxTranslate())<1;n=r||s<=0,a=o||s>=1,r&&(s=0),o&&(s=1)}if(r.loop){const r=t.getSlideIndexByData(0),i=t.getSlideIndexByData(t.slides.length-1),s=t.slidesGrid[r],n=t.slidesGrid[i],a=t.slidesGrid[t.slidesGrid.length-1],l=Math.abs(e);o=l>=s?(l-s)/a:(l+a-n)/a,o>1&&(o-=1)}Object.assign(t,{progress:s,progressLoop:o,isBeginning:n,isEnd:a}),(r.watchSlidesProgress||r.centeredSlides&&r.autoHeight)&&t.updateSlidesProgress(e),n&&!l&&t.emit("reachBeginning toEdge"),a&&!c&&t.emit("reachEnd toEdge"),(l&&!n||c&&!a)&&t.emit("fromEdge"),t.emit("progress",s)},updateSlidesClasses:function(){const e=this,{slides:t,params:r,slidesEl:i,activeIndex:s}=e,n=e.virtual&&r.virtual.enabled,a=e.grid&&r.grid&&r.grid.rows>1,o=e=>qs(i,`.${r.slideClass}${e}, swiper-slide${e}`)[0];let l,c,d;if(n)if(r.loop){let t=s-e.virtual.slidesBefore;t<0&&(t=e.virtual.slides.length+t),t>=e.virtual.slides.length&&(t-=e.virtual.slides.length),l=o(`[data-swiper-slide-index="${t}"]`)}else l=o(`[data-swiper-slide-index="${s}"]`);else a?(l=t.filter(e=>e.column===s)[0],d=t.filter(e=>e.column===s+1)[0],c=t.filter(e=>e.column===s-1)[0]):l=t[s];l&&(a||(d=function(e,t){const r=[];for(;e.nextElementSibling;){const i=e.nextElementSibling;t?i.matches(t)&&r.push(i):r.push(i),e=i}return r}(l,`.${r.slideClass}, swiper-slide`)[0],r.loop&&!d&&(d=t[0]),c=function(e,t){const r=[];for(;e.previousElementSibling;){const i=e.previousElementSibling;t?i.matches(t)&&r.push(i):r.push(i),e=i}return r}(l,`.${r.slideClass}, swiper-slide`)[0],r.loop&&0===!c&&(c=t[t.length-1]))),t.forEach(e=>{un(e,e===l,r.slideActiveClass),un(e,e===d,r.slideNextClass),un(e,e===c,r.slidePrevClass)}),e.emitSlidesClasses()},updateActiveIndex:function(e){const t=this,r=t.rtlTranslate?t.translate:-t.translate,{snapGrid:i,params:s,activeIndex:n,realIndex:a,snapIndex:o}=t;let l,c=e;const d=e=>{let r=e-t.virtual.slidesBefore;return r<0&&(r=t.virtual.slides.length+r),r>=t.virtual.slides.length&&(r-=t.virtual.slides.length),r};if(void 0===c&&(c=function(e){const{slidesGrid:t,params:r}=e,i=e.rtlTranslate?e.translate:-e.translate;let s;for(let e=0;e<t.length;e+=1)void 0!==t[e+1]?i>=t[e]&&i<t[e+1]-(t[e+1]-t[e])/2?s=e:i>=t[e]&&i<t[e+1]&&(s=e+1):i>=t[e]&&(s=e);return r.normalizeSlideIndex&&(s<0||void 0===s)&&(s=0),s}(t)),i.indexOf(r)>=0)l=i.indexOf(r);else{const e=Math.min(s.slidesPerGroupSkip,c);l=e+Math.floor((c-e)/s.slidesPerGroup)}if(l>=i.length&&(l=i.length-1),c===n&&!t.params.loop)return void(l!==o&&(t.snapIndex=l,t.emit("snapIndexChange")));if(c===n&&t.params.loop&&t.virtual&&t.params.virtual.enabled)return void(t.realIndex=d(c));const u=t.grid&&s.grid&&s.grid.rows>1;let h;if(t.virtual&&s.virtual.enabled&&s.loop)h=d(c);else if(u){const e=t.slides.filter(e=>e.column===c)[0];let r=parseInt(e.getAttribute("data-swiper-slide-index"),10);Number.isNaN(r)&&(r=Math.max(t.slides.indexOf(e),0)),h=Math.floor(r/s.grid.rows)}else if(t.slides[c]){const e=t.slides[c].getAttribute("data-swiper-slide-index");h=e?parseInt(e,10):c}else h=c;Object.assign(t,{previousSnapIndex:o,snapIndex:l,previousRealIndex:a,realIndex:h,previousIndex:n,activeIndex:c}),t.initialized&&pn(t),t.emit("activeIndexChange"),t.emit("snapIndexChange"),(t.initialized||t.params.runCallbacksOnInit)&&(a!==h&&t.emit("realIndexChange"),t.emit("slideChange"))},updateClickedSlide:function(e,t){const r=this,i=r.params;let s=e.closest(`.${i.slideClass}, swiper-slide`);!s&&r.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach(e=>{!s&&e.matches&&e.matches(`.${i.slideClass}, swiper-slide`)&&(s=e)});let n,a=!1;if(s)for(let e=0;e<r.slides.length;e+=1)if(r.slides[e]===s){a=!0,n=e;break}if(!s||!a)return r.clickedSlide=void 0,void(r.clickedIndex=void 0);r.clickedSlide=s,r.virtual&&r.params.virtual.enabled?r.clickedIndex=parseInt(s.getAttribute("data-swiper-slide-index"),10):r.clickedIndex=n,i.slideToClickedSlide&&void 0!==r.clickedIndex&&r.clickedIndex!==r.activeIndex&&r.slideToClickedSlide()}};var gn={getTranslate:function(e){void 0===e&&(e=this.isHorizontal()?"x":"y");const{params:t,rtlTranslate:r,translate:i,wrapperEl:s}=this;if(t.virtualTranslate)return r?-i:i;if(t.cssMode)return i;let n=Gs(s,e);return n+=this.cssOverflowAdjustment(),r&&(n=-n),n||0},setTranslate:function(e,t){const r=this,{rtlTranslate:i,params:s,wrapperEl:n,progress:a}=r;let o,l=0,c=0;r.isHorizontal()?l=i?-e:e:c=e,s.roundLengths&&(l=Math.floor(l),c=Math.floor(c)),r.previousTranslate=r.translate,r.translate=r.isHorizontal()?l:c,s.cssMode?n[r.isHorizontal()?"scrollLeft":"scrollTop"]=r.isHorizontal()?-l:-c:s.virtualTranslate||(r.isHorizontal()?l-=r.cssOverflowAdjustment():c-=r.cssOverflowAdjustment(),n.style.transform=`translate3d(${l}px, ${c}px, 0px)`);const d=r.maxTranslate()-r.minTranslate();o=0===d?0:(e-r.minTranslate())/d,o!==a&&r.updateProgress(e),r.emit("setTranslate",r.translate,t)},minTranslate:function(){return-this.snapGrid[0]},maxTranslate:function(){return-this.snapGrid[this.snapGrid.length-1]},translateTo:function(e,t,r,i,s){void 0===e&&(e=0),void 0===t&&(t=this.params.speed),void 0===r&&(r=!0),void 0===i&&(i=!0);const n=this,{params:a,wrapperEl:o}=n;if(n.animating&&a.preventInteractionOnTransition)return!1;const l=n.minTranslate(),c=n.maxTranslate();let d;if(d=i&&e>l?l:i&&e<c?c:e,n.updateProgress(d),a.cssMode){const e=n.isHorizontal();if(0===t)o[e?"scrollLeft":"scrollTop"]=-d;else{if(!n.support.smoothScroll)return Ys({swiper:n,targetPosition:-d,side:e?"left":"top"}),!0;o.scrollTo({[e?"left":"top"]:-d,behavior:"smooth"})}return!0}return 0===t?(n.setTransition(0),n.setTranslate(d),r&&(n.emit("beforeTransitionStart",t,s),n.emit("transitionEnd"))):(n.setTransition(t),n.setTranslate(d),r&&(n.emit("beforeTransitionStart",t,s),n.emit("transitionStart")),n.animating||(n.animating=!0,n.onTranslateToWrapperTransitionEnd||(n.onTranslateToWrapperTransitionEnd=function(e){n&&!n.destroyed&&e.target===this&&(n.wrapperEl.removeEventListener("transitionend",n.onTranslateToWrapperTransitionEnd),n.onTranslateToWrapperTransitionEnd=null,delete n.onTranslateToWrapperTransitionEnd,n.animating=!1,r&&n.emit("transitionEnd"))}),n.wrapperEl.addEventListener("transitionend",n.onTranslateToWrapperTransitionEnd))),!0}};function vn(e){let{swiper:t,runCallbacks:r,direction:i,step:s}=e;const{activeIndex:n,previousIndex:a}=t;let o=i;if(o||(o=n>a?"next":n<a?"prev":"reset"),t.emit(`transition${s}`),r&&n!==a){if("reset"===o)return void t.emit(`slideResetTransition${s}`);t.emit(`slideChangeTransition${s}`),"next"===o?t.emit(`slideNextTransition${s}`):t.emit(`slidePrevTransition${s}`)}}var yn={setTransition:function(e,t){const r=this;r.params.cssMode||(r.wrapperEl.style.transitionDuration=`${e}ms`,r.wrapperEl.style.transitionDelay=0===e?"0ms":""),r.emit("setTransition",e,t)},transitionStart:function(e,t){void 0===e&&(e=!0);const r=this,{params:i}=r;i.cssMode||(i.autoHeight&&r.updateAutoHeight(),vn({swiper:r,runCallbacks:e,direction:t,step:"Start"}))},transitionEnd:function(e,t){void 0===e&&(e=!0);const r=this,{params:i}=r;r.animating=!1,i.cssMode||(r.setTransition(0),vn({swiper:r,runCallbacks:e,direction:t,step:"End"}))}};var bn={slideTo:function(e,t,r,i,s){void 0===e&&(e=0),void 0===r&&(r=!0),"string"==typeof e&&(e=parseInt(e,10));const n=this;let a=e;a<0&&(a=0);const{params:o,snapGrid:l,slidesGrid:c,previousIndex:d,activeIndex:u,rtlTranslate:h,wrapperEl:f,enabled:p}=n;if(!p&&!i&&!s||n.destroyed||n.animating&&o.preventInteractionOnTransition)return!1;void 0===t&&(t=n.params.speed);const m=Math.min(n.params.slidesPerGroupSkip,a);let g=m+Math.floor((a-m)/n.params.slidesPerGroup);g>=l.length&&(g=l.length-1);const v=-l[g];if(o.normalizeSlideIndex)for(let e=0;e<c.length;e+=1){const t=-Math.floor(100*v),r=Math.floor(100*c[e]),i=Math.floor(100*c[e+1]);void 0!==c[e+1]?t>=r&&t<i-(i-r)/2?a=e:t>=r&&t<i&&(a=e+1):t>=r&&(a=e)}if(n.initialized&&a!==u){if(!n.allowSlideNext&&(h?v>n.translate&&v>n.minTranslate():v<n.translate&&v<n.minTranslate()))return!1;if(!n.allowSlidePrev&&v>n.translate&&v>n.maxTranslate()&&(u||0)!==a)return!1}let y;a!==(d||0)&&r&&n.emit("beforeSlideChangeStart"),n.updateProgress(v),y=a>u?"next":a<u?"prev":"reset";const b=n.virtual&&n.params.virtual.enabled;if(!(b&&s)&&(h&&-v===n.translate||!h&&v===n.translate))return n.updateActiveIndex(a),o.autoHeight&&n.updateAutoHeight(),n.updateSlidesClasses(),"slide"!==o.effect&&n.setTranslate(v),"reset"!==y&&(n.transitionStart(r,y),n.transitionEnd(r,y)),!1;if(o.cssMode){const e=n.isHorizontal(),r=h?v:-v;if(0===t)b&&(n.wrapperEl.style.scrollSnapType="none",n._immediateVirtual=!0),b&&!n._cssModeVirtualInitialSet&&n.params.initialSlide>0?(n._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{f[e?"scrollLeft":"scrollTop"]=r})):f[e?"scrollLeft":"scrollTop"]=r,b&&requestAnimationFrame(()=>{n.wrapperEl.style.scrollSnapType="",n._immediateVirtual=!1});else{if(!n.support.smoothScroll)return Ys({swiper:n,targetPosition:r,side:e?"left":"top"}),!0;f.scrollTo({[e?"left":"top"]:r,behavior:"smooth"})}return!0}return n.setTransition(t),n.setTranslate(v),n.updateActiveIndex(a),n.updateSlidesClasses(),n.emit("beforeTransitionStart",t,i),n.transitionStart(r,y),0===t?n.transitionEnd(r,y):n.animating||(n.animating=!0,n.onSlideToWrapperTransitionEnd||(n.onSlideToWrapperTransitionEnd=function(e){n&&!n.destroyed&&e.target===this&&(n.wrapperEl.removeEventListener("transitionend",n.onSlideToWrapperTransitionEnd),n.onSlideToWrapperTransitionEnd=null,delete n.onSlideToWrapperTransitionEnd,n.transitionEnd(r,y))}),n.wrapperEl.addEventListener("transitionend",n.onSlideToWrapperTransitionEnd)),!0},slideToLoop:function(e,t,r,i){if(void 0===e&&(e=0),void 0===r&&(r=!0),"string"==typeof e){e=parseInt(e,10)}const s=this;if(s.destroyed)return;void 0===t&&(t=s.params.speed);const n=s.grid&&s.params.grid&&s.params.grid.rows>1;let a=e;if(s.params.loop)if(s.virtual&&s.params.virtual.enabled)a+=s.virtual.slidesBefore;else{let e;if(n){const t=a*s.params.grid.rows;e=s.slides.filter(e=>1*e.getAttribute("data-swiper-slide-index")===t)[0].column}else e=s.getSlideIndexByData(a);const t=n?Math.ceil(s.slides.length/s.params.grid.rows):s.slides.length,{centeredSlides:r}=s.params;let o=s.params.slidesPerView;"auto"===o?o=s.slidesPerViewDynamic():(o=Math.ceil(parseFloat(s.params.slidesPerView,10)),r&&o%2==0&&(o+=1));let l=t-e<o;if(r&&(l=l||e<Math.ceil(o/2)),i&&r&&"auto"!==s.params.slidesPerView&&!n&&(l=!1),l){const i=r?e<s.activeIndex?"prev":"next":e-s.activeIndex-1<s.params.slidesPerView?"next":"prev";s.loopFix({direction:i,slideTo:!0,activeSlideIndex:"next"===i?e+1:e-t+1,slideRealIndex:"next"===i?s.realIndex:void 0})}if(n){const e=a*s.params.grid.rows;a=s.slides.filter(t=>1*t.getAttribute("data-swiper-slide-index")===e)[0].column}else a=s.getSlideIndexByData(a)}return requestAnimationFrame(()=>{s.slideTo(a,t,r,i)}),s},slideNext:function(e,t,r){void 0===t&&(t=!0);const i=this,{enabled:s,params:n,animating:a}=i;if(!s||i.destroyed)return i;void 0===e&&(e=i.params.speed);let o=n.slidesPerGroup;"auto"===n.slidesPerView&&1===n.slidesPerGroup&&n.slidesPerGroupAuto&&(o=Math.max(i.slidesPerViewDynamic("current",!0),1));const l=i.activeIndex<n.slidesPerGroupSkip?1:o,c=i.virtual&&n.virtual.enabled;if(n.loop){if(a&&!c&&n.loopPreventsSliding)return!1;if(i.loopFix({direction:"next"}),i._clientLeft=i.wrapperEl.clientLeft,i.activeIndex===i.slides.length-1&&n.cssMode)return requestAnimationFrame(()=>{i.slideTo(i.activeIndex+l,e,t,r)}),!0}return n.rewind&&i.isEnd?i.slideTo(0,e,t,r):i.slideTo(i.activeIndex+l,e,t,r)},slidePrev:function(e,t,r){void 0===t&&(t=!0);const i=this,{params:s,snapGrid:n,slidesGrid:a,rtlTranslate:o,enabled:l,animating:c}=i;if(!l||i.destroyed)return i;void 0===e&&(e=i.params.speed);const d=i.virtual&&s.virtual.enabled;if(s.loop){if(c&&!d&&s.loopPreventsSliding)return!1;i.loopFix({direction:"prev"}),i._clientLeft=i.wrapperEl.clientLeft}function u(e){return e<0?-Math.floor(Math.abs(e)):Math.floor(e)}const h=u(o?i.translate:-i.translate),f=n.map(e=>u(e));let p=n[f.indexOf(h)-1];if(void 0===p&&s.cssMode){let e;n.forEach((t,r)=>{h>=t&&(e=r)}),void 0!==e&&(p=n[e>0?e-1:e])}let m=0;if(void 0!==p&&(m=a.indexOf(p),m<0&&(m=i.activeIndex-1),"auto"===s.slidesPerView&&1===s.slidesPerGroup&&s.slidesPerGroupAuto&&(m=m-i.slidesPerViewDynamic("previous",!0)+1,m=Math.max(m,0))),s.rewind&&i.isBeginning){const s=i.params.virtual&&i.params.virtual.enabled&&i.virtual?i.virtual.slides.length-1:i.slides.length-1;return i.slideTo(s,e,t,r)}return s.loop&&0===i.activeIndex&&s.cssMode?(requestAnimationFrame(()=>{i.slideTo(m,e,t,r)}),!0):i.slideTo(m,e,t,r)},slideReset:function(e,t,r){void 0===t&&(t=!0);const i=this;if(!i.destroyed)return void 0===e&&(e=i.params.speed),i.slideTo(i.activeIndex,e,t,r)},slideToClosest:function(e,t,r,i){void 0===t&&(t=!0),void 0===i&&(i=.5);const s=this;if(s.destroyed)return;void 0===e&&(e=s.params.speed);let n=s.activeIndex;const a=Math.min(s.params.slidesPerGroupSkip,n),o=a+Math.floor((n-a)/s.params.slidesPerGroup),l=s.rtlTranslate?s.translate:-s.translate;if(l>=s.snapGrid[o]){const e=s.snapGrid[o];l-e>(s.snapGrid[o+1]-e)*i&&(n+=s.params.slidesPerGroup)}else{const e=s.snapGrid[o-1];l-e<=(s.snapGrid[o]-e)*i&&(n-=s.params.slidesPerGroup)}return n=Math.max(n,0),n=Math.min(n,s.slidesGrid.length-1),s.slideTo(n,e,t,r)},slideToClickedSlide:function(){const e=this;if(e.destroyed)return;const{params:t,slidesEl:r}=e,i="auto"===t.slidesPerView?e.slidesPerViewDynamic():t.slidesPerView;let s,n=e.clickedIndex;const a=e.isElement?"swiper-slide":`.${t.slideClass}`;if(t.loop){if(e.animating)return;s=parseInt(e.clickedSlide.getAttribute("data-swiper-slide-index"),10),t.centeredSlides?n<e.loopedSlides-i/2||n>e.slides.length-e.loopedSlides+i/2?(e.loopFix(),n=e.getSlideIndex(qs(r,`${a}[data-swiper-slide-index="${s}"]`)[0]),Us(()=>{e.slideTo(n)})):e.slideTo(n):n>e.slides.length-i?(e.loopFix(),n=e.getSlideIndex(qs(r,`${a}[data-swiper-slide-index="${s}"]`)[0]),Us(()=>{e.slideTo(n)})):e.slideTo(n)}else e.slideTo(n)}};var En={loopCreate:function(e){const t=this,{params:r,slidesEl:i}=t;if(!r.loop||t.virtual&&t.params.virtual.enabled)return;const s=()=>{qs(i,`.${r.slideClass}, swiper-slide`).forEach((e,t)=>{e.setAttribute("data-swiper-slide-index",t)})},n=t.grid&&r.grid&&r.grid.rows>1,a=r.slidesPerGroup*(n?r.grid.rows:1),o=t.slides.length%a!==0,l=n&&t.slides.length%r.grid.rows!==0,c=e=>{for(let i=0;i<e;i+=1){const e=t.isElement?Qs("swiper-slide",[r.slideBlankClass]):Qs("div",[r.slideClass,r.slideBlankClass]);t.slidesEl.append(e)}};if(o){if(r.loopAddBlankSlides){c(a-t.slides.length%a),t.recalcSlides(),t.updateSlides()}else Xs("Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");s()}else if(l){if(r.loopAddBlankSlides){c(r.grid.rows-t.slides.length%r.grid.rows),t.recalcSlides(),t.updateSlides()}else Xs("Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");s()}else s();t.loopFix({slideRealIndex:e,direction:r.centeredSlides?void 0:"next"})},loopFix:function(e){let{slideRealIndex:t,slideTo:r=!0,direction:i,setTranslate:s,activeSlideIndex:n,byController:a,byMousewheel:o}=void 0===e?{}:e;const l=this;if(!l.params.loop)return;l.emit("beforeLoopFix");const{slides:c,allowSlidePrev:d,allowSlideNext:u,slidesEl:h,params:f}=l,{centeredSlides:p}=f;if(l.allowSlidePrev=!0,l.allowSlideNext=!0,l.virtual&&f.virtual.enabled)return r&&(f.centeredSlides||0!==l.snapIndex?f.centeredSlides&&l.snapIndex<f.slidesPerView?l.slideTo(l.virtual.slides.length+l.snapIndex,0,!1,!0):l.snapIndex===l.snapGrid.length-1&&l.slideTo(l.virtual.slidesBefore,0,!1,!0):l.slideTo(l.virtual.slides.length,0,!1,!0)),l.allowSlidePrev=d,l.allowSlideNext=u,void l.emit("loopFix");let m=f.slidesPerView;"auto"===m?m=l.slidesPerViewDynamic():(m=Math.ceil(parseFloat(f.slidesPerView,10)),p&&m%2==0&&(m+=1));const g=f.slidesPerGroupAuto?m:f.slidesPerGroup;let v=g;v%g!==0&&(v+=g-v%g),v+=f.loopAdditionalSlides,l.loopedSlides=v;const y=l.grid&&f.grid&&f.grid.rows>1;c.length<m+v?Xs("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled and not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"):y&&"row"===f.grid.fill&&Xs("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");const b=[],E=[];let w=l.activeIndex;void 0===n?n=l.getSlideIndex(c.filter(e=>e.classList.contains(f.slideActiveClass))[0]):w=n;const S="next"===i||!i,T="prev"===i||!i;let x=0,A=0;const k=y?Math.ceil(c.length/f.grid.rows):c.length,L=(y?c[n].column:n)+(p&&void 0===s?-m/2+.5:0);if(L<v){x=Math.max(v-L,g);for(let e=0;e<v-L;e+=1){const t=e-Math.floor(e/k)*k;if(y){const e=k-t-1;for(let t=c.length-1;t>=0;t-=1)c[t].column===e&&b.push(t)}else b.push(k-t-1)}}else if(L+m>k-v){A=Math.max(L-(k-2*v),g);for(let e=0;e<A;e+=1){const t=e-Math.floor(e/k)*k;y?c.forEach((e,r)=>{e.column===t&&E.push(r)}):E.push(t)}}if(l.__preventObserver__=!0,requestAnimationFrame(()=>{l.__preventObserver__=!1}),T&&b.forEach(e=>{c[e].swiperLoopMoveDOM=!0,h.prepend(c[e]),c[e].swiperLoopMoveDOM=!1}),S&&E.forEach(e=>{c[e].swiperLoopMoveDOM=!0,h.append(c[e]),c[e].swiperLoopMoveDOM=!1}),l.recalcSlides(),"auto"===f.slidesPerView?l.updateSlides():y&&(b.length>0&&T||E.length>0&&S)&&l.slides.forEach((e,t)=>{l.grid.updateSlide(t,e,l.slides)}),f.watchSlidesProgress&&l.updateSlidesOffset(),r)if(b.length>0&&T){if(void 0===t){const e=l.slidesGrid[w],t=l.slidesGrid[w+x]-e;o?l.setTranslate(l.translate-t):(l.slideTo(w+Math.ceil(x),0,!1,!0),s&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-t,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-t))}else if(s){const e=y?b.length/f.grid.rows:b.length;l.slideTo(l.activeIndex+e,0,!1,!0),l.touchEventsData.currentTranslate=l.translate}}else if(E.length>0&&S)if(void 0===t){const e=l.slidesGrid[w],t=l.slidesGrid[w-A]-e;o?l.setTranslate(l.translate-t):(l.slideTo(w-A,0,!1,!0),s&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-t,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-t))}else{const e=y?E.length/f.grid.rows:E.length;l.slideTo(l.activeIndex-e,0,!1,!0)}if(l.allowSlidePrev=d,l.allowSlideNext=u,l.controller&&l.controller.control&&!a){const e={slideRealIndex:t,direction:i,setTranslate:s,activeSlideIndex:n,byController:!0};Array.isArray(l.controller.control)?l.controller.control.forEach(t=>{!t.destroyed&&t.params.loop&&t.loopFix({...e,slideTo:t.params.slidesPerView===f.slidesPerView&&r})}):l.controller.control instanceof l.constructor&&l.controller.control.params.loop&&l.controller.control.loopFix({...e,slideTo:l.controller.control.params.slidesPerView===f.slidesPerView&&r})}l.emit("loopFix")},loopDestroy:function(){const e=this,{params:t,slidesEl:r}=e;if(!t.loop||e.virtual&&e.params.virtual.enabled)return;e.recalcSlides();const i=[];e.slides.forEach(e=>{const t=void 0===e.swiperSlideIndex?1*e.getAttribute("data-swiper-slide-index"):e.swiperSlideIndex;i[t]=e}),e.slides.forEach(e=>{e.removeAttribute("data-swiper-slide-index")}),i.forEach(e=>{r.append(e)}),e.recalcSlides(),e.slideTo(e.realIndex,0)}};function wn(e,t,r){const i=Bs(),{params:s}=e,n=s.edgeSwipeDetection,a=s.edgeSwipeThreshold;return!n||!(r<=a||r>=i.innerWidth-a)||"prevent"===n&&(t.preventDefault(),!0)}function Sn(e){const t=this,r=Fs();let i=e;i.originalEvent&&(i=i.originalEvent);const s=t.touchEventsData;if("pointerdown"===i.type){if(null!==s.pointerId&&s.pointerId!==i.pointerId)return;s.pointerId=i.pointerId}else"touchstart"===i.type&&1===i.targetTouches.length&&(s.touchId=i.targetTouches[0].identifier);if("touchstart"===i.type)return void wn(t,i,i.targetTouches[0].pageX);const{params:n,touches:a,enabled:o}=t;if(!o)return;if(!n.simulateTouch&&"mouse"===i.pointerType)return;if(t.animating&&n.preventInteractionOnTransition)return;!t.animating&&n.cssMode&&n.loop&&t.loopFix();let l=i.target;if("wrapper"===n.touchEventsTarget&&!function(e,t){const r=t.contains(e);if(!r&&t instanceof HTMLSlotElement)return[...t.assignedElements()].includes(e);return r}(l,t.wrapperEl))return;if("which"in i&&3===i.which)return;if("button"in i&&i.button>0)return;if(s.isTouched&&s.isMoved)return;const c=!!n.noSwipingClass&&""!==n.noSwipingClass,d=i.composedPath?i.composedPath():i.path;c&&i.target&&i.target.shadowRoot&&d&&(l=d[0]);const u=n.noSwipingSelector?n.noSwipingSelector:`.${n.noSwipingClass}`,h=!(!i.target||!i.target.shadowRoot);if(n.noSwiping&&(h?function(e,t){return void 0===t&&(t=this),function t(r){if(!r||r===Fs()||r===Bs())return null;r.assignedSlot&&(r=r.assignedSlot);const i=r.closest(e);return i||r.getRootNode?i||t(r.getRootNode().host):null}(t)}(u,l):l.closest(u)))return void(t.allowClick=!0);if(n.swipeHandler&&!l.closest(n.swipeHandler))return;a.currentX=i.pageX,a.currentY=i.pageY;const f=a.currentX,p=a.currentY;if(!wn(t,i,f))return;Object.assign(s,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),a.startX=f,a.startY=p,s.touchStartTime=zs(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,n.threshold>0&&(s.allowThresholdMove=!1);let m=!0;l.matches(s.focusableElements)&&(m=!1,"SELECT"===l.nodeName&&(s.isTouched=!1)),r.activeElement&&r.activeElement.matches(s.focusableElements)&&r.activeElement!==l&&("mouse"===i.pointerType||"mouse"!==i.pointerType&&!l.matches(s.focusableElements))&&r.activeElement.blur();const g=m&&t.allowTouchMove&&n.touchStartPreventDefault;!n.touchStartForcePreventDefault&&!g||l.isContentEditable||i.preventDefault(),n.freeMode&&n.freeMode.enabled&&t.freeMode&&t.animating&&!n.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",i)}function Tn(e){const t=Fs(),r=this,i=r.touchEventsData,{params:s,touches:n,rtlTranslate:a,enabled:o}=r;if(!o)return;if(!s.simulateTouch&&"mouse"===e.pointerType)return;let l,c=e;if(c.originalEvent&&(c=c.originalEvent),"pointermove"===c.type){if(null!==i.touchId)return;if(c.pointerId!==i.pointerId)return}if("touchmove"===c.type){if(l=[...c.changedTouches].filter(e=>e.identifier===i.touchId)[0],!l||l.identifier!==i.touchId)return}else l=c;if(!i.isTouched)return void(i.startMoving&&i.isScrolling&&r.emit("touchMoveOpposite",c));const d=l.pageX,u=l.pageY;if(c.preventedByNestedSwiper)return n.startX=d,void(n.startY=u);if(!r.allowTouchMove)return c.target.matches(i.focusableElements)||(r.allowClick=!1),void(i.isTouched&&(Object.assign(n,{startX:d,startY:u,currentX:d,currentY:u}),i.touchStartTime=zs()));if(s.touchReleaseOnEdges&&!s.loop)if(r.isVertical()){if(u<n.startY&&r.translate<=r.maxTranslate()||u>n.startY&&r.translate>=r.minTranslate())return i.isTouched=!1,void(i.isMoved=!1)}else if(d<n.startX&&r.translate<=r.maxTranslate()||d>n.startX&&r.translate>=r.minTranslate())return;if(t.activeElement&&t.activeElement.matches(i.focusableElements)&&t.activeElement!==c.target&&"mouse"!==c.pointerType&&t.activeElement.blur(),t.activeElement&&c.target===t.activeElement&&c.target.matches(i.focusableElements))return i.isMoved=!0,void(r.allowClick=!1);i.allowTouchCallbacks&&r.emit("touchMove",c),n.previousX=n.currentX,n.previousY=n.currentY,n.currentX=d,n.currentY=u;const h=n.currentX-n.startX,f=n.currentY-n.startY;if(r.params.threshold&&Math.sqrt(h**2+f**2)<r.params.threshold)return;if(void 0===i.isScrolling){let e;r.isHorizontal()&&n.currentY===n.startY||r.isVertical()&&n.currentX===n.startX?i.isScrolling=!1:h*h+f*f>=25&&(e=180*Math.atan2(Math.abs(f),Math.abs(h))/Math.PI,i.isScrolling=r.isHorizontal()?e>s.touchAngle:90-e>s.touchAngle)}if(i.isScrolling&&r.emit("touchMoveOpposite",c),void 0===i.startMoving&&(n.currentX===n.startX&&n.currentY===n.startY||(i.startMoving=!0)),i.isScrolling||"touchmove"===c.type&&i.preventTouchMoveFromPointerMove)return void(i.isTouched=!1);if(!i.startMoving)return;r.allowClick=!1,!s.cssMode&&c.cancelable&&c.preventDefault(),s.touchMoveStopPropagation&&!s.nested&&c.stopPropagation();let p=r.isHorizontal()?h:f,m=r.isHorizontal()?n.currentX-n.previousX:n.currentY-n.previousY;s.oneWayMovement&&(p=Math.abs(p)*(a?1:-1),m=Math.abs(m)*(a?1:-1)),n.diff=p,p*=s.touchRatio,a&&(p=-p,m=-m);const g=r.touchesDirection;r.swipeDirection=p>0?"prev":"next",r.touchesDirection=m>0?"prev":"next";const v=r.params.loop&&!s.cssMode,y="next"===r.touchesDirection&&r.allowSlideNext||"prev"===r.touchesDirection&&r.allowSlidePrev;if(!i.isMoved){if(v&&y&&r.loopFix({direction:r.swipeDirection}),i.startTranslate=r.getTranslate(),r.setTransition(0),r.animating){const e=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});r.wrapperEl.dispatchEvent(e)}i.allowMomentumBounce=!1,!s.grabCursor||!0!==r.allowSlideNext&&!0!==r.allowSlidePrev||r.setGrabCursor(!0),r.emit("sliderFirstMove",c)}if((new Date).getTime(),i.isMoved&&i.allowThresholdMove&&g!==r.touchesDirection&&v&&y&&Math.abs(p)>=1)return Object.assign(n,{startX:d,startY:u,currentX:d,currentY:u,startTranslate:i.currentTranslate}),i.loopSwapReset=!0,void(i.startTranslate=i.currentTranslate);r.emit("sliderMove",c),i.isMoved=!0,i.currentTranslate=p+i.startTranslate;let b=!0,E=s.resistanceRatio;if(s.touchReleaseOnEdges&&(E=0),p>0?(v&&y&&i.allowThresholdMove&&i.currentTranslate>(s.centeredSlides?r.minTranslate()-r.slidesSizesGrid[r.activeIndex+1]-("auto"!==s.slidesPerView&&r.slides.length-s.slidesPerView>=2?r.slidesSizesGrid[r.activeIndex+1]+r.params.spaceBetween:0)-r.params.spaceBetween:r.minTranslate())&&r.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),i.currentTranslate>r.minTranslate()&&(b=!1,s.resistance&&(i.currentTranslate=r.minTranslate()-1+(-r.minTranslate()+i.startTranslate+p)**E))):p<0&&(v&&y&&i.allowThresholdMove&&i.currentTranslate<(s.centeredSlides?r.maxTranslate()+r.slidesSizesGrid[r.slidesSizesGrid.length-1]+r.params.spaceBetween+("auto"!==s.slidesPerView&&r.slides.length-s.slidesPerView>=2?r.slidesSizesGrid[r.slidesSizesGrid.length-1]+r.params.spaceBetween:0):r.maxTranslate())&&r.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:r.slides.length-("auto"===s.slidesPerView?r.slidesPerViewDynamic():Math.ceil(parseFloat(s.slidesPerView,10)))}),i.currentTranslate<r.maxTranslate()&&(b=!1,s.resistance&&(i.currentTranslate=r.maxTranslate()+1-(r.maxTranslate()-i.startTranslate-p)**E))),b&&(c.preventedByNestedSwiper=!0),!r.allowSlideNext&&"next"===r.swipeDirection&&i.currentTranslate<i.startTranslate&&(i.currentTranslate=i.startTranslate),!r.allowSlidePrev&&"prev"===r.swipeDirection&&i.currentTranslate>i.startTranslate&&(i.currentTranslate=i.startTranslate),r.allowSlidePrev||r.allowSlideNext||(i.currentTranslate=i.startTranslate),s.threshold>0){if(!(Math.abs(p)>s.threshold||i.allowThresholdMove))return void(i.currentTranslate=i.startTranslate);if(!i.allowThresholdMove)return i.allowThresholdMove=!0,n.startX=n.currentX,n.startY=n.currentY,i.currentTranslate=i.startTranslate,void(n.diff=r.isHorizontal()?n.currentX-n.startX:n.currentY-n.startY)}s.followFinger&&!s.cssMode&&((s.freeMode&&s.freeMode.enabled&&r.freeMode||s.watchSlidesProgress)&&(r.updateActiveIndex(),r.updateSlidesClasses()),s.freeMode&&s.freeMode.enabled&&r.freeMode&&r.freeMode.onTouchMove(),r.updateProgress(i.currentTranslate),r.setTranslate(i.currentTranslate))}function xn(e){const t=this,r=t.touchEventsData;let i,s=e;s.originalEvent&&(s=s.originalEvent);if("touchend"===s.type||"touchcancel"===s.type){if(i=[...s.changedTouches].filter(e=>e.identifier===r.touchId)[0],!i||i.identifier!==r.touchId)return}else{if(null!==r.touchId)return;if(s.pointerId!==r.pointerId)return;i=s}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(s.type)){if(!(["pointercancel","contextmenu"].includes(s.type)&&(t.browser.isSafari||t.browser.isWebView)))return}r.pointerId=null,r.touchId=null;const{params:n,touches:a,rtlTranslate:o,slidesGrid:l,enabled:c}=t;if(!c)return;if(!n.simulateTouch&&"mouse"===s.pointerType)return;if(r.allowTouchCallbacks&&t.emit("touchEnd",s),r.allowTouchCallbacks=!1,!r.isTouched)return r.isMoved&&n.grabCursor&&t.setGrabCursor(!1),r.isMoved=!1,void(r.startMoving=!1);n.grabCursor&&r.isMoved&&r.isTouched&&(!0===t.allowSlideNext||!0===t.allowSlidePrev)&&t.setGrabCursor(!1);const d=zs(),u=d-r.touchStartTime;if(t.allowClick){const e=s.path||s.composedPath&&s.composedPath();t.updateClickedSlide(e&&e[0]||s.target,e),t.emit("tap click",s),u<300&&d-r.lastClickTime<300&&t.emit("doubleTap doubleClick",s)}if(r.lastClickTime=zs(),Us(()=>{t.destroyed||(t.allowClick=!0)}),!r.isTouched||!r.isMoved||!t.swipeDirection||0===a.diff&&!r.loopSwapReset||r.currentTranslate===r.startTranslate&&!r.loopSwapReset)return r.isTouched=!1,r.isMoved=!1,void(r.startMoving=!1);let h;if(r.isTouched=!1,r.isMoved=!1,r.startMoving=!1,h=n.followFinger?o?t.translate:-t.translate:-r.currentTranslate,n.cssMode)return;if(n.freeMode&&n.freeMode.enabled)return void t.freeMode.onTouchEnd({currentPos:h});const f=h>=-t.maxTranslate()&&!t.params.loop;let p=0,m=t.slidesSizesGrid[0];for(let e=0;e<l.length;e+=e<n.slidesPerGroupSkip?1:n.slidesPerGroup){const t=e<n.slidesPerGroupSkip-1?1:n.slidesPerGroup;void 0!==l[e+t]?(f||h>=l[e]&&h<l[e+t])&&(p=e,m=l[e+t]-l[e]):(f||h>=l[e])&&(p=e,m=l[l.length-1]-l[l.length-2])}let g=null,v=null;n.rewind&&(t.isBeginning?v=n.virtual&&n.virtual.enabled&&t.virtual?t.virtual.slides.length-1:t.slides.length-1:t.isEnd&&(g=0));const y=(h-l[p])/m,b=p<n.slidesPerGroupSkip-1?1:n.slidesPerGroup;if(u>n.longSwipesMs){if(!n.longSwipes)return void t.slideTo(t.activeIndex);"next"===t.swipeDirection&&(y>=n.longSwipesRatio?t.slideTo(n.rewind&&t.isEnd?g:p+b):t.slideTo(p)),"prev"===t.swipeDirection&&(y>1-n.longSwipesRatio?t.slideTo(p+b):null!==v&&y<0&&Math.abs(y)>n.longSwipesRatio?t.slideTo(v):t.slideTo(p))}else{if(!n.shortSwipes)return void t.slideTo(t.activeIndex);t.navigation&&(s.target===t.navigation.nextEl||s.target===t.navigation.prevEl)?s.target===t.navigation.nextEl?t.slideTo(p+b):t.slideTo(p):("next"===t.swipeDirection&&t.slideTo(null!==g?g:p+b),"prev"===t.swipeDirection&&t.slideTo(null!==v?v:p))}}function An(){const e=this,{params:t,el:r}=e;if(r&&0===r.offsetWidth)return;t.breakpoints&&e.setBreakpoint();const{allowSlideNext:i,allowSlidePrev:s,snapGrid:n}=e,a=e.virtual&&e.params.virtual.enabled;e.allowSlideNext=!0,e.allowSlidePrev=!0,e.updateSize(),e.updateSlides(),e.updateSlidesClasses();const o=a&&t.loop;!("auto"===t.slidesPerView||t.slidesPerView>1)||!e.isEnd||e.isBeginning||e.params.centeredSlides||o?e.params.loop&&!a?e.slideToLoop(e.realIndex,0,!1,!0):e.slideTo(e.activeIndex,0,!1,!0):e.slideTo(e.slides.length-1,0,!1,!0),e.autoplay&&e.autoplay.running&&e.autoplay.paused&&(clearTimeout(e.autoplay.resizeTimeout),e.autoplay.resizeTimeout=setTimeout(()=>{e.autoplay&&e.autoplay.running&&e.autoplay.paused&&e.autoplay.resume()},500)),e.allowSlidePrev=s,e.allowSlideNext=i,e.params.watchOverflow&&n!==e.snapGrid&&e.checkOverflow()}function kn(e){const t=this;t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function Ln(){const e=this,{wrapperEl:t,rtlTranslate:r,enabled:i}=e;if(!i)return;let s;e.previousTranslate=e.translate,e.isHorizontal()?e.translate=-t.scrollLeft:e.translate=-t.scrollTop,0===e.translate&&(e.translate=0),e.updateActiveIndex(),e.updateSlidesClasses();const n=e.maxTranslate()-e.minTranslate();s=0===n?0:(e.translate-e.minTranslate())/n,s!==e.progress&&e.updateProgress(r?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}function In(e){const t=this;hn(t,e.target),t.params.cssMode||"auto"!==t.params.slidesPerView&&!t.params.autoHeight||t.update()}function Rn(){const e=this;e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}const Pn=(e,t)=>{const r=Fs(),{params:i,el:s,wrapperEl:n,device:a}=e,o=!!i.nested,l="on"===t?"addEventListener":"removeEventListener",c=t;s&&"string"!=typeof s&&(r[l]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:o}),s[l]("touchstart",e.onTouchStart,{passive:!1}),s[l]("pointerdown",e.onTouchStart,{passive:!1}),r[l]("touchmove",e.onTouchMove,{passive:!1,capture:o}),r[l]("pointermove",e.onTouchMove,{passive:!1,capture:o}),r[l]("touchend",e.onTouchEnd,{passive:!0}),r[l]("pointerup",e.onTouchEnd,{passive:!0}),r[l]("pointercancel",e.onTouchEnd,{passive:!0}),r[l]("touchcancel",e.onTouchEnd,{passive:!0}),r[l]("pointerout",e.onTouchEnd,{passive:!0}),r[l]("pointerleave",e.onTouchEnd,{passive:!0}),r[l]("contextmenu",e.onTouchEnd,{passive:!0}),(i.preventClicks||i.preventClicksPropagation)&&s[l]("click",e.onClick,!0),i.cssMode&&n[l]("scroll",e.onScroll),i.updateOnWindowResize?e[c](a.ios||a.android?"resize orientationchange observerUpdate":"resize observerUpdate",An,!0):e[c]("observerUpdate",An,!0),s[l]("load",e.onLoad,{capture:!0}))};const Cn=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var Dn={setBreakpoint:function(){const e=this,{realIndex:t,initialized:r,params:i,el:s}=e,n=i.breakpoints;if(!n||n&&0===Object.keys(n).length)return;const a=e.getBreakpoint(n,e.params.breakpointsBase,e.el);if(!a||e.currentBreakpoint===a)return;const o=(a in n?n[a]:void 0)||e.originalParams,l=Cn(e,i),c=Cn(e,o),d=e.params.grabCursor,u=o.grabCursor,h=i.enabled;l&&!c?(s.classList.remove(`${i.containerModifierClass}grid`,`${i.containerModifierClass}grid-column`),e.emitContainerClasses()):!l&&c&&(s.classList.add(`${i.containerModifierClass}grid`),(o.grid.fill&&"column"===o.grid.fill||!o.grid.fill&&"column"===i.grid.fill)&&s.classList.add(`${i.containerModifierClass}grid-column`),e.emitContainerClasses()),d&&!u?e.unsetGrabCursor():!d&&u&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(t=>{if(void 0===o[t])return;const r=i[t]&&i[t].enabled,s=o[t]&&o[t].enabled;r&&!s&&e[t].disable(),!r&&s&&e[t].enable()});const f=o.direction&&o.direction!==i.direction,p=i.loop&&(o.slidesPerView!==i.slidesPerView||f),m=i.loop;f&&r&&e.changeDirection(),Vs(e.params,o);const g=e.params.enabled,v=e.params.loop;Object.assign(e,{allowTouchMove:e.params.allowTouchMove,allowSlideNext:e.params.allowSlideNext,allowSlidePrev:e.params.allowSlidePrev}),h&&!g?e.disable():!h&&g&&e.enable(),e.currentBreakpoint=a,e.emit("_beforeBreakpoint",o),r&&(p?(e.loopDestroy(),e.loopCreate(t),e.updateSlides()):!m&&v?(e.loopCreate(t),e.updateSlides()):m&&!v&&e.loopDestroy()),e.emit("breakpoint",o)},getBreakpoint:function(e,t,r){if(void 0===t&&(t="window"),!e||"container"===t&&!r)return;let i=!1;const s=Bs(),n="window"===t?s.innerHeight:r.clientHeight,a=Object.keys(e).map(e=>{if("string"==typeof e&&0===e.indexOf("@")){const t=parseFloat(e.substr(1));return{value:n*t,point:e}}return{value:e,point:e}});a.sort((e,t)=>parseInt(e.value,10)-parseInt(t.value,10));for(let e=0;e<a.length;e+=1){const{point:n,value:o}=a[e];"window"===t?s.matchMedia(`(min-width: ${o}px)`).matches&&(i=n):o<=r.clientWidth&&(i=n)}return i||"max"}};var _n={init:!0,direction:"horizontal",oneWayMovement:!1,swiperElementNodeName:"SWIPER-CONTAINER",touchEventsTarget:"wrapper",initialSlide:0,speed:300,cssMode:!1,updateOnWindowResize:!0,resizeObserver:!0,nested:!1,createElements:!1,eventsPrefix:"swiper",enabled:!0,focusableElements:"input, select, option, textarea, button, video, label",width:null,height:null,preventInteractionOnTransition:!1,userAgent:null,url:null,edgeSwipeDetection:!1,edgeSwipeThreshold:20,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",breakpoints:void 0,breakpointsBase:"window",spaceBetween:0,slidesPerView:1,slidesPerGroup:1,slidesPerGroupSkip:0,slidesPerGroupAuto:!1,centeredSlides:!1,centeredSlidesBounds:!1,slidesOffsetBefore:0,slidesOffsetAfter:0,normalizeSlideIndex:!0,centerInsufficientSlides:!1,watchOverflow:!0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,allowTouchMove:!0,threshold:5,touchMoveStopPropagation:!1,touchStartPreventDefault:!0,touchStartForcePreventDefault:!1,touchReleaseOnEdges:!1,uniqueNavElements:!0,resistance:!0,resistanceRatio:.85,watchSlidesProgress:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,slideToClickedSlide:!1,loop:!1,loopAddBlankSlides:!0,loopAdditionalSlides:0,loopPreventsSliding:!0,rewind:!1,allowSlidePrev:!0,allowSlideNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:null,passiveListeners:!0,maxBackfaceHiddenSlides:10,containerModifierClass:"swiper-",slideClass:"swiper-slide",slideBlankClass:"swiper-slide-blank",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideFullyVisibleClass:"swiper-slide-fully-visible",slideNextClass:"swiper-slide-next",slidePrevClass:"swiper-slide-prev",wrapperClass:"swiper-wrapper",lazyPreloaderClass:"swiper-lazy-preloader",lazyPreloadPrevNext:0,runCallbacksOnInit:!0,_emitClasses:!1};function On(e,t){return function(r){void 0===r&&(r={});const i=Object.keys(r)[0],s=r[i];"object"==typeof s&&null!==s?(!0===e[i]&&(e[i]={enabled:!0}),"navigation"===i&&e[i]&&e[i].enabled&&!e[i].prevEl&&!e[i].nextEl&&(e[i].auto=!0),["pagination","scrollbar"].indexOf(i)>=0&&e[i]&&e[i].enabled&&!e[i].el&&(e[i].auto=!0),i in e&&"enabled"in s?("object"!=typeof e[i]||"enabled"in e[i]||(e[i].enabled=!0),e[i]||(e[i]={enabled:!1}),Vs(t,r)):Vs(t,r)):Vs(t,r)}}const Mn={eventsEmitter:cn,update:mn,translate:gn,transition:yn,slide:bn,loop:En,grabCursor:{setGrabCursor:function(e){const t=this;if(!t.params.simulateTouch||t.params.watchOverflow&&t.isLocked||t.params.cssMode)return;const r="container"===t.params.touchEventsTarget?t.el:t.wrapperEl;t.isElement&&(t.__preventObserver__=!0),r.style.cursor="move",r.style.cursor=e?"grabbing":"grab",t.isElement&&requestAnimationFrame(()=>{t.__preventObserver__=!1})},unsetGrabCursor:function(){const e=this;e.params.watchOverflow&&e.isLocked||e.params.cssMode||(e.isElement&&(e.__preventObserver__=!0),e["container"===e.params.touchEventsTarget?"el":"wrapperEl"].style.cursor="",e.isElement&&requestAnimationFrame(()=>{e.__preventObserver__=!1}))}},events:{attachEvents:function(){const e=this,{params:t}=e;e.onTouchStart=Sn.bind(e),e.onTouchMove=Tn.bind(e),e.onTouchEnd=xn.bind(e),e.onDocumentTouchStart=Rn.bind(e),t.cssMode&&(e.onScroll=Ln.bind(e)),e.onClick=kn.bind(e),e.onLoad=In.bind(e),Pn(e,"on")},detachEvents:function(){Pn(this,"off")}},breakpoints:Dn,checkOverflow:{checkOverflow:function(){const e=this,{isLocked:t,params:r}=e,{slidesOffsetBefore:i}=r;if(i){const t=e.slides.length-1,r=e.slidesGrid[t]+e.slidesSizesGrid[t]+2*i;e.isLocked=e.size>r}else e.isLocked=1===e.snapGrid.length;!0===r.allowSlideNext&&(e.allowSlideNext=!e.isLocked),!0===r.allowSlidePrev&&(e.allowSlidePrev=!e.isLocked),t&&t!==e.isLocked&&(e.isEnd=!1),t!==e.isLocked&&e.emit(e.isLocked?"lock":"unlock")}},classes:{addClasses:function(){const e=this,{classNames:t,params:r,rtl:i,el:s,device:n}=e,a=function(e,t){const r=[];return e.forEach(e=>{"object"==typeof e?Object.keys(e).forEach(i=>{e[i]&&r.push(t+i)}):"string"==typeof e&&r.push(t+e)}),r}(["initialized",r.direction,{"free-mode":e.params.freeMode&&r.freeMode.enabled},{autoheight:r.autoHeight},{rtl:i},{grid:r.grid&&r.grid.rows>1},{"grid-column":r.grid&&r.grid.rows>1&&"column"===r.grid.fill},{android:n.android},{ios:n.ios},{"css-mode":r.cssMode},{centered:r.cssMode&&r.centeredSlides},{"watch-progress":r.watchSlidesProgress}],r.containerModifierClass);t.push(...a),s.classList.add(...t),e.emitContainerClasses()},removeClasses:function(){const{el:e,classNames:t}=this;e&&"string"!=typeof e&&(e.classList.remove(...t),this.emitContainerClasses())}}},Nn={};let Fn=class e{constructor(){let t,r;for(var i=arguments.length,s=new Array(i),n=0;n<i;n++)s[n]=arguments[n];1===s.length&&s[0].constructor&&"Object"===Object.prototype.toString.call(s[0]).slice(8,-1)?r=s[0]:[t,r]=s,r||(r={}),r=Vs({},r),t&&!r.el&&(r.el=t);const a=Fs();if(r.el&&"string"==typeof r.el&&a.querySelectorAll(r.el).length>1){const t=[];return a.querySelectorAll(r.el).forEach(i=>{const s=Vs({},r,{el:i});t.push(new e(s))}),t}const o=this;o.__swiper__=!0,o.support=an(),o.device=on({userAgent:r.userAgent}),o.browser=ln(),o.eventsListeners={},o.eventsAnyListeners=[],o.modules=[...o.__modules__],r.modules&&Array.isArray(r.modules)&&o.modules.push(...r.modules);const l={};o.modules.forEach(e=>{e({params:r,swiper:o,extendParams:On(r,l),on:o.on.bind(o),once:o.once.bind(o),off:o.off.bind(o),emit:o.emit.bind(o)})});const c=Vs({},_n,l);return o.params=Vs({},c,Nn,r),o.originalParams=Vs({},o.params),o.passedParams=Vs({},r),o.params&&o.params.on&&Object.keys(o.params.on).forEach(e=>{o.on(e,o.params.on[e])}),o.params&&o.params.onAny&&o.onAny(o.params.onAny),Object.assign(o,{enabled:o.params.enabled,el:t,classNames:[],slides:[],slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal:()=>"horizontal"===o.params.direction,isVertical:()=>"vertical"===o.params.direction,activeIndex:0,realIndex:0,isBeginning:!0,isEnd:!1,translate:0,previousTranslate:0,progress:0,velocity:0,animating:!1,cssOverflowAdjustment(){return Math.trunc(this.translate/2**23)*2**23},allowSlideNext:o.params.allowSlideNext,allowSlidePrev:o.params.allowSlidePrev,touchEventsData:{isTouched:void 0,isMoved:void 0,allowTouchCallbacks:void 0,touchStartTime:void 0,isScrolling:void 0,currentTranslate:void 0,startTranslate:void 0,allowThresholdMove:void 0,focusableElements:o.params.focusableElements,lastClickTime:0,clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,startMoving:void 0,pointerId:null,touchId:null},allowClick:!0,allowTouchMove:o.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0}),o.emit("_swiper"),o.params.init&&o.init(),o}getDirectionLabel(e){return this.isHorizontal()?e:{width:"height","margin-top":"margin-left","margin-bottom ":"margin-right","margin-left":"margin-top","margin-right":"margin-bottom","padding-left":"padding-top","padding-right":"padding-bottom",marginRight:"marginBottom"}[e]}getSlideIndex(e){const{slidesEl:t,params:r}=this,i=Js(qs(t,`.${r.slideClass}, swiper-slide`)[0]);return Js(e)-i}getSlideIndexByData(e){return this.getSlideIndex(this.slides.filter(t=>1*t.getAttribute("data-swiper-slide-index")===e)[0])}recalcSlides(){const{slidesEl:e,params:t}=this;this.slides=qs(e,`.${t.slideClass}, swiper-slide`)}enable(){const e=this;e.enabled||(e.enabled=!0,e.params.grabCursor&&e.setGrabCursor(),e.emit("enable"))}disable(){const e=this;e.enabled&&(e.enabled=!1,e.params.grabCursor&&e.unsetGrabCursor(),e.emit("disable"))}setProgress(e,t){const r=this;e=Math.min(Math.max(e,0),1);const i=r.minTranslate(),s=(r.maxTranslate()-i)*e+i;r.translateTo(s,void 0===t?0:t),r.updateActiveIndex(),r.updateSlidesClasses()}emitContainerClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=e.el.className.split(" ").filter(t=>0===t.indexOf("swiper")||0===t.indexOf(e.params.containerModifierClass));e.emit("_containerClasses",t.join(" "))}getSlideClasses(e){const t=this;return t.destroyed?"":e.className.split(" ").filter(e=>0===e.indexOf("swiper-slide")||0===e.indexOf(t.params.slideClass)).join(" ")}emitSlidesClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=[];e.slides.forEach(r=>{const i=e.getSlideClasses(r);t.push({slideEl:r,classNames:i}),e.emit("_slideClass",r,i)}),e.emit("_slideClasses",t)}slidesPerViewDynamic(e,t){void 0===e&&(e="current"),void 0===t&&(t=!1);const{params:r,slides:i,slidesGrid:s,slidesSizesGrid:n,size:a,activeIndex:o}=this;let l=1;if("number"==typeof r.slidesPerView)return r.slidesPerView;if(r.centeredSlides){let e,t=i[o]?Math.ceil(i[o].swiperSlideSize):0;for(let r=o+1;r<i.length;r+=1)i[r]&&!e&&(t+=Math.ceil(i[r].swiperSlideSize),l+=1,t>a&&(e=!0));for(let r=o-1;r>=0;r-=1)i[r]&&!e&&(t+=i[r].swiperSlideSize,l+=1,t>a&&(e=!0))}else if("current"===e)for(let e=o+1;e<i.length;e+=1){(t?s[e]+n[e]-s[o]<a:s[e]-s[o]<a)&&(l+=1)}else for(let e=o-1;e>=0;e-=1){s[o]-s[e]<a&&(l+=1)}return l}update(){const e=this;if(!e||e.destroyed)return;const{snapGrid:t,params:r}=e;function i(){const t=e.rtlTranslate?-1*e.translate:e.translate,r=Math.min(Math.max(t,e.maxTranslate()),e.minTranslate());e.setTranslate(r),e.updateActiveIndex(),e.updateSlidesClasses()}let s;if(r.breakpoints&&e.setBreakpoint(),[...e.el.querySelectorAll('[loading="lazy"]')].forEach(t=>{t.complete&&hn(e,t)}),e.updateSize(),e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),r.freeMode&&r.freeMode.enabled&&!r.cssMode)i(),r.autoHeight&&e.updateAutoHeight();else{if(("auto"===r.slidesPerView||r.slidesPerView>1)&&e.isEnd&&!r.centeredSlides){const t=e.virtual&&r.virtual.enabled?e.virtual.slides:e.slides;s=e.slideTo(t.length-1,0,!1,!0)}else s=e.slideTo(e.activeIndex,0,!1,!0);s||i()}r.watchOverflow&&t!==e.snapGrid&&e.checkOverflow(),e.emit("update")}changeDirection(e,t){void 0===t&&(t=!0);const r=this,i=r.params.direction;return e||(e="horizontal"===i?"vertical":"horizontal"),e===i||"horizontal"!==e&&"vertical"!==e||(r.el.classList.remove(`${r.params.containerModifierClass}${i}`),r.el.classList.add(`${r.params.containerModifierClass}${e}`),r.emitContainerClasses(),r.params.direction=e,r.slides.forEach(t=>{"vertical"===e?t.style.width="":t.style.height=""}),r.emit("changeDirection"),t&&r.update()),r}changeLanguageDirection(e){const t=this;t.rtl&&"rtl"===e||!t.rtl&&"ltr"===e||(t.rtl="rtl"===e,t.rtlTranslate="horizontal"===t.params.direction&&t.rtl,t.rtl?(t.el.classList.add(`${t.params.containerModifierClass}rtl`),t.el.dir="rtl"):(t.el.classList.remove(`${t.params.containerModifierClass}rtl`),t.el.dir="ltr"),t.update())}mount(e){const t=this;if(t.mounted)return!0;let r=e||t.params.el;if("string"==typeof r&&(r=document.querySelector(r)),!r)return!1;r.swiper=t,r.parentNode&&r.parentNode.host&&r.parentNode.host.nodeName===t.params.swiperElementNodeName.toUpperCase()&&(t.isElement=!0);const i=()=>`.${(t.params.wrapperClass||"").trim().split(" ").join(".")}`;let s=(()=>{if(r&&r.shadowRoot&&r.shadowRoot.querySelector){return r.shadowRoot.querySelector(i())}return qs(r,i())[0]})();return!s&&t.params.createElements&&(s=Qs("div",t.params.wrapperClass),r.append(s),qs(r,`.${t.params.slideClass}`).forEach(e=>{s.append(e)})),Object.assign(t,{el:r,wrapperEl:s,slidesEl:t.isElement&&!r.parentNode.host.slideSlots?r.parentNode.host:s,hostEl:t.isElement?r.parentNode.host:r,mounted:!0,rtl:"rtl"===r.dir.toLowerCase()||"rtl"===Zs(r,"direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===r.dir.toLowerCase()||"rtl"===Zs(r,"direction")),wrongRTL:"-webkit-box"===Zs(s,"display")}),!0}init(e){const t=this;if(t.initialized)return t;if(!1===t.mount(e))return t;t.emit("beforeInit"),t.params.breakpoints&&t.setBreakpoint(),t.addClasses(),t.updateSize(),t.updateSlides(),t.params.watchOverflow&&t.checkOverflow(),t.params.grabCursor&&t.enabled&&t.setGrabCursor(),t.params.loop&&t.virtual&&t.params.virtual.enabled?t.slideTo(t.params.initialSlide+t.virtual.slidesBefore,0,t.params.runCallbacksOnInit,!1,!0):t.slideTo(t.params.initialSlide,0,t.params.runCallbacksOnInit,!1,!0),t.params.loop&&t.loopCreate(),t.attachEvents();const r=[...t.el.querySelectorAll('[loading="lazy"]')];return t.isElement&&r.push(...t.hostEl.querySelectorAll('[loading="lazy"]')),r.forEach(e=>{e.complete?hn(t,e):e.addEventListener("load",e=>{hn(t,e.target)})}),pn(t),t.initialized=!0,pn(t),t.emit("init"),t.emit("afterInit"),t}destroy(e,t){void 0===e&&(e=!0),void 0===t&&(t=!0);const r=this,{params:i,el:s,wrapperEl:n,slides:a}=r;return void 0===r.params||r.destroyed||(r.emit("beforeDestroy"),r.initialized=!1,r.detachEvents(),i.loop&&r.loopDestroy(),t&&(r.removeClasses(),s&&"string"!=typeof s&&s.removeAttribute("style"),n&&n.removeAttribute("style"),a&&a.length&&a.forEach(e=>{e.classList.remove(i.slideVisibleClass,i.slideFullyVisibleClass,i.slideActiveClass,i.slideNextClass,i.slidePrevClass),e.removeAttribute("style"),e.removeAttribute("data-swiper-slide-index")})),r.emit("destroy"),Object.keys(r.eventsListeners).forEach(e=>{r.off(e)}),!1!==e&&(r.el&&"string"!=typeof r.el&&(r.el.swiper=null),function(e){const t=e;Object.keys(t).forEach(e=>{try{t[e]=null}catch(e){}try{delete t[e]}catch(e){}})}(r)),r.destroyed=!0),null}static extendDefaults(e){Vs(Nn,e)}static get extendedDefaults(){return Nn}static get defaults(){return _n}static installModule(t){e.prototype.__modules__||(e.prototype.__modules__=[]);const r=e.prototype.__modules__;"function"==typeof t&&r.indexOf(t)<0&&r.push(t)}static use(t){return Array.isArray(t)?(t.forEach(t=>e.installModule(t)),e):(e.installModule(t),e)}};Object.keys(Mn).forEach(e=>{Object.keys(Mn[e]).forEach(t=>{Fn.prototype[t]=Mn[e][t]})}),Fn.use([function(e){let{swiper:t,on:r,emit:i}=e;const s=Bs();let n=null,a=null;const o=()=>{t&&!t.destroyed&&t.initialized&&(i("beforeResize"),i("resize"))},l=()=>{t&&!t.destroyed&&t.initialized&&i("orientationchange")};r("init",()=>{t.params.resizeObserver&&void 0!==s.ResizeObserver?t&&!t.destroyed&&t.initialized&&(n=new ResizeObserver(e=>{a=s.requestAnimationFrame(()=>{const{width:r,height:i}=t;let s=r,n=i;e.forEach(e=>{let{contentBoxSize:r,contentRect:i,target:a}=e;a&&a!==t.el||(s=i?i.width:(r[0]||r).inlineSize,n=i?i.height:(r[0]||r).blockSize)}),s===r&&n===i||o()})}),n.observe(t.el)):(s.addEventListener("resize",o),s.addEventListener("orientationchange",l))}),r("destroy",()=>{a&&s.cancelAnimationFrame(a),n&&n.unobserve&&t.el&&(n.unobserve(t.el),n=null),s.removeEventListener("resize",o),s.removeEventListener("orientationchange",l)})},function(e){let{swiper:t,extendParams:r,on:i,emit:s}=e;const n=[],a=Bs(),o=function(e,r){void 0===r&&(r={});const i=new(a.MutationObserver||a.WebkitMutationObserver)(e=>{if(t.__preventObserver__)return;if(1===e.length)return void s("observerUpdate",e[0]);const r=function(){s("observerUpdate",e[0])};a.requestAnimationFrame?a.requestAnimationFrame(r):a.setTimeout(r,0)});i.observe(e,{attributes:void 0===r.attributes||r.attributes,childList:t.isElement||(void 0===r.childList||r).childList,characterData:void 0===r.characterData||r.characterData}),n.push(i)};r({observer:!1,observeParents:!1,observeSlideChildren:!1}),i("init",()=>{if(t.params.observer){if(t.params.observeParents){const e=function(e){const t=[];let r=e.parentElement;for(;r;)t.push(r),r=r.parentElement;return t}(t.hostEl);for(let t=0;t<e.length;t+=1)o(e[t])}o(t.hostEl,{childList:t.params.observeSlideChildren}),o(t.wrapperEl,{attributes:!1})}}),i("destroy",()=>{n.forEach(e=>{e.disconnect()}),n.splice(0,n.length)})}]);const $n=["eventsPrefix","injectStyles","injectStylesUrls","modules","init","_direction","oneWayMovement","swiperElementNodeName","touchEventsTarget","initialSlide","_speed","cssMode","updateOnWindowResize","resizeObserver","nested","focusableElements","_enabled","_width","_height","preventInteractionOnTransition","userAgent","url","_edgeSwipeDetection","_edgeSwipeThreshold","_freeMode","_autoHeight","setWrapperSize","virtualTranslate","_effect","breakpoints","breakpointsBase","_spaceBetween","_slidesPerView","maxBackfaceHiddenSlides","_grid","_slidesPerGroup","_slidesPerGroupSkip","_slidesPerGroupAuto","_centeredSlides","_centeredSlidesBounds","_slidesOffsetBefore","_slidesOffsetAfter","normalizeSlideIndex","_centerInsufficientSlides","_watchOverflow","roundLengths","touchRatio","touchAngle","simulateTouch","_shortSwipes","_longSwipes","longSwipesRatio","longSwipesMs","_followFinger","allowTouchMove","_threshold","touchMoveStopPropagation","touchStartPreventDefault","touchStartForcePreventDefault","touchReleaseOnEdges","uniqueNavElements","_resistance","_resistanceRatio","_watchSlidesProgress","_grabCursor","preventClicks","preventClicksPropagation","_slideToClickedSlide","_loop","loopAdditionalSlides","loopAddBlankSlides","loopPreventsSliding","_rewind","_allowSlidePrev","_allowSlideNext","_swipeHandler","_noSwiping","noSwipingClass","noSwipingSelector","passiveListeners","containerModifierClass","slideClass","slideActiveClass","slideVisibleClass","slideFullyVisibleClass","slideNextClass","slidePrevClass","slideBlankClass","wrapperClass","lazyPreloaderClass","lazyPreloadPrevNext","runCallbacksOnInit","observer","observeParents","observeSlideChildren","a11y","_autoplay","_controller","coverflowEffect","cubeEffect","fadeEffect","flipEffect","creativeEffect","cardsEffect","hashNavigation","history","keyboard","mousewheel","_navigation","_pagination","parallax","_scrollbar","_thumbs","virtual","zoom","control"];function Bn(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)&&!e.__swiper__}function Un(e,t){const r=["__proto__","constructor","prototype"];Object.keys(t).filter(e=>r.indexOf(e)<0).forEach(r=>{void 0===e[r]?e[r]=t[r]:Bn(t[r])&&Bn(e[r])&&Object.keys(t[r]).length>0?t[r].__swiper__?e[r]=t[r]:Un(e[r],t[r]):e[r]=t[r]})}function zn(e){return void 0===e&&(e={}),e.navigation&&void 0===e.navigation.nextEl&&void 0===e.navigation.prevEl}function Gn(e){return void 0===e&&(e={}),e.pagination&&void 0===e.pagination.el}function jn(e){return void 0===e&&(e={}),e.scrollbar&&void 0===e.scrollbar.el}function Hn(e){void 0===e&&(e="");const t=e.split(" ").map(e=>e.trim()).filter(e=>!!e),r=[];return t.forEach(e=>{r.indexOf(e)<0&&r.push(e)}),r.join(" ")}function Vn(e){return void 0===e&&(e=""),e?e.includes("swiper-wrapper")?e:`swiper-wrapper ${e}`:"swiper-wrapper"}function Wn(){return Wn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},Wn.apply(this,arguments)}function Yn(e){return e.type&&e.type.displayName&&e.type.displayName.includes("SwiperSlide")}function Kn(e){const r=[];return t.Children.toArray(e).forEach(e=>{Yn(e)?r.push(e):e.props&&e.props.children&&Kn(e.props.children).forEach(e=>r.push(e))}),r}function qn(e){const r=[],i={"container-start":[],"container-end":[],"wrapper-start":[],"wrapper-end":[]};return t.Children.toArray(e).forEach(e=>{if(Yn(e))r.push(e);else if(e.props&&e.props.slot&&i[e.props.slot])i[e.props.slot].push(e);else if(e.props&&e.props.children){const t=Kn(e.props.children);t.length>0?t.forEach(e=>r.push(e)):i["container-end"].push(e)}else i["container-end"].push(e)}),{slides:r,slots:i}}function Xn(e,t){return"undefined"==typeof window?i(e,t):o(e,t)}const Qn=s(null),Zn=s(null),Jn=n(function(e,s){let{className:n,tag:o="div",wrapperTag:l="div",children:c,onSwiper:d,...u}=void 0===e?{}:e,h=!1;const[f,p]=a("swiper"),[m,g]=a(null),[v,y]=a(!1),b=r(!1),E=r(null),w=r(null),S=r(null),T=r(null),x=r(null),A=r(null),k=r(null),L=r(null),{params:I,passedParams:R,rest:P,events:C}=function(e,t){void 0===e&&(e={}),void 0===t&&(t=!0);const r={on:{}},i={},s={};Un(r,_n),r._emitClasses=!0,r.init=!1;const n={},a=$n.map(e=>e.replace(/_/,"")),o=Object.assign({},e);return Object.keys(o).forEach(o=>{void 0!==e[o]&&(a.indexOf(o)>=0?Bn(e[o])?(r[o]={},s[o]={},Un(r[o],e[o]),Un(s[o],e[o])):(r[o]=e[o],s[o]=e[o]):0===o.search(/on[A-Z]/)&&"function"==typeof e[o]?t?i[`${o[2].toLowerCase()}${o.substr(3)}`]=e[o]:r.on[`${o[2].toLowerCase()}${o.substr(3)}`]=e[o]:n[o]=e[o])}),["navigation","pagination","scrollbar"].forEach(e=>{!0===r[e]&&(r[e]={}),!1===r[e]&&delete r[e]}),{params:r,passedParams:s,rest:n,events:i}}(u),{slides:D,slots:_}=qn(c),O=()=>{y(!v)};Object.assign(I.on,{_containerClasses(e,t){p(t)}});const M=()=>{Object.assign(I.on,C),h=!0;const e={...I};if(delete e.wrapperClass,w.current=new Fn(e),w.current.virtual&&w.current.params.virtual.enabled){w.current.virtual.slides=D;const e={cache:!1,slides:D,renderExternal:g,renderExternalUpdate:!1};Un(w.current.params.virtual,e),Un(w.current.originalParams.virtual,e)}};E.current||M(),w.current&&w.current.on("_beforeBreakpoint",O);return i(()=>()=>{w.current&&w.current.off("_beforeBreakpoint",O)}),i(()=>{!b.current&&w.current&&(w.current.emitSlidesClasses(),b.current=!0)}),Xn(()=>{if(s&&(s.current=E.current),E.current)return w.current.destroyed&&M(),function(e,t){let{el:r,nextEl:i,prevEl:s,paginationEl:n,scrollbarEl:a,swiper:o}=e;zn(t)&&i&&s&&(o.params.navigation.nextEl=i,o.originalParams.navigation.nextEl=i,o.params.navigation.prevEl=s,o.originalParams.navigation.prevEl=s),Gn(t)&&n&&(o.params.pagination.el=n,o.originalParams.pagination.el=n),jn(t)&&a&&(o.params.scrollbar.el=a,o.originalParams.scrollbar.el=a),o.init(r)}({el:E.current,nextEl:x.current,prevEl:A.current,paginationEl:k.current,scrollbarEl:L.current,swiper:w.current},I),d&&!w.current.destroyed&&d(w.current),()=>{w.current&&!w.current.destroyed&&w.current.destroy(!0,!1)}},[]),Xn(()=>{!h&&C&&w.current&&Object.keys(C).forEach(e=>{w.current.on(e,C[e])});const e=function(e,t,r,i,s){const n=[];if(!t)return n;const a=e=>{n.indexOf(e)<0&&n.push(e)};if(r&&i){const e=i.map(s),t=r.map(s);e.join("")!==t.join("")&&a("children"),i.length!==r.length&&a("children")}return $n.filter(e=>"_"===e[0]).map(e=>e.replace(/_/,"")).forEach(r=>{if(r in e&&r in t)if(Bn(e[r])&&Bn(t[r])){const i=Object.keys(e[r]),s=Object.keys(t[r]);i.length!==s.length?a(r):(i.forEach(i=>{e[r][i]!==t[r][i]&&a(r)}),s.forEach(i=>{e[r][i]!==t[r][i]&&a(r)}))}else e[r]!==t[r]&&a(r)}),n}(R,S.current,D,T.current,e=>e.key);return S.current=R,T.current=D,e.length&&w.current&&!w.current.destroyed&&function(e){let{swiper:t,slides:r,passedParams:i,changedParams:s,nextEl:n,prevEl:a,scrollbarEl:o,paginationEl:l}=e;const c=s.filter(e=>"children"!==e&&"direction"!==e&&"wrapperClass"!==e),{params:d,pagination:u,navigation:h,scrollbar:f,virtual:p,thumbs:m}=t;let g,v,y,b,E,w,S,T;s.includes("thumbs")&&i.thumbs&&i.thumbs.swiper&&!i.thumbs.swiper.destroyed&&d.thumbs&&(!d.thumbs.swiper||d.thumbs.swiper.destroyed)&&(g=!0),s.includes("controller")&&i.controller&&i.controller.control&&d.controller&&!d.controller.control&&(v=!0),s.includes("pagination")&&i.pagination&&(i.pagination.el||l)&&(d.pagination||!1===d.pagination)&&u&&!u.el&&(y=!0),s.includes("scrollbar")&&i.scrollbar&&(i.scrollbar.el||o)&&(d.scrollbar||!1===d.scrollbar)&&f&&!f.el&&(b=!0),s.includes("navigation")&&i.navigation&&(i.navigation.prevEl||a)&&(i.navigation.nextEl||n)&&(d.navigation||!1===d.navigation)&&h&&!h.prevEl&&!h.nextEl&&(E=!0);const x=e=>{t[e]&&(t[e].destroy(),"navigation"===e?(t.isElement&&(t[e].prevEl.remove(),t[e].nextEl.remove()),d[e].prevEl=void 0,d[e].nextEl=void 0,t[e].prevEl=void 0,t[e].nextEl=void 0):(t.isElement&&t[e].el.remove(),d[e].el=void 0,t[e].el=void 0))};s.includes("loop")&&t.isElement&&(d.loop&&!i.loop?w=!0:!d.loop&&i.loop?S=!0:T=!0),c.forEach(e=>{if(Bn(d[e])&&Bn(i[e]))Object.assign(d[e],i[e]),"navigation"!==e&&"pagination"!==e&&"scrollbar"!==e||!("enabled"in i[e])||i[e].enabled||x(e);else{const t=i[e];!0!==t&&!1!==t||"navigation"!==e&&"pagination"!==e&&"scrollbar"!==e?d[e]=i[e]:!1===t&&x(e)}}),c.includes("controller")&&!v&&t.controller&&t.controller.control&&d.controller&&d.controller.control&&(t.controller.control=d.controller.control),s.includes("children")&&r&&p&&d.virtual.enabled?(p.slides=r,p.update(!0)):s.includes("virtual")&&p&&d.virtual.enabled&&(r&&(p.slides=r),p.update(!0)),s.includes("children")&&r&&d.loop&&(T=!0),g&&m.init()&&m.update(!0);v&&(t.controller.control=d.controller.control),y&&(!t.isElement||l&&"string"!=typeof l||(l=document.createElement("div"),l.classList.add("swiper-pagination"),l.part.add("pagination"),t.el.appendChild(l)),l&&(d.pagination.el=l),u.init(),u.render(),u.update()),b&&(!t.isElement||o&&"string"!=typeof o||(o=document.createElement("div"),o.classList.add("swiper-scrollbar"),o.part.add("scrollbar"),t.el.appendChild(o)),o&&(d.scrollbar.el=o),f.init(),f.updateSize(),f.setTranslate()),E&&(t.isElement&&(n&&"string"!=typeof n||(n=document.createElement("div"),n.classList.add("swiper-button-next"),n.innerHTML=t.hostEl.constructor.nextButtonSvg,n.part.add("button-next"),t.el.appendChild(n)),a&&"string"!=typeof a||(a=document.createElement("div"),a.classList.add("swiper-button-prev"),a.innerHTML=t.hostEl.constructor.prevButtonSvg,a.part.add("button-prev"),t.el.appendChild(a))),n&&(d.navigation.nextEl=n),a&&(d.navigation.prevEl=a),h.init(),h.update()),s.includes("allowSlideNext")&&(t.allowSlideNext=i.allowSlideNext),s.includes("allowSlidePrev")&&(t.allowSlidePrev=i.allowSlidePrev),s.includes("direction")&&t.changeDirection(i.direction,!1),(w||T)&&t.loopDestroy(),(S||T)&&t.loopCreate(),t.update()}({swiper:w.current,slides:D,passedParams:R,changedParams:e,nextEl:x.current,prevEl:A.current,scrollbarEl:L.current,paginationEl:k.current}),()=>{C&&w.current&&Object.keys(C).forEach(e=>{w.current.off(e,C[e])})}}),Xn(()=>{var e;!(e=w.current)||e.destroyed||!e.params.virtual||e.params.virtual&&!e.params.virtual.enabled||(e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),e.parallax&&e.params.parallax&&e.params.parallax.enabled&&e.parallax.setTranslate())},[m]),t.createElement(o,Wn({ref:E,className:Hn(`${f}${n?` ${n}`:""}`)},P),t.createElement(Zn.Provider,{value:w.current},_["container-start"],t.createElement(l,{className:Vn(I.wrapperClass)},_["wrapper-start"],I.virtual?function(e,r,i){if(!i)return null;const s=e=>{let t=e;return e<0?t=r.length+e:t>=r.length&&(t-=r.length),t},n=e.isHorizontal()?{[e.rtlTranslate?"right":"left"]:`${i.offset}px`}:{top:`${i.offset}px`},{from:a,to:o}=i,l=e.params.loop?-r.length:0,c=e.params.loop?2*r.length:r.length,d=[];for(let e=l;e<c;e+=1)e>=a&&e<=o&&d.push(r[s(e)]);return d.map((r,i)=>t.cloneElement(r,{swiper:e,style:n,key:r.props.virtualIndex||r.key||`slide-${i}`}))}(w.current,D,m):D.map((e,r)=>t.cloneElement(e,{swiper:w.current,swiperSlideIndex:r})),_["wrapper-end"]),zn(I)&&t.createElement(t.Fragment,null,t.createElement("div",{ref:A,className:"swiper-button-prev"}),t.createElement("div",{ref:x,className:"swiper-button-next"})),jn(I)&&t.createElement("div",{ref:L,className:"swiper-scrollbar"}),Gn(I)&&t.createElement("div",{ref:k,className:"swiper-pagination"}),_["container-end"]))});Jn.displayName="Swiper";const ea=n(function(e,i){let{tag:s="div",children:n,className:o="",swiper:l,zoom:c,lazy:d,virtualIndex:u,swiperSlideIndex:h,...f}=void 0===e?{}:e;const p=r(null),[m,g]=a("swiper-slide"),[v,y]=a(!1);function b(e,t,r){t===p.current&&g(r)}Xn(()=>{if(void 0!==h&&(p.current.swiperSlideIndex=h),i&&(i.current=p.current),p.current&&l){if(!l.destroyed)return l.on("_slideClass",b),()=>{l&&l.off("_slideClass",b)};"swiper-slide"!==m&&g("swiper-slide")}}),Xn(()=>{l&&p.current&&!l.destroyed&&g(l.getSlideClasses(p.current))},[l]);const E={isActive:m.indexOf("swiper-slide-active")>=0,isVisible:m.indexOf("swiper-slide-visible")>=0,isPrev:m.indexOf("swiper-slide-prev")>=0,isNext:m.indexOf("swiper-slide-next")>=0},w=()=>"function"==typeof n?n(E):n;return t.createElement(s,Wn({ref:p,className:Hn(`${m}${o?` ${o}`:""}`),"data-swiper-slide-index":u,onLoad:()=>{y(!0)}},f),c&&t.createElement(Qn.Provider,{value:E},t.createElement("div",{className:"swiper-zoom-container","data-swiper-zoom":"number"==typeof c?c:void 0},w(),d&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"}))),!c&&t.createElement(Qn.Provider,{value:E},w(),d&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"})))});function ta(e){let{swiper:t,extendParams:r,on:i,emit:s}=e;const n=Bs();let a;r({mousewheel:{enabled:!1,releaseOnEdges:!1,invert:!1,forceToAxis:!1,sensitivity:1,eventsTarget:"container",thresholdDelta:null,thresholdTime:null,noMousewheelClass:"swiper-no-mousewheel"}}),t.mousewheel={enabled:!1};let o,l=zs();const c=[];function d(){t.enabled&&(t.mouseEntered=!0)}function u(){t.enabled&&(t.mouseEntered=!1)}function h(e){return!(t.params.mousewheel.thresholdDelta&&e.delta<t.params.mousewheel.thresholdDelta)&&(!(t.params.mousewheel.thresholdTime&&zs()-l<t.params.mousewheel.thresholdTime)&&(e.delta>=6&&zs()-l<60||(e.direction<0?t.isEnd&&!t.params.loop||t.animating||(t.slideNext(),s("scroll",e.raw)):t.isBeginning&&!t.params.loop||t.animating||(t.slidePrev(),s("scroll",e.raw)),l=(new n.Date).getTime(),!1)))}function f(e){let r=e,i=!0;if(!t.enabled)return;if(e.target.closest(`.${t.params.mousewheel.noMousewheelClass}`))return;const n=t.params.mousewheel;t.params.cssMode&&r.preventDefault();let l=t.el;"container"!==t.params.mousewheel.eventsTarget&&(l=document.querySelector(t.params.mousewheel.eventsTarget));const d=l&&l.contains(r.target);if(!t.mouseEntered&&!d&&!n.releaseOnEdges)return!0;r.originalEvent&&(r=r.originalEvent);let u=0;const f=t.rtlTranslate?-1:1,p=function(e){let t=0,r=0,i=0,s=0;return"detail"in e&&(r=e.detail),"wheelDelta"in e&&(r=-e.wheelDelta/120),"wheelDeltaY"in e&&(r=-e.wheelDeltaY/120),"wheelDeltaX"in e&&(t=-e.wheelDeltaX/120),"axis"in e&&e.axis===e.HORIZONTAL_AXIS&&(t=r,r=0),i=10*t,s=10*r,"deltaY"in e&&(s=e.deltaY),"deltaX"in e&&(i=e.deltaX),e.shiftKey&&!i&&(i=s,s=0),(i||s)&&e.deltaMode&&(1===e.deltaMode?(i*=40,s*=40):(i*=800,s*=800)),i&&!t&&(t=i<1?-1:1),s&&!r&&(r=s<1?-1:1),{spinX:t,spinY:r,pixelX:i,pixelY:s}}(r);if(n.forceToAxis)if(t.isHorizontal()){if(!(Math.abs(p.pixelX)>Math.abs(p.pixelY)))return!0;u=-p.pixelX*f}else{if(!(Math.abs(p.pixelY)>Math.abs(p.pixelX)))return!0;u=-p.pixelY}else u=Math.abs(p.pixelX)>Math.abs(p.pixelY)?-p.pixelX*f:-p.pixelY;if(0===u)return!0;n.invert&&(u=-u);let m=t.getTranslate()+u*n.sensitivity;if(m>=t.minTranslate()&&(m=t.minTranslate()),m<=t.maxTranslate()&&(m=t.maxTranslate()),i=!!t.params.loop||!(m===t.minTranslate()||m===t.maxTranslate()),i&&t.params.nested&&r.stopPropagation(),t.params.freeMode&&t.params.freeMode.enabled){const e={time:zs(),delta:Math.abs(u),direction:Math.sign(u)},i=o&&e.time<o.time+500&&e.delta<=o.delta&&e.direction===o.direction;if(!i){o=void 0;let l=t.getTranslate()+u*n.sensitivity;const d=t.isBeginning,h=t.isEnd;if(l>=t.minTranslate()&&(l=t.minTranslate()),l<=t.maxTranslate()&&(l=t.maxTranslate()),t.setTransition(0),t.setTranslate(l),t.updateProgress(),t.updateActiveIndex(),t.updateSlidesClasses(),(!d&&t.isBeginning||!h&&t.isEnd)&&t.updateSlidesClasses(),t.params.loop&&t.loopFix({direction:e.direction<0?"next":"prev",byMousewheel:!0}),t.params.freeMode.sticky){clearTimeout(a),a=void 0,c.length>=15&&c.shift();const r=c.length?c[c.length-1]:void 0,i=c[0];if(c.push(e),r&&(e.delta>r.delta||e.direction!==r.direction))c.splice(0);else if(c.length>=15&&e.time-i.time<500&&i.delta-e.delta>=1&&e.delta<=6){const r=u>0?.8:.2;o=e,c.splice(0),a=Us(()=>{!t.destroyed&&t.params&&t.slideToClosest(t.params.speed,!0,void 0,r)},0)}a||(a=Us(()=>{if(t.destroyed||!t.params)return;o=e,c.splice(0),t.slideToClosest(t.params.speed,!0,void 0,.5)},500))}if(i||s("scroll",r),t.params.autoplay&&t.params.autoplayDisableOnInteraction&&t.autoplay.stop(),n.releaseOnEdges&&(l===t.minTranslate()||l===t.maxTranslate()))return!0}}else{const r={time:zs(),delta:Math.abs(u),direction:Math.sign(u),raw:e};c.length>=2&&c.shift();const i=c.length?c[c.length-1]:void 0;if(c.push(r),i?(r.direction!==i.direction||r.delta>i.delta||r.time>i.time+150)&&h(r):h(r),function(e){const r=t.params.mousewheel;if(e.direction<0){if(t.isEnd&&!t.params.loop&&r.releaseOnEdges)return!0}else if(t.isBeginning&&!t.params.loop&&r.releaseOnEdges)return!0;return!1}(r))return!0}return r.preventDefault?r.preventDefault():r.returnValue=!1,!1}function p(e){let r=t.el;"container"!==t.params.mousewheel.eventsTarget&&(r=document.querySelector(t.params.mousewheel.eventsTarget)),r[e]("mouseenter",d),r[e]("mouseleave",u),r[e]("wheel",f)}function m(){return t.params.cssMode?(t.wrapperEl.removeEventListener("wheel",f),!0):!t.mousewheel.enabled&&(p("addEventListener"),t.mousewheel.enabled=!0,!0)}function g(){return t.params.cssMode?(t.wrapperEl.addEventListener(event,f),!0):!!t.mousewheel.enabled&&(p("removeEventListener"),t.mousewheel.enabled=!1,!0)}i("init",()=>{!t.params.mousewheel.enabled&&t.params.cssMode&&g(),t.params.mousewheel.enabled&&m()}),i("destroy",()=>{t.params.cssMode&&m(),t.mousewheel.enabled&&g()}),Object.assign(t.mousewheel,{enable:m,disable:g})}function ra(e){let{swiper:t,extendParams:r,on:i,emit:s}=e;function n(e){let r;return e&&"string"==typeof e&&t.isElement&&(r=t.el.querySelector(e)||t.hostEl.querySelector(e),r)?r:(e&&("string"==typeof e&&(r=[...document.querySelectorAll(e)]),t.params.uniqueNavElements&&"string"==typeof e&&r&&r.length>1&&1===t.el.querySelectorAll(e).length?r=t.el.querySelector(e):r&&1===r.length&&(r=r[0])),e&&!r?e:r)}function a(e,r){const i=t.params.navigation;(e=tn(e)).forEach(e=>{e&&(e.classList[r?"add":"remove"](...i.disabledClass.split(" ")),"BUTTON"===e.tagName&&(e.disabled=r),t.params.watchOverflow&&t.enabled&&e.classList[t.isLocked?"add":"remove"](i.lockClass))})}function o(){const{nextEl:e,prevEl:r}=t.navigation;if(t.params.loop)return a(r,!1),void a(e,!1);a(r,t.isBeginning&&!t.params.rewind),a(e,t.isEnd&&!t.params.rewind)}function l(e){e.preventDefault(),(!t.isBeginning||t.params.loop||t.params.rewind)&&(t.slidePrev(),s("navigationPrev"))}function c(e){e.preventDefault(),(!t.isEnd||t.params.loop||t.params.rewind)&&(t.slideNext(),s("navigationNext"))}function d(){const e=t.params.navigation;if(t.params.navigation=function(e,t,r,i){return e.params.createElements&&Object.keys(i).forEach(s=>{if(!r[s]&&!0===r.auto){let n=qs(e.el,`.${i[s]}`)[0];n||(n=Qs("div",i[s]),n.className=i[s],e.el.append(n)),r[s]=n,t[s]=n}}),r}(t,t.originalParams.navigation,t.params.navigation,{nextEl:"swiper-button-next",prevEl:"swiper-button-prev"}),!e.nextEl&&!e.prevEl)return;let r=n(e.nextEl),i=n(e.prevEl);Object.assign(t.navigation,{nextEl:r,prevEl:i}),r=tn(r),i=tn(i);const s=(r,i)=>{r&&r.addEventListener("click","next"===i?c:l),!t.enabled&&r&&r.classList.add(...e.lockClass.split(" "))};r.forEach(e=>s(e,"next")),i.forEach(e=>s(e,"prev"))}function u(){let{nextEl:e,prevEl:r}=t.navigation;e=tn(e),r=tn(r);const i=(e,r)=>{e.removeEventListener("click","next"===r?c:l),e.classList.remove(...t.params.navigation.disabledClass.split(" "))};e.forEach(e=>i(e,"next")),r.forEach(e=>i(e,"prev"))}r({navigation:{nextEl:null,prevEl:null,hideOnClick:!1,disabledClass:"swiper-button-disabled",hiddenClass:"swiper-button-hidden",lockClass:"swiper-button-lock",navigationDisabledClass:"swiper-navigation-disabled"}}),t.navigation={nextEl:null,prevEl:null},i("init",()=>{!1===t.params.navigation.enabled?h():(d(),o())}),i("toEdge fromEdge lock unlock",()=>{o()}),i("destroy",()=>{u()}),i("enable disable",()=>{let{nextEl:e,prevEl:r}=t.navigation;e=tn(e),r=tn(r),t.enabled?o():[...e,...r].filter(e=>!!e).forEach(e=>e.classList.add(t.params.navigation.lockClass))}),i("click",(e,r)=>{let{nextEl:i,prevEl:n}=t.navigation;i=tn(i),n=tn(n);const a=r.target;let o=n.includes(a)||i.includes(a);if(t.isElement&&!o){const e=r.path||r.composedPath&&r.composedPath();e&&(o=e.find(e=>i.includes(e)||n.includes(e)))}if(t.params.navigation.hideOnClick&&!o){if(t.pagination&&t.params.pagination&&t.params.pagination.clickable&&(t.pagination.el===a||t.pagination.el.contains(a)))return;let e;i.length?e=i[0].classList.contains(t.params.navigation.hiddenClass):n.length&&(e=n[0].classList.contains(t.params.navigation.hiddenClass)),s(!0===e?"navigationShow":"navigationHide"),[...i,...n].filter(e=>!!e).forEach(e=>e.classList.toggle(t.params.navigation.hiddenClass))}});const h=()=>{t.el.classList.add(...t.params.navigation.navigationDisabledClass.split(" ")),u()};Object.assign(t.navigation,{enable:()=>{t.el.classList.remove(...t.params.navigation.navigationDisabledClass.split(" ")),d(),o()},disable:h,update:o,init:d,destroy:u})}function ia(e){let t,r,{swiper:i,extendParams:s,on:n,emit:a,params:o}=e;i.autoplay={running:!1,paused:!1,timeLeft:0},s({autoplay:{enabled:!1,delay:3e3,waitForTransition:!0,disableOnInteraction:!1,stopOnLastSlide:!1,reverseDirection:!1,pauseOnMouseEnter:!1}});let l,c,d,u,h,f,p,m,g=o&&o.autoplay?o.autoplay.delay:3e3,v=o&&o.autoplay?o.autoplay.delay:3e3,y=(new Date).getTime();function b(e){i&&!i.destroyed&&i.wrapperEl&&e.target===i.wrapperEl&&(i.wrapperEl.removeEventListener("transitionend",b),m||e.detail&&e.detail.bySwiperTouchMove||A())}const E=()=>{if(i.destroyed||!i.autoplay.running)return;i.autoplay.paused?c=!0:c&&(v=l,c=!1);const e=i.autoplay.paused?l:y+v-(new Date).getTime();i.autoplay.timeLeft=e,a("autoplayTimeLeft",e,e/g),r=requestAnimationFrame(()=>{E()})},w=e=>{if(i.destroyed||!i.autoplay.running)return;cancelAnimationFrame(r),E();let s=void 0===e?i.params.autoplay.delay:e;g=i.params.autoplay.delay,v=i.params.autoplay.delay;const n=(()=>{let e;if(e=i.virtual&&i.params.virtual.enabled?i.slides.filter(e=>e.classList.contains("swiper-slide-active"))[0]:i.slides[i.activeIndex],!e)return;return parseInt(e.getAttribute("data-swiper-autoplay"),10)})();!Number.isNaN(n)&&n>0&&void 0===e&&(s=n,g=n,v=n),l=s;const o=i.params.speed,c=()=>{i&&!i.destroyed&&(i.params.autoplay.reverseDirection?!i.isBeginning||i.params.loop||i.params.rewind?(i.slidePrev(o,!0,!0),a("autoplay")):i.params.autoplay.stopOnLastSlide||(i.slideTo(i.slides.length-1,o,!0,!0),a("autoplay")):!i.isEnd||i.params.loop||i.params.rewind?(i.slideNext(o,!0,!0),a("autoplay")):i.params.autoplay.stopOnLastSlide||(i.slideTo(0,o,!0,!0),a("autoplay")),i.params.cssMode&&(y=(new Date).getTime(),requestAnimationFrame(()=>{w()})))};return s>0?(clearTimeout(t),t=setTimeout(()=>{c()},s)):requestAnimationFrame(()=>{c()}),s},S=()=>{y=(new Date).getTime(),i.autoplay.running=!0,w(),a("autoplayStart")},T=()=>{i.autoplay.running=!1,clearTimeout(t),cancelAnimationFrame(r),a("autoplayStop")},x=(e,r)=>{if(i.destroyed||!i.autoplay.running)return;clearTimeout(t),e||(p=!0);const s=()=>{a("autoplayPause"),i.params.autoplay.waitForTransition?i.wrapperEl.addEventListener("transitionend",b):A()};if(i.autoplay.paused=!0,r)return f&&(l=i.params.autoplay.delay),f=!1,void s();const n=l||i.params.autoplay.delay;l=n-((new Date).getTime()-y),i.isEnd&&l<0&&!i.params.loop||(l<0&&(l=0),s())},A=()=>{i.isEnd&&l<0&&!i.params.loop||i.destroyed||!i.autoplay.running||(y=(new Date).getTime(),p?(p=!1,w(l)):w(),i.autoplay.paused=!1,a("autoplayResume"))},k=()=>{if(i.destroyed||!i.autoplay.running)return;const e=Fs();"hidden"===e.visibilityState&&(p=!0,x(!0)),"visible"===e.visibilityState&&A()},L=e=>{"mouse"===e.pointerType&&(p=!0,m=!0,i.animating||i.autoplay.paused||x(!0))},I=e=>{"mouse"===e.pointerType&&(m=!1,i.autoplay.paused&&A())};n("init",()=>{i.params.autoplay.enabled&&(i.params.autoplay.pauseOnMouseEnter&&(i.el.addEventListener("pointerenter",L),i.el.addEventListener("pointerleave",I)),Fs().addEventListener("visibilitychange",k),S())}),n("destroy",()=>{i.el&&"string"!=typeof i.el&&(i.el.removeEventListener("pointerenter",L),i.el.removeEventListener("pointerleave",I)),Fs().removeEventListener("visibilitychange",k),i.autoplay.running&&T()}),n("_freeModeStaticRelease",()=>{(u||p)&&A()}),n("_freeModeNoMomentumRelease",()=>{i.params.autoplay.disableOnInteraction?T():x(!0,!0)}),n("beforeTransitionStart",(e,t,r)=>{!i.destroyed&&i.autoplay.running&&(r||!i.params.autoplay.disableOnInteraction?x(!0,!0):T())}),n("sliderFirstMove",()=>{!i.destroyed&&i.autoplay.running&&(i.params.autoplay.disableOnInteraction?T():(d=!0,u=!1,p=!1,h=setTimeout(()=>{p=!0,u=!0,x(!0)},200)))}),n("touchEnd",()=>{if(!i.destroyed&&i.autoplay.running&&d){if(clearTimeout(h),clearTimeout(t),i.params.autoplay.disableOnInteraction)return u=!1,void(d=!1);u&&i.params.cssMode&&A(),u=!1,d=!1}}),n("slideChange",()=>{!i.destroyed&&i.autoplay.running&&(f=!0)}),Object.assign(i.autoplay,{start:S,stop:T,pause:x,resume:A})}function sa(e){let t,r,i,s,{swiper:n,extendParams:a,on:o}=e;a({grid:{rows:1,fill:"column"}});const l=()=>{let e=n.params.spaceBetween;return"string"==typeof e&&e.indexOf("%")>=0?e=parseFloat(e.replace("%",""))/100*n.size:"string"==typeof e&&(e=parseFloat(e)),e};o("init",()=>{s=n.params.grid&&n.params.grid.rows>1}),o("update",()=>{const{params:e,el:t}=n,r=e.grid&&e.grid.rows>1;s&&!r?(t.classList.remove(`${e.containerModifierClass}grid`,`${e.containerModifierClass}grid-column`),i=1,n.emitContainerClasses()):!s&&r&&(t.classList.add(`${e.containerModifierClass}grid`),"column"===e.grid.fill&&t.classList.add(`${e.containerModifierClass}grid-column`),n.emitContainerClasses()),s=r}),n.grid={initSlides:e=>{const{slidesPerView:s}=n.params,{rows:a,fill:o}=n.params.grid,l=n.virtual&&n.params.virtual.enabled?n.virtual.slides.length:e.length;i=Math.floor(l/a),t=Math.floor(l/a)===l/a?l:Math.ceil(l/a)*a,"auto"!==s&&"row"===o&&(t=Math.max(t,s*a)),r=t/a},unsetSlides:()=>{n.slides&&n.slides.forEach(e=>{e.swiperSlideGridSet&&(e.style.height="",e.style[n.getDirectionLabel("margin-top")]="")})},updateSlide:(e,s,a)=>{const{slidesPerGroup:o}=n.params,c=l(),{rows:d,fill:u}=n.params.grid,h=n.virtual&&n.params.virtual.enabled?n.virtual.slides.length:a.length;let f,p,m;if("row"===u&&o>1){const r=Math.floor(e/(o*d)),i=e-d*o*r,n=0===r?o:Math.min(Math.ceil((h-r*d*o)/d),o);m=Math.floor(i/n),p=i-m*n+r*o,f=p+m*t/d,s.style.order=f}else"column"===u?(p=Math.floor(e/d),m=e-p*d,(p>i||p===i&&m===d-1)&&(m+=1,m>=d&&(m=0,p+=1))):(m=Math.floor(e/r),p=e-m*r);s.row=m,s.column=p,s.style.height=`calc((100% - ${(d-1)*c}px) / ${d})`,s.style[n.getDirectionLabel("margin-top")]=0!==m?c&&`${c}px`:"",s.swiperSlideGridSet=!0},updateWrapperSize:(e,r)=>{const{centeredSlides:i,roundLengths:s}=n.params,a=l(),{rows:o}=n.params.grid;if(n.virtualSize=(e+a)*t,n.virtualSize=Math.ceil(n.virtualSize/o)-a,n.params.cssMode||(n.wrapperEl.style[n.getDirectionLabel("width")]=`${n.virtualSize+a}px`),i){const e=[];for(let t=0;t<r.length;t+=1){let i=r[t];s&&(i=Math.floor(i)),r[t]<n.virtualSize+r[0]&&e.push(i)}r.splice(0,r.length),r.push(...e)}}}}function na(e){const t=this,{params:r,slidesEl:i}=t;r.loop&&t.loopDestroy();const s=e=>{if("string"==typeof e){const t=document.createElement("div");t.innerHTML=e,i.append(t.children[0]),t.innerHTML=""}else i.append(e)};if("object"==typeof e&&"length"in e)for(let t=0;t<e.length;t+=1)e[t]&&s(e[t]);else s(e);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update()}function aa(e){const t=this,{params:r,activeIndex:i,slidesEl:s}=t;r.loop&&t.loopDestroy();let n=i+1;const a=e=>{if("string"==typeof e){const t=document.createElement("div");t.innerHTML=e,s.prepend(t.children[0]),t.innerHTML=""}else s.prepend(e)};if("object"==typeof e&&"length"in e){for(let t=0;t<e.length;t+=1)e[t]&&a(e[t]);n=i+e.length}else a(e);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update(),t.slideTo(n,0,!1)}function oa(e,t){const r=this,{params:i,activeIndex:s,slidesEl:n}=r;let a=s;i.loop&&(a-=r.loopedSlides,r.loopDestroy(),r.recalcSlides());const o=r.slides.length;if(e<=0)return void r.prependSlide(t);if(e>=o)return void r.appendSlide(t);let l=a>e?a+1:a;const c=[];for(let t=o-1;t>=e;t-=1){const e=r.slides[t];e.remove(),c.unshift(e)}if("object"==typeof t&&"length"in t){for(let e=0;e<t.length;e+=1)t[e]&&n.append(t[e]);l=a>e?a+t.length:a}else n.append(t);for(let e=0;e<c.length;e+=1)n.append(c[e]);r.recalcSlides(),i.loop&&r.loopCreate(),i.observer&&!r.isElement||r.update(),i.loop?r.slideTo(l+r.loopedSlides,0,!1):r.slideTo(l,0,!1)}function la(e){const t=this,{params:r,activeIndex:i}=t;let s=i;r.loop&&(s-=t.loopedSlides,t.loopDestroy());let n,a=s;if("object"==typeof e&&"length"in e){for(let r=0;r<e.length;r+=1)n=e[r],t.slides[n]&&t.slides[n].remove(),n<a&&(a-=1);a=Math.max(a,0)}else n=e,t.slides[n]&&t.slides[n].remove(),n<a&&(a-=1),a=Math.max(a,0);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update(),r.loop?t.slideTo(a+t.loopedSlides,0,!1):t.slideTo(a,0,!1)}function ca(){const e=this,t=[];for(let r=0;r<e.slides.length;r+=1)t.push(r);e.removeSlide(t)}function da(e){let{swiper:t}=e;Object.assign(t,{appendSlide:na.bind(t),prependSlide:aa.bind(t),addSlide:oa.bind(t),removeSlide:la.bind(t),removeAllSlides:ca.bind(t)})}function ua(e,t){const r=Ks(t);return r!==t&&(r.style.backfaceVisibility="hidden",r.style["-webkit-backface-visibility"]="hidden"),r}function ha(e){let{swiper:t,duration:r,transformElements:i,allSlides:s}=e;const{activeIndex:n}=t;if(t.params.virtualTranslate&&0!==r){let e,r=!1;e=s?i:i.filter(e=>{const r=e.classList.contains("swiper-slide-transform")?(e=>{if(!e.parentElement)return t.slides.filter(t=>t.shadowRoot&&t.shadowRoot===e.parentNode)[0];return e.parentElement})(e):e;return t.getSlideIndex(r)===n}),e.forEach(e=>{!function(e,t){t&&e.addEventListener("transitionend",function r(i){i.target===e&&(t.call(e,i),e.removeEventListener("transitionend",r))})}(e,()=>{if(r)return;if(!t||t.destroyed)return;r=!0,t.animating=!1;const e=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0});t.wrapperEl.dispatchEvent(e)})})}}function fa(e,t,r){const i=`swiper-slide-shadow swiper-slide-shadow-${e}`,s=Ks(t);let n=s.querySelector(`.${i.split(" ").join(".")}`);return n||(n=Qs("div",i.split(" ")),s.append(n)),n}function pa(e){let{swiper:t,extendParams:r,on:i}=e;r({cardsEffect:{slideShadows:!0,rotate:!0,perSlideRotate:2,perSlideOffset:8}});!function(e){const{effect:t,swiper:r,on:i,setTranslate:s,setTransition:n,overwriteParams:a,perspective:o,recreateShadows:l,getEffectParams:c}=e;let d;i("beforeInit",()=>{if(r.params.effect!==t)return;r.classNames.push(`${r.params.containerModifierClass}${t}`),o&&o()&&r.classNames.push(`${r.params.containerModifierClass}3d`);const e=a?a():{};Object.assign(r.params,e),Object.assign(r.originalParams,e)}),i("setTranslate",()=>{r.params.effect===t&&s()}),i("setTransition",(e,i)=>{r.params.effect===t&&n(i)}),i("transitionEnd",()=>{if(r.params.effect===t&&l){if(!c||!c().slideShadows)return;r.slides.forEach(e=>{e.querySelectorAll(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").forEach(e=>e.remove())}),l()}}),i("virtualUpdate",()=>{r.params.effect===t&&(r.slides.length||(d=!0),requestAnimationFrame(()=>{d&&r.slides&&r.slides.length&&(s(),d=!1)}))})}({effect:"cards",swiper:t,on:i,setTranslate:()=>{const{slides:e,activeIndex:r,rtlTranslate:i}=t,s=t.params.cardsEffect,{startTranslate:n,isTouched:a}=t.touchEventsData,o=i?-t.translate:t.translate;for(let l=0;l<e.length;l+=1){const c=e[l],d=c.progress,u=Math.min(Math.max(d,-4),4);let h=c.swiperSlideOffset;t.params.centeredSlides&&!t.params.cssMode&&(t.wrapperEl.style.transform=`translateX(${t.minTranslate()}px)`),t.params.centeredSlides&&t.params.cssMode&&(h-=e[0].swiperSlideOffset);let f=t.params.cssMode?-h-t.translate:-h,p=0;const m=-100*Math.abs(u);let g=1,v=-s.perSlideRotate*u,y=s.perSlideOffset-.75*Math.abs(u);const b=t.virtual&&t.params.virtual.enabled?t.virtual.from+l:l,E=(b===r||b===r-1)&&u>0&&u<1&&(a||t.params.cssMode)&&o<n,w=(b===r||b===r+1)&&u<0&&u>-1&&(a||t.params.cssMode)&&o>n;if(E||w){const e=(1-Math.abs((Math.abs(u)-.5)/.5))**.5;v+=-28*u*e,g+=-.5*e,y+=96*e,p=-25*e*Math.abs(u)+"%"}if(f=u<0?`calc(${f}px ${i?"-":"+"} (${y*Math.abs(u)}%))`:u>0?`calc(${f}px ${i?"-":"+"} (-${y*Math.abs(u)}%))`:`${f}px`,!t.isHorizontal()){const e=p;p=f,f=e}const S=u<0?""+(1+(1-g)*u):""+(1-(1-g)*u),T=`\n translate3d(${f}, ${p}, ${m}px)\n rotateZ(${s.rotate?i?-v:v:0}deg)\n scale(${S})\n `;if(s.slideShadows){let e=c.querySelector(".swiper-slide-shadow");e||(e=fa("cards",c)),e&&(e.style.opacity=Math.min(Math.max((Math.abs(u)-.5)/.5,0),1))}c.style.zIndex=-Math.abs(Math.round(d))+e.length;ua(0,c).style.transform=T}},setTransition:e=>{const r=t.slides.map(e=>Ks(e));r.forEach(t=>{t.style.transitionDuration=`${e}ms`,t.querySelectorAll(".swiper-slide-shadow").forEach(t=>{t.style.transitionDuration=`${e}ms`})}),ha({swiper:t,duration:e,transformElements:r})},perspective:()=>!0,overwriteParams:()=>({watchSlidesProgress:!0,virtualTranslate:!t.params.cssMode})})}ea.displayName="SwiperSlide";const ma=({product:e})=>{const[r,i]=a(!1);return t.createElement("a",{href:e.linkPath,target:"_blank",className:"apphref"},t.createElement("div",{className:"w-full h-full min-w-0 flex gap-2 flex-col"},t.createElement("div",{className:"mb-2 flex aspect-square w-full max-h-fit items-center justify-center overflow-hidden rounded border"},e.thumbPath&&!r?t.createElement(Hr,{product:e,onError:()=>i(!0)}):t.createElement(jr,null)),t.createElement("div",{className:"justify-center flex flex-col min-w-0"},e.brand&&t.createElement("p",{className:"max-w-52 break-keep line-clamp-1 text-xs text-gray-500"},e.brand.brandName),t.createElement("p",{className:"break-keep line-clamp-2"},e.productName),t.createElement("div",{className:"break-keep"},t.createElement("span",{className:"font-semibold text-red-500"},e.discount,"%"," "),t.createElement("span",{className:"font-semibold"},Tt(e.sellingPrice,e.currency))))))},ga=({products:e})=>{const i=r(null);return e&&t.createElement("div",{className:"relative flex h-full w-full max-w-[830px] items-center"},e.length>3&&t.createElement("button",{"aria-label":"prev",onClick:()=>{var e;null===(e=i.current)||void 0===e||e.slidePrev()},className:"absolute left-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(Pr,{size:32,strokeWidth:1})),t.createElement("div",{className:"w-full px-10"},t.createElement(Jn,{modules:[ra],onSwiper:e=>{i.current=e},slidesPerView:3,navigation:{prevEl:".slide__prev",nextEl:".slide__next"},spaceBetween:0},e.map(e=>t.createElement(ea,{key:e.productId},t.createElement("div",{className:"h-full px-3 md:px-4 lg:px-5"},t.createElement(ma,{product:e})))))),e.length>3&&t.createElement("button",{"aria-label":"next",onClick:()=>{var e;null===(e=i.current)||void 0===e||e.slideNext()},className:"absolute right-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(Cr,{size:32,strokeWidth:1})))},va=e=>{const{player:r,shortform:i}=e;return t.createElement("div",{className:"flex h-full w-full gap-5 bg-white items-center"},t.createElement("div",{className:"h-full shrink-0"},r),t.createElement("div",{className:"flex h-full w-full min-w-44 max-w-[800px] items-center overflow-hidden text-sm"},t.createElement(ga,{products:i.productsInfo})))},ya=({products:e})=>{const s=r(null),n=r(null),[o,l]=a(4);return i(()=>{const e=n.current;if(!e)return;const t=()=>{const t=e.clientHeight;if(!t)return;const r=Math.max(1,Math.floor((t+12)/112));l(r)};t();const r=new ResizeObserver(()=>t());return r.observe(e),window.addEventListener("resize",t),()=>{r.disconnect(),window.removeEventListener("resize",t)}},[]),t.createElement("div",{className:"flex h-[80%] min-h-0 w-full flex-col items-center",style:{height:500}},e.length>o&&t.createElement(Dr,{size:50,strokeWidth:1,className:"slide__prev shrink-0 cursor-pointer text-zinc-500"}),t.createElement("div",{ref:n,className:"min-h-0 w-full max-w-full flex-1"},t.createElement(Jn,{modules:[ta,ra],mousewheel:!0,onSwiper:e=>{s.current=e},spaceBetween:12,className:"h-full min-h-0 w-full max-w-full",slidesPerView:o,direction:"vertical",navigation:{prevEl:".slide__prev",nextEl:".slide__next"}},e.map(e=>t.createElement(ea,{key:e.productId},t.createElement("div",{className:"h-full items-center flex"},t.createElement(Vr,{product:e})))))),e.length>o&&t.createElement(Rr,{size:50,strokeWidth:1,className:"slide__next shrink-0 cursor-pointer text-zinc-500"}))},ba=e=>{const{playerSettings:r,shortform:{productsInfo:i},player:s}=e;return t.createElement("div",{className:"flex h-full w-full gap-5"},t.createElement("div",{className:" h-full "},s),t.createElement("div",{className:"max-w-[800px] overflow-hidden"},t.createElement(ya,{products:i})))},Ea=({products:e})=>{const i=r(null),s=e.length>6;return t.createElement("div",{className:"relative flex h-full w-full max-w-[830px] items-center text-sm"},s&&t.createElement("button",{"aria-label":"prev",onClick:()=>{var e;null===(e=i.current)||void 0===e||e.slidePrev()},className:"absolute left-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(Pr,{size:50,strokeWidth:1})),t.createElement("div",{className:"w-full px-14"},t.createElement(Jn,{onSwiper:e=>{i.current=e},slidesPerView:3,spaceBetween:20,modules:[sa],grid:{rows:2,fill:"row"}},e.map(e=>t.createElement(ea,{key:e.productId},t.createElement(ma,{product:e}))))),s&&t.createElement("button",{"aria-label":"next",onClick:()=>{var e;null===(e=i.current)||void 0===e||e.slideNext()},className:"absolute right-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(Cr,{size:50,strokeWidth:1})))},wa=e=>{const{player:r,shortform:{productsInfo:i}}=e;return t.createElement("div",{className:"flex gap-4 w-full h-full min-w-[768px] items-center"},t.createElement("div",{className:"flex-1 w-full h-full flex justify-center"},r),t.createElement("div",{className:"flex-[2] w-full h-full overflow-hidden"},t.createElement(Ea,{products:i})))},Sa="cursor-pointer text-zinc-500",Ta=e=>{const{collection:i,shortform:s,setShortform:n}=e,a=r(null);return t.createElement(t.Fragment,null,i.contents.length>1&&t.createElement("div",{className:"self-center flex gap-4 flex-col"},t.createElement(Dr,{size:44,strokeWidth:1,className:Sa,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(Rr,{size:44,strokeWidth:1,className:Sa,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slideNext()}})),t.createElement("div",{className:"h-full aspect-[9/16] relative"},t.createElement(Jn,{modules:[ta,da],mousewheel:!0,loop:i.contents.length>1,direction:"vertical",touchEventsTarget:"container",preventClicksPropagation:!1,preventClicks:!1,allowTouchMove:!1,slidesPerView:1.05,ref:a,className:"h-full z-10",onSlideChangeTransitionEnd:e=>{(e=>{const t=i.contents[e];t&&n(Object.assign({},t))})(e.realIndex)}},i.contents.map(e=>t.createElement(ea,{key:e.shortsId,className:"rounded-xl overflow-hidden aspect-[9/16]"},t.createElement("div",{className:"h-[95%] mb-2"},s.shortsId===e.shortsId&&t.createElement("div",{className:"h-[95%] overflow-hidden rounded-xl absolute z-[999] w-full"},t.createElement(L,{file:xt(s.media.objectId)})),t.createElement("img",{src:Ct(e.thumbPath),alt:e.title,className:"rounded-xl w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")})))))))};var xa;!function(e){e.latest="",e.views="pageView",e.likes="like"}(xa||(xa={}));let Aa=0;const ka=e=>x(void 0,void 0,void 0,function*(){const{PLAYER_BACK_BASE_URL:t}=gt(),{contentId:r,uuid:i,type:s,userId:n,isFirstPlay:a}=e;try{if(3===Aa)return;const e=`${t}/statistics/play`,o=Object.assign({contentId:r,uuid:i,type:s,date:kt(),userId:+n,playtime:0,isLive:!1,isFirstPlay:a},"shorts"===s&&{isFinished:!1,playedOver5Sec:!1});yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})}catch(e){console.error(`Error in statisticsApi.join - contentId: ${r}`),Dt(e),Aa++}}),La=e=>{const{PLAYER_BACK_BASE_URL:t}=gt(),{contentId:r,uuid:i,type:s,isFinished:n,playtime:a,userId:o}=e,l=Object.assign({contentId:r,uuid:i,playtime:a,type:s,date:kt(),userId:+o,isLive:!1},"shorts"===s&&{isFinished:n,playedOver5Sec:Number(a)>5});fetch(`${t}/statistics/play`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l),keepalive:!0})},Ia=e=>x(void 0,void 0,void 0,function*(){const{PLAYER_BACK_BASE_URL:t}=gt(),{contentProductId:r}=e;try{yield fetch(`${t}/statistics/products/${r}/clicks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({date:kt()},e)),keepalive:!0})}catch(e){console.error(`Error in statisticsApi.productClick - contentProductId: ${r}`),Dt(e)}}),Ra=e=>x(void 0,void 0,void 0,function*(){const{STATISTICS_BASE_URL:t}=gt();try{return(yield(yield fetch(`${t}/${e}/likes`)).json()).result||0}catch(t){return console.error(`Error in statisticsApi.getLike - contentId: ${e}`),Dt(t),0}}),Pa=e=>x(void 0,void 0,void 0,function*(){const{PLAYER_BACK_BASE_URL:t}=gt();try{yield fetch(`${t}/statistics/like`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contentId:e,isLive:!1,isFirst:!1})})}catch(t){console.error(`Error in statisticsApi.getLike - contentId: ${e}`),Dt(t)}}),Ca=e=>x(void 0,[e],void 0,function*({collectionId:e,nextKey:t,size:r=5}){const{PLAYER_BACK_BASE_URL:i}=gt();try{const s=new URLSearchParams;-1!==r&&s.set("size",String(r)),t&&s.set("nextKey",t);const n=yield fetch(`${i}/commerce/collection/${e}?${s.toString()}`);return n.ok?yield n.json():null}catch(e){return Dt(e),null}}),Da=(e,...t)=>x(void 0,[e,...t],void 0,function*(e,t=!1){const{API_BASE_URL:r,PLAYER_BACK_BASE_URL:i}=gt();if(t)try{const t=(yield(yield fetch(`${r}/shorts/player/${e}`)).json()).result;if(!t.media)return null;t.file=`${r}/direct/${t.media.objectId}`;const{player:{viewPlayer:{width:i,height:s}}}=t;return Object.assign(Object.assign(Object.assign(Object.assign({layout:t.player.layout},t.player.shoppingPlayer),{aspectRatio:_t(i,s)}),t),{uuid:Lt()})}catch(e){return Dt(e),null}try{const t=yield fetch(`${i}/commerce/short-form/${e}`),r=yield t.json();return r.shortsId?r:null}catch(e){return Dt(e),null}}),_a=(e,t,r,i,s)=>x(void 0,void 0,void 0,function*(){const{API_BASE_URL:n}=gt();try{const a=yield fetch(`${n}/live/${e}/list?size=${r||6}&status=${t}&includeMainLive=${i}${s&&xa[s]?`&sortBy=${xa[s]}`:""}`);if(!a.ok)return console.error("Error in getLiveWidgetContents "),null;const o=(yield a.json()).result;if(o.content){const{mainLive:e,content:t}=o;return[...e?[e]:[],...t]}return o}catch(e){return console.error("Error in getLiveWidgetContents: ",e),null}}),Oa=e=>{let t;const r=new Set,i=(e,i)=>{const s="function"==typeof e?e(t):e;if(!Object.is(s,t)){const e=t;t=(null!=i?i:"object"!=typeof s||null===s)?s:Object.assign({},t,s),r.forEach(r=>r(t,e))}},s=()=>t,n={setState:i,getState:s,getInitialState:()=>a,subscribe:e=>(r.add(e),()=>r.delete(e))},a=t=e(i,s,n);return n},Ma=e=>e?Oa(e):Oa,Na=e=>e;function Fa(e,r=Na){const i=t.useSyncExternalStore(e.subscribe,t.useCallback(()=>r(e.getState()),[e,r]),t.useCallback(()=>r(e.getInitialState()),[e,r]));return t.useDebugValue(i),i}const $a=e=>{const t=Ma(e),r=e=>Fa(t,e);return Object.assign(r,t),r},Ba=e=>e?$a(e):$a,Ua=Ba(e=>({priceText:"",isPreview:!1,memberOnly:!1,isMemberLoggedIn:!1,setPriceText:t=>e({priceText:t}),setIsPreview:t=>e({isPreview:t}),setMemberOnly:t=>e({memberOnly:t}),setIsMemberLoggedIn:t=>e({isMemberLoggedIn:t})})),za=()=>t.createElement("div",{className:"inline-block absolute pointer-events-none top-0 z-10 animate-float w-[24px] h-[24px]"},t.createElement(Mr,{className:"fill-red-500 text-transparent w-[24px] h-[24px]"})),Ga=({shortsId:e})=>{const{isPreview:r}=Ua(),[s,n]=a(r?123:0),[o,l]=a([]);i(()=>{r||x(void 0,void 0,void 0,function*(){try{const t=yield Ra(e);n(t)}catch(e){return console.error(`Error in statistics getLikeInLive: ${e.toString()}`),0}})},[r,e]);return t.createElement("div",{className:"flex justify-center flex-col items-center relative"},t.createElement("button",{onClick:()=>x(void 0,void 0,void 0,function*(){(()=>{const e=Date.now();l(t=>[...t,e]),setTimeout(()=>{l(t=>t.filter(t=>t!==e))},2e3)})(),n(e=>e+1),r||(yield x(void 0,void 0,void 0,function*(){yield Pa(e)}))}),className:"z-[5] cursor-pointer"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:"https://mbus-asset.s3.ap-northeast-2.amazonaws.com/mcom-player/heart.png",width:24,height:24,className:"block h-6 w-6 object-contain",alt:"like"}))),o.map(e=>t.createElement(za,{key:e})),t.createElement("span",{className:"break-keep text-[10px]"},At(s)))};var ja,Ha,Va={},Wa={exports:{}},Ya=Wa.exports;function Ka(){return ja||(ja=1,e=Wa,t=Wa.exports,function(r,i){var s="function",n="undefined",a="object",o="string",l="major",c="model",d="name",u="type",h="vendor",f="version",p="architecture",m="console",g="mobile",v="tablet",y="smarttv",b="wearable",E="embedded",w="Amazon",S="Apple",T="ASUS",x="BlackBerry",A="Browser",k="Chrome",L="Firefox",I="Google",R="Huawei",P="LG",C="Microsoft",D="Motorola",_="Opera",O="Samsung",M="Sharp",N="Sony",F="Xiaomi",$="Zebra",B="Facebook",U="Chromium OS",z="Mac OS",G=" Browser",j=function(e){for(var t={},r=0;r<e.length;r++)t[e[r].toUpperCase()]=e[r];return t},H=function(e,t){return typeof e===o&&-1!==V(t).indexOf(V(e))},V=function(e){return e.toLowerCase()},W=function(e,t){if(typeof e===o)return e=e.replace(/^\s\s*/,""),typeof t===n?e:e.substring(0,500)},Y=function(e,t){for(var r,n,o,l,c,d,u=0;u<t.length&&!c;){var h=t[u],f=t[u+1];for(r=n=0;r<h.length&&!c&&h[r];)if(c=h[r++].exec(e))for(o=0;o<f.length;o++)d=c[++n],typeof(l=f[o])===a&&l.length>0?2===l.length?typeof l[1]==s?this[l[0]]=l[1].call(this,d):this[l[0]]=l[1]:3===l.length?typeof l[1]!==s||l[1].exec&&l[1].test?this[l[0]]=d?d.replace(l[1],l[2]):i:this[l[0]]=d?l[1].call(this,d,l[2]):i:4===l.length&&(this[l[0]]=d?l[3].call(this,d.replace(l[1],l[2])):i):this[l]=d||i;u+=2}},K=function(e,t){for(var r in t)if(typeof t[r]===a&&t[r].length>0){for(var s=0;s<t[r].length;s++)if(H(t[r][s],e))return"?"===r?i:r}else if(H(t[r],e))return"?"===r?i:r;return t.hasOwnProperty("*")?t["*"]:e},q={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},X={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[f,[d,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[f,[d,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[d,f],[/opios[\/ ]+([\w\.]+)/i],[f,[d,_+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[f,[d,_+" GX"]],[/\bopr\/([\w\.]+)/i],[f,[d,_]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[f,[d,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[f,[d,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[d,f],[/quark(?:pc)?\/([-\w\.]+)/i],[f,[d,"Quark"]],[/\bddg\/([\w\.]+)/i],[f,[d,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[f,[d,"UC"+A]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[f,[d,"WeChat"]],[/konqueror\/([\w\.]+)/i],[f,[d,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[f,[d,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[f,[d,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[f,[d,"Smart Lenovo "+A]],[/(avast|avg)\/([\w\.]+)/i],[[d,/(.+)/,"$1 Secure "+A],f],[/\bfocus\/([\w\.]+)/i],[f,[d,L+" Focus"]],[/\bopt\/([\w\.]+)/i],[f,[d,_+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[f,[d,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[f,[d,"Dolphin"]],[/coast\/([\w\.]+)/i],[f,[d,_+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[f,[d,"MIUI"+G]],[/fxios\/([\w\.-]+)/i],[f,[d,L]],[/\bqihoobrowser\/?([\w\.]*)/i],[f,[d,"360"]],[/\b(qq)\/([\w\.]+)/i],[[d,/(.+)/,"$1Browser"],f],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[d,/(.+)/,"$1"+G],f],[/samsungbrowser\/([\w\.]+)/i],[f,[d,O+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[f,[d,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[d,"Sogou Mobile"],f],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[d,f],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[d],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[f,d],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[d,B],f],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[d,f],[/\bgsa\/([\w\.]+) .*safari\//i],[f,[d,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[f,[d,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[f,[d,k+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[d,k+" WebView"],f],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[f,[d,"Android "+A]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[d,f],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[f,[d,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[f,d],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[d,[f,K,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[d,f],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[d,"Netscape"],f],[/(wolvic|librewolf)\/([\w\.]+)/i],[d,f],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[f,[d,L+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i],[d,[f,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[d,[f,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[p,"amd64"]],[/(ia32(?=;))/i],[[p,V]],[/((?:i[346]|x)86)[;\)]/i],[[p,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[p,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[p,"armhf"]],[/windows (ce|mobile); ppc;/i],[[p,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[p,/ower/,"",V]],[/(sun4\w)[;\)]/i],[[p,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[p,V]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[c,[h,O],[u,v]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[c,[h,O],[u,g]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[c,[h,S],[u,g]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[c,[h,S],[u,v]],[/(macintosh);/i],[c,[h,S]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[c,[h,M],[u,g]],[/(?:honor)([-\w ]+)[;\)]/i],[c,[h,"Honor"],[u,g]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[c,[h,R],[u,v]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[c,[h,R],[u,g]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i],[[c,/_/g," "],[h,F],[u,g]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[c,/_/g," "],[h,F],[u,v]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[c,[h,"OPPO"],[u,g]],[/\b(opd2\d{3}a?) bui/i],[c,[h,"OPPO"],[u,v]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[c,[h,"Vivo"],[u,g]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[c,[h,"Realme"],[u,g]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[c,[h,D],[u,g]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[c,[h,D],[u,v]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[c,[h,P],[u,v]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[c,[h,P],[u,g]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[c,[h,"Lenovo"],[u,v]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[c,/_/g," "],[h,"Nokia"],[u,g]],[/(pixel c)\b/i],[c,[h,I],[u,v]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[c,[h,I],[u,g]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[c,[h,N],[u,g]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[c,"Xperia Tablet"],[h,N],[u,v]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[c,[h,"OnePlus"],[u,g]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[c,[h,w],[u,v]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[c,/(.+)/g,"Fire Phone $1"],[h,w],[u,g]],[/(playbook);[-\w\),; ]+(rim)/i],[c,h,[u,v]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[c,[h,x],[u,g]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[c,[h,T],[u,v]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[c,[h,T],[u,g]],[/(nexus 9)/i],[c,[h,"HTC"],[u,v]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[c,/_/g," "],[u,g]],[/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])\w*(\)| bui)/i],[c,[h,"TCL"],[u,v]],[/(itel) ((\w+))/i],[[h,V],c,[u,K,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[c,[h,"Acer"],[u,v]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[c,[h,"Meizu"],[u,g]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[c,[h,"Ulefone"],[u,g]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[c,[h,"Energizer"],[u,g]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[c,[h,"Cat"],[u,g]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[c,[h,"Smartfren"],[u,g]],[/droid.+; (a(?:015|06[35]|142p?))/i],[c,[h,"Nothing"],[u,g]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (imo) ((?!tab)[\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[h,c,[u,g]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[h,c,[u,v]],[/(surface duo)/i],[c,[h,C],[u,v]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[c,[h,"Fairphone"],[u,g]],[/(u304aa)/i],[c,[h,"AT&T"],[u,g]],[/\bsie-(\w*)/i],[c,[h,"Siemens"],[u,g]],[/\b(rct\w+) b/i],[c,[h,"RCA"],[u,v]],[/\b(venue[\d ]{2,7}) b/i],[c,[h,"Dell"],[u,v]],[/\b(q(?:mv|ta)\w+) b/i],[c,[h,"Verizon"],[u,v]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[c,[h,"Barnes & Noble"],[u,v]],[/\b(tm\d{3}\w+) b/i],[c,[h,"NuVision"],[u,v]],[/\b(k88) b/i],[c,[h,"ZTE"],[u,v]],[/\b(nx\d{3}j) b/i],[c,[h,"ZTE"],[u,g]],[/\b(gen\d{3}) b.+49h/i],[c,[h,"Swiss"],[u,g]],[/\b(zur\d{3}) b/i],[c,[h,"Swiss"],[u,v]],[/\b((zeki)?tb.*\b) b/i],[c,[h,"Zeki"],[u,v]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,"Dragon Touch"],c,[u,v]],[/\b(ns-?\w{0,9}) b/i],[c,[h,"Insignia"],[u,v]],[/\b((nxa|next)-?\w{0,9}) b/i],[c,[h,"NextBook"],[u,v]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,"Voice"],c,[u,g]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,"LvTel"],c,[u,g]],[/\b(ph-1) /i],[c,[h,"Essential"],[u,g]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[c,[h,"Envizen"],[u,v]],[/\b(trio[-\w\. ]+) b/i],[c,[h,"MachSpeed"],[u,v]],[/\btu_(1491) b/i],[c,[h,"Rotor"],[u,v]],[/(shield[\w ]+) b/i],[c,[h,"Nvidia"],[u,v]],[/(sprint) (\w+)/i],[h,c,[u,g]],[/(kin\.[onetw]{3})/i],[[c,/\./g," "],[h,C],[u,g]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[c,[h,$],[u,v]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[c,[h,$],[u,g]],[/smart-tv.+(samsung)/i],[h,[u,y]],[/hbbtv.+maple;(\d+)/i],[[c,/^/,"SmartTV"],[h,O],[u,y]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,P],[u,y]],[/(apple) ?tv/i],[h,[c,S+" TV"],[u,y]],[/crkey/i],[[c,k+"cast"],[h,I],[u,y]],[/droid.+aft(\w+)( bui|\))/i],[c,[h,w],[u,y]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[c,[h,M],[u,y]],[/(bravia[\w ]+)( bui|\))/i],[c,[h,N],[u,y]],[/(mitv-\w{5}) bui/i],[c,[h,F],[u,y]],[/Hbbtv.*(technisat) (.*);/i],[h,c,[u,y]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,W],[c,W],[u,y]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[u,y]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,c,[u,m]],[/droid.+; (shield) bui/i],[c,[h,"Nvidia"],[u,m]],[/(playstation [345portablevi]+)/i],[c,[h,N],[u,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[c,[h,C],[u,m]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[c,[h,O],[u,b]],[/((pebble))app/i],[h,c,[u,b]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[c,[h,S],[u,b]],[/droid.+; (glass) \d/i],[c,[h,I],[u,b]],[/droid.+; (wt63?0{2,3})\)/i],[c,[h,$],[u,b]],[/droid.+; (glass) \d/i],[c,[h,I],[u,b]],[/(pico) (4|neo3(?: link|pro)?)/i],[h,c,[u,b]],[/; (quest( \d| pro)?)/i],[c,[h,B],[u,b]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[u,E]],[/(aeobc)\b/i],[c,[h,w],[u,E]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[c,[u,g]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[c,[u,v]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[u,v]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[u,g]],[/(android[-\w\. ]{0,9});.+buil/i],[c,[h,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[f,[d,"EdgeHTML"]],[/(arkweb)\/([\w\.]+)/i],[d,f],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[f,[d,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[d,f],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[f,d]],os:[[/microsoft (windows) (vista|xp)/i],[d,f],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[d,[f,K,q]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[f,K,q],[d,"Windows"]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[f,/_/g,"."],[d,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[d,z],[f,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[f,d],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[d,f],[/\(bb(10);/i],[f,[d,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[f,[d,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[f,[d,L+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[f,[d,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[f,[d,"watchOS"]],[/crkey\/([\d\.]+)/i],[f,[d,k+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[d,U],f],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[d,f],[/(sunos) ?([\w\.\d]*)/i],[[d,"Solaris"],f],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[d,f]]},Q=function(e,t){if(typeof e===a&&(t=e,e=i),!(this instanceof Q))return new Q(e,t).getResult();var m=typeof r!==n&&r.navigator?r.navigator:i,y=e||(m&&m.userAgent?m.userAgent:""),b=m&&m.userAgentData?m.userAgentData:i,E=t?function(e,t){var r={};for(var i in e)t[i]&&t[i].length%2==0?r[i]=t[i].concat(e[i]):r[i]=e[i];return r}(X,t):X,w=m&&m.userAgent==y;return this.getBrowser=function(){var e={};return e[d]=i,e[f]=i,Y.call(e,y,E.browser),e[l]=function(e){return typeof e===o?e.replace(/[^\d\.]/g,"").split(".")[0]:i}(e[f]),w&&m&&m.brave&&typeof m.brave.isBrave==s&&(e[d]="Brave"),e},this.getCPU=function(){var e={};return e[p]=i,Y.call(e,y,E.cpu),e},this.getDevice=function(){var e={};return e[h]=i,e[c]=i,e[u]=i,Y.call(e,y,E.device),w&&!e[u]&&b&&b.mobile&&(e[u]=g),w&&"Macintosh"==e[c]&&m&&typeof m.standalone!==n&&m.maxTouchPoints&&m.maxTouchPoints>2&&(e[c]="iPad",e[u]=v),e},this.getEngine=function(){var e={};return e[d]=i,e[f]=i,Y.call(e,y,E.engine),e},this.getOS=function(){var e={};return e[d]=i,e[f]=i,Y.call(e,y,E.os),w&&!e[d]&&b&&b.platform&&"Unknown"!=b.platform&&(e[d]=b.platform.replace(/chrome os/i,U).replace(/macos/i,z)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return y},this.setUA=function(e){return y=typeof e===o&&e.length>500?W(e,500):e,this},this.setUA(y),this};Q.VERSION="1.0.40",Q.BROWSER=j([d,f,l]),Q.CPU=j([p]),Q.DEVICE=j([c,h,u,m,g,y,v,b,E]),Q.ENGINE=Q.OS=j([d,f]),e.exports&&(t=e.exports=Q),t.UAParser=Q;var Z=typeof r!==n&&(r.jQuery||r.Zepto);if(Z&&!Z.ua){var J=new Q;Z.ua=J.getResult(),Z.ua.get=function(){return J.getUA()},Z.ua.set=function(e){J.setUA(e);var t=J.getResult();for(var r in t)Z.ua[r]=t[r]}}}("object"==typeof window?window:Ya)),Wa.exports;var e,t}var qa=function(){if(Ha)return Va;Ha=1,Object.defineProperty(Va,"__esModule",{value:!0});var e,r=t,i=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,s=Ka(),n=new s,a=n.getBrowser(),o=n.getCPU(),l=n.getDevice(),c=n.getEngine(),d=n.getOS(),u=n.getUA(),h=function(e){return n.setUA(e)},f=function(e){if(e){var t=new s(e);return{UA:t,browser:t.getBrowser(),cpu:t.getCPU(),device:t.getDevice(),engine:t.getEngine(),os:t.getOS(),ua:t.getUA(),setUserAgent:function(e){return t.setUA(e)}}}console.error("No userAgent string was provided")},p=Object.freeze({ClientUAInstance:n,browser:a,cpu:o,device:l,engine:c,os:d,ua:u,setUa:h,parseUserAgent:f});function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function g(e){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g(e)}function v(e,t,r){return t&&function(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),e}function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(){return b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},b.apply(this,arguments)}function E(e){return E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},E(e)}function w(e,t){return w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},w(e,t)}function S(e,t){if(null==e)return{};var r,i,s=function(e,t){if(null==e)return{};var r,i,s={},n=Object.keys(e);for(i=0;i<n.length;i++)r=n[i],t.indexOf(r)>=0||(s[r]=e[r]);return s}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(i=0;i<n.length;i++)r=n[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(s[r]=e[r])}return s}function T(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var i,s,n=[],a=!0,o=!1;try{for(r=r.call(e);!(a=(i=r.next()).done)&&(n.push(i.value),!t||n.length!==t);a=!0);}catch(e){o=!0,s=e}finally{try{a||null==r.return||r.return()}finally{if(o)throw s}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return A(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return A(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}var k="mobile",L="tablet",I="smarttv",R="console",P="wearable",C="embedded",D=void 0,_={Chrome:"Chrome",Firefox:"Firefox",Opera:"Opera",Yandex:"Yandex",Safari:"Safari",InternetExplorer:"Internet Explorer",Edge:"Edge",Chromium:"Chromium",Ie:"IE",MobileSafari:"Mobile Safari",EdgeChromium:"Edge Chromium",MIUI:"MIUI Browser",SamsungBrowser:"Samsung Browser"},O={IOS:"iOS",Android:"Android",WindowsPhone:"Windows Phone",Windows:"Windows",MAC_OS:"Mac OS"},M={isMobile:!1,isTablet:!1,isBrowser:!1,isSmartTV:!1,isConsole:!1,isWearable:!1},N=function(e){return e||(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"none")},F=function(){return!("undefined"==typeof window||!window.navigator&&!navigator)&&(window.navigator||navigator)},$=function(e){var t=F();return t&&t.platform&&(-1!==t.platform.indexOf(e)||"MacIntel"===t.platform&&t.maxTouchPoints>1&&!window.MSStream)},B=function(e,t,r,i){return function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach(function(t){y(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({},e,{vendor:N(t.vendor),model:N(t.model),os:N(r.name),osVersion:N(r.version),ua:N(i)})},U=function(e){return e.type===k},z=function(e){return e.type===L},G=function(e){var t=e.type;return t===k||t===L},j=function(e){return e.type===I},H=function(e){return e.type===D},V=function(e){return e.type===P},W=function(e){return e.type===R},Y=function(e){return e.type===C},K=function(e){var t=e.vendor;return N(t)},q=function(e){var t=e.model;return N(t)},X=function(e){var t=e.type;return N(t,"browser")},Q=function(e){return e.name===O.Android},Z=function(e){return e.name===O.Windows},J=function(e){return e.name===O.MAC_OS},ee=function(e){return e.name===O.WindowsPhone},te=function(e){return e.name===O.IOS},re=function(e){var t=e.version;return N(t)},ie=function(e){var t=e.name;return N(t)},se=function(e){return e.name===_.Chrome},ne=function(e){return e.name===_.Firefox},ae=function(e){return e.name===_.Chromium},oe=function(e){return e.name===_.Edge},le=function(e){return e.name===_.Yandex},ce=function(e){var t=e.name;return t===_.Safari||t===_.MobileSafari},de=function(e){return e.name===_.MobileSafari},ue=function(e){return e.name===_.Opera},he=function(e){var t=e.name;return t===_.InternetExplorer||t===_.Ie},fe=function(e){return e.name===_.MIUI},pe=function(e){return e.name===_.SamsungBrowser},me=function(e){var t=e.version;return N(t)},ge=function(e){var t=e.major;return N(t)},ve=function(e){var t=e.name;return N(t)},ye=function(e){var t=e.name;return N(t)},be=function(e){var t=e.version;return N(t)},Ee=function(){var e=F(),t=e&&e.userAgent&&e.userAgent.toLowerCase();return"string"==typeof t&&/electron/.test(t)},we=function(e){return"string"==typeof e&&-1!==e.indexOf("Edg/")},Se=function(){var e=F();return e&&(/iPad|iPhone|iPod/.test(e.platform)||"MacIntel"===e.platform&&e.maxTouchPoints>1)&&!window.MSStream},Te=function(){return $("iPad")},xe=function(){return $("iPhone")},Ae=function(){return $("iPod")},ke=function(e){return N(e)};function Le(e){var t=e||p,r=t.device,i=t.browser,s=t.os,n=t.engine,a=t.ua;return{isSmartTV:j(r),isConsole:W(r),isWearable:V(r),isEmbedded:Y(r),isMobileSafari:de(i)||Te(),isChromium:ae(i),isMobile:G(r)||Te(),isMobileOnly:U(r),isTablet:z(r)||Te(),isBrowser:H(r),isDesktop:H(r),isAndroid:Q(s),isWinPhone:ee(s),isIOS:te(s)||Te(),isChrome:se(i),isFirefox:ne(i),isSafari:ce(i),isOpera:ue(i),isIE:he(i),osVersion:re(s),osName:ie(s),fullBrowserVersion:me(i),browserVersion:ge(i),browserName:ve(i),mobileVendor:K(r),mobileModel:q(r),engineName:ye(n),engineVersion:be(n),getUA:ke(a),isEdge:oe(i)||we(a),isYandex:le(i),deviceType:X(r),isIOS13:Se(),isIPad13:Te(),isIPhone13:xe(),isIPod13:Ae(),isElectron:Ee(),isEdgeChromium:we(a),isLegacyEdge:oe(i)&&!we(a),isWindows:Z(s),isMacOs:J(s),isMIUI:fe(i),isSamsungBrowser:pe(i)}}var Ie=j(l),Re=W(l),Pe=V(l),Ce=Y(l),De=de(a)||Te(),_e=ae(a),Oe=G(l)||Te(),Me=U(l),Ne=z(l)||Te(),Fe=H(l),$e=H(l),Be=Q(d),Ue=ee(d),ze=te(d)||Te(),Ge=se(a),je=ne(a),He=ce(a),Ve=ue(a),We=he(a),Ye=re(d),Ke=ie(d),qe=me(a),Xe=ge(a),Qe=ve(a),Ze=K(l),Je=q(l),et=ye(c),tt=be(c),rt=ke(u),it=oe(a)||we(u),st=le(a),nt=X(l),at=Se(),ot=Te(),lt=xe(),ct=Ae(),dt=Ee(),ut=we(u),ht=oe(a)&&!we(u),ft=Z(d),pt=J(d),mt=fe(a),gt=pe(a);function vt(e){var t=e||window.navigator.userAgent;return f(t)}return Va.AndroidView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Be?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.BrowserTypes=_,Va.BrowserView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Fe?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.ConsoleView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Re?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.CustomView=function(e){var t=e.renderWithFragment,s=e.children;e.viewClassName,e.style;var n=e.condition,a=S(e,["renderWithFragment","children","viewClassName","style","condition"]);return n?t?i.createElement(r.Fragment,null,s):i.createElement("div",a,s):null},Va.IEView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return We?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.IOSView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return ze?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.MobileOnlyView=function(e){var t=e.renderWithFragment,s=e.children;e.viewClassName,e.style;var n=S(e,["renderWithFragment","children","viewClassName","style"]);return Me?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.MobileView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Oe?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.OsTypes=O,Va.SmartTVView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Ie?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.TabletView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Ne?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.WearableView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Pe?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.WinPhoneView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Ue?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.browserName=Qe,Va.browserVersion=Xe,Va.deviceDetect=function(e){var t=e?f(e):p,r=t.device,i=t.browser,s=t.engine,n=t.os,a=t.ua,o=function(e){switch(e){case k:return{isMobile:!0};case L:return{isTablet:!0};case I:return{isSmartTV:!0};case R:return{isConsole:!0};case P:return{isWearable:!0};case D:return{isBrowser:!0};case C:return{isEmbedded:!0};default:return M}}(r.type),l=o.isBrowser,c=o.isMobile,d=o.isTablet,u=o.isSmartTV,h=o.isConsole,m=o.isWearable,g=o.isEmbedded;return l?function(e,t,r,i,s){return{isBrowser:e,browserMajorVersion:N(t.major),browserFullVersion:N(t.version),browserName:N(t.name),engineName:N(r.name),engineVersion:N(r.version),osName:N(i.name),osVersion:N(i.version),userAgent:N(s)}}(l,i,s,n,a):u?function(e,t,r,i){return{isSmartTV:e,engineName:N(t.name),engineVersion:N(t.version),osName:N(r.name),osVersion:N(r.version),userAgent:N(i)}}(u,s,n,a):h?function(e,t,r,i){return{isConsole:e,engineName:N(t.name),engineVersion:N(t.version),osName:N(r.name),osVersion:N(r.version),userAgent:N(i)}}(h,s,n,a):c||d?B(o,r,n,a):m?function(e,t,r,i){return{isWearable:e,engineName:N(t.name),engineVersion:N(t.version),osName:N(r.name),osVersion:N(r.version),userAgent:N(i)}}(m,s,n,a):g?function(e,t,r,i,s){return{isEmbedded:e,vendor:N(t.vendor),model:N(t.model),engineName:N(r.name),engineVersion:N(r.version),osName:N(i.name),osVersion:N(i.version),userAgent:N(s)}}(g,r,s,n,a):void 0},Va.deviceType=nt,Va.engineName=et,Va.engineVersion=tt,Va.fullBrowserVersion=qe,Va.getSelectorsByUserAgent=function(e){if(e&&"string"==typeof e){var t=f(e);return Le({device:t.device,browser:t.browser,os:t.os,engine:t.engine,ua:t.ua})}console.error("No valid user agent string was provided")},Va.getUA=rt,Va.isAndroid=Be,Va.isBrowser=Fe,Va.isChrome=Ge,Va.isChromium=_e,Va.isConsole=Re,Va.isDesktop=$e,Va.isEdge=it,Va.isEdgeChromium=ut,Va.isElectron=dt,Va.isEmbedded=Ce,Va.isFirefox=je,Va.isIE=We,Va.isIOS=ze,Va.isIOS13=at,Va.isIPad13=ot,Va.isIPhone13=lt,Va.isIPod13=ct,Va.isLegacyEdge=ht,Va.isMIUI=mt,Va.isMacOs=pt,Va.isMobile=Oe,Va.isMobileOnly=Me,Va.isMobileSafari=De,Va.isOpera=Ve,Va.isSafari=He,Va.isSamsungBrowser=gt,Va.isSmartTV=Ie,Va.isTablet=Ne,Va.isWearable=Pe,Va.isWinPhone=Ue,Va.isWindows=ft,Va.isYandex=st,Va.mobileModel=Je,Va.mobileVendor=Ze,Va.osName=Ke,Va.osVersion=Ye,Va.parseUserAgent=f,Va.setUserAgent=function(e){return h(e)},Va.useDeviceData=vt,Va.useDeviceSelectors=function(e){var t=vt(e||window.navigator.userAgent);return[Le(t),t]},Va.useMobileOrientation=function(){var e=x(r.useState(function(){var e=window.innerWidth>window.innerHeight?90:0;return{isPortrait:0===e,isLandscape:90===e,orientation:0===e?"portrait":"landscape"}}),2),t=e[0],i=e[1],s=r.useCallback(function(){var e=window.innerWidth>window.innerHeight?90:0,r={isPortrait:0===e,isLandscape:90===e,orientation:0===e?"portrait":"landscape"};t.orientation!==r.orientation&&i(r)},[t.orientation]);return r.useEffect(function(){return void 0!==("undefined"==typeof window?"undefined":g(window))&&Oe&&(s(),window.addEventListener("load",s,!1),window.addEventListener("resize",s,!1)),function(){window.removeEventListener("resize",s,!1),window.removeEventListener("load",s,!1)}},[s]),t},Va.withOrientationChange=function(e){return function(t){function r(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),(t=function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return T(e)}(this,E(r).call(this,e))).isEventListenerAdded=!1,t.handleOrientationChange=t.handleOrientationChange.bind(T(t)),t.onOrientationChange=t.onOrientationChange.bind(T(t)),t.onPageLoad=t.onPageLoad.bind(T(t)),t.state={isLandscape:!1,isPortrait:!1},t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&w(e,t)}(r,t),v(r,[{key:"handleOrientationChange",value:function(){this.isEventListenerAdded||(this.isEventListenerAdded=!0);var e=window.innerWidth>window.innerHeight?90:0;this.setState({isPortrait:0===e,isLandscape:90===e})}},{key:"onOrientationChange",value:function(){this.handleOrientationChange()}},{key:"onPageLoad",value:function(){this.handleOrientationChange()}},{key:"componentDidMount",value:function(){void 0!==("undefined"==typeof window?"undefined":g(window))&&Oe&&(this.isEventListenerAdded?window.removeEventListener("load",this.onPageLoad,!1):(this.handleOrientationChange(),window.addEventListener("load",this.onPageLoad,!1)),window.addEventListener("resize",this.onOrientationChange,!1))}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.onOrientationChange,!1)}},{key:"render",value:function(){return i.createElement(e,b({},this.props,{isLandscape:this.state.isLandscape,isPortrait:this.state.isPortrait}))}}]),r}(i.Component)},Va}();function Xa({message:e,duration:r=3e3,visible:s,setVisible:n}){return i(()=>{const e=setTimeout(()=>n(!1),r);return()=>clearTimeout(e)},[s]),s?t.createElement("div",{style:{position:"fixed",top:"1rem",left:"50%",transform:"translateX(-50%)",background:"rgba(0,0,0,0.8)",color:"#fff",padding:"0.75rem 1.25rem",borderRadius:"0.375rem",fontSize:"14px",zIndex:9999,boxShadow:"0 2px 10px rgba(0,0,0,0.2)"}},e):null}const Qa=({shortForm:e,shareUrl:r})=>{const i=null!=r?r:window.location.href,[s,n]=a(!1);return t.createElement(t.Fragment,null,t.createElement("button",{onClick:()=>x(void 0,void 0,void 0,function*(){try{n(!0),qa.isMobile&&navigator.share&&e?yield navigator.share({title:e.title,url:i}):(e=>{if(void 0!==navigator.clipboard)navigator.clipboard.writeText(e).then(()=>{});else{const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),t.setSelectionRange(0,99999);try{document.execCommand("copy")}catch(e){console.error("복사 실패",e)}t.setSelectionRange(0,0),document.body.removeChild(t)}})(i)}catch(e){console.error("Fail to copy on clipboard")}}),className:"cursor-pointer"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:"https://mbus-asset.s3.ap-northeast-2.amazonaws.com/mcom-player/share.png",alt:"share",width:24,height:24,className:"block h-6 w-6 object-contain"})),t.createElement(Xa,{message:"공유 링크 복사 완료",setVisible:n,visible:s})))},Za=({product:e,useDirectLink:r,contentId:i})=>{var s;const{isPreview:n,priceText:o,memberOnly:l,isMemberLoggedIn:c}=Ua(),d=l&&!c,[u,h]=a(!1),f=t=>{if(!r)return;if(n)return void t.preventDefault();Ia({contentProductId:e.eventProductId,contentId:i,productId:e.productId});(e=>{if("undefined"==typeof window)return!1;const t=window.goDetail;return"function"==typeof t&&(t(e),!0)})(t.currentTarget)&&t.preventDefault()},p=t.createElement(t.Fragment,null,t.createElement("div",{className:"w-1/3 h-full shrink-0"},e.thumbPath&&!u?t.createElement(Hr,{product:e,onError:()=>h(!0)}):t.createElement(jr,null)),t.createElement("div",{className:"flex flex-col text-left p-2 w-full justify-center"},e.brand&&t.createElement("span",{className:"break-keep line-clamp-1 text-gray-500",style:{fontSize:"10px"}},e.brand.brandName),t.createElement("div",{className:"text-gray-800 text-ellipsis line-clamp-1 ",style:{fontSize:"12px"}},e.productName),t.createElement("div",{className:"text-red-500 break-keep",style:{fontSize:"12px"}},d?t.createElement("span",{className:"font-semibold break-keep"},"판매가 회원 공개"):t.createElement(t.Fragment,null,o?o+" ":"할인가 ",t.createElement("span",{className:"font-semibold break-keep"},Tt(e.sellingPrice,e.currency))))));return r?t.createElement("a",{href:null!==(s=e.linkPath)&&void 0!==s?s:void 0,"data-mgcode":e.mallProductCode,target:"_blank",draggable:!1,rel:"noopener noreferrer",style:{height:"80px",textDecoration:"none",color:"inherit"},className:"apphref flex gap-2 items-center w-full",onClick:f},p):t.createElement("div",{style:{height:"80px"},className:"flex gap-2 items-center w-full",onClick:f},p)},Ja=({products:e,contentId:r})=>{const i=d(()=>(e=>{if(e.length>=3)return e;const t=[...e];for(;t.length<3;)t.push(...e);return t})(e),[e]),s=1===(null==e?void 0:e.length);return(null==e?void 0:e.length)?t.createElement("div",{className:"w-full",style:{height:"80px"}},s?t.createElement("div",{className:"bg-white overflow-hidden rounded-xl w-full",style:{borderRadius:"10px",height:"80px"}},t.createElement(Za,{product:e[0],useDirectLink:!0,contentId:r})):t.createElement(Jn,{nested:!0,modules:[pa,ia],slidesPerView:1.1,effect:"cards",autoplay:!0,loop:!0,grabCursor:!0,threshold:10,onClick:(e,t)=>{var r;const i=e.slides[e.activeIndex],s=null==i?void 0:i.querySelector("a.apphref");if(!s)return;const n=e.el.getRootNode(),a=t,o=null===(r=n.elementFromPoint)||void 0===r?void 0:r.call(n,a.clientX,a.clientY);o&&s.contains(o)||s.click()},cardsEffect:{rotate:!1},className:"w-full",style:{height:"80px"}},i.map((e,i)=>t.createElement(ea,{key:i+e.productId,className:"bg-white overflow-hidden rounded-xl",style:{borderRadius:"10px",height:"80px"}},t.createElement(Za,{product:e,useDirectLink:!0,contentId:r}))))):null},eo="https://mbus-asset.s3.ap-northeast-2.amazonaws.com/mcom-player",to=({shortForm:e,isPopup:r,hideProductCarousel:i,hideOverlay:s,shareUrl:n,handleClose:o})=>{const[l,c]=a(!Boolean(r)),[d,u]=a(!0),h=()=>{c(e=>!e)},f=()=>{u(e=>!e)},{logo:p,productsInfo:m,thumbPath:g,title:v,media:y,brand:b,shortsId:E}=e,w=r?"mb-1 max-h-10 max-w-20 object-contain":"mb-1 max-h-10 max-w-28 object-contain",S=e=>{e.stopPropagation()},T=r?t.createElement("div",{className:"justify-self-end flex gap-2"},t.createElement("button",{className:"cursor-pointer text-white",onClick:f},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},d?t.createElement(Nr,{size:24}):t.createElement(Fr,{size:24}))),t.createElement("button",{className:"cursor-pointer text-white",onClick:h},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:`${eo}/${l?"sound_off":"sound"}.png`,alt:l?"muted":"volume",width:24,height:24,className:"block h-6 w-6 object-contain"}))),o?t.createElement("button",{className:"cursor-pointer text-white",onClick:o},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement(zr,{size:24}))):null):t.createElement("div",{className:"flex flex-col gap-3 items-end"},t.createElement("button",{type:"button",className:"text-white",onClick:e=>{S(e),h()},"aria-label":l?"음소거 해제":"음소거"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:`${eo}/${l?"sound_off":"sound"}.png`,alt:l?"muted":"volume",width:24,height:24,className:"block h-6 w-6 object-contain"}))),o?t.createElement("button",{type:"button",className:"text-white",onClick:e=>{S(e),o()},"aria-label":"닫기"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement(zr,{size:24}))):null);return t.createElement("div",{className:"h-full w-full text-sm overflow-hidden text-white relative",onClick:r?void 0:f},t.createElement("div",{className:"pointer-events-none absolute inset-0 z-[1] flex h-full w-full flex-col justify-between bg-gradient-to-b from-black/40 via-transparent to-black/40 p-4"},t.createElement("div",{className:"flex gap-2 justify-between pointer-events-auto",onClick:S},t.createElement("div",null,!s&&(null==p?void 0:p.thumbPath)?t.createElement("img",{className:w,src:p.thumbPath,alt:p.logoName,width:100,height:100}):null),!s&&T),t.createElement("div",{className:"h-full w-full"}),t.createElement("div",{className:"mb-6 pointer-events-auto",onClick:S},!s&&t.createElement("div",{className:"flex justify-between items-end mb-3 gap-3"},t.createElement("div",{className:"w-full"},b&&t.createElement("div",{className:"items-center flex gap-3 mb-2"},t.createElement("div",{className:"w-14 h-14 bg-white rounded-full border overflow-hidden shrink-0"},t.createElement("img",{src:b.thumbPath,alt:b.brandName,width:100,height:100,className:"object-contain w-full h-full"})),t.createElement("p",{className:"mb-2 text-start text-sm line-clamp-1"},null==b?void 0:b.brandName)),t.createElement("p",{className:"text-start text-base line-clamp-2"},v)),t.createElement("div",{className:"flex flex-col gap-4 items-center"},t.createElement(Ga,{shortsId:E}),t.createElement("div",{className:"flex items-center justify-center"},t.createElement(Qa,{shortForm:e,shareUrl:n})))),!i&&(null==m?void 0:m.length)>0&&t.createElement(Ja,{products:m,contentId:e.shortsId}))),t.createElement(L,{file:xt(null==y?void 0:y.objectId),thumbnail:`${Ct(g)}`,mute:l,isVertical:(null==y?void 0:y.height)>(null==y?void 0:y.width),play:d}))},ro="cursor-pointer text-zinc-500",io=e=>{const{collection:i,shortform:s,setShortform:n}=e,a=r(null);return t.createElement("div",{className:"flex h-full gap-2 items-center justify-center mx-auto"},t.createElement("div",{className:"flex flex-col gap-4"},t.createElement(Dr,{size:44,strokeWidth:1,className:ro,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(Rr,{size:44,strokeWidth:1,className:ro,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slideNext()}})),t.createElement("div",{className:"h-full aspect-[9/16] max-w-fit relative"},t.createElement(Jn,{modules:[ta,da],mousewheel:!0,direction:"vertical",slidesPerView:1,ref:a,onSlideChangeTransitionEnd:e=>{(e=>{const t=i.contents[e];t&&n(Object.assign({},t))})(e.realIndex)},className:"h-full",preventClicksPropagation:!1,preventClicks:!1,noSwiping:!0,allowTouchMove:!1,loop:!0},i.contents.map(e=>t.createElement(ea,{key:e.shortsId},t.createElement("div",{className:"flex justify-center gap-3 h-full"},s.shortsId===e.shortsId&&t.createElement("div",{className:"h-full absolute z-[999] w-full bg-white"},t.createElement(to,{shortForm:s,hideProductCarousel:!0})),t.createElement("img",{src:Ct(e.thumbPath),alt:e.title,className:"w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")})))))))},so=()=>t.createElement("div",{className:"w-full h-full bg-black/50 absolute top-0 left-0 z-[999] flex items-center justify-center pointer-events-none"},t.createElement("div",{className:"flex flex-col gap-5 items-center justify-center"},t.createElement(_r,{size:80,strokeWidth:1.2,className:"text-white"}),t.createElement("p",{className:"text-white"},"위아래로 스와이프 해보세요"))),no=({collection:e,playerSettings:r})=>{const[i,s]=a(e.contents[0]),[n,o]=a(!0),l=u(()=>{n&&o(!1)},[n]);return t.createElement("div",{className:"flex-1 md:flex md:justify-center w-full h-full bg-black relative",onClick:l},n&&t.createElement(so,null),t.createElement("div",{className:"h-full w-full"},t.createElement(Jn,{modules:[ta,da],loop:!0,mousewheel:!0,direction:"vertical",touchEventsTarget:"container",slidesPerView:1,onSlideChangeTransitionEnd:t=>{const r=e.contents[t.realIndex];s(Object.assign({},r))},className:"h-full md:aspect-[9/16] md:mx-auto"},e.contents.map(e=>t.createElement(ea,{key:e.shortsId,className:"rounded-xl overflow-hidden"},i.shortsId===e.shortsId&&t.createElement("div",{className:"w-full h-full md:flex md:justify-center absolute z-[999]"},t.createElement(to,{shortForm:i})),t.createElement("img",{src:Ct(e.thumbPath),alt:e.title,className:"rounded-xl w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")}))))))};const ao='/*! tailwindcss v4.0.12 | MIT License | https://tailwindcss.com */@layer theme, base, components, utilities;@layer theme{:host,:root{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-500:oklch(0.637 0.237 25.331);--color-blue-200:oklch(0.882 0.059 254.128);--color-blue-300:oklch(0.809 0.105 251.813);--color-gray-200:oklch(0.928 0.006 264.531);--color-gray-400:oklch(0.707 0.022 261.325);--color-gray-500:oklch(0.551 0.027 264.364);--color-gray-700:oklch(0.373 0.034 259.733);--color-gray-800:oklch(0.278 0.033 256.848);--color-gray-900:oklch(0.21 0.034 264.665);--color-zinc-500:oklch(0.552 0.016 285.938);--color-zinc-700:oklch(0.37 0.013 285.805);--color-black:#000;--color-white:#fff;--spacing:0.25rem;--container-lg:32rem;--text-xs:0.75rem;--text-xs--line-height:1.33333;--text-sm:0.875rem;--text-sm--line-height:1.42857;--text-base:1rem;--text-base--line-height:1.5;--text-lg:1.125rem;--text-lg--line-height:1.55556;--text-xl:1.25rem;--text-xl--line-height:1.4;--font-weight-medium:500;--font-weight-semibold:600;--leading-tight:1.25;--ease-in:cubic-bezier(0.4,0,1,1);--ease-in-out:cubic-bezier(0.4,0,0.2,1);--animate-pulse:pulse 2s cubic-bezier(0.4,0,0.6,1) infinite;--aspect-video:16/9;--default-transition-duration:150ms;--default-transition-timing-function:cubic-bezier(0.4,0,0.2,1);--default-font-family:var(--font-sans);--default-font-feature-settings:var(--font-sans--font-feature-settings);--default-font-variation-settings:var(\n --font-sans--font-variation-settings\n );--default-mono-font-family:var(--font-mono);--default-mono-font-feature-settings:var(\n --font-mono--font-feature-settings\n );--default-mono-font-variation-settings:var(\n --font-mono--font-variation-settings\n );--animate-float:float 2s ease}}@layer base{*,::backdrop,::file-selector-button,:after,:before{border:0 solid;box-sizing:border-box;margin:0;padding:0}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:var(--default-font-feature-settings,normal);-webkit-tap-highlight-color:transparent;font-family:var( --default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji" );font-variation-settings:var( --default-font-variation-settings,normal );line-height:1.5;tab-size:4}body{line-height:inherit}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:var( --default-mono-font-feature-settings,normal );font-family:var( --default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace );font-size:1em;font-variation-settings:var( --default-mono-font-variation-settings,normal )}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}::file-selector-button,button,input,optgroup,select,textarea{font-feature-settings:inherit;background-color:transparent;border-radius:0;color:inherit;font:inherit;font-variation-settings:inherit;letter-spacing:inherit;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{color:color-mix(in oklab,currentColor 50%,transparent);opacity:1}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-year-field{padding-block:0}:-moz-ui-invalid{box-shadow:none}::file-selector-button,button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.inset-0{inset:calc(var(--spacing)*0)}.top-0{top:calc(var(--spacing)*0)}.top-1\\/2{top:50%}.top-4{top:calc(var(--spacing)*4)}.right-0{right:calc(var(--spacing)*0)}.right-4{right:calc(var(--spacing)*4)}.bottom-0{bottom:calc(var(--spacing)*0)}.left-0{left:calc(var(--spacing)*0)}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.z-\\[1\\]{z-index:1}.z-\\[5\\]{z-index:5}.z-\\[999\\]{z-index:999}.container{width:100%;@media (width >= 40rem){max-width:40rem}@media (width >= 48rem){max-width:48rem}@media (width >= 64rem){max-width:64rem}@media (width >= 80rem){max-width:80rem}@media (width >= 96rem){max-width:96rem}}.mx-0{margin-inline:calc(var(--spacing)*0)}.mx-auto{margin-inline:auto}.my-0{margin-block:calc(var(--spacing)*0)}.my-2{margin-block:calc(var(--spacing)*2)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.line-clamp-1{-webkit-line-clamp:1}.line-clamp-1,.line-clamp-2{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-2{-webkit-line-clamp:2}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.table{display:table}.aspect-\\[9\\/16\\]{aspect-ratio:9/16}.aspect-square{aspect-ratio:1/1}.aspect-video{aspect-ratio:var(--aspect-video)}.size-3{height:calc(var(--spacing)*3);width:calc(var(--spacing)*3)}.size-4{height:calc(var(--spacing)*4);width:calc(var(--spacing)*4)}.h-1{height:calc(var(--spacing)*1)}.h-3\\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-16{height:calc(var(--spacing)*16)}.h-\\[24px\\]{height:24px}.h-\\[60px\\]{height:60px}.h-\\[80\\%\\]{height:80%}.h-\\[95\\%\\]{height:95%}.h-\\[100px\\]{height:100px}.h-\\[125px\\]{height:125px}.h-\\[500px\\]{height:500px}.h-\\[600px\\]{height:600px}.h-full{height:100%}.max-h-10{max-height:calc(var(--spacing)*10)}.max-h-\\[150px\\]{max-height:150px}.max-h-\\[300px\\]{max-height:300px}.max-h-fit{max-height:fit-content}.max-h-full{max-height:100%}.min-h-0{min-height:calc(var(--spacing)*0)}.\\!w-auto{width:auto!important}.w-1\\/3{width:33.33333%}.w-4{width:calc(var(--spacing)*4)}.w-4\\/5{width:80%}.w-6{width:calc(var(--spacing)*6)}.w-10{width:calc(var(--spacing)*10)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-16{width:calc(var(--spacing)*16)}.w-36{width:calc(var(--spacing)*36)}.w-\\[24px\\]{width:24px}.w-\\[400px\\]{width:400px}.w-\\[500px\\]{width:500px}.w-\\[1024px\\]{width:1024px}.w-full{width:100%}.max-w-20{max-width:calc(var(--spacing)*20)}.max-w-28{max-width:calc(var(--spacing)*28)}.max-w-52{max-width:calc(var(--spacing)*52)}.max-w-\\[40\\%\\]{max-width:40%}.max-w-\\[160px\\]{max-width:160px}.max-w-\\[800px\\]{max-width:800px}.max-w-\\[830px\\]{max-width:830px}.max-w-fit{max-width:fit-content}.max-w-full{max-width:100%}.max-w-lg{max-width:var(--container-lg)}.max-w-none{max-width:none}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-44{min-width:calc(var(--spacing)*44)}.min-w-\\[768px\\]{min-width:768px}.flex-1{flex:1}.flex-\\[2\\]{flex:2}.flex-shrink-0,.shrink-0{flex-shrink:0}.grow{flex-grow:1}.border-collapse{border-collapse:collapse}.-translate-y-1\\/2{--tw-translate-y:-50%}.-translate-y-1\\/2,.translate-y-0\\.5{translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-0\\.5{--tw-translate-y:calc(var(--spacing)*0.5)}.transform{transform:var(--tw-rotate-x) var(--tw-rotate-y) var(--tw-rotate-z) var(--tw-skew-x) var(--tw-skew-y)}.animate-float{animation:var(--animate-float)}.animate-pulse{animation:var(--animate-pulse)}.cursor-default{cursor:default}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.resize{resize:both}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-1{gap:calc(var(--spacing)*1)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-8{gap:calc(var(--spacing)*8)}.gap-10{gap:calc(var(--spacing)*10)}.self-center{align-self:center}.justify-self-end{justify-self:flex-end}.truncate{text-overflow:ellipsis;white-space:nowrap}.overflow-hidden,.truncate{overflow:hidden}.overflow-scroll{overflow:scroll}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:calc(infinity * 1px)}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-xl{border-radius:calc(var(--radius) + 4px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-none{--tw-border-style:none;border-style:none}.bg-\\[\\#0ab060\\]{background-color:#0ab060}.bg-\\[\\#eeeeee\\]{background-color:#eee}.bg-\\[\\#f4f4f4\\]{background-color:#f4f4f4}.bg-\\[rgba\\(0\\,0\\,0\\,\\.3\\)\\]{background-color:rgba(0,0,0,.3)}.bg-black{background-color:var(--color-black)}.bg-black\\/50{background-color:color-mix(in oklab,var(--color-black) 50%,transparent)}.bg-blue-200{background-color:var(--color-blue-200)}.bg-blue-300{background-color:var(--color-blue-300)}.bg-gray-200{background-color:var(--color-gray-200)}.bg-white{background-color:var(--color-white)}.bg-zinc-700{background-color:var(--color-zinc-700)}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-black\\/40{--tw-gradient-from:color-mix(in oklab,var(--color-black) 40%,transparent);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}.via-transparent{--tw-gradient-via:transparent;--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-via) var(--tw-gradient-via-position),var(--tw-gradient-to) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-black\\/40{--tw-gradient-to:color-mix(in oklab,var(--color-black) 40%,transparent);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}.fill-black{fill:var(--color-black)}.fill-red-500{fill:var(--color-red-500)}.fill-white{fill:var(--color-white)}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-center{object-position:center}.p-0{padding:calc(var(--spacing)*0)}.p-1{padding:calc(var(--spacing)*1)}.p-2{padding:calc(var(--spacing)*2)}.p-4{padding:calc(var(--spacing)*4)}.p-6{padding:calc(var(--spacing)*6)}.p-10{padding:calc(var(--spacing)*10)}.p-\\[3px\\]{padding:3px}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-10{padding-inline:calc(var(--spacing)*10)}.px-14{padding-inline:calc(var(--spacing)*14)}.px-\\[24px\\]{padding-inline:24px}.py-2{padding-block:calc(var(--spacing)*2)}.py-4{padding-block:calc(var(--spacing)*4)}.pt-0{padding-top:calc(var(--spacing)*0)}.pr-1{padding-right:calc(var(--spacing)*1)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pb-10{padding-bottom:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-start{text-align:start}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[10px\\]{font-size:10px}.text-\\[12px\\]{font-size:12px}.leading-none{--tw-leading:1;line-height:1}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.break-keep{word-break:keep-all}.text-clip{text-overflow:clip}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.text-black{color:var(--color-black)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-700{color:var(--color-gray-700)}.text-gray-800{color:var(--color-gray-800)}.text-gray-900{color:var(--color-gray-900)}.text-muted-foreground{color:var(--muted-foreground)}.text-red-500{color:var(--color-red-500)}.text-transparent{color:transparent}.text-white{color:var(--color-white)}.text-zinc-500{color:var(--color-zinc-500)}.line-through{text-decoration-line:line-through}.opacity-50{opacity:50%}.opacity-70{opacity:70%}.shadow,.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,rgba(0,0,0,.1)),0 1px 2px -1px var(--tw-shadow-color,rgba(0,0,0,.1));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-ring\\/30{--tw-ring-color:color-mix(in oklab,var(--ring) 30%,transparent)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.transition{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-\\[color\\,box-shadow\\]{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:color,box-shadow;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-all{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-opacity{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-transform{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.duration-200{--tw-duration:200ms;transition-duration:.2s}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.duration-200{animation-duration:.2s}.ease-in{animation-timing-function:cubic-bezier(.4,0,1,1)}.ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.fade-in{--tw-enter-opacity:0}.last\\:border-b-0{&:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}}.hover\\:underline{&:hover{@media (hover:hover){text-decoration-line:underline}}}.hover\\:opacity-100{&:hover{@media (hover:hover){opacity:100%}}}.hover\\:ring-4{&:hover{@media (hover:hover){--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}}.focus\\:ring-2{&:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus\\:ring-ring{&:focus{--tw-ring-color:var(--ring)}}.focus\\:ring-offset-2{&:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}}.focus\\:ring-offset-background{&:focus{--tw-ring-offset-color:var(--background)}}.focus\\:outline-none{&:focus{--tw-outline-style:none;outline-style:none}}.focus-visible\\:border-ring{&:focus-visible{border-color:var(--ring)}}.focus-visible\\:ring-4{&:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus-visible\\:ring-\\[3px\\]{&:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus-visible\\:ring-ring\\/50{&:focus-visible{--tw-ring-color:color-mix(in oklab,var(--ring) 50%,transparent)}}.focus-visible\\:outline-hidden{&:focus-visible{--tw-outline-style:none;outline-style:none;@media (forced-colors:active){outline:2px solid transparent;outline-offset:2px}}}.disabled\\:pointer-events-none{&:disabled{pointer-events:none}}.disabled\\:opacity-50{&:disabled{opacity:50%}}.data-\\[disabled\\]\\:opacity-50{&[data-disabled]{opacity:50%}}.data-\\[orientation\\=horizontal\\]\\:h-1\\.5{&[data-orientation=horizontal]{height:calc(var(--spacing)*1.5)}}.data-\\[orientation\\=horizontal\\]\\:h-full{&[data-orientation=horizontal]{height:100%}}.data-\\[orientation\\=horizontal\\]\\:w-full{&[data-orientation=horizontal]{width:100%}}.data-\\[orientation\\=vertical\\]\\:h-full{&[data-orientation=vertical]{height:100%}}.data-\\[orientation\\=vertical\\]\\:min-h-44{&[data-orientation=vertical]{min-height:calc(var(--spacing)*44)}}.data-\\[orientation\\=vertical\\]\\:w-1\\.5{&[data-orientation=vertical]{width:calc(var(--spacing)*1.5)}}.data-\\[orientation\\=vertical\\]\\:w-auto{&[data-orientation=vertical]{width:auto}}.data-\\[orientation\\=vertical\\]\\:w-full{&[data-orientation=vertical]{width:100%}}.data-\\[orientation\\=vertical\\]\\:flex-col{&[data-orientation=vertical]{flex-direction:column}}.\\[\\&\\[data-state\\=open\\]\\>svg\\]\\:rotate-180,.lg\\:px-5,.md\\:aspect-\\[9\\/16\\],.md\\:flex,.md\\:justify-center,.md\\:mx-auto,.md\\:px-4,.sm\\:flex-row,.sm\\:justify-end,.sm\\:mx-0{&[data-state=open]>svg{rotate:180deg}}}body{--background:oklch(1 0 0);--foreground:oklch(0.145 0 0);--card:oklch(1 0 0);--card-foreground:oklch(0.145 0 0);--popover:oklch(1 0 0);--popover-foreground:oklch(0.145 0 0);--primary:oklch(0.205 0 0);--primary-foreground:oklch(0.985 0 0);--secondary:oklch(0.97 0 0);--secondary-foreground:oklch(0.205 0 0);--muted:oklch(0.97 0 0);--muted-foreground:oklch(0.556 0 0);--accent:oklch(0.97 0 0);--accent-foreground:oklch(0.205 0 0);--destructive:oklch(0.577 0.245 27.325);--destructive-foreground:oklch(0.577 0.245 27.325);--border:oklch(0.922 0 0);--input:oklch(0.922 0 0);--ring:oklch(0.708 0 0);--chart-1:oklch(0.646 0.222 41.116);--chart-2:oklch(0.6 0.118 184.704);--chart-3:oklch(0.398 0.07 227.392);--chart-4:oklch(0.828 0.189 84.429);--chart-5:oklch(0.769 0.188 70.08);--radius:0.625rem;--sidebar:oklch(0.985 0 0);--sidebar-foreground:oklch(0.145 0 0);--sidebar-primary:oklch(0.205 0 0);--sidebar-primary-foreground:oklch(0.985 0 0);--sidebar-accent:oklch(0.97 0 0);--sidebar-accent-foreground:oklch(0.205 0 0);--sidebar-border:oklch(0.922 0 0);--sidebar-ring:oklch(0.708 0 0);outline:none}.dark{--background:oklch(0.145 0 0);--foreground:oklch(0.985 0 0);--card:oklch(0.145 0 0);--card-foreground:oklch(0.985 0 0);--popover:oklch(0.145 0 0);--popover-foreground:oklch(0.985 0 0);--primary:oklch(0.985 0 0);--primary-foreground:oklch(0.205 0 0);--secondary:oklch(0.269 0 0);--secondary-foreground:oklch(0.985 0 0);--muted:oklch(0.269 0 0);--muted-foreground:oklch(0.708 0 0);--accent:oklch(0.269 0 0);--accent-foreground:oklch(0.985 0 0);--destructive:oklch(0.396 0.141 25.723);--destructive-foreground:oklch(0.637 0.237 25.331);--border:oklch(0.269 0 0);--input:oklch(0.269 0 0);--ring:oklch(0.439 0 0);--chart-1:oklch(0.488 0.243 264.376);--chart-2:oklch(0.696 0.17 162.48);--chart-3:oklch(0.769 0.188 70.08);--chart-4:oklch(0.627 0.265 303.9);--chart-5:oklch(0.645 0.246 16.439);--sidebar:oklch(0.205 0 0);--sidebar-foreground:oklch(0.985 0 0);--sidebar-primary:oklch(0.488 0.243 264.376);--sidebar-primary-foreground:oklch(0.985 0 0);--sidebar-accent:oklch(0.269 0 0);--sidebar-accent-foreground:oklch(0.985 0 0);--sidebar-border:oklch(0.269 0 0);--sidebar-ring:oklch(0.439 0 0)}@layer base{*{border-color:var(--border);outline-color:color-mix(in oklab,var(--ring) 50%,transparent)}body{background-color:var(--background);color:var(--foreground)}}html.overflow-hidden{overflow:hidden}.scrollbar-hide::-webkit-scrollbar{display:none}.scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.bg-insta{background-image:linear-gradient(to top right,#facc15,#ec4899,#9333ea)}.glass-panel{backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);background:hsla(0,0%,100%,.1);border:1px solid hsla(0,0%,100%,.1)}.product-banner{align-items:center;background:#fff;border-radius:8px;cursor:pointer;display:flex;gap:8px;position:relative}.product-banner__clip{border-radius:inherit;overflow:hidden}.product-banner__clip,.product-banner__sheen{inset:0;pointer-events:none;position:absolute;z-index:1}.product-banner__sheen{background:linear-gradient(270deg,rgba(0,0,0,.1),transparent);transform:translateX(100%);transition:transform .3s ease}.product-banner:hover .product-banner__sheen{transform:translateX(0)}.product-banner__arrow{opacity:0;pointer-events:none;position:absolute;right:8px;top:50%;transform:translate(4px,-50%);transition:transform .3s ease,opacity .3s ease;z-index:2}.product-banner:hover .product-banner__arrow{opacity:1;transform:translateY(-50%)}.product-dialog-container{max-height:70vh;max-width:min(82vw,500px);overflow-y:auto;width:100%}.border{border:1px solid oklch(.922 0 0)}@font-face{font-family:swiper-icons;font-style:normal;font-weight:400;src:url("data:application/font-woff;charset=utf-8;base64, d09GRgABAAAAAAZgABAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAGRAAAABoAAAAci6qHkUdERUYAAAWgAAAAIwAAACQAYABXR1BPUwAABhQAAAAuAAAANuAY7+xHU1VCAAAFxAAAAFAAAABm2fPczU9TLzIAAAHcAAAASgAAAGBP9V5RY21hcAAAAkQAAACIAAABYt6F0cBjdnQgAAACzAAAAAQAAAAEABEBRGdhc3AAAAWYAAAACAAAAAj//wADZ2x5ZgAAAywAAADMAAAD2MHtryVoZWFkAAABbAAAADAAAAA2E2+eoWhoZWEAAAGcAAAAHwAAACQC9gDzaG10eAAAAigAAAAZAAAArgJkABFsb2NhAAAC0AAAAFoAAABaFQAUGG1heHAAAAG8AAAAHwAAACAAcABAbmFtZQAAA/gAAAE5AAACXvFdBwlwb3N0AAAFNAAAAGIAAACE5s74hXjaY2BkYGAAYpf5Hu/j+W2+MnAzMYDAzaX6QjD6/4//Bxj5GA8AuRwMYGkAPywL13jaY2BkYGA88P8Agx4j+/8fQDYfA1AEBWgDAIB2BOoAeNpjYGRgYNBh4GdgYgABEMnIABJzYNADCQAACWgAsQB42mNgYfzCOIGBlYGB0YcxjYGBwR1Kf2WQZGhhYGBiYGVmgAFGBiQQkOaawtDAoMBQxXjg/wEGPcYDDA4wNUA2CCgwsAAAO4EL6gAAeNpj2M0gyAACqxgGNWBkZ2D4/wMA+xkDdgAAAHjaY2BgYGaAYBkGRgYQiAHyGMF8FgYHIM3DwMHABGQrMOgyWDLEM1T9/w8UBfEMgLzE////P/5//f/V/xv+r4eaAAeMbAxwIUYmIMHEgKYAYjUcsDAwsLKxc3BycfPw8jEQA/gZBASFhEVExcQlJKWkZWTl5BUUlZRVVNXUNTQZBgMAAMR+E+gAEQFEAAAAKgAqACoANAA+AEgAUgBcAGYAcAB6AIQAjgCYAKIArAC2AMAAygDUAN4A6ADyAPwBBgEQARoBJAEuATgBQgFMAVYBYAFqAXQBfgGIAZIBnAGmAbIBzgHsAAB42u2NMQ6CUAyGW568x9AneYYgm4MJbhKFaExIOAVX8ApewSt4Bic4AfeAid3VOBixDxfPYEza5O+Xfi04YADggiUIULCuEJK8VhO4bSvpdnktHI5QCYtdi2sl8ZnXaHlqUrNKzdKcT8cjlq+rwZSvIVczNiezsfnP/uznmfPFBNODM2K7MTQ45YEAZqGP81AmGGcF3iPqOop0r1SPTaTbVkfUe4HXj97wYE+yNwWYxwWu4v1ugWHgo3S1XdZEVqWM7ET0cfnLGxWfkgR42o2PvWrDMBSFj/IHLaF0zKjRgdiVMwScNRAoWUoH78Y2icB/yIY09An6AH2Bdu/UB+yxopYshQiEvnvu0dURgDt8QeC8PDw7Fpji3fEA4z/PEJ6YOB5hKh4dj3EvXhxPqH/SKUY3rJ7srZ4FZnh1PMAtPhwP6fl2PMJMPDgeQ4rY8YT6Gzao0eAEA409DuggmTnFnOcSCiEiLMgxCiTI6Cq5DZUd3Qmp10vO0LaLTd2cjN4fOumlc7lUYbSQcZFkutRG7g6JKZKy0RmdLY680CDnEJ+UMkpFFe1RN7nxdVpXrC4aTtnaurOnYercZg2YVmLN/d/gczfEimrE/fs/bOuq29Zmn8tloORaXgZgGa78yO9/cnXm2BpaGvq25Dv9S4E9+5SIc9PqupJKhYFSSl47+Qcr1mYNAAAAeNptw0cKwkAAAMDZJA8Q7OUJvkLsPfZ6zFVERPy8qHh2YER+3i/BP83vIBLLySsoKimrqKqpa2hp6+jq6RsYGhmbmJqZSy0sraxtbO3sHRydnEMU4uR6yx7JJXveP7WrDycAAAAAAAH//wACeNpjYGRgYOABYhkgZgJCZgZNBkYGLQZtIJsFLMYAAAw3ALgAeNolizEKgDAQBCchRbC2sFER0YD6qVQiBCv/H9ezGI6Z5XBAw8CBK/m5iQQVauVbXLnOrMZv2oLdKFa8Pjuru2hJzGabmOSLzNMzvutpB3N42mNgZGBg4GKQYzBhYMxJLMlj4GBgAYow/P/PAJJhLM6sSoWKfWCAAwDAjgbRAAB42mNgYGBkAIIbCZo5IPrmUn0hGA0AO8EFTQAA")}:root{--swiper-theme-color:#007aff}:host{display:block;margin-left:auto;margin-right:auto;position:relative;z-index:1}.swiper{display:block;list-style:none;margin-left:auto;margin-right:auto;overflow:hidden;padding:0;position:relative;z-index:1}.swiper-vertical>.swiper-wrapper{flex-direction:column}.swiper-wrapper{box-sizing:content-box;display:flex;height:100%;position:relative;transition-property:transform;transition-timing-function:var(--swiper-wrapper-transition-timing-function,initial);width:100%;z-index:1}.swiper-android .swiper-slide,.swiper-ios .swiper-slide,.swiper-wrapper{transform:translateZ(0)}.swiper-horizontal{touch-action:pan-y}.swiper-vertical{touch-action:pan-x}.swiper-slide{display:block;flex-shrink:0;height:100%;position:relative;transition-property:transform;width:100%}.swiper-slide-invisible-blank{visibility:hidden}.swiper-autoheight,.swiper-autoheight .swiper-slide{height:auto}.swiper-autoheight .swiper-wrapper{align-items:flex-start;transition-property:transform,height}.swiper-backface-hidden .swiper-slide{-webkit-backface-visibility:hidden;backface-visibility:hidden;transform:translateZ(0)}.swiper-3d.swiper-css-mode .swiper-wrapper{perspective:1200px}.swiper-3d .swiper-wrapper{transform-style:preserve-3d}.swiper-3d{perspective:1200px}.swiper-3d .swiper-cube-shadow,.swiper-3d .swiper-slide{transform-style:preserve-3d}.swiper-css-mode>.swiper-wrapper{-ms-overflow-style:none;overflow:auto;scrollbar-width:none}.swiper-css-mode>.swiper-wrapper::-webkit-scrollbar{display:none}.swiper-css-mode>.swiper-wrapper>.swiper-slide{scroll-snap-align:start start}.swiper-css-mode.swiper-horizontal>.swiper-wrapper{scroll-snap-type:x mandatory}.swiper-css-mode.swiper-vertical>.swiper-wrapper{scroll-snap-type:y mandatory}.swiper-css-mode.swiper-free-mode>.swiper-wrapper{scroll-snap-type:none}.swiper-css-mode.swiper-free-mode>.swiper-wrapper>.swiper-slide{scroll-snap-align:none}.swiper-css-mode.swiper-centered>.swiper-wrapper:before{content:"";flex-shrink:0;order:9999}.swiper-css-mode.swiper-centered>.swiper-wrapper>.swiper-slide{scroll-snap-align:center center;scroll-snap-stop:always}.swiper-css-mode.swiper-centered.swiper-horizontal>.swiper-wrapper>.swiper-slide:first-child{margin-inline-start:var(--swiper-centered-offset-before)}.swiper-css-mode.swiper-centered.swiper-horizontal>.swiper-wrapper:before{height:100%;min-height:1px;width:var(--swiper-centered-offset-after)}.swiper-css-mode.swiper-centered.swiper-vertical>.swiper-wrapper>.swiper-slide:first-child{margin-block-start:var(--swiper-centered-offset-before)}.swiper-css-mode.swiper-centered.swiper-vertical>.swiper-wrapper:before{height:var(--swiper-centered-offset-after);min-width:1px;width:100%}.swiper-3d .swiper-slide-shadow,.swiper-3d .swiper-slide-shadow-bottom,.swiper-3d .swiper-slide-shadow-left,.swiper-3d .swiper-slide-shadow-right,.swiper-3d .swiper-slide-shadow-top{height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:10}.swiper-3d .swiper-slide-shadow{background:rgba(0,0,0,.15)}.swiper-3d .swiper-slide-shadow-left{background-image:linear-gradient(270deg,rgba(0,0,0,.5),transparent)}.swiper-3d .swiper-slide-shadow-right{background-image:linear-gradient(90deg,rgba(0,0,0,.5),transparent)}.swiper-3d .swiper-slide-shadow-top{background-image:linear-gradient(0deg,rgba(0,0,0,.5),transparent)}.swiper-3d .swiper-slide-shadow-bottom{background-image:linear-gradient(180deg,rgba(0,0,0,.5),transparent)}.swiper-lazy-preloader{border:4px solid var(--swiper-preloader-color,var(--swiper-theme-color));border-radius:50%;border-top:4px solid transparent;box-sizing:border-box;height:42px;left:50%;margin-left:-21px;margin-top:-21px;position:absolute;top:50%;transform-origin:50%;width:42px;z-index:10}.swiper-watch-progress .swiper-slide-visible .swiper-lazy-preloader,.swiper:not(.swiper-watch-progress) .swiper-lazy-preloader{animation:swiper-preloader-spin 1s linear infinite}.swiper-lazy-preloader-white{--swiper-preloader-color:#fff}.swiper-lazy-preloader-black{--swiper-preloader-color:#000}@keyframes swiper-preloader-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.swiper.swiper-cards{overflow:visible}.swiper-cards .swiper-slide{-webkit-backface-visibility:hidden;backface-visibility:hidden;overflow:hidden;transform-origin:center bottom}.swiper-grid>.swiper-wrapper{flex-wrap:wrap}.swiper-grid-column>.swiper-wrapper{flex-direction:column;flex-wrap:wrap}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false;initial-value:rotateX(0)}@property --tw-rotate-y{syntax:"*";inherits:false;initial-value:rotateY(0)}@property --tw-rotate-z{syntax:"*";inherits:false;initial-value:rotateZ(0)}@property --tw-skew-x{syntax:"*";inherits:false;initial-value:skewX(0)}@property --tw-skew-y{syntax:"*";inherits:false;initial-value:skewY(0)}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --tw-gradient-via-position{syntax:"<length-percentage>";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"<length-percentage>";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes pulse{50%{opacity:.5}}@keyframes float{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-200px)}}',oo=ao.trim().length>0,lo="undefined"!=typeof window&&"adoptedStyleSheets"in Document.prototype&&"undefined"!=typeof CSSStyleSheet&&"replaceSync"in CSSStyleSheet.prototype;let co=null;function uo(e){return co||(co=new CSSStyleSheet,co.replaceSync(e)),co}function ho(){return oo?ao:function(){const e=[];for(const t of Array.from(document.styleSheets))try{e.push(Array.from(t.cssRules).map(e=>e.cssText).join("\n"))}catch(e){}return e.join("\n")}()}const fo=({extra:e})=>{const r=ho()+(e?"\n"+e:"");return t.createElement("style",null,r)};const po=Ba(e=>({open:!1,setOpen:t=>e({open:t})}));function mo(){const[e,s]=t.useState(null),n=r(null),{open:a,setOpen:o}=po();return i(()=>{n.current&&(n.current.style.display=a?"block":"none")},[a]),t.useLayoutEffect(()=>{const e=document.createElement("div");e.style.position="fixed",e.style.inset="0",e.style.zIndex="214748348",e.style.display="none",document.body.appendChild(e),n.current=e;const t=e.attachShadow({mode:"open"});!function(e){const t=ho();if(lo)e.adoptedStyleSheets=[uo(t)];else{const r=document.createElement("style");r.textContent=t,e.appendChild(r)}}(t);const r=document.createElement("style");r.innerHTML="\n .product-dialog-container{\n max-height: 70vh;\n overflow-y: auto;\n width: 100%;\n max-width: min(82vw, 500px) !important;\n }\n ",t.appendChild(r);const i=document.createElement("div");return t.appendChild(i),s(i),()=>e.remove()},[]),{container:e,setOpen:o}}const go=t.createContext(null),vo=e=>{const{isMobile:r}=e,s=Ua(e=>e.setIsPreview),[n,o]=a("collection"in e?e.collection.contents[0]:null);if(i(()=>{var t;const r=Ua.getState().isPreview;return s(null===(t=e.isPreview)||void 0===t||t),()=>{s(r)}},[e.isPreview,s]),r){if("shortform"in e)return t.createElement(to,{shortForm:e.shortform});if(e.collection)return t.createElement(no,{collection:e.collection,playerSettings:e.collection.player.shoppingPlayer})}if("shortform"in e){const{layout:r}=e.shortform.player,i=e.shortform.player.shoppingPlayer;switch(r){case wr.PLATFORM:return t.createElement(_s,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"aspect-[9/16] h-full rounded-xl border overflow-hidden"},t.createElement(to,{shortForm:e.shortform,hideProductCarousel:!0,hideOverlay:!0}))});case wr.HORIZONTAL:return t.createElement(va,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(to,{shortForm:e.shortform,hideProductCarousel:!0}))});case wr.VERTICAL:return t.createElement(ba,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"aspect-[9/16] h-full"},t.createElement(to,{shortForm:e.shortform,hideProductCarousel:!0}))});case wr.GRID:return t.createElement(wa,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(to,{shortForm:e.shortform,hideProductCarousel:!0}))})}}else{if(!e.collection||!n)return null;{const{layout:r}=e.collection.player,i=e.collection.player.shoppingPlayer;switch(r){case wr.PLATFORM:return t.createElement(_s,{shortform:n,playerSettings:i,player:t.createElement("div",{className:"w-full flex items-center justify-center gap-4",style:{height:"calc(-220px + 100vh)"}},t.createElement(Ta,{collection:e.collection,playerSettings:i,shortform:n,setShortform:o}))});case wr.HORIZONTAL:return t.createElement(va,{shortform:n,playerSettings:Object.assign({},i),player:t.createElement(io,{collection:e.collection,playerSettings:i,shortform:n,setShortform:o})});case wr.VERTICAL:return t.createElement(ba,{playerSettings:Object.assign({},i),shortform:n,player:t.createElement(io,{collection:e.collection,playerSettings:i,shortform:n,setShortform:o})});case wr.GRID:return t.createElement(wa,{shortform:n,playerSettings:Object.assign({},i),player:t.createElement(io,{collection:e.collection,playerSettings:i,shortform:n,setShortform:o})})}}}},yo=e=>{const{container:r}=mo();return r?t.createElement(Sr.div,{style:{display:"block",width:"100%",height:"100%"}},t.createElement(fo,null),t.createElement(go.Provider,{value:r},t.createElement(vo,Object.assign({},e)))):null},bo=e=>{const{container:r}=mo();return r?t.createElement(Sr.div,{style:{display:"block",width:"100%",height:"100%"}},t.createElement(fo,null),t.createElement(go.Provider,{value:r},t.createElement(to,Object.assign({},e)))):null},Eo=e=>(document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}),wo=()=>document.visibilityState,So=()=>{throw Error("useVisibilityChange is a client-only hook")};function To(){return"visible"===e.useSyncExternalStore(Eo,wo,So)}var xo=(e,t,s=!0)=>{const n=r(e),a=r(null),o=()=>{a.current&&(clearInterval(a.current),a.current=null)},l=u(()=>{a.current||(a.current=setInterval(()=>n.current(),t))},[t]);return i(()=>{n.current=e},[e]),i(()=>(s&&l(),()=>o()),[l,s]),{clear:o,run:l}};const Ao=()=>{const[e,t]=a(0);xo(()=>{t(e=>e+1)},1e3);return{playtime:e,resetPlaytime:()=>t(0)}},ko=t.createContext(null),Lo=({children:e})=>{const r=t.useRef(null);return r.current||(r.current=Ma(e=>({collection:null,setCollection:t=>e({collection:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})}))),t.createElement(ko.Provider,{value:r.current},e)},Io=()=>(e=>{const r=t.useContext(ko);if(!r)throw new Error("Missing CollectionProvider");return Fa(r,e)})(e=>e),Ro=(e,t)=>{const{collection:r,setCollection:s,isFetching:n,setIsFetching:a,nextKey:o,setNextKey:l}=Io(),{isPreview:c}=Ua(),d=(null==e?void 0:e.media)?e.media.duration.split(":").reduce((e,t,r)=>e+ +t*60**(2-r),0):0;const{resetPlaytime:u,playtime:h}=Ao(),{playtime:f,resetPlaytime:p}=Ao(),m=To(),g=()=>{if(!r)return;const{colId:t,uuid:i,userId:s}=r,n=Ge,a=Math.floor((new Date).getTime()/1e3);localStorage.setItem(n,a.toString()),c||(La({contentId:t,uuid:i,type:wt.COLLECTION,userId:s,playtime:f}),e&&La({contentId:e.shortsId,uuid:e.uuid,type:wt.SHORTS,userId:s,playtime:h,isFinished:h>=d}),p(),u())};i(()=>{m||g()},[m]);return{onSlideChange:i=>x(void 0,void 0,void 0,function*(){if(e&&r&&(yield(e=>x(void 0,void 0,void 0,function*(){var t,i;if(!r)return;const{contents:c,count:d}=r;if((null!=d?d:Number.MAX_SAFE_INTEGER)>c.length&&e>=c.length-5&&!n){a(!0);try{const e=yield Ca({collectionId:r.colId,nextKey:o});if(!e||!(null===(t=e.contents)||void 0===t?void 0:t.length))return;l((null===(i=e.contents.at(-1))||void 0===i?void 0:i.shortsId)||"");const n=new Set(r.contents.map(e=>e.shortsId)),a=e.contents.filter(e=>!n.has(e.shortsId));if(!a.length)return;const c=r.contents.concat(a);s(Object.assign(Object.assign({},r),{contents:c}))}catch(e){console.error(e)}finally{a(!1)}}}))(i),!c)){const{shortsId:s,uuid:n,userId:a}=e;La({contentId:s,uuid:n,type:wt.SHORTS,playtime:h,isFinished:h>=d,userId:a}),u();const o=Lt(),l=r.contents[i];t(Object.assign(Object.assign({},l),{uuid:o})),yield ka({contentId:l.shortsId,uuid:o,type:wt.SHORTS,userId:l.userId,isFirstPlay:!Rt(l.shortsId)})}}),onCollectionClose:g}};function Po(){const[e,t]=a({width:window.innerWidth,height:window.innerHeight});return i(()=>{const e=()=>t({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}const Co=t.memo(({shortform:e,shareUrl:r,handleClose:i})=>t.createElement(t.Fragment,null,t.createElement("div",{onClick:e=>e.stopPropagation(),className:"overflow-hidden",style:{borderRadius:"10px",overflow:"hidden",width:"100%",height:"100%",backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",backgroundImage:`url(${Ct(e.thumbPath)})`}},t.createElement(to,{handleClose:i,shortForm:e,isPopup:!0,shareUrl:r})))),Do=t.memo(({shortform:e})=>t.createElement("div",{onClick:e=>{e.stopPropagation()},style:{width:"100%",height:"100%",borderRadius:"10px",backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",backgroundImage:`url(${e.thumbPath.includes("https")?e.thumbPath:`https://${e.thumbPath}`})`}})),_o=({shortform:e,shareUrl:r,handleClose:i})=>{const{isActive:s}=c(Qn),n=c(Zn),a=Po().width<430||qa.isMobile;return t.createElement("div",{className:"flex items-center justify-center w-full h-full select-none",onClick:e=>{i()}},t.createElement("div",{className:"max-h-full flex items-center justify-center",style:{width:"100%",aspectRatio:a?"auto":"9 / 16",height:a?"100dvh":"auto",maxHeight:a?void 0:"90vh",transform:a?void 0:`scale(${s?1:.8})`,transition:"transform 180ms ease"}},s?t.createElement("div",{className:"flex items-center justify-between w-full h-full text-white relative"},t.createElement("div",{className:"cursor-pointer absolute",onClick:e=>{e.stopPropagation(),n.slidePrev()},style:{zIndex:1e5,left:a?"0":"-30px",top:"50%",transform:"translateY(-50%)",width:30,height:30,display:"grid",placeItems:"center",pointerEvents:"auto"}},t.createElement(Pr,{size:28})),t.createElement(Co,{shortform:e,shareUrl:r,handleClose:i}),t.createElement("div",{className:"cursor-pointer absolute",style:{zIndex:1e5,right:a?"0":"-30px",top:"50%",transform:"translateY(-50%)",width:30,height:30,display:"grid",placeItems:"center",pointerEvents:"auto"},onClick:e=>{e.stopPropagation(),n.slideNext()}},t.createElement(Cr,{size:28}))):t.createElement(Do,{shortform:e})))},Oo=({collection:e,initialShortsId:i,onSlideChange:s,onClosePlayer:n})=>{var a;const{PLAYER_BASE_URL:o}=gt(),l=d(()=>Math.max(e.contents.findIndex(e=>e.shortsId===i),0),[e.contents,i]),c=e.contents.length,u=Math.max(c,10),h=null!==(a=Po().width)&&void 0!==a?a:0,f=h<430||qa.isMobile,p=f?1:h>=1200?4:h>=900?3:2,m=d(()=>(e=>{const t=[...e];for(;t.length<u;)t.push(...e);return t})(e.contents),[e.contents]),g=r(null);return t.createElement("div",{style:{minHeight:100,minWidth:300},className:"w-full"},t.createElement(Jn,{style:{minHeight:100,overflow:"visible"},initialSlide:l,ref:g,lazyPreloadPrevNext:2,className:"w-full",spaceBetween:f?8:h>=1200?24:h>=900?25:16,slidesPerView:p,grabCursor:!0,centeredSlides:1!==p,onSlideChangeTransitionEnd:t=>{const r=t.realIndex%c;null==s||s(r);const i=e.contents[(r+1)%c];var n;n=xt(i.media.objectId),A||(A=document.createElement("video"),A.muted=!0,A.playsInline=!0,A.preload="metadata",A.loop=!0,A.style.cssText="position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;opacity:0",document.body.appendChild(A)),k!==n&&(A.src=n,A.load(),k=n)},loop:!0,slideToClickedSlide:!0},m.map((r,i)=>t.createElement(ea,{key:i},t.createElement(_o,{handleClose:n,shortform:r,shareUrl:`${o}/collection/${e.colId}?start=${r.shortsId}&layout=5`})))))},Mo=({shortform:e,onThumbnailClick:r,iconSize:i,exposeTitle:s,borderLine:n})=>{const a=d(()=>Pt(n),[n])?{background:"linear-gradient(#fff,#fff) padding-box, conic-gradient(#f58529,#f77737,#fd1d1d,#833ab4,#c13584,#f58529) border-box",border:"3px solid transparent"}:{background:"#fff",border:"3px solid #fff"};return t.createElement("div",{className:"flex flex-col w-full gap-2",onClick:()=>r(e.shortsId)},t.createElement("div",{className:"rounded-full overflow-hidden cursor-pointer",style:Object.assign({width:i,height:i,padding:4},a)},t.createElement("img",{src:Ct(e.thumbPath),alt:"thumbnail",className:"w-full h-full object-cover block rounded-full"})),s&&t.createElement("span",{style:{width:i},className:"text-black overflow-hidden text-[12px] whitespace-nowrap text-center text-clip cursor-default"},e.title))},No=({product:e,productLength:r,hideMoreBadge:i=!1,contentId:s,lineClamp:n,showMoreBtn:a=!1,openProductPopup:o})=>{var l;const{isPreview:c}=Ua(),d=t=>{i&&(c?t.preventDefault():Ia({contentProductId:e.eventProductId,contentId:s,productId:e.productId}))},u=t.createElement(t.Fragment,null,t.createElement("span",{className:"product-banner__clip","aria-hidden":!0},t.createElement("span",{className:"product-banner__sheen"})),t.createElement("div",{className:"relative",style:{width:"40%",minWidth:"40%"}},t.createElement("img",{style:{borderRadius:"0.625rem"},className:"aspect-square rounded-lg object-cover w-full",src:Ct(e.thumbPath),alt:e.productName}),!i&&t.createElement("p",{className:"absolute text-white rounded-lg",style:{backgroundColor:"#797979",top:-10,right:-10,padding:"2px 4px",fontSize:"10px",borderRadius:"0.625rem"}},"+",r)),t.createElement("div",{style:{position:"relative",zIndex:2,minWidth:0,flex:1,paddingRight:24}},t.createElement("p",{style:{display:"-webkit-box",WebkitLineClamp:n||2,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word",fontWeight:600,color:"#494949"}},e.productName)),t.createElement("span",{className:"product-banner__arrow","aria-hidden":!0},"›"));return t.createElement(t.Fragment,null,i?t.createElement("a",{href:null!==(l=e.linkPath)&&void 0!==l?l:void 0,target:"_blank",rel:"noopener noreferrer",className:"apphref product-banner border mbus-border",style:{textDecoration:"none",color:"inherit"},onClick:d},u):t.createElement("div",{className:"product-banner border mbus-border",onClick:d},u),a&&r>1&&t.createElement("div",{onClick:o,className:" flex items-center justify-center border mbus-border cursor-pointer",style:{borderRadius:"0.625rem",padding:"10px",backgroundColor:"#f5f5f5",fontWeight:600}},"+ 더보기 (",r,")"))},Fo=({products:e,iconSize:r,contentId:i,setSelectedProducts:s,showMoreBtn:n,hideMoreBadge:a})=>{const{setOpen:o}=po(),l=()=>{s({productsInfo:e,shortsId:i}),o(!0)};return t.createElement(t.Fragment,null,t.createElement("div",{onClick:()=>x(void 0,void 0,void 0,function*(){1===e.length||n||l()}),className:"flex flex-col gap-2 mt-4 text-gray-800",style:{maxWidth:r||"100%",fontSize:13}},t.createElement(No,{showMoreBtn:n,lineClamp:2,product:e[0],contentId:i,productLength:e.length,hideMoreBadge:null!=a?a:1===e.length,openProductPopup:l})))},$o=({product:e,maxWidth:r="100%",height:i,cardWidth:s})=>{const n=Ua(e=>e.memberOnly&&!e.isMemberLoggedIn);return t.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,borderRadius:8,backgroundColor:"#ffffff",color:"#111827",maxWidth:r,height:i,width:"100%",paddingRight:8}},t.createElement("img",{src:Ct(e.thumbPath),alt:e.productName,style:{height:"100%",aspectRatio:"1 / 1",borderRadius:6,objectFit:"cover",flexShrink:0}}),t.createElement("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",justifyContent:"center"}},t.createElement("span",{style:{lineHeight:1.25,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontSize:12}},e.productName),t.createElement("span",{style:{lineHeight:1.25,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontSize:11}},(()=>{if(n)return t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},"판매가 회원 공개");return"number"==typeof e.sellingPrice&&e.sellingPrice<e.price?"number"==typeof s&&s>=190?t.createElement(t.Fragment,null,t.createElement("span",{style:{color:"#dc2626",fontWeight:600,marginRight:4}},Tt(e.sellingPrice,e.currency)),t.createElement("span",{style:{color:"#9ca3af",textDecoration:"line-through"}},Tt(e.price,e.currency))):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},Tt(e.sellingPrice,e.currency)):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},Tt(e.price,e.currency))})())))},Bo=({playUrl:e,poster:r})=>t.createElement("div",{className:"w-full h-full absolute top-0 left-0 z-10 pointer-events-none",style:{backgroundImage:`url(${r})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"}},t.createElement("video",{src:e,autoPlay:!0,muted:!0,preload:"auto",playsInline:!0,loop:!0,className:"w-full h-full object-cover"})),Uo=({shortform:e,onThumbnailClick:r,onPreviewPlay:i,iconSize:s,exposeTitle:n,rounded:o,borderLine:l,titlePosition:c,exposeProductBanner:u,setSelectedProducts:h,iconRatio:f,hoverPlay:p,exposeProductBadge:m})=>{var g;const v=d(()=>Pt(l),[l]),[y,b]=a(!1),{API_BASE_URL:E}=gt();return t.createElement("div",{className:"relative"},t.createElement("div",{onMouseEnter:()=>{b(!0),p&&i(e.shortsId)},onMouseLeave:()=>b(!1),onClick:()=>r(e.shortsId),style:Object.assign({width:s,aspectRatio:f},o&&{borderRadius:"10px"}),className:`cursor-pointer p-[3px] ${o&&"rounded-xl"} ${v&&"bg-insta"} relative overflow-hidden`},y&&p&&t.createElement(Bo,{playUrl:`${E}/direct/${e.media.objectId}`,poster:Ct(e.thumbPath)}),t.createElement("img",{style:Object.assign({},o&&{borderRadius:"10px"}),src:Ct(e.thumbPath),alt:"thumbnail",className:`w-full h-full object-cover ${o&&"rounded-xl"}`}),m&&(null===(g=e.productsInfo)||void 0===g?void 0:g.length)>0&&!(p&&y)&&t.createElement("div",{className:"absolute pointer-events-none flex items-center justify-center z-20",style:{left:2,right:2,bottom:10,height:"20%"}},t.createElement("div",{className:"h-full inline-block",style:{width:"95%"}},t.createElement($o,{product:e.productsInfo[0],maxWidth:"100%",height:"100%",cardWidth:s}))),n&&c===Be.INNER&&!(p&&y)&&t.createElement("p",{style:Object.assign({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},m?{bottom:"22%"}:{}),className:"absolute bottom-0 left-0 w-full my-2 text-white px-2 z-10 text-[12px] cursor-default truncate"},e.title)),n&&c!==Be.INNER&&t.createElement("p",{style:{width:s,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},className:"my-2 text-[12px] cursor-default truncate"},e.title),u&&t.createElement(Fo,{setSelectedProducts:h,products:e.productsInfo,iconSize:s,contentId:e.shortsId}))},zo=e=>{const{iconShape:r,collection:i}=e;return r===Ne.MANY?t.createElement(Go,Object.assign({},e)):t.createElement(jo,Object.assign({},e,{shortform:i.contents[0]}))},Go=e=>{const{collection:r}=e,{thumbnailAutoPlay:i}=e,{setCollection:s,nextKey:n,setNextKey:a,isFetching:o,setIsFetching:l}=Io();return t.createElement(Jn,{freeMode:!0,slidesPerView:"auto",spaceBetween:12,onReachEnd:()=>x(void 0,void 0,void 0,function*(){var e,t,i;if(r&&!(o||(null!==(e=r.count)&&void 0!==e?e:Number.MAX_SAFE_INTEGER)<=r.contents.length)){l(!0);try{const e=yield Ca({collectionId:r.colId,nextKey:n});if(!e||!(null===(t=e.contents)||void 0===t?void 0:t.length))return;a((null===(i=e.contents.at(-1))||void 0===i?void 0:i.shortsId)||"");const o=new Set(r.contents.map(e=>e.shortsId)),l=e.contents.filter(e=>!o.has(e.shortsId));if(!l.length)return;s(Object.assign(Object.assign({},r),{contents:[...r.contents,...l]}))}catch(e){console.error(e)}finally{l(!1)}}}),modules:i?[ia]:[],autoplay:!!i&&{delay:3e3,disableOnInteraction:!1,pauseOnMouseEnter:!0},loop:i||void 0},null==r?void 0:r.contents.map(r=>t.createElement(ea,{key:r.shortsId,className:"!w-auto"},t.createElement(jo,Object.assign({},e,{shortform:r})))))},jo=e=>{const{iconForm:r}=e;return r===Me.INSTA?t.createElement(Mo,Object.assign({},e)):t.createElement(Uo,Object.assign({},e))};function Ho(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function Vo(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Wo(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Vo(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():Vo(e[t],null)}}}}function Yo(...t){return e.useCallback(Wo(...t),t)}function Ko(...t){const r=t[0];if(1===t.length)return r;const i=()=>{const i=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const s=i.reduce((e,{useScope:r,scopeName:i})=>({...e,...r(t)[`__scope${i}`]}),{});return e.useMemo(()=>({[`__scope${r.scopeName}`]:s}),[s])}};return i.scopeName=r.scopeName,i}var qo=globalThis?.document?e.useLayoutEffect:()=>{},Xo=e[" useId ".trim().toString()]||(()=>{}),Qo=0;function Zo(t){const[r,i]=e.useState(Xo());return qo(()=>{t||i(e=>e??String(Qo++))},[t]),t||(r?`radix-${r}`:"")}var Jo=e[" useInsertionEffect ".trim().toString()]||qo;function el({prop:t,defaultProp:r,onChange:i=()=>{},caller:s}){const[n,a,o]=function({defaultProp:t,onChange:r}){const[i,s]=e.useState(t),n=e.useRef(i),a=e.useRef(r);return Jo(()=>{a.current=r},[r]),e.useEffect(()=>{n.current!==i&&(a.current?.(i),n.current=i)},[i,n]),[i,s,a]}({defaultProp:r,onChange:i}),l=void 0!==t,c=l?t:n;{const r=e.useRef(void 0!==t);e.useEffect(()=>{const e=r.current;if(e!==l){const t=e?"controlled":"uncontrolled",r=l?"controlled":"uncontrolled";console.warn(`${s} is changing from ${t} to ${r}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}r.current=l},[l,s])}const d=e.useCallback(e=>{if(l){const r=function(e){return"function"==typeof e}(e)?e(t):e;r!==t&&o.current?.(r)}else a(e)},[l,t,a,o]);return[c,d]}function tl(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function rl(t){const r=il(t),i=e.forwardRef((t,i)=>{const{children:s,...n}=t,a=e.Children.toArray(s),o=a.find(nl);if(o){const t=o.props.children,s=a.map(r=>r===o?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(r,{...n,ref:i,children:e.isValidElement(t)?e.cloneElement(t,void 0,s):null})}return b(r,{...n,ref:i,children:s})});return i.displayName=`${t}.Slot`,i}function il(t){const r=e.forwardRef((t,r)=>{const{children:i,...s}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),n=function(e,t){const r={...t};for(const i in t){const s=e[i],n=t[i];/^on[A-Z]/.test(i)?s&&n?r[i]=(...e)=>{const t=n(...e);return s(...e),t}:s&&(r[i]=s):"style"===i?r[i]={...s,...n}:"className"===i&&(r[i]=[s,n].filter(Boolean).join(" "))}return{...e,...r}}(s,i.props);return i.type!==e.Fragment&&(n.ref=r?Wo(r,t):t),e.cloneElement(i,n)}return e.Children.count(i)>1?e.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}var sl=Symbol("radix.slottable");function nl(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===sl}var al=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=rl(`Primitive.${r}`),s=e.forwardRef((e,t)=>{const{asChild:s,...n}=e,a=s?i:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(a,{...n,ref:t})});return s.displayName=`Primitive.${r}`,{...t,[r]:s}},{});function ol(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}var ll,cl="dismissableLayer.update",dl="dismissableLayer.pointerDownOutside",ul="dismissableLayer.focusOutside",hl=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),fl=e.forwardRef((t,r)=>{const{disableOutsidePointerEvents:i=!1,onEscapeKeyDown:s,onPointerDownOutside:n,onFocusOutside:a,onInteractOutside:o,onDismiss:l,...c}=t,d=e.useContext(hl),[u,h]=e.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=e.useState({}),m=Yo(r,e=>h(e)),g=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(v),E=u?g.indexOf(u):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,S=E>=y,T=function(t,r=globalThis?.document){const i=ol(t),s=e.useRef(!1),n=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!s.current){let t=function(){ml(dl,i,s,{discrete:!0})};const s={originalEvent:e};"touch"===e.pointerType?(r.removeEventListener("click",n.current),n.current=t,r.addEventListener("click",n.current,{once:!0})):t()}else r.removeEventListener("click",n.current);s.current=!1},t=window.setTimeout(()=>{r.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),r.removeEventListener("pointerdown",e),r.removeEventListener("click",n.current)}},[r,i]),{onPointerDownCapture:()=>s.current=!0}}(e=>{const t=e.target,r=[...d.branches].some(e=>e.contains(t));S&&!r&&(n?.(e),o?.(e),e.defaultPrevented||l?.())},f),x=function(t,r=globalThis?.document){const i=ol(t),s=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!s.current){ml(ul,i,{originalEvent:e},{discrete:!1})}};return r.addEventListener("focusin",e),()=>r.removeEventListener("focusin",e)},[r,i]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}(e=>{const t=e.target;[...d.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||l?.())},f);return function(t,r=globalThis?.document){const i=ol(t);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&i(e)};return r.addEventListener("keydown",e,{capture:!0}),()=>r.removeEventListener("keydown",e,{capture:!0})},[i,r])}(e=>{E===d.layers.size-1&&(s?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),e.useEffect(()=>{if(u)return i&&(0===d.layersWithOutsidePointerEventsDisabled.size&&(ll=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(u)),d.layers.add(u),pl(),()=>{i&&1===d.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=ll)}},[u,f,i,d]),e.useEffect(()=>()=>{u&&(d.layers.delete(u),d.layersWithOutsidePointerEventsDisabled.delete(u),pl())},[u,d]),e.useEffect(()=>{const e=()=>p({});return document.addEventListener(cl,e),()=>document.removeEventListener(cl,e)},[]),b(al.div,{...c,ref:m,style:{pointerEvents:w?S?"auto":"none":void 0,...t.style},onFocusCapture:tl(t.onFocusCapture,x.onFocusCapture),onBlurCapture:tl(t.onBlurCapture,x.onBlurCapture),onPointerDownCapture:tl(t.onPointerDownCapture,T.onPointerDownCapture)})});fl.displayName="DismissableLayer";function pl(){const e=new CustomEvent(cl);document.dispatchEvent(e)}function ml(e,t,r,{discrete:i}){const s=r.originalEvent.target,n=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&s.addEventListener(e,t,{once:!0}),i?function(e,t){e&&p.flushSync(()=>e.dispatchEvent(t))}(s,n):s.dispatchEvent(n)}e.forwardRef((t,r)=>{const i=e.useContext(hl),s=e.useRef(null),n=Yo(r,s);return e.useEffect(()=>{const e=s.current;if(e)return i.branches.add(e),()=>{i.branches.delete(e)}},[i.branches]),b(al.div,{...t,ref:n})}).displayName="DismissableLayerBranch";var gl="focusScope.autoFocusOnMount",vl="focusScope.autoFocusOnUnmount",yl={bubbles:!1,cancelable:!0},bl=e.forwardRef((t,r)=>{const{loop:i=!1,trapped:s=!1,onMountAutoFocus:n,onUnmountAutoFocus:a,...o}=t,[l,c]=e.useState(null),d=ol(n),u=ol(a),h=e.useRef(null),f=Yo(r,e=>c(e)),p=e.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;e.useEffect(()=>{if(s){let e=function(e){if(p.paused||!l)return;const t=e.target;l.contains(t)?h.current=t:Tl(h.current,{select:!0})},t=function(e){if(p.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||Tl(h.current,{select:!0}))},r=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&Tl(l)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const i=new MutationObserver(r);return l&&i.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),i.disconnect()}}},[s,l,p.paused]),e.useEffect(()=>{if(l){xl.add(p);const t=document.activeElement;if(!l.contains(t)){const r=new CustomEvent(gl,yl);l.addEventListener(gl,d),l.dispatchEvent(r),r.defaultPrevented||(!function(e,{select:t=!1}={}){const r=document.activeElement;for(const i of e)if(Tl(i,{select:t}),document.activeElement!==r)return}((e=El(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&Tl(l))}return()=>{l.removeEventListener(gl,d),setTimeout(()=>{const e=new CustomEvent(vl,yl);l.addEventListener(vl,u),l.dispatchEvent(e),e.defaultPrevented||Tl(t??document.body,{select:!0}),l.removeEventListener(vl,u),xl.remove(p)},0)}}var e},[l,d,u,p]);const m=e.useCallback(e=>{if(!i&&!s)return;if(p.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,r=document.activeElement;if(t&&r){const t=e.currentTarget,[s,n]=function(e){const t=El(e),r=wl(t,e),i=wl(t.reverse(),e);return[r,i]}(t);s&&n?e.shiftKey||r!==n?e.shiftKey&&r===s&&(e.preventDefault(),i&&Tl(n,{select:!0})):(e.preventDefault(),i&&Tl(s,{select:!0})):r===t&&e.preventDefault()}},[i,s,p.paused]);return b(al.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});function El(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function wl(e,t){for(const r of e)if(!Sl(r,{upTo:t}))return r}function Sl(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function Tl(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}bl.displayName="FocusScope";var xl=function(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=Al(e,t),e.unshift(t)},remove(t){e=Al(e,t),e[0]?.resume()}}}();function Al(e,t){const r=[...e],i=r.indexOf(t);return-1!==i&&r.splice(i,1),r}var kl=e.forwardRef((t,r)=>{const{container:i,...s}=t,[n,a]=e.useState(!1);qo(()=>a(!0),[]);const o=i||n&&globalThis?.document?.body;return o?m.createPortal(b(al.div,{...s,ref:r}),o):null});kl.displayName="Portal";var Ll=t=>{const{present:r,children:i}=t,s=function(t){const[r,i]=e.useState(),s=e.useRef(null),n=e.useRef(t),a=e.useRef("none"),o=t?"mounted":"unmounted",[l,c]=function(t,r){return e.useReducer((e,t)=>r[e][t]??e,t)}(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=Il(s.current);a.current="mounted"===l?e:"none"},[l]),qo(()=>{const e=s.current,r=n.current;if(r!==t){const i=a.current,s=Il(e);if(t)c("MOUNT");else if("none"===s||"none"===e?.display)c("UNMOUNT");else{c(r&&i!==s?"ANIMATION_OUT":"UNMOUNT")}n.current=t}},[t,c]),qo(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=Il(s.current).includes(CSS.escape(i.animationName));if(i.target===r&&a&&(c("ANIMATION_END"),!n.current)){const i=r.style.animationFillMode;r.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===r.style.animationFillMode&&(r.style.animationFillMode=i)})}},o=e=>{e.target===r&&(a.current=Il(s.current))};return r.addEventListener("animationstart",o),r.addEventListener("animationcancel",i),r.addEventListener("animationend",i),()=>{t.clearTimeout(e),r.removeEventListener("animationstart",o),r.removeEventListener("animationcancel",i),r.removeEventListener("animationend",i)}}c("ANIMATION_END")},[r,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{s.current=e?getComputedStyle(e):null,i(e)},[])}}(r),n="function"==typeof i?i({present:s.isPresent}):e.Children.only(i),a=Yo(s.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(n));return"function"==typeof i||s.isPresent?e.cloneElement(n,{ref:a}):null};function Il(e){return e?.animationName||"none"}Ll.displayName="Presence";var Rl=0;function Pl(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Cl="right-scroll-bar-position",Dl="width-before-scroll-bar";function _l(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var Ol="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,Ml=new WeakMap;function Nl(e,t){var r,i,s,n=(r=null,i=function(t){return e.forEach(function(e){return _l(e,t)})},(s=a(function(){return{value:r,callback:i,facade:{get current(){return s.value},set current(e){var t=s.value;t!==e&&(s.value=e,s.callback(e,t))}}}})[0]).callback=i,s.facade);return Ol(function(){var t=Ml.get(n);if(t){var r=new Set(t),i=new Set(e),s=n.current;r.forEach(function(e){i.has(e)||_l(e,null)}),i.forEach(function(e){r.has(e)||_l(e,s)})}Ml.set(n,e)},[e]),n}function Fl(e){return e}var $l=function(t){var r=t.sideCar,i=T(t,["sideCar"]);if(!r)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=r.read();if(!s)throw new Error("Sidecar medium not found");return e.createElement(s,S({},i))};$l.isSideCarExport=!0;var Bl=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=Fl);var r=[],i=!1,s={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(e){var s=t(e,i);return r.push(s),function(){r=r.filter(function(e){return e!==s})}},assignSyncMedium:function(e){for(i=!0;r.length;){var t=r;r=[],t.forEach(e)}r={push:function(t){return e(t)},filter:function(){return r}}},assignMedium:function(e){i=!0;var t=[];if(r.length){var s=r;r=[],s.forEach(e),t=r}var n=function(){var r=t;t=[],r.forEach(e)},a=function(){return Promise.resolve().then(n)};a(),r={push:function(e){t.push(e),a()},filter:function(e){return t=t.filter(e),r}}}};return s}(null);return t.options=S({async:!0,ssr:!1},e),t}(),Ul=function(){},zl=e.forwardRef(function(t,r){var i=e.useRef(null),s=e.useState({onScrollCapture:Ul,onWheelCapture:Ul,onTouchMoveCapture:Ul}),n=s[0],a=s[1],o=t.forwardProps,l=t.children,c=t.className,d=t.removeScrollBar,u=t.enabled,h=t.shards,f=t.sideCar,p=t.noRelative,m=t.noIsolation,g=t.inert,v=t.allowPinchZoom,y=t.as,b=void 0===y?"div":y,E=t.gapMode,w=T(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),x=f,A=Nl([i,r]),k=S(S({},w),n);return e.createElement(e.Fragment,null,u&&e.createElement(x,{sideCar:Bl,removeScrollBar:d,shards:h,noRelative:p,noIsolation:m,inert:g,setCallbacks:a,allowPinchZoom:!!v,lockRef:i,gapMode:E}),o?e.cloneElement(e.Children.only(l),S(S({},k),{ref:A})):e.createElement(b,S({},k,{className:c,ref:A}),l))});zl.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},zl.classNames={fullWidth:Dl,zeroRight:Cl};function Gl(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var jl=function(){var e=0,t=null;return{add:function(r){var i,s;0==e&&(t=Gl())&&(s=r,(i=t).styleSheet?i.styleSheet.cssText=s:i.appendChild(document.createTextNode(s)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Hl=function(){var t,r=(t=jl(),function(r,i){e.useEffect(function(){return t.add(r),function(){t.remove()}},[r&&i])});return function(e){var t=e.styles,i=e.dynamic;return r(t,i),null}},Vl={left:0,top:0,right:0,gap:0},Wl=function(e){return parseInt(e||"",10)||0},Yl=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return Vl;var t=function(e){var t=window.getComputedStyle(document.body),r=t["padding"===e?"paddingLeft":"marginLeft"],i=t["padding"===e?"paddingTop":"marginTop"],s=t["padding"===e?"paddingRight":"marginRight"];return[Wl(r),Wl(i),Wl(s)]}(e),r=document.documentElement.clientWidth,i=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,i-r+t[2]-t[0])}},Kl=Hl(),ql="data-scroll-locked",Xl=function(e,t,r,i){var s=e.left,n=e.top,a=e.right,o=e.gap;return void 0===r&&(r="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(i,";\n padding-right: ").concat(o,"px ").concat(i,";\n }\n body[").concat(ql,"] {\n overflow: hidden ").concat(i,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(i,";"),"margin"===r&&"\n padding-left: ".concat(s,"px;\n padding-top: ").concat(n,"px;\n padding-right: ").concat(a,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(o,"px ").concat(i,";\n "),"padding"===r&&"padding-right: ".concat(o,"px ").concat(i,";")].filter(Boolean).join(""),"\n }\n \n .").concat(Cl," {\n right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat(Dl," {\n margin-right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat(Cl," .").concat(Cl," {\n right: 0 ").concat(i,";\n }\n \n .").concat(Dl," .").concat(Dl," {\n margin-right: 0 ").concat(i,";\n }\n \n body[").concat(ql,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(o,"px;\n }\n")},Ql=function(){var e=parseInt(document.body.getAttribute(ql)||"0",10);return isFinite(e)?e:0},Zl=function(t){var r=t.noRelative,i=t.noImportant,s=t.gapMode,n=void 0===s?"margin":s;e.useEffect(function(){return document.body.setAttribute(ql,(Ql()+1).toString()),function(){var e=Ql()-1;e<=0?document.body.removeAttribute(ql):document.body.setAttribute(ql,e.toString())}},[]);var a=e.useMemo(function(){return Yl(n)},[n]);return e.createElement(Kl,{styles:Xl(a,!r,n,i?"":"!important")})},Jl=!1;if("undefined"!=typeof window)try{var ec=Object.defineProperty({},"passive",{get:function(){return Jl=!0,!0}});window.addEventListener("test",ec,ec),window.removeEventListener("test",ec,ec)}catch(e){Jl=!1}var tc=!!Jl&&{passive:!1},rc=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return"hidden"!==r[t]&&!(r.overflowY===r.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===r[t])},ic=function(e,t){var r=t.ownerDocument,i=t;do{if("undefined"!=typeof ShadowRoot&&i instanceof ShadowRoot&&(i=i.host),sc(e,i)){var s=nc(e,i);if(s[1]>s[2])return!0}i=i.parentNode}while(i&&i!==r.body);return!1},sc=function(e,t){return"v"===e?function(e){return rc(e,"overflowY")}(t):function(e){return rc(e,"overflowX")}(t)},nc=function(e,t){return"v"===e?[(r=t).scrollTop,r.scrollHeight,r.clientHeight]:function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t);var r},ac=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},oc=function(e){return[e.deltaX,e.deltaY]},lc=function(e){return e&&"current"in e?e.current:e},cc=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},dc=0,uc=[];function hc(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var fc,pc=(fc=function(t){var r=e.useRef([]),i=e.useRef([0,0]),s=e.useRef(),n=e.useState(dc++)[0],a=e.useState(Hl)[0],o=e.useRef(t);e.useEffect(function(){o.current=t},[t]),e.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(n));var e=function(e,t,r){if(r||2===arguments.length)for(var i,s=0,n=t.length;s<n;s++)!i&&s in t||(i||(i=Array.prototype.slice.call(t,0,s)),i[s]=t[s]);return e.concat(i||Array.prototype.slice.call(t))}([t.lockRef.current],(t.shards||[]).map(lc),!0).filter(Boolean);return e.forEach(function(e){return e.classList.add("allow-interactivity-".concat(n))}),function(){document.body.classList.remove("block-interactivity-".concat(n)),e.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(n))})}}},[t.inert,t.lockRef.current,t.shards]);var l=e.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!o.current.allowPinchZoom;var r,n=ac(e),a=i.current,l="deltaX"in e?e.deltaX:a[0]-n[0],c="deltaY"in e?e.deltaY:a[1]-n[1],d=e.target,u=Math.abs(l)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===u&&"range"===d.type)return!1;var h=ic(u,d);if(!h)return!0;if(h?r=u:(r="v"===u?"h":"v",h=ic(u,d)),!h)return!1;if(!s.current&&"changedTouches"in e&&(l||c)&&(s.current=r),!r)return!0;var f=s.current||r;return function(e,t,r,i,s){var n=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),a=n*i,o=r.target,l=t.contains(o),c=!1,d=a>0,u=0,h=0;do{if(!o)break;var f=nc(e,o),p=f[0],m=f[1]-f[2]-n*p;(p||m)&&sc(e,o)&&(u+=m,h+=p);var g=o.parentNode;o=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!l&&o!==document.body||l&&(t.contains(o)||t===o));return d&&(Math.abs(u)<1||!s)?c=!0:d||!(Math.abs(h)<1)&&s||(c=!0),c}(f,t,e,"h"===f?l:c,!0)},[]),c=e.useCallback(function(e){var t=e;if(uc.length&&uc[uc.length-1]===a){var i="deltaY"in t?oc(t):ac(t),s=r.current.filter(function(e){return e.name===t.type&&(e.target===t.target||t.target===e.shadowParent)&&function(e,t){return e[0]===t[0]&&e[1]===t[1]}(e.delta,i)})[0];if(s&&s.should)t.cancelable&&t.preventDefault();else if(!s){var n=(o.current.shards||[]).map(lc).filter(Boolean).filter(function(e){return e.contains(t.target)});(n.length>0?l(t,n[0]):!o.current.noIsolation)&&t.cancelable&&t.preventDefault()}}},[]),d=e.useCallback(function(e,t,i,s){var n={name:e,delta:t,target:i,should:s,shadowParent:hc(i)};r.current.push(n),setTimeout(function(){r.current=r.current.filter(function(e){return e!==n})},1)},[]),u=e.useCallback(function(e){i.current=ac(e),s.current=void 0},[]),h=e.useCallback(function(e){d(e.type,oc(e),e.target,l(e,t.lockRef.current))},[]),f=e.useCallback(function(e){d(e.type,ac(e),e.target,l(e,t.lockRef.current))},[]);e.useEffect(function(){return uc.push(a),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",c,tc),document.addEventListener("touchmove",c,tc),document.addEventListener("touchstart",u,tc),function(){uc=uc.filter(function(e){return e!==a}),document.removeEventListener("wheel",c,tc),document.removeEventListener("touchmove",c,tc),document.removeEventListener("touchstart",u,tc)}},[]);var p=t.removeScrollBar,m=t.inert;return e.createElement(e.Fragment,null,m?e.createElement(a,{styles:cc(n)}):null,p?e.createElement(Zl,{noRelative:t.noRelative,gapMode:t.gapMode}):null)},Bl.useMedium(fc),$l),mc=e.forwardRef(function(t,r){return e.createElement(zl,S({},t,{ref:r,sideCar:pc}))});mc.classNames=zl.classNames;var gc=new WeakMap,vc=new WeakMap,yc={},bc=0,Ec=function(e){return e&&(e.host||Ec(e.parentNode))},wc=function(e,t,r,i){var s=function(e,t){return t.map(function(t){if(e.contains(t))return t;var r=Ec(t);return r&&e.contains(r)?r:(console.error("aria-hidden",t,"in not contained inside",e,". Doing nothing"),null)}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);yc[r]||(yc[r]=new WeakMap);var n=yc[r],a=[],o=new Set,l=new Set(s),c=function(e){e&&!o.has(e)&&(o.add(e),c(e.parentNode))};s.forEach(c);var d=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(o.has(e))d(e);else try{var t=e.getAttribute(i),s=null!==t&&"false"!==t,l=(gc.get(e)||0)+1,c=(n.get(e)||0)+1;gc.set(e,l),n.set(e,c),a.push(e),1===l&&s&&vc.set(e,!0),1===c&&e.setAttribute(r,"true"),s||e.setAttribute(i,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return d(t),o.clear(),bc++,function(){a.forEach(function(e){var t=gc.get(e)-1,s=n.get(e)-1;gc.set(e,t),n.set(e,s),t||(vc.has(e)||e.removeAttribute(i),vc.delete(e)),s||e.removeAttribute(r)}),--bc||(gc=new WeakMap,gc=new WeakMap,vc=new WeakMap,yc={})}},Sc=function(e,t,r){void 0===r&&(r="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),s=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return s?(i.push.apply(i,Array.from(s.querySelectorAll("[aria-live], script"))),wc(i,s,r,"aria-hidden")):function(){return null}},Tc="Dialog",[xc,Ac]=function(t,r=[]){let i=[];const s=()=>{const r=i.map(t=>e.createContext(t));return function(i){const s=i?.[t]||r;return e.useMemo(()=>({[`__scope${t}`]:{...i,[t]:s}}),[i,s])}};return s.scopeName=t,[function(r,s){const n=e.createContext(s),a=i.length;i=[...i,s];const o=r=>{const{scope:i,children:s,...o}=r,l=i?.[t]?.[a]||n,c=e.useMemo(()=>o,Object.values(o));return b(l.Provider,{value:c,children:s})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||n,c=e.useContext(l);if(c)return c;if(void 0!==s)return s;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},Ko(s,...r)]}(Tc),[kc,Lc]=xc(Tc),Ic=t=>{const{__scopeDialog:r,children:i,open:s,defaultOpen:n,onOpenChange:a,modal:o=!0}=t,l=e.useRef(null),c=e.useRef(null),[d,u]=el({prop:s,defaultProp:n??!1,onChange:a,caller:Tc});return b(kc,{scope:r,triggerRef:l,contentRef:c,contentId:Zo(),titleId:Zo(),descriptionId:Zo(),open:d,onOpenChange:u,onOpenToggle:e.useCallback(()=>u(e=>!e),[u]),modal:o,children:i})};Ic.displayName=Tc;var Rc="DialogTrigger";e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,s=Lc(Rc,r),n=Yo(t,s.triggerRef);return b(al.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":qc(s.open),...i,ref:n,onClick:Ho(e.onClick,s.onOpenToggle)})}).displayName=Rc;var Pc="DialogPortal",[Cc,Dc]=xc(Pc,{forceMount:void 0}),_c=t=>{const{__scopeDialog:r,forceMount:i,children:s,container:n}=t,a=Lc(Pc,r);return b(Cc,{scope:r,forceMount:i,children:e.Children.map(s,e=>b(Ll,{present:i||a.open,children:b(kl,{asChild:!0,container:n,children:e})}))})};_c.displayName=Pc;var Oc="DialogOverlay",Mc=e.forwardRef((e,t)=>{const r=Dc(Oc,e.__scopeDialog),{forceMount:i=r.forceMount,...s}=e,n=Lc(Oc,e.__scopeDialog);return n.modal?b(Ll,{present:i||n.open,children:b(Fc,{...s,ref:t})}):null});Mc.displayName=Oc;var Nc=rl("DialogOverlay.RemoveScroll"),Fc=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,s=Lc(Oc,r);return b(mc,{as:Nc,allowPinchZoom:!0,shards:[s.contentRef],children:b(al.div,{"data-state":qc(s.open),...i,ref:t,style:{pointerEvents:"auto",...i.style}})})}),$c="DialogContent",Bc=e.forwardRef((e,t)=>{const r=Dc($c,e.__scopeDialog),{forceMount:i=r.forceMount,...s}=e,n=Lc($c,e.__scopeDialog);return b(Ll,{present:i||n.open,children:n.modal?b(Uc,{...s,ref:t}):b(zc,{...s,ref:t})})});Bc.displayName=$c;var Uc=e.forwardRef((t,r)=>{const i=Lc($c,t.__scopeDialog),s=e.useRef(null),n=Yo(r,i.contentRef,s);return e.useEffect(()=>{const e=s.current;if(e)return Sc(e)},[]),b(Gc,{...t,ref:n,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ho(t.onCloseAutoFocus,e=>{e.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:Ho(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;(2===t.button||r)&&e.preventDefault()}),onFocusOutside:Ho(t.onFocusOutside,e=>e.preventDefault())})}),zc=e.forwardRef((t,r)=>{const i=Lc($c,t.__scopeDialog),s=e.useRef(!1),n=e.useRef(!1);return b(Gc,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),e.defaultPrevented||(s.current||i.triggerRef.current?.focus(),e.preventDefault()),s.current=!1,n.current=!1},onInteractOutside:e=>{t.onInteractOutside?.(e),e.defaultPrevented||(s.current=!0,"pointerdown"===e.detail.originalEvent.type&&(n.current=!0));const r=e.target,a=i.triggerRef.current?.contains(r);a&&e.preventDefault(),"focusin"===e.detail.originalEvent.type&&n.current&&e.preventDefault()}})}),Gc=e.forwardRef((t,r)=>{const{__scopeDialog:i,trapFocus:s,onOpenAutoFocus:n,onCloseAutoFocus:a,...o}=t,l=Lc($c,i),c=e.useRef(null),d=Yo(r,c);return e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Pl()),document.body.insertAdjacentElement("beforeend",e[1]??Pl()),Rl++,()=>{1===Rl&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Rl--}},[]),w(E,{children:[b(bl,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:n,onUnmountAutoFocus:a,children:b(fl,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":qc(l.open),...o,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),w(E,{children:[b(Jc,{titleId:l.titleId}),b(ed,{contentRef:c,descriptionId:l.descriptionId})]})]})}),jc="DialogTitle",Hc=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,s=Lc(jc,r);return b(al.h2,{id:s.titleId,...i,ref:t})});Hc.displayName=jc;var Vc="DialogDescription",Wc=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,s=Lc(Vc,r);return b(al.p,{id:s.descriptionId,...i,ref:t})});Wc.displayName=Vc;var Yc="DialogClose",Kc=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,s=Lc(Yc,r);return b(al.button,{type:"button",...i,ref:t,onClick:Ho(e.onClick,()=>s.onOpenChange(!1))})});function qc(e){return e?"open":"closed"}Kc.displayName=Yc;var Xc="DialogTitleWarning",[Qc,Zc]=function(t,r){const i=e.createContext(r),s=t=>{const{children:r,...s}=t,n=e.useMemo(()=>s,Object.values(s));return b(i.Provider,{value:n,children:r})};return s.displayName=t+"Provider",[s,function(s){const n=e.useContext(i);if(n)return n;if(void 0!==r)return r;throw new Error(`\`${s}\` must be used within \`${t}\``)}]}(Xc,{contentName:$c,titleName:jc,docsSlug:"dialog"}),Jc=({titleId:t})=>{const r=Zc(Xc),i=`\`${r.contentName}\` requires a \`${r.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return e.useEffect(()=>{if(t){document.getElementById(t)||console.error(i)}},[i,t]),null},ed=({contentRef:t,descriptionId:r})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Zc("DialogDescriptionWarning").contentName}}.`;return e.useEffect(()=>{const e=t.current?.getAttribute("aria-describedby");if(r&&e){document.getElementById(r)||console.warn(i)}},[i,t,r]),null},td=Ic,rd=_c,id=Mc,sd=Bc,nd=Hc,ad=Kc;function od(t){return e.createElement(td,Object.assign({"data-slot":"dialog"},t))}function ld(t){var r=T(t,[]);return e.createElement(rd,Object.assign({"data-slot":"dialog-portal"},r))}function cd(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(id,Object.assign({"data-slot":"dialog-overlay",className:St("fixed inset-0 z-50 bg-black/50",r)},i))}function dd(t){var{className:r,children:i,showCloseButton:s=!0,container:n}=t,a=T(t,["className","children","showCloseButton","container"]);return e.createElement(ld,{"data-slot":"dialog-portal",container:n},e.createElement(cd,null),e.createElement(sd,Object.assign({"data-slot":"dialog-content",style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",outline:"none"},className:St("fixed","z-50 grid w-full max-w-lg sm:mx-0 gap-4 p-6",r)},a),i,s&&e.createElement(ad,{"data-slot":"dialog-close",style:{right:"calc(var(--spacing) * 4)",top:"calc(var(--spacing) * 4)",outline:"none"},className:St("absolute right-4 top-4 rounded opacity-70 transition-opacity","hover:opacity-100 focus:outline-none","focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background","disabled:pointer-events-none"),"aria-label":"Close"},e.createElement(zr,{className:"h-4 w-4 pointer-events-none shrink-0",style:{height:"calc(var(--spacing) * 4)",width:"calc(var(--spacing) * 4)"}}))))}function ud(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({"data-slot":"dialog-header",className:St("flex flex-col gap-2 text-left",r)},i))}function hd(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(nd,Object.assign({"data-slot":"dialog-title",className:St("text-lg leading-none font-semibold",r)},i))}function fd({title:e,children:r,contentClassName:i,hideCloseButton:s=!1,portalContainer:n,description:a}){const{open:o,setOpen:l}=po();return t.createElement(od,{open:o,onOpenChange:l},t.createElement(dd,{container:n,className:i,showCloseButton:!s},e&&t.createElement(ud,null,t.createElement(hd,{style:{color:"#494949"}},e||""),t.createElement(Wc,{style:{color:"#5e5e5e",fontSize:"12.5px"}},a||"")),r))}const pd=({products:e,contentId:r})=>{const i=Po().width<430||qa.isMobile;return t.createElement("div",{onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),className:"grid gap-2 "+(i?"grid-cols-1":"grid-cols-2"),style:{fontSize:13}},e.map(i=>t.createElement(No,{key:i.productId,product:i,hideMoreBadge:!0,productLength:e.length,contentId:r})))},md=({widgetPlayerOption:e,setCollectionUuid:s,portalContainer:n})=>{const{PLAYER_BASE_URL:o}=gt(),{player:l}=e,[c,d]=a(null),{collection:h}=Io(),{isPreview:f}=Ua(),{onSlideChange:p,onCollectionClose:m}=Ro(c,d),g=r(null),v=r(new Set),y=u(e=>{f||h&&(v.current.has(e)||(v.current.add(e),ka({contentId:e,uuid:Lt(),type:wt.SHORTS,userId:h.userId,isFirstPlay:!It(e)}).catch(e=>console.error("Error joining shorts PV:",e))))},[f,h]);i(()=>{if(f)return;if(!h)return;if(g.current===h.colId)return;g.current=h.colId;const e=Lt();s(e),ka({contentId:h.colId,uuid:e,type:wt.COLLECTION,userId:h.userId,isFirstPlay:!Rt(h.colId)}).catch(e=>console.error("Error joining collection PV:",e))},[f,null==h?void 0:h.colId]);const{setOpen:b,open:E}=po();i(()=>{E||(c&&(m(),d(null)),w&&S(null))},[E]);const[w,S]=a();return t.createElement(t.Fragment,null,h&&t.createElement(zo,Object.assign({collection:h},e,{onThumbnailClick:e=>x(void 0,void 0,void 0,function*(){if(l===$e.POPUP){const t=Lt();if(d(Object.assign(Object.assign({},h.contents.find(t=>t.shortsId===e)),{uuid:t})),b(!0),f)return;try{yield ka({contentId:e,uuid:t,type:wt.SHORTS,userId:h.userId,isFirstPlay:!Rt(e)})}catch(e){console.error("Error joining shorts PV:",e)}}else{const t=(e=>{switch(e){case $e.HORIZONTAL:return Ue.HORIZONTAL;case $e.VERTICAL:return Ue.VERTICAL;case $e.GRID:return Ue.PRODUCTS;case $e.TABLET:return Ue.TABLET;default:return Ue.PLATFORM}})(l),r=null==h?void 0:h.contents.findIndex(t=>t.shortsId===e);let i="";r&&(i=(null==h?void 0:h.contents[r-1].shortsId)||"");const s=new URLSearchParams(Object.assign(Object.assign({},i&&{nextKey:i}),{layout:String(t)}));open(`${o}/collection/${h.colId}?${s.toString()}`)}}),onPreviewPlay:y,setSelectedProducts:S})),w&&t.createElement(fd,{portalContainer:n,title:"상품 목록",contentClassName:"bg-white rounded p-4 product-dialog-container",description:"상품 정보를 확인해 보세요"},t.createElement(pd,{products:w.productsInfo,contentId:w.shortsId})),h&&c&&t.createElement(fd,{portalContainer:n,hideCloseButton:!0,contentClassName:"w-full max-w-none p-0 mx-0"},t.createElement(Oo,{collection:h,initialShortsId:c.shortsId,onClosePlayer:()=>x(void 0,void 0,void 0,function*(){m(),b(!1)}),onSlideChange:p})))};const gd=e=>{const{collectionId:r,isPreview:s,priceText:n,memberOnly:a,container:o}=e,{setIsPreview:l,setPriceText:c,setMemberOnly:d,setIsMemberLoggedIn:u}=Ua(),{setCollection:h,setNextKey:f,collection:p}=Io();i(()=>{n&&c(n);const e=Boolean(s);e&&l(e),a&&(d(!0),u(Boolean(window.MEMBER_UID)))},[]),i(()=>{x(void 0,void 0,void 0,function*(){var e;const t=yield Ca({collectionId:r,size:10});if(!t)return;const{contents:i,count:s}=t;(null==i?void 0:i.length)&&f(null===(e=i.at(-1))||void 0===e?void 0:e.shortsId),h(Object.assign(Object.assign({},t),{count:s}))})},[r]);const m=function(e){var t,r,i,s,n,a,o,l,c,d,u,h;const f=null!==(t=e.iconForm)&&void 0!==t?t:Me.INSTA,p={collectionId:e.collectionId,iconForm:f,iconShape:null!==(r=e.iconShape)&&void 0!==r?r:Ne.MANY,iconSize:null!==(i=e.iconSize)&&void 0!==i?i:120,borderLine:null!==(s=e.borderLine)&&void 0!==s?s:Fe.DAY,exposeTitle:null===(n=e.exposeTitle)||void 0===n||n,player:null!==(a=e.player)&&void 0!==a?a:$e.POPUP,rounded:null===(o=e.rounded)||void 0===o||o,titlePosition:null!==(l=e.titlePosition)&&void 0!==l?l:Be.BOTTOM,exposeProductBanner:null!==(c=e.exposeProductBanner)&&void 0!==c&&c,exposeProductBadge:null!==(d=e.exposeProductBadge)&&void 0!==d&&d,priceText:e.priceText||"할인가",hoverPlay:null!==(u=e.hoverPlay)&&void 0!==u&&u,thumbnailAutoPlay:null!==(h=e.thumbnailAutoPlay)&&void 0!==h&&h};return f===Me.YOUTUBE?Object.assign(Object.assign({},p),{iconForm:Me.YOUTUBE,iconRatio:e.iconRatio||"9/16"}):Object.assign(Object.assign({},p),{iconForm:Me.INSTA})}(e),{containerRef:g}=function({collectionId:e,iconSize:r}){const{collection:i,setCollection:s,nextKey:n,setNextKey:a,isFetching:o,setIsFetching:l}=Io(),c=t.useRef(null),[d,u]=t.useState(0);return t.useEffect(()=>{if(!c.current)return;const e=new ResizeObserver(e=>{var t,r,i;const s=null!==(i=null===(r=null===(t=e[0])||void 0===t?void 0:t.contentRect)||void 0===r?void 0:r.width)&&void 0!==i?i:0;u(s)});return e.observe(c.current),()=>e.disconnect()},[]),t.useEffect(()=>{var e;if(!i||!i.contents)return;const t=Math.max(1,r+12),c=Math.ceil((d||0)/t)+4,u=null!==(e=i.count)&&void 0!==e?e:Number.MAX_SAFE_INTEGER,h=Math.min(u,c);if(i.contents.length>=h||o)return;let f=!1;return(()=>{x(this,void 0,void 0,function*(){var e,t,r,o,c;try{l(!0);let d=i,u=n||(null===(e=d.contents.at(-1))||void 0===e?void 0:e.shortsId)||void 0;const p=new Set(d.contents.map(e=>e.shortsId));for(;!f&&d.contents.length<h;){const e=Math.max(6,h-d.contents.length),i=yield Ca({collectionId:d.colId,nextKey:u,size:e});if(!i||!(null===(t=i.contents)||void 0===t?void 0:t.length))break;u=null!==(o=null===(r=i.contents.at(-1))||void 0===r?void 0:r.shortsId)&&void 0!==o?o:u;const n=i.contents.filter(e=>!p.has(e.shortsId));if(!n.length)break;if(n.forEach(e=>p.add(e.shortsId)),d=Object.assign(Object.assign({},d),{contents:[...d.contents,...n]}),s(d),a(u||""),d.contents.length>=(null!==(c=d.count)&&void 0!==c?c:Number.MAX_SAFE_INTEGER))break}}finally{l(!1)}})})(),()=>{f=!0}},[null==i?void 0:i.colId,null==i?void 0:i.count,null==i?void 0:i.contents.length,d,r,o,n,s,l,a]),{containerRef:c}}({collectionId:r,iconSize:m.iconSize});return t.createElement(Sr.div,null,t.createElement(fo,null),t.createElement("div",{ref:g},t.createElement(md,{widgetPlayerOption:m,setCollectionUuid:e=>{h(Object.assign(Object.assign({},p),{uuid:e}))},portalContainer:o})))},vd=e=>{const{container:r}=mo();return r?t.createElement(Lo,null,t.createElement(gd,Object.assign({},e,{container:r}))):null},yd=({portalContainer:e,aspectRatio:r})=>{var s;const{collection:n,setNextKey:o}=Io(),[l,c]=a(),{setOpen:d,open:u}=po();i(()=>{u||l&&c(null)},[u]);const h=(null!==(s=Po().width)&&void 0!==s?s:0)<430||qa.isMobile;return t.createElement(t.Fragment,null,t.createElement("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${h?2:5}, 1fr)`}},null==n?void 0:n.contents.map(e=>t.createElement("div",null,t.createElement("div",{className:"overflow-hidden",style:{borderRadius:"0.625rem",aspectRatio:null!=r?r:"9/16"}},t.createElement("video",{loop:!0,className:"w-full h-full object-cover",muted:!0,autoPlay:!0,playsInline:!0,src:xt(e.media.objectId),poster:Ct(e.thumbPath)})),t.createElement(Fo,{hideMoreBadge:!0,showMoreBtn:!0,products:e.productsInfo,contentId:e.shortsId,setSelectedProducts:c})))),l&&t.createElement(fd,{portalContainer:e,title:"상품 목록",contentClassName:"bg-white rounded p-4 product-dialog-container",description:"연결된 전체 상품 정보를 확인해 보세요"},t.createElement(pd,{products:l.productsInfo,contentId:l.shortsId})))},bd=({collectionId:e,aspectRatio:r,container:s,isPreview:n})=>{const{setCollection:a,setNextKey:o}=Io();return i(()=>{x(void 0,void 0,void 0,function*(){var t;const r=yield Ca({collectionId:e,size:-1});if(!r)return;const{contents:i,count:s}=r;(null==i?void 0:i.length)&&o(null===(t=i.at(-1))||void 0===t?void 0:t.shortsId),a(Object.assign(Object.assign({},r),{count:s}))})},[e]),t.createElement(Sr.div,null,t.createElement(fo,null),t.createElement(yd,{portalContainer:s,aspectRatio:r}))},Ed=e=>{const{container:r}=mo();return r?t.createElement(Lo,null,t.createElement(bd,Object.assign({},e,{container:r}))):null},wd=Ba(e=>({shortform:null,setShortform:t=>e({shortform:t})}));var Sd={exports:{}},Td={};function xd(e){var t,r,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(r=xd(e[t]))&&(i&&(i+=" "),i+=r);else for(t in e)e[t]&&(i&&(i+=" "),i+=t);return i}function Ad(){for(var e,t,r=0,i="";r<arguments.length;)(e=arguments[r++])&&(t=xd(e))&&(i&&(i+=" "),i+=t);return i}var kd,Ld=He(Object.freeze({__proto__:null,clsx:Ad,default:Ad})),Id={},Rd={};function Pd(){if(kd)return Rd;return kd=1,Object.defineProperty(Rd,"__esModule",{value:!0}),Rd.dontSetMe=function(e,t,r){if(e[t])return new Error("Invalid prop ".concat(t," passed to ").concat(r," - do not set this, set it on the child."))},Rd.findInArray=function(e,t){for(let r=0,i=e.length;r<i;r++)if(t.apply(t,[e[r],r,e]))return e[r]},Rd.int=function(e){return parseInt(e,10)},Rd.isFunction=function(e){return"function"==typeof e||"[object Function]"===Object.prototype.toString.call(e)},Rd.isNum=function(e){return"number"==typeof e&&!isNaN(e)},Rd}var Cd,Dd,_d={};function Od(){if(Dd)return Id;Dd=1,Object.defineProperty(Id,"__esModule",{value:!0}),Id.addClassName=a,Id.addEvent=function(e,t,r,i){if(!e)return;const s={capture:!0,...i};e.addEventListener?e.addEventListener(t,r,s):e.attachEvent?e.attachEvent("on"+t,r):e["on"+t]=r},Id.addUserSelectStyles=function(e){if(!e)return;let t=e.getElementById("react-draggable-style-el");t||(t=e.createElement("style"),t.type="text/css",t.id="react-draggable-style-el",t.innerHTML=".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n",t.innerHTML+=".react-draggable-transparent-selection *::selection {all: inherit;}\n",e.getElementsByTagName("head")[0].appendChild(t));e.body&&a(e.body,"react-draggable-transparent-selection")},Id.createCSSTransform=function(e,r){const i=n(e,r,"px");return{[(0,t.browserPrefixToKey)("transform",t.default)]:i}},Id.createSVGTransform=function(e,t){return n(e,t,"")},Id.getTouch=function(t,r){return t.targetTouches&&(0,e.findInArray)(t.targetTouches,e=>r===e.identifier)||t.changedTouches&&(0,e.findInArray)(t.changedTouches,e=>r===e.identifier)},Id.getTouchIdentifier=function(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier},Id.getTranslation=n,Id.innerHeight=function(t){let r=t.clientHeight;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r-=(0,e.int)(i.paddingTop),r-=(0,e.int)(i.paddingBottom),r},Id.innerWidth=function(t){let r=t.clientWidth;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r-=(0,e.int)(i.paddingLeft),r-=(0,e.int)(i.paddingRight),r},Id.matchesSelector=s,Id.matchesSelectorAndParentsTo=function(e,t,r){let i=e;do{if(s(i,t))return!0;if(i===r)return!1;i=i.parentNode}while(i);return!1},Id.offsetXYFromParent=function(e,t,r){const i=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect(),s=(e.clientX+t.scrollLeft-i.left)/r,n=(e.clientY+t.scrollTop-i.top)/r;return{x:s,y:n}},Id.outerHeight=function(t){let r=t.clientHeight;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r+=(0,e.int)(i.borderTopWidth),r+=(0,e.int)(i.borderBottomWidth),r},Id.outerWidth=function(t){let r=t.clientWidth;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r+=(0,e.int)(i.borderLeftWidth),r+=(0,e.int)(i.borderRightWidth),r},Id.removeClassName=o,Id.removeEvent=function(e,t,r,i){if(!e)return;const s={capture:!0,...i};e.removeEventListener?e.removeEventListener(t,r,s):e.detachEvent?e.detachEvent("on"+t,r):e["on"+t]=null},Id.removeUserSelectStyles=function(e){if(!e)return;try{if(e.body&&o(e.body,"react-draggable-transparent-selection"),e.selection)e.selection.empty();else{const t=(e.defaultView||window).getSelection();t&&"Caret"!==t.type&&t.removeAllRanges()}}catch(e){}};var e=Pd(),t=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var i=r(t);if(i&&i.has(e))return i.get(e);var s={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var o=n?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(s,a,o):s[a]=e[a]}s.default=e,i&&i.set(e,s);return s}(function(){if(Cd)return _d;Cd=1,Object.defineProperty(_d,"__esModule",{value:!0}),_d.browserPrefixToKey=r,_d.browserPrefixToStyle=function(e,t){return t?"-".concat(t.toLowerCase(),"-").concat(e):e},_d.default=void 0,_d.getPrefix=t;const e=["Moz","Webkit","O","ms"];function t(){var t;let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"transform";if("undefined"==typeof window)return"";const s=null===(t=window.document)||void 0===t||null===(t=t.documentElement)||void 0===t?void 0:t.style;if(!s)return"";if(i in s)return"";for(let t=0;t<e.length;t++)if(r(i,e[t])in s)return e[t];return""}function r(e,t){return t?"".concat(t).concat(function(e){let t="",r=!0;for(let i=0;i<e.length;i++)r?(t+=e[i].toUpperCase(),r=!1):"-"===e[i]?r=!0:t+=e[i];return t}(e)):e}return _d.default=t(),_d}());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}let i="";function s(t,r){return i||(i=(0,e.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(r){return(0,e.isFunction)(t[r])})),!!(0,e.isFunction)(t[i])&&t[i](r)}function n(e,t,r){let{x:i,y:s}=e,n="translate(".concat(i).concat(r,",").concat(s).concat(r,")");if(t){const e="".concat("string"==typeof t.x?t.x:t.x+r),i="".concat("string"==typeof t.y?t.y:t.y+r);n="translate(".concat(e,", ").concat(i,")")+n}return n}function a(e,t){e.classList?e.classList.add(t):e.className.match(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)")))||(e.className+=" ".concat(t))}function o(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)"),"g"),"")}return Id}var Md,Nd={};function Fd(){if(Md)return Nd;Md=1,Object.defineProperty(Nd,"__esModule",{value:!0}),Nd.canDragX=function(e){return"both"===e.props.axis||"x"===e.props.axis},Nd.canDragY=function(e){return"both"===e.props.axis||"y"===e.props.axis},Nd.createCoreData=function(t,i,s){const n=!(0,e.isNum)(t.lastX),a=r(t);return n?{node:a,deltaX:0,deltaY:0,lastX:i,lastY:s,x:i,y:s}:{node:a,deltaX:i-t.lastX,deltaY:s-t.lastY,lastX:t.lastX,lastY:t.lastY,x:i,y:s}},Nd.createDraggableData=function(e,t){const r=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/r,y:e.state.y+t.deltaY/r,deltaX:t.deltaX/r,deltaY:t.deltaY/r,lastX:e.state.x,lastY:e.state.y}},Nd.getBoundPosition=function(i,s,n){if(!i.props.bounds)return[s,n];let{bounds:a}=i.props;a="string"==typeof a?a:function(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}(a);const o=r(i);if("string"==typeof a){const{ownerDocument:r}=o,i=r.defaultView;let s;if(s="parent"===a?o.parentNode:r.querySelector(a),!(s instanceof i.HTMLElement))throw new Error('Bounds selector "'+a+'" could not find an element.');const n=s,l=i.getComputedStyle(o),c=i.getComputedStyle(n);a={left:-o.offsetLeft+(0,e.int)(c.paddingLeft)+(0,e.int)(l.marginLeft),top:-o.offsetTop+(0,e.int)(c.paddingTop)+(0,e.int)(l.marginTop),right:(0,t.innerWidth)(n)-(0,t.outerWidth)(o)-o.offsetLeft+(0,e.int)(c.paddingRight)-(0,e.int)(l.marginRight),bottom:(0,t.innerHeight)(n)-(0,t.outerHeight)(o)-o.offsetTop+(0,e.int)(c.paddingBottom)-(0,e.int)(l.marginBottom)}}(0,e.isNum)(a.right)&&(s=Math.min(s,a.right));(0,e.isNum)(a.bottom)&&(n=Math.min(n,a.bottom));(0,e.isNum)(a.left)&&(s=Math.max(s,a.left));(0,e.isNum)(a.top)&&(n=Math.max(n,a.top));return[s,n]},Nd.getControlPosition=function(e,i,s){const n="number"==typeof i?(0,t.getTouch)(e,i):null;if("number"==typeof i&&!n)return null;const a=r(s),o=s.props.offsetParent||a.offsetParent||a.ownerDocument.body;return(0,t.offsetXYFromParent)(n||e,o,s.props.scale)},Nd.snapToGrid=function(e,t,r){const i=Math.round(t/e[0])*e[0],s=Math.round(r/e[1])*e[1];return[i,s]};var e=Pd(),t=Od();function r(e){const t=e.findDOMNode();if(!t)throw new Error("<DraggableCore>: Unmounted during event!");return t}return Nd}var $d,Bd,Ud,zd,Gd={},jd={};function Hd(){if($d)return jd;return $d=1,Object.defineProperty(jd,"__esModule",{value:!0}),jd.default=function(){},jd}function Vd(){if(Bd)return Gd;Bd=1,Object.defineProperty(Gd,"__esModule",{value:!0}),Gd.default=void 0;var e=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=c(t);if(r&&r.has(e))return r.get(e);var i={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if("default"!==n&&Object.prototype.hasOwnProperty.call(e,n)){var a=s?Object.getOwnPropertyDescriptor(e,n):null;a&&(a.get||a.set)?Object.defineProperty(i,n,a):i[n]=e[n]}i.default=e,r&&r.set(e,i);return i}(t),r=l(lr()),i=l(m),s=Od(),n=Fd(),a=Pd(),o=l(Hd());function l(e){return e&&e.__esModule?e:{default:e}}function c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(c=function(e){return e?r:t})(e)}function d(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const u={start:"touchstart",move:"touchmove",stop:"touchend"},h={start:"mousedown",move:"mousemove",stop:"mouseup"};let f=h,p=class extends e.Component{constructor(){super(...arguments),d(this,"dragging",!1),d(this,"lastX",NaN),d(this,"lastY",NaN),d(this,"touchIdentifier",null),d(this,"mounted",!1),d(this,"handleDragStart",e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&"number"==typeof e.button&&0!==e.button)return!1;const t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");const{ownerDocument:r}=t;if(this.props.disabled||!(e.target instanceof r.defaultView.Node)||this.props.handle&&!(0,s.matchesSelectorAndParentsTo)(e.target,this.props.handle,t)||this.props.cancel&&(0,s.matchesSelectorAndParentsTo)(e.target,this.props.cancel,t))return;"touchstart"===e.type&&e.preventDefault();const i=(0,s.getTouchIdentifier)(e);this.touchIdentifier=i;const a=(0,n.getControlPosition)(e,i,this);if(null==a)return;const{x:l,y:c}=a,d=(0,n.createCoreData)(this,l,c);(0,o.default)("DraggableCore: handleDragStart: %j",d),(0,o.default)("calling",this.props.onStart);!1!==this.props.onStart(e,d)&&!1!==this.mounted&&(this.props.enableUserSelectHack&&(0,s.addUserSelectStyles)(r),this.dragging=!0,this.lastX=l,this.lastY=c,(0,s.addEvent)(r,f.move,this.handleDrag),(0,s.addEvent)(r,f.stop,this.handleDragStop))}),d(this,"handleDrag",e=>{const t=(0,n.getControlPosition)(e,this.touchIdentifier,this);if(null==t)return;let{x:r,y:i}=t;if(Array.isArray(this.props.grid)){let e=r-this.lastX,t=i-this.lastY;if([e,t]=(0,n.snapToGrid)(this.props.grid,e,t),!e&&!t)return;r=this.lastX+e,i=this.lastY+t}const s=(0,n.createCoreData)(this,r,i);(0,o.default)("DraggableCore: handleDrag: %j",s);if(!1!==this.props.onDrag(e,s)&&!1!==this.mounted)this.lastX=r,this.lastY=i;else try{this.handleDragStop(new MouseEvent("mouseup"))}catch(e){const t=document.createEvent("MouseEvents");t.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(t)}}),d(this,"handleDragStop",e=>{if(!this.dragging)return;const t=(0,n.getControlPosition)(e,this.touchIdentifier,this);if(null==t)return;let{x:r,y:i}=t;if(Array.isArray(this.props.grid)){let e=r-this.lastX||0,t=i-this.lastY||0;[e,t]=(0,n.snapToGrid)(this.props.grid,e,t),r=this.lastX+e,i=this.lastY+t}const a=(0,n.createCoreData)(this,r,i);if(!1===this.props.onStop(e,a)||!1===this.mounted)return!1;const l=this.findDOMNode();l&&this.props.enableUserSelectHack&&(0,s.removeUserSelectStyles)(l.ownerDocument),(0,o.default)("DraggableCore: handleDragStop: %j",a),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,l&&((0,o.default)("DraggableCore: Removing handlers"),(0,s.removeEvent)(l.ownerDocument,f.move,this.handleDrag),(0,s.removeEvent)(l.ownerDocument,f.stop,this.handleDragStop))}),d(this,"onMouseDown",e=>(f=h,this.handleDragStart(e))),d(this,"onMouseUp",e=>(f=h,this.handleDragStop(e))),d(this,"onTouchStart",e=>(f=u,this.handleDragStart(e))),d(this,"onTouchEnd",e=>(f=u,this.handleDragStop(e)))}componentDidMount(){this.mounted=!0;const e=this.findDOMNode();e&&(0,s.addEvent)(e,u.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const e=this.findDOMNode();if(e){const{ownerDocument:t}=e;(0,s.removeEvent)(t,h.move,this.handleDrag),(0,s.removeEvent)(t,u.move,this.handleDrag),(0,s.removeEvent)(t,h.stop,this.handleDragStop),(0,s.removeEvent)(t,u.stop,this.handleDragStop),(0,s.removeEvent)(e,u.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,s.removeUserSelectStyles)(t)}}findDOMNode(){var e,t;return null!==(e=this.props)&&void 0!==e&&e.nodeRef?null===(t=this.props)||void 0===t||null===(t=t.nodeRef)||void 0===t?void 0:t.current:i.default.findDOMNode(this)}render(){return e.cloneElement(e.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};return Gd.default=p,d(p,"displayName","DraggableCore"),d(p,"propTypes",{allowAnyClick:r.default.bool,children:r.default.node.isRequired,disabled:r.default.bool,enableUserSelectHack:r.default.bool,offsetParent:function(e,t){if(e[t]&&1!==e[t].nodeType)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:r.default.arrayOf(r.default.number),handle:r.default.string,cancel:r.default.string,nodeRef:r.default.object,onStart:r.default.func,onDrag:r.default.func,onStop:r.default.func,onMouseDown:r.default.func,scale:r.default.number,className:a.dontSetMe,style:a.dontSetMe,transform:a.dontSetMe}),d(p,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1}),Gd}function Wd(){return Ud||(Ud=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return c.default}}),e.default=void 0;var r=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=h(t);if(r&&r.has(e))return r.get(e);var i={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if("default"!==n&&Object.prototype.hasOwnProperty.call(e,n)){var a=s?Object.getOwnPropertyDescriptor(e,n):null;a&&(a.get||a.set)?Object.defineProperty(i,n,a):i[n]=e[n]}i.default=e,r&&r.set(e,i);return i}(t),i=u(lr()),s=u(m),n=u(Ld),a=Od(),o=Fd(),l=Pd(),c=u(Vd()),d=u(Hd());function u(e){return e&&e.__esModule?e:{default:e}}function h(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(h=function(e){return e?r:t})(e)}function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},f.apply(this,arguments)}function p(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class g extends r.Component{static getDerivedStateFromProps(e,t){let{position:r}=e,{prevPropsPosition:i}=t;return!r||i&&r.x===i.x&&r.y===i.y?null:((0,d.default)("Draggable: getDerivedStateFromProps %j",{position:r,prevPropsPosition:i}),{x:r.x,y:r.y,prevPropsPosition:{...r}})}constructor(e){super(e),p(this,"onDragStart",(e,t)=>{(0,d.default)("Draggable: onDragStart: %j",t);if(!1===this.props.onStart(e,(0,o.createDraggableData)(this,t)))return!1;this.setState({dragging:!0,dragged:!0})}),p(this,"onDrag",(e,t)=>{if(!this.state.dragging)return!1;(0,d.default)("Draggable: onDrag: %j",t);const r=(0,o.createDraggableData)(this,t),i={x:r.x,y:r.y,slackX:0,slackY:0};if(this.props.bounds){const{x:e,y:t}=i;i.x+=this.state.slackX,i.y+=this.state.slackY;const[s,n]=(0,o.getBoundPosition)(this,i.x,i.y);i.x=s,i.y=n,i.slackX=this.state.slackX+(e-i.x),i.slackY=this.state.slackY+(t-i.y),r.x=i.x,r.y=i.y,r.deltaX=i.x-this.state.x,r.deltaY=i.y-this.state.y}if(!1===this.props.onDrag(e,r))return!1;this.setState(i)}),p(this,"onDragStop",(e,t)=>{if(!this.state.dragging)return!1;if(!1===this.props.onStop(e,(0,o.createDraggableData)(this,t)))return!1;(0,d.default)("Draggable: onDragStop: %j",t);const r={dragging:!1,slackX:0,slackY:0};if(Boolean(this.props.position)){const{x:e,y:t}=this.props.position;r.x=e,r.y=t}this.setState(r)}),this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},!e.position||e.onDrag||e.onStop||console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){void 0!==window.SVGElement&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.setState({dragging:!1})}findDOMNode(){var e,t;return null!==(e=null===(t=this.props)||void 0===t||null===(t=t.nodeRef)||void 0===t?void 0:t.current)&&void 0!==e?e:s.default.findDOMNode(this)}render(){const{axis:e,bounds:t,children:i,defaultPosition:s,defaultClassName:l,defaultClassNameDragging:d,defaultClassNameDragged:u,position:h,positionOffset:p,scale:m,...g}=this.props;let v={},y=null;const b=!Boolean(h)||this.state.dragging,E=h||s,w={x:(0,o.canDragX)(this)&&b?this.state.x:E.x,y:(0,o.canDragY)(this)&&b?this.state.y:E.y};this.state.isElementSVG?y=(0,a.createSVGTransform)(w,p):v=(0,a.createCSSTransform)(w,p);const S=(0,n.default)(i.props.className||"",l,{[d]:this.state.dragging,[u]:this.state.dragged});return r.createElement(c.default,f({},g,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),r.cloneElement(r.Children.only(i),{className:S,style:{...i.props.style,...v},transform:y}))}}e.default=g,p(g,"displayName","Draggable"),p(g,"propTypes",{...c.default.propTypes,axis:i.default.oneOf(["both","x","y","none"]),bounds:i.default.oneOfType([i.default.shape({left:i.default.number,right:i.default.number,top:i.default.number,bottom:i.default.number}),i.default.string,i.default.oneOf([!1])]),defaultClassName:i.default.string,defaultClassNameDragging:i.default.string,defaultClassNameDragged:i.default.string,defaultPosition:i.default.shape({x:i.default.number,y:i.default.number}),positionOffset:i.default.shape({x:i.default.oneOfType([i.default.number,i.default.string]),y:i.default.oneOfType([i.default.number,i.default.string])}),position:i.default.shape({x:i.default.number,y:i.default.number}),className:l.dontSetMe,style:l.dontSetMe,transform:l.dontSetMe}),p(g,"defaultProps",{...c.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})}(Td)),Td}var Yd=function(){if(zd)return Sd.exports;zd=1;const{default:e,DraggableCore:t}=Wd();return Sd.exports=e,Sd.exports.default=e,Sd.exports.DraggableCore=t,Sd.exports}(),Kd=je(Yd),qd=function(){return qd=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},qd.apply(this,arguments)},Xd={width:"100%",height:"10px",top:"0px",left:"0px",cursor:"row-resize"},Qd={width:"10px",height:"100%",top:"0px",left:"0px",cursor:"col-resize"},Zd={width:"20px",height:"20px",position:"absolute",zIndex:1},Jd={top:qd(qd({},Xd),{top:"-5px"}),right:qd(qd({},Qd),{left:void 0,right:"-5px"}),bottom:qd(qd({},Xd),{top:void 0,bottom:"-5px"}),left:qd(qd({},Qd),{left:"-5px"}),topRight:qd(qd({},Zd),{right:"-10px",top:"-10px",cursor:"ne-resize"}),bottomRight:qd(qd({},Zd),{right:"-10px",bottom:"-10px",cursor:"se-resize"}),bottomLeft:qd(qd({},Zd),{left:"-10px",bottom:"-10px",cursor:"sw-resize"}),topLeft:qd(qd({},Zd),{left:"-10px",top:"-10px",cursor:"nw-resize"})},eu=h(function(e){var t=e.onResizeStart,r=e.direction,i=e.children,s=e.replaceStyles,n=e.className,a=u(function(e){t(e,r)},[t,r]),o=u(function(e){t(e,r)},[t,r]),l=d(function(){return qd(qd({position:"absolute",userSelect:"none"},Jd[r]),null!=s?s:{})},[s,r]);return b("div",{className:n||void 0,style:l,onMouseDown:a,onTouchStart:o,children:i})}),tu=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),ru=function(){return ru=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},ru.apply(this,arguments)},iu={width:"auto",height:"auto"},su=function(e,t,r){return Math.max(Math.min(e,r),t)},nu=function(e,t,r){var i=Math.round(e/t);return i*t+r*(i-1)},au=function(e,t){return new RegExp(e,"i").test(t)},ou=function(e){return Boolean(e.touches&&e.touches.length)},lu=function(e,t,r){void 0===r&&(r=0);var i=t.reduce(function(r,i,s){return Math.abs(i-e)<Math.abs(t[r]-e)?s:r},0),s=Math.abs(t[i]-e);return 0===r||s<r?t[i]:e},cu=function(e){return"auto"===(e=e.toString())||e.endsWith("px")||e.endsWith("%")||e.endsWith("vh")||e.endsWith("vw")||e.endsWith("vmax")||e.endsWith("vmin")?e:"".concat(e,"px")},du=function(e,t,r,i){if(e&&"string"==typeof e){if(e.endsWith("px"))return Number(e.replace("px",""));if(e.endsWith("%"))return t*(Number(e.replace("%",""))/100);if(e.endsWith("vw"))return r*(Number(e.replace("vw",""))/100);if(e.endsWith("vh"))return i*(Number(e.replace("vh",""))/100)}return e},uu=["as","ref","style","className","grid","gridGap","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],hu="__resizable_base__",fu=function(e){function t(t){var r,i,s,n,a=e.call(this,t)||this;return a.ratio=1,a.resizable=null,a.parentLeft=0,a.parentTop=0,a.resizableLeft=0,a.resizableRight=0,a.resizableTop=0,a.resizableBottom=0,a.targetLeft=0,a.targetTop=0,a.delta={width:0,height:0},a.appendBase=function(){if(!a.resizable||!a.window)return null;var e=a.parentNode;if(!e)return null;var t=a.window.document.createElement("div");return t.style.width="100%",t.style.height="100%",t.style.position="absolute",t.style.transform="scale(0, 0)",t.style.left="0",t.style.flex="0 0 100%",t.classList?t.classList.add(hu):t.className+=hu,e.appendChild(t),t},a.removeBase=function(e){var t=a.parentNode;t&&t.removeChild(e)},a.state={isResizing:!1,width:null!==(i=null===(r=a.propsSize)||void 0===r?void 0:r.width)&&void 0!==i?i:"auto",height:null!==(n=null===(s=a.propsSize)||void 0===s?void 0:s.height)&&void 0!==n?n:"auto",direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},a.onResizeStart=a.onResizeStart.bind(a),a.onMouseMove=a.onMouseMove.bind(a),a.onMouseUp=a.onMouseUp.bind(a),a}return tu(t,e),Object.defineProperty(t.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"window",{get:function(){return this.resizable&&this.resizable.ownerDocument?this.resizable.ownerDocument.defaultView:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||iu},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){var e=0,t=0;if(this.resizable&&this.window){var r=this.resizable.offsetWidth,i=this.resizable.offsetHeight,s=this.resizable.style.position;"relative"!==s&&(this.resizable.style.position="relative"),e="auto"!==this.resizable.style.width?this.resizable.offsetWidth:r,t="auto"!==this.resizable.style.height?this.resizable.offsetHeight:i,this.resizable.style.position=s}return{width:e,height:t}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sizeStyle",{get:function(){var e=this,t=this.props.size,r=function(t){var r;if(void 0===e.state[t]||"auto"===e.state[t])return"auto";if(e.propsSize&&e.propsSize[t]&&(null===(r=e.propsSize[t])||void 0===r?void 0:r.toString().endsWith("%"))){if(e.state[t].toString().endsWith("%"))return e.state[t].toString();var i=e.getParentSize(),s=Number(e.state[t].toString().replace("px",""))/i[t]*100;return"".concat(s,"%")}return cu(e.state[t])};return{width:t&&void 0!==t.width&&!this.state.isResizing?cu(t.width):r("width"),height:t&&void 0!==t.height&&!this.state.isResizing?cu(t.height):r("height")}},enumerable:!1,configurable:!0}),t.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var e=this.appendBase();if(!e)return{width:0,height:0};var t=!1,r=this.parentNode.style.flexWrap;"wrap"!==r&&(t=!0,this.parentNode.style.flexWrap="wrap"),e.style.position="relative",e.style.minWidth="100%",e.style.minHeight="100%";var i={width:e.offsetWidth,height:e.offsetHeight};return t&&(this.parentNode.style.flexWrap=r),this.removeBase(e),i},t.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},t.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},t.prototype.componentDidMount=function(){if(this.resizable&&this.window){var e=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:"auto"!==e.flexBasis?e.flexBasis:void 0})}},t.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},t.prototype.createSizeForCssProperty=function(e,t){var r=this.propsSize&&this.propsSize[t];return"auto"!==this.state[t]||this.state.original[t]!==e||void 0!==r&&"auto"!==r?e:"auto"},t.prototype.calculateNewMaxFromBoundary=function(e,t){var r,i,s=this.props.boundsByDirection,n=this.state.direction,a=s&&au("left",n),o=s&&au("top",n);if("parent"===this.props.bounds){var l=this.parentNode;l&&(r=a?this.resizableRight-this.parentLeft:l.offsetWidth+(this.parentLeft-this.resizableLeft),i=o?this.resizableBottom-this.parentTop:l.offsetHeight+(this.parentTop-this.resizableTop))}else"window"===this.props.bounds?this.window&&(r=a?this.resizableRight:this.window.innerWidth-this.resizableLeft,i=o?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(r=a?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),i=o?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return r&&Number.isFinite(r)&&(e=e&&e<r?e:r),i&&Number.isFinite(i)&&(t=t&&t<i?t:i),{maxWidth:e,maxHeight:t}},t.prototype.calculateNewSizeFromDirection=function(e,t){var r,i=this.props.scale||1,s=(r=this.props.resizeRatio||1,Array.isArray(r)?r:[r,r]),n=s[0],a=s[1],o=this.state,l=o.direction,c=o.original,d=this.props,u=d.lockAspectRatio,h=d.lockAspectRatioExtraHeight,f=d.lockAspectRatioExtraWidth,p=c.width,m=c.height,g=h||0,v=f||0;return au("right",l)&&(p=c.width+(e-c.x)*n/i,u&&(m=(p-v)/this.ratio+g)),au("left",l)&&(p=c.width-(e-c.x)*n/i,u&&(m=(p-v)/this.ratio+g)),au("bottom",l)&&(m=c.height+(t-c.y)*a/i,u&&(p=(m-g)*this.ratio+v)),au("top",l)&&(m=c.height-(t-c.y)*a/i,u&&(p=(m-g)*this.ratio+v)),{newWidth:p,newHeight:m}},t.prototype.calculateNewSizeFromAspectRatio=function(e,t,r,i){var s=this.props,n=s.lockAspectRatio,a=s.lockAspectRatioExtraHeight,o=s.lockAspectRatioExtraWidth,l=void 0===i.width?10:i.width,c=void 0===r.width||r.width<0?e:r.width,d=void 0===i.height?10:i.height,u=void 0===r.height||r.height<0?t:r.height,h=a||0,f=o||0;if(n){var p=(d-h)*this.ratio+f,m=(u-h)*this.ratio+f,g=(l-f)/this.ratio+h,v=(c-f)/this.ratio+h,y=Math.max(l,p),b=Math.min(c,m),E=Math.max(d,g),w=Math.min(u,v);e=su(e,y,b),t=su(t,E,w)}else e=su(e,l,c),t=su(t,d,u);return{newWidth:e,newHeight:t}},t.prototype.setBoundingClientRect=function(){var e=1/(this.props.scale||1);if("parent"===this.props.bounds){var t=this.parentNode;if(t){var r=t.getBoundingClientRect();this.parentLeft=r.left*e,this.parentTop=r.top*e}}if(this.props.bounds&&"string"!=typeof this.props.bounds){var i=this.props.bounds.getBoundingClientRect();this.targetLeft=i.left*e,this.targetTop=i.top*e}if(this.resizable){var s=this.resizable.getBoundingClientRect(),n=s.left,a=s.top,o=s.right,l=s.bottom;this.resizableLeft=n*e,this.resizableRight=o*e,this.resizableTop=a*e,this.resizableBottom=l*e}},t.prototype.onResizeStart=function(e,t){if(this.resizable&&this.window){var r,i=0,s=0;if(e.nativeEvent&&function(e){return Boolean((e.clientX||0===e.clientX)&&(e.clientY||0===e.clientY))}(e.nativeEvent)?(i=e.nativeEvent.clientX,s=e.nativeEvent.clientY):e.nativeEvent&&ou(e.nativeEvent)&&(i=e.nativeEvent.touches[0].clientX,s=e.nativeEvent.touches[0].clientY),this.props.onResizeStart)if(this.resizable)if(!1===this.props.onResizeStart(e,t,this.resizable))return;this.props.size&&(void 0!==this.props.size.height&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),void 0!==this.props.size.width&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio="number"==typeof this.props.lockAspectRatio?this.props.lockAspectRatio:this.size.width/this.size.height;var n=this.window.getComputedStyle(this.resizable);if("auto"!==n.flexBasis){var a=this.parentNode;if(a){var o=this.window.getComputedStyle(a).flexDirection;this.flexDir=o.startsWith("row")?"row":"column",r=n.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var l={original:{x:i,y:s,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:ru(ru({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(e.target).cursor||"auto"}),direction:t,flexBasis:r};this.setState(l)}},t.prototype.onMouseMove=function(e){var t=this;if(this.state.isResizing&&this.resizable&&this.window){if(this.window.TouchEvent&&ou(e))try{e.preventDefault(),e.stopPropagation()}catch(e){}var r=this.props,i=r.maxWidth,s=r.maxHeight,n=r.minWidth,a=r.minHeight,o=ou(e)?e.touches[0].clientX:e.clientX,l=ou(e)?e.touches[0].clientY:e.clientY,c=this.state,d=c.direction,u=c.original,h=c.width,f=c.height,p=this.getParentSize(),m=function(e,t,r,i,s,n,a){return i=du(i,e.width,t,r),s=du(s,e.height,t,r),n=du(n,e.width,t,r),a=du(a,e.height,t,r),{maxWidth:void 0===i?void 0:Number(i),maxHeight:void 0===s?void 0:Number(s),minWidth:void 0===n?void 0:Number(n),minHeight:void 0===a?void 0:Number(a)}}(p,this.window.innerWidth,this.window.innerHeight,i,s,n,a);i=m.maxWidth,s=m.maxHeight,n=m.minWidth,a=m.minHeight;var g=this.calculateNewSizeFromDirection(o,l),y=g.newHeight,b=g.newWidth,E=this.calculateNewMaxFromBoundary(i,s);this.props.snap&&this.props.snap.x&&(b=lu(b,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(y=lu(y,this.props.snap.y,this.props.snapGap));var w=this.calculateNewSizeFromAspectRatio(b,y,{width:E.maxWidth,height:E.maxHeight},{width:n,height:a});if(b=w.newWidth,y=w.newHeight,this.props.grid){var S=nu(b,this.props.grid[0],this.props.gridGap?this.props.gridGap[0]:0),T=nu(y,this.props.grid[1],this.props.gridGap?this.props.gridGap[1]:0),x=this.props.snapGap||0;b=0===x||Math.abs(S-b)<=x?S:b,y=0===x||Math.abs(T-y)<=x?T:y}var A={width:b-u.width,height:y-u.height};if(this.delta=A,h&&"string"==typeof h)if(h.endsWith("%")){var k=b/p.width*100;b="".concat(k,"%")}else if(h.endsWith("vw")){var L=b/this.window.innerWidth*100;b="".concat(L,"vw")}else if(h.endsWith("vh")){var I=b/this.window.innerHeight*100;b="".concat(I,"vh")}if(f&&"string"==typeof f)if(f.endsWith("%")){k=y/p.height*100;y="".concat(k,"%")}else if(f.endsWith("vw")){L=y/this.window.innerWidth*100;y="".concat(L,"vw")}else if(f.endsWith("vh")){I=y/this.window.innerHeight*100;y="".concat(I,"vh")}var R={width:this.createSizeForCssProperty(b,"width"),height:this.createSizeForCssProperty(y,"height")};"row"===this.flexDir?R.flexBasis=R.width:"column"===this.flexDir&&(R.flexBasis=R.height);var P=this.state.width!==R.width,C=this.state.height!==R.height,D=this.state.flexBasis!==R.flexBasis,_=P||C||D;_&&v(function(){t.setState(R)}),this.props.onResize&&_&&this.props.onResize(e,d,this.resizable,A)}},t.prototype.onMouseUp=function(e){var t,r,i=this.state,s=i.isResizing,n=i.direction;i.original,s&&this.resizable&&(this.props.onResizeStop&&this.props.onResizeStop(e,n,this.resizable,this.delta),this.props.size&&this.setState({width:null!==(t=this.props.size.width)&&void 0!==t?t:"auto",height:null!==(r=this.props.size.height)&&void 0!==r?r:"auto"}),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:ru(ru({},this.state.backgroundStyle),{cursor:"auto"})}))},t.prototype.updateSize=function(e){var t,r;this.setState({width:null!==(t=e.width)&&void 0!==t?t:"auto",height:null!==(r=e.height)&&void 0!==r?r:"auto"})},t.prototype.renderResizer=function(){var e=this,t=this.props,r=t.enable,i=t.handleStyles,s=t.handleClasses,n=t.handleWrapperStyle,a=t.handleWrapperClass,o=t.handleComponent;if(!r)return null;var l=Object.keys(r).map(function(t){return!1!==r[t]?b(eu,{direction:t,onResizeStart:e.onResizeStart,replaceStyles:i&&i[t],className:s&&s[t],children:o&&o[t]?o[t]:null},t):null});return b("div",{className:a,style:n,children:l})},t.prototype.render=function(){var e=this,t=Object.keys(this.props).reduce(function(t,r){return-1!==uu.indexOf(r)||(t[r]=e.props[r]),t},{}),r=ru(ru(ru({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(r.flexBasis=this.state.flexBasis);var i=this.props.as||"div";return w(i,ru({style:r,className:this.props.className},t,{ref:function(t){t&&(e.resizable=t)},children:[this.state.isResizing&&b("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer()]}))},t.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],gridGap:[0,0],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},t}(f),pu=function(e,t){return pu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},pu(e,t)};var mu=function(){return mu=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},mu.apply(this,arguments)};var gu={width:"auto",height:"auto",display:"inline-block",position:"absolute",top:0,left:0},vu=function(e){function t(t){var r=e.call(this,t)||this;return r.resizingPosition={x:0,y:0},r.offsetFromParent={left:0,top:0},r.resizableElement={current:null},r.originalPosition={x:0,y:0},r.state={resizing:!1,bounds:{top:0,right:0,bottom:0,left:0},maxWidth:t.maxWidth,maxHeight:t.maxHeight},r.onResizeStart=r.onResizeStart.bind(r),r.onResize=r.onResize.bind(r),r.onResizeStop=r.onResizeStop.bind(r),r.onDragStart=r.onDragStart.bind(r),r.onDrag=r.onDrag.bind(r),r.onDragStop=r.onDragStop.bind(r),r.getMaxSizesFromProps=r.getMaxSizesFromProps.bind(r),r}return function(e,t){function r(){this.constructor=e}pu(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.prototype.componentDidMount=function(){this.updateOffsetFromParent();var e=this.offsetFromParent,t=e.left,r=e.top,i=this.getDraggablePosition(),s=i.x,n=i.y;this.draggable.setState({x:s-t,y:n-r}),this.forceUpdate()},t.prototype.getDraggablePosition=function(){var e=this.draggable.state;return{x:e.x,y:e.y}},t.prototype.getParent=function(){return this.resizable&&this.resizable.parentNode},t.prototype.getParentSize=function(){return this.resizable.getParentSize()},t.prototype.getMaxSizesFromProps=function(){return{maxWidth:void 0===this.props.maxWidth?Number.MAX_SAFE_INTEGER:this.props.maxWidth,maxHeight:void 0===this.props.maxHeight?Number.MAX_SAFE_INTEGER:this.props.maxHeight}},t.prototype.getSelfElement=function(){return this.resizable&&this.resizable.resizable},t.prototype.getOffsetHeight=function(e){var t=this.props.scale;switch(this.props.bounds){case"window":return window.innerHeight/t;case"body":return document.body.offsetHeight/t;default:return e.offsetHeight}},t.prototype.getOffsetWidth=function(e){var t=this.props.scale;switch(this.props.bounds){case"window":return window.innerWidth/t;case"body":return document.body.offsetWidth/t;default:return e.offsetWidth}},t.prototype.onDragStart=function(e,t){this.props.onDragStart&&this.props.onDragStart(e,t);var r=this.getDraggablePosition();if(this.originalPosition=r,this.props.bounds){var i,s=this.getParent(),n=this.props.scale;if("parent"===this.props.bounds)i=s;else{if("body"===this.props.bounds){var a=s.getBoundingClientRect(),o=a.left,l=a.top,c=document.body.getBoundingClientRect(),d=-(o-s.offsetLeft*n-c.left)/n,u=-(l-s.offsetTop*n-c.top)/n,h=(document.body.offsetWidth-this.resizable.size.width*n)/n+d,f=(document.body.offsetHeight-this.resizable.size.height*n)/n+u;return this.setState({bounds:{top:u,right:h,bottom:f,left:d}})}if("window"===this.props.bounds){if(!this.resizable)return;var p=s.getBoundingClientRect(),m=p.left,g=p.top,v=-(m-s.offsetLeft*n)/n,y=-(g-s.offsetTop*n)/n;h=(window.innerWidth-this.resizable.size.width*n)/n+v,f=(window.innerHeight-this.resizable.size.height*n)/n+y;return this.setState({bounds:{top:y,right:h,bottom:f,left:v}})}"string"==typeof this.props.bounds?i=document.querySelector(this.props.bounds):this.props.bounds instanceof HTMLElement&&(i=this.props.bounds)}if(i instanceof HTMLElement&&s instanceof HTMLElement){var b=i.getBoundingClientRect(),E=b.left,w=b.top,S=s.getBoundingClientRect(),T=(E-S.left)/n,x=w-S.top;if(this.resizable){this.updateOffsetFromParent();var A=this.offsetFromParent;this.setState({bounds:{top:x-A.top,right:T+(i.offsetWidth-this.resizable.size.width)-A.left/n,bottom:x+(i.offsetHeight-this.resizable.size.height)-A.top,left:T-A.left/n}})}}}},t.prototype.onDrag=function(e,t){if(this.props.onDrag){var r=this.offsetFromParent,i=r.left,s=r.top;return this.props.dragAxis&&"both"!==this.props.dragAxis?"x"===this.props.dragAxis?this.props.onDrag(e,mu(mu({},t),{x:t.x+i,y:this.originalPosition.y+s,deltaY:0})):"y"===this.props.dragAxis?this.props.onDrag(e,mu(mu({},t),{x:this.originalPosition.x+i,y:t.y+s,deltaX:0})):void 0:this.props.onDrag(e,mu(mu({},t),{x:t.x+i,y:t.y+s}))}},t.prototype.onDragStop=function(e,t){if(this.props.onDragStop){var r=this.offsetFromParent,i=r.left,s=r.top;return this.props.dragAxis&&"both"!==this.props.dragAxis?"x"===this.props.dragAxis?this.props.onDragStop(e,mu(mu({},t),{x:t.x+i,y:this.originalPosition.y+s,deltaY:0})):"y"===this.props.dragAxis?this.props.onDragStop(e,mu(mu({},t),{x:this.originalPosition.x+i,y:t.y+s,deltaX:0})):void 0:this.props.onDragStop(e,mu(mu({},t),{x:t.x+i,y:t.y+s}))}},t.prototype.onResizeStart=function(e,t,r){e.stopPropagation(),this.setState({resizing:!0});var i=this.props.scale,s=this.offsetFromParent,n=this.getDraggablePosition();if(this.resizingPosition={x:n.x+s.left,y:n.y+s.top},this.originalPosition=n,this.props.bounds){var a=this.getParent(),o=void 0;"parent"===this.props.bounds?o=a:"body"===this.props.bounds?o=document.body:"window"===this.props.bounds?o=window:"string"==typeof this.props.bounds?o=document.querySelector(this.props.bounds):this.props.bounds instanceof HTMLElement&&(o=this.props.bounds);var l=this.getSelfElement();if(l instanceof Element&&(o instanceof HTMLElement||o===window)&&a instanceof HTMLElement){var c=this.getMaxSizesFromProps(),d=c.maxWidth,u=c.maxHeight,h=this.getParentSize();if(d&&"string"==typeof d)if(d.endsWith("%")){var f=Number(d.replace("%",""))/100;d=h.width*f}else d.endsWith("px")&&(d=Number(d.replace("px","")));if(u&&"string"==typeof u)if(u.endsWith("%")){f=Number(u.replace("%",""))/100;u=h.height*f}else u.endsWith("px")&&(u=Number(u.replace("px","")));var p=l.getBoundingClientRect(),m=p.left,g=p.top,v="window"===this.props.bounds?{left:0,top:0}:o.getBoundingClientRect(),y=v.left,b=v.top,E=this.getOffsetWidth(o),w=this.getOffsetHeight(o),S=t.toLowerCase().endsWith("left"),T=t.toLowerCase().endsWith("right"),x=t.startsWith("top"),A=t.startsWith("bottom");if((S||x)&&this.resizable){var k=(m-y)/i+this.resizable.size.width;this.setState({maxWidth:k>Number(d)?d:k})}if(T||this.props.lockAspectRatio&&!S&&!x){k=E+(y-m)/i;this.setState({maxWidth:k>Number(d)?d:k})}if((x||S)&&this.resizable){k=(g-b)/i+this.resizable.size.height;this.setState({maxHeight:k>Number(u)?u:k})}if(A||this.props.lockAspectRatio&&!x&&!S){k=w+(b-g)/i;this.setState({maxHeight:k>Number(u)?u:k})}}}else this.setState({maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight});this.props.onResizeStart&&this.props.onResizeStart(e,t,r)},t.prototype.onResize=function(e,t,r,i){var s=this,n={x:this.originalPosition.x,y:this.originalPosition.y},a=-i.width,o=-i.height;["top","left","topLeft","bottomLeft","topRight"].includes(t)&&("bottomLeft"===t?n.x+=a:("topRight"===t||(n.x+=a),n.y+=o));var l=this.draggable.state;n.x===l.x&&n.y===l.y||v(function(){s.draggable.setState(n)}),this.updateOffsetFromParent();var c=this.offsetFromParent,d=this.getDraggablePosition().x+c.left,u=this.getDraggablePosition().y+c.top;this.resizingPosition={x:d,y:u},this.props.onResize&&this.props.onResize(e,t,r,i,{x:d,y:u})},t.prototype.onResizeStop=function(e,t,r,i){this.setState({resizing:!1});var s=this.getMaxSizesFromProps(),n=s.maxWidth,a=s.maxHeight;this.setState({maxWidth:n,maxHeight:a}),this.props.onResizeStop&&this.props.onResizeStop(e,t,r,i,this.resizingPosition)},t.prototype.updateSize=function(e){this.resizable&&this.resizable.updateSize({width:e.width,height:e.height})},t.prototype.updatePosition=function(e){this.draggable.setState(e)},t.prototype.updateOffsetFromParent=function(){var e=this.props.scale,t=this.getParent(),r=this.getSelfElement();if(!t||null===r)return{top:0,left:0};var i=t.getBoundingClientRect(),s=i.left,n=i.top,a=r.getBoundingClientRect(),o=this.getDraggablePosition(),l=t.scrollLeft,c=t.scrollTop;this.offsetFromParent={left:a.left-s+l-o.x*e,top:a.top-n+c-o.y*e}},t.prototype.render=function(){var e=this,t=this.props,r=t.disableDragging,i=t.style,s=t.dragHandleClassName,n=t.position,a=t.onMouseDown,o=t.onMouseUp,c=t.dragAxis,d=t.dragGrid,u=t.bounds,h=t.enableUserSelectHack,f=t.cancel,p=t.children;t.onResizeStart,t.onResize,t.onResizeStop,t.onDragStart,t.onDrag,t.onDragStop;var m=t.resizeHandleStyles,g=t.resizeHandleClasses,v=t.resizeHandleComponent,y=t.enableResizing,b=t.resizeGrid,E=t.resizeHandleWrapperClass,w=t.resizeHandleWrapperStyle,S=t.scale,T=t.allowAnyClick,x=t.dragPositionOffset,A=function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(i=Object.getOwnPropertySymbols(e);s<i.length;s++)t.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(e,i[s])&&(r[i[s]]=e[i[s]])}return r}(t,["disableDragging","style","dragHandleClassName","position","onMouseDown","onMouseUp","dragAxis","dragGrid","bounds","enableUserSelectHack","cancel","children","onResizeStart","onResize","onResizeStop","onDragStart","onDrag","onDragStop","resizeHandleStyles","resizeHandleClasses","resizeHandleComponent","enableResizing","resizeGrid","resizeHandleWrapperClass","resizeHandleWrapperStyle","scale","allowAnyClick","dragPositionOffset"]),k=this.props.default?mu({},this.props.default):void 0;delete A.default;var L,I=r||s?{cursor:"auto"}:{cursor:"move"},R=mu(mu(mu({},gu),I),i),P=this.offsetFromParent,C=P.left,D=P.top;n&&(L={x:n.x-C,y:n.y-D});var _,O=this.state.resizing?void 0:L,M=this.state.resizing?"both":c;return l(Kd,{ref:function(t){t&&(e.draggable=t)},handle:s?".".concat(s):void 0,defaultPosition:k,onMouseDown:a,onMouseUp:o,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop,axis:M,disabled:r,grid:d,bounds:u?this.state.bounds:void 0,position:O,enableUserSelectHack:h,cancel:f,scale:S,allowAnyClick:T,nodeRef:this.resizableElement,positionOffset:x},l(fu,mu({},A,{ref:function(t){t&&(e.resizable=t,e.resizableElement.current=t.resizable)},defaultSize:k,size:this.props.size,enable:"boolean"==typeof y?(_=y,{bottom:_,bottomLeft:_,bottomRight:_,left:_,right:_,top:_,topLeft:_,topRight:_}):y,onResizeStart:this.onResizeStart,onResize:this.onResize,onResizeStop:this.onResizeStop,style:R,minWidth:this.props.minWidth,minHeight:this.props.minHeight,maxWidth:this.state.resizing?this.state.maxWidth:this.props.maxWidth,maxHeight:this.state.resizing?this.state.maxHeight:this.props.maxHeight,grid:b,handleWrapperClass:E,handleWrapperStyle:w,lockAspectRatio:this.props.lockAspectRatio,lockAspectRatioExtraWidth:this.props.lockAspectRatioExtraWidth,lockAspectRatioExtraHeight:this.props.lockAspectRatioExtraHeight,handleStyles:m,handleClasses:g,handleComponent:v,scale:this.props.scale}),p))},t.defaultProps={maxWidth:Number.MAX_SAFE_INTEGER,maxHeight:Number.MAX_SAFE_INTEGER,scale:1,onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},onDragStart:function(){},onDrag:function(){},onDragStop:function(){}},t}(f);const yu=({shortform:e,setClose:r})=>{const[s,n]=t.useState(!0),[o,l]=a(!0),[c,d]=a(!1),u=t.useRef(null),h=()=>{u.current&&(window.clearTimeout(u.current),u.current=null)},f=(e=1500)=>{h(),u.current=window.setTimeout(()=>d(!1),e)};return i(()=>()=>h(),[]),t.createElement("div",{className:"relative w-full h-full",onClick:()=>{d(!0),f(2e3)},onMouseLeave:()=>f(800),onMouseEnter:()=>c&&f(1500)},t.createElement("div",{className:"absolute inset-0 bg-black",style:{zIndex:1,opacity:c?.4:0,transition:"opacity 300ms ease",pointerEvents:c?"auto":"none"}}),t.createElement("div",{className:"absolute inset-0",style:{zIndex:2,opacity:c?1:0,transition:"opacity 300ms ease",pointerEvents:c?"auto":"none"}},t.createElement("div",{className:"absolute text-white flex gap-2",style:{zIndex:3,top:8,right:8}},t.createElement("button",{className:"cursor-pointer",onClick:e=>{e.stopPropagation(),n(e=>!e)},"aria-label":s?"Unmute":"Mute"},s?t.createElement(Ur,{size:20}):t.createElement(Br,{size:20})),t.createElement("button",{className:"cursor-pointer",onClick:e=>{null==e||e.stopPropagation(),r()},"aria-label":"Close"},t.createElement(zr,{size:20}))),t.createElement("div",{className:"absolute inset-0 flex items-center justify-center",style:{pointerEvents:"none"}},t.createElement("button",{onClick:e=>{null==e||e.stopPropagation(),l(e=>!e)},"aria-label":o?"Pause":"Play",className:"cursor-pointer text-white p-2 ",style:{pointerEvents:"auto"}},o?t.createElement(Nr,{size:28}):t.createElement(Fr,{size:28})))),t.createElement(Ot,{shortform:e,mute:s,play:o}))},bu=({shortsId:e,type:r})=>{const{shortform:s}=wd(),[n,o]=a(!1),{playtime:l}=Ao(),c=()=>{if(!s)return;o(!0);const{shortsId:e,uuid:t,userId:r}=s;La({contentId:e,uuid:t,type:wt.SHORTS,playtime:l,userId:r})};(({shorform:e,playtime:t})=>{i(()=>{if(!e)return;const{shortsId:t,shortsUuid:r,userId:i}=e;ka({contentId:t,uuid:r,type:wt.SHORTS,userId:i,isFirstPlay:!Rt(t)})},[]);const r=To();i(()=>{if(!e||r)return;const{shortsId:i,uuid:s,userId:n}=e;La({contentId:i,uuid:s,type:wt.SHORTS,playtime:t,userId:n})},[r])})({shorform:s,playtime:l});const{w:d,h:u,left:h,top:f}=(()=>{const e=window.visualViewport;return e?{w:e.width,h:e.height,left:e.offsetLeft,top:e.offsetTop}:{w:window.innerWidth,h:window.innerHeight,left:0,top:0}})();return s&&!n&&t.createElement(vu,{minWidth:240,lockAspectRatio:9/16,style:{zIndex:99999},default:{width:240,height:427,x:h+d-240-50,y:f+u-427-50},bounds:"window"},"shopping"===r&&s.productsInfo.length>0?t.createElement(to,{shortForm:s,handleClose:c}):t.createElement(yu,{shortform:s,setClose:c}))},Eu=({shortsId:e,type:r,isPreview:s})=>{const{setShortform:n,shortform:a}=wd();return i(()=>{if(!e)return;e&&x(void 0,void 0,void 0,function*(){const t=yield Da(e,s);t&&n(Object.assign(Object.assign({},t),{uuid:Lt()}))})},[e]),a?t.createElement(Sr.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:99999}},t.createElement(fo,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(bu,{shortsId:e,type:r}))):null},wu=t.createContext(null),Su=({children:e})=>{const r=t.useRef(null);return r.current||(r.current=Ma(e=>({liveWidget:null,setLiveWidget:t=>e({liveWidget:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})}))),t.createElement(wu.Provider,{value:r.current},e)};function Tu(e){const r=t.useContext(wu);if(!r)throw new Error("Missing LiveWidgetProvider");return Fa(r,e)}var xu;!function(e){e[e.READY=1]="READY",e[e.STREAMING=2]="STREAMING",e[e.PAUSED=3]="PAUSED"}(xu||(xu={}));const Au=({opacity:e=.4,className:r})=>{const i=Math.max(0,Math.min(1,e));return t.createElement("div",{"aria-hidden":!0,role:"presentation",className:`absolute inset-0 pointer-events-none ${null!=r?r:""}`,style:{backgroundColor:`rgba(0,0,0,${i})`,borderRadius:"inherit"}})},ku=({content:e})=>{const{PLAYER_BASE_URL:r}=gt();return t.createElement("iframe",{src:`${r}/live/${e.eventId}`,className:"w-full h-full block",style:{border:0,display:"block"},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade"})},Lu=(e,r)=>{const[i,s]=t.useState({}),[n,a]=t.useState({primary:20,secondary:12});return t.useLayoutEffect(()=>{s({})},[e]),t.useEffect(()=>{const t=r.current;if(!t)return;const i=()=>{const r=t.getBoundingClientRect(),i=Math.max(0,Math.floor(r.width)),n=Math.max(0,Math.floor(r.height)),[o,l]=e.includes("/")?e.split("/").map(e=>parseFloat(e)):[1,1],c=l/o;let d,u;i>0&&n>0?(d=i,u=Math.round(d*c),u>n&&(u=n,d=Math.round(u/c)),s({width:d,height:u})):s({});const h="number"==typeof d?d:i,f=Math.max(16,Math.round(.075*h)),p=Math.max(11,Math.round(.042*h));a({primary:f,secondary:p})};if("undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>i());return e.observe(t),()=>e.disconnect()}{const e=()=>i();return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}},[e]),{fontSize:n,boxSize:i}},Iu=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:s})=>{var n,o;const{leftTime:l}=(e=>{const{start:t}=e,r=qe().tz("Asia/Seoul").unix(),[i,s]=a(t-r>0?t-r:0);return xo(()=>{s(i<=0?0:e=>e-1)},1e3),{leftTime:i}})(e),c=null===(o=null===(n=null==e?void 0:e.designInfo)||void 0===n?void 0:n.thumbPath)||void 0===o?void 0:o.preview,d=t.useRef(null),{boxSize:u,fontSize:h}=Lu(r,d),{PLAYER_BASE_URL:f}=gt(),p=Math.floor(Date.now()/1e3),m="number"==typeof e.end&&e.end>0&&e.end<p;return t.createElement("div",{className:"w-full h-full flex items-center justify-center",ref:d},t.createElement("div",{className:"relative rounded overflow-hidden",style:{width:u.width?`${u.width}px`:"100%",height:u.height?`${u.height}px`:"100%",borderRadius:`${null!=s?s:10}px`,backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",aspectRatio:u.height?void 0:r,backgroundImage:c?`url(${Ct(c)})`:void 0,backgroundColor:c?void 0:"black"}},1===e.openStatus?t.createElement(t.Fragment,null,t.createElement(ku,{content:e}),t.createElement("a",{href:`${f}/live/${e.eventId}`,target:"_blank",rel:"noopener noreferrer","aria-label":`${e.eventName} 바로가기`,style:{position:"absolute",inset:0,zIndex:30,display:"block",textDecoration:"none",cursor:"pointer",background:"transparent"}})):m?t.createElement(t.Fragment,null,t.createElement(Au,null),t.createElement("div",{className:"text-white flex flex-col items-center justify-center absolute inset-0",style:{zIndex:10,gap:"12px",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",cursor:i,pointerEvents:"none"}},t.createElement("p",{style:{fontSize:`${h.primary}px`,fontWeight:700}},"다시보기"),t.createElement("p",{style:{fontSize:`${h.secondary}px`}},"라이브가 종료되었습니다"))):t.createElement(t.Fragment,null,t.createElement(Au,null),t.createElement("div",{className:"text-white flex flex-col items-center justify-center absolute inset-0",style:{zIndex:10,gap:"20px",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",cursor:i,pointerEvents:"none"}},t.createElement("p",{style:{fontSize:`${h.primary}px`}},((e,t)=>{if(e>86400)return qe.unix(t).tz("Asia/Seoul").format("M월 D일 A h시 mm분");const r=qe.duration(e,"seconds");return`${r.hours().toString().padStart(2,"0")}:${r.minutes().toString().padStart(2,"0")}:${r.seconds().toString().padStart(2,"0")}`})(l,e.start)),t.createElement("p",{style:{fontSize:`${h.secondary}px`}},"곧 라이브가 시작됩니다!")))))},Ru=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},Pu=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=Cu},Cu=Number.MAX_SAFE_INTEGER||9007199254740991;let Du=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),_u=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),Ou=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.STALL_RESOLVED="hlsStallResolved",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({});var Mu="manifest",Nu="level",Fu="audioTrack",$u="subtitleTrack",Bu="main",Uu="audio",zu="subtitle";class Gu{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){const r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class ju{constructor(e,t,r,i=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Gu(e),this.fast_=new Gu(t),this.defaultTTFB_=i,this.ttfb_=new Gu(e)}update(e,t){const{slow_:r,fast_:i,ttfb_:s}=this;r.halfLife!==e&&(this.slow_=new Gu(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new Gu(t,i.getEstimate(),i.getTotalWeight())),s.halfLife!==e&&(this.ttfb_=new Gu(e,s.getEstimate(),s.getTotalWeight()))}sample(e,t){const r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)}sampleTTFB(e){const t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function Hu(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Vu(){return Vu=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},Vu.apply(null,arguments)}function Wu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function Yu(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Wu(Object(r),!0).forEach(function(t){Hu(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Wu(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class Ku{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const r=`[${e}]:`;this.trace=qu,this.debug=t.debug.bind(null,r),this.log=t.log.bind(null,r),this.warn=t.warn.bind(null,r),this.info=t.info.bind(null,r),this.error=t.error.bind(null,r)}}const qu=function(){},Xu={trace:qu,debug:qu,log:qu,warn:qu,info:qu,error:qu};function Qu(){return Vu({},Xu)}function Zu(e,t,r){return t[e]?t[e].bind(t):function(e,t){const r=self.console[e];return r?r.bind(self.console,`${t?"["+t+"] ":""}[${e}] >`):qu}(e,r)}const Ju=Qu();const eh=Ju;function th(e=!0){if("undefined"==typeof self)return;return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function rh(e,t){const r=Object.keys(e),i=Object.keys(t),s=r.length,n=i.length;return!s||!n||s===n&&!r.some(e=>-1===i.indexOf(e))}function ih(e,t=!1){if("undefined"!=typeof TextDecoder){const r=new TextDecoder("utf-8").decode(e);if(t){const e=r.indexOf("\0");return-1!==e?r.substring(0,e):r}return r.replace(/\0/g,"")}const r=e.length;let i,s,n,a="",o=0;for(;o<r;){if(i=e[o++],0===i&&t)return a;if(0!==i&&3!==i)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:s=e[o++],a+=String.fromCharCode((31&i)<<6|63&s);break;case 14:s=e[o++],n=e[o++],a+=String.fromCharCode((15&i)<<12|(63&s)<<6|63&n)}}return a}function sh(e){let t="";for(let r=0;r<e.length;r++){let i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t}function nh(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function ah(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var oh,lh={exports:{}};var ch,dh,uh,hh,fh,ph=oh?lh.exports:(oh=1,ch=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,dh=/^(?=([^\/?#]*))\1([^]*)$/,uh=/(?:\/|^)\.(?=\/)/g,hh=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,lh.exports=fh={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=fh.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=fh.normalizePath(i.path),fh.buildURLFromParts(i)}var s=fh.parseURL(t);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return r.alwaysNormalize?(s.path=fh.normalizePath(s.path),fh.buildURLFromParts(s)):t;var n=fh.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");if(!n.netLoc&&n.path&&"/"!==n.path[0]){var a=dh.exec(n.path);n.netLoc=a[1],n.path=a[2]}n.netLoc&&!n.path&&(n.path="/");var o={scheme:n.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(o.netLoc=n.netLoc,"/"!==s.path[0]))if(s.path){var l=n.path,c=l.substring(0,l.lastIndexOf("/")+1)+s.path;o.path=fh.normalizePath(c)}else o.path=n.path,s.params||(o.params=n.params,s.query||(o.query=n.query));return null===o.path&&(o.path=r.alwaysNormalize?fh.normalizePath(s.path):s.path),fh.buildURLFromParts(o)},parseURL:function(e){var t=ch.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(uh,"");e.length!==(e=e.replace(hh,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}});class mh{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var gh="audio",vh="video",yh="audiovideo";class bh{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof e&&(e={url:e}),this.base=e,function(e,t){const r=Th(e,t);r&&(r.enumerable=!0,Object.defineProperty(e,t,r))}(this,"stats")}setByteRange(e,t){const r=e.split("@",2);let i;i=1===r.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(r[1]),this._byteRange=[i,parseInt(r[0])+i]}get baseurl(){return this.base.url}get byteRange(){return null===this._byteRange?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return null===this._streams&&(this._streams={[gh]:null,[vh]:null,[yh]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return null!==this._stats}get hasStreams(){return null!==this._streams}get stats(){return null===this._stats&&(this._stats=new mh),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=ph.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[gh]=null,e[vh]=null,e[yh]=null}}function Eh(e){return"initSegment"!==e.sn}class wh extends bh{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if(Ru(e)&&Ru(t))return t-e}return null}get bitrate(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){var e;const{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(null==(e=this._decryptdata)||!e.keyId){const e=Object.keys(t);if(1===e.length){const r=this._decryptdata=t[e[0]]||null;r&&(this._decryptdata=r.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;const e=Ru(this.duration)?this.duration:0;return this.programDateTime+1e3*e}get encrypted(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t;const e=Object.keys(this.levelkeys),r=e.length;if(r>1||1===r&&null!=(t=this.levelkeys[e[0]])&&t.encrypted)return!0}return!1}get programDateTime(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){Ru(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}get ref(){return Eh(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){const t=this.levelkeys;if(t){var r;const i=t[e];!i||null!=(r=this._decryptdata)&&r.keyId||(this._decryptdata=i.getDecryptData(this.sn,t))}}abortRequests(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}setElementaryStreamInfo(e,t,r,i,s,n=!1){const{elementaryStreams:a}=this,o=a[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,s)):a[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:s,partial:n}}}class Sh extends bh{constructor(e,t,r,i,s){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=i;const n=e.enumeratedString("BYTERANGE");n&&this.setByteRange(n,s),s&&(this.fragOffset=s.fragOffset+s.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}function Th(e,t){const r=Object.getPrototypeOf(e);if(r){const e=Object.getOwnPropertyDescriptor(r,t);return e||Th(r,t)}}const xh=Math.pow(2,32)-1,Ah=[].push,kh={video:1,audio:2,id3:3,text:4};function Lh(e){return String.fromCharCode.apply(null,e)}function Ih(e,t){const r=e[t]<<8|e[t+1];return r<0?65536+r:r}function Rh(e,t){const r=Ch(e,t);return r<0?4294967296+r:r}function Ph(e,t){let r=Rh(e,t);return r*=Math.pow(2,32),r+=Rh(e,t+4),r}function Ch(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function Dh(e,t){const r=[];if(!t.length)return r;const i=e.byteLength;for(let s=0;s<i;){const n=Rh(e,s),a=n>1?s+n:i;if(Lh(e.subarray(s+4,s+8))===t[0])if(1===t.length)r.push(e.subarray(s+8,a));else{const i=Dh(e.subarray(s+8,a),t.slice(1));i.length&&Ah.apply(r,i)}s=a}return r}function _h(e){const t=[],r=e[0];let i=8;const s=Rh(e,i);i+=4;let n=0,a=0;0===r?(n=Rh(e,i),a=Rh(e,i+4),i+=8):(n=Ph(e,i),a=Ph(e,i+8),i+=16),i+=2;let o=e.length+a;const l=Ih(e,i);i+=2;for(let r=0;r<l;r++){let r=i;const n=Rh(e,r);r+=4;const a=2147483647&n;if(1===(2147483648&n)>>>31)return eh.warn("SIDX has hierarchical references (not supported)"),null;const l=Rh(e,r);r+=4,t.push({referenceSize:a,subsegmentDuration:l,info:{duration:l/s,start:o,end:o+a-1}}),o+=a,r+=4,i=r}return{earliestPresentationTime:n,timescale:s,version:r,referencesCount:l,references:t}}function Oh(e){const t=[],r=Dh(e,["moov","trak"]);for(let e=0;e<r.length;e++){const i=r[e],s=Dh(i,["tkhd"])[0];if(s){let e=s[0];const r=Rh(s,0===e?12:20),n=Dh(i,["mdia","mdhd"])[0];if(n){e=n[0];const s=Rh(n,0===e?12:20),a=Dh(i,["mdia","hdlr"])[0];if(a){const e=Lh(a.subarray(8,12)),n={soun:gh,vide:vh}[e],o=Mh(Dh(i,["mdia","minf","stbl","stsd"])[0]);n?(t[r]={timescale:s,type:n,stsd:o},t[n]=Yu({timescale:s,id:r},o)):t[r]={timescale:s,type:e,stsd:o}}}}}return Dh(e,["moov","mvex","trex"]).forEach(e=>{const r=Rh(e,4),i=t[r];i&&(i.default={duration:Rh(e,12),flags:Rh(e,20)})}),t}function Mh(e){const t=e.subarray(8),r=t.subarray(86),i=Lh(t.subarray(4,8));let s,n=i;const a="enca"===i||"encv"===i;if(a){const e=Dh(t,[i])[0];Dh(e.subarray("enca"===i?28:78),["sinf"]).forEach(e=>{const t=Dh(e,["schm"])[0];if(t){const r=Lh(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=Dh(e,["frma"])[0];t&&(n=Lh(t))}}})}const o=n;switch(n){case"avc1":case"avc2":case"avc3":case"avc4":{const e=Dh(r,["avcC"])[0];e&&e.length>3&&(n+="."+$h(e[1])+$h(e[2])+$h(e[3]),s=Nh("avc1"===o?"dva1":"dvav",r));break}case"mp4a":{const e=Dh(t,[i])[0],r=Dh(e.subarray(28),["esds"])[0];if(r&&r.length>7){let e=4;if(3!==r[e++])break;e=Fh(r,e),e+=2;const t=r[e++];if(128&t&&(e+=2),64&t&&(e+=r[e++]),4!==r[e++])break;e=Fh(r,e);const i=r[e++];if(64!==i)break;if(n+="."+$h(i),e+=12,5!==r[e++])break;e=Fh(r,e);const s=r[e++];let a=(248&s)>>3;31===a&&(a+=1+((7&s)<<3)+((224&r[e])>>5)),n+="."+a}break}case"hvc1":case"hev1":{const e=Dh(r,["hvcC"])[0];if(e&&e.length>12){const t=e[1],r=["","A","B","C"][t>>6],i=31&t,s=Rh(e,2),a=(32&t)>>5?"H":"L",o=e[12],l=e.subarray(6,12);n+="."+r+i,n+="."+function(e){let t=0;for(let r=0;r<32;r++)t|=(e>>r&1)<<31-r;return t>>>0}(s).toString(16).toUpperCase(),n+="."+a+o;let c="";for(let e=l.length;e--;){const t=l[e];if(t||c){c="."+t.toString(16).toUpperCase()+c}}n+=c}s=Nh("hev1"==o?"dvhe":"dvh1",r);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":n=Nh(n,r)||n;break;case"vp09":{const e=Dh(r,["vpcC"])[0];if(e&&e.length>6){const t=e[4],r=e[5],i=e[6]>>4&15;n+="."+Bh(t)+"."+Bh(r)+"."+Bh(i)}break}case"av01":{const e=Dh(r,["av1C"])[0];if(e&&e.length>2){const t=e[1]>>>5,i=31&e[1],a=e[2]>>>7?"H":"M",o=(64&e[2])>>6,l=(32&e[2])>>5,c=2===t&&o?l?12:10:o?10:8,d=(16&e[2])>>4,u=(8&e[2])>>3,h=(4&e[2])>>2,f=3&e[2],p=1,m=1,g=1,v=0;n+="."+t+"."+Bh(i)+a+"."+Bh(c)+"."+d+"."+u+h+f+"."+Bh(p)+"."+Bh(m)+"."+Bh(g)+"."+v,s=Nh("dav1",r)}break}}return{codec:n,encrypted:a,supplemental:s}}function Nh(e,t){const r=Dh(t,["dvvC"]),i=r.length?r[0]:Dh(t,["dvcC"])[0];if(i){const t=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return e+"."+Bh(t)+"."+Bh(r)}}function Fh(e,t){const r=t+5;for(;128&e[t++]&&t<r;);return t}function $h(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function Bh(e){return(e<10?"0":"")+e}function Uh(e,t){Dh(e,["moov","trak"]).forEach(e=>{const r=Dh(e,["mdia","minf","stbl","stsd"])[0];if(!r)return;const i=r.subarray(8);let s=Dh(i,["enca"]);const n=s.length>0;n||(s=Dh(i,["encv"])),s.forEach(e=>{Dh(n?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{const r=zh(e);r&&t(r,n)})})})}function zh(e){const t=Dh(e,["schm"])[0];if(t){const r=Lh(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=Dh(e,["schi","tenc"])[0];if(t)return t}}}function Gh(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function jh(e,t){const r=[],i=t.samples,s=t.timescale,n=t.id;let a=!1;return Dh(i,["moof"]).map(o=>{const l=o.byteOffset-8;Dh(o,["traf"]).map(o=>{const c=Dh(o,["tfdt"]).map(e=>{const t=e[0];let r=Rh(e,4);return 1===t&&(r*=Math.pow(2,32),r+=Rh(e,8)),r/s})[0];return void 0!==c&&(e=c),Dh(o,["tfhd"]).map(c=>{const d=Rh(c,4),u=16777215&Rh(c,0);let h=0;const f=!!(16&u);let p=0;const m=!!(32&u);let g=8;d===n&&(!!(1&u)&&(g+=8),!!(2&u)&&(g+=4),!!(8&u)&&(h=Rh(c,g),g+=4),f&&(p=Rh(c,g),g+=4),m&&(g+=4),"video"===t.type&&(a=Hh(t.codec)),Dh(o,["trun"]).map(n=>{const o=n[0],c=16777215&Rh(n,0),d=!!(1&c);let u=0;const f=!!(4&c),m=!!(256&c);let g=0;const v=!!(512&c);let y=0;const b=!!(1024&c),E=!!(2048&c);let w=0;const S=Rh(n,4);let T=8;d&&(u=Rh(n,T),T+=4),f&&(T+=4);let x=u+l;for(let l=0;l<S;l++){if(m?(g=Rh(n,T),T+=4):g=h,v?(y=Rh(n,T),T+=4):y=p,b&&(T+=4),E&&(w=0===o?Rh(n,T):Ch(n,T),T+=4),t.type===vh){let t=0;for(;t<y;){const n=Rh(i,x);if(x+=4,Vh(a,i[x])){Wh(i.subarray(x,x+n),a?2:1,e+w/s,r)}x+=n,t+=n+4}}e+=g/s}}))})})}),r}function Hh(e){if(!e)return!1;const t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function Vh(e,t){if(e){const e=t>>1&63;return 39===e||40===e}return 6===(31&t)}function Wh(e,t,r,i){const s=Yh(e);let n=0;n+=t;let a=0,o=0,l=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;l=s[n++],a+=l}while(255===l);o=0;do{if(n>=s.length)break;l=s[n++],o+=l}while(255===l);const e=s.length-n;let t=n;if(o<e)n+=o;else if(o>e){eh.error(`Malformed SEI payload. ${o} is too small, only ${e} bytes left to parse.`);break}if(4===a){if(181===s[t++]){const e=Ih(s,t);if(t+=2,49===e){const e=Rh(s,t);if(t+=4,1195456820===e){const e=s[t++];if(3===e){const n=s[t++],o=64&n,l=o?2+3*(31&n):0,c=new Uint8Array(l);if(o){c[0]=n;for(let e=1;e<l;e++)c[e]=s[t++]}i.push({type:e,payloadType:a,pts:r,bytes:c})}}}}}else if(5===a&&o>16){const e=[];for(let r=0;r<16;r++){const i=s[t++].toString(16);e.push(1==i.length?"0"+i:i),3!==r&&5!==r&&7!==r&&9!==r||e.push("-")}const n=o-16,l=new Uint8Array(n);for(let e=0;e<n;e++)l[e]=s[t++];i.push({payloadType:a,pts:r,uuid:e.join(""),userData:ih(l),userDataBytes:l})}}}function Yh(e){const t=e.byteLength,r=[];let i=1;for(;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;const s=t-r.length,n=new Uint8Array(s);let a=0;for(i=0;i<s;a++,i++)a===r[0]&&(a++,r.shift()),n[i]=e[a];return n}function Kh(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");let i,s,n;i=0,s=new Uint8Array,n=new Uint8Array;const a=new Uint8Array(4);return r.byteLength>0&&new DataView(a.buffer).setUint32(0,r.byteLength,!1),function(e,...t){const r=t.length;let i=8,s=r;for(;s--;)i+=t[s].byteLength;const n=new Uint8Array(i);for(n[0]=i>>24&255,n[1]=i>>16&255,n[2]=i>>8&255,n[3]=255&i,n.set(e,4),s=0,i=8;s<r;s++)n.set(t[s],i),i+=t[s].byteLength;return n}([112,115,115,104],new Uint8Array([0,0,0,0]),e,n,s,a,r)}function qh(e){const t=e.getUint32(0),r=e.byteOffset,i=e.byteLength;if(i<t)return{offset:r,size:i};if(1886614376!==e.getUint32(4))return{offset:r,size:t};const s=e.getUint32(8)>>>24;if(0!==s&&1!==s)return{offset:r,size:t};const n=e.buffer,a=sh(new Uint8Array(n,r+12,16));let o=null,l=null,c=0;if(0===s)c=28;else{const s=e.getUint32(28);if(!s||i<32+16*s)return{offset:r,size:t};o=[];for(let e=0;e<s;e++)o.push(new Uint8Array(n,r+32+16*e,16));c=32+16*s}if(!c)return{offset:r,size:t};const d=e.getUint32(c);return t-32<d?{offset:r,size:t}:(l=new Uint8Array(n,r+c+4,d),{version:s,systemId:a,kids:o,data:l,offset:r,size:t})}const Xh=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),Qh={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Zh(e,t){const r=Qh[t];return!!r&&!!r[e.slice(0,4)]}function Jh(e,t,r=!0){return!e.split(",").some(e=>!ef(e,t,r))}function ef(e,t,r=!0){var i;const s=th(r);return null!=(i=null==s?void 0:s.isTypeSupported(tf(e,t)))&&i}function tf(e,t){return`${t}/mp4;codecs=${e}`}function rf(e){if(e){const t=e.substring(0,4);return Qh.video[t]}return 2}function sf(e){const t=Xh();return e.split(",").reduce((e,r)=>{const i=t&&Hh(r)?9:Qh.video[r];return i?(2*i+e)/(e?3:2):(Qh.audio[r]+e)/(e?2:1)},0)}const nf={};const af=/flac|opus|mp4a\.40\.34/i;function of(e,t=!0){return e.replace(af,e=>function(e,t=!0){if(nf[e])return nf[e];const r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e];for(let s=0;s<r.length;s++){var i;if(ef(r[s],"audio",t))return nf[e]=r[s],r[s];if("mp3"===r[s]&&null!=(i=th(t))&&i.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t))}function lf(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(cf(e,"audio")||cf(e,"video")))return e;if(t){const r=t.split(",");if(r.length>1){if(e)for(let t=r.length;t--;)if(r[t].substring(0,4)===e.substring(0,4))return r[t];return r[0]}}return t||e}function cf(e,t){return Zh(e,t)&&ef(e,t)}function df(e){if(e.startsWith("av01.")){const t=e.split("."),r=["0","111","01","01","01","0"];for(let e=t.length;e>4&&e<10;e++)t[e]=r[e-4];return t.join(".")}return e}function uf(e){const t=th(e)||{isTypeSupported:()=>!1};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}function hf(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const ff={supported:!1,smooth:!1,powerEfficient:!1},pf={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function mf(e,t){return{supported:!1,configurations:t,decodingInfoResults:[ff],error:e}}function gf(e,t,r,i,s,n){const a=e.videoCodec,o=e.audioCodec?e.audioGroups:null,l=null==n?void 0:n.audioCodec,c=null==n?void 0:n.channels,d=c?parseInt(c):l?1/0:2;let u=null;if(null!=o&&o.length)try{u=1===o.length&&o[0]?t.groups[o[0]].channels:o.reduce((e,r)=>{if(r){const i=t.groups[r];if(!i)throw new Error(`Audio track group ${r} not found`);Object.keys(i.channels).forEach(t=>{e[t]=(e[t]||0)+i.channels[t]})}return e},{2:0})}catch(e){return!0}return void 0!==a&&(a.split(",").some(e=>Hh(e))||e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(i,30)||"SDR"!==e.videoRange&&e.videoRange!==r||e.bitrate>Math.max(s,8e6))||!!u&&Ru(d)&&Object.keys(u).some(e=>parseInt(e)>d)}function vf(e,t,r,i={}){const s=e.videoCodec;if(!s&&!e.audioCodec||!r)return Promise.resolve(pf);const n=[],a=function(e){var t;const r=null==(t=e.videoCodec)?void 0:t.split(","),i=bf(e),s=e.width||640,n=e.height||480,a=e.frameRate||30,o=e.videoRange.toLowerCase();return r?r.map(e=>{const t={contentType:tf(df(e),"video"),width:s,height:n,bitrate:i,framerate:a};return"sdr"!==o&&(t.transferFunction=o),t}):[]}(e),o=a.length,l=function(e,t,r){var i;const s=null==(i=e.audioCodec)?void 0:i.split(","),n=bf(e);if(s&&e.audioGroups)return e.audioGroups.reduce((e,i)=>{var a;const o=i?null==(a=t.groups[i])?void 0:a.tracks:null;return o?o.reduce((e,t)=>{if(t.groupId===i){const i=parseFloat(t.channels||"");s.forEach(t=>{const s={contentType:tf(t,"audio"),bitrate:r?yf(t,n):n};i&&(s.channels=""+i),e.push(s)})}return e},e):e},[]);return[]}(e,t,o>0),c=l.length;for(let e=o||1*c||1;e--;){const t={type:"media-source"};if(o&&(t.video=a[e%o]),c){t.audio=l[e%c];const r=t.audio.bitrate;t.video&&r&&(t.video.bitrate-=r)}n.push(t)}if(s){const e=navigator.userAgent;if(s.split(",").some(e=>Hh(e))&&Xh())return Promise.resolve(mf(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${e})`),n))}return Promise.all(n.map(e=>{const t=function(e){let t="";const{audio:r,video:i}=e;if(i){t+=`${hf(i.contentType)}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(r){t+=`${i?"_":""}${hf(r.contentType)}_c${r.channels}`}return t}(e);return i[t]||(i[t]=r.decodingInfo(e))})).then(e=>({supported:!e.some(e=>!e.supported),configurations:n,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:n,decodingInfoResults:[],error:e}))}function yf(e,t){if(t<=1)return 1;let r=128e3;return"ec-3"===e?r=768e3:"ac-3"===e&&(r=64e4),Math.min(t/2,r)}function bf(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}const Ef=["NONE","TYPE-0","TYPE-1",null];const wf=["SDR","PQ","HLG"];var Sf="",Tf="YES",xf="v2";function Af(e){const{canSkipUntil:t,canSkipDateRanges:r,age:i}=e;return t&&i<t/2?r?xf:Tf:Sf}class kf{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){const t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class Lf{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(e=>!!e).map(e=>e.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const r=null==(t=e.supplemental)?void 0:t.videoCodec;r&&r!==e.videoCodec&&(this.codecSet+=`,${r.substring(0,4)}`)}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return If(this._audioGroups,e)}hasSubtitleGroup(e){return If(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t)if("audio"===e){let e=this._audioGroups;e||(e=this._audioGroups=[]),-1===e.indexOf(t)&&e.push(t)}else if("text"===e){let e=this._subtitleGroups;e||(e=this._subtitleGroups=[]),-1===e.indexOf(t)&&e.push(t)}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return null==(e=this.audioGroups)?void 0:e[0]}get textGroupId(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}addFallback(){}}function If(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function Rf(e,t){let r=!1,i=[];if(e&&(r="SDR"!==e,i=[e]),t){i=t.allowedVideoRanges||wf.slice(0);const e="SDR"!==i.join("")&&!t.videoCodec;r=void 0!==t.preferHDR?t.preferHDR:e&&function(){if("function"==typeof matchMedia){const e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}(),r||(i=["SDR"])}return{preferHDR:r,allowedVideoRanges:i}}const Pf=(e,t)=>JSON.stringify(e,(e=>{const t=new WeakSet;return(r,i)=>{if(e&&(i=e(r,i)),"object"==typeof i&&null!==i){if(t.has(i))return;t.add(i)}return i}})(t));function Cf(e,t){eh.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function Df(e){return e.reduce((e,t)=>{let r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);const i=t.channels||"2";return r.channels[i]=(r.channels[i]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function _f(e){if(!e)return e;const{lang:t,assocLang:r,characteristics:i,channels:s,audioCodec:n}=e;return{lang:t,assocLang:r,characteristics:i,channels:s,audioCodec:n}}function Of(e,t,r){if("attrs"in e){const r=t.indexOf(e);if(-1!==r)return r}for(let i=0;i<t.length;i++){if(Mf(e,t[i],r))return i}return-1}function Mf(e,t,r){const{groupId:i,name:s,lang:n,assocLang:a,default:o}=e,l=e.forced;return(void 0===i||t.groupId===i)&&(void 0===s||t.name===s)&&(void 0===n||function(e,t="--"){if(e.length===t.length)return e===t;return e.startsWith(t)||t.startsWith(e)}(n,t.lang))&&(void 0===n||t.assocLang===a)&&(void 0===o||t.default===o)&&(void 0===l||t.forced===l)&&(!("characteristics"in e)||function(e,t=""){const r=e.split(","),i=t.split(",");return r.length===i.length&&!r.some(e=>-1===i.indexOf(e))}(e.characteristics||"",t.characteristics))&&(void 0===r||r(e,t))}function Nf(e,t){const{audioCodec:r,channels:i}=e;return!(void 0!==r&&(t.audioCodec||"").substring(0,4)!==r.substring(0,4)||void 0!==i&&i!==(t.channels||"2"))}function Ff(e,t,r){for(let i=t;i>-1;i--)if(r(e[i]))return i;for(let i=t+1;i<e.length;i++)if(r(e[i]))return i;return-1}function $f(e,t){var r;return!!e&&e!==(null==(r=t.loadLevelObj)?void 0:r.uri)}const Bf=function(e,t){let r=0,i=e.length-1,s=null,n=null;for(;r<=i;){s=(r+i)/2|0,n=e[s];const a=t(n);if(a>0)r=s+1;else{if(!(a<0))return n;i=s-1}}return null};function Uf(e,t,r=0,i=0,s=.005){let n=null;if(e){n=t[1+e.sn-t[0].sn]||null;const i=e.endDTS-r;i>0&&i<15e-7&&(r+=15e-7),n&&e.level!==n.level&&n.end<=e.end&&(n=t[2+e.sn-t[0].sn]||null)}else 0===r&&0===t[0].start&&(n=t[0]);if(n&&((!e||e.level===n.level)&&0===zf(r,i,n)||function(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){const i=t.tagList.reduce((e,t)=>("INF"===t[0]&&(e+=parseFloat(t[1])),e),r);return e.start<=i}return!1}(n,e,Math.min(s,i))))return n;const a=Bf(t,zf.bind(null,r,i));return!a||a===e&&n?n:a}function zf(e=0,t=0,r){if(r.start<=e&&r.start+r.duration>e)return 0;const i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function Gf(e,t,r){const i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function jf(e,t,r){if(e&&e.startCC<=t&&e.endCC>=t){let i=e.fragments;const{fragmentHint:s}=e;let n;return s&&(i=i.concat(s)),Bf(i,e=>e.cc<t?1:e.cc>t?-1:(n=e,e.end<=r?1:e.start>r?-1:0)),n||null}return null}function Hf(e){switch(e.details){case _u.FRAG_LOAD_TIMEOUT:case _u.KEY_LOAD_TIMEOUT:case _u.LEVEL_LOAD_TIMEOUT:case _u.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Vf(e){return e.details.startsWith("key")}function Wf(e){return Vf(e)&&!!e.frag&&!e.frag.decryptdata}function Yf(e,t){const r=Hf(t);return e.default[(r?"timeout":"error")+"Retry"]}function Kf(e,t){const r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function qf(e){return Yu(Yu({},e),{errorRetry:null,timeoutRetry:null})}function Xf(e,t,r,i){if(!e)return!1;const s=null==i?void 0:i.code,n=t<e.maxNumRetry&&(function(e){return Qf(e)||!!e&&(e<400||e>499)}(s)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,n):n}function Qf(e){return 0===e&&!1===navigator.onLine}var Zf=0,Jf=2,ep=3,tp=5,rp=0,ip=1,sp=2,np=4;function ap(e){const t={action:Zf,flags:rp};return e&&(t.resolved=!0),t}var op="NOT_LOADED",lp="APPENDING",cp="PARTIAL",dp="OK";class up{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e&&(e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Ou.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Ou.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Ou.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Ou.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const r=this.activePartLists[t];if(r)for(let t=r.length;t--;){const i=r[t];if(!i)break;if(i.start<=e&&e<=i.end&&i.loaded)return i}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,r){const{fragments:i}=this,s=Object.keys(i);for(let n=s.length;n--;){const a=i[s[n]];if((null==a?void 0:a.body.type)===t&&(!r||a.buffered)){const t=a.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,r,i,s){this.timeRanges&&(this.timeRanges[e]=t);const n=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach(i=>{const a=this.fragments[i];if(!a)return;if(n>=a.body.sn)return;if(!a.buffered&&(!a.loaded||s))return void(a.body.type===r&&this.removeFragment(a.body));const o=a.range[e];o&&(0!==o.time.length?o.time.some(e=>{const r=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&this.removeFragment(a.body),r}):this.removeFragment(a.body))})}detectPartialFragments(e){const t=this.timeRanges;if(!t||"initSegment"===e.frag.sn)return;const r=e.frag,i=fp(r),s=this.fragments[i];if(!s||s.buffered&&r.gap)return;const n=!r.relurl;Object.keys(t).forEach(i=>{const a=r.elementaryStreams[i];if(!a)return;const o=t[i],l=n||!0===a.partial;s.range[i]=this.getBufferedTimes(r,e.part,l,o)}),s.loaded=null,Object.keys(s.range).length?(this.bufferedEnd(s,r),hp(s)||this.removeParts(r.sn-1,r.type)):this.removeFragment(s.body)}bufferedEnd(e,t){e.buffered=!0;(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}removeParts(e,t){const r=this.activePartLists[t];r&&(this.activePartLists[t]=pp(r,t=>t.fragment.sn>=e))}fragBuffered(e,t){const r=fp(e);let i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,this.bufferedEnd(i,e))}getBufferedTimes(e,t,r,i){const s={time:[],partial:r},n=e.start,a=e.end,o=e.minEndPTS||a,l=e.maxStartPTS||n;for(let e=0;e<i.length;e++){const t=i.start(e)-this.bufferPadding,r=i.end(e)+this.bufferPadding;if(l>=t&&o<=r){s.time.push({startPTS:Math.max(n,i.start(e)),endPTS:Math.min(a,i.end(e))});break}if(n<r&&a>t){const t=Math.max(n,i.start(e)),r=Math.min(a,i.end(e));r>t&&(s.partial=!0,s.time.push({startPTS:t,endPTS:r}))}else if(a<=t)break}return s}getPartialFragment(e){let t,r,i,s=null,n=0;const{bufferPadding:a,fragments:o}=this;return Object.keys(o).forEach(l=>{const c=o[l];c&&hp(c)&&(r=c.body.start-a,i=c.body.end+a,e>=r&&e<=i&&(t=Math.min(e-r,i-e),n<=t&&(s=c.body,n=t)))}),s}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||hp(t))}getState(e){const t=fp(e),r=this.fragments[t];return r?r.buffered?hp(r)?cp:dp:lp:op}isTimeBuffered(e,t,r){let i,s;for(let n=0;n<r.length;n++){if(i=r.start(n)-this.bufferPadding,s=r.end(n)+this.bufferPadding,e>=i&&t<=s)return!0;if(t<=i)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if("initSegment"===t.frag.sn||t.frag.bitrateTest)return;const r=t.frag,i=t.part?null:t,s=fp(r);this.fragments[s]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:r,part:i,timeRanges:s,type:n}=t;if("initSegment"===r.sn)return;const a=r.type;if(i){let e=this.activePartLists[a];e||(this.activePartLists[a]=e=[]),e.push(i)}this.timeRanges=s;const o=s[n];this.detectEvictedFragments(n,o,a,i)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=fp(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,r=Object.keys(t);if(!e)return r.length>0;for(let i=r.length;i--;){const s=t[r[i]];if((null==s?void 0:s.body.type)===e)return!0}return!1}hasParts(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}removeFragmentsInRange(e,t,r,i,s){i&&!this.hasGaps||Object.keys(this.fragments).forEach(n=>{const a=this.fragments[n];if(!a)return;const o=a.body;o.type!==r||i&&!o.gap||o.start<t&&o.end>e&&(a.buffered||s)&&this.removeFragment(o)})}removeFragment(e){const t=fp(e);e.clearElementaryStreamInfo();const r=this.activePartLists[e.type];if(r){const t=e.sn;this.activePartLists[e.type]=pp(r,e=>e.fragment.sn!==t)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const t=null==(e=this.hls)||null==(e=e.latestLevelDetails)?void 0:e.partList;t&&t.forEach(e=>e.clearElementaryStreamInfo())}}function hp(e){var t,r,i;return e.buffered&&!!(e.body.gap||null!=(t=e.range.video)&&t.partial||null!=(r=e.range.audio)&&r.partial||null!=(i=e.range.audiovideo)&&i.partial)}function fp(e){return`${e.type}_${e.level}_${e.sn}`}function pp(e,t){return e.filter(e=>{const r=t(e);return r||e.clearElementaryStreamInfo(),r})}var mp=0,gp=1;class vp{constructor(e,t,r){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=r}decrypt(e,t){switch(this.aesMode){case mp:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case gp:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}class yp{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const t=new DataView(e),r=new Uint32Array(4);for(let e=0;e<4;e++)r[e]=t.getUint32(4*e);return r}initTable(){const e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],s=r[1],n=r[2],a=r[3],o=this.invSubMix,l=o[0],c=o[1],d=o[2],u=o[3],h=new Uint32Array(256);let f=0,p=0,m=0;for(m=0;m<256;m++)h[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){let r=p^p<<1^p<<2^p<<3^p<<4;r=r>>>8^255&r^99,e[f]=r,t[r]=f;const o=h[f],m=h[o],g=h[m];let v=257*h[r]^16843008*r;i[f]=v<<24|v>>>8,s[f]=v<<16|v>>>16,n[f]=v<<8|v>>>24,a[f]=v,v=16843009*g^65537*m^257*o^16843008*f,l[r]=v<<24|v>>>8,c[r]=v<<16|v>>>16,d[r]=v<<8|v>>>24,u[r]=v,f?(f=o^h[h[h[g^o]]],p^=h[h[p]]):f=p=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let r=!0,i=0;for(;i<t.length&&r;)r=t[i]===this.key[i],i++;if(r)return;this.key=t;const s=this.keySize=t.length;if(4!==s&&6!==s&&8!==s)throw new Error("Invalid aes key size="+s);const n=this.ksRows=4*(s+6+1);let a,o;const l=this.keySchedule=new Uint32Array(n),c=this.invKeySchedule=new Uint32Array(n),d=this.sBox,u=this.rcon,h=this.invSubMix,f=h[0],p=h[1],m=h[2],g=h[3];let v,y;for(a=0;a<n;a++)a<s?v=l[a]=t[a]:(y=v,a%s===0?(y=y<<8|y>>>24,y=d[y>>>24]<<24|d[y>>>16&255]<<16|d[y>>>8&255]<<8|d[255&y],y^=u[a/s|0]<<24):s>6&&a%s===4&&(y=d[y>>>24]<<24|d[y>>>16&255]<<16|d[y>>>8&255]<<8|d[255&y]),l[a]=v=(l[a-s]^y)>>>0);for(o=0;o<n;o++)a=n-o,y=3&o?l[a]:l[a-4],c[o]=o<4||a<=4?y:f[d[y>>>24]]^p[d[y>>>16&255]]^m[d[y>>>8&255]]^g[d[255&y]],c[o]=c[o]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,r){const i=this.keySize+6,s=this.invKeySchedule,n=this.invSBox,a=this.invSubMix,o=a[0],l=a[1],c=a[2],d=a[3],u=this.uint8ArrayToUint32Array_(r);let h=u[0],f=u[1],p=u[2],m=u[3];const g=new Int32Array(e),v=new Int32Array(g.length);let y,b,E,w,S,T,x,A,k,L,I,R,P,C;const D=this.networkToHostOrderSwap;for(;t<g.length;){for(k=D(g[t]),L=D(g[t+1]),I=D(g[t+2]),R=D(g[t+3]),S=k^s[0],T=R^s[1],x=I^s[2],A=L^s[3],P=4,C=1;C<i;C++)y=o[S>>>24]^l[T>>16&255]^c[x>>8&255]^d[255&A]^s[P],b=o[T>>>24]^l[x>>16&255]^c[A>>8&255]^d[255&S]^s[P+1],E=o[x>>>24]^l[A>>16&255]^c[S>>8&255]^d[255&T]^s[P+2],w=o[A>>>24]^l[S>>16&255]^c[T>>8&255]^d[255&x]^s[P+3],S=y,T=b,x=E,A=w,P+=4;y=n[S>>>24]<<24^n[T>>16&255]<<16^n[x>>8&255]<<8^n[255&A]^s[P],b=n[T>>>24]<<24^n[x>>16&255]<<16^n[A>>8&255]<<8^n[255&S]^s[P+1],E=n[x>>>24]<<24^n[A>>16&255]<<16^n[S>>8&255]<<8^n[255&T]^s[P+2],w=n[A>>>24]<<24^n[S>>16&255]<<16^n[T>>8&255]<<8^n[255&x]^s[P+3],v[t]=D(y^h),v[t+1]=D(w^f),v[t+2]=D(E^p),v[t+3]=D(b^m),h=k,f=L,p=I,m=R,t+=4}return v.buffer}}class bp{constructor(e,t,r){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=r}expandKey(){const e=function(e){switch(e){case mp:return"AES-CBC";case gp:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${e}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}class Ep{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?function(e){const t=e.byteLength,r=t&&new DataView(e.buffer).getUint8(t-1);return r?e.slice(0,t-r):e}(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r,i){return this.useSoftware?new Promise((s,n)=>{const a=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(a,t,r,i);const o=this.flush();o?s(o.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r,i)}softwareDecrypt(e,t,r,i){const{currentIV:s,currentResult:n,remainderData:a}=this;if(i!==mp||16!==t.byteLength)return eh.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),a&&(e=Gh(a,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;s&&(r=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new yp),l.expandKey(t);const c=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=o.slice(-16).buffer,c||null}webCryptoDecrypt(e,t,r,i){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r,i));this.key=t,this.fastAesKey=new bp(this.subtle,t,i)}return this.fastAesKey.expandKey().then(t=>{if(!this.subtle)return Promise.reject(new Error("web crypto not initialized"));this.logOnce("WebCrypto AES decrypt");return new vp(this.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)}).catch(s=>(eh.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${s.name}: ${s.message}`),this.onWebCryptoError(e,t,r,i)))}onWebCryptoError(e,t,r,i){const s=this.enableSoftwareAES;if(s){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,i);const s=this.flush();if(s)return s.buffer}throw new Error("WebCrypto"+(s?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const r=e.length-e.length%16;return r!==e.length&&(t=e.slice(0,r),this.remainderData=e.slice(r)),t}logOnce(e){this.logEnabled&&(eh.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const wp=Math.pow(2,17);class Sp{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const r=e.url;if(!r)return Promise.reject(new Ap({type:Du.NETWORK_ERROR,details:_u.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(r?"part list":"url")),networkDetails:null}));this.abort();const i=this.config,s=i.fLoader,n=i.loader;return new Promise((a,o)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some(e=>"GAP"===e[0]))return void o(xp(e));e.gap=!1}const l=this.loader=s?new s(i):new n(i),c=Tp(e);e.loader=l;const d=qf(i.fragLoadPolicy.default),u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:wp};e.stats=l.stats;const h={onSuccess:(t,r,i,s)=>{this.resetLoader(e,l);let n=t.data;i.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(n.slice(0,16)),n=n.slice(16)),a({frag:e,part:null,payload:n,networkDetails:s})},onError:(t,i,s,n)=>{this.resetLoader(e,l),o(new Ap({type:Du.NETWORK_ERROR,details:_u.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Yu({url:r,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:s,stats:n}))},onAbort:(t,r,i)=>{this.resetLoader(e,l),o(new Ap({type:Du.NETWORK_ERROR,details:_u.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:(t,r,i)=>{this.resetLoader(e,l),o(new Ap({type:Du.NETWORK_ERROR,details:_u.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:i,stats:t}))}};t&&(h.onProgress=(r,i,s,n)=>t({frag:e,part:null,payload:s,networkDetails:n})),l.load(c,u,h)})}loadPart(e,t,r){this.abort();const i=this.config,s=i.fLoader,n=i.loader;return new Promise((a,o)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void o(xp(e,t));const l=this.loader=s?new s(i):new n(i),c=Tp(e,t);e.loader=l;const d=qf(i.fragLoadPolicy.default),u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:wp};t.stats=l.stats,l.load(c,u,{onSuccess:(i,s,n,o)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const c={frag:e,part:t,payload:i.data,networkDetails:o};r(c),a(c)},onError:(r,i,s,n)=>{this.resetLoader(e,l),o(new Ap({type:Du.NETWORK_ERROR,details:_u.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Yu({url:c.url,data:void 0},r),error:new Error(`HTTP Error ${r.code} ${r.text}`),networkDetails:s,stats:n}))},onAbort:(r,i,s)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),o(new Ap({type:Du.NETWORK_ERROR,details:_u.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:s,stats:r}))},onTimeout:(r,i,s)=>{this.resetLoader(e,l),o(new Ap({type:Du.NETWORK_ERROR,details:_u.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:s,stats:r}))}})})}updateStatsFromPart(e,t){const r=e.stats,i=t.stats,s=i.total;if(r.loaded+=i.loaded,s){const i=Math.round(e.duration/t.duration),n=Math.min(Math.round(r.loaded/s),i),a=(i-n)*Math.round(r.loaded/n);r.total=r.loaded+a}else r.total=Math.max(r.loaded,r.total);const n=r.loading,a=i.loading;n.start?n.first+=a.first-a.start:(n.start=a.start,n.first=a.first),n.end=a.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function Tp(e,t=null){const r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},s=r.byteRangeStartOffset,n=r.byteRangeEndOffset;if(Ru(s)&&Ru(n)){var a;let t=s,r=n;if("initSegment"===e.sn&&("AES-128"===(o=null==(a=e.decryptdata)?void 0:a.method)||"AES-256"===o)){const e=n-s;e%16&&(r=n+(16-e%16)),0!==s&&(i.resetIV=!0,t=s-16)}i.rangeStart=t,i.rangeEnd=r}var o;return i}function xp(e,t){const r=new Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:Du.MEDIA_ERROR,details:_u.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new Ap(i)}class Ap extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class kp extends Ku{constructor(e,t){super(e,t),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class Lp{constructor(e,t,r,i=0,s=-1,n=!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=e,this.sn=t,this.id=r,this.size=i,this.part=s,this.partial=n}}const Ip={length:0,start:()=>0,end:()=>0};class Rp{static isBuffered(e,t){if(e){const r=Rp.getBuffered(e);for(let e=r.length;e--;)if(t>=r.start(e)&&t<=r.end(e))return!0}return!1}static bufferedRanges(e){if(e){const t=Rp.getBuffered(e);return Rp.timeRangesToArray(t)}return[]}static timeRangesToArray(e){const t=[];for(let r=0;r<e.length;r++)t.push({start:e.start(r),end:e.end(r)});return t}static bufferInfo(e,t,r){if(e){const i=Rp.bufferedRanges(e);if(i.length)return Rp.bufferedInfo(i,t,r)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.length>1&&e.sort((e,t)=>e.start-t.start||t.end-e.end);let i=-1,s=[];if(r)for(let n=0;n<e.length;n++){t>=e[n].start&&t<=e[n].end&&(i=n);const a=s.length;if(a){const t=s[a-1].end;e[n].start-t<r?e[n].end>t&&(s[a-1].end=e[n].end):s.push(e[n])}else s.push(e[n])}else s=e;let n,a=0,o=t,l=t;for(let e=0;e<s.length;e++){const c=s[e].start,d=s[e].end;if(-1===i&&t>=c&&t<=d&&(i=e),t+r>=c&&t<d)o=c,l=d,a=l-t;else if(t+r<c){n=c;break}}return{len:a,start:o||0,end:l||0,nextStart:n,buffered:e,bufferedIndex:i}}static getBuffered(e){try{return e.buffered||Ip}catch(e){return eh.log("failed to get media.buffered",e),Ip}}}const Pp=/\{\$([a-zA-Z0-9-_]+)\}/g;function Cp(e){return Pp.test(e)}function Dp(e,t){if(null!==e.variableList||e.hasVariableRefs){const r=e.variableList;return t.replace(Pp,t=>{const i=t.substring(2,t.length-1),s=null==r?void 0:r[i];return void 0===s?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"`)),t):s})}return t}function _p(e,t,r){let i,s,n=e.variableList;if(n||(e.variableList=n={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{const e=new self.URL(r).searchParams;if(!e.has(i))throw new Error(`"${i}" does not match any query parameter in URI: "${r}"`);s=e.get(i)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else i=t.NAME,s=t.VALUE;i in n?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):n[i]=s||""}function Op(e,t,r){const i=t.IMPORT;if(r&&i in r){let t=e.variableList;t||(e.variableList=t={}),t[i]=r[i]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}const Mp=/^(\d+)x(\d+)$/,Np=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Fp{constructor(e,t){"string"==typeof e&&(e=Fp.parseAttrList(e,t)),Vu(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>"X-"===e.substring(0,2))}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;const r=new Uint8Array(t.length/2);for(let e=0;e<t.length/2;e++)r[e]=parseInt(t.slice(2*e,2*e+2),16);return r}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){const r=this[e];return(r?r.split(/[ ,]+/):[]).reduce((e,t)=>(e[t.toLowerCase()]=!0,e),t)}bool(e){return"YES"===this[e]}decimalResolution(e){const t=Mp.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let r;const i={};for(Np.lastIndex=0;null!==(r=Np.exec(e));){const s=r[1].trim();let n=r[2];const a=0===n.indexOf('"')&&n.lastIndexOf('"')===n.length-1;let o=!1;if(a)n=n.slice(1,-1);else switch(s){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":o=!0}if(t&&(a||o))n=Dp(t,n);else if(!o&&!a)switch(s){case"CLOSED-CAPTIONS":if("NONE"===n)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":eh.warn(`${e}: attribute ${s} is missing quotes`)}i[s]=n}return i}}function $p(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function Bp(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}class Up{constructor(e,t,r=0){var i;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==t?void 0:t.tagAnchor)||null,this.tagOrder=null!=(i=null==t?void 0:t.tagOrder)?i:r,t){const r=t.attr;for(const t in r)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==r[t]){eh.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=Vu(new Fp({}),r,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const e=(null==t?void 0:t.endDate)||new Date(this.attr["END-DATE"]);Ru(e.getTime())&&(this._endDate=e)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}get startTime(){const{tagAnchor:e}=this;return null===e||null===e.programDateTime?(eh.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const e=this._endDate||this._dateAtEnd;if(e)return e;const t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(Ru(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return"com.apple.hls.interstitial"===this.class}get isValid(){return!!this.id&&!this._badValueForSameId&&Ru(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}class zp{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!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.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e)return this.advanced=!0,void(this.updated=!0);const t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some(t=>{let r=t.decryptdata;return r||(t.setKeyFormat(e.keyFormat),r=t.decryptdata),!!r&&e.matches(r)})}get hasProgramDateTime(){return!!this.fragments.length&&Ru(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const e=this.driftEndTime-this.driftStartTime;if(e>0){return 1e3*(this.driftEnd-this.driftStart)/e}return 1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){const e=this.partList;if(e){const t=this.lastPartIndex;if(-1!==t){for(let r=e.length;r--;)if(e[r].index>t)return e[r].index;return t}}return 0}get lastPartSn(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function Gp(e,t){return e.length===t.length&&!e.some((e,r)=>e!==t[r])}function jp(e,t){return!e&&!t||!(!e||!t)&&Gp(e,t)}function Hp(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function Vp(e){switch(e){case"AES-128":case"AES-256":return mp;case"AES-256-CTR":return gp;default:throw new Error(`invalid full segment method ${e}`)}}function Wp(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function Yp(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function Kp(e){const t=function(e,t,r){const i=e[t];e[t]=e[r],e[r]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function qp(e){const t=e.split(":");let r=null;if("data"===t[0]&&2===t.length){const e=t[1].split(";"),i=e[e.length-1].split(",");if(2===i.length){const t="base64"===i[0],s=i[1];t?(e.splice(-1,1),r=Wp(s)):r=function(e){const t=Yp(e).subarray(0,16),r=new Uint8Array(16);return r.set(t,16-t.length),r}(s)}}return r}const Xp="undefined"!=typeof self?self:void 0;var Qp={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Zp="org.w3.clearkey",Jp="com.apple.streamingkeydelivery",em="com.microsoft.playready",tm="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function rm(e){switch(e){case Jp:return Qp.FAIRPLAY;case em:return Qp.PLAYREADY;case tm:return Qp.WIDEVINE;case Zp:return Qp.CLEARKEY}}function im(e){switch(e){case Qp.FAIRPLAY:return Jp;case Qp.PLAYREADY:return em;case Qp.WIDEVINE:return tm;case Qp.CLEARKEY:return Zp}}function sm(e){const{drmSystems:t,widevineLicenseUrl:r}=e,i=t?[Qp.FAIRPLAY,Qp.WIDEVINE,Qp.PLAYREADY,Qp.CLEARKEY].filter(e=>!!t[e]):[];return!i[Qp.WIDEVINE]&&r&&i.push(Qp.WIDEVINE),i}const nm=null!=Xp&&null!=(am=Xp.navigator)&&am.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var am;function om(e){const t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),r=String.fromCharCode.apply(null,Array.from(t)),i=r.substring(r.indexOf("<"),r.length),s=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(s){const e=s.childNodes[0]?s.childNodes[0].nodeValue:s.getAttribute("VALUE");if(e){const t=Wp(e).subarray(0,16);return Kp(t),t}}return null}let lm={};class cm{static clearKeyUriToKeyIdMap(){lm={}}static setKeyIdForUri(e,t){lm[e]=t}static addKeyIdForUri(e){const t=Object.keys(lm).length%Number.MAX_SAFE_INTEGER,r=new Uint8Array(16);return new DataView(r.buffer,12,4).setUint32(0,t),lm[e]=r,r}constructor(e,t,r,i=[1],s=null,n){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=s,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&!Hp(e),null!=n&&n.startsWith("0x")&&(this.keyId=new Uint8Array(nh(n)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&Gp(e.keyFormatVersions,this.keyFormatVersions)&&jp(e.iv,this.iv)&&jp(e.keyId,this.keyId)}isSupported(){if(this.method){if(Hp(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case Jp:case tm:case em:case Zp:return-1!==["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e,t){if(!this.encrypted||!this.uri)return null;if(Hp(this.method)){let t=this.iv;t||("number"!=typeof e&&(eh.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),t=function(e){const t=new Uint8Array(16);for(let r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}(e));return new cm(this.method,this.uri,"identity",this.keyFormatVersions,t)}if(this.keyId){const e=lm[this.uri];if(e&&!Gp(this.keyId,e)&&cm.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const r=qp(this.uri);if(r)switch(this.keyFormat){case tm:if(this.pssh=r,!this.keyId){const e=function(e){const t=[];if(e instanceof ArrayBuffer){const r=e.byteLength;let i=0;for(;i+32<r;){const r=qh(new DataView(e,i));t.push(r),i+=r.size}}return t}(r.buffer);if(e.length){var i;const t=e[0];this.keyId=null!=(i=t.kids)&&i.length?t.kids[0]:null}}this.keyId||(this.keyId=dm(t));break;case em:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Kh(e,0,r),this.keyId=om(r);break}default:{let e=r.subarray(0,16);if(16!==e.length){const t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e;break}}if(!this.keyId||16!==this.keyId.byteLength){let e;e=function(e){const t=null==e?void 0:e[tm];if(t)return t.keyId;return null}(t),e||(e=dm(t),e||(e=lm[this.uri])),e&&(this.keyId=e,cm.setKeyIdForUri(this.uri,e))}return this}}function dm(e){const t=null==e?void 0:e[em];if(t){const e=qp(t.uri);if(e)return om(e)}return null}const um=/#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,hm=/#EXT-X-MEDIA:(.*)/g,fm=/^#EXT(?:INF|-X-TARGETDURATION):/m,pm=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),mm=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class gm{static findGroup(e,t){for(let r=0;r<e.length;r++){const i=e[r];if(i.id===t)return i}}static resolve(e,t){return ph.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return fm.test(e)}static parseMasterPlaylist(e,t){const r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Cp(e)},i=[];if(um.lastIndex=0,!e.startsWith("#EXTM3U"))return r.playlistParsingError=new Error("no EXTM3U delimiter"),r;let s;for(;null!=(s=um.exec(e));)if(s[1]){var n;const e=new Fp(s[1],r),a=Dp(r,s[2]),o={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:gm.resolve(a,t)},l=e.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),wm(e.CODECS,o);const c=e["SUPPLEMENTAL-CODECS"];c&&(o.supplemental={},wm(c,o.supplemental)),null!=(n=o.unknownCodecs)&&n.length||i.push(o),r.levels.push(o)}else if(s[3]){const e=s[3],i=s[4];switch(e){case"SESSION-DATA":{const e=new Fp(i,r),t=e["DATA-ID"];t&&(null===r.sessionData&&(r.sessionData={}),r.sessionData[t]=e);break}case"SESSION-KEY":{const e=bm(i,t,r);e.encrypted&&e.isSupported()?(null===r.sessionKeys&&(r.sessionKeys=[]),r.sessionKeys.push(e)):eh.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":_p(r,new Fp(i,r),t);break;case"CONTENT-STEERING":{const e=new Fp(i,r);r.contentSteering={uri:gm.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":r.startTimeOffset=Em(i)}}const a=i.length>0&&i.length<r.levels.length;return r.levels=a?i:r.levels,0===r.levels.length&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,r){let i;const s={},n=r.levels,a={AUDIO:n.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:n.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]};let o=0;for(hm.lastIndex=0;null!==(i=hm.exec(e));){const e=new Fp(i[1],r),n=e.TYPE;if(n){const r=a[n],i=s[n]||[];s[n]=i;const l=e.LANGUAGE,c=e["ASSOC-LANGUAGE"],d=e.CHANNELS,u=e.CHARACTERISTICS,h=e["INSTREAM-ID"],f={attrs:e,bitrate:0,id:o++,groupId:e["GROUP-ID"]||"",name:e.NAME||l||"",type:n,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:l,url:e.URI?gm.resolve(e.URI,t):""};if(c&&(f.assocLang=c),d&&(f.channels=d),u&&(f.characteristics=u),h&&(f.instreamId=h),null!=r&&r.length){const e=gm.findGroup(r,f.groupId)||r[0];Sm(f,e,"audioCodec"),Sm(f,e,"textCodec")}i.push(f)}}return s}static parseLevelPlaylist(e,t,r,i,s,n){var a;const o={url:t},l=new zp(t),c=l.fragments,d=[];let u,h,f,p,m=null,g=0,v=0,y=0,b=0,E=0,w=null,S=new wh(i,o),T=-1,x=!1,A=null;if(pm.lastIndex=0,l.m3u8=e,l.hasVariableRefs=Cp(e),"#EXTM3U"!==(null==(a=pm.exec(e))?void 0:a[0]))return l.playlistParsingError=new Error("Missing format identifier #EXTM3U"),l;for(;null!==(u=pm.exec(e));){x&&(x=!1,S=new wh(i,o),S.playlistOffset=y,S.setStart(y),S.sn=g,S.cc=b,E&&(S.bitrate=E),S.level=r,m&&(S.initSegment=m,m.rawProgramDateTime&&(S.rawProgramDateTime=m.rawProgramDateTime,m.rawProgramDateTime=null),A&&(S.setByteRange(A),A=null)));const e=u[1];if(e){S.duration=parseFloat(e);const t=(" "+u[2]).slice(1);S.title=t||null,S.tagList.push(t?["INF",e,t]:["INF",e])}else if(u[3]){if(Ru(S.duration)){S.playlistOffset=y,S.setStart(y),f&&Am(S,f,l),S.sn=g,S.level=r,S.cc=b,c.push(S);const e=(" "+u[3]).slice(1);S.relurl=Dp(l,e),Tm(S,w,d),w=S,y+=S.duration,g++,v=0,x=!0}}else{if(u=u[0].match(mm),!u){eh.warn("No matches on slow regex match for level playlist!");continue}for(h=1;h<u.length&&void 0===u[h];h++);const e=(" "+u[h]).slice(1),s=(" "+u[h+1]).slice(1),a=u[h+2]?(" "+u[h+2]).slice(1):null;switch(e){case"BYTERANGE":w?S.setByteRange(s,w):S.setByteRange(s);break;case"PROGRAM-DATE-TIME":S.rawProgramDateTime=s,S.tagList.push(["PROGRAM-DATE-TIME",s]),-1===T&&(T=c.length);break;case"PLAYLIST-TYPE":l.type&&km(l,e,u),l.type=s.toUpperCase();break;case"MEDIA-SEQUENCE":0!==l.startSN?km(l,e,u):c.length>0&&Lm(l,e,u),g=l.startSN=parseInt(s);break;case"SKIP":{l.skippedSegments&&km(l,e,u);const t=new Fp(s,l),r=t.decimalInteger("SKIPPED-SEGMENTS");if(Ru(r)){l.skippedSegments+=r;for(let e=r;e--;)c.push(null);g+=r}const i=t.enumeratedString("RECENTLY-REMOVED-DATERANGES");i&&(l.recentlyRemovedDateranges=(l.recentlyRemovedDateranges||[]).concat(i.split("\t")));break}case"TARGETDURATION":0!==l.targetduration&&km(l,e,u),l.targetduration=Math.max(parseInt(s),1);break;case"VERSION":null!==l.version&&km(l,e,u),l.version=parseInt(s);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":l.live||km(l,e,u),l.live=!1;break;case"#":(s||a)&&S.tagList.push(a?[s,a]:[s]);break;case"DISCONTINUITY":b++,S.tagList.push(["DIS"]);break;case"GAP":S.gap=!0,S.tagList.push([e]);break;case"BITRATE":S.tagList.push([e,s]),E=1e3*parseInt(s),Ru(E)?S.bitrate=E:E=0;break;case"DATERANGE":{const e=new Fp(s,l),t=new Up(e,l.dateRanges[e.ID],l.dateRangeTagCount);l.dateRangeTagCount++,t.isValid||l.skippedSegments?l.dateRanges[t.id]=t:eh.warn(`Ignoring invalid DATERANGE tag: "${s}"`),S.tagList.push(["EXT-X-DATERANGE",s]);break}case"DEFINE":{const e=new Fp(s,l);"IMPORT"in e?Op(l,e,n):_p(l,e,t)}break;case"DISCONTINUITY-SEQUENCE":0!==l.startCC?km(l,e,u):c.length>0&&Lm(l,e,u),l.startCC=b=parseInt(s);break;case"KEY":{const e=bm(s,t,l);if(e.isSupported()){if("NONE"===e.method){f=void 0;break}f||(f={});const t=f[e.keyFormat];null!=t&&t.matches(e)||(t&&(f=Vu({},f)),f[e.keyFormat]=e)}else eh.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${s}"`);break}case"START":l.startTimeOffset=Em(s);break;case"MAP":{const e=new Fp(s,l);if(S.duration){const t=new wh(i,o);xm(t,e,r,f),m=t,S.initSegment=m,m.rawProgramDateTime&&!S.rawProgramDateTime&&(S.rawProgramDateTime=m.rawProgramDateTime)}else{const t=S.byteRangeEndOffset;if(t){const e=S.byteRangeStartOffset;A=`${t-e}@${e}`}else A=null;xm(S,e,r,f),m=S,x=!0}m.cc=b;break}case"SERVER-CONTROL":p&&km(l,e,u),p=new Fp(s),l.canBlockReload=p.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=p.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&p.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=p.optionalFloat("PART-HOLD-BACK",0),l.holdBack=p.optionalFloat("HOLD-BACK",0);break;case"PART-INF":{l.partTarget&&km(l,e,u);const t=new Fp(s);l.partTarget=t.decimalFloatingPoint("PART-TARGET");break}case"PART":{let e=l.partList;e||(e=l.partList=[]);const t=v>0?e[e.length-1]:void 0,r=v++,i=new Fp(s,l),n=new Sh(i,S,o,r,t);e.push(n),S.duration+=n.duration;break}case"PRELOAD-HINT":{const e=new Fp(s,l);l.preloadHint=e;break}case"RENDITION-REPORT":{const e=new Fp(s,l);l.renditionReports=l.renditionReports||[],l.renditionReports.push(e);break}default:eh.warn(`line parsed but not handled: ${u}`)}}}w&&!w.relurl?(c.pop(),y-=w.duration,l.partList&&(l.fragmentHint=w)):l.partList&&(Tm(S,w,d),S.cc=b,l.fragmentHint=S,f&&Am(S,f,l)),l.targetduration||(l.playlistParsingError=new Error("Missing Target Duration"));const k=c.length,L=c[0],I=c[k-1];if(y+=l.skippedSegments*l.targetduration,y>0&&k&&I){l.averagetargetduration=y/k;const e=I.sn;l.endSN="initSegment"!==e?e:0,l.live||(I.endList=!0),T>0&&(!function(e,t){let r=e[t];for(let i=t;i--;){const t=e[i];if(!t)return;t.programDateTime=r.programDateTime-1e3*t.duration,r=t}}(c,T),L&&d.unshift(L))}return l.fragmentHint&&(y+=l.fragmentHint.duration),l.totalduration=y,d.length&&l.dateRangeTagCount&&L&&vm(d,l),l.endCC=b,l}}function vm(e,t){let r=e.length;if(!r){if(!t.hasProgramDateTime)return;{const i=t.fragments[t.fragments.length-1];e.push(i),r++}}const i=e[r-1],s=t.live?1/0:t.totalduration,n=Object.keys(t.dateRanges);for(let o=n.length;o--;){const l=t.dateRanges[n[o]],c=l.startDate.getTime();l.tagAnchor=i.ref;for(let i=r;i--;){var a;if((null==(a=e[i])?void 0:a.sn)<t.startSN)break;const r=ym(t,c,e,i,s);if(-1!==r){l.tagAnchor=t.fragments[r].ref;break}}}}function ym(e,t,r,i,s){const n=r[i];if(n){const o=n.programDateTime;if(t>=o||0===i){var a;if(t<=o+1e3*(((null==(a=r[i+1])?void 0:a.start)||s)-n.start)){const s=r[i].sn-e.startSN;if(s<0)return-1;const n=e.fragments;if(n.length>r.length){for(let a=(r[i+1]||n[n.length-1]).sn-e.startSN;a>s;a--){const e=n[a].programDateTime;if(t>=e&&t<e+1e3*n[a].duration)return a}}return s}}}return-1}function bm(e,t,r){var i,s;const n=new Fp(e,r),a=null!=(i=n.METHOD)?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),c=n.KEYFORMATVERSIONS,d=null!=(s=n.KEYFORMAT)?s:"identity";o&&n.IV&&!l&&eh.error(`Invalid IV: ${n.IV}`);const u=o?gm.resolve(o,t):"",h=(c||"1").split("/").map(Number).filter(Number.isFinite);return new cm(a,u,d,h,l,n.KEYID)}function Em(e){const t=new Fp(e).decimalFloatingPoint("TIME-OFFSET");return Ru(t)?t:null}function wm(e,t){let r=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{const i=r.filter(t=>Zh(t,e));i.length&&(t[`${e}Codec`]=i.map(e=>e.split("/")[0]).join(","),r=r.filter(e=>-1===i.indexOf(e)))}),t.unknownCodecs=r}function Sm(e,t,r){const i=t[r];i&&(e[r]=i)}function Tm(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function xm(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function Am(e,t,r){e.levelkeys=t;const{encryptedFragments:i}=r;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some(e=>t[e].isCommonEncryption)||i.push(e)}function km(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${r[0]})`)}function Lm(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${r[0]})`)}function Im(e,t){const r=t.startPTS;if(Ru(r)){let i,s=0;t.sn>e.sn?(s=r-e.start,i=e):(s=e.start-r,i=t),i.duration!==s&&i.setDuration(s)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration)}else t.setStart(Math.max(e.start-t.duration,0))}function Rm(e,t,r,i,s,n,a){i-r<=0&&(a.warn("Fragment should have a positive duration",t),i=r+t.duration,n=s+t.duration);let o=r,l=i;const c=t.startPTS,d=t.endPTS;if(Ru(c)){const u=Math.abs(c-r);e&&u>e.totalduration?a.warn(`media timestamps and playlist times differ by ${u}s for level ${t.level} ${e.url}`):Ru(t.deltaPTS)?t.deltaPTS=Math.max(u,t.deltaPTS):t.deltaPTS=u,o=Math.max(r,c),r=Math.min(r,c),s=void 0!==t.startDTS?Math.min(s,t.startDTS):s,l=Math.min(i,d),i=Math.max(i,d),n=void 0!==t.endDTS?Math.max(n,t.endDTS):n}const u=r-t.start;0!==t.start&&t.setStart(r),t.setDuration(i-t.start),t.startPTS=r,t.maxStartPTS=o,t.startDTS=s,t.endPTS=i,t.minEndPTS=l,t.endDTS=n;const h=t.sn;if(!e||h<e.startSN||h>e.endSN)return 0;let f;const p=h-e.startSN,m=e.fragments;for(m[p]=t,f=p;f>0;f--)Im(m[f],m[f-1]);for(f=p;f<m.length-1;f++)Im(m[f],m[f+1]);return e.fragmentHint&&Im(m[m.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,u}function Pm(e,t,r){if(e===t)return;let i=null;const s=e.fragments;for(let e=s.length-1;e>=0;e--){const t=s[e].initSegment;if(t){i=t;break}}let n;e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,r){const i=t.skippedSegments,s=Math.max(e.startSN,t.startSN)-t.startSN,n=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,a=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;for(let c=s;c<=n;c++){const s=l[a+c];let n=o[c];if(i&&!n&&s&&(n=t.fragments[c]=s),s&&n){r(s,n,c,o);const i=s.relurl,a=n.relurl;if(i&&Bm(i,a))return void(t.playlistParsingError=Cm(`media sequence mismatch ${n.sn}:`,e,t,s,n));if(s.cc!==n.cc)return void(t.playlistParsingError=Cm(`discontinuity sequence mismatch (${s.cc}!=${n.cc})`,e,t,s,n))}}}(e,t,(e,r,s,a)=>{if((!t.startCC||t.skippedSegments)&&r.cc!==e.cc){const i=e.cc-r.cc;for(let e=s;e<a.length;e++)a[e].cc+=i;t.endCC=a[a.length-1].cc}Ru(e.startPTS)&&Ru(e.endPTS)&&(r.setStart(r.startPTS=e.startPTS),r.startDTS=e.startDTS,r.maxStartPTS=e.maxStartPTS,r.endPTS=e.endPTS,r.endDTS=e.endDTS,r.minEndPTS=e.minEndPTS,r.setDuration(e.endPTS-e.startPTS),r.duration&&(n=r),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(r.elementaryStreams=e.elementaryStreams),r.loader=e.loader,e.hasStats&&(r.stats=e.stats),e.initSegment&&(r.initSegment=e.initSegment,i=e.initSegment)});const a=t.fragments,o=t.fragmentHint?a.concat(t.fragmentHint):a;if(i&&o.forEach(e=>{var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=i)?void 0:t.relurl)||(e.initSegment=i)}),t.skippedSegments){if(t.deltaUpdateFailed=a.some(e=>!e),t.deltaUpdateFailed){r.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=t.skippedSegments;e--;)a.shift();t.startSN=a[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=function(e,t,r){const{dateRanges:i,recentlyRemovedDateranges:s}=t,n=Vu({},e);s&&s.forEach(e=>{delete n[e]});const a=Object.keys(n).length;if(!a)return i;return Object.keys(i).forEach(e=>{const t=n[e],s=new Up(i[e].attr,t);s.isValid?(n[e]=s,t||(s.tagOrder+=a)):r.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${Pf(i[e].attr)}"`)}),n}(e.dateRanges,t,r));const i=e.fragments.filter(e=>e.rawProgramDateTime);if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(let e=1;e<o.length;e++)null===o[e].programDateTime&&Tm(o[e],o[e-1],i);vm(i,t)}t.endCC=a[a.length-1].cc}if(!t.startCC){var l;const r=Mm(e,t.startSN-1);t.startCC=null!=(l=null==r?void 0:r.cc)?l:a[0].cc}!function(e,t,r){if(e&&t){let i=0;for(let s=0,n=e.length;s<=n;s++){const n=e[s],a=t[s+i];n&&a&&n.index===a.index&&n.fragment.sn===a.fragment.sn?r(n,a):i--}}}(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),n?Rm(t,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS,r):Dm(e,t),a.length&&(t.totalduration=t.edge-a[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;const c=t.advancedDateTime;if(t.advanced&&c){const e=t.edge;t.driftStart||(t.driftStartTime=c,t.driftStart=e),t.driftEndTime=c,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}function Cm(e,t,r,i,s){return new Error(`${e} ${s.url}\nPlaylist starting @${t.startSN}\n${t.m3u8}\n\nPlaylist starting @${r.startSN}\n${r.m3u8}`)}function Dm(e,t,r=!0){const i=t.startSN+t.skippedSegments-e.startSN,s=e.fragments,n=i>=0;let a=0;if(n&&i<s.length)a=s[i].start;else if(n&&t.startSN===e.endSN+1)a=e.fragmentEnd;else if(n&&r)a=e.fragmentStart+i*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;a=e.fragmentStart}_m(t,a)}function _m(e,t){if(t){const r=e.fragments;for(let i=e.skippedSegments;i<r.length;i++)r[i].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function Om(e,t=1/0){let r=1e3*e.targetduration;if(e.updated){const i=e.fragments,s=4;if(i.length&&r*s>t){const e=1e3*i[i.length-1].duration;e<r&&(r=e)}}else r/=2;return Math.round(r)}function Mm(e,t,r){if(!e)return null;let i=e.fragments[t-e.startSN];return i||(i=e.fragmentHint,i&&i.sn===t?i:t<e.startSN&&r&&r.sn===t?r:null)}function Nm(e,t,r){return e?Fm(e.partList,t,r):null}function Fm(e,t,r){if(e)for(let i=e.length;i--;){const s=e[i];if(s.index===r&&s.fragment.sn===t)return s}return null}function $m(e){e.forEach((e,t)=>{var r;null==(r=e.details)||r.fragments.forEach(e=>{e.level=t,e.initSegment&&(e.initSegment.level=t)})})}function Bm(e,t){return!(e===t||!t)&&Um(e)!==Um(t)}function Um(e){return e.replace(/\?[^?]*$/,"")}function zm(e,t){for(let i=0,s=e.length;i<s;i++){var r;if((null==(r=e[i])?void 0:r.cc)===t)return e[i]}return null}function Gm(e,t){const r=e.start+t;e.startPTS=r,e.setStart(r),e.endPTS=r+e.duration}function jm(e,t){const r=t.fragments;for(let t=0,i=r.length;t<i;t++)Gm(r[t],e);t.fragmentHint&&Gm(t.fragmentHint,e),t.alignedSliding=!0}function Hm(e,t){if(!function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e))return;const r=Math.min(t.endCC,e.endCC),i=zm(t.fragments,r),s=zm(e.fragments,r);if(!i||!s)return;eh.log(`Aligning playlist at start of dicontinuity sequence ${r}`);jm(i.start-s.start,e)}function Vm(e,t){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;const r=e.fragments,i=t.fragments;if(!r.length||!i.length)return;let s,n;const a=Math.min(t.endCC,e.endCC);t.startCC<a&&e.startCC<a&&(s=zm(i,a),n=zm(r,a)),s&&n||(s=i[Math.floor(i.length/2)],n=zm(r,s.cc)||r[Math.floor(r.length/2)]);const o=s.programDateTime,l=n.programDateTime;if(!o||!l)return;jm((l-o)/1e3-(n.start-s.start),e)}function Wm(e,t,r){Ym(e,t,r),e.addEventListener(t,r)}function Ym(e,t,r){e.removeEventListener(t,r)}const Km=function(e){let t="";const r=e.length;for(let i=0;i<r;i++)t+=`[${e.start(i).toFixed(3)}-${e.end(i).toFixed(3)}]`;return t},qm="STOPPED",Xm="IDLE",Qm="KEY_LOADING",Zm="FRAG_LOADING",Jm="FRAG_LOADING_WAITING_RETRY",eg="WAITING_TRACK",tg="PARSING",rg="PARSED",ig="ENDED",sg="ERROR",ng="WAITING_INIT_PTS",ag="WAITING_LEVEL";class og extends kp{constructor(e,t,r,i,s){super(i,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=qm,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:e,fragCurrent:t,media:r,mediaBuffer:i,state:s}=this,n=r?r.currentTime:0,a=Rp.bufferInfo(i||r,n,e.maxBufferHole),o=!a.len;if(this.log(`Media seeking to ${Ru(n)?n.toFixed(3):n}, state: ${s}, ${o?"out of":"in"} buffer`),this.state===ig)this.resetLoadingState();else if(t){const r=e.maxFragLookUpTolerance,i=t.start-r,s=t.start+t.duration+r;if(o||s<a.start||i>a.end){const e=n>s;(n<i||e)&&(e&&t.loader&&(this.log(`Cancelling fragment load for seek (sn: ${t.sn})`),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(r){this.fragmentTracker.removeFragmentsInRange(n,1/0,this.playlistType,!0);if(n>this.lastCurrentTime&&(this.lastCurrentTime=n),!this.loadingParts){const e=Math.max(a.end,n),t=this.shouldLoadParts(this.getLevelDetails(),e);t&&(this.log(`LL-Part loading ON after seeking to ${n.toFixed(2)} with buffer @${e.toFixed(2)}`),this.loadingParts=t)}}this.hls.hasEnoughToStart||(this.log(`Setting ${o?"startPosition":"nextLoadPosition"} to ${n} for seek without enough to start`),this.nextLoadPosition=n,o&&(this.startPosition=n)),o&&this.state===Xm&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=s,this.hls=e,this.fragmentLoader=new Sp(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Ep(e.config)}registerListeners(){const{hls:e}=this;e.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Ou.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Ou.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===qm)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=qm}get startPositionValue(){const{nextLoadPosition:e,startPosition:t}=this;return-1===t&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;const r=e.end||0,i=this.config.timelineOffset||0;if(r<=i)return!1;const s=e.buffered;this.config.maxBufferHole&&s&&s.length>1&&(e=Rp.bufferedInfo(s,e.start,0));const n=e.nextStart;if(n&&n>i&&n<t.edge)return!1;if(this.media.currentTime<e.start)return!1;const a=t.partList;if(null!=a&&a.length){const e=a[a.length-1];return Rp.isBuffered(this.media,e.start+e.duration/2)}const o=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(o)}getLevelDetails(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details}get timelineOffset(){const e=this.config.timelineOffset;var t;return e?(null==(t=this.getLevelDetails())?void 0:t.appliedTimelineOffset)||e:0}onMediaAttached(e,t){const r=this.media=this.mediaBuffer=t.media;Wm(r,"seeking",this.onMediaSeeking),Wm(r,"ended",this.onMediaEnded);const i=this.config;this.levels&&i.autoStartLoad&&this.state===qm&&this.startLoad(i.startPosition)}onMediaDetaching(e,t){const r=!!t.transferMedia,i=this.media;if(null!==i){if(i.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),Ym(i,"seeking",this.onMediaSeeking),Ym(i,"ended",this.onMediaEnded),this.keyLoader&&!r&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,r)return this.resetLoadingState(),void this.resetTransmuxer();this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=qm,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this.startFragRequested=!0,this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){this._doFragLoad(e,t,r,e=>{const t=e.frag;if(this.fragContextChanged(t))return this.warn(`${t.type} sn: ${t.sn}${e.part?" part: "+e.part.index:""} of ${this.fragInfo(t,!1,e.part)}) was dropped during download.`),void this.fragmentTracker.removeFragment(t);t.stats.chunkCount++,this._handleFragmentLoadProgress(e)}).then(e=>{if(!e)return;const t=this.state,r=e.frag;this.fragContextChanged(r)?(t===Zm||!this.fragCurrent&&t===tg)&&(this.fragmentTracker.removeFragment(r),this.state=Xm):("payload"in e&&(this.log(`Loaded ${r.type} sn: ${r.sn} of ${this.playlistLabel()} ${r.level}`),this.hls.trigger(Ou.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))}).catch(t=>{this.state!==qm&&this.state!==sg&&(this.warn(`Frag error: ${(null==t?void 0:t.message)||t}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:r}=this;if(r.getState(e)===lp){const t=e.type,i=this.getFwdBufferInfo(this.mediaBuffer,t),s=Math.max(e.duration,i?i.len:this.config.maxBufferLength),n=this.backtrackFragment;(1===(n?e.sn-n.sn:0)||this.reduceMaxBufferLength(s,e.duration))&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===cp&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}waitForLive(e){const t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,r=null){if(!(e-t))return;const i={startOffset:e,endOffset:t,type:r};this.hls.trigger(Ou.BUFFER_FLUSHING,i)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(e=>{const t=null==e?void 0:e.frag;if(!t||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return e}).then(e=>{const{hls:t}=this,{frag:r,payload:i}=e,s=r.decryptdata;if(i&&i.byteLength>0&&null!=s&&s.key&&s.iv&&Hp(s.method)){const n=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer,Vp(s.method)).catch(e=>{throw t.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e}).then(i=>{const s=self.performance.now();return t.trigger(Ou.FRAG_DECRYPTED,{frag:r,payload:i,stats:{tstart:n,tdecrypt:s}}),e.payload=i,this.completeInitSegmentLoad(e)})}return this.completeInitSegmentLoad(e)}).catch(t=>{this.state!==qm&&this.state!==sg&&(this.warn(t),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const r=e.frag.stats;this.state!==qm&&(this.state=Xm),e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(e,t){var r,i;const s=e.tracks;if(s&&!t.encrypted&&(null!=(r=s.audio)&&r.encrypted||null!=(i=s.video)&&i.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const e=this.media,r=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${e?"attached mediaKeys: "+e.mediaKeys:"detached"})`);return this.warn(r.message),!e||e.mediaKeys?!1:(this.hls.trigger(Ou.ERROR,{type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_NO_KEYS,fatal:!1,error:r,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){const r=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${r?Km(Rp.getBuffered(r)):"(detached)"})`),Eh(e)){var i;if(e.type!==zu){const t=e.elementaryStreams;if(!Object.keys(t).some(e=>!!t[e]))return void(this.state=Xm)}const t=null==(i=this.levels)?void 0:i[e.level];null!=t&&t.fragmentError&&(this.log(`Resetting level fragment error count of ${t.fragmentError} on frag buffered`),t.fragmentError=0)}this.state=Xm}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:r,part:i,partsLoaded:s}=e,n=!s||0===s.length||s.some(e=>!e),a=new Lp(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!n);t.flush(a)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,i){var s;this.fragCurrent=e;const n=t.details;if(!this.levels||!n)throw new Error(`frag load aborted, missing level${n?"":" detail"}s`);let a=null;if(!e.encrypted||null!=(s=e.decryptdata)&&s.key)e.encrypted||(a=this.keyLoader.loadClear(e,n.encryptedFragments,this.startFragRequested),a&&this.log("[eme] blocking frag load until media-keys acquired"));else if(this.log(`Loading key for ${e.sn} of [${n.startSN}-${n.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=Qm,this.fragCurrent=e,a=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(Ou.KEY_LOADED,e),this.state===Qm&&(this.state=Xm),e}),this.hls.trigger(Ou.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);const o=this.fragPrevious;if(Eh(e)&&(!o||e.sn!==o.sn)){const r=this.shouldLoadParts(t.details,e.end);r!==this.loadingParts&&(this.log(`LL-Part loading ${r?"ON":"OFF"} loading sn ${null==o?void 0:o.sn}->${e.sn}`),this.loadingParts=r)}if(r=Math.max(e.start,r||0),this.loadingParts&&Eh(e)){const s=n.partList;if(s&&i){r>n.fragmentEnd&&n.fragmentHint&&(e=n.fragmentHint);const o=this.getNextPart(s,e,r);if(o>-1){const l=s[o];let c;return e=this.fragCurrent=l.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${l.index} (${o}/${s.length-1}) of ${this.fragInfo(e,!1,l)}) cc: ${e.cc} [${n.startSN}-${n.endSN}], target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=Zm,c=a?a.then(r=>!r||this.fragContextChanged(r.frag)?null:this.doFragPartsLoad(e,l,t,i)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(e,l,t,i).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(Ou.FRAG_LOADING,{frag:e,part:l,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!e.url||this.loadedEndOfParts(s,r))return Promise.resolve(null)}}var l;if(Eh(e)&&this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${r.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${null==(l=n.partList)?void 0:l.filter(e=>e.loaded).map(e=>`[${e.start}-${e.end}]`)}`),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+n.startSN+"-"+n.endSN+"]"}, target: ${parseFloat(r.toFixed(3))}`),Ru(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Zm;const c=this.config.progressive&&e.type!==zu;let d;return d=c&&a?a.then(t=>!t||this.fragContextChanged(t.frag)?null:this.fragmentLoader.load(e,i)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,c?i:void 0),a]).then(([e])=>(!c&&i&&i(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(Ou.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,i){return new Promise((s,n)=>{var a;const o=[],l=null==(a=r.details)?void 0:a.partList,c=t=>{this.fragmentLoader.loadPart(e,t,i).then(i=>{o[t.index]=i;const n=i.part;this.hls.trigger(Ou.FRAG_LOADED,i);const a=Nm(r.details,e.sn,t.index+1)||Fm(l,e.sn,t.index+1);if(!a)return s({frag:e,part:n,partsLoaded:o});c(a)}).catch(n)};c(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===_u.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===Du.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(Ou.ERROR,t)}else this.hls.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==tg)return void(this.fragCurrent||this.state===qm||this.state===sg||(this.state=Xm));const{frag:r,part:i,level:s}=t,n=self.performance.now();r.stats.parsing.end=n,i&&(i.stats.parsing.end=n);const a=this.getLevelDetails(),o=a&&r.sn>a.endSN||this.shouldLoadParts(a,r.end);o!==this.loadingParts&&(this.log(`LL-Part loading ${o?"ON":"OFF"} after parsing segment ending @${r.end.toFixed(2)}`),this.loadingParts=o),this.updateLevelTiming(r,i,s,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var r;const s=e.partList[0];if(s.fragment.type===zu)return!1;if(t>=s.end+((null==(r=e.fragmentHint)?void 0:r.duration)||0)){var i;if((this.hls.hasEnoughToStart?(null==(i=this.media)?void 0:i.currentTime)||this.lastCurrentTime:this.getLoadPosition())>s.start-s.fragment.duration)return!0}}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:r}=this,{level:i,sn:s,part:n}=e;if(null==t||!t[i])return this.warn(`Levels object was unset while buffering fragment ${s} of ${this.playlistLabel()} ${i}. The current chunk will not be buffered.`),null;const a=t[i],o=a.details,l=n>-1?Nm(o,s,n):null,c=l?l.fragment:Mm(o,s,r);return c?(r&&r!==c&&(c.stats=r.stats),{frag:c,part:l,level:a}):null}bufferFragmentData(e,t,r,i,s){if(this.state!==tg)return;const{data1:n,data2:a}=e;let o=n;if(a&&(o=Gh(n,a)),!o.length)return;const l=this.initPTS[t.cc],c=l?-l.baseTime/l.timescale:void 0,d={type:e.type,frag:t,part:r,chunkMeta:i,offset:c,parent:t.type,data:o};if(this.hls.trigger(Ou.BUFFER_APPENDING,d),e.dropped&&e.independent&&!r){if(s)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Rp.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);const r=t.currentTime,i=Rp.bufferInfo(t,r,0),s=e.duration,n=Math.min(2*this.config.maxFragLookUpTolerance,.25*s),a=Math.max(Math.min(e.start-n,i.end-n),r+n);e.start-a>n&&this.flushMainBuffer(a,e.start)}getFwdBufferInfo(e,t){var r;const i=this.getLoadPosition();if(!Ru(i))return null;const s=this.lastCurrentTime>i||null!=(r=this.media)&&r.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,i,t,s)}getFwdBufferInfoAtPos(e,t,r,i){const s=Rp.bufferInfo(e,t,i);if(0===s.len&&void 0!==s.nextStart){const n=this.fragmentTracker.getBufferedFrag(t,r);if(n&&(s.nextStart<=n.end||n.gap)){const r=Math.max(Math.min(s.nextStart,n.end)-t,i);return Rp.bufferInfo(e,t,r)}}return s}getMaxBufferLength(e){const{config:t}=this;let r;return r=e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const r=this.config,i=Math.max(Math.min(e-t,r.maxBufferLength),t),s=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return s>=i&&(r.maxMaxBufferLength=s,this.warn(`Reduce max buffer length to ${s}s`),!0)}getAppendedFrag(e,t=Bu){const r=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){const r=t.fragments,i=r.length;if(!i)return null;const{config:s}=this,n=r[0].start,a=s.lowLatencyMode&&!!t.partList;let o=null;if(t.live){const r=s.initialLiveManifestSize;if(i<r)return this.warn(`Not enough fragments to start playback (have: ${i}, need: ${r})`),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<n){var l;a&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),o=this.getInitialLiveFragment(t);const r=this.hls.startPosition,i=this.hls.liveSyncPosition,s=o?(-1!==r&&r>=n?r:i)||o.start:e;this.log(`Setting startPosition to ${s} to match start frag at live edge. mainStart: ${r} liveSyncPosition: ${i} frag.start: ${null==(l=o)?void 0:l.start}`),this.startPosition=this.nextLoadPosition=s}}else e<=n&&(o=r[0]);if(!o){const r=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,r,t)}let c=this.filterReplacedPrimary(o,t);if(!c&&o){const e=o.sn-t.startSN;c=this.filterReplacedPrimary(r[e+1]||null,t)}return this.mapToInitFragWhenRequired(c)}isLoopLoading(e,t){const r=this.fragmentTracker.getState(e);return(r===dp||r===cp&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,i,s){let n=null;if(e.gap&&(n=this.getNextFragment(this.nextLoadPosition,t),n&&!n.gap&&r.nextStart)){const e=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i,0);if(null!==e&&r.len+e.len>=s){const e=n.sn;return this.loopSn!==e&&(this.log(`buffer full after gaps in "${i}" playlist starting at sn: ${e}`),this.loopSn=e),null}}return this.loopSn=void 0,n}get primaryPrefetch(){if(lg(this.config)){var e;if(null==(e=this.hls.interstitialsManager)||null==(e=e.playingItem)?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(lg(this.config)&&e.type!==zu){const r=this.hls.interstitialsManager,i=null==r?void 0:r.bufferingItem;if(i){const r=i.event;if(r){if(r.appendInPlace||Math.abs(e.start-i.start)>1||0===i.start)return null}else{if(e.end<=i.start&&!1===(null==t?void 0:t.live))return null;if(e.start>i.end&&i.nextEvent&&(i.nextEvent.appendInPlace||e.start-i.end>1))return null}}const s=null==r?void 0:r.playerQueue;if(s)for(let t=s.length;t--;){const r=s[t].interstitial;if(r.appendInPlace&&e.start>=r.startTime&&e.end<=r.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(e,t,r){let i=-1,s=!1,n=!0;for(let a=0,o=e.length;a<o;a++){const o=e[a];if(n=n&&!o.independent,i>-1&&r<o.start)break;const l=o.loaded;l?i=-1:(s||(o.independent||n)&&o.fragment===t)&&(o.fragment!==t&&this.warn(`Need buffer at ${r} but next unloaded part starts at ${o.start}`),i=a),s=l}return i}loadedEndOfParts(e,t){let r;for(let i=e.length;i--;){if(r=e[i],!r.loaded)return!1;if(t>r.start)return!0}return!1}getInitialLiveFragment(e){const t=e.fragments,r=this.fragPrevious;let i=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),i=function(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!Ru(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;for(let i=0;i<e.length;++i){const s=e[i];if(Gf(t,r,s))return s}return null}(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){const s=r.sn+1;if(s>=e.startSN&&s<=e.endSN){const n=t[s-e.startSN];r.cc===n.cc&&(i=n,this.log(`Live playlist, switching playlist, load frag with next SN: ${i.sn}`))}i||(i=jf(e,r.cc,r.end),i&&this.log(`Live playlist, switching playlist, load frag with same CC: ${i.sn}`))}}else{const t=this.hls.liveSyncPosition;null!==t&&(i=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i}getFragmentAtPosition(e,t,r){const{config:i}=this;let{fragPrevious:s}=this,{fragments:n,endSN:a}=r;const{fragmentHint:o}=r,{maxFragLookUpTolerance:l}=i,c=r.partList,d=!!(this.loadingParts&&null!=c&&c.length&&o);let u;if(d&&!this.bitrateTest&&c[c.length-1].fragment.sn===o.sn&&(n=n.concat(o),a=o.sn),e<t){var h;u=Uf(s,n,e,e<this.lastCurrentTime||e>t-l||null!=(h=this.media)&&h.paused||!this.startFragRequested?0:l)}else u=n[n.length-1];if(u){const e=u.sn-r.startSN,t=this.fragmentTracker.getState(u);if((t===dp||t===cp&&u.gap)&&(s=u),s&&u.sn===s.sn&&(!d||c[0].fragment.sn>u.sn||!r.live)){if(u.level===s.level){const t=n[e+1];u=u.sn<a&&this.fragmentTracker.getState(t)!==dp?t:null}}}return u}alignPlaylists(e,t,r){const i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;const s=e.fragmentStart,n=!t,a=e.alignedSliding&&Ru(s);if(n||!a&&!s){!function(e,t){e&&(Hm(t,e),t.alignedSliding||Vm(t,e),t.alignedSliding||t.skippedSegments||Dm(e,t,!1))}(r,e);const s=e.fragmentStart;return this.log(`Live playlist sliding: ${s.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${i}`),s}return s}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}setStartPosition(e,t){let r=this.startPosition;r<t&&(r=-1);const i=this.timelineOffset;if(-1===r){const s=null!==this.startTimeOffset,n=s?this.startTimeOffset:e.startTimeOffset;null!==n&&Ru(n)?(r=t+n,n<0&&(r+=e.edge),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Setting startPosition to ${r} for start time offset ${n} found in ${s?"multivariant":"media"} playlist`),this.startPosition=r):e.live?(r=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${r}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=r=0),this.lastCurrentTime=r+i}this.nextLoadPosition=r+i}getLoadPosition(){var e;const{media:t}=this;let r=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?r=t.currentTime:this.nextLoadPosition>=0&&(r=this.nextLoadPosition),r}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&Eh(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===Jm)||(this.state=Xm)}onFragmentOrKeyLoadError(e,t){var r;if(t.chunkMeta&&!t.frag){const e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}const i=t.frag;if(!i||i.type!==e||!this.levels)return;var s;if(this.fragContextChanged(i))return void this.warn(`Frag load error must match current frag to retry ${i.url} > ${null==(s=this.fragCurrent)?void 0:s.url}`);const n=t.details===_u.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,!0);const a=t.errorAction;if(!a)return void(this.state=sg);const{action:o,flags:l,retryCount:c=0,retryConfig:d}=a,u=!!d,h=u&&o===tp,f=u&&!a.resolved&&l===ip,p=null==(r=this.hls.latestLevelDetails)?void 0:r.live;if(!h&&f&&Eh(i)&&!i.endList&&p&&!Wf(t))this.resetFragmentErrors(e),this.treatAsGap(i),a.resolved=!0;else if((h||f)&&c<d.maxNumRetry){var m;const r=Qf(null==(m=t.response)?void 0:m.code),s=Kf(d,c);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+s,this.state=Jm,a.resolved=!0,r)return this.log("Waiting for connection (offline)"),this.retryDate=1/0,void(t.reason="offline");this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${c+1}/${d.maxNumRetry} in ${s}ms`)}else if(d){if(this.resetFragmentErrors(e),!(c<d.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${c})`);n||o===ep||(a.resolved=!0)}else this.state=o===Jf?ag:sg;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,r=t===1/0;(!t||e>=t||r&&!Qf(0))&&(r&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=Xm)}reduceLengthAndFlushBuffer(e){if(this.state===tg||this.state===rg){const t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),s=i&&i.len>.5;s&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);const n=!s;return n&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${r} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===Uu&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==qm&&(this.state=Xm)}afterBufferFlushed(e,t,r){if(!e)return;const i=Rp.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===ig&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==qm&&(this.state=Xm)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=this.levelLastLoaded,t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${-1===e.level?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,i){const s=r.details;if(!s)return void this.warn("level.details undefined");if(!Object.keys(e.elementaryStreams).reduce((t,n)=>{const a=e.elementaryStreams[n];if(a){const o=a.endPTS-a.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${e.sn} ${n} duration reliably (${o})`),t||!1;const l=i?0:Rm(s,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS,this);return this.hls.trigger(Ou.LEVEL_PTS_UPDATED,{details:s,level:r,drift:l,type:n,frag:e,start:a.startPTS,end:a.endPTS}),!0}return t},!1)){var n;const t=null===(null==(n=this.transmuxer)?void 0:n.error);if((0===r.fragmentError||t&&(r.fragmentError<2||e.endList))&&this.treatAsGap(e,r),t){const t=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(t.message),this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=rg,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(Ou.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===Bu?"level":"track"}fragInfo(e,t=!0,r){var i,s;return`${this.playlistLabel()} ${e.level} (${r?"part":"frag"}:[${(null!=(i=t&&!r?e.startPTS:(r||e).start)?i:NaN).toFixed(3)}-${(null!=(s=t&&!r?e.endPTS:(r||e).end)?s:NaN).toFixed(3)}]${r&&"main"===e.type?"INDEPENDENT="+(r.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}resetTransmuxer(){var e;null==(e=this.transmuxer)||e.reset()}recoverWorkerError(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function lg(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}class cg{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let r;return e.length?(r=1===e.length?e[0]:function(e,t){const r=new Uint8Array(t);let i=0;for(let t=0;t<e.length;t++){const s=e[t];r.set(s,i),i+=s.length}return r}(e,t),this.reset(),r):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}var dg,ug={exports:{}};var hg=(dg||(dg=1,function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function n(e,t,i,n,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new s(i,n||e,a),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function a(e,t){0===--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,s=[];if(0===this._eventsCount)return s;for(i in e=this._events)t.call(e,i)&&s.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var s=0,n=i.length,a=new Array(n);s<n;s++)a[s]=i[s].fn;return a},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,s,n,a){var o=r?r+e:e;if(!this._events[o])return!1;var l,c,d=this._events[o],u=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),u){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,s),!0;case 5:return d.fn.call(d.context,t,i,s,n),!0;case 6:return d.fn.call(d.context,t,i,s,n,a),!0}for(c=1,l=new Array(u-1);c<u;c++)l[c-1]=arguments[c];d.fn.apply(d.context,l)}else{var h,f=d.length;for(c=0;c<f;c++)switch(d[c].once&&this.removeListener(e,d[c].fn,void 0,!0),u){case 1:d[c].fn.call(d[c].context);break;case 2:d[c].fn.call(d[c].context,t);break;case 3:d[c].fn.call(d[c].context,t,i);break;case 4:d[c].fn.call(d[c].context,t,i,s);break;default:if(!l)for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];d[c].fn.apply(d[c].context,l)}}return!0},o.prototype.on=function(e,t,r){return n(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return n(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,s){var n=r?r+e:e;if(!this._events[n])return this;if(!t)return a(this,n),this;var o=this._events[n];if(o.fn)o.fn!==t||s&&!o.once||i&&o.context!==i||a(this,n);else{for(var l=0,c=[],d=o.length;l<d;l++)(o[l].fn!==t||s&&!o[l].once||i&&o[l].context!==i)&&c.push(o[l]);c.length?this._events[n]=1===c.length?c[0]:c:a(this,n)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(ug)),ug.exports),fg=ah(hg);const pg="1.6.15",mg={};function gg(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function vg(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function yg(e,t){let r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3],r}function bg(e,t){const r=t;let i=0;for(;vg(e,t);){i+=10;i+=yg(e,t+6),gg(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(r,r+i)}function Eg(e,t){return 255===e[t]&&240==(246&e[t+1])}function wg(e,t){return 1&e[t+1]?7:9}function Sg(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Tg(e,t){return t+1<e.length&&Eg(e,t)}function xg(e,t){if(Tg(e,t)){const r=wg(e,t);if(t+r>=e.length)return!1;const i=Sg(e,t);if(i<=r)return!1;const s=t+i;return s===e.length||Tg(e,s)}return!1}function Ag(e,t,r,i,s){if(!e.samplerate){const n=function(e,t,r,i){const s=t[r+2],n=s>>2&15;if(n>12){const t=new Error(`invalid ADTS sampling index:${n}`);return void e.emit(Ou.ERROR,Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.FRAG_PARSING_ERROR,fatal:!0,error:t,reason:t.message})}const a=1+(s>>6&3),o=t[r+3]>>6&3|(1&s)<<2,l="mp4a.40."+a,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][n];let d=n;5!==a&&29!==a||(d-=3);const u=[a<<3|(14&d)>>1,(1&d)<<7|o<<3];return eh.log(`manifest codec:${i}, parsed codec:${l}, channels:${o}, rate:${c} (ADTS object type:${a} sampling index:${n})`),{config:u,samplerate:c,channelCount:o,codec:l,parsedCodec:l,manifestCodec:i}}(t,r,i,s);if(!n)return;Vu(e,n)}}function kg(e){return 9216e4/e}function Lg(e,t,r,i,s){const n=i+s*kg(e.samplerate),a=function(e,t){const r=wg(e,t);if(t+r<=e.length){const i=Sg(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);let o;if(a){const{frameLength:i,headerLength:s}=a,l=s+i,c=Math.max(0,r+l-t.length);c?(o=new Uint8Array(l-s),o.set(t.subarray(r+s,t.length),0)):o=t.subarray(r+s,r+l);const d={unit:o,pts:n};return c||e.samples.push(d),{sample:d,length:l,missing:c}}const l=t.length-r;o=new Uint8Array(l),o.set(t.subarray(r,t.length),0);return{sample:{unit:o,pts:n},length:l,missing:-1}}function Ig(e,t){return vg(e,t)&&yg(e,t+6)+10<=e.length-t}function Rg(e,t=0,r=1/0){return function(e,t,r,i){const s=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e);let n=1;"BYTES_PER_ELEMENT"in i&&(n=i.BYTES_PER_ELEMENT);const a=(u=e,u&&u.buffer instanceof ArrayBuffer&&void 0!==u.byteLength&&void 0!==u.byteOffset?e.byteOffset:0),o=(a+e.byteLength)/n,l=(a+t)/n,c=Math.floor(Math.max(0,Math.min(l,o))),d=Math.floor(Math.min(c+Math.max(r,0),o));var u;return new i(s,c,d-c)}(e,t,r,Uint8Array)}function Pg(e){const t={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(e.size<2)return;if(3!==e.data[0])return void console.log("Ignore frame with unrecognized character encoding");const r=e.data.subarray(1).indexOf(0);if(-1===r)return;const i=ih(Rg(e.data,1,r)),s=e.data[2+r],n=e.data.subarray(3+r).indexOf(0);if(-1===n)return;const a=ih(Rg(e.data,3+r,n));let o;return o="--\x3e"===i?ih(Rg(e.data,4+r+n)):function(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}(e.data.subarray(4+r+n)),t.mimeType=i,t.pictureType=s,t.description=a,t.data=o,t}function Cg(e){return"PRIV"===e.type?function(e){if(e.size<2)return;const t=ih(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;let t=1;const r=ih(e.data.subarray(t),!0);t+=r.length+1;const i=ih(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=ih(e.data);return{key:e.type,info:"",data:t}}(e):"APIC"===e.type?Pg(e):function(e){if(e.size<2)return;if("TXXX"===e.type){let t=1;const r=ih(e.data.subarray(t),!0);t+=r.length+1;const i=ih(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=ih(e.data.subarray(1));return{key:e.type,info:"",data:t}}(e)}function Dg(e){const t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=yg(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}function _g(e){let t=0;const r=[];for(;vg(e,t);){const i=yg(e,t+6);e[t+5]>>6&1&&(t+=10),t+=10;const s=t+i;for(;t+10<s;){const i=Dg(e.subarray(t)),s=Cg(i);s&&r.push(s),t+=i.size+10}gg(e,t)&&(t+=10)}return r}function Og(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function Mg(e){if(8===e.data.byteLength){const t=new Uint8Array(e.data),r=1&t[3];let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}}function Ng(e){const t=_g(e);for(let e=0;e<t.length;e++){const r=t[e];if(Og(r))return Mg(r)}}let Fg=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function $g(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class Bg{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=Gh(this.cachedData,e),this.cachedData=null);let r,i=bg(e,0),s=i?i.length:0;const n=this._audioTrack,a=this._id3Track,o=i?Ng(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&Ru(o))&&(this.basePTS=Ug(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Fg.audioId3,duration:Number.POSITIVE_INFINITY});s<l;){if(this.canParse(e,s)){const t=this.appendFrame(n,e,s);t?(this.frameIndex++,this.lastPTS=t.sample.pts,s+=t.length,r=s):s=l}else Ig(e,s)?(i=bg(e,s),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Fg.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,r=s):s++;if(s===l&&r!==l){const t=e.slice(r);this.cachedData?this.cachedData=Gh(this.cachedData,t):this.cachedData=t}}return{audioTrack:n,videoTrack:$g(),id3Track:a,textTrack:$g()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:$g(),id3Track:this._id3Track,textTrack:$g()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const Ug=(e,t,r)=>{if(Ru(e))return 90*e;return 9e4*t+(r?9e4*r.baseTime/r.timescale:0)};let zg=null;const Gg=[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],jg=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Hg=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Vg=[0,1,1,4];function Wg(e,t,r,i,s){if(r+24>t.length)return;const n=Yg(t,r);if(n&&r+n.frameLength<=t.length){const a=i+s*(9e4*n.samplesPerFrame/n.sampleRate),o={unit:t.subarray(r,r+n.frameLength),pts:a,dts:a};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(o),{sample:o,length:n.frameLength,missing:0}}}function Yg(e,t){const r=e[t+1]>>3&3,i=e[t+1]>>1&3,s=e[t+2]>>4&15,n=e[t+2]>>2&3;if(1!==r&&0!==s&&15!==s&&3!==n){const a=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*Gg[14*(3===r?3-i:3===i?3:4)+s-1],c=jg[3*(3===r?0:2===r?1:2)+n],d=3===o?1:2,u=Hg[r][i],h=Vg[i],f=8*u*h,p=Math.floor(u*l/c+a)*h;if(null===zg){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);zg=e?parseInt(e[1]):0}return!!zg&&zg<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:c,channelCount:d,frameLength:p,samplesPerFrame:f}}}function Kg(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function qg(e,t){return t+1<e.length&&Kg(e,t)}function Xg(e,t){if(t+1<e.length&&Kg(e,t)){const r=4,i=Yg(e,t);let s=r;null!=i&&i.frameLength&&(s=i.frameLength);const n=t+s;return n===e.length||qg(e,n)}return!1}const Qg=(e,t)=>{let r=0,i=5;t+=i;const s=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=e[t];const o=Math.min(i,8),l=8-o;n[0]=4278190080>>>24+l<<l,s[0]=(a[0]&n[0])>>l,r=r?r<<o|s[0]:s[0],t+=1,i-=o}return r};class Zg extends Bg{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,r){const i=Jg(e,t,r,this.basePTS,this.frameIndex);if(-1!==i){return{sample:e.samples[e.samples.length-1],length:i,missing:0}}}static probe(e){if(!e)return!1;const t=bg(e,0);if(!t)return!1;const r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==Ng(t)&&Qg(e,r)<16}}function Jg(e,t,r,i,s){if(r+8>t.length)return-1;if(11!==t[r]||119!==t[r+1])return-1;const n=t[r+4]>>6;if(n>=3)return-1;const a=[48e3,44100,32e3][n],o=63&t[r+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+n];if(r+l>t.length)return-1;const c=t[r+6]>>5;let d=0;2===c?d+=2:(1&c&&1!==c&&(d+=2),4&c&&(d+=2));const u=(t[r+6]<<8|t[r+7])>>12-d&1,h=[2,1,2,3,3,4,4,5][c]+u,f=t[r+5]>>3,p=7&t[r+5],m=new Uint8Array([n<<6|f<<1|p>>2,(3&p)<<6|c<<3|u<<2|o>>4,o<<4&224]),g=i+s*(1536/a*9e4),v=t.subarray(r,r+l);return e.config=m,e.channelCount=h,e.samplerate=a,e.samples.push({unit:v,pts:g}),l}const ev=/\/emsg[-/]ID3/i;function tv(e,t){return Ru(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}class rv{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Ep(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,mp)}decryptAacSample(e,t,r){const i=e[t].unit;if(i.length<=16)return;const s=i.subarray(16,i.length-i.length%16),n=s.buffer.slice(s.byteOffset,s.byteOffset+s.length);this.decryptBuffer(n).then(s=>{const n=new Uint8Array(s);i.set(n,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)}).catch(r)}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)r.set(e.subarray(t,t+16),i);return r}getAvcDecryptedUnit(e,t){const r=new Uint8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)e.set(r.subarray(i,i+16),t);return e}decryptAvcSample(e,t,r,i,s){const n=Yh(s.data),a=this.getAvcEncryptedData(n);this.decryptBuffer(a.buffer).then(a=>{s.data=this.getAvcDecryptedUnit(n,a),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,i)}).catch(i)}decryptAvcSamples(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();const s=e[t].units;for(;!(r>=s.length);r++){const n=s[r];if(!(n.data.length<=48||1!==n.type&&5!==n.type||(this.decryptAvcSample(e,t,r,i,n),this.decrypter.isSync())))return}}}}class iv{constructor(){this.VideoSample=null}createVideoSample(e,t,r){return{key:e,frame:!1,pts:t,dts:r,units:[],length:0}}getLastNalUnit(e){var t;let r,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){const e=i.units;r=e[e.length-1]}return r}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){const r=t.samples,i=r.length;if(!i)return void t.dropped++;{const t=r[i-1];e.pts=t.pts,e.dts=t.dts}}t.samples.push(e)}}parseNALu(e,t,r){const i=t.byteLength;let s=e.naluState||0;const n=s,a=[];let o,l,c,d=0,u=-1,h=0;for(-1===s&&(u=0,h=this.getNALuType(t,0),s=0,d=1);d<i;)if(o=t[d++],s)if(1!==s)if(o)if(1===o){if(l=d-s-1,u>=0){const e={data:t.subarray(u,l),type:h};a.push(e)}else{const r=this.getLastNalUnit(e.samples);r&&(n&&d<=4-n&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-n)),l>0&&(r.data=Gh(r.data,t.subarray(0,l)),r.state=0))}d<i?(c=this.getNALuType(t,d),u=d,h=c,s=0):s=-1}else s=0;else s=3;else s=o?0:2;else s=o?0:1;if(u>=0&&s>=0){const e={data:t.subarray(u,i),type:h,state:s};a.push(e)}if(0===a.length){const r=this.getLastNalUnit(e.samples);r&&(r.data=Gh(r.data,t))}return e.naluState=s,a}}class sv{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),s=Math.min(4,t);if(0===s)throw new Error("no bytes available");i.set(e.subarray(r,r+s)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*s,this.bytesAvailable-=s}skipBits(e){let t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(t=(e-=this.bitsAvailable)>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const r=this.word>>>32-t;if(e>32&&eh.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class nv extends iv{parsePES(e,t,r,i){const s=this.parseNALu(e,r.data,i);let n,a=this.VideoSample,o=!1;r.data=null,a&&s.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),s.forEach(i=>{var s,l;switch(i.type){case 1:{let t=!1;n=!0;const s=i.data;if(o&&s.length>4){const e=this.readSliceType(s);2!==e&&4!==e&&7!==e&&9!==e||(t=!0)}var c;if(t)null!=(c=a)&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.frame=!0,a.key=t;break}case 5:n=!0,null!=(s=a)&&s.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0,a.frame=!0;break;case 6:n=!0,Wh(i.data,1,r.pts,t.samples);break;case 7:{var d,u;n=!0,o=!0;const t=i.data,r=this.readSPS(t);if(!e.sps||e.width!==r.width||e.height!==r.height||(null==(d=e.pixelRatio)?void 0:d[0])!==r.pixelRatio[0]||(null==(u=e.pixelRatio)?void 0:u[1])!==r.pixelRatio[1]){e.width=r.width,e.height=r.height,e.pixelRatio=r.pixelRatio,e.sps=[t];const i=t.subarray(1,4);let s="avc1.";for(let e=0;e<3;e++){let t=i[e].toString(16);t.length<2&&(t="0"+t),s+=t}e.codec=s}break}case 8:n=!0,e.pps=[i.data];break;case 9:n=!0,e.audFound=!0,null!=(l=a)&&l.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts));break;case 12:n=!0;break;default:n=!1}if(a&&n){a.units.push(i)}}),i&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}getNALuType(e,t){return 31&e[t]}readSliceType(e){const t=new sv(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let r,i=8,s=8;for(let n=0;n<e;n++)0!==s&&(r=t.readEG(),s=(i+r+256)%256),i=0===s?i:s}readSPS(e){const t=new sv(e);let r,i,s,n=0,a=0,o=0,l=0;const c=t.readUByte.bind(t),d=t.readBits.bind(t),u=t.readUEG.bind(t),h=t.readBoolean.bind(t),f=t.skipBits.bind(t),p=t.skipEG.bind(t),m=t.skipUEG.bind(t),g=this.skipScalingList.bind(this);c();const v=c();if(d(5),f(3),c(),m(),100===v||110===v||122===v||244===v||44===v||83===v||86===v||118===v||128===v){const e=u();if(3===e&&f(1),m(),m(),f(1),h())for(i=3!==e?8:12,s=0;s<i;s++)h()&&g(s<6?16:64,t)}m();const y=u();if(0===y)u();else if(1===y)for(f(1),p(),p(),r=u(),s=0;s<r;s++)p();m(),f(1);const b=u(),E=u(),w=d(1);0===w&&f(1),f(1),h()&&(n=u(),a=u(),o=u(),l=u());let S=[1,1];if(h()&&h()){switch(c()){case 1:S=[1,1];break;case 2:S=[12,11];break;case 3:S=[10,11];break;case 4:S=[16,11];break;case 5:S=[40,33];break;case 6:S=[24,11];break;case 7:S=[20,11];break;case 8:S=[32,11];break;case 9:S=[80,33];break;case 10:S=[18,11];break;case 11:S=[15,11];break;case 12:S=[64,33];break;case 13:S=[160,99];break;case 14:S=[4,3];break;case 15:S=[3,2];break;case 16:S=[2,1];break;case 255:S=[c()<<8|c(),c()<<8|c()]}}return{width:Math.ceil(16*(b+1)-2*n-2*a),height:(2-w)*(E+1)*16-(w?2:4)*(o+l),pixelRatio:S}}}class av extends iv{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,r,i){const s=this.parseNALu(e,r.data,i);let n,a=this.VideoSample,o=!1;r.data=null,a&&s.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),s.forEach(i=>{var s,l;switch(i.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:a||(a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),a.frame=!0,n=!0;break;case 16:case 17:case 18:case 21:var c;if(n=!0,o)null!=(c=a)&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0,a.frame=!0;break;case 19:case 20:n=!0,null!=(s=a)&&s.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0,a.frame=!0;break;case 39:n=!0,Wh(i.data,2,r.pts,t.samples);break;case 32:n=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=Vu(e.params,this.readVPS(i.data)),this.initVPS=i.data),e.vps=[i.data];break;case 33:if(n=!0,o=!0,void 0===e.vps||e.vps[0]===this.initVPS||void 0===e.sps||this.matchSPS(e.sps[0],i.data)||(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const t=this.readSPS(i.data);e.width=t.width,e.height=t.height,e.pixelRatio=t.pixelRatio,e.codec=t.codecString,e.sps=[],"object"!=typeof e.params&&(e.params={});for(const r in t.params)e.params[r]=t.params[r]}this.pushParameterSet(e.sps,i.data,e.vps),a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0;break;case 34:if(n=!0,"object"==typeof e.params){if(!e.pps){e.pps=[];const t=this.readPPS(i.data);for(const r in t)e.params[r]=t[r]}this.pushParameterSet(e.pps,i.data,e.vps)}break;case 35:n=!0,e.audFound=!0,null!=(l=a)&&l.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts));break;default:n=!1}if(a&&n){a.units.push(i)}}),i&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}pushParameterSet(e,t,r){(r&&r[0]===this.initVPS||!r&&!e.length)&&e.push(t)}getNALuType(e,t){return(126&e[t])>>>1}ebsp2rbsp(e){const t=new Uint8Array(e.byteLength);let r=0;for(let i=0;i<e.byteLength;i++)i>=2&&3===e[i]&&0===e[i-1]&&0===e[i-2]||(t[r]=e[i],r++);return new Uint8Array(t.buffer,0,r)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){const t=new sv(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);return{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}}readSPS(e){const t=new sv(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const r=t.readBits(3);t.readBoolean();const i=t.readBits(2),s=t.readBoolean(),n=t.readBits(5),a=t.readUByte(),o=t.readUByte(),l=t.readUByte(),c=t.readUByte(),d=t.readUByte(),u=t.readUByte(),h=t.readUByte(),f=t.readUByte(),p=t.readUByte(),m=t.readUByte(),g=t.readUByte(),v=[],y=[];for(let e=0;e<r;e++)v.push(t.readBoolean()),y.push(t.readBoolean());if(r>0)for(let e=r;e<8;e++)t.readBits(2);for(let e=0;e<r;e++)v[e]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),y[e]&&t.readUByte();t.readUEG();const b=t.readUEG();3==b&&t.skipBits(1);const E=t.readUEG(),w=t.readUEG(),S=t.readBoolean();let T=0,x=0,A=0,k=0;S&&(T+=t.readUEG(),x+=t.readUEG(),A+=t.readUEG(),k+=t.readUEG());const L=t.readUEG(),I=t.readUEG(),R=t.readUEG();for(let e=t.readBoolean()?0:r;e<=r;e++)t.skipUEG(),t.skipUEG(),t.skipUEG();t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.readBoolean()){if(t.readBoolean())for(let e=0;e<4;e++)for(let r=0;r<(3===e?2:6);r++){if(t.readBoolean()){const r=Math.min(64,1<<4+(e<<1));e>1&&t.readEG();for(let e=0;e<r;e++)t.readEG()}else t.readUEG()}}t.readBoolean(),t.readBoolean();t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const P=t.readUEG();let C=0;for(let e=0;e<P;e++){let r=!1;if(0!==e&&(r=t.readBoolean()),r){e===P&&t.readUEG(),t.readBoolean(),t.readUEG();let r=0;for(let e=0;e<=C;e++){const e=t.readBoolean();let i=!1;e||(i=t.readBoolean()),(e||i)&&r++}C=r}else{const e=t.readUEG(),r=t.readUEG();C=e+r;for(let r=0;r<e;r++)t.readUEG(),t.readBoolean();for(let e=0;e<r;e++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const e=t.readUEG();for(let r=0;r<e;r++){for(let e=0;e<R+4;e++)t.readBits(1);t.readBits(1)}}let D=0,_=1,O=1,M=!0,N=1,F=0;t.readBoolean(),t.readBoolean();let $=!1;if(t.readBoolean()){if(t.readBoolean()){const e=t.readUByte();e>0&&e<16?(_=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],O=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(_=t.readBits(16),O=t.readBits(16))}t.readBoolean()&&t.readBoolean();if(t.readBoolean()){t.readBits(3),t.readBoolean();t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())}t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),$=t.readBoolean(),$&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG());if(t.readBoolean()){N=t.readBits(32),F=t.readBits(32);t.readBoolean()&&t.readUEG();if(t.readBoolean()){const e=t.readBoolean(),i=t.readBoolean();let s=!1;(e||i)&&(s=t.readBoolean(),s&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),s&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let n=0;n<=r;n++){M=t.readBoolean();let r=!1;M||t.readBoolean()?t.readEG():r=t.readBoolean();const n=r?1:t.readUEG()+1;if(e)for(let e=0;e<n;e++)t.readUEG(),t.readUEG(),s&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(i)for(let e=0;e<n;e++)t.readUEG(),t.readUEG(),s&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),D=t.readUEG())}let B=E,U=w;if(S){let e=1,t=1;1===b?e=t=2:2==b&&(e=2),B=E-e*x-e*T,U=w-t*k-t*A}const z=i?["A","B","C"][i]:"",G=a<<24|o<<16|l<<8|c;let j=0;for(let e=0;e<32;e++)j=(j|(G>>e&1)<<31-e)>>>0;let H=j.toString(16);1===n&&"2"===H&&(H="6");return{codecString:`hvc1.${z}${n}.${H}.${s?"H":"L"}${g}.B0`,params:{general_tier_flag:s,general_profile_idc:n,general_profile_space:i,general_profile_compatibility_flags:[a,o,l,c],general_constraint_indicator_flags:[d,u,h,f,p,m],general_level_idc:g,bit_depth:L+8,bit_depth_luma_minus8:L,bit_depth_chroma_minus8:I,min_spatial_segmentation_idc:D,chroma_format_idc:b,frame_rate:{fixed:M,fps:F/N}},width:B,height:U,pixelRatio:[_,O]}}readPPS(e){const t=new sv(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2);t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);const r=t.readBoolean(),i=t.readBoolean();let s=1;return i&&r?s=0:i?s=3:r&&(s=2),{parallelismType:s}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const ov=188;class lv{constructor(e,t,r,i){this.logger=void 0,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._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.logger=i,this.videoParser=null}static probe(e,t){const r=lv.syncOffset(e);return r>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${r}`),-1!==r}static syncOffset(e){const t=e.length;let r=Math.min(940,t-ov)+1,i=0;for(;i<r;){let s=!1,n=-1,a=0;for(let o=i;o<t;o+=ov){if(71!==e[o]||t-o!==ov&&71!==e[o+ov]){if(a)return-1;break}if(a++,-1===n&&(n=o,0!==n&&(r=Math.min(n+18612,e.length-ov)+1)),s||(s=0===cv(e,o)),s&&a>1&&(0===n&&a>2||o+ov>r))return n}i++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:kh[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=lv.createTrack("video"),this._videoTrack.duration=i,this._audioTrack=lv.createTrack("audio",i),this._id3Track=lv.createTrack("id3"),this._txtTrack=lv.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,r=!1,i=!1){let s;r||(this.sampleAes=null);const n=this._videoTrack,a=this._audioTrack,o=this._id3Track,l=this._txtTrack;let c=n.pid,d=n.pesData,u=a.pid,h=o.pid,f=a.pesData,p=o.pesData,m=null,g=this.pmtParsed,v=this._pmtId,y=e.length;if(this.remainderData&&(y=(e=Gh(this.remainderData,e)).length,this.remainderData=null),y<ov&&!i)return this.remainderData=e,{audioTrack:a,videoTrack:n,id3Track:o,textTrack:l};const b=Math.max(0,lv.syncOffset(e));y-=(y-b)%ov,y<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,y,e.buffer.byteLength-y));let E=0;for(let t=b;t<y;t+=ov)if(71===e[t]){const i=!!(64&e[t+1]),y=cv(e,t);let E;if((48&e[t+3])>>4>1){if(E=t+5+e[t+4],E===t+ov)continue}else E=t+4;switch(y){case c:i&&(d&&(s=pv(d,this.logger))&&(this.readyVideoParser(n.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(n,l,s,!1)),d={data:[],size:0}),d&&(d.data.push(e.subarray(E,t+ov)),d.size+=t+ov-E);break;case u:if(i){if(f&&(s=pv(f,this.logger)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,s);break;case"mp3":this.parseMPEGPES(a,s);break;case"ac3":this.parseAC3PES(a,s)}f={data:[],size:0}}f&&(f.data.push(e.subarray(E,t+ov)),f.size+=t+ov-E);break;case h:i&&(p&&(s=pv(p,this.logger))&&this.parseID3PES(o,s),p={data:[],size:0}),p&&(p.data.push(e.subarray(E,t+ov)),p.size+=t+ov-E);break;case 0:i&&(E+=e[E]+1),v=this._pmtId=dv(e,E);break;case v:{i&&(E+=e[E]+1);const s=uv(e,E,this.typeSupported,r,this.observer,this.logger);c=s.videoPid,c>0&&(n.pid=c,n.segmentCodec=s.segmentVideoCodec),u=s.audioPid,u>0&&(a.pid=u,a.segmentCodec=s.segmentAudioCodec),h=s.id3Pid,h>0&&(o.pid=h),null===m||g||(this.logger.warn(`MPEG-TS PMT found at ${t} after unknown PID '${m}'. Backtracking to sync byte @${b} to parse all TS packets.`),m=null,t=b-188),g=this.pmtParsed=!0;break}case 17:case 8191:break;default:m=y}}else E++;E>0&&hv(this.observer,new Error(`Found ${E} TS packet/s that do not start with 0x47`),void 0,this.logger),n.pesData=d,a.pesData=f,o.pesData=p;const w={audioTrack:a,videoTrack:n,id3Track:o,textTrack:l};return i&&this.extractRemainingSamples(w),w}flush(){const{remainderData:e}=this;let t;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:r,id3Track:i,textTrack:s}=e,n=r.pesData,a=t.pesData,o=i.pesData;let l;if(n&&(l=pv(n,this.logger))?(this.readyVideoParser(r.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(r,s,l,!0),r.pesData=null)):r.pesData=n,a&&(l=pv(a,this.logger))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,l);break;case"mp3":this.parseMPEGPES(t,l);break;case"ac3":this.parseAC3PES(t,l)}t.pesData=null}else null!=a&&a.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=a;o&&(l=pv(o,this.logger))?(this.parseID3PES(i,l),i.pesData=null):i.pesData=o}demuxSampleAes(e,t,r){const i=this.demux(e,r,!0,!this.config.progressive),s=this.sampleAes=new rv(this.observer,this.config,t);return this.decrypt(i,s)}readyVideoParser(e){null===this.videoParser&&("avc"===e?this.videoParser=new nv:"hevc"===e&&(this.videoParser=new av))}decrypt(e,t){return new Promise(r=>{const{audioTrack:i,videoTrack:s}=e;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,()=>{s.samples?t.decryptAvcSamples(s.samples,0,0,()=>{r(e)}):r(e)}):s.samples&&t.decryptAvcSamples(s.samples,0,0,()=>{r(e)})})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}parseAACPES(e,t){let r=0;const i=this.aacOverFlow;let s,n,a,o=t.data;if(i){this.aacOverFlow=null;const t=i.missing,s=i.sample.unit.byteLength;if(-1===t)o=Gh(i.sample.unit,o);else{const n=s-t;i.sample.unit.set(o.subarray(0,t),n),e.samples.push(i.sample),r=i.missing}}for(s=r,n=o.length;s<n-1&&!Tg(o,s);s++);if(s!==r){let e;const t=s<n-1;if(e=t?`AAC PES did not start with ADTS header,offset:${s}`:"No ADTS header found in AAC PES",hv(this.observer,new Error(e),t,this.logger),!t)return}if(Ag(e,this.observer,o,s,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!i)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");{const t=kg(e.samplerate);a=i.sample.pts+t}}let l,c=0;for(;s<n;){if(l=Lg(e,o,s,a,c),s+=l.length,l.missing){this.aacOverFlow=l;break}for(c++;s<n-1&&!Tg(o,s);s++);}}parseMPEGPES(e,t){const r=t.data,i=r.length;let s=0,n=0;const a=t.pts;if(void 0!==a)for(;n<i;)if(qg(r,n)){const t=Wg(e,r,n,a,s);if(!t)break;n+=t.length,s++}else n++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseAC3PES(e,t){{const r=t.data,i=t.pts;if(void 0===i)return void this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");const s=r.length;let n,a=0,o=0;for(;o<s&&(n=Jg(e,r,o,i,a++))>0;)o+=n}}parseID3PES(e,t){if(void 0===t.pts)return void this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");const r=Vu({},t,{type:this._videoTrack?Fg.emsg:Fg.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}}function cv(e,t){return((31&e[t+1])<<8)+e[t+2]}function dv(e,t){return(31&e[t+10])<<8|e[t+11]}function uv(e,t,r,i,s,n){const a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<o;){const o=cv(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){fv("ADTS AAC",n);break}case 15:-1===a.audioPid&&(a.audioPid=o);break;case 21:-1===a.id3Pid&&(a.id3Pid=o);break;case 219:if(!i){fv("H.264",n);break}case 27:-1===a.videoPid&&(a.videoPid=o);break;case 3:case 4:r.mpeg||r.mp3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="mp3"):n.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){fv("AC-3",n);break}case 129:r.ac3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="ac3"):n.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===a.audioPid&&l>0){let i=t+5,s=l;for(;s>2;){if(106===e[i])!0!==r.ac3?n.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=o,a.segmentAudioCodec="ac3");const t=e[i+1]+2;i+=t,s-=t}}break;case 194:case 135:return hv(s,new Error("Unsupported EC-3 in M2TS found"),void 0,n),a;case 36:-1===a.videoPid&&(a.videoPid=o,a.segmentVideoCodec="hevc",n.log("HEVC in M2TS found"))}t+=l+5}return a}function hv(e,t,r,i){i.warn(`parsing error: ${t.message}`),e.emit(Ou.ERROR,Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function fv(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function pv(e,t){let r,i,s,n,a,o=0;const l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=Gh(l[0],l[1]),l.splice(1,1);r=l[0];if(1===(r[0]<<16)+(r[1]<<8)+r[2]){if(i=(r[4]<<8)+r[5],i&&i>e.size-6)return null;const c=r[7];192&c&&(n=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&c?(a=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2,n-a>54e5&&(t.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=r[8];let d=s+9;if(e.size<=d)return null;e.size-=d;const u=new Uint8Array(e.size);for(let e=0,t=l.length;e<t;e++){r=l[e];let t=r.byteLength;if(d){if(d>t){d-=t;continue}r=r.subarray(d),t-=d,d=0}u.set(r,o),o+=t}return i&&(i-=s+3),{data:u,pts:n,dts:a,len:i}}return null}class mv{static getSilentFrame(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}const gv=Math.pow(2,32)-1;class vv{static init(){let e;for(e in vv.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},vv.types)vv.types.hasOwnProperty(e)&&(vv.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=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]),r=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]);vv.HDLR_TYPES={video:t,audio:r};const i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);vv.STTS=vv.STSC=vv.STCO=s,vv.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),vv.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),vv.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),vv.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const n=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),o=new Uint8Array([0,0,0,1]);vv.FTYP=vv.box(vv.types.ftyp,n,o,n,a),vv.DINF=vv.box(vv.types.dinf,vv.box(vv.types.dref,i))}static box(e,...t){let r=8,i=t.length;const s=i;for(;i--;)r+=t[i].byteLength;const n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=255&r,n.set(e,4),i=0,r=8;i<s;i++)n.set(t[i],r),r+=t[i].byteLength;return n}static hdlr(e){return vv.box(vv.types.hdlr,vv.HDLR_TYPES[e])}static mdat(e){return vv.box(vv.types.mdat,e)}static mdhd(e,t){t*=e;const r=Math.floor(t/(gv+1)),i=Math.floor(t%(gv+1));return vv.box(vv.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))}static mdia(e){return vv.box(vv.types.mdia,vv.mdhd(e.timescale||0,e.duration||0),vv.hdlr(e.type),vv.minf(e))}static mfhd(e){return vv.box(vv.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?vv.box(vv.types.minf,vv.box(vv.types.smhd,vv.SMHD),vv.DINF,vv.stbl(e)):vv.box(vv.types.minf,vv.box(vv.types.vmhd,vv.VMHD),vv.DINF,vv.stbl(e))}static moof(e,t,r){return vv.box(vv.types.moof,vv.mfhd(e),vv.traf(r,t))}static moov(e){let t=e.length;const r=[];for(;t--;)r[t]=vv.trak(e[t]);return vv.box.apply(null,[vv.types.moov,vv.mvhd(e[0].timescale||0,e[0].duration||0)].concat(r).concat(vv.mvex(e)))}static mvex(e){let t=e.length;const r=[];for(;t--;)r[t]=vv.trex(e[t]);return vv.box.apply(null,[vv.types.mvex,...r])}static mvhd(e,t){t*=e;const r=Math.floor(t/(gv+1)),i=Math.floor(t%(gv+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return vv.box(vv.types.mvhd,s)}static sdtp(e){const t=e.samples||[],r=new Uint8Array(4+t.length);let i,s;for(i=0;i<t.length;i++)s=t[i].flags,r[i+4]=s.dependsOn<<4|s.isDependedOn<<2|s.hasRedundancy;return vv.box(vv.types.sdtp,r)}static stbl(e){return vv.box(vv.types.stbl,vv.stsd(e),vv.box(vv.types.stts,vv.STTS),vv.box(vv.types.stsc,vv.STSC),vv.box(vv.types.stsz,vv.STSZ),vv.box(vv.types.stco,vv.STCO))}static avc1(e){let t,r,i,s=[],n=[];for(t=0;t<e.sps.length;t++)r=e.sps[t],i=r.byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(r));for(t=0;t<e.pps.length;t++)r=e.pps[t],i=r.byteLength,n.push(i>>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(r));const a=vv.box(vv.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|e.sps.length].concat(s).concat([e.pps.length]).concat(n))),o=e.width,l=e.height,c=e.pixelRatio[0],d=e.pixelRatio[1];return vv.box(vv.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a,vv.box(vv.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),vv.box(vv.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d])))}static esds(e){const t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}static audioStsd(e){const t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,255&t,0,0])}static mp4a(e){return vv.box(vv.types.mp4a,vv.audioStsd(e),vv.box(vv.types.esds,vv.esds(e)))}static mp3(e){return vv.box(vv.types[".mp3"],vv.audioStsd(e))}static ac3(e){return vv.box(vv.types["ac-3"],vv.audioStsd(e),vv.box(vv.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if("audio"===e.type){if("aac"===t)return vv.box(vv.types.stsd,vv.STSD,vv.mp4a(e));if("ac3"===t&&e.config)return vv.box(vv.types.stsd,vv.STSD,vv.ac3(e));if("mp3"===t&&"mp3"===e.codec)return vv.box(vv.types.stsd,vv.STSD,vv.mp3(e))}else{if(!e.pps||!e.sps)throw new Error("video track missing pps or sps");if("avc"===t)return vv.box(vv.types.stsd,vv.STSD,vv.avc1(e));if("hevc"===t&&e.vps)return vv.box(vv.types.stsd,vv.STSD,vv.hvc1(e))}throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){const t=e.id,r=(e.duration||0)*(e.timescale||0),i=e.width||0,s=e.height||0,n=Math.floor(r/(gv+1)),a=Math.floor(r%(gv+1));return vv.box(vv.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,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,s>>8&255,255&s,0,0]))}static traf(e,t){const r=vv.sdtp(e),i=e.id,s=Math.floor(t/(gv+1)),n=Math.floor(t%(gv+1));return vv.box(vv.types.traf,vv.box(vv.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),vv.box(vv.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,n>>24,n>>16&255,n>>8&255,255&n])),vv.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,vv.box(vv.types.trak,vv.tkhd(e),vv.mdia(e))}static trex(e){const t=e.id;return vv.box(vv.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const r=e.samples||[],i=r.length,s=12+16*i,n=new Uint8Array(s);let a,o,l,c,d,u;for(t+=8+s,n.set(["video"===e.type?1:0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),a=0;a<i;a++)o=r[a],l=o.duration,c=o.size,d=o.flags,u=o.cts,n.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,c>>>24&255,c>>>16&255,c>>>8&255,255&c,d.isLeading<<2|d.dependsOn,d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|d.isNonSync,61440&d.degradPrio,15&d.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*a);return vv.box(vv.types.trun,n)}static initSegment(e){vv.types||vv.init();const t=vv.moov(e);return Gh(vv.FTYP,t)}static hvc1(e){const t=e.params,r=[e.vps,e.sps,e.pps],i=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),3|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),r.length]);let s=i.length;for(let e=0;e<r.length;e+=1){s+=3;for(let t=0;t<r[e].length;t+=1)s+=2+r[e][t].length}const n=new Uint8Array(s);n.set(i,0),s=i.length;const a=r.length-1;for(let e=0;e<r.length;e+=1){n.set(new Uint8Array([32+e|(e===a?128:0),0,r[e].length]),s),s+=3;for(let t=0;t<r[e].length;t+=1)n.set(new Uint8Array([r[e][t].length>>8,255&r[e][t].length]),s),s+=2,n.set(r[e][t],s),s+=r[e][t].length}const o=vv.box(vv.types.hvcC,n),l=e.width,c=e.height,d=e.pixelRatio[0],u=e.pixelRatio[1];return vv.box(vv.types.hvc1,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,l>>8&255,255&l,c>>8&255,255&c,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]),o,vv.box(vv.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),vv.box(vv.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,u>>24,u>>16&255,u>>8&255,255&u])))}}vv.types=void 0,vv.HDLR_TYPES=void 0,vv.STTS=void 0,vv.STSC=void 0,vv.STCO=void 0,vv.STSZ=void 0,vv.VMHD=void 0,vv.SMHD=void 0,vv.STSD=void 0,vv.FTYP=void 0,vv.DINF=void 0;function yv(e,t,r=1,i=!1){const s=e*t*r;return i?Math.round(s):s}function bv(e,t=!1){return yv(e,1e3,1/9e4,t)}function Ev(e){const{baseTime:t,timescale:r,trackId:i}=e;return`${t/r} (${t}/${r}) trackId: ${i}`}let wv,Sv=null,Tv=null;function xv(e,t,r,i){return{duration:t,size:r,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}class Av extends Ku{constructor(e,t,r,i){if(super("mp4-remuxer",i),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===Sv){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Sv=e?parseInt(e[1]):0}if(null===Tv){const e=navigator.userAgent.match(/Safari\/(\d+)/i);Tv=e?parseInt(e[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){const t=this._initPTS;t&&e&&e.trackId===t.trackId&&e.baseTime===t.baseTime&&e.timescale===t.timescale||this.log(`Reset initPTS: ${t?Ev(t):t} > ${e?Ev(e):e}`),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const r=e[0].pts,i=e.reduce((e,i)=>{let s=i.pts,n=s-e;return n<-4294967296&&(t=!0,s=kv(s,r),n=s-e),n>0?e:s},r);return t&&this.debug("PTS rollover detected"),i}remux(e,t,r,i,s,n,a,o){let l,c,d,u,h,f,p=s,m=s;const g=e.pid>-1,v=t.pid>-1,y=t.samples.length,b=e.samples.length>0,E=a&&y>0||y>1;if((!g||b)&&(!v||E)||this.ISGenerated||a){if(this.ISGenerated){var w,S,T,x;const e=this.videoTrackConfig;(e&&(t.width!==e.width||t.height!==e.height||(null==(w=t.pixelRatio)?void 0:w[0])!==(null==(S=e.pixelRatio)?void 0:S[0])||(null==(T=t.pixelRatio)?void 0:T[1])!==(null==(x=e.pixelRatio)?void 0:x[1]))||!e&&E||null===this.nextAudioTs&&b)&&this.resetInitSegment()}this.ISGenerated||(d=this.generateIS(e,t,s,n));const r=this.isVideoContiguous;let i,a=-1;if(E&&(a=function(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!r&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,a>0){this.warn(`Dropped ${a} out of ${y} video samples due to a missing keyframe`);const e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(a),t.dropped+=a,m+=(t.samples[0].pts-e)/t.inputTimeScale,i=m}else-1===a&&(this.warn(`No keyframe found out of ${y} video samples`),f=!1);if(this.ISGenerated){if(b&&E){const r=this.getVideoStartPts(t.samples),i=(kv(e.samples[0].pts,r)-r)/t.inputTimeScale;p+=Math.max(0,i),m+=Math.max(0,-i)}if(b){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),d=this.generateIS(e,t,s,n)),c=this.remuxAudio(e,p,this.isAudioContiguous,n,v||E||o===Uu?m:void 0),E){const i=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),d=this.generateIS(e,t,s,n)),l=this.remuxVideo(t,m,r,i)}}else E&&(l=this.remuxVideo(t,m,r,0));l&&(l.firstKeyFrame=a,l.independent=-1!==a,l.firstKeyFramePTS=i)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(h=Lv(r,s,this._initPTS,this._initDTS)),i.samples.length&&(u=Iv(i,s,this._initPTS))),{audio:c,video:l,initSegment:d,independent:f,text:u,id3:h}}computeInitPts(e,t,r,i){const s=Math.round(r*t);let n=kv(e,s);if(n<s+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(s-n)/t} ${i}`);n<s+t;)n+=8589934592;return n-s}generateIS(e,t,r,i){const s=e.samples,n=t.samples,a=this.typeSupported,o={},l=this._initPTS;let c,d,u,h=!l||i,f="audio/mp4",p=-1;if(h&&(c=d=1/0),e.config&&s.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":a.mpeg?(f="audio/mpeg",e.codec=""):a.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}o.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&a.mpeg?new Uint8Array(0):vv.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(p=e.id,u=e.inputTimeScale,l&&u===l.timescale?h=!1:c=d=this.computeInitPts(s[0].pts,u,r,"audio"))}if(t.sps&&t.pps&&n.length){if(t.timescale=t.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:vv.initSegment([t]),metadata:{width:t.width,height:t.height}},h)if(p=t.id,u=t.inputTimeScale,l&&u===l.timescale)h=!1;else{const e=this.getVideoStartPts(n),t=kv(n[0].dts,e),i=this.computeInitPts(t,u,r,"video"),s=this.computeInitPts(e,u,r,"video");d=Math.min(d,i),c=Math.min(c,s)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(o).length)return this.ISGenerated=!0,h?(l&&this.warn(`Timestamps at playlist time: ${i?"":"~"}${r} ${c/u} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${r} offset: ${c/u} (${c}/${u}) trackId: ${p}`),this._initPTS={baseTime:c,timescale:u,trackId:p},this._initDTS={baseTime:d,timescale:u,trackId:p}):c=u=void 0,{tracks:o,initPTS:c,timescale:u,trackId:p}}remuxVideo(e,t,r,i){const s=e.inputTimeScale,n=e.samples,a=[],o=n.length,l=this._initPTS,c=l.baseTime*s/l.timescale;let d,u,h=this.nextVideoTs,f=8,p=this.videoSampleDuration,m=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,v=!1;if(!r||null===h){const e=c+t*s,i=n[0].pts-kv(n[0].dts,n[0].pts);Sv&&null!==h&&Math.abs(e-i-(h+c))<15e3?r=!0:h=e-i-c}const y=h+c;for(let e=0;e<o;e++){const t=n[e];t.pts=kv(t.pts,y),t.dts=kv(t.dts,y),t.dts<n[e>0?e-1:e].dts&&(v=!0)}v&&n.sort(function(e,t){const r=e.dts-t.dts,i=e.pts-t.pts;return r||i}),d=n[0].dts,u=n[n.length-1].dts;const b=u-d,E=b?Math.round(b/(o-1)):p||e.inputTimeScale/30;if(r){const r=d-y,i=r>E,s=r<-1;if((i||s)&&(i?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${bv(r,!0)} ms (${r}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${bv(-r,!0)} ms (${r}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!s||y>=n[0].pts||Sv)){d=y;const e=n[0].pts-r;if(i)n[0].dts=d,n[0].pts=e;else{let t=!0;for(let i=0;i<n.length&&!(n[i].dts>e&&t);i++){const e=n[i].pts;if(n[i].dts-=r,n[i].pts-=r,i<n.length-1){const r=n[i+1].pts;t=r<=n[i].pts==r<=e}}}this.log(`Video: Initial PTS/DTS adjusted: ${bv(e,!0)}/${bv(d,!0)}, delta: ${bv(r,!0)} ms`)}}d=Math.max(0,d);let w=0,S=0,T=d;for(let e=0;e<o;e++){const t=n[e],r=t.units,i=r.length;let s=0;for(let e=0;e<i;e++)s+=r[e].data.length;S+=s,w+=i,t.length=s,t.dts<T?(t.dts=T,T+=E/4|0||1):T=t.dts,m=Math.min(t.pts,m),g=Math.max(t.pts,g)}u=n[o-1].dts;const x=S+4*w+8;let A;try{A=new Uint8Array(x)}catch(e){return void this.observer.emit(Ou.ERROR,Ou.ERROR,{type:Du.MUX_ERROR,details:_u.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:x,reason:`fail allocating video mdat ${x}`})}const k=new DataView(A.buffer);k.setUint32(0,x),A.set(vv.types.mdat,4);let L=!1,I=Number.POSITIVE_INFINITY,R=Number.POSITIVE_INFINITY,P=Number.NEGATIVE_INFINITY,C=Number.NEGATIVE_INFINITY;for(let e=0;e<o;e++){const t=n[e],r=t.units;let l,d=0;for(let e=0,t=r.length;e<t;e++){const t=r[e],i=t.data,s=t.data.byteLength;k.setUint32(f,s),f+=4,A.set(i,f),f+=s,d+=4+s}if(e<o-1)p=n[e+1].dts-t.dts,l=n[e+1].pts-t.pts;else{const r=this.config,a=e>0?t.dts-n[e-1].dts:E;if(l=e>0?t.pts-n[e-1].pts:E,r.stretchShortVideoTrack&&null!==this.nextAudioTs){const e=Math.floor(r.maxBufferHole*s),n=(i?m+i*s:this.nextAudioTs+c)-t.pts;n>e?(p=n-a,p<0?p=a:L=!0,this.log(`It is approximately ${n/90} ms to the next segment; using duration ${p/90} ms for the last video frame.`)):p=a}else p=a}const u=Math.round(t.pts-t.dts);I=Math.min(I,p),P=Math.max(P,p),R=Math.min(R,l),C=Math.max(C,l),a.push(xv(t.key,p,d,u))}if(a.length)if(Sv){if(Sv<70){const e=a[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(Tv&&C-R<P-I&&E/P<.025&&0===a[0].cts){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let e=d;for(let t=0,r=a.length;t<r;t++){const i=e+a[t].duration,s=e+a[t].cts;if(t<r-1){const e=i+a[t+1].cts;a[t].duration=e-s}else a[t].duration=t?a[t-1].duration:E;a[t].cts=0,e=i}}p=L||!p?E:p;const D=u+p;this.nextVideoTs=h=D-c,this.videoSampleDuration=p,this.isVideoContiguous=!0;const _={data1:vv.moof(e.sequenceNumber++,d,Vu(e,{samples:a})),data2:A,startPTS:(m-c)/s,endPTS:(g+p-c)/s,startDTS:(d-c)/s,endDTS:h/s,type:"video",hasAudio:!1,hasVideo:!0,nb:a.length,dropped:e.dropped};return e.samples=[],e.dropped=0,_}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}remuxAudio(e,t,r,i,s){const n=e.inputTimeScale,a=n/(e.samplerate?e.samplerate:n),o=this.getSamplesPerFrame(e),l=o*a,c=this._initPTS,d="mp3"===e.segmentCodec&&this.typeSupported.mpeg,u=[],h=void 0!==s;let f=e.samples,p=d?0:8,m=this.nextAudioTs||-1;const g=c.baseTime*n/c.timescale,v=g+t*n;if(this.isAudioContiguous=r=r||f.length&&m>0&&(i&&Math.abs(v-(m+g))<9e3||Math.abs(kv(f[0].pts,v)-(m+g))<20*l),f.forEach(function(e){e.pts=kv(e.pts,v)}),!r||m<0){const e=f.length;if(f=f.filter(e=>e.pts>=0),e!==f.length&&this.warn(`Removed ${f.length-e} of ${e} samples (initPTS ${g} / ${n})`),!f.length)return;m=0===s?0:i&&!h?Math.max(0,v-g):f[0].pts-g}if("aac"===e.segmentCodec){const t=this.config.maxAudioFramesDrift;for(let r=0,i=m+g;r<f.length;r++){const s=f[r],a=s.pts,o=a-i,c=Math.abs(1e3*o/n);if(o<=-t*l&&h)0===r&&(this.warn(`Audio frame @ ${(a/n).toFixed(3)}s overlaps marker by ${Math.round(1e3*o/n)} ms.`),this.nextAudioTs=m=a-g,i=a);else if(o>=t*l&&c<1e4&&h){let t=Math.round(o/l);for(i=a-t*l;i<0&&t&&l;)t--,i+=l;0===r&&(this.nextAudioTs=m=i-g),this.warn(`Injecting ${t} audio frames @ ${((i-g)/n).toFixed(3)}s due to ${Math.round(1e3*o/n)} ms gap.`);for(let n=0;n<t;n++){let t=mv.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);t||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),t=s.unit.subarray()),f.splice(r,0,{unit:t,pts:i}),i+=l,r++}}s.pts=i,i+=l}}let y,b=null,E=null,w=0,S=f.length;for(;S--;)w+=f[S].unit.byteLength;for(let t=0,i=f.length;t<i;t++){const i=f[t],s=i.unit;let n=i.pts;if(null!==E){u[t-1].duration=Math.round((n-E)/a)}else{if(r&&"aac"===e.segmentCodec&&(n=m+g),b=n,!(w>0))return;w+=p;try{y=new Uint8Array(w)}catch(e){return void this.observer.emit(Ou.ERROR,Ou.ERROR,{type:Du.MUX_ERROR,details:_u.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:w,reason:`fail allocating audio mdat ${w}`})}if(!d){new DataView(y.buffer).setUint32(0,w),y.set(vv.types.mdat,4)}}y.set(s,p);const l=s.byteLength;p+=l,u.push(xv(!0,o,l,0)),E=n}const T=u.length;if(!T)return;const x=u[u.length-1];m=E-g,this.nextAudioTs=m+a*x.duration;const A=d?new Uint8Array(0):vv.moof(e.sequenceNumber++,b/a,Vu({},e,{samples:u}));e.samples=[];const k=(b-g)/n,L=this.nextAudioTs/n,I={data1:A,data2:y,startPTS:k,endPTS:L,startDTS:k,endDTS:L,type:"audio",hasAudio:!0,hasVideo:!1,nb:T};return this.isAudioContiguous=!0,I}}function kv(e,t){let r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}function Lv(e,t,r,i){const s=e.samples.length;if(!s)return;const n=e.inputTimeScale;for(let a=0;a<s;a++){const s=e.samples[a];s.pts=kv(s.pts-r.baseTime*n/r.timescale,t*n)/n,s.dts=kv(s.dts-i.baseTime*n/i.timescale,t*n)/n}const a=e.samples;return e.samples=[],{samples:a}}function Iv(e,t,r){const i=e.samples.length;if(!i)return;const s=e.inputTimeScale;for(let n=0;n<i;n++){const i=e.samples[n];i.pts=kv(i.pts-r.baseTime*s/r.timescale,t*s)/s}e.samples.sort((e,t)=>e.pts-t.pts);const n=e.samples;return e.samples=[],{samples:n}}function Rv(e,t,r=!1){return void 0!==(null==e?void 0:e.start)?(e.start+(r?e.duration:0))/e.timescale:t}function Pv(e,t,r){const i=e.codec;if(i&&i.length>4)return i;if(t===gh){if("ec-3"===i||"ac-3"===i||"alac"===i)return i;if("fLaC"===i||"Opus"===i){return of(i,!1)}return r.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"}return r.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1"}try{wv=self.performance.now.bind(self.performance)}catch(e){wv=Date.now}const Cv=[{demux:class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,i){const s=this.videoTrack=$g("video",1),n=this.audioTrack=$g("audio",1),a=this.txtTrack=$g("text",1);if(this.id3Track=$g("id3",1),this.timeOffset=0,null==e||!e.byteLength)return;const o=Oh(e);if(o.video){const{id:e,timescale:t,codec:r,supplemental:i}=o.video;s.id=e,s.timescale=a.timescale=t,s.codec=r,s.supplemental=i}if(o.audio){const{id:e,timescale:t,codec:r}=o.audio;n.id=e,n.timescale=t,n.codec=r}a.id=kh.text,s.sampleDuration=0,s.duration=n.duration=i}resetContiguity(){this.remainderData=null}static probe(e){return function(e){const t=e.byteLength;for(let r=0;r<t;){const i=Rh(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}(e)}demux(e,t){this.timeOffset=t;let r=e;const i=this.videoTrack,s=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Gh(this.remainderData,e));const t=function(e){const t={valid:null,remainder:null},r=Dh(e,["moof"]);if(r.length<2)return t.remainder=e,t;const i=r[r.length-1];return t.valid=e.slice(0,i.byteOffset-8),t.remainder=e.slice(i.byteOffset-8),t}(r);this.remainderData=t.remainder,i.samples=t.valid||new Uint8Array}else i.samples=r;const n=this.extractID3Track(i,t);return s.samples=jh(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const i=this.extractID3Track(t,this.timeOffset);return r.samples=jh(e,t),{videoTrack:t,audioTrack:$g(),id3Track:i,textTrack:$g()}}extractID3Track(e,t){const r=this.id3Track;if(e.samples.length){const i=Dh(e.samples,["emsg"]);i&&i.forEach(e=>{const i=function(e){const t=e[0];let r="",i="",s=0,n=0,a=0,o=0,l=0,c=0;if(0===t){for(;"\0"!==Lh(e.subarray(c,c+1));)r+=Lh(e.subarray(c,c+1)),c+=1;for(r+=Lh(e.subarray(c,c+1)),c+=1;"\0"!==Lh(e.subarray(c,c+1));)i+=Lh(e.subarray(c,c+1)),c+=1;i+=Lh(e.subarray(c,c+1)),c+=1,s=Rh(e,12),n=Rh(e,16),o=Rh(e,20),l=Rh(e,24),c=28}else if(1===t){c+=4,s=Rh(e,c),c+=4;const t=Rh(e,c);c+=4;const n=Rh(e,c);for(c+=4,a=2**32*t+n,Pu(a)||(a=Number.MAX_SAFE_INTEGER,eh.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Rh(e,c),c+=4,l=Rh(e,c),c+=4;"\0"!==Lh(e.subarray(c,c+1));)r+=Lh(e.subarray(c,c+1)),c+=1;for(r+=Lh(e.subarray(c,c+1)),c+=1;"\0"!==Lh(e.subarray(c,c+1));)i+=Lh(e.subarray(c,c+1)),c+=1;i+=Lh(e.subarray(c,c+1)),c+=1}return{schemeIdUri:r,value:i,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:e.subarray(c,e.byteLength)}}(e);if(ev.test(i.schemeIdUri)){const e=tv(i,t);let s=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;s<=.001&&(s=Number.POSITIVE_INFINITY);const n=i.payload;r.samples.push({data:n,len:n.byteLength,dts:e,pts:e,type:Fg.emsg,duration:s})}else if(this.config.enableEmsgKLVMetadata&&i.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const e=tv(i,t);r.samples.push({data:i.payload,len:i.payload.byteLength,dts:e,pts:e,type:Fg.misbklv,duration:Number.POSITIVE_INFINITY})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}},remux:class extends Ku{constructor(e,t,r,i){super("passthrough-remuxer",i),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,this.isVideoContiguous=!1}destroy(){}resetTimeStamp(e){this.lastEndTime=null;const t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(e,i),this.emitInitSegment=!0}generateInitSegment(e,t){let{audioCodec:r,videoCodec:i}=this;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const{audio:s,video:n}=this.initData=Oh(e);if(t)!function(e,t){if(!e||!t)return;const r=t.keyId;r&&t.isCommonEncryption&&Uh(e,(e,t)=>{const i=e.subarray(8,24);i.some(e=>0!==e)||(eh.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${sh(i)} -> ${sh(r)}`),e.set(r,8))})}(e,t);else{const e=s||n;null!=e&&e.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${e.codec}")!`)}s&&(r=Pv(s,gh,this)),n&&(i=Pv(n,vh,this));const a={};s&&n?a.audiovideo={container:"video/mp4",codec:r+","+i,supplemental:n.supplemental,encrypted:n.encrypted,initSegment:e,id:"main"}:s?a.audio={container:"audio/mp4",codec:r,encrypted:s.encrypted,initSegment:e,id:"audio"}:n?a.video={container:"video/mp4",codec:i,supplemental:n.supplemental,encrypted:n.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=a}remux(e,t,r,i,s,n){var a,o;let{initPTS:l,lastEndTime:c}=this;const d={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};Ru(c)||(c=this.lastEndTime=s||0);const u=t.samples;if(!u.length)return d;const h={initPTS:void 0,timescale:void 0,trackId:void 0};let f=this.initData;if(null!=(a=f)&&a.length||(this.generateInitSegment(u),f=this.initData),null==(o=f)||!o.length)return this.warn("Failed to generate initSegment."),d;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1);const p=function(e,t,r){const i={},s=Dh(e,["moof","traf"]);for(let e=0;e<s.length;e++){const n=s[e],a=Dh(n,["tfhd"])[0],o=Rh(a,4),l=t[o];if(!l)continue;i[o]||(i[o]={start:NaN,duration:0,sampleCount:0,timescale:l.timescale,type:l.type});const c=i[o],d=Dh(n,["tfdt"])[0];if(d){const e=d[0];let t=Rh(d,4);1===e&&(t===xh?r.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(t*=xh+1,t+=Rh(d,8))),Ru(t)&&(!Ru(c.start)||t<c.start)&&(c.start=t)}const u=l.default,h=Rh(a,0)|(null==u?void 0:u.flags);let f=(null==u?void 0:u.duration)||0;8&h&&(f=Rh(a,2&h?12:8));const p=Dh(n,["trun"]);let m=c.start||0,g=0,v=f;for(let e=0;e<p.length;e++){const t=p[e],r=Rh(t,4),i=c.sampleCount;c.sampleCount+=r;const s=1&t[3],n=4&t[3],a=1&t[2],o=2&t[2],l=4&t[2],d=8&t[2];let u=8,h=r;for(s&&(u+=4),n&&r&&(1&t[u+1]||void 0!==c.keyFrameIndex||(c.keyFrameIndex=i),u+=4,a?(v=Rh(t,u),u+=4):v=f,o&&(u+=4),d&&(u+=4),m+=v,g+=v,h--);h--;)a?(v=Rh(t,u),u+=4):v=f,o&&(u+=4),l&&(1&t[u+1]||void 0===c.keyFrameIndex&&(c.keyFrameIndex=c.sampleCount-(h+1),c.keyFrameStart=m),u+=4),d&&(u+=4),m+=v,g+=v;!g&&f&&(g+=f*r)}c.duration+=g}if(!Object.keys(i).some(e=>i[e].duration)){let t=1/0,r=0;const s=Dh(e,["sidx"]);for(let e=0;e<s.length;e++){const i=_h(s[e]);if(null!=i&&i.references){t=Math.min(t,i.earliestPresentationTime/i.timescale);const e=i.references.reduce((e,t)=>e+t.info.duration||0,0);r=Math.max(r,e+i.earliestPresentationTime/i.timescale)}}r&&Ru(r)&&Object.keys(i).forEach(e=>{i[e].duration||(i[e].duration=r*i[e].timescale-i[e].start)})}return i}(u,f,this),m=f.audio?p[f.audio.id]:null,g=f.video?p[f.video.id]:null,v=Rv(g,1/0),y=Rv(m,1/0),b=Rv(g,0,!0),E=Rv(m,0,!0);let w=s,S=0;const T=m&&(!g||!l&&y<v||l&&l.trackId===f.audio.id),x=T?m:g;if(x){const e=x.timescale,t=x.start-s*e,r=T?f.audio.id:f.video.id;w=x.start/e,S=T?E-y:b-v,!n&&l||!function(e,t,r,i){if(null===e)return!0;const s=Math.max(i,1),n=t-e.baseTime/e.timescale;return Math.abs(n-r)>s}(l,w,s,S)&&e===l.timescale||(l&&this.warn(`Timestamps at playlist time: ${n?"":"~"}${s} ${t/e} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${s} offset: ${w-s} (${t}/${e}) trackId: ${r}`),l=null,h.initPTS=t,h.timescale=e,h.trackId=r)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${s}`);l?(h.initPTS=l.baseTime,h.timescale=l.timescale,h.trackId=l.trackId):(h.timescale&&void 0!==h.trackId&&void 0!==h.initPTS||(this.warn("Could not set initPTS"),h.initPTS=w,h.timescale=1,h.trackId=-1),this.initPTS=l={baseTime:h.initPTS,timescale:h.timescale,trackId:h.trackId});const A=w-l.baseTime/l.timescale,k=A+S;S>0?this.lastEndTime=k:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const L=!!f.audio,I=!!f.video;let R="";L&&(R+="audio"),I&&(R+="video");const P={data1:u,startPTS:A,startDTS:A,endPTS:k,endDTS:k,type:R,hasAudio:L,hasVideo:I,nb:1,dropped:0,encrypted:!!f.audio&&f.audio.encrypted||!!f.video&&f.video.encrypted};d.audio=L&&!I?P:void 0,d.video=I?P:void 0;const C=null==g?void 0:g.sampleCount;if(C){const e=g.keyFrameIndex,t=-1!==e;P.nb=C,P.dropped=0===e||this.isVideoContiguous?0:t?e:C,P.independent=t,P.firstKeyFrame=e,t&&g.keyFrameStart&&(P.firstKeyFramePTS=(g.keyFrameStart-l.baseTime)/l.timescale),this.isVideoContiguous||(d.independent=t),this.isVideoContiguous||(this.isVideoContiguous=t),P.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${e}/${C} dropped: ${P.dropped} start: ${P.firstKeyFramePTS||"NA"}`)}return d.initSegment=h,d.id3=Lv(r,s,l,l),i.samples.length&&(d.text=Iv(i,s,l)),d}}},{demux:lv,remux:Av},{demux:class extends Bg{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;const r=bg(e,0);let i=(null==r?void 0:r.length)||0;if(Xg(e,i))return!1;for(let r=e.length;i<r;i++)if(xg(e,i))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&Eg(e,t)&&Sg(e,t)<=e.length-t}(e,t)}appendFrame(e,t,r){Ag(e,this.observer,t,r,e.manifestCodec);const i=Lg(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}},remux:Av},{demux:class extends Bg{resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=bg(e,0);let r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==Ng(t)&&Qg(e,r)<=16)return!1;for(let t=e.length;r<t;r++)if(Xg(e,r))return eh.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return Kg(e,t)&&4<=e.length-t}(e,t)}appendFrame(e,t,r){if(null!==this.basePTS)return Wg(e,t,r,this.basePTS,this.frameIndex)}},remux:Av}];Cv.splice(2,0,{demux:Zg,remux:Av});class Dv{constructor(e,t,r,i,s,n){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.id=s,this.logger=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,i){const s=r.transmuxing;s.executeStart=wv();let n=new Uint8Array(e);const{currentTransmuxState:a,transmuxConfig:o}=this;i&&(this.currentTransmuxState=i);const{contiguous:l,discontinuity:c,trackSwitch:d,accurateTimeOffset:u,timeOffset:h,initSegmentChange:f}=i||a,{audioCodec:p,videoCodec:m,defaultInitPts:g,duration:v,initSegmentData:y}=o,b=function(e,t){let r=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t);return r}(n,t);if(b&&Hp(b.method)){const e=this.getDecrypter(),t=Vp(b.method);if(!e.isSync())return this.asyncResult=!0,this.decryptionPromise=e.webCryptoDecrypt(n,b.key.buffer,b.iv.buffer,t).then(e=>{const t=this.push(e,null,r);return this.decryptionPromise=null,t}),this.decryptionPromise;{let i=e.softwareDecrypt(n,b.key.buffer,b.iv.buffer,t);if(r.part>-1){const t=e.flush();i=t?t.buffer:t}if(!i)return s.executeEnd=wv(),_v(r);n=new Uint8Array(i)}}const E=this.needsProbing(c,d);if(E){const e=this.configureTransmuxer(n);if(e)return this.logger.warn(`[transmuxer] ${e.message}`),this.observer.emit(Ou.ERROR,Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),s.executeEnd=wv(),_v(r)}(c||d||f||E)&&this.resetInitSegment(y,p,m,v,t),(c||f||E)&&this.resetInitialTimestamp(g),l||this.resetContiguity();const w=this.transmux(n,b,h,u,r);this.asyncResult=Ov(w);const S=this.currentTransmuxState;return S.contiguous=!0,S.discontinuity=!1,S.trackSwitch=!1,s.executeEnd=wv(),w}flush(e){const t=e.transmuxing;t.executeStart=wv();const{decrypter:r,currentTransmuxState:i,decryptionPromise:s}=this;if(s)return this.asyncResult=!0,s.then(()=>this.flush(e));const n=[],{timeOffset:a}=i;if(r){const t=r.flush();t&&n.push(this.push(t.buffer,null,e))}const{demuxer:o,remuxer:l}=this;if(!o||!l){t.executeEnd=wv();const r=[_v(e)];return this.asyncResult?Promise.resolve(r):r}const c=o.flush(a);return Ov(c)?(this.asyncResult=!0,c.then(t=>(this.flushRemux(n,t,e),n))):(this.flushRemux(n,c,e),this.asyncResult?Promise.resolve(n):n)}flushRemux(e,t,r){const{audioTrack:i,videoTrack:s,id3Track:n,textTrack:a}=t,{accurateTimeOffset:o,timeOffset:l}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${r.sn}${r.part>-1?" part: "+r.part:""} of ${this.id===Bu?"level":"track"} ${r.level}`);const c=this.remuxer.remux(i,s,n,a,l,o,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=wv()}resetInitialTimestamp(e){const{demuxer:t,remuxer:r}=this;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,i,s){const{demuxer:n,remuxer:a}=this;n&&a&&(n.resetInitSegment(e,t,r,i),a.resetInitSegment(e,t,r,s))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,i,s){let n;return n=t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,s):this.transmuxUnencrypted(e,r,i,s),n}transmuxUnencrypted(e,t,r,i){const{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(s,n,a,o,t,r,!1,this.id),chunkMeta:i}}transmuxSampleAes(e,t,r,i,s){return this.demuxer.demuxSampleAes(e,t,r).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,this.id),chunkMeta:s}))}configureTransmuxer(e){const{config:t,observer:r,typeSupported:i}=this;let s;for(let t=0,r=Cv.length;t<r;t++){var n;if(null!=(n=Cv[t].demux)&&n.probe(e,this.logger)){s=Cv[t];break}}if(!s)return new Error("Failed to find demuxer by probing fragment data");const a=this.demuxer,o=this.remuxer,l=s.remux,c=s.demux;o&&o instanceof l||(this.remuxer=new l(r,t,i,this.logger)),a&&a instanceof c||(this.demuxer=new c(r,t,i,this.logger),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Ep(this.config)),e}}const _v=e=>({remuxResult:{},chunkMeta:e});function Ov(e){return"then"in e&&e.then instanceof Function}class Mv{constructor(e,t,r,i,s){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=s||null}}class Nv{constructor(e,t,r,i,s,n){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=s,this.initSegmentChange=n}}let Fv=0;class $v{constructor(e,t,r,i){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Fv++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=e=>{const t=e.data,r=this.hls;if(r&&null!=t&&t.event&&t.instanceNo===this.instanceNo)switch(t.event){case"init":{var i;const e=null==(i=this.workerContext)?void 0:i.objectURL;e&&self.URL.revokeObjectURL(e);break}case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":r.logger[t.data.logType]&&r.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.part=this.part,t.data.id=this.id,r.trigger(t.event,t.data)}},this.onWorkerError=e=>{if(!this.hls)return;const t=new Error(`${e.message} (${e.filename}:${e.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})};const s=e.config;this.hls=e,this.id=t,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;const n=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===Ou.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new fg,this.observer.on(Ou.FRAG_DECRYPTED,n),this.observer.on(Ou.ERROR,n);const a=uf(s.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){const r=this.hls.logger;if(s.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{s.workerPath?(r.log(`loading Web Worker ${s.workerPath} for "${t}"`),this.workerContext=function(e){const t=mg[e];if(t)return t.clientCount++,t;const r=new self.URL(e,self.location.href).href,i={worker:new self.Worker(r),scriptURL:r,clientCount:1};return mg[e]=i,i}(s.workerPath)):(r.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){const e=mg[pg];if(e)return e.clientCount++,e;const t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),r=self.URL.createObjectURL(t),i={worker:new self.Worker(r),objectURL:r,clientCount:1};return mg[pg]=i,i}());const{worker:e}=this.workerContext;e.addEventListener("message",this.onWorkerMessage),e.addEventListener("error",this.onWorkerError),e.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:a,id:t,config:Pf(s)})}catch(i){r.warn(`Error setting up "${t}" Web Worker, fallback to inline`,i),this.terminateWorker(),this.error=null,this.transmuxer=new Dv(this.observer,a,s,"",t,e.logger)}return}}this.transmuxer=new Dv(this.observer,a,s,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=Fv++;const t=this.hls.config,r=uf(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:Pf(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),function(e){const t=mg[e||pg];if(t&&1===t.clientCount--){const{worker:r,objectURL:i}=t;delete mg[e||pg],i&&self.URL.revokeObjectURL(i),r.terminate()}}(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,r,i,s,n,a,o,l,c){var d,u;l.transmuxing.start=self.performance.now();const{instanceNo:h,transmuxer:f}=this,p=n?n.start:s.start,m=s.decryptdata,g=this.frag,v=!(g&&s.cc===g.cc),y=!(g&&l.level===g.level),b=g?l.sn-g.sn:-1,E=this.part?l.part-this.part.index:-1,w=0===b&&l.id>1&&l.id===(null==g?void 0:g.stats.chunkCount),S=!y&&(1===b||0===b&&(1===E||w&&E<=0)),T=self.performance.now();(y||b||0===s.stats.parsing.start)&&(s.stats.parsing.start=T),!n||!E&&S||(n.stats.parsing.start=T);const x=!(g&&(null==(d=s.initSegment)?void 0:d.url)===(null==(u=g.initSegment)?void 0:u.url)),A=new Nv(v,S,o,y,p,x);if(!S||v||x){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${s.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id===Bu?"level":"track"}: ${l.level} id: ${l.id}\n discontinuity: ${v}\n trackSwitch: ${y}\n contiguous: ${S}\n accurateTimeOffset: ${o}\n timeOffset: ${p}\n initSegmentChange: ${x}`);const e=new Mv(r,i,t,a,c);this.configureTransmuxer(e)}if(this.frag=s,this.part=n,this.workerContext)this.workerContext.worker.postMessage({instanceNo:h,cmd:"demux",data:e,decryptdata:m,chunkMeta:l,state:A},e instanceof ArrayBuffer?[e]:[]);else if(f){const t=f.push(e,m,l,A);Ov(t)?t.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,l,"transmuxer-interface push error")}):this.handleTransmuxComplete(t)}}flush(e){e.transmuxing.start=self.performance.now();const{instanceNo:t,transmuxer:r}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(r){const t=r.flush(e);Ov(t)?t.then(t=>{this.handleFlushResult(t,e)}).catch(t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")}):this.handleFlushResult(t,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}configureTransmuxer(e){const{instanceNo:t,transmuxer:r}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):r&&r.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}class Bv extends Ku{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,r){const i=null==t?void 0:t.renditionReports;if(i){let s=-1;for(let r=0;r<i.length;r++){const n=i[r];let a;try{a=new self.URL(n.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),a=n.URI||""}if(a===e){s=r;break}a===e.substring(0,a.length)&&(s=r)}if(-1!==s){const e=i[s],n=parseInt(e["LAST-MSN"])||t.lastPartSn;let a=parseInt(e["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const e=Math.min(t.age-t.partTarget,t.targetduration);a>=0&&e>t.partTarget&&(a+=1)}const o=r&&Af(r);return new kf(n,a>=0?a:void 0,o)}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}return e}playlistLoaded(e,t,r){const{details:i,stats:s}=t,n=self.performance.now(),a=s.loading.first?Math.max(0,n-s.loading.first):0;i.advancedDateTime=Date.now()-a;const o=this.hls.config.timelineOffset;if(o!==i.appliedTimelineOffset){const e=Math.max(o||0,0);i.appliedTimelineOffset=e,i.fragments.forEach(t=>{t.setStart(t.playlistOffset+e)})}if(i.live||null!=r&&r.live){const o="levelInfo"in t?t.levelInfo:t.track;if(i.reloaded(r),r&&i.fragments.length>0){Pm(r,i,this);const e=i.playlistParsingError;if(e){this.warn(e);const r=this.hls;if(!r.config.ignorePlaylistParsingErrors){var l;const{networkDetails:n}=t;return void r.trigger(Ou.ERROR,{type:Du.NETWORK_ERROR,details:_u.LEVEL_PARSING_ERROR,fatal:!1,url:i.url,error:e,reason:e.message,level:t.level||void 0,parent:null==(l=i.fragments[0])?void 0:l.type,networkDetails:n,stats:s})}i.playlistParsingError=null}}-1===i.requestScheduled&&(i.requestScheduled=s.loading.start);const c=this.hls.mainForwardBufferInfo,d=c?c.end-c.len:0,u=Om(i,1e3*(i.edge-d));if(i.requestScheduled+u<n?i.requestScheduled=n:i.requestScheduled+=u,this.log(`live playlist ${e} ${i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED"}`),!this.canLoad||!i.live)return;let h,f,p;if(i.canBlockReload&&i.endSN&&i.advanced){const e=this.hls.config.lowLatencyMode,s=i.lastPartSn,a=i.endSN,l=i.lastPartIndex,c=s===a;-1!==l?c?(f=a+1,p=e?0:l):(f=s,p=e?l+1:i.maxPartIndex):f=a+1;const d=i.age,u=d+i.ageHeader;let m=Math.min(u-i.partTarget,1.5*i.targetduration);if(m>0){if(u>3*i.targetduration)this.log(`Playlist last advanced ${d.toFixed(2)}s ago. Omitting segment and part directives.`),f=void 0,p=void 0;else if(null!=r&&r.tuneInGoal&&u-i.partTarget>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${m} with playlist age: ${i.age}`),m=0;else{const e=Math.floor(m/i.targetduration);if(f+=e,void 0!==p){p+=Math.round(m%i.targetduration/i.partTarget)}this.log(`CDN Tune-in age: ${i.ageHeader}s last advanced ${d.toFixed(2)}s goal: ${m} skip sn ${e} to part ${p}`)}i.tuneInGoal=m}if(h=this.getDeliveryDirectives(i,t.deliveryDirectives,f,p),e||!c)return i.requestScheduled=n,void this.loadingPlaylist(o,h)}else(i.canBlockReload||i.canSkipUntil)&&(h=this.getDeliveryDirectives(i,t.deliveryDirectives,f,p));h&&void 0!==f&&i.canBlockReload&&(i.requestScheduled=s.loading.first+Math.max(u-2*a,u/2)),this.scheduleLoading(o,h,i)}else this.clearTimer()}scheduleLoading(e,t,r){const i=r||e.details;if(!i)return void this.loadingPlaylist(e,t);const s=self.performance.now(),n=i.requestScheduled;if(s>=n)return void this.loadingPlaylist(e,t);const a=n-s;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(a)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),a)}getDeliveryDirectives(e,t,r,i){let s=Af(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,s=Sf),new kf(r,i,s)}checkRetry(e){const t=e.details,r=Hf(e),i=e.errorAction,{action:s,retryCount:n=0,retryConfig:a}=i||{},o=!!i&&!!a&&(s===tp||!i.resolved&&s===Jf);if(o){var l;if(n>=a.maxNumRetry)return!1;if(r&&null!=(l=e.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${n+1}/${a.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const e=Kf(a,n);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),e),this.warn(`Retrying playlist loading ${n+1}/${a.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,i.resolved=!0}return o}}function Uv(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!zv(e[r].attrs,t[r].attrs))return!1;return!0}function zv(e,t,r){const i=e["STABLE-RENDITION-ID"];return i&&!r?i===t["STABLE-RENDITION-ID"]:!(r||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(r=>e[r]!==t[r])}function Gv(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}class jv{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,r){if(null===this.queues||null===this.tracks)return;const i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)}appendBlocker(e){return new Promise(t=>{const r={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(r,e)})}prependBlocker(e){return new Promise(t=>{if(this.queues){const r={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(r)}})}removeBlockers(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;const r=null==(t=e[0])?void 0:t.label;"async-blocker"!==r&&"async-blocker-prepend"!==r||(e[0].execute(),e.splice(0,1))})}unblockAudio(e){if(null===this.queues)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")}executeNext(e){if(null===this.queues||null===this.tracks)return;const t=this.queues[e];if(t.length){const i=t[0];try{i.execute()}catch(t){var r;if(i.onError(t),null===this.queues||null===this.tracks)return;const s=null==(r=this.tracks[e])?void 0:r.buffer;null!=s&&s.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}toString(){const{queues:e,tracks:t}=this;return null===e||null===t?"<destroyed>":`\n${this.list("video")}\n${this.list("audio")}\n${this.list("audiovideo")}}`}list(e){var t,r;return null!=(t=this.queues)&&t[e]||null!=(r=this.tracks)&&r[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;const r=null==(t=this.tracks)?void 0:t[e],i=null==r?void 0:r.buffer;return i?`SourceBuffer${i.updating?" updating":""}${r.ended?" ended":""}${r.ending?" ending":""}`:"none"}listOps(e){var t;return(null==(t=this.queues)?void 0:t[e].map(e=>e.label).join(", "))||""}}const Hv=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Vv="HlsJsTrackRemovedError";class Wv extends Error{constructor(e){super(e),this.name=Vv}}function Yv(e){const t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function Kv(e){return"audio"===e?1:0}class qv{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(Ou.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Ou.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(Ou.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Ou.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&Ru(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);const e=this.hls.levels;if(e.length){const t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${r}: ${e[r].height}p@${e[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=r,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const r=t.filter((t,r)=>this.isLevelAllowed(t)&&r<=e);return this.clientRect=null,qv.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return!this.restrictedLevels.some(t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height)}static getMaxLevelByMediaSize(e,t,r){if(null==e||!e.length)return-1;const i=(e,t)=>!t||(e.width!==t.width||e.height!==t.height);let s=e.length-1;const n=Math.max(t,r);for(let t=0;t<e.length;t+=1){const r=e[t];if((r.width>=n||r.height>=n)&&i(r,e[t+1])){s=t;break}}return s}}const Xv={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},Qv={HLS:"h"};class Zv{constructor(e,t){Array.isArray(e)&&(e=e.map(e=>e instanceof Zv?e:new Zv(e))),this.value=e,this.params=t}}function Jv(e,t,r,i){return new Error(`failed to ${e} "${s=t,Array.isArray(s)?JSON.stringify(s):s instanceof Map?"Map{}":s instanceof Set?"Set{}":"object"==typeof s?JSON.stringify(s):String(s)}" as ${r}`,{cause:i});var s}function ey(e,t,r){return Jv("serialize",e,t,r)}class ty{constructor(e){this.description=e}}const ry="Bare Item";function iy(e){if(!1===ArrayBuffer.isView(e))throw ey(e,"Byte Sequence");return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function sy(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw ey(e,"Integer");return e.toString()}function ny(e,t){if(e<0)return-ny(-e,t);const r=Math.pow(10,t);if(Math.abs(e*r%1-.5)<Number.EPSILON){const t=Math.floor(e*r);return(t%2==0?t:t+1)/r}return Math.round(e*r)/r}function ay(e){const t=ny(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw ey(e,"Decimal");const r=t.toString();return r.includes(".")?r:`${r}.0`}const oy=/[\x00-\x1f\x7f]+/;function ly(e){const t=(r=e).description||r.toString().slice(7,-1);var r;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw ey(t,"Token");return t}function cy(e){switch(typeof e){case"number":if(!Ru(e))throw ey(e,ry);return Number.isInteger(e)?sy(e):ay(e);case"string":return function(e){if(oy.test(e))throw ey(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return ly(e);case"boolean":return function(e){if("boolean"!=typeof e)throw ey(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${sy(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return iy(e);if(e instanceof ty)return ly(e);default:throw ey(e,ry)}}function dy(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw ey(e,"Key");return e}function uy(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${dy(e)}`:`;${dy(e)}=${cy(t)}`).join("")}function hy(e){return e instanceof Zv?`${cy(e.value)}${uy(e.params)}`:cy(e)}function fy(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw ey(e,"Dict");const r=e instanceof Map?e.entries():Object.entries(e),i=(null==t?void 0:t.whitespace)?" ":"";return Array.from(r).map(([e,t])=>{t instanceof Zv==!1&&(t=new Zv(t));let r=dy(e);var i;return!0===t.value?r+=uy(t.params):(r+="=",Array.isArray(t.value)?r+=`(${(i=t).value.map(hy).join(" ")})${uy(i.params)}`:r+=hy(t)),r}).join(`,${i}`)}function py(e,t){return fy(e,t)}const my="CMCD-Object",gy="CMCD-Request",vy="CMCD-Session",yy="CMCD-Status",by={br:my,ab:my,d:my,ot:my,tb:my,tpb:my,lb:my,tab:my,lab:my,url:my,pb:gy,bl:gy,tbl:gy,dl:gy,ltc:gy,mtp:gy,nor:gy,nrr:gy,rc:gy,sn:gy,sta:gy,su:gy,ttfb:gy,ttfbb:gy,ttlb:gy,cmsdd:gy,cmsds:gy,smrt:gy,df:gy,cs:gy,ts:gy,cid:vy,pr:vy,sf:vy,sid:vy,st:vy,v:vy,msd:vy,bs:yy,bsd:yy,cdn:yy,rtp:yy,bg:yy,pt:yy,ec:yy,e:yy},Ey=gy;function wy(e,t){const r={};if(!e)return r;const i=Object.keys(e),s=t?(n=t,Object.keys(n).reduce((e,t)=>{var r;return null===(r=n[t])||void 0===r||r.forEach(r=>e[r]=t),e},{})):{};var n;return i.reduce((t,r)=>{var i;const n=by[r]||s[r]||Ey;return(null!==(i=t[n])&&void 0!==i?i:t[n]={})[r]=e[r],t},r)}const Sy="event";const Ty=e=>Math.round(e),xy=(e,t)=>Array.isArray(e)?e.map(e=>xy(e,t)):e instanceof Zv&&"string"==typeof e.value?new Zv(xy(e.value,t),e.params):(t.baseUrl&&(e=function(e,t){const r=new URL(e),i=new URL(t);if(r.origin!==i.origin)return e;const s=r.pathname.split("/").slice(1),n=i.pathname.split("/").slice(1,-1);for(;s[0]===n[0];)s.shift(),n.shift();for(;n.length;)n.shift(),s.unshift("..");return s.join("/")+r.search+r.hash}(e,t.baseUrl)),1===t.version?encodeURIComponent(e):e),Ay=e=>100*Ty(e/100),ky={br:Ty,d:Ty,bl:Ay,dl:Ay,mtp:Ay,nor:(e,t)=>{let r=e;return t.version>=2&&(e instanceof Zv&&"string"==typeof e.value?r=new Zv([e]):"string"==typeof e&&(r=[e])),xy(r,t)},rtp:Ay,tb:Ty},Ly="request",Iy="response",Ry=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],Py=["e"],Cy=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function Dy(e){return Cy.test(e)}const _y=["d","dl","nor","ot","rtp","su"];const Oy=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];const My=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function Ny(e){return My.includes(e)||Dy(e)}const Fy={[Iy]:function(e){return Ry.includes(e)||_y.includes(e)||Oy.includes(e)||Dy(e)},[Sy]:function(e){return Ry.includes(e)||Py.includes(e)||Dy(e)},[Ly]:function(e){return Ry.includes(e)||_y.includes(e)||Dy(e)}};function $y(e,t={}){const r={};if(null==e||"object"!=typeof e)return r;const i=t.version||e.v||1,s=t.reportingMode||Ly,n=1===i?Ny:Fy[s];let a=Object.keys(e).filter(n);const o=t.filter;"function"==typeof o&&(a=a.filter(o));const l=s===Iy||s===Sy;l&&!a.includes("ts")&&a.push("ts"),i>1&&!a.includes("v")&&a.push("v");const c=Vu({},ky,t.formatters),d={version:i,reportingMode:s,baseUrl:t.baseUrl};return a.sort().forEach(t=>{let s=e[t];const n=c[t];if("function"==typeof n&&(s=n(s,d)),"v"===t){if(1===i)return;s=i}"pr"==t&&1===s||(l&&"ts"===t&&!Ru(s)&&(s=Date.now()),function(e){return"number"==typeof e?Ru(e):null!=e&&""!==e&&!1!==e}(s)&&(function(e){return["ot","sf","st","e","sta"].includes(e)}(t)&&"string"==typeof s&&(s=new ty(s)),r[t]=s))}),r}function By(e,t,r){return Vu(e,function(e,t={}){const r={};if(!e)return r;const i=wy($y(e,t),null==t?void 0:t.customHeaderMap);return Object.entries(i).reduce((e,[t,r])=>{const i=py(r,{whitespace:!1});return i&&(e[t]=i),e},r)}(t,r))}function Uy(e,t={}){if(!e)return"";const r=function(e,t={}){return e?py($y(e,t),{whitespace:!1}):""}(e,t);return encodeURIComponent(r)}const zy=/CMCD=[^&#]+/;function Gy(e,t,r){const i=function(e,t={}){return e?`CMCD=${Uy(e,t)}`:""}(t,r);if(!i)return e;if(zy.test(e))return e.replace(zy,i);const s=e.includes("?")?"&":"?";return`${e}${s}${i}`}function jy(e,t,r,i){e&&Object.keys(t).forEach(s=>{const n=e.filter(e=>e.groupId===s).map(e=>{const n=Vu({},e);return n.details=void 0,n.attrs=new Fp(n.attrs),n.url=n.attrs.URI=Hy(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),n.groupId=n.attrs["GROUP-ID"]=t[s],n.attrs["PATHWAY-ID"]=i,n});e.push(...n)})}function Hy(e,t,r,i){const{HOST:s,PARAMS:n,[r]:a}=i;let o;t&&(o=null==a?void 0:a[t],o&&(e=o));const l=new self.URL(e);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(e=>{e&&l.searchParams.set(e,n[e])}),l.href}class Vy extends Ku{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=Vy.CDMCleanupPromise?[Vy.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=e=>{const{initDataType:t,initData:r}=e,i=`"${e.type}" event: init data type: "${t}"`;if(this.debug(i),null!==r){if(!this.keyFormatPromise){let e=Object.keys(this.keySystemAccessPromises);e.length||(e=sm(this.config));const t=e.map(im).filter(e=>!!e);this.keyFormatPromise=this.getKeyFormatPromise(t)}this.keyFormatPromise.then(s=>{const n=rm(s);if("sinf"!==t||n!==Qp.FAIRPLAY)return void this.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${n}`);let a;try{const e=Lh(new Uint8Array(r)),t=zh(Wp(JSON.parse(e).sinf));if(!t)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");a=new Uint8Array(t.subarray(8,24))}catch(e){return void this.warn(`${i} Failed to parse sinf: ${e}`)}const o=sh(a),{keyIdToKeySessionPromise:l,mediaKeySessions:c}=this;let d=l[o];for(let e=0;e<c.length;e++){const i=c[e],s=i.decryptdata;if(!s.keyId)continue;const n=sh(s.keyId);if(Gp(a,s.keyId)||-1!==s.uri.replace(/-/g,"").indexOf(o)){if(d=l[n],!d)continue;if(s.pssh)break;delete l[n],s.pssh=new Uint8Array(r),s.keyId=a,d=l[o]=d.then(()=>this.generateRequestWithPreferredKeySession(i,t,r,"encrypted-event-key-match")),d.catch(e=>this.handleError(e));break}}d||this.handleError(new Error(`Key ID ${o} not encountered in playlist. Key-system sessions ${c.length}.`))}).catch(e=>this.handleError(e))}},this.onWaitingForKey=e=>{this.log(`"${e.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Ou.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(Ou.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Ou.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(Ou.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:r}=this.config,i=null==t?void 0:t[e];return i?i.licenseUrl:e===Qp.WIDEVINE&&r?r:void 0}getLicenseServerUrlOrThrow(e){const t=this.getLicenseServerUrl(e);if(void 0===t)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){const{drmSystems:t}=this.config,r=null==t?void 0:t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,r=(e,t,r)=>!!e&&r.indexOf(e)===t,i=t.map(e=>e.audioCodec).filter(r),s=t.map(e=>e.videoCodec).filter(r);return i.length+s.length===0&&s.push("avc1.42e01e"),new Promise((t,r)=>{const n=e=>{const a=e.shift();this.getMediaKeysPromise(a,i,s).then(e=>t({keySystem:a,mediaKeys:e})).catch(t=>{e.length?n(e):r(t instanceof Ky?t:new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};n(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:r}=this.config;if("function"!=typeof r){let e=`Configured requestMediaKeySystemAccess is not a function ${r}`;return null===nm&&"http:"===self.location.protocol&&(e=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(e))}return r(e,t)}getMediaKeysPromise(e,t,r){var i;const s=function(e,t,r,i){let s;switch(e){case Qp.FAIRPLAY:s=["cenc","sinf"];break;case Qp.WIDEVINE:case Qp.PLAYREADY:s=["cenc"];break;case Qp.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${e}`)}return function(e,t,r,i){return[{initDataTypes:e,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(e=>({contentType:`audio/mp4; codecs=${e}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:r.map(e=>({contentType:`video/mp4; codecs=${e}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}(s,t,r,i)}(e,t,r,this.config.drmSystemOptions||{});let n=this.keySystemAccessPromises[e],a=null==(i=n)?void 0:i.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${Pf(s)}`),a=this.requestMediaKeySystemAccess(e,s);const t=n=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),a.then(r=>{this.log(`Access for key-system "${r.keySystem}" obtained`);const i=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);const s=t.mediaKeys=r.createMediaKeys().then(r=>(this.log(`Media-keys created for "${e}"`),t.hasMediaKeys=!0,i.then(t=>t?this.setMediaKeysServerCertificate(r,e,t):r)));return s.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),s})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${sh(e.keyId||[])} keyUri: ${e.uri}`);const i=r.createSession(),s={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(s),s}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const r=this.createMediaKeySessionContext(e),i=Wy(t),s="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,s,t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}updateKeySession(e,t){const r=e.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyId ${sh(e.decryptdata.keyId||[])}\n } (data length: ${t.byteLength})`),r.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>im(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:e,mediaKeys:t})=>this.attemptSetMediaKeys(e,t))}selectKeySystem(e){return new Promise((t,r)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:e})=>{const i=im(e);i?t(i):r(new Error(`Unable to find format for key-system "${e}"`))}).catch(r)})}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){const t=sm(this.config),r=e.map(rm).filter(e=>!!e&&-1!==t.indexOf(e));return this.selectKeySystem(r)}getKeyStatus(e){const{mediaKeySessions:t}=this;for(let r=0;r<t.length;r++){const i=Yy(e,t[r]);if(i)return i}}loadKey(e){const t=e.keyInfo.decryptdata,r=Wy(t),i=this.bannedKeyIds[r];if(i||"internal-error"===this.getKeyStatus(t)){const r=qy(i||"internal-error",t);return this.handleError(r,e.frag),Promise.reject(r)}const s=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);const n=this.keyIdToKeySessionPromise[r];if(!n){const i=this.getKeySystemForKeyPromise(t).then(({keySystem:r,mediaKeys:i})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(r,i).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:r,mediaKeys:i,decryptdata:t}))))).then(e=>{const r=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(e,"cenc",r,"playlist-key")});return i.catch(t=>this.handleError(t,e.frag)),this.keyIdToKeySessionPromise[r]=i,i}return n.catch(r=>{if(r instanceof Ky){const i=Yu({},r.data);"internal-error"===this.getKeyStatus(t)&&(i.decryptdata=t);const s=new Ky(i,r.message);this.handleError(s,e.frag)}}),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof Ky){t&&(e.data.frag=t);const r=e.data.decryptdata;this.error(`${e.message}${r?` (${sh(r.keyId||[])})`:""}`),this.hls.trigger(Ou.ERROR,e.data)}else this.error(e.message),this.hls.trigger(Ou.ERROR,{type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){const t=Wy(e),r=this.keyIdToKeySessionPromise[t];if(!r){const t=rm(e.keyFormat),r=t?[t]:sm(this.config);return this.attemptKeySystemAccess(r)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=sm(this.config)),0===e.length)throw new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${Pf({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();const r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const i=Promise.all(r).then(()=>this.media?this.media.setMediaKeys(t):new Promise((e,r)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return r(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(e).catch(r)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(i),i.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(i),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===r.indexOf(e))})}generateRequestWithPreferredKeySession(e,t,r,i){var s;const n=null==(s=this.config.drmSystems)||null==(s=s[e.keySystem])?void 0:s.generateRequest;if(n)try{const i=n.call(this.hls,t,r,e);if(!i)throw new Error("Invalid response from configured generateRequest filter");t=i.initDataType,r=i.initData?i.initData:null,e.decryptdata.pssh=r?new Uint8Array(r):null}catch(e){if(this.warn(e.message),this.hls&&this.hls.config.debug)throw e}if(null===r)return this.log(`Skipping key-session request for "${i}" (no initData)`),Promise.resolve(e);const a=Wy(e.decryptdata),o=e.decryptdata.uri;this.log(`Generating key-session request for "${i}" keyId: ${a} URI: ${o} (init data type: ${t} length: ${r.byteLength})`);const l=new fg,c=e._onmessage=t=>{const r=e.mediaKeysSession;if(!r)return void l.emit("error",new Error("invalid state"));const{messageType:i,message:s}=t;this.log(`"${i}" message event for session "${r.sessionId}" message size: ${s.byteLength}`),"license-request"===i||"license-renewal"===i?this.renewLicense(e,s).catch(e=>{l.eventNames().length?l.emit("error",e):this.handleError(e)}):"license-release"===i?e.keySystem===Qp.FAIRPLAY&&this.updateKeySession(e,Yp("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${i}"`)},d=(e,t)=>{let r;t.keyStatus=e,e.startsWith("usable")?l.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?r=qy(e,t.decryptdata):"expired"===e?r=new Error(`key expired (keyId: ${a})`):"released"===e?r=new Error("key released"):"status-pending"===e||this.warn(`unhandled key status change "${e}" (keyId: ${a})`),r&&(l.eventNames().length?l.emit("error",r):this.handleError(r))},u=e._onkeystatuseschange=t=>{if(!e.mediaKeysSession)return void l.emit("error",new Error("invalid state"));const r=this.getKeyStatuses(e);if(!Object.keys(r).some(e=>"status-pending"!==r[e]))return;if("expired"===r[a])return this.log(`Expired key ${Pf(r)} in key-session "${e.mediaKeysSession.sessionId}"`),void this.renewKeySession(e);let i=r[a];if(i)d(i,e);else{var s;const t=1e3;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(s=e.keyStatusTimeouts)[a]||(s[a]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;const r=this.getKeyStatus(e.decryptdata);if(r&&"status-pending"!==r)return this.log(`No status for keyId ${a} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${r} from other session.`),d(r,e);this.log(`key status for ${a} in key-session "${e.mediaKeysSession.sessionId}" timed out after ${t}ms`),i="internal-error",d(i,e)},t)),this.log(`No status for keyId ${a} (${Pf(r)}).`)}};Wm(e.mediaKeysSession,"message",c),Wm(e.mediaKeysSession,"keystatuseschange",u);const h=new Promise((e,t)=>{l.on("error",t),l.on("resolved",e)});return e.mediaKeysSession.generateRequest(t,r).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${a} URI: ${o}`)}).catch(t=>{throw new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_NO_SESSION,error:t,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${t}`)}).then(()=>h).catch(t=>(l.removeAllListeners(),this.removeSession(e).then(()=>{throw t}))).then(()=>(l.removeAllListeners(),e))}getKeyStatuses(e){const t={};return e.mediaKeysSession.keyStatuses.forEach((r,i)=>{if("string"==typeof i&&"object"==typeof r){const e=i;i=r,r=e}const s="buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i);if(e.keySystem===Qp.PLAYREADY&&16===s.length){const e=sh(s);t[e]=r,Kp(s)}const n=sh(s);"internal-error"===r&&(this.bannedKeyIds[n]=r),this.log(`key status change "${r}" for keyStatuses keyId: ${n} key-session "${e.mediaKeysSession.sessionId}"`),t[n]=r}),t}fetchServerCertificate(e){const t=this.config,r=new(0,t.loader)(t),i=this.getServerCertificateUrl(e);return i?(this.log(`Fetching server certificate for "${e}"`),new Promise((s,n)=>{const a={responseType:"arraybuffer",url:i},o=t.certLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(e,t,r,i)=>{s(e.data)},onError:(t,r,s,o)=>{n(new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:s,response:Yu({url:a.url,data:void 0},t)},`"${e}" certificate request failed (${i}). Status: ${t.code} (${t.text})`))},onTimeout:(t,r,s)=>{n(new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:s,response:{url:a.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(e,t,r)=>{n(new Error("aborted"))}};r.load(a,l,c)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((i,s)=>{e.setServerCertificate(r).then(s=>{this.log(`setServerCertificate ${s?"success":"not supported by CDM"} (${r.byteLength}) on "${t}"`),i(e)}).catch(e=>{s(new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(t=>this.updateKeySession(e,new Uint8Array(t)).catch(t=>{throw new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:t,fatal:!1},t.message)}))}unpackPlayReadyKeyMessage(e,t){const r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const i=(new DOMParser).parseFromString(r,"application/xml"),s=i.querySelectorAll("HttpHeader");if(s.length>0){let t;for(let r=0,i=s.length;r<i;r++){var n,a;t=s[r];const i=null==(n=t.querySelector("name"))?void 0:n.textContent,o=null==(a=t.querySelector("value"))?void 0:a.textContent;i&&o&&e.setRequestHeader(i,o)}}const o=i.querySelector("Challenge"),l=null==o?void 0:o.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return Yp(atob(l))}setupLicenseXHR(e,t,r,i){const s=this.config.licenseXhrSetup;return s?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return s.call(this.hls,e,t,r,i)}).catch(n=>{if(!r.decryptdata)throw n;return e.open("POST",t,!0),s.call(this.hls,e,t,r,i)}).then(r=>{e.readyState||e.open("POST",t,!0);return{xhr:e,licenseChallenge:r||i}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))}requestLicense(e,t){const r=this.config.keyLoadPolicy.default;return new Promise((i,s)=>{const n=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${n}`);const a=new XMLHttpRequest;a.responseType="arraybuffer",a.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return s(new Error("invalid state"));if(4===a.readyState)if(200===a.status){this._requestLicenseFailureCount=0;let t=a.response;this.log(`License received ${t instanceof ArrayBuffer?t.byteLength:t}`);const r=this.config.licenseResponseCallback;if(r)try{t=r.call(this.hls,a,n,e)}catch(e){this.error(e)}i(t)}else{const o=r.errorRetry,l=o?o.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||a.status>=400&&a.status<500)s(new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:a,response:{url:n,data:void 0,code:a.status,text:a.statusText}},`License Request XHR failed (${n}). Status: ${a.status} (${a.statusText})`));else{const r=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${r} attempts left`),this.requestLicense(e,t).then(i,s)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=a,this.setupLicenseXHR(a,n,e,t).then(({xhr:t,licenseChallenge:r})=>{e.keySystem==Qp.PLAYREADY&&(r=this.unpackPlayReadyKeyMessage(t,r)),t.send(r)}).catch(s)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const r=t.media;this.media=r,Wm(r,"encrypted",this.onMediaEncrypted),Wm(r,"waitingforkey",this.onWaitingForKey);const i=this.mediaResolved;i?i():this.mediaKeys=r.mediaKeys}onMediaDetached(){const e=this.media;e&&(Ym(e,"encrypted",this.onMediaEncrypted),Ym(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};const t=this.mediaResolved;if(t&&t(),!this.mediaKeys&&!this.mediaKeySessions.length)return;const r=this.media,i=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,cm.clearKeyUriToKeyIdMap();const s=i.length;Vy.CDMCleanupPromise=Promise.all(i.map(e=>this.removeSession(e)).concat((null==r||null==(e=r.setMediaKeys(null))?void 0:e.catch(e=>{this.log(`Could not clear media keys: ${e}`),this.hls&&this.hls.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${e}`)})}))||Promise.resolve())).catch(e=>{this.log(`Could not close sessions and clear media keys: ${e}`),this.hls&&this.hls.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${e}`)})}).then(()=>{s&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this._clear()}onManifestLoaded(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){const e=t.reduce((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e),[]);this.log(`Selecting key-system from session-keys ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:r,decryptdata:i}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${sh((null==i?void 0:i.keyId)||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const s=this.mediaKeySessions.indexOf(e);s>-1&&this.mediaKeySessions.splice(s,1);const{keyStatusTimeouts:n}=e;n&&Object.keys(n).forEach(e=>self.clearTimeout(n[e]));const{drmSystemOptions:a}=this.config,o=function(e){var t;return!(!e||"persistent-license"!==e.sessionType&&(null==(t=e.sessionTypes)||!t.some(e=>"persistent-license"===e)))}(a)?new Promise((e,r)=>{self.setTimeout(()=>r(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(e).catch(r)}):Promise.resolve();return o.catch(e=>{this.log(`Could not remove session: ${e}`),this.hls&&this.hls.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${e}`)})}).then(()=>t.close()).catch(e=>{this.log(`Could not close session: ${e}`),this.hls&&this.hls.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}function Wy(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return sh(e.keyId)}function Yy(e,t){return e.keyId&&t.mediaKeysSession.keyStatuses.has(e.keyId)?t.mediaKeysSession.keyStatuses.get(e.keyId):e.matches(t.decryptdata)?t.keyStatus:void 0}Vy.CDMCleanupPromise=void 0;class Ky extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}function qy(e,t){const r="output-restricted"===e,i=r?_u.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:_u.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new Ky({type:Du.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:t},r?"HDCP level output restricted":`key status changed to "${e}"`)}function Xy(e,t){let r;try{r=new Event("addtrack")}catch(e){r=document.createEvent("Event"),r.initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function Qy(e,t){const r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(r){eh.debug(`[texttrack-utils]: ${r}`);try{const r=new self.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,e.addCue(r)}catch(e){eh.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===r&&(e.mode=r)}function Zy(e,t){const r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues)for(let r=e.cues.length;r--;)t&&e.cues[r].removeEventListener("enter",t),e.removeCue(e.cues[r]);"disabled"===r&&(e.mode=r)}function Jy(e,t,r,i){const s=e.mode;if("disabled"===s&&(e.mode="hidden"),e.cues&&e.cues.length>0){const s=function(e,t,r){const i=[],s=function(e,t){if(t<=e[0].startTime)return 0;const r=e.length-1;if(t>e[r].endTime)return-1;let i,s=0,n=r;for(;s<=n;)if(i=Math.floor((n+s)/2),t<e[i].startTime)n=i-1;else{if(!(t>e[i].startTime&&s<r))return i;s=i+1}return e[s].startTime-t<t-e[n].startTime?s:n}(e,t);if(s>-1)for(let n=s,a=e.length;n<a;n++){const s=e[n];if(s.startTime>=t&&s.endTime<=r)i.push(s);else if(s.startTime>r)return i}return i}(e.cues,t,r);for(let t=0;t<s.length;t++)i&&!i(s[t])||e.removeCue(s[t])}"disabled"===s&&(e.mode=s)}function eb(e){const t=[];for(let r=0;r<e.length;r++){const i=e[r];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||t.push(e[r])}return t}function tb(e){let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}const rb=.025;let ib=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function sb(e,t,r){return`${e.identifier}-${r+1}-${tb(t)}`}class nb{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var e;this.appendInPlaceStarted=!1,null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;const r=this.playoutLimit;if(e<=0||isNaN(r))return!1;if(0===r)return!0;return((null==(t=this.assetList[e])?void 0:t.startOffset)||0)>r}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const e=this.dateRange.startTime;if(this.snapOptions.out){const t=this.dateRange.tagAnchor;if(t)return ab(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(0===this.startTime||this.snapOptions.out)return!0;const e=this.dateRange.tagAnchor;if(e){const t=this.dateRange.startTime;return t-ab(t,e)<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=Ru(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){const e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const t=this.resumeAnchor;if(t)return ab(e,t)}return e}get appendInPlace(){return!!this.appendInPlaceStarted||!this.appendInPlaceDisabled&&!(this.cue.once||this.cue.pre||!this.startIsAligned||!(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<rb))}set appendInPlace(e){this.appendInPlaceStarted?this.resetOnResume=!e:this.appendInPlaceDisabled=!e}get timelineStart(){return null!==this._timelineStart?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){const e=this.playoutLimit;let t;return t=null!==this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?ib.Range:ib.Point}get supplementsPrimary(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}get contentMayVary(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||null!==this.assetListResponse}toString(){return`["${(e=this).identifier}" ${e.cue.pre?"<pre>":e.cue.post?"<post>":""}${e.timelineStart.toFixed(2)}-${e.resumeTime.toFixed(2)}]`;var e}}function ab(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<rb)?t.start:t.start+t.duration}function ob(e,t,r){const i=new self.URL(e,r);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function lb(e,t){for(;null!=(r=e.assetList[++t])&&r.error;)var r;return t}function cb(e){const t=e.timelineStart,r=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+r).toFixed(2)}]`}class db{constructor(e,t,r,i){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(Ou.PLAYOUT_LIMIT_REACHED,{})};const s=this.hls=new e(t);this.interstitial=r,this.assetItem=i;const n=()=>{this.hasDetails=!0};s.once(Ou.LEVEL_LOADED,n),s.once(Ou.AUDIO_TRACK_LOADED,n),s.once(Ou.SUBTITLE_TRACK_LOADED,n),s.on(Ou.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t;this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&s.on(Ou.BUFFER_APPENDED,()=>{const e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,s.trigger(Ou.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=ob(t,e.config.primarySessionId||"").href}catch(e){}e.loadSource(t)}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return!1;if(null!=(t=this.hls)&&t.bufferedToEnd)return!0;if(!e)return!1;const r=Math.min(this._bufferedEosTime||1/0,this.duration),i=this.timelineOffset,s=Rp.bufferInfo(e,i,0);return this.getAssetTime(s.end)>=r-.02}reachedPlayout(e){const t=this.interstitial.playoutLimit;return this.startOffset+e>=t}get destroyed(){var e;return!(null!=(e=this.hls)&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return(null==(e=this.hls)?void 0:e.media)||null}get bufferedEnd(){const e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const t=Rp.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){const e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){const e=this.assetItem.duration;if(!e)return 0;const t=this.interstitial.playoutLimit;if(t){const r=t-this.startOffset;if(r>0&&r<e)return r}return e}get remaining(){const e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return(null==(e=this.hls)?void 0:e.config.timelineOffset)||0}set timelineOffset(e){const t=this.timelineOffset;if(e!==t){const r=e-t;if(Math.abs(r)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}getAssetTime(e){const t=this.timelineOffset,r=this.duration;return Math.min(Math.max(0,e-t),r)}removeMediaListeners(){const e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){var e;this.mediaAttached&&(null!=(e=this.hls)&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd))}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),null==(t=this.hls)||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,null==(e=this.hls)||e.detachMedia()}resumeBuffering(){var e;null==(e=this.hls)||e.resumeBuffering()}pauseBuffering(){var e;null==(e=this.hls)||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),(null==(e=this.hls)?void 0:e.transferMedia())||null}resetDetails(){const e=this.hls;if(e&&this.hasDetails){e.stopLoad();const t=e=>delete e.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,r){var i;null==(i=this.hls)||i.on(e,t)}once(e,t,r){var i;null==(i=this.hls)||i.once(e,t)}off(e,t,r){var i;null==(i=this.hls)||i.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${cb(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}class ub extends Ku{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((r,i)=>e<=i.startOffset&&t>i.startOffset?(delete i.error,r+1):r,0):0}get duration(){const e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let r=-1;e.nextEvent?r=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(r=this.findEventIndex(e.previousEvent.identifier)+1);const i=this.items;if(i)for(i[r]||(void 0===t&&(t=e.start),r=this.findItemIndexAtTime(t));r>=0&&null!=(s=i[r])&&s.event;){var s;r--}return r}findItemIndexAtTime(e,t){const r=this.items;if(r)for(let i=0;i<r.length;i++){let s=r[i];if(t&&"primary"!==t&&(s=s[t]),e===s.start||e>s.start&&e<s.end)return i}return-1}findJumpRestrictedIndex(e,t){const r=this.items;if(r)for(let i=e;i<=t&&r[i];i++){const e=r[i].event;if(null!=e&&e.restrictions.jump&&!e.appendInPlace)return i}return-1}findEventIndex(e){const t=this.items;if(t)for(let i=t.length;i--;){var r;if((null==(r=t[i].event)?void 0:r.identifier)===e)return i}return-1}findAssetIndex(e,t){const r=e.assetList,i=r.length;if(i>1)for(let e=0;e<i;e++){const s=r[e];if(!s.error){const r=s.timelineStart;if(t===r||t>r&&(t<r+(s.duration||0)||e===i-1))return e}}return 0}get assetIdAtEnd(){var e;const t=null==(e=this.items)||null==(e=e[this.length-1])?void 0:e.event;if(t){const e=t.assetList,r=e[e.length-1];if(r)return r.identifier}return null}parseInterstitialDateRanges(e,t){const r=e.main.details,{dateRanges:i}=r,s=this.events,n=this.parseDateRanges(i,{url:r.url},t),a=Object.keys(i),o=s?s.filter(e=>!a.includes(e.identifier)):[];n.length&&n.sort((e,t)=>{const r=e.cue.pre,i=e.cue.post,s=t.cue.pre,n=t.cue.post;if(r&&!s)return-1;if(s&&!r)return 1;if(i&&!n)return 1;if(n&&!i)return-1;if(!(r||s||i||n)){const r=e.startTime,i=t.startTime;if(r!==i)return r-i}return e.dateRange.tagOrder-t.dateRange.tagOrder}),this.events=n,o.forEach(e=>{this.removeEvent(e)}),this.updateSchedule(e,o)}updateSchedule(e,t=[],r=!1){const i=this.events||[];if(i.length||t.length||this.length<2){const s=this.items,n=this.parseSchedule(i,e),a=r||t.length||(null==s?void 0:s.length)!==n.length||n.some((e,t)=>Math.abs(e.playout.start-s[t].playout.start)>.005||Math.abs(e.playout.end-s[t].playout.end)>.005);a&&(this.items=n,this.onScheduleUpdate(t,s))}}parseDateRanges(e,t,r){const i=[],s=Object.keys(e);for(let n=0;n<s.length;n++){const a=s[n],o=e[a];if(o.isInterstitial){let e=this.eventMap[a];e?e.setDateRange(o):(e=new nb(o,t),this.eventMap[a]=e,!1===r&&(e.appendInPlace=r)),i.push(e)}}return i}parseSchedule(e,t){const r=[],i=t.main.details,s=i.live?1/0:i.edge;let n=0;if((e=e.filter(e=>!(e.error||e.cue.once&&e.hasPlayed))).length){this.resolveOffsets(e,t);let i=0,o=0;if(e.forEach((t,a)=>{const l=t.cue.pre,c=t.cue.post,d=e[a-1]||null,u=t.appendInPlace,h=c?s:t.startOffset,f=t.duration,p=t.timelineOccupancy===ib.Range?f:0,m=t.resumptionOffset,g=(null==d?void 0:d.startTime)===h,v=h+t.cumulativeDuration;let y=u?v+f:h+m;if(l||!c&&h<=0){const e=o;o+=p,t.timelineStart=v;const i=n;n+=f,r.push({event:t,start:v,end:y,playout:{start:i,end:n},integrated:{start:e,end:o}})}else{if(!(h<=s))return;{if(!g){const s=h-i;if(s>.033){const l=i,c=o;o+=s;const d=n;n+=s;const u={previousEvent:e[a-1]||null,nextEvent:t,start:l,end:l+s,playout:{start:d,end:n},integrated:{start:c,end:o}};r.push(u)}else s>0&&d&&(d.cumulativeDuration+=s,r[r.length-1].end=h)}c&&(y=v),t.timelineStart=v;const s=o;o+=p;const l=n;n+=f,r.push({event:t,start:v,end:y,playout:{start:l,end:n},integrated:{start:s,end:o}})}}const b=t.resumeTime;i=c||b>s?s:b}),i<s){var a;const e=i,t=o,l=s-i;o+=l;const c=n;n+=l,r.push({previousEvent:(null==(a=r[r.length-1])?void 0:a.event)||null,nextEvent:null,start:i,end:e+l,playout:{start:c,end:n},integrated:{start:t,end:o}})}this.setDurations(s,n,o)}else{const e=0;r.push({previousEvent:null,nextEvent:null,start:e,end:s,playout:{start:e,end:s},integrated:{start:e,end:s}}),this.setDurations(s,s,s)}return r}setDurations(e,t,r){this.durations={primary:e,playout:t,integrated:r}}resolveOffsets(e,t){const r=t.main.details,i=r.live?1/0:r.edge;let s=0,n=-1;e.forEach((a,o)=>{const l=a.cue.pre,c=a.cue.post,d=l?0:c?i:a.startTime;this.updateAssetDurations(a);if(n===d?a.cumulativeDuration=s:(s=0,n=d),!c&&a.snapOptions.in&&(a.resumeAnchor=Uf(null,r.fragments,a.startOffset+a.resumptionOffset,0,0)||void 0),a.appendInPlace&&!a.appendInPlaceStarted){this.primaryCanResumeInPlaceAt(a,t)||(a.appendInPlace=!1)}if(!a.appendInPlace&&o+1<e.length){e[o+1].startTime-e[o].resumeTime<.033&&(e[o+1].appendInPlace=!1,e[o+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${a}`))}const u=Ru(a.resumeOffset)?a.resumeOffset:a.duration;s+=u})}primaryCanResumeInPlaceAt(e,t){const r=e.resumeTime,i=e.startTime+e.resumptionOffset;if(Math.abs(r-i)>rb)return this.log(`"${e.identifier}" resumption ${r} not aligned with estimated timeline end ${i}`),!1;return!Object.keys(t).some(i=>{const s=t[i].details,n=s.edge;if(r>=n)return this.log(`"${e.identifier}" resumption ${r} past ${i} playlist end ${n}`),!1;const a=Uf(null,s.fragments,r);if(!a)return this.log(`"${e.identifier}" resumption ${r} does not align with any fragments in ${i} playlist (${s.fragStart}-${s.fragmentEnd})`),!0;const o="audio"===i?.175:0;return!(Math.abs(a.start-r)<rb+o||Math.abs(a.end-r)<rb+o)&&(this.log(`"${e.identifier}" resumption ${r} not aligned with ${i} fragment bounds (${a.start}-${a.end} sn: ${a.sn} cc: ${a.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let r=0,i=!1,s=!1;for(let n=0;n<e.assetList.length;n++){const a=e.assetList[n],o=t+r;a.startOffset=r,a.timelineStart=o,i||(i=null===a.duration),s||(s=!!a.error);r+=a.error?0:a.duration||0}e.duration=i&&!s?Math.max(r,e.duration):r}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function hb(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}class fb{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const r=e.assetListUrl;let i;try{i=ob(r,this.hls.sessionId,e.baseUrl)}catch(t){const i=this.assignAssetListError(e,_u.ASSET_LIST_LOAD_ERROR,t,r);return void this.hls.trigger(Ou.ERROR,i)}t&&"data:"!==i.protocol&&i.searchParams.set("_HLS_start_offset",""+t);const s=this.hls.config,n=new(0,s.loader)(s),a={responseType:"json",url:i.href},o=s.interstitialAssetListLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(t,r,i,s)=>{const n=t.data,a=null==n?void 0:n.ASSETS;if(!Array.isArray(a)){const t=this.assignAssetListError(e,_u.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),i.url,r,s);return void this.hls.trigger(Ou.ERROR,t)}e.assetListResponse=n,this.hls.trigger(Ou.ASSET_LIST_LOADED,{event:e,assetListResponse:n,networkDetails:s})},onError:(t,r,i,s)=>{const n=this.assignAssetListError(e,_u.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${r.url})`),r.url,s,i);this.hls.trigger(Ou.ERROR,n)},onTimeout:(t,r,i)=>{const s=this.assignAssetListError(e,_u.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${r.url})`),r.url,t,i);this.hls.trigger(Ou.ERROR,s)}};return n.load(a,l,c),this.hls.trigger(Ou.ASSET_LIST_LOADING,{event:e}),n}assignAssetListError(e,t,r,i,s,n){return e.error=r,{type:Du.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:r,networkDetails:n,stats:s}}}function pb(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function mb(e,t){return`[${e}] Advancing timeline position to ${t}`}class gb{constructor(e){this.buffered=void 0;const t=(t,r,i)=>{if((r>>>=0)>i-1)throw new DOMException(`Failed to execute '${t}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${i})`);return e[r][t]};this.buffered={get length(){return e.length},end:r=>t("end",r,e.length),start:r=>t("start",r,e.length)}}}const vb={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},yb=e=>String.fromCharCode(vb[e]||e),bb=15,Eb=100,wb={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Sb={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Tb={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},xb={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Ab=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class kb{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const r="function"==typeof t?t():t;eh.log(`${this.time} [${e}] ${r}`)}}}const Lb=function(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t};class Ib{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){const i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class Rb{constructor(){this.uchar=" ",this.penState=new Ib}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class Pb{constructor(e){this.chars=[],this.pos=0,this.currPenState=new Ib,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<Eb;e++)this.chars.push(new Rb);this.logger=e}equals(e){for(let t=0;t<Eb;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Eb;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Eb;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Eb&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Eb)}moveCursor(e){const t=this.pos+e;if(e>1)for(let e=this.pos+1;e<t+1;e++)this.chars[e].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=yb(e);this.pos>=Eb?this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}clearFromPos(e){let t;for(t=e;t<Eb;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let r=0;r<Eb;r++){const i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e);this.chars[this.pos].setPenState(this.currPenState)}}class Cb{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<bb;t++)this.rows.push(new Pb(e));this.logger=e}reset(){for(let e=0;e<bb;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let r=0;r<bb;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<bb;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<bb;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e);this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+Pf(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let e=0;e<bb;e++)this.rows[e].clear();const e=this.currRow+1-this.nrRollUpRows,r=this.lastOutputScreen;if(r){const i=r.rows[e].cueStartTime,s=this.logger.time;if(null!==i&&null!==s&&i<s)for(let i=0;i<this.nrRollUpRows;i++)this.rows[t-this.nrRollUpRows+i+1].copy(r.rows[e+i])}}this.currRow=t;const r=this.rows[this.currRow];if(null!==e.indent){const t=e.indent,i=Math.max(t-1,0);r.setCursor(e.indent),e.color=r.chars[i].penState.foreground}const i={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(i)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+Pf(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let r="",i=-1;for(let r=0;r<bb;r++){const s=this.rows[r].getTextString();s&&(i=r+1,e?t.push("Row "+i+": '"+s+"'"):t.push(s.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}getTextAndFormat(){return this.rows}}class Db{constructor(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Cb(r),this.nonDisplayedMemory=new Cb(r),this.lastOutputScreen=new Cb(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{const r=Math.floor(e/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=i[r]}this.logger.log(2,"MIDROW: "+Pf(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class _b{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;const i=this.logger=new kb;this.channels=[null,new Db(e,t,i),new Db(e+1,r,i)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let e=0;e<t.length;e+=2){const r=127&t[e],i=127&t[e+1];let s=!1,n=null;if(0===r&&0===i)continue;this.logger.log(3,()=>"["+Lb([t[e],t[e+1]])+"] -> ("+Lb([r,i])+")");const a=this.cmdHistory;if(r>=16&&r<=31){if(Mb(r,i,a)){Ob(null,null,a),this.logger.log(3,()=>"Repeated command ("+Lb([r,i])+") is dropped");continue}Ob(r,i,this.cmdHistory),s=this.parseCmd(r,i),s||(s=this.parseMidrow(r,i)),s||(s=this.parsePAC(r,i)),s||(s=this.parseBackgroundAttributes(r,i))}else Ob(null,null,a);if(!s&&(n=this.parseChars(r,i),n)){const e=this.currentChannel;if(e&&e>0){this.channels[e].insertChars(n)}else this.logger.log(2,"No channel found yet. TEXT-MODE?")}s||n||this.logger.log(2,()=>"Couldn't parse cleaned data "+Lb([r,i])+" orig: "+Lb([t[e],t[e+1]]))}}parseCmd(e,t){if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;const r=20===e||21===e||23===e?1:2,i=this.channels[r];return 20===e||21===e||28===e||29===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),this.currentChannel=r,!0}parseMidrow(e,t){let r=0;if((17===e||25===e)&&t>=32&&t<=47){if(r=17===e?1:2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+Lb([e,t])+")"),!0)}return!1}parsePAC(e,t){let r;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;const i=e<=23?1:2;r=t>=64&&t<=95?1===i?wb[e]:Tb[e]:1===i?Sb[e]:xb[e];const s=this.channels[i];return!!s&&(s.setPAC(this.interpretPAC(r,t)),this.currentChannel=i,!0)}interpretPAC(e,t){let r;const i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=!(1&~r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i}parseChars(e,t){let r,i=null,s=null;if(e>=25?(r=2,s=e-8):(r=1,s=e),s>=17&&s<=19){let e;e=17===s?t+80:18===s?t+112:t+144,this.logger.log(2,()=>"Special char '"+yb(e)+"' in channel "+r),i=[e]}else e>=32&&e<=127&&(i=0===t?[e]:[e,t]);return i&&this.logger.log(3,()=>"Char codes = "+Lb(i).join(",")),i}parseBackgroundAttributes(e,t){if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;let r;const i={};16===e||24===e?(r=Math.floor((t-32)/2),i.background=Ab[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));const s=e<=23?1:2;return this.channels[s].setBkgData(i),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}Ob(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const r=this.channels[t];r&&r.cueSplitAtTime(e)}}}function Ob(e,t,r){r.a=e,r.b=t}function Mb(e,t,r){return r.a===e&&r.b===t}var Nb=function(){if(null!=Xp&&Xp.VTTCue)return self.VTTCue;const e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;const r=t.toLowerCase();return!!~e.indexOf(r)&&r}function i(e){return r(t,e)}function s(e,...t){let r=1;for(;r<arguments.length;r++){const t=arguments[r];for(const r in t)e[r]=t[r]}return e}function n(t,n,a){const o=this,l={enumerable:!0};o.hasBeenReset=!1;let c="",d=!1,u=t,h=n,f=a,p=null,m="",g=!0,v="auto",y="start",b=50,E="middle",w=50,S="middle";Object.defineProperty(o,"id",s({},l,{get:function(){return c},set:function(e){c=""+e}})),Object.defineProperty(o,"pauseOnExit",s({},l,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(o,"startTime",s({},l,{get:function(){return u},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");u=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",s({},l,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",s({},l,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",s({},l,{get:function(){return p},set:function(e){p=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",s({},l,{get:function(){return m},set:function(t){const i=function(t){return r(e,t)}(t);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");m=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",s({},l,{get:function(){return g},set:function(e){g=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",s({},l,{get:function(){return v},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",s({},l,{get:function(){return y},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",s({},l,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",s({},l,{get:function(){return E},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",s({},l,{get:function(){return w},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");w=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",s({},l,{get:function(){return S},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");S=t,this.hasBeenReset=!0}})),o.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n}();class Fb{decode(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function $b(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+parseFloat(i||0)}const r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}class Bb{constructor(){this.values=Object.create(null)}set(e,t){this.get(e)||""===t||(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}function Ub(e,t,r,i){const s=i?e.split(i):[e];for(const e in s){if("string"!=typeof s[e])continue;const i=s[e].split(r);if(2!==i.length)continue;t(i[0],i[1])}}const zb=new Nb(0,0,""),Gb="middle"===zb.align?"middle":"center";function jb(e,t,r){const i=e;function s(){const t=$b(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function n(){e=e.replace(/^\s+/,"")}if(n(),t.startTime=s(),n(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.slice(3),n(),t.endTime=s(),n(),function(e,t){const i=new Bb;Ub(e,function(e,t){let s;switch(e){case"region":for(let s=r.length-1;s>=0;s--)if(r[s].id===t){i.set(e,r[s].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":s=t.split(","),i.integer(e,s[0]),i.percent(e,s[0])&&i.set("snapToLines",!1),i.alt(e,s[0],["auto"]),2===s.length&&i.alt("lineAlign",s[1],["start",Gb,"end"]);break;case"position":s=t.split(","),i.percent(e,s[0]),2===s.length&&i.alt("positionAlign",s[1],["start",Gb,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",Gb,"end","left","right"])}},/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");let s=i.get("line","auto");"auto"===s&&-1===zb.line&&(s=-1),t.line=s,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",Gb);let n=i.get("position","auto");"auto"===n&&50===zb.position&&(n="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=n}(e,t)}function Hb(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class Vb{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Fb,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;function r(){let e=t.buffer,r=0;for(e=Hb(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;const i=e.slice(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.slice(r),i}function i(e){Ub(e,function(e,t){},/:/)}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{let e="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;e=r();const i=e.match(/^()?WEBVTT([ \t].*)?$/);if(null==i||!i[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let s=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(s?s=!1:e=r(),t.state){case"HEADER":/:/.test(e)?i(e):e||(t.state="ID");continue;case"NOTE":e||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){t.state="NOTE";break}if(!e)continue;if(t.cue=new Nb(0,0,""),t.state="CUE",-1===e.indexOf("--\x3e")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{jb(e,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const r=-1!==e.indexOf("--\x3e");if(!e||r&&(s=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=e}continue;case"BADCUE":e||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const Wb=/\r\n|\n\r|\n|\r/g,Yb=function(e,t,r=0){return e.slice(r,r+t.length)===t};function Kb(e,t,r){return tb(e.toString())+tb(t.toString())+tb(r)}function qb(e,t,r,i,s,n,a){const o=new Vb,l=ih(new Uint8Array(e)).trim().replace(Wb,"\n").split("\n"),c=[],d=t?function(e,t=1){return yv(e,9e4,1/t)}(t.baseTime,t.timescale):0;let u,h="00:00.000",f=0,p=0,m=!0;o.oncue=function(e){const n=r[i];let a=r.ccOffset;const o=(f-d)/9e4;if(null!=n&&n.new&&(void 0!==p?a=r.ccOffset=n.start:function(e,t,r){let i=e[t],s=e[i.prevCC];if(!s||!s.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;null!=(n=s)&&n.new;){var n;e.ccOffset+=i.start-s.start,i.new=!1,i=s,s=e[i.prevCC]}e.presentationOffset=r}(r,i,o)),o){if(!t)return void(u=new Error("Missing initPTS for VTT MPEGTS"));a=o-r.presentationOffset}const l=e.endTime-e.startTime,h=kv(9e4*(e.startTime+a-p),9e4*s)/9e4;e.startTime=Math.max(h,0),e.endTime=Math.max(h+l,0);const m=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(m)),e.id||(e.id=Kb(e.startTime,e.endTime,m)),e.endTime>0&&c.push(e)},o.onparsingerror=function(e){u=e},o.onflush=function(){u?a(u):n(c)},l.forEach(e=>{if(m){if(Yb(e,"X-TIMESTAMP-MAP=")){m=!1,e.slice(16).split(",").forEach(e=>{Yb(e,"LOCAL:")?h=e.slice(6):Yb(e,"MPEGTS:")&&(f=parseInt(e.slice(7)))});try{p=function(e){let t=parseInt(e.slice(-3));const r=parseInt(e.slice(-6,-4)),i=parseInt(e.slice(-9,-7)),s=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(Ru(t)&&Ru(r)&&Ru(i)&&Ru(s)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=6e4*i,t+=36e5*s,t}(h)/1e3}catch(e){u=e}return}""===e&&(m=!1)}o.parse(e+"\n")}),o.flush()}const Xb="stpp.ttml.im1t",Qb=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Zb=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Jb={left:"start",center:"center",right:"end",start:"start",end:"end"};function eE(e,t,r,i){const s=Dh(new Uint8Array(e),["mdat"]);if(0===s.length)return void i(new Error("Could not parse IMSC1 mdat"));const n=s.map(e=>ih(e)),a=function(e,t,r=1,i=!1){return yv(e,t,1/r,i)}(t.baseTime,1,t.timescale);try{n.forEach(e=>r(function(e,t){const r=(new DOMParser).parseFromString(e,"text/xml"),i=r.getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");const s={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(s).reduce((e,t)=>(e[t]=i.getAttribute(`ttp:${t}`)||s[t],e),{}),a="preserve"!==i.getAttribute("xml:space"),o=rE(tE(i,"styling","style")),l=rE(tE(i,"layout","region")),c=tE(i,"body","[begin]");return[].map.call(c,e=>{const r=iE(e,a);if(!r||!e.hasAttribute("begin"))return null;const i=aE(e.getAttribute("begin"),n),s=aE(e.getAttribute("dur"),n);let c=aE(e.getAttribute("end"),n);if(null===i)throw nE(e);if(null===c){if(null===s)throw nE(e);c=i+s}const d=new Nb(i-t,c-t,r);d.id=Kb(d.startTime,d.endTime,d.text);const u=function(e,t,r){const i="http://www.w3.org/ns/ttml#styling";let s=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;a&&r.hasOwnProperty(a)&&(s=r[a]);return n.reduce((r,n)=>{const a=sE(t,i,n)||sE(e,i,n)||sE(s,i,n);return a&&(r[n]=a),r},{})}(l[e.getAttribute("region")],o[e.getAttribute("style")],o),{textAlign:h}=u;if(h){const e=Jb[h];e&&(d.lineAlign=e),d.align=h}return Vu(d,u),d}).filter(e=>null!==e)}(e,a)))}catch(e){i(e)}}function tE(e,t,r){const i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function rE(e){return e.reduce((e,t)=>{const r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function iE(e,t){return[].slice.call(e.childNodes).reduce((e,r,i)=>{var s;return"br"===r.nodeName&&i?e+"\n":null!=(s=r.childNodes)&&s.length?iE(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function sE(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function nE(e){return new Error(`Could not parse ttml timestamp ${e}`)}function aE(e,t){if(!e)return null;let r=$b(e);return null===r&&(Qb.test(e)?r=function(e,t){const r=Qb.exec(e),i=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/t.frameRate}(e,t):Zb.test(e)&&(r=function(e,t){const r=Zb.exec(e),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),r}class oE{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}function lE(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function cE(e,t){return!!e&&e.kind===lE(t)&&Gv(t,e)}function dE(e,t,r,i){return Math.min(t,i)-Math.max(e,r)}const uE=/\s/,hE={newCue(e,t,r,i){const s=[];let n,a,o,l,c;const d=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(n=i.rows[h],o=!0,l=0,c="",!n.isEmpty()){var u;for(let e=0;e<n.chars.length;e++)uE.test(n.chars[e].uchar)&&o?l++:(c+=n.chars[e].uchar,o=!1);n.cueStartTime=t,t===r&&(r+=1e-4),l>=16?l--:l++;const i=Hb(c.trim()),f=Kb(t,r,i);null!=e&&null!=(u=e.cues)&&u.getCueById(f)||(a=new d(t,r,i),a.id=f,a.line=h+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*l/32)),s.push(a))}return e&&s.length&&(s.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),s.forEach(t=>Qy(e,t))),s}};const fE=/(\d+)-(\d+)\/(\d+)/;class pE{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||mE,this.controller=new self.AbortController,this.stats=new mh}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){const i=this.stats;if(i.loading.start)throw new Error("Loader can only be used once.");i.loading.start=self.performance.now();const s=function(e,t){const r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(Vu({},e.headers))};e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return r}(e,this.controller.signal),n="arraybuffer"===e.responseType,a=n?"byteLength":"length",{maxTimeToFirstByteMs:o,maxLoadTimeMs:l}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),t.timeout=o&&Ru(o)?o:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},t.timeout);(Ov(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(r=>{var s;this.response=this.loader=r;const a=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},l-(a-i.loading.start)),!r.ok){const{status:e,statusText:t}=r;throw new gE(t||"fetch, bad network response",e,r)}i.loading.first=a,i.total=function(e){const t=e.get("Content-Range");if(t){const e=function(e){const t=fE.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(Ru(e))return e}const r=e.get("Content-Length");if(r)return parseInt(r)}(r.headers)||i.total;const o=null==(s=this.callbacks)?void 0:s.onProgress;return o&&Ru(t.highWaterMark)?this.loadProgressively(r,i,e,t.highWaterMark,o):n?r.arrayBuffer():"json"===e.responseType?r.json():r.text()}).then(r=>{var s,n;const o=this.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);const l=r[a];l&&(i.loaded=i.total=l);const c={url:o.url,data:r,code:o.status},d=null==(s=this.callbacks)?void 0:s.onProgress;d&&!Ru(t.highWaterMark)&&d(i,e,r,o),null==(n=this.callbacks)||n.onSuccess(c,i,e,o)}).catch(t=>{var r;if(self.clearTimeout(this.requestTimeout),i.aborted)return;const s=t&&t.code||0,n=t?t.message:null;null==(r=this.callbacks)||r.onError({code:s,text:n},e,t?t.details:null,i)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,i=0,s){const n=new cg,a=e.body.getReader(),o=()=>a.read().then(a=>{if(a.done)return n.dataLength&&s(t,r,n.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const l=a.value,c=l.length;return t.loaded+=c,c<i||n.dataLength?(n.push(l),n.dataLength>=i&&s(t,r,n.flush().buffer,e)):s(t,r,l.buffer,e),o()}).catch(()=>Promise.reject());return o()}}function mE(e,t){return new self.Request(e.url,t)}class gE extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}}const vE=/^age:\s*[\d.]+\s*$/im;class yE{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new mh,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;const s=this.xhrSetup;s?Promise.resolve().then(()=>{if(this.loader===r&&!this.stats.aborted)return s(r,t.url)}).catch(e=>{if(this.loader===r&&!this.stats.aborted)return r.open("GET",t.url,!0),s(r,t.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(e=>{var s;null==(s=this.callbacks)||s.onError({code:r.status,text:e.message},t,r,i)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);const i=t.headers,{maxTimeToFirstByteMs:s,maxLoadTimeMs:n}=r.loadPolicy;if(i)for(const t in i)e.setRequestHeader(t,i[t]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=s&&Ru(s)?s:n,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:r}=this;if(!e||!t)return;const i=t.readyState,s=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),s.timeout!==s.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),s.timeout=s.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const i=t.status,l="text"===t.responseType?t.responseText:null;if(i>=200&&i<300){const s=null!=l?l:t.response;if(null!=s){var n,a;r.loading.end=Math.max(self.performance.now(),r.loading.first);const o="arraybuffer"===t.responseType?s.byteLength:s.length;r.loaded=r.total=o,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first);const l=null==(n=this.callbacks)?void 0:n.onProgress;l&&l(r,e,s,t);const c={url:t.responseURL,data:s,code:i};return void(null==(a=this.callbacks)||a.onSuccess(c,r,e,t))}}const c=s.loadPolicy.errorRetry;var o;if(Xf(c,r.retry,!1,{url:e.url,data:void 0,code:i}))this.retry(c);else eh.error(`${i} while loading ${e.url}`),null==(o=this.callbacks)||o.onError({code:i,text:t.statusText},e,t,r)}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry;if(Xf(e,this.stats.retry,!0))this.retry(e);else{var t;eh.warn(`timeout while loading ${null==(t=this.context)?void 0:t.url}`);const e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:r}=this;this.retryDelay=Kf(e,r.retry),r.retry++,eh.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==t?void 0:t.url}, retrying ${r.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&vE.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const bE=Yu(Yu({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,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,ignorePlaylistParsingErrors:!1,loader:yE,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class extends Ku{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=e=>{var t;const{fragCurrent:r,partCurrent:i,hls:s}=this,{autoLevelEnabled:n,media:a}=s;if(!r||!a)return;const o=performance.now(),l=i?i.stats:r.stats,c=i?i.duration:r.duration,d=o-l.loading.start,u=s.minAutoLevel,h=r.level,f=this._nextAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||h<=u)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!n)return;const p=f>-1&&f!==h,m=!!e||p;if(!m&&(a.paused||!a.playbackRate||!a.readyState))return;const g=s.mainForwardBufferInfo;if(!m&&null===g)return;const v=this.bwEstimator.getEstimateTTFB(),y=Math.abs(a.playbackRate);if(d<=Math.max(v,c/(2*y)*1e3))return;const b=g?g.len/y:0,E=l.loading.first?l.loading.first-l.loading.start:-1,w=l.loaded&&E>-1,S=this.getBwEstimate(),T=s.levels,x=T[h],A=Math.max(l.loaded,Math.round(c*(r.bitrate||x.averageBitrate)/8));let k=w?d-E:d;k<1&&w&&(k=Math.min(d,8*l.loaded/S));const L=w?1e3*l.loaded/k:0,I=v/1e3,R=L?(A-l.loaded)/L:8*A/S+I;if(R<=b)return;const P=L?8*L:S,C=!0===(null==(t=(null==e?void 0:e.details)||this.hls.latestLevelDetails)?void 0:t.live),D=this.hls.config.abrBandWidthUpFactor;let _,O=Number.POSITIVE_INFINITY;for(_=h-1;_>u;_--){const e=T[_].maxBitrate,t=!T[_].details||C;if(O=this.getTimeToLoadFrag(I,P,c*e,t),O<Math.min(b,c+I))break}if(O>=R)return;if(O>10*c)return;w?this.bwEstimator.sample(d-Math.min(v,E),l.loaded):this.bwEstimator.sampleTTFB(d);const M=T[_].maxBitrate;this.getBwEstimate()*D>M&&this.resetEstimator(M);const N=this.findBestLevel(M,u,_,0,b,1,1);N>-1&&(_=N),this.warn(`Fragment ${r.sn}${i?" part "+i.index:""} of level ${h} is loading too slowly;\n Fragment duration: ${r.duration.toFixed(3)}\n Time to underbuffer: ${b.toFixed(3)} s\n Estimated load time for current fragment: ${R.toFixed(3)} s\n Estimated load time for down switch fragment: ${O.toFixed(3)} s\n TTFB estimate: ${0|E} ms\n Current BW estimate: ${Ru(S)?0|S:"Unknown"} bps\n New BW estimate: ${0|this.getBwEstimate()} bps\n Switching to level ${_} @ ${0|M} bps`),s.nextLoadLevel=s.nextAutoLevel=_,this.clearTimer();const F=()=>{if(this.clearTimer(),this.fragCurrent===r&&this.hls.loadLevel===_&&_>0){const e=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${_>0?"and switching down":""}\n Fragment duration: ${r.duration.toFixed(3)} s\n Time to underbuffer: ${e.toFixed(3)} s`),r.abortRequests(),this.fragCurrent=this.partCurrent=null,_>u){let t=this.findBestLevel(this.hls.levels[u].bitrate,u,_,0,e,1,1);-1===t&&(t=u),this.hls.nextLoadLevel=this.hls.nextAutoLevel=t,this.resetEstimator(this.hls.levels[t].bitrate)}}};p||R>2*O?F():this.timer=self.setInterval(F,1e3*O),s.trigger(Ou.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:i,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new ju(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.FRAG_LOADING,this.onFragLoading,this),e.on(Ou.FRAG_LOADED,this.onFragLoaded,this),e.on(Ou.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Ou.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Ou.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(Ou.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.FRAG_LOADING,this.onFragLoading,this),e.off(Ou.FRAG_LOADED,this.onFragLoaded,this),e.off(Ou.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Ou.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Ou.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(Ou.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const r=t.frag;if(!this.ignoreFragment(r)){var i;if(!r.bitrateTest)this.fragCurrent=r,this.partCurrent=null!=(i=t.part)?i:null;this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case _u.BUFFER_ADD_CODEC_ERROR:case _u.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case _u.FRAG_LOAD_TIMEOUT:{const e=t.frag,{fragCurrent:r,partCurrent:i}=this;if(e&&r&&e.sn===r.sn&&e.level===r.level){const t=performance.now(),r=i?i.stats:e.stats,s=t-r.loading.start,n=r.loading.first?r.loading.first-r.loading.start:-1;if(r.loaded&&n>-1){const e=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(s-Math.min(e,n),r.loaded)}else this.bwEstimator.sampleTTFB(s)}break}}}getTimeToLoadFrag(e,t,r,i){return e+r/t+(i?e+this.lastLevelLoadSec:0)}onLevelLoaded(e,t){const r=this.hls.config,{loading:i}=t.stats,s=i.end-i.first;Ru(s)&&(this.lastLevelLoadSec=s/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,{frag:t,part:r}){const i=r?r.stats:t.stats;if(t.type===Bu&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const e=r?r.duration:t.duration,s=this.hls.levels[t.level],n=(s.loaded?s.loaded.bytes:0)+i.loaded,a=(s.loaded?s.loaded.duration:0)+e;s.loaded={bytes:n,duration:a},s.realBitrate=Math.round(8*n/a)}if(t.bitrateTest){const e={stats:i,frag:t,part:r,id:t.type};this.onFragBuffered(Ou.FRAG_BUFFERED,e),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:r,part:i}=t,s=null!=i&&i.stats.loaded?i.stats:r.stats;if(s.aborted)return;if(this.ignoreFragment(r))return;const n=s.parsing.end-s.loading.start-Math.min(s.loading.first-s.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,s.loaded),s.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==Bu||"initSegment"===e.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,r=this.getBwEstimate(),i=this.hls.config.maxStarvationDelay,s=this.findBestLevel(r,t,e,0,i,1,1);if(s>-1)return s;const n=this.hls.firstLevel,a=Math.min(Math.max(n,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${n} clamped to ${a}`),a}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;const i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){const t=this.hls.levels;if(t.length>Math.max(e,i)&&t[e].loadError<=t[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:r}=this;if(r.levels.length<=1)return r.loadLevel;const{maxAutoLevel:i,config:s,minAutoLevel:n}=r,a=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay();let c=s.abrBandWidthFactor,d=s.abrBandWidthUpFactor;if(l){const e=this.findBestLevel(o,n,i,l,0,c,d);if(e>=0)return this.rebufferNotice=-1,e}let u=a?Math.min(a,s.maxStarvationDelay):s.maxStarvationDelay;if(!l){const e=this.bitrateTestDelay;if(e){u=(a?Math.min(a,s.maxLoadingDelay):s.maxLoadingDelay)-e,this.info(`bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*u)} ms`),c=d=1}}const h=this.findBestLevel(o,n,i,l,u,c,d);if(this.rebufferNotice!==h&&(this.rebufferNotice=h,this.info(`${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${h}`)),h>-1)return h;const f=r.levels[n],p=r.loadLevelObj;return p&&(null==f?void 0:f.bitrate)<p.bitrate?n:r.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/r}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,r,i,s,n,a){var o;const l=i+s,c=this.lastLoadedFragLevel,d=-1===c?this.hls.firstLevel:c,{fragCurrent:u,partCurrent:h}=this,{levels:f,allAudioTracks:p,loadLevel:m,config:g}=this.hls;if(1===f.length)return 0;const v=f[d],y=!(null==(o=this.hls.latestLevelDetails)||!o.live),b=-1===m||-1===c;let E,w="SDR",S=(null==v?void 0:v.frameRate)||0;const{audioPreference:T,videoPreference:x}=g,A=this.audioTracksByGroup||(this.audioTracksByGroup=Df(p));let k=-1;if(b){if(-1!==this.firstSelection)return this.firstSelection;const i=this.codecTiers||(this.codecTiers=function(e,t,r,i){return e.slice(r,i+1).reduce((e,r,i)=>{if(!r.codecSet)return e;const s=r.audioGroups;let n=e[r.codecSet];n||(e[r.codecSet]=n={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!s,fragmentError:0}),n.minBitrate=Math.min(n.minBitrate,r.bitrate);const a=Math.min(r.height,r.width);return n.minHeight=Math.min(n.minHeight,a),n.minFramerate=Math.min(n.minFramerate,r.frameRate),n.minIndex=Math.min(n.minIndex,i),n.maxScore=Math.max(n.maxScore,r.score),n.fragmentError+=r.fragmentError,n.videoRanges[r.videoRange]=(n.videoRanges[r.videoRange]||0)+1,s&&s.forEach(e=>{if(!e)return;const r=t.groups[e];r&&(n.hasDefaultAudio=n.hasDefaultAudio||t.hasDefaultAudio?r.hasDefault:r.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(r.channels).forEach(e=>{n.channels[e]=(n.channels[e]||0)+r.channels[e]}))}),e},{})}(f,A,t,r)),s=function(e,t,r,i,s){const n=Object.keys(e),a=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,l=null==s?void 0:s.videoCodec,c=a&&2===parseInt(a);let d=!1,u=!1,h=1/0,f=1/0,p=1/0,m=1/0,g=0,v=[];const{preferHDR:y,allowedVideoRanges:b}=Rf(t,s);for(let t=n.length;t--;){const r=e[n[t]];d||(d=r.channels[2]>0),h=Math.min(h,r.minHeight),f=Math.min(f,r.minFramerate),p=Math.min(p,r.minBitrate),b.filter(e=>r.videoRanges[e]>0).length>0&&(u=!0)}h=Ru(h)?h:0,f=Ru(f)?f:0;const E=Math.max(1080,h),w=Math.max(30,f);p=Ru(p)?p:r,r=Math.max(p,r),u||(t=void 0);const S=n.length>1;return{codecSet:n.reduce((t,i)=>{const s=e[i];if(i===t)return t;if(v=u?b.filter(e=>s.videoRanges[e]>0):[],S){if(s.minBitrate>r)return Cf(i,`min bitrate of ${s.minBitrate} > current estimate of ${r}`),t;if(!s.hasDefaultAudio)return Cf(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!=0)return Cf(i,`audio codec preference "${o}" not found`),t;if(a&&!c){if(!s.channels[a])return Cf(i,`no renditions with ${a} channel sound found (channels options: ${Object.keys(s.channels)})`),t}else if((!o||c)&&d&&0===s.channels[2])return Cf(i,"no renditions with stereo sound found"),t;if(s.minHeight>E)return Cf(i,`min resolution of ${s.minHeight} > maximum of ${E}`),t;if(s.minFramerate>w)return Cf(i,`min framerate of ${s.minFramerate} > maximum of ${w}`),t;if(!v.some(e=>s.videoRanges[e]>0))return Cf(i,`no variants with VIDEO-RANGE of ${Pf(v)} found`),t;if(l&&i.indexOf(l.substring(0,4))%5!=0)return Cf(i,`video codec preference "${l}" not found`),t;if(s.maxScore<g)return Cf(i,`max score of ${s.maxScore} < selected max of ${g}`),t}return t&&(sf(i)>=sf(t)||s.fragmentError>e[t].fragmentError)?t:(m=s.minIndex,g=s.maxScore,i)},void 0),videoRanges:v,preferHDR:y,minFramerate:f,minBitrate:p,minIndex:m}}(i,w,e,T,x),{codecSet:n,videoRanges:a,minFramerate:o,minBitrate:l,minIndex:c,preferHDR:d}=s;k=c,E=n,w=d?a[a.length-1]:a[0],S=o,e=Math.max(e,l),this.log(`picked start tier ${Pf(s)}`)}else E=null==v?void 0:v.codecSet,w=null==v?void 0:v.videoRange;const L=h?h.duration:u?u.duration:0,I=this.bwEstimator.getEstimateTTFB()/1e3,R=[];for(let o=r;o>=t;o--){var P;const t=f[o],u=o>d;if(!t)continue;if(g.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){const r=navigator.mediaCapabilities;"function"==typeof(null==r?void 0:r.decodingInfo)&&gf(t,A,w,S,e,T)?(t.supportedPromise=vf(t,A,r,this.supportedCache),t.supportedPromise.then(e=>{if(!this.hls)return;t.supportedResult=e;const r=this.hls.levels,i=r.indexOf(t);e.error?this.warn(`MediaCapabilities decodingInfo error: "${e.error}" for level ${i} ${Pf(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&this.log(`MediaCapabilities decodingInfo for level ${i} not smooth or powerEfficient: ${Pf(e)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${i} ${Pf(e)}`),i>-1&&r.length>1&&(this.log(`Removing unsupported level ${i}`),this.hls.removeLevel(i),-1===this.hls.loadLevel&&(this.hls.nextLoadLevel=0)))}).catch(e=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${e}`)})):t.supportedResult=pf}if((E&&t.codecSet!==E||w&&t.videoRange!==w||u&&S>t.frameRate||!u&&S>0&&S<t.frameRate||null!=(P=t.supportedResult)&&null!=(P=P.decodingInfoResults)&&P.some(e=>!1===e.smooth))&&(!b||o!==k)){R.push(o);continue}const p=t.details,v=(h?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||L;let x;x=u?a*e:n*e;const C=L&&i>=2*L&&0===s?t.averageBitrate:t.maxBitrate,D=this.getTimeToLoadFrag(I,x,C*v,void 0===p);if(x>=C&&(o===c||0===t.loadError&&0===t.fragmentError)&&(D<=I||!Ru(D)||y&&!this.bitrateTestDelay||D<l)){const e=this.forcedAutoLevel;return o===m||-1!==e&&e===m||(R.length&&this.trace(`Skipped level(s) ${R.join(",")} of ${r} max with CODECS and VIDEO-RANGE:"${f[R[0]].codecs}" ${f[R[0]].videoRange}; not compatible with "${E}" ${w}`),this.info(`switch candidate:${d}->${o} adjustedbw(${Math.round(x)})-bitrate=${Math.round(x-C)} ttfb:${I.toFixed(1)} avgDuration:${v.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${D.toFixed(1)} firstSelection:${b} codecSet:${t.codecSet} videoRange:${t.videoRange} hls.loadLevel:${m}`)),b&&(this.firstSelection=o),o}}return-1}set nextAutoLevel(e){const t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:r}=this.hls;return Math.min(Math.max(e,r),t)}},bufferController:class extends Ku{constructor(e,t){var r;super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=e=>{var t;this.hls&&"open"===(null==(t=this.mediaSource)?void 0:t.readyState)&&this.hls.pauseBuffering()},this._onStartStreaming=e=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=e=>{const{media:t,mediaSource:r}=this;e&&this.log("Media source opened"),t&&r&&(r.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(Ou.MEDIA_ATTACHED,{media:t,mediaSource:r}),null!==this.mediaSource&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:e,_objectUrl:t}=this;e!==t&&this.error(`Media element src was set while attaching MediaSource (${t} > ${e})`)},this.hls=e,this.fragmentTracker=t,this.appendSource=(r=th(e.config.preferManagedMediaSource),"undefined"!=typeof self&&r===self.ManagedMediaSource),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}registerListeners(){const{hls:e}=this;e.on(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ou.BUFFER_RESET,this.onBufferReset,this),e.on(Ou.BUFFER_APPENDING,this.onBufferAppending,this),e.on(Ou.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Ou.BUFFER_EOS,this.onBufferEos,this),e.on(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Ou.FRAG_PARSED,this.onFragParsed,this),e.on(Ou.FRAG_CHANGED,this.onFragChanged,this),e.on(Ou.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ou.BUFFER_RESET,this.onBufferReset,this),e.off(Ou.BUFFER_APPENDING,this.onBufferAppending,this),e.off(Ou.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Ou.BUFFER_EOS,this.onBufferEos,this),e.off(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Ou.FRAG_PARSED,this.onFragParsed,this),e.off(Ou.FRAG_CHANGED,this.onFragChanged,this),e.off(Ou.ERROR,this.onError,this)}transferMedia(){const{media:e,mediaSource:t}=this;if(!e)return null;const r={};if(this.operationQueue){const e=this.isUpdating();e||this.operationQueue.removeBlockers();const t=this.isQueued();(e||t)&&this.warn(`Transfering MediaSource with${t?" operations in queue":""}${e?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const i=this.transferData;return!this.sourceBufferCount&&i&&i.mediaSource===t?Vu(r,i.tracks):this.sourceBuffers.forEach(e=>{const[t]=e;t&&(r[t]=Vu({},this.tracks[t]),this.removeBuffer(t)),e[0]=e[1]=null}),{media:e,mediaSource:t,tracks:r}}initTracks(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){var r;let i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsTotal=i,this.log(`${i} bufferCodec event(s) expected.`),null!=(r=this.transferData)&&r.mediaSource&&this.sourceBufferCount&&i&&this.bufferCreated()}onMediaAttaching(e,t){const r=this.media=t.media;this.transferData=this.overrides=void 0;const i=th(this.appendSource);if(i){const e=!!t.mediaSource;(e||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const s=this.mediaSource=t.mediaSource||new i;if(this.assignMediaSource(s),e)this._objectUrl=r.src,this.attachTransferred();else{const e=this._objectUrl=self.URL.createObjectURL(s);if(this.appendSource)try{r.removeAttribute("src");const t=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||t&&s instanceof t,Yv(r),function(e,t){const r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(r,e),r.load()}catch(t){r.src=e}else r.src=e}r.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(e){var t,r;this.log(`${(null==(t=this.transferData)?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${null==(r=e.constructor)?void 0:r.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}attachTransferred(){const e=this.media,t=this.transferData;if(!t||!e)return;const r=this.tracks,i=t.tracks,s=i?Object.keys(i):null,n=s?s.length:0,a=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(i&&s&&n){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})\nrequired tracks: ${Pf(r,(e,t)=>"initSegment"===e?void 0:t)};\ntransfer tracks: ${Pf(i,(e,t)=>"initSegment"===e?void 0:t)}}`),!rh(i,r)){t.mediaSource=null,t.tracks=void 0;const s=e.currentTime,n=this.details,a=Math.max(s,(null==n?void 0:n.fragments[0].start)||0);return a-s>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${s} -> ${a}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(i)}"->"${Object.keys(r)}") start time: ${a} currentTime: ${s}`),this.onMediaDetaching(Ou.MEDIA_DETACHING,{}),this.onMediaAttaching(Ou.MEDIA_ATTACHING,t),void(e.currentTime=a))}this.transferData=void 0,s.forEach(e=>{const t=e,r=i[t];if(r){const e=r.buffer;if(e){const i=this.fragmentTracker,s=r.id;if(i.hasFragments(s)||i.hasParts(s)){const r=Rp.getBuffered(e);i.detectEvictedFragments(t,r,s,null,!0)}const n=Kv(t),a=[t,e];this.sourceBuffers[n]=a,e.updating&&this.operationQueue&&this.operationQueue.prependBlocker(t),this.trackSourceBuffer(t,r)}}}),a(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),a()}get mediaSourceOpenOrEnded(){var e;const t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}onMediaDetaching(e,t){const r=!!t.transferMedia;this.transferData=this.overrides=void 0;const{media:i,mediaSource:s,_objectUrl:n}=this;if(s){if(this.log("media source "+(r?"transferring":"detaching")),r)this.sourceBuffers.forEach(([e])=>{e&&this.removeBuffer(e)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const e="open"===s.readyState;try{const t=s.sourceBuffers;for(let r=t.length;r--;)e&&t[r].abort(),s.removeSourceBuffer(t[r]);e&&s.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(s.removeEventListener("startstreaming",this._onStartStreaming),s.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}i&&(i.removeEventListener("emptied",this._onMediaEmptied),r||(n&&self.URL.revokeObjectURL(n),this.mediaSrc===n?(i.removeAttribute("src"),this.appendSource&&Yv(i),i.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(Ou.MEDIA_DETACHED,t)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t;const r=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),r)try{var i;null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(r)}catch(t){this.warn(`onBufferReset ${e}`,t)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[Kv(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new jv(this.tracks)}onBufferCodecs(e,t){var r;const i=this.tracks,s=Object.keys(t);this.log(`BUFFER_CODECS: "${s}" (current SB count ${this.sourceBufferCount})`);const n="audiovideo"in t&&(i.audio||i.video)||i.audiovideo&&("audio"in t||"video"in t),a=!n&&this.sourceBufferCount&&this.media&&s.some(e=>!i[e]);n||a?this.warn(`Unsupported transition between "${Object.keys(i)}" and "${s}" SourceBuffers`):(s.forEach(e=>{var r,s;const n=t[e],{id:a,codec:o,levelCodec:l,container:c,metadata:d,supplemental:u}=n;let h=i[e];const f=null==(r=this.transferData)||null==(r=r.tracks)?void 0:r[e],p=null!=f&&f.buffer?f:h,m=(null==p?void 0:p.pendingCodec)||(null==p?void 0:p.codec),g=null==p?void 0:p.levelCodec;h||(h=i[e]={buffer:void 0,listeners:[],codec:o,supplemental:u,container:c,levelCodec:l,metadata:d,id:a});const v=lf(m,g),y=null==v?void 0:v.replace(Hv,"$1");let b=lf(o,l);const E=null==(s=b)?void 0:s.replace(Hv,"$1");b&&v&&y!==E&&("audio"===e.slice(0,5)&&(b=of(b,this.appendSource)),this.log(`switching codec ${m} to ${b}`),b!==(h.pendingCodec||h.codec)&&(h.pendingCodec=b),h.container=c,this.appendChangeType(e,c,b))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&"main"===(null==(r=t.audio)?void 0:r.id)&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{const r=this.tracks[t];return e[t]={id:r.id,container:r.container,codec:r.codec,levelCodec:r.levelCodec},e},{})}appendChangeType(e,t,r){const i=`${t};codecs=${r}`,s={label:`change-type=${i}`,execute:()=>{const s=this.tracks[e];if(s){const n=s.buffer;null!=n&&n.changeType&&(this.log(`changing ${e} sourceBuffer type to ${i}`),n.changeType(i),s.codec=r,s.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};this.append(s,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;const r=e.start,i=r+.05*e.duration;if(!0===(null==(t=this.fragmentTracker.getAppendedFrag(r,Bu))?void 0:t.gap))return;const s={label:"block-audio",execute:()=>{var e;const t=this.tracks.video;(this.lastVideoAppendEnd>i||null!=t&&t.buffer&&Rp.isBuffered(t.buffer,i)||!0===(null==(e=this.fragmentTracker.getAppendedFrag(i,Bu))?void 0:e.gap))&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:s,frag:e},this.append(s,"audio",!0)}unblockAudio(){const{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}onBufferAppending(e,t){const{tracks:r}=this,{data:i,type:s,parent:n,frag:a,part:o,chunkMeta:l,offset:c}=t,d=l.buffering[s],{sn:u,cc:h}=a,f=self.performance.now();d.start=f;const p=a.stats.buffering,m=o?o.stats.buffering:null;0===p.start&&(p.start=f),m&&0===m.start&&(m.start=f);const g=r.audio;let v=!1;"audio"===s&&"audio/mpeg"===(null==g?void 0:g.container)&&(v=!this.lastMpegAudioChunk||1===l.id||this.lastMpegAudioChunk.sn!==l.sn,this.lastMpegAudioChunk=l);const y=r.video,b=null==y?void 0:y.buffer;if(b&&"initSegment"!==u){const e=o||a,t=this.blockedAudioAppend;if("audio"!==s||"main"===n||this.blockedAudioAppend||y.ending||y.ended){if("video"===s){const r=e.end;if(t){const e=t.frag.start;(r>e||r<this.lastVideoAppendEnd||Rp.isBuffered(b,e))&&this.unblockAudio()}this.lastVideoAppendEnd=r}}else{const t=e.start+.05*e.duration,r=b.buffered,i=this.currentOp("video");r.length||i?!i&&!Rp.isBuffered(b,t)&&this.lastVideoAppendEnd<t&&this.blockAudio(e):this.blockAudio(e)}}const E=(o||a).start,w={label:`append-${s}`,execute:()=>{var e;d.executeStart=self.performance.now();const t=null==(e=this.tracks[s])?void 0:e.buffer;t&&(v?this.updateTimestampOffset(t,E,.1,s,u,h):void 0!==c&&Ru(c)&&this.updateTimestampOffset(t,c,1e-6,s,u,h)),this.appendExecutor(i,s)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();d.executeEnd=d.end=e,0===p.first&&(p.first=e),m&&0===m.first&&(m.first=e);const t={};this.sourceBuffers.forEach(([e,r])=>{e&&(t[e]=Rp.getBuffered(r))}),this.appendErrors[s]=0,"audio"===s||"video"===s?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(Ou.BUFFER_APPENDED,{type:s,frag:a,part:o,chunkMeta:l,parent:a.type,timeRanges:t})},onError:e=>{var t;const r={type:Du.MEDIA_ERROR,parent:a.type,details:_u.BUFFER_APPEND_ERROR,sourceBufferName:s,frag:a,part:o,chunkMeta:l,error:e,err:e,fatal:!1},i=null==(t=this.media)?void 0:t.error;if(e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e)r.details=_u.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!i)r.errorAction=ap(!0);else if(e.name===Vv&&0===this.sourceBufferCount)r.errorAction=ap(!0);else{const e=++this.appendErrors[s];this.warn(`Failed ${e}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${s}" sourceBuffer (${i||"no media error"})`),(e>=this.hls.config.appendErrorMaxRetry||i)&&(r.fatal=!0)}this.hls.trigger(Ou.ERROR,r)}};this.log(`queuing "${s}" append sn: ${u}${o?" p: "+o.index:""} of ${a.type===Bu?"level":"track"} ${a.level} cc: ${h}`),this.append(w,s,this.isPending(this.tracks[s]))}getFlushOp(e,t,r){return this.log(`queuing "${e}" remove ${t}-${r}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,r)},onStart:()=>{},onComplete:()=>{this.hls.trigger(Ou.BUFFER_FLUSHED,{type:e})},onError:i=>{this.warn(`Failed to remove ${t}-${r} from "${e}" SourceBuffer`,i)}}}onBufferFlushing(e,t){const{type:r,startOffset:i,endOffset:s}=t;r?this.append(this.getFlushOp(r,i,s),r):this.sourceBuffers.forEach(([e])=>{e&&this.append(this.getFlushOp(e,i,s),e)})}onFragParsed(e,t){const{frag:r,part:i}=t,s=[],n=i?i.elementaryStreams:r.elementaryStreams;n[yh]?s.push("audiovideo"):(n[gh]&&s.push("audio"),n[vh]&&s.push("video"));0===s.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(()=>{const e=self.performance.now();r.stats.buffering.end=e,i&&(i.stats.buffering.end=e);const t=i?i.stats:r.stats;this.hls.trigger(Ou.FRAG_BUFFERED,{frag:r,part:i,stats:t,id:r.type})},s).catch(e=>{this.warn(`Fragment buffered callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){const t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}onBufferEos(e,t){var r;this.sourceBuffers.forEach(([e])=>{if(e){const r=this.tracks[e];t.type&&t.type!==e||(r.ending=!0,r.ended||(r.ended=!0,this.log(`${e} buffer reached EOS`)))}});const i=!1!==(null==(r=this.overrides)?void 0:r.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{var t;return e&&!(null!=(t=this.tracks[e])&&t.ended)})?i?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:e}=this;e&&"open"===e.readyState?(this.log("Calling mediaSource.endOfStream()"),e.endOfStream(),this.hls.trigger(Ou.BUFFERED_TO_END,void 0)):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})):(this.tracksEnded(),this.hls.trigger(Ou.BUFFERED_TO_END,void 0)):"video"===t.type&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(null!==e){const t=this.tracks[e];t&&(t.ending=!1)}})}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{const e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}onError(e,t){if(t.details===_u.BUFFER_APPEND_ERROR&&t.frag){var r;const e=null==(r=t.errorAction)?void 0:r.nextAutoLevel;Ru(e)&&e!==t.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:e,details:t,media:r}=this;if(!r||null===t)return;if(!this.sourceBufferCount)return;const i=e.config,s=r.currentTime,n=t.levelTargetDuration,a=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(Ru(a)&&a>=0){const e=Math.max(a,n),t=Math.floor(s/n)*n-e;this.flushBackBuffer(s,n,t)}const o=i.frontBufferFlushThreshold;if(Ru(o)&&o>0){const e=Math.max(i.maxBufferLength,o),t=Math.max(e,n),r=Math.floor(s/n)*n+t;this.flushFrontBuffer(s,n,r)}}flushBackBuffer(e,t,r){this.sourceBuffers.forEach(([e,t])=>{if(t){const s=Rp.getBuffered(t);if(s.length>0&&r>s.start(0)){var i;this.hls.trigger(Ou.BACK_BUFFER_REACHED,{bufferEnd:r});const t=this.tracks[e];if(null!=(i=this.details)&&i.live)this.hls.trigger(Ou.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(null!=t&&t.ended)return void this.log(`Cannot flush ${e} back buffer while SourceBuffer is in ended state`);this.hls.trigger(Ou.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:e})}}})}flushFrontBuffer(e,t,r){this.sourceBuffers.forEach(([t,i])=>{if(i){const s=Rp.getBuffered(i),n=s.length;if(n<2)return;const a=s.start(n-1),o=s.end(n-1);if(r>a||e>=a&&e<=o)return;this.hls.trigger(Ou.BUFFER_FLUSHING,{startOffset:a,endOffset:1/0,type:t})}})}getDurationAndRange(){var e;const{details:t,mediaSource:r}=this;if(!t||!this.media||"open"!==(null==r?void 0:r.readyState))return null;const i=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&r.setLiveSeekableRange){const e=Math.max(0,t.fragmentStart);return{duration:1/0,start:e,end:Math.max(e,i)}}return{duration:1/0}}const s=null==(e=this.overrides)?void 0:e.duration;if(s)return Ru(s)?{duration:s}:null;const n=this.media.duration;return i>(Ru(r.duration)?r.duration:0)&&i>n||!Ru(n)?{duration:i}:null}updateMediaSource({duration:e,start:t,end:r}){const i=this.mediaSource;this.media&&i&&"open"===i.readyState&&(i.duration!==e&&(Ru(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),i.duration=e),void 0!==t&&void 0!==r&&(this.log(`MediaSource duration is set to ${i.duration}. Setting seekable range to ${t}-${r}.`),i.setLiveSeekableRange(t,r)))}get tracksReady(){const e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:r}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${Pf(r)}`),this.tracksReady){var i;const e=null==(i=this.transferData)?void 0:i.tracks;e&&Object.keys(e).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const e={};this.sourceBuffers.forEach(([t,r])=>{if(t){const i=this.tracks[t];e[t]={buffer:r,container:i.container,codec:i.codec,supplemental:i.supplemental,levelCodec:i.levelCodec,id:i.id,metadata:i.metadata}}}),this.hls.trigger(Ou.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([e])=>{this.executeNext(e)})}else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){const{tracks:e,sourceBuffers:t,mediaSource:r}=this;if(!r)throw new Error("createSourceBuffers called when mediaSource was null");for(const s in e){const n=s,a=e[n];if(this.isPending(a)){const e=this.getTrackCodec(a,n),s=`${a.container};codecs=${e}`;a.codec=e,this.log(`creating sourceBuffer(${s})${this.currentOp(n)?" Queued":""} ${Pf(a)}`);try{const e=r.addSourceBuffer(s),i=Kv(n),o=[n,e];t[i]=o,a.buffer=e}catch(e){var i;return this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(n),null==(i=this.operationQueue)||i.removeBlockers(),delete this.tracks[n],void this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:n,mimeType:s,parent:a.id})}this.trackSourceBuffer(n,a)}}this.bufferCreated()}getTrackCodec(e,t){const r=e.supplemental;let i=e.codec;r&&("video"===t||"audiovideo"===t)&&Jh(r,"video")&&(i=function(e,t){const r=[];if(e){const t=e.split(",");for(let e=0;e<t.length;e++)Zh(t[e],"video")||r.push(t[e])}return t&&r.push(t),r.join(",")}(i,r));const s=lf(i,e.levelCodec);return s?"audio"===t.slice(0,5)?of(s,this.appendSource):s:""}trackSourceBuffer(e,t){const r=t.buffer;if(!r)return;const i=this.getTrackCodec(t,e);this.tracks[e]={buffer:r,codec:i,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(e,t)=>{const r=t.removedRanges;null!=r&&r.length&&this.hls.trigger(Ou.BUFFER_FLUSHED,{type:e})})}get mediaSrc(){var e,t;const r=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==r?void 0:r.src}onSBUpdateStart(e){const t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t;if("closed"===(null==(t=this.mediaSource)?void 0:t.readyState))return void this.resetBuffer(e);const r=this.currentOp(e);r&&(r.onComplete(),this.shiftAndExecuteNext(e))}onSBUpdateError(e,t){var r;const i=new Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(r=this.mediaSource)?void 0:r.readyState}`);this.error(`${i}`,t),this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});const s=this.currentOp(e);s&&s.onError(i)}updateTimestampOffset(e,t,r,i,s,n){const a=t-e.timestampOffset;Math.abs(a)>=r&&(this.log(`Updating ${i} SourceBuffer timestampOffset to ${t} (sn: ${s} cc: ${n})`),e.timestampOffset=t)}removeExecutor(e,t,r){const{media:i,mediaSource:s}=this,n=this.tracks[e],a=null==n?void 0:n.buffer;if(!i||!s||!a)return this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void this.shiftAndExecuteNext(e);const o=Ru(i.duration)?i.duration:1/0,l=Ru(s.duration)?s.duration:1/0,c=Math.max(0,t),d=Math.min(r,o,l);d>c&&(!n.ending||n.ended)?(n.ended=!1,this.log(`Removing [${c},${d}] from the ${e} SourceBuffer`),a.remove(c,d)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const r=this.tracks[t],i=null==r?void 0:r.buffer;if(!i)throw new Wv(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);r.ending=!1,r.ended=!1,i.appendBuffer(e)}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(e=>{this.warn(`SourceBuffer blocked callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(e){this.warn(`Callback run without blocking ${this.operationQueue} ${e}`)}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);const{operationQueue:r}=this,i=t.map(e=>this.appendBlocker(e));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(i).then(t=>{r===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(e=>{var t;const r=null==(t=this.tracks[e])?void 0:t.buffer;r&&!r.updating&&this.shiftAndExecuteNext(e)})}append(e,t,r){this.operationQueue&&this.operationQueue.append(e,t,r)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,r){const i=this.tracks[e];if(!i)return;const s=i.buffer;if(!s)return;const n=r.bind(this,e);i.listeners.push({event:t,listener:n}),s.addEventListener(t,n)}removeBufferListeners(e){const t=this.tracks[e];if(!t)return;const r=t.buffer;r&&(t.listeners.forEach(e=>{r.removeEventListener(e.event,e.listener)}),t.listeners.length=0)}},capLevelController:qv,errorController:class extends Ku{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(Ou.ERROR,this.onError,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(Ou.ERROR,this.onError,this),e.off(Ou.ERROR,this.onErrorOut,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(null==e?void 0:e.type)===Bu?e.level:this.getVariantIndex()}getVariantIndex(){var e;const t=this.hls,r=t.currentLevel;return null!=(e=t.loadLevelObj)&&e.details||-1===r?t.loadLevel:r}variantHasKey(e,t){if(e){var r;if(null!=(r=e.details)&&r.hasKey(t))return!0;const i=e.audioGroups;if(i){return this.hls.allAudioTracks.filter(e=>i.indexOf(e.groupId)>=0).some(e=>{var r;return null==(r=e.details)?void 0:r.hasKey(t)})}}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var r;if(t.fatal)return;const i=this.hls,s=t.context;switch(t.details){case _u.FRAG_LOAD_ERROR:case _u.FRAG_LOAD_TIMEOUT:case _u.KEY_LOAD_ERROR:case _u.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case _u.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=ap());case _u.FRAG_GAP:case _u.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=Jf);case _u.LEVEL_EMPTY_ERROR:case _u.LEVEL_PARSING_ERROR:{var n;const e=t.parent===Bu?t.level:i.loadLevel;t.details===_u.LEVEL_EMPTY_ERROR&&null!=(n=t.context)&&null!=(n=n.levelDetails)&&n.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case _u.LEVEL_LOAD_ERROR:case _u.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==s?void 0:s.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.level)));case _u.AUDIO_TRACK_LOAD_ERROR:case _u.AUDIO_TRACK_LOAD_TIMEOUT:case _u.SUBTITLE_LOAD_ERROR:case _u.SUBTITLE_TRACK_LOAD_TIMEOUT:if(s){const e=i.loadLevelObj;if(e&&(s.type===Fu&&e.hasAudioGroup(s.groupId)||s.type===$u&&e.hasSubtitleGroup(s.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=Jf,void(t.errorAction.flags=ip)}return;case _u.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:Jf,flags:sp});case _u.KEY_SYSTEM_SESSION_UPDATE_FAILED:case _u.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case _u.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:Jf,flags:np});case _u.BUFFER_ADD_CODEC_ERROR:case _u.REMUX_ALLOC_ERROR:case _u.BUFFER_APPEND_ERROR:var a;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(a=t.level)?a:i.loadLevel);return;case _u.INTERNAL_EXCEPTION:case _u.BUFFER_APPENDING_ERROR:case _u.BUFFER_FULL_ERROR:case _u.LEVEL_SWITCH_ERROR:case _u.BUFFER_STALLED_ERROR:case _u.BUFFER_SEEK_OVER_HOLE:case _u.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=ap())}t.type===Du.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=ap())}getPlaylistRetryOrSwitchAction(e,t){const r=Yf(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(Xf(r,i,Hf(e),e.response))return{action:tp,flags:rp,retryConfig:r,retryCount:i};const s=this.getLevelSwitchAction(e,t);return r&&(s.retryConfig=r,s.retryCount=i),s}getFragRetryOrSwitchAction(e){const t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],{fragLoadPolicy:s,keyLoadPolicy:n}=t.config,a=Yf(Vf(e)?n:s,e),o=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(i&&(e.details!==_u.FRAG_GAP&&i.fragmentError++,!Wf(e))){if(Xf(a,o,Hf(e),e.response))return{action:tp,flags:rp,retryConfig:a,retryCount:o}}const l=this.getLevelSwitchAction(e,r);return a&&(l.retryConfig=a,l.retryCount=o),l}getLevelSwitchAction(e,t){const r=this.hls;null==t&&(t=r.loadLevel);const i=this.hls.levels[t];if(i){var s,n;const t=e.details;i.loadError++,t===_u.BUFFER_APPEND_ERROR&&i.fragmentError++;let l=-1;const{levels:c,loadLevel:d,minAutoLevel:u,maxAutoLevel:h}=r;r.autoLevelEnabled||r.config.preserveManualLevelOnError||(r.loadLevel=-1);const f=null==(s=e.frag)?void 0:s.type,p=(f===Uu&&t===_u.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(t===_u.BUFFER_ADD_CODEC_ERROR||t===_u.BUFFER_APPEND_ERROR))&&c.some(({audioCodec:e})=>i.audioCodec!==e),m="video"===e.sourceBufferName&&(t===_u.BUFFER_ADD_CODEC_ERROR||t===_u.BUFFER_APPEND_ERROR)&&c.some(({codecSet:e,audioCodec:t})=>i.codecSet!==e&&i.audioCodec===t),{type:g,groupId:v}=null!=(n=e.context)?n:{};for(let r=c.length;r--;){const s=(r+d)%c.length;if(s!==d&&s>=u&&s<=h&&0===c[s].loadError){var a,o;const r=c[s];if(t===_u.FRAG_GAP&&f===Bu&&e.frag){const t=c[s].details;if(t){const r=Uf(e.frag,t.fragments,e.frag.start);if(null!=r&&r.gap)continue}}else{if(g===Fu&&r.hasAudioGroup(v)||g===$u&&r.hasSubtitleGroup(v))continue;if(f===Uu&&null!=(a=i.audioGroups)&&a.some(e=>r.hasAudioGroup(e))||f===zu&&null!=(o=i.subtitleGroups)&&o.some(e=>r.hasSubtitleGroup(e))||p&&i.audioCodec===r.audioCodec||m&&i.codecSet===r.codecSet||!p&&i.codecSet!==r.codecSet)continue}l=s;break}}if(l>-1&&r.loadLevel!==l)return e.levelRetry=!0,this.playlistError=0,{action:Jf,flags:rp,nextAutoLevel:l}}return{action:Jf,flags:ip}}onErrorOut(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case Zf:break;case Jf:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===_u.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(e){const t=this.hls,r=e.errorAction;if(!r)return;const{flags:i}=r,s=r.nextAutoLevel;switch(i){case rp:this.switchLevel(e,s);break;case sp:{const i=this.getVariantLevelIndex(e.frag),s=t.levels[i],n=null==s?void 0:s.attrs["HDCP-LEVEL"];if(r.hdcpLevel=n,"NONE"===n)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(n){t.maxHdcpLevel=Ef[Ef.indexOf(n)-1],r.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case np:{const t=e.decryptdata;if(t){const i=this.hls.levels,s=i.length;for(let r=s;r--;){var n,a;if(this.variantHasKey(i[r],t))this.log(`Banned key found in level ${r} (${i[r].bitrate}bps) or audio group "${null==(n=i[r].audioGroups)?void 0:n.join(",")}" (${null==(a=e.frag)?void 0:a.type} fragment) ${sh(t.keyId||[])}`),i[r].fragmentError++,i[r].loadError++,this.log(`Removing level ${r} with key error (${e.error})`),this.hls.removeLevel(r)}const o=e.frag;if(this.hls.levels.length<s)r.resolved=!0;else if(o&&o.type!==Bu){const e=o.decryptdata;e&&!t.matches(e)&&(r.resolved=!0)}}break}}r.resolved||this.switchLevel(e,s)}switchLevel(e,t){if(void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===_u.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName)){const t=hf(e.mimeType),r=this.hls.levels;for(let i=r.length;i--;)r[i][`${e.sourceBufferName}Codec`]===t&&(this.log(`Removing level ${i} for ${e.details} ("${t}" not supported)`),this.hls.removeLevel(i))}}},fpsController:class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const r=this.hls.config;if(r.capLevelOnFPSDrop){const e=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=e,e&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,r){const i=performance.now();if(t){if(this.lastTime){const e=i-this.lastTime,s=r-this.lastDroppedFrames,n=t-this.lastDecodedFrames,a=1e3*s/e,o=this.hls;if(o.trigger(Ou.FPS_DROP,{currentDropped:s,currentDecoded:n,totalDroppedFrames:r}),a>0&&s>o.config.fpsDroppedMonitoringThreshold*n){let e=o.currentLevel;o.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===o.autoLevelCapping||o.autoLevelCapping>=e)&&(e-=1,o.trigger(Ou.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:o.currentLevel}),o.autoLevelCapping=e,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:nm,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,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}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,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:hE,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends og{constructor(e,t,r){super(e,t,r,"subtitle-stream-controller",zu),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Ou.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Ou.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Ou.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Ou.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Ou.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Ou.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Ou.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Ou.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=Xm,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:r,success:i}=t;if(this.fragContextChanged(r)||(Eh(r)&&(this.fragPrevious=r),this.state=Xm),!i)return;const s=this.tracksBuffered[this.currentTrackId];if(!s)return;let n;const a=r.start;for(let e=0;e<s.length;e++)if(a>=s[e].start&&a<=s[e].end){n=s[e];break}const o=r.start+r.duration;n?n.end=o:(n={start:a,end:o},s.push(n)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null),this.media&&this.tick()}onBufferFlushing(e,t){const{startOffset:r,endOffset:i}=t;if(0===r&&i!==Number.POSITIVE_INFINITY){const e=i-1;if(e<=0)return;t.endOffsetSubtitles=Math.max(0,e),this.tracksBuffered.forEach(t=>{for(let r=0;r<t.length;)if(t[r].end<=e)t.shift();else{if(!(t[r].start<e))break;t[r].start=e,r++}}),this.fragmentTracker.removeFragmentsInRange(r,e,zu)}}onError(e,t){const r=t.frag;(null==r?void 0:r.type)===zu&&(t.details===_u.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==qm&&(this.state=Xm))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){this.levels&&Uv(this.levels,t)?this.levels=t.map(e=>new Lf(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{const t=new Lf(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,zu),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(e,t){var r;if(this.currentTrackId=t.id,null==(r=this.levels)||!r.length||-1===this.currentTrackId)return void this.clearInterval();const i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.state!==qm&&this.setInterval(500)}onSubtitleTrackLoaded(e,t){var r;const{currentTrackId:i,levels:s}=this,{details:n,id:a}=t;if(!s)return void this.warn(`Subtitle tracks were reset while loading level ${a}`);const o=s[a];if(a>=s.length||!o)return;this.log(`Subtitle track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(n.live||null!=(r=o.details)&&r.live){if(n.deltaUpdateFailed)return;const e=this.mainDetails;if(!e)return void(this.startFragRequested=!1);const t=e.fragments[0];var c;if(o.details)l=this.alignPlaylists(n,o.details,null==(c=this.levelLastLoaded)?void 0:c.details),0===l&&t&&(l=t.start,_m(n,l));else n.hasProgramDateTime&&e.hasProgramDateTime?(Vm(n,e),l=n.fragmentStart):t&&(l=t.start,_m(n,l));e&&!this.startFragRequested&&this.setStartPosition(e,l)}if(o.details=n,this.levelLastLoaded=o,a===i&&(this.hls.trigger(Ou.SUBTITLE_TRACK_UPDATED,{details:n,id:a,groupId:t.groupId}),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===Xm)){Uf(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)}}_handleFragmentLoadComplete(e){const{frag:t,payload:r}=e,i=t.decryptdata,s=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&null!=i&&i.key&&i.iv&&Hp(i.method)){const e=performance.now();this.decrypter.decrypt(new Uint8Array(r),i.key.buffer,i.iv.buffer,Vp(i.method)).catch(e=>{throw s.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(r=>{const i=performance.now();s.trigger(Ou.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:e,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=Xm})}}doTick(){if(this.media){if(this.state===Xm){const{currentTrackId:e,levels:t}=this,r=null==t?void 0:t[e];if(!r||!t.length||!r.details)return;if(this.waitForLive(r))return;const{config:i}=this,s=this.getLoadPosition(),n=Rp.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],s,i.maxBufferHole),{end:a,len:o}=n,l=r.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;const c=l.fragments,d=c.length,u=l.edge;let h=null;const f=this.fragPrevious;if(a<u){const e=i.maxFragLookUpTolerance,t=a>u-e?0:e;h=Uf(f,c,Math.max(c[0].start,a),t),!h&&f&&f.start<c[0].start&&(h=c[0])}else h=c[d-1];if(h=this.filterReplacedPrimary(h,r.details),!h)return;const p=c[h.sn-l.startSN-1];if(p&&p.cc===h.cc&&this.fragmentTracker.getState(p)===op&&(h=p),this.fragmentTracker.getState(h)===op){const e=this.mapToInitFragWhenRequired(h);e&&this.loadFragment(e,r,a)}}}else this.state=Xm}loadFragment(e,t,r){Eh(e)?super.loadFragment(e,t,r):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new gb(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends Bv{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=null;const t=eb(this.media.textTracks);for(let r=0;r<t.length;r++)if("hidden"===t[r].mode)e=t[r];else if("showing"===t[r].mode){e=t[r];break}const r=this.findTrackForTextTrack(e);this.subtitleTrack!==r&&this.setSubtitleTrack(r)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ou.LEVEL_LOADING,this.onLevelLoading,this),e.on(Ou.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Ou.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Ou.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ou.LEVEL_LOADING,this.onLevelLoading,this),e.off(Ou.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Ou.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Ou.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(e,t){const r=this.media;if(!r)return;const i=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||r.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,i)return;eb(r.textTracks).forEach(e=>{Zy(e)})}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:r,groupId:i,details:s}=t,n=this.tracksInGroup[r];if(!n||n.groupId!==i)return void this.warn(`Subtitle track with id:${r} and group:${i} not found in active group ${null==n?void 0:n.groupId}`);const a=n.details;n.details=t.details,this.log(`Subtitle track ${r} "${n.name}" lang:${n.lang} group:${i} loaded [${s.startSN}-${s.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.subtitleGroups||null,i=this.groupIds;let s=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&r.some(e=>-1===(null==i?void 0:i.indexOf(e)))){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter(e=>!r||-1!==r.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>{e.id=t});else if(!s&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.subtitlePreference;if(!s&&t){this.selectDefaultTrack=!1;const r=Of(t,e);if(r>-1)s=e[r];else{const e=Of(t,this.tracks);s=this.tracks[e]}}let i=this.findTrackId(s);-1===i&&s&&(i=this.findTrackId(null));const n={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${null==r?void 0:r.join(",")}" group-id`),this.hls.trigger(Ou.SUBTITLE_TRACKS_UPDATED,n),-1!==i&&-1===this.trackId&&this.setSubtitleTrack(i)}}findTrackId(e){const t=this.tracksInGroup,r=this.selectDefaultTrack;for(let i=0;i<t.length;i++){const s=t[i];if((!r||s.default)&&(r||e)&&(!e||Mf(s,e)))return i}if(e){for(let r=0;r<t.length;r++){const i=t[r];if(zv(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(zv(e.attrs,i.attrs,["LANGUAGE"]))return r}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){if(Gv(t[r],e))return r}}return-1}onError(e,t){!t.fatal&&t.context&&(t.context.type!==$u||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const r=this.currentTrack;if(r&&Mf(e,r))return r;const i=Of(e,this.tracksInGroup);if(i>-1){const e=this.tracksInGroup[i];return this.setSubtitleTrack(i),e}if(r)return null;{const r=Of(e,t);if(r>-1)return t[r]}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const r=e.id,i=e.groupId,s=this.getUrlWithDirectives(e.url,t),n=e.details,a=null==n?void 0:n.age;this.log(`Loading subtitle ${r} "${e.name}" lang:${e.lang} group:${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${a&&n.live?" age "+a.toFixed(1)+(n.type&&" "+n.type||""):""} ${s}`),this.hls.trigger(Ou.SUBTITLE_TRACK_LOADING,{url:s,id:r,groupId:i,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=eb(e.textTracks),r=this.currentTrack;let i;if(r&&(i=t.filter(e=>Gv(r,e))[0],i||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(t).forEach(e=>{"disabled"!==e.mode&&e!==i&&(e.mode="disabled")}),i){const e=this.subtitleDisplay?"showing":"hidden";i.mode!==e&&(i.mode=e)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=e);if(e<-1||e>=t.length||!Ru(e))return void this.warn(`Invalid subtitle track id: ${e}`);this.selectDefaultTrack=!1;const r=this.currentTrack,i=t[e]||null;if(this.trackId=e,this.currentTrack=i,this.toggleTrackModes(),!i)return void this.hls.trigger(Ou.SUBTITLE_TRACK_SWITCH,{id:e});const s=!!i.details&&!i.details.live;if(e===this.trackId&&i===r&&s)return;this.log(`Switching to subtitle-track ${e}`+(i?` "${i.name}" lang:${i.lang} group:${i.groupId}`:""));const{id:n,groupId:a="",name:o,type:l,url:c}=i;this.hls.trigger(Ou.SUBTITLE_TRACK_SWITCH,{id:n,groupId:a,name:o,type:l,url:c});const d=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(d)}},timelineController:class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Ou.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Ou.FRAG_LOADING,this.onFragLoading,this),e.on(Ou.FRAG_LOADED,this.onFragLoaded,this),e.on(Ou.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(Ou.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(Ou.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Ou.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Ou.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Ou.FRAG_LOADING,this.onFragLoading,this),e.off(Ou.FRAG_LOADED,this.onFragLoaded,this),e.off(Ou.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(Ou.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(Ou.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Ou.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new oE(this,"textTrack1"),t=new oE(this,"textTrack2"),r=new oE(this,"textTrack3"),i=new oE(this,"textTrack4");this.cea608Parser1=new _b(1,e,t),this.cea608Parser2=new _b(3,r,i)}addCues(e,t,r,i,s){let n=!1;for(let e=s.length;e--;){const i=s[e],a=dE(i[0],i[1],t,r);if(a>=0&&(i[0]=Math.min(i[0],t),i[1]=Math.max(i[1],r),n=!0,a/(r-t)>.5))return}if(n||s.push([t,r]),this.config.renderTextTracksNatively){const s=this.captionsTracks[e];this.Cues.newCue(s,t,r,i)}else{const s=this.Cues.newCue(null,t,r,i);this.hls.trigger(Ou.CUES_PARSED,{type:"captions",cues:s,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:s,trackId:n}){const{unparsedVttFrags:a}=this;r===Bu&&(this.initPTS[t.cc]={baseTime:i,timescale:s,trackId:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(Ou.FRAG_LOADED,e):this.hls.trigger(Ou.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,t){const{media:r}=this;if(r)for(let i=0;i<r.textTracks.length;i++){const s=r.textTracks[i];if(cE(s,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return s}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:r,media:i}=this,{label:s,languageCode:n}=t[e],a=this.getExistingTrack(s,n);if(a)r[e]=a,Zy(r[e]),Xy(r[e],i);else{const t=this.createTextTrack("captions",s,n);t&&(t[e]=!0,r[e]=t)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(Ou.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}createTextTrack(e,t,r){const i=this.media;if(i)return i.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}onMediaDetaching(e,t){const r=!!t.transferMedia;if(this.media=null,r)return;const{captionsTracks:i}=this;Object.keys(i).forEach(e=>{Zy(i[e]),delete i[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,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())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let e=0;e<t.length;e++)Zy(t[e])}onSubtitleTracksUpdated(e,t){const r=t.subtitleTracks||[],i=r.some(e=>e.textCodec===Xb);if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(Uv(this.tracks,r))return void(this.tracks=r);if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const e=this.media,t=e?eb(e.textTracks):null;if(this.tracks.forEach((e,r)=>{let i;if(t){let r=null;for(let i=0;i<t.length;i++)if(t[i]&&cE(t[i],e)){r=t[i],t[i]=null;break}r&&(i=r)}if(i)Zy(i);else{const t=lE(e);i=this.createTextTrack(t,e.name,e.lang),i&&(i.mode="disabled")}i&&this.textTracks.push(i)}),null!=t&&t.length){const e=t.filter(e=>null!==e).map(e=>e.label);e.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${e.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const e=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(Ou.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{const t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(!t)return;const r=`textTrack${t[1]}`,i=this.captionsProperties[r];i&&(i.label=e.name,e.lang&&(i.languageCode=e.lang),i.media=e)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===Bu){var r,i;const{cea608Parser1:e,cea608Parser2:s,lastSn:n}=this,{cc:a,sn:o}=t.frag,l=null!=(r=null==(i=t.part)?void 0:i.index)?r:-1;e&&s&&(o!==n+1||o===n&&l!==this.lastPartIndex+1||a!==this.lastCc)&&(e.reset(),s.reset()),this.lastCc=a,this.lastSn=o,this.lastPartIndex=l}}onFragLoaded(e,t){const{frag:r,payload:i}=t;if(r.type===zu)if(i.byteLength){const e=r.decryptdata,s="stats"in t;if(null==e||!e.encrypted||s){const e=this.tracks[r.level],s=this.vttCCs;s[r.cc]||(s[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),e&&e.textCodec===Xb?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(Ou.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;eE(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),r.trigger(Ou.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{r.logger.log(`Failed to parse IMSC1: ${t}`),r.trigger(Ou.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}_parseVTTs(e){var t;const{frag:r,payload:i}=e,{initPTS:s,unparsedVttFrags:n}=this,a=s.length-1;if(!s[r.cc]&&-1===a)return void n.push(e);const o=this.hls;qb(null!=(t=r.initSegment)&&t.data?Gh(r.initSegment.data,new Uint8Array(i)).buffer:i,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,e=>{this._appendCues(e,r.level),o.trigger(Ou.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},t=>{const s="Missing initPTS for VTT MPEGTS"===t.message;s?n.push(e):this._fallbackToIMSC1(r,i),o.logger.log(`Failed to parse VTT cue: ${t}`),s&&a>r.cc||o.trigger(Ou.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:t})})}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||eE(t,this.initPTS[e.cc],()=>{r.textCodec=Xb,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){const r=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];if(!r||"disabled"===r.mode)return;e.forEach(e=>Qy(r,e))}else{const i=this.tracks[t];if(!i)return;const s=i.default?"default":"subtitles"+t;r.trigger(Ou.CUES_PARSED,{type:"subtitles",cues:e,track:s})}}onFragDecrypted(e,t){const{frag:r}=t;r.type===zu&&this.onFragLoaded(Ou.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:r,samples:i}=t;if(r.type!==Bu||"NONE"!==this.closedCaptionsForLevel(r))for(let e=0;e<i.length;e++){const t=i[e].bytes;if(t){this.cea608Parser1||this.initCea608Parsers();const r=this.extractCea608Data(t);this.cea608Parser1.addData(i[e].pts,r[0]),this.cea608Parser2.addData(i[e].pts,r[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:i,type:s}){const{media:n}=this;if(n&&!(n.currentTime<r)){if(!s||"video"===s){const{captionsTracks:e}=this;Object.keys(e).forEach(i=>Jy(e[i],t,r))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==i){const{textTracks:e}=this;Object.keys(e).forEach(r=>Jy(e[r],t,i))}}}extractCea608Data(e){const t=[[],[]],r=31&e[0];let i=2;for(let s=0;s<r;s++){const r=e[i++],s=127&e[i++],n=127&e[i++];if(0===s&&0===n)continue;if(!!(4&r)){const e=3&r;0!==e&&1!==e||(t[e].push(s),t[e].push(n))}}return t}},audioStreamController:class extends og{constructor(e,t,r){super(e,t,r,"audio-stream-controller",Uu),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Ou.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(Ou.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Ou.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Ou.BUFFER_RESET,this.onBufferReset,this),e.on(Ou.BUFFER_CREATED,this.onBufferCreated,this),e.on(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Ou.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Ou.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Ou.FRAG_LOADING,this.onFragLoading,this),e.on(Ou.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Ou.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(Ou.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Ou.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Ou.BUFFER_RESET,this.onBufferReset,this),e.off(Ou.BUFFER_CREATED,this.onBufferCreated,this),e.off(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Ou.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Ou.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Ou.FRAG_LOADING,this.onFragLoading,this),e.off(Ou.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:s,trackId:n}){if(r===Bu){const e=t.cc,r=this.fragCurrent;if(this.initPTS[e]={baseTime:i,timescale:s,trackId:n},this.log(`InitPTS for cc: ${e} found from main: ${i/s} (${i}/${s}) trackId: ${n}`),this.mainAnchor=t,this.state===ng){const r=this.waitingData;(!r&&!this.loadingParts||r&&r.frag.cc!==e)&&this.syncWithAnchor(t,null==r?void 0:r.frag)}else!this.hls.hasEnoughToStart&&r&&r.cc!==e?(r.abortRequests(),this.syncWithAnchor(t,r)):this.state===Xm&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var r;const i=(null==(r=this.mainFragLoading)?void 0:r.frag)||null;if(t&&(null==i?void 0:i.cc)===t.cc)return;const s=(i||e).cc,n=jf(this.getLevelDetails(),s,this.getLoadPosition());n&&(this.log(`Syncing with main frag at ${n.start} cc ${n.cc}`),this.startFragRequested=!1,this.nextLoadPosition=n.start,this.resetLoadingState(),this.state===Xm&&this.doTickIdle())}startLoad(e,t){if(!this.levels)return this.startPosition=e,void(this.state=qm);const r=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),r>0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${r.toFixed(3)}`),e=r,this.state=Xm):this.state=eg,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case Xm:this.doTickIdle();break;case eg:{const{levels:e,trackId:t}=this,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&!this.waitForLive(r)){if(this.waitForCdnTuneIn(i))break;this.state=ng}break}case Jm:this.checkRetryDate();break;case ng:{const e=this.waitingData;if(e){const{frag:t,part:r,cache:i,complete:s}=e,n=this.mainAnchor;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.state=Zm;const e={frag:t,part:r,payload:i.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(e),s&&super._handleFragmentLoadComplete(e)}else n&&n.cc!==e.frag.cc&&this.syncWithAnchor(n,e.frag)}else this.state=Xm}}this.onTickEnd()}resetLoadingState(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:e}=this;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){var e;const{hls:t,levels:r,media:i,trackId:s}=this,n=t.config;if(!this.buffering||!i&&!this.primaryPrefetch&&(this.startFragRequested||!n.startFragPrefetch)||null==r||!r[s])return;const a=r[s],o=a.details;if(!o||this.waitForLive(a)||this.waitForCdnTuneIn(o))return this.state=eg,void(this.startFragRequested=!1);const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,gh,Uu));const c=this.getFwdBufferInfo(l,Uu);if(null===c)return;if(!this.switchingTrack&&this._streamEnded(c,o))return t.trigger(Ou.BUFFER_EOS,{type:"audio"}),void(this.state=ig);const d=c.len,u=t.maxBufferLength,h=o.fragments,f=h[0].start,p=this.getLoadPosition(),m=this.flushing?p:c.end;if(this.switchingTrack&&i){const e=p;o.PTSKnown&&e<f&&(c.end>f||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=f+.05)}if(d>=u&&!this.switchingTrack&&m<h[h.length-1].start)return;let g=this.getNextFragment(m,o);if(g&&this.isLoopLoading(g,m)&&(g=this.getNextFragmentLoopLoading(g,o,c,Bu,u)),!g)return void(this.bufferFlushed=!0);let v=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&v&&Eh(g)&&!g.endList&&(!o.live||!this.loadingParts&&m<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(v)===dp&&(this.mainFragLoading=v=null),v&&Eh(v))){if(g.start>v.end){const e=this.fragmentTracker.getFragAtPos(m,Bu);e&&e.end>v.end&&(v=e,this.mainFragLoading={frag:e,targetBufferTime:null})}if(g.start>v.end)return}this.loadFragment(g,a,m)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new Lf(e))}onAudioTrackSwitching(e,t){const r=!!t.url;this.trackId=t.id;const{fragCurrent:i}=this;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),r?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==qm&&(this.setInterval(100),this.state=Xm,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;const r=this.cachedTrackLoadedData;r&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(Ou.AUDIO_TRACK_LOADED,r))}onAudioTrackLoaded(e,t){var r;const{levels:i}=this,{details:s,id:n,groupId:a,track:o}=t;if(!i)return void this.warn(`Audio tracks reset while loading track ${n} "${o.name}" of "${a}"`);const l=this.mainDetails;if(!l||s.endCC>l.endCC||l.expired)return this.cachedTrackLoadedData=t,void(this.state!==qm&&(this.state=eg));this.cachedTrackLoadedData=null,this.log(`Audio track ${n} "${o.name}" of "${a}" loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""},duration:${s.totalduration}`);const c=i[n];let d=0;if(s.live||null!=(r=c.details)&&r.live){if(this.checkLiveUpdate(s),s.deltaUpdateFailed)return;var u;if(c.details)d=this.alignPlaylists(s,c.details,null==(u=this.levelLastLoaded)?void 0:u.details);s.alignedSliding||(Hm(s,l),s.alignedSliding||Vm(s,l),d=s.fragmentStart)}c.details=s,this.levelLastLoaded=c,this.startFragRequested||this.setStartPosition(l,d),this.hls.trigger(Ou.AUDIO_TRACK_UPDATED,{details:s,id:n,groupId:t.groupId}),this.state!==eg||this.waitForCdnTuneIn(s)||(this.state=Xm),this.tick()}_handleFragmentLoadProgress(e){var t;const r=e.frag,{part:i,payload:s}=e,{config:n,trackId:a,levels:o}=this;if(!o)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);const l=o[a];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const c=l.details;if(!c)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);const d=n.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let u=this.transmuxer;u||(u=this.transmuxer=new $v(this.hls,Uu,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const h=this.initPTS[r.cc],f=null==(t=r.initSegment)?void 0:t.data;if(void 0!==h){const e=!1,t=i?i.index:-1,n=-1!==t,a=new Lp(r.level,r.sn,r.stats.chunkCount,s.byteLength,t,n);u.push(s,f,d,"",r,i,c.totalduration,e,a,h)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${c.startSN} ,${c.endSN}],track ${a}`);const{cache:e}=this.waitingData=this.waitingData||{frag:r,part:i,cache:new cg,complete:!1};e.push(new Uint8Array(s)),this.state!==qm&&(this.state=ng)}}_handleFragmentLoadComplete(e){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;const r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===Bu&&Eh(t.frag)&&(this.mainFragLoading=t,this.state===Xm&&this.tick())}onFragBuffered(e,t){const{frag:r,part:i}=t;if(r.type===Uu)if(this.fragContextChanged(r))this.warn(`Fragment ${r.sn}${i?" p: "+i.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if(Eh(r)){this.fragPrevious=r;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(Ou.AUDIO_TRACK_SWITCHED,Yu({},e)))}this.fragBufferedComplete(r,i),this.media&&this.tick()}else this.audioOnly||r.type!==Bu||r.elementaryStreams.video||r.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}onError(e,t){var r;if(t.fatal)this.state=sg;else switch(t.details){case _u.FRAG_GAP:case _u.FRAG_PARSING_ERROR:case _u.FRAG_DECRYPT_ERROR:case _u.FRAG_LOAD_ERROR:case _u.FRAG_LOAD_TIMEOUT:case _u.KEY_LOAD_ERROR:case _u.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Uu,t);break;case _u.AUDIO_TRACK_LOAD_ERROR:case _u.AUDIO_TRACK_LOAD_TIMEOUT:case _u.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==eg||(null==(r=t.context)?void 0:r.type)!==Fu||(this.state=Xm);break;case _u.BUFFER_ADD_CODEC_ERROR:case _u.BUFFER_APPEND_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case _u.BUFFER_FULL_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case _u.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,{type:t}){t!==vh&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==vh){this.flushing=!1,this.bufferFlushed=!0,this.state===ig&&(this.state=Xm);const e=this.mediaBuffer||this.media;e&&(this.afterBufferFlushed(e,t,Uu),this.tick())}}_handleTransmuxComplete(e){var t;const r="audio",{hls:i}=this,{remuxResult:s,chunkMeta:n}=e,a=this.getCurrentContext(n);if(!a)return void this.resetWhenMissingContext(n);const{frag:o,part:l,level:c}=a,{details:d}=c,{audio:u,text:h,id3:f,initSegment:p}=s;if(!this.fragContextChanged(o)&&d){if(this.state=tg,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=p&&p.tracks){const e=o.initSegment||o;if(this.unhandledEncryptionError(p,o))return;this._bufferInitSegment(c,p.tracks,e,n),i.trigger(Ou.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:r,tracks:p.tracks})}if(u){const{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=u;l&&(l.elementaryStreams[gh]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(gh,e,t,r,i),this.bufferFragmentData(u,o,l,n)}if(null!=f&&null!=(t=f.samples)&&t.length){const e=Vu({id:r,frag:o,details:d},f);i.trigger(Ou.FRAG_PARSING_METADATA,e)}if(h){const e=Vu({id:r,frag:o,details:d},h);i.trigger(Ou.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(e,t,r,i){if(this.state!==tg)return;if(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio)return;const s=t.audio;s.id=Uu;const n=e.audioCodec;this.log(`Init audio buffer, container:${s.container}, codecs[level/parsed]=[${n}/${s.codec}]`),n&&1===n.split(",").length&&(s.levelCodec=n),this.hls.trigger(Ou.BUFFER_CODECS,t);const a=s.initSegment;if(null!=a&&a.byteLength){const e={type:"audio",frag:r,part:null,chunkMeta:i,parent:r.type,data:a};this.hls.trigger(Ou.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);var s;if(this.switchingTrack||i===op||i===cp)if(Eh(e))if(null!=(s=t.details)&&s.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=ng;const r=this.mainDetails;r&&r.fragmentStart!==t.details.fragmentStart&&Vm(t.details,r)}else super.loadFragment(e,t,r);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){const{name:t,lang:r,assocLang:i,characteristics:s,audioCodec:n,channels:a}=this.bufferedTrack;Mf({name:t,lang:r,assocLang:i,characteristics:s,audioCodec:n,channels:a},e,Nf)||($f(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(Ou.AUDIO_TRACK_SWITCHED,Yu({},e))}},audioTrackController:class extends Bv{constructor(e){super(e,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ou.LEVEL_LOADING,this.onLevelLoading,this),e.on(Ou.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Ou.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Ou.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ou.LEVEL_LOADING,this.onLevelLoading,this),e.off(Ou.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Ou.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Ou.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:r,groupId:i,details:s}=t,n=this.tracksInGroup[r];if(!n||n.groupId!==i)return void this.warn(`Audio track with id:${r} and group:${i} not found in active group ${null==n?void 0:n.groupId}`);const a=n.details;n.details=t.details,this.log(`Audio track ${r} "${n.name}" lang:${n.lang} group:${i} loaded [${s.startSN}-${s.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.audioGroups||null,i=this.groupIds;let s=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&r.some(e=>-1===(null==i?void 0:i.indexOf(e)))){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter(e=>!r||-1!==r.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>{e.id=t});else if(!s&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.audioPreference;if(!s&&t){const r=Of(t,e,Nf);if(r>-1)s=e[r];else{const e=Of(t,this.tracks);s=this.tracks[e]}}let i=this.findTrackId(s);-1===i&&s&&(i=this.findTrackId(null));const a={audioTracks:e};this.log(`Updating audio tracks, ${e.length} track(s) found in group(s): ${null==r?void 0:r.join(",")}`),this.hls.trigger(Ou.AUDIO_TRACKS_UPDATED,a);const o=this.trackId;if(-1!==i&&-1===o)this.setAudioTrack(i);else if(e.length&&-1===o){var n;const t=new Error(`No audio track selected for current audio group-ID(s): ${null==(n=this.groupIds)?void 0:n.join(",")} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}}onError(e,t){!t.fatal&&t.context&&(t.context.type!==Fu||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){const i=this.currentTrack;if(i&&Mf(e,i,Nf))return i;const s=Of(e,this.tracksInGroup,Nf);if(s>-1){const e=this.tracksInGroup[s];return this.setAudioTrack(s),e}if(i){let i=t.loadLevel;-1===i&&(i=t.firstAutoLevel);const s=function(e,t,r,i,s){const n=t[i],a=t.reduce((e,t,r)=>{const i=t.uri;return(e[i]||(e[i]=[])).push(r),e},{})[n.uri];a.length>1&&(i=Math.max.apply(Math,a));const o=n.videoRange,l=n.frameRate,c=n.codecSet.substring(0,4),d=Ff(t,i,t=>{if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==c)return!1;const i=t.audioGroups,n=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return Of(e,n,s)>-1});return d>-1?d:Ff(t,i,t=>{const i=t.audioGroups,n=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return Of(e,n,s)>-1})}(e,t.levels,r,i,Nf);if(-1===s)return null;t.nextLoadLevel=s}if(e.channels||e.audioCodec){const t=Of(e,r);if(t>-1)return r[t]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length)return void this.warn(`Invalid audio track id: ${e}`);this.selectDefaultTrack=!1;const r=this.currentTrack,i=t[e],s=i.details&&!i.details.live;if(e===this.trackId&&i===r&&s)return;if(this.log(`Switching to audio-track ${e} "${i.name}" lang:${i.lang} group:${i.groupId} channels:${i.channels}`),this.trackId=e,this.currentTrack=i,this.hls.trigger(Ou.AUDIO_TRACK_SWITCHING,Yu({},i)),s)return;const n=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(n)}findTrackId(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||Mf(e,i,Nf)))return r}if(e){const{name:r,lang:i,assocLang:s,characteristics:n,audioCodec:a,channels:o}=e;for(let e=0;e<t.length;e++){if(Mf({name:r,lang:i,assocLang:s,characteristics:n,audioCodec:a,channels:o},t[e],Nf))return e}for(let r=0;r<t.length;r++){const i=t[r];if(zv(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(zv(e.attrs,i.attrs,["LANGUAGE"]))return r}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&$f(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const r=e.id,i=e.groupId,s=this.getUrlWithDirectives(e.url,t),n=e.details,a=null==n?void 0:n.age;this.log(`Loading audio-track ${r} "${e.name}" lang:${e.lang} group:${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${a&&n.live?" age "+a.toFixed(1)+(n.type&&" "+n.type||""):""} ${s}`),this.hls.trigger(Ou.AUDIO_TRACK_LOADING,{url:s,id:r,groupId:i,deliveryDirectives:t||null,track:e})}},emeController:Vy,cmcdController:class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=e=>{try{this.apply(e,{ot:Xv.MANIFEST,su:!this.initialized})}catch(e){this.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{const{frag:t,part:r}=e,i=this.hls.levels[t.level],s=this.getObjectType(t),n={d:1e3*(r||t).duration,ot:s};s!==Xv.VIDEO&&s!==Xv.AUDIO&&s!=Xv.MUXED||(n.br=i.bitrate/1e3,n.tb=this.getTopBandwidth(s)/1e3,n.bl=this.getBufferLength(s));const a=r?this.getNextPart(r):this.getNextFrag(t);null!=a&&a.url&&a.url!==t.url&&(n.nor=a.url),this.apply(e,n)}catch(e){this.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=e;const t=this.config=e.config,{cmcd:r}=t;null!=r&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||e.sessionId,this.cid=r.contentId,this.useHeaders=!0===r.useHeaders,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ou.MEDIA_DETACHED,this.onMediaDetached,this),e.on(Ou.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ou.MEDIA_DETACHED,this.onMediaDetached,this),e.off(Ou.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,i;this.audioBuffer=null==(r=t.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(i=t.tracks.video)?void 0:i.buffer}createData(){var e;return{v:1,sf:Qv.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Vu(t,this.createData());const r=t.ot===Xv.INIT||t.ot===Xv.VIDEO||t.ot===Xv.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);const{includeKeys:i}=this;i&&(t=Object.keys(t).reduce((e,r)=>(i.includes(r)&&(e[r]=t[r]),e),{}));const s={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),By(e.headers,t,s)):e.url=Gy(e.url,t,s)}getNextFrag(e){var t;const r=null==(t=this.hls.levels[e.level])?void 0:t.details;if(r){const t=e.sn-r.startSN;return r.fragments[t+1]}}getNextPart(e){var t;const{index:r,fragment:i}=e,s=null==(t=this.hls.levels[i.level])||null==(t=t.details)?void 0:t.partList;if(s){const{sn:e}=i;for(let t=s.length-1;t>=0;t--){const i=s[t];if(i.index===r&&i.fragment.sn===e)return s[t+1]}}}getObjectType(e){const{type:t}=e;return"subtitle"===t?Xv.TIMED_TEXT:"initSegment"===e.sn?Xv.INIT:"audio"===t?Xv.AUDIO:"main"===t?this.hls.audioTracks.length?Xv.VIDEO:Xv.MUXED:void 0}getTopBandwidth(e){let t,r=0;const i=this.hls;if(e===Xv.AUDIO)t=i.audioTracks;else{const e=i.maxAutoLevel,r=e>-1?e+1:i.levels.length;t=i.levels.slice(0,r)}return t.forEach(e=>{e.bitrate>r&&(r=e.bitrate)}),r>0?r:NaN}getBufferLength(e){const t=this.media,r=e===Xv.AUDIO?this.audioBuffer:this.videoBuffer;if(!r||!t)return NaN;return 1e3*Rp.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new r(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,r,i){t(e),this.loader.load(e,r,i)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new r(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,r,i){t(e),this.loader.load(e,r,i)}}}},contentSteeringController:class extends Ku{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ou.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ou.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:r}=t;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:r}=t;if((null==r?void 0:r.action)===Jf&&r.flags===ip){const e=this.levels;let i=this._pathwayPriority,s=this.pathwayId;if(t.context){const{groupId:r,pathwayId:i,type:n}=t.context;r&&e?s=this.getPathwayForGroupId(r,n,s):i&&(s=i)}s in this.penalizedPathways||(this.penalizedPathways[s]=performance.now()),!i&&e&&(i=this.pathways()),i&&i.length>1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==s),t.details!==_u.BUFFER_APPEND_ERROR||t.fatal?r.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${s} levels: ${e?e.length:e} priorities: ${Pf(i)} penalized: ${Pf(this.penalizedPathways)}`):r.resolved=!0}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){const r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){let t;this._pathwayPriority=e;const r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(e=>{i-r[e]>3e5&&delete r[e]});for(let i=0;i<e.length;i++){const s=e[i];if(s in r)continue;if(s===this.pathwayId)return;const n=this.hls.nextLoadLevel,a=this.hls.levels[n];if(t=this.getLevelsForPathway(s),t.length>0){this.log(`Setting Pathway to "${s}"`),this.pathwayId=s,$m(t),this.hls.trigger(Ou.LEVELS_UPDATED,{levels:t});const e=this.hls.levels[n];a&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==a.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==a.bitrate&&this.log(`Unstable Pathways change from bitrate ${a.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=n);break}}}getPathwayForGroupId(e,t,r){const i=this.getLevelsForPathway(r).concat(this.levels||[]);for(let r=0;r<i.length;r++)if(t===Fu&&i[r].hasAudioGroup(e)||t===$u&&i[r].hasSubtitleGroup(e))return i[r].pathwayId;return r}clonePathways(e){const t=this.levels;if(!t)return;const r={},i={};e.forEach(e=>{const{ID:s,"BASE-ID":n,"URI-REPLACEMENT":a}=e;if(t.some(e=>e.pathwayId===s))return;const o=this.getLevelsForPathway(n).map(e=>{const t=new Fp(e.attrs);t["PATHWAY-ID"]=s;const n=t.AUDIO&&`${t.AUDIO}_clone_${s}`,o=t.SUBTITLES&&`${t.SUBTITLES}_clone_${s}`;n&&(r[t.AUDIO]=n,t.AUDIO=n),o&&(i[t.SUBTITLES]=o,t.SUBTITLES=o);const l=Hy(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),c=new Lf({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:l,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(let t=1;t<e.audioGroups.length;t++)c.addGroupId("audio",`${e.audioGroups[t]}_clone_${s}`);if(e.subtitleGroups)for(let t=1;t<e.subtitleGroups.length;t++)c.addGroupId("text",`${e.subtitleGroups[t]}_clone_${s}`);return c});t.push(...o),jy(this.audioTracks,r,a,s),jy(this.subtitleTracks,i,a,s)})}loadSteeringManifest(e){const t=this.hls.config,r=t.loader;let i;this.loader&&this.loader.destroy(),this.loader=new r(t);try{i=new self.URL(e)}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${e}`)}if("data:"!==i.protocol){const e=0|(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate);i.searchParams.set("_HLS_pathway",this.pathwayId),i.searchParams.set("_HLS_throughput",""+e)}const s={responseType:"json",url:i.href},n=t.steeringManifestLoadPolicy.default,a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(e,t,r,s)=>{this.log(`Loaded steering manifest: "${i}"`);const n=e.data;if(1!==(null==n?void 0:n.VERSION))return void this.log(`Steering VERSION ${n.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=n.TTL;const{"RELOAD-URI":a,"PATHWAY-CLONES":o,"PATHWAY-PRIORITY":l}=n;if(a)try{this.uri=new self.URL(a,i).href}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${a}`)}this.scheduleRefresh(this.uri||r.url),o&&this.clonePathways(o);const c={steeringManifest:n,url:i.toString()};this.hls.trigger(Ou.STEERING_MANIFEST_LOADED,c),l&&this.updatePathwayPriority(l)},onError:(e,t,r,i)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)return this.enabled=!1,void this.log(`Steering manifest ${t.url} no longer available`);let s=1e3*this.timeToLoad;if(429===e.code){const e=this.loader;if("function"==typeof(null==e?void 0:e.getResponseHeader)){const t=e.getResponseHeader("Retry-After");t&&(s=1e3*parseFloat(t))}return void this.log(`Steering manifest ${t.url} rate limited`)}this.scheduleRefresh(this.uri||t.url,s)},onTimeout:(e,t,r)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log(`Requesting steering manifest: ${i}`),this.loader.load(s,o,l)}scheduleRefresh(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var t;const r=null==(t=this.hls)?void 0:t.media;!r||r.ended?this.scheduleRefresh(e,1e3*this.timeToLoad):this.loadSteeringManifest(e)},t)}},interstitialsController:class extends Ku{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const e=this.currentTime;if(void 0===e||this.playbackDisabled||!this.schedule)return;const t=e-this.timelinePos;if(Math.abs(t)<1/7056e5)return;const r=t<=-.01;this.timelinePos=e,this.bufferedPos=e;const i=this.playingItem;if(!i)return void this.checkBuffer();if(r){this.schedule.resetErrorsInRange(e,e-t)&&this.updateSchedule(!0)}if(this.checkBuffer(),r&&e<i.start||e>=i.end){var s;const t=this.findItemIndex(i);let n=this.schedule.findItemIndexAtTime(e);if(-1===n&&(n=t+(r?-1:1),this.log(`seeked ${r?"back ":""}to position not covered by schedule ${e} (resolving from ${t} to ${n})`)),!this.isInterstitial(i)&&null!=(s=this.media)&&s.paused&&(this.shouldPlay=!1),!r&&n>t){const e=this.schedule.findJumpRestrictedIndex(t+1,n);if(e>t)return void this.setSchedulePosition(e)}return void this.setSchedulePosition(n)}const n=this.playingAsset;if(!n){if(this.playingLastItem&&this.isInterstitial(i)){const t=i.event.assetList[0];t&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(e,t))}return}const a=n.timelineStart,o=n.duration||0;var l;(r&&e<a||e>=a+o)&&(null!=(l=i.event)&&l.appendInPlace&&(this.clearAssetPlayers(i.event,i),this.flushFrontBuffer(e)),this.setScheduleToAssetAtTime(e,n))},this.onTimeupdate=()=>{const e=this.currentTime;if(void 0===e||this.playbackDisabled)return;if(!(e>this.timelinePos))return;this.timelinePos=e,e>this.bufferedPos&&this.checkBuffer();const t=this.playingItem;if(!t||this.playingLastItem)return;if(e>=t.end){this.timelinePos=t.end;const e=this.findItemIndex(t);this.setSchedulePosition(e+1)}const r=this.playingAsset;if(!r)return;e>=r.timelineStart+(r.duration||0)&&this.setScheduleToAssetAtTime(e,r)},this.onScheduleUpdate=(e,t)=>{const r=this.schedule;if(!r)return;const i=this.playingItem,s=r.events||[],n=r.items||[],a=r.durations,o=e.map(e=>e.identifier),l=!(!s.length&&!o.length);(l||t)&&this.log(`INTERSTITIALS_UPDATED (${s.length}): ${s}\nSchedule: ${n.map(e=>hb(e))} pos: ${this.timelinePos}`),o.length&&this.log(`Removed events ${o}`);let c=null,d=null;i&&(c=this.updateItem(i,this.timelinePos),this.itemsMatch(i,c)?this.playingItem=c:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const u=this.bufferingItem;if(u&&(d=this.updateItem(u,this.bufferedPos),this.itemsMatch(u,d)?this.bufferingItem=d:u.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(u.event,null))),e.forEach(e=>{e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,null)})}),this.playerQueue.forEach(e=>{if(e.interstitial.appendInPlace){const t=e.assetItem.timelineStart,r=e.timelineOffset-t;if(r)try{e.timelineOffset=t}catch(i){Math.abs(r)>rb&&this.warn(`${i} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),l||t){if(this.hls.trigger(Ou.INTERSTITIALS_UPDATED,{events:s.slice(0),schedule:n.slice(0),durations:a,removedIds:o}),this.isInterstitial(i)&&o.includes(i.event.identifier))return this.warn(`Interstitial "${i.event.identifier}" removed while playing`),void this.primaryFallback(i.event);i&&this.trimInPlace(c,i),u&&d!==c&&this.trimInPlace(d,u),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new fb(e),this.schedule=new ub(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Ou.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Ou.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(Ou.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Ou.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(Ou.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(Ou.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(Ou.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Ou.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Ou.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(Ou.MEDIA_ENDED,this.onMediaEnded,this),e.on(Ou.ERROR,this.onError,this),e.on(Ou.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Ou.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Ou.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(Ou.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Ou.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(Ou.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(Ou.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(Ou.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Ou.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Ou.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Ou.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(Ou.MEDIA_ENDED,this.onMediaEnded,this),e.off(Ou.ERROR,this.onError,this),e.off(Ou.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;null==(e=this.getBufferingPlayer())||e.resumeBuffering()}pauseBuffering(){var e;null==(e=this.getBufferingPlayer())||e.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){Ym(e,"play",this.onPlay),Ym(e,"pause",this.onPause),Ym(e,"seeking",this.onSeeking),Ym(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const r=this.media=t.media;Wm(r,"seeking",this.onSeeking),Wm(r,"timeupdate",this.onTimeupdate),Wm(r,"play",this.onPlay),Wm(r,"pause",this.onPause)}onMediaAttached(e,t){const r=this.effectivePlayingItem,i=this.detachedData;if(this.detachedData=null,null===r)this.checkStart();else if(!i){this.clearScheduleState();const e=this.findItemIndex(r);this.setSchedulePosition(e)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){const r=!!t.transferMedia,i=this.media;if(this.media=null,!r&&(i&&this.removeMediaListeners(i),this.detachedData)){const e=this.getBufferingPlayer();e&&(this.log(`Removing schedule state for detachedData and ${e}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,e.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const e=this,t=()=>e.bufferingItem||e.waitingItem,r=t=>t?e.getAssetPlayer(t.identifier):t,i=(t,i,n,a,o)=>{if(t){let l=t[i].start;const c=t.event;if(c){if("playout"===i||c.timelineOccupancy!==ib.Point){const e=r(n);(null==e?void 0:e.interstitial)===c&&(l+=e.assetItem.startOffset+e[o])}}else{l+=("bufferedPos"===a?s():e[a])-t.start}return l}return 0},s=()=>{const t=e.bufferedPos;return t===Number.MAX_VALUE?n("primary"):Math.max(t,0)},n=t=>{var r,i;return null!=(r=e.primaryDetails)&&r.live?e.primaryDetails.edge:(null==(i=e.schedule)?void 0:i.durations[t])||0},a=(t,s)=>{var n,a;const o=e.effectivePlayingItem;if(null!=o&&null!=(n=o.event)&&n.restrictions.skip||!e.schedule)return;e.log(`seek to ${t} "${s}"`);const l=e.effectivePlayingItem,c=e.schedule.findItemIndexAtTime(t,s),d=null==(a=e.schedule.items)?void 0:a[c],u=e.getBufferingPlayer(),h=null==u?void 0:u.interstitial,f=null==h?void 0:h.appendInPlace,p=l&&e.itemsMatch(l,d);if(l&&(f||p)){const n=r(e.playingAsset),a=(null==n?void 0:n.media)||e.primaryMedia;if(a){const r="primary"===s?a.currentTime:i(l,s,e.playingAsset,"timelinePos","currentTime"),o=t-r,c=(f?r:a.currentTime)+o;if(c>=0&&(!n||f||c<=n.duration))return void(a.currentTime=c)}}if(d){let r=t;if("primary"!==s){const e=t-d[s].start;r=d.start+e}const i=!e.isInterstitial(d);if(e.isInterstitial(l)&&!l.event.appendInPlace||!i&&!d.event.appendInPlace){if(l){const n=e.findItemIndex(l);if(c>n){const t=e.schedule.findJumpRestrictedIndex(n+1,c);if(t>n)return void e.setSchedulePosition(t)}let a=0;if(i)e.timelinePos=r,e.checkBuffer();else{const e=d.event.assetList,r=t-(d[s]||d).start;for(let t=e.length;t--;){const i=e[t];if(i.duration&&r>=i.startOffset&&r<i.startOffset+i.duration){a=t;break}}}e.setSchedulePosition(c,a)}}else{const t=e.media||(f?null==u?void 0:u.media:null);t&&(t.currentTime=r)}}},o=()=>{const r=e.effectivePlayingItem;if(e.isInterstitial(r))return r;const i=t();return e.isInterstitial(i)?i:null},l={get bufferedEnd(){const r=t(),s=e.bufferingItem;var n;return s&&s===r&&(i(s,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-s.playout.start||(null==(n=e.bufferingAsset)?void 0:n.startOffset))||0},get currentTime(){const t=o(),r=e.effectivePlayingItem;return r&&r===t?i(r,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-r.playout.start:0},set currentTime(t){const r=o(),i=e.effectivePlayingItem;i&&i===r&&a(t+i.playout.start,"playout")},get duration(){const e=o();return e?e.playout.end-e.playout.start:0},get assetPlayers(){var t;const r=null==(t=o())?void 0:t.event.assetList;return r?r.map(t=>e.getAssetPlayer(t.identifier)):[]},get playingIndex(){var t;const r=null==(t=o())?void 0:t.event;return r&&e.effectivePlayingAsset?r.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return o()}};return this.manager={get events(){var t;return(null==(t=e.schedule)||null==(t=t.events)?void 0:t.slice(0))||[]},get schedule(){var t;return(null==(t=e.schedule)||null==(t=t.items)?void 0:t.slice(0))||[]},get interstitialPlayer(){return o()?l:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const r=t();return e.findItemIndex(r)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const t=e.effectivePlayingItem;return e.findItemIndex(t)},primary:{get bufferedEnd(){return s()},get currentTime(){const t=e.timelinePos;return t>0?t:0},set currentTime(e){a(e,"primary")},get duration(){return n("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0}},integrated:{get bufferedEnd(){return i(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return i(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(e){a(e,"integrated")},get duration(){return n("integrated")},get seekableStart(){var t;return((t,r)=>{var i;if(0!==t&&"primary"!==r&&null!=(i=e.schedule)&&i.length){var s;const i=e.schedule.findItemIndexAtTime(t),n=null==(s=e.schedule.items)?void 0:s[i];if(n)return t+(n[r].start-n.start)}return t})((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")}},skip:()=>{const t=e.effectivePlayingItem,r=null==t?void 0:t.event;if(r&&!r.restrictions.skip){const i=e.findItemIndex(t);if(r.appendInPlace){const e=t.playout.start+t.event.duration;a(e+.001,"playout")}else e.advanceAfterAssetEnded(r,i,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;const t=this.playingItem,r=null==(e=this.schedule)?void 0:e.items;return!!(this.playbackStarted&&t&&r)&&this.findItemIndex(t)===r.length-1}get playbackStarted(){return null!==this.effectivePlayingItem}get currentTime(){var e,t;if(null===this.mediaSelection)return;const r=this.waitingItem||this.playingItem;if(this.isInterstitial(r)&&!r.event.appendInPlace)return;let i=this.media;!i&&null!=(e=this.bufferingItem)&&null!=(e=e.event)&&e.appendInPlace&&(i=this.primaryMedia);const s=null==(t=i)?void 0:t.currentTime;return void 0!==s&&Ru(s)?s:void 0}get primaryMedia(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}isInterstitial(e){return!(null==e||!e.event)}retreiveMediaSource(e,t){const r=this.getAssetPlayer(e);r&&this.transferMediaFromPlayer(r,t)}transferMediaFromPlayer(e,t){const r=e.interstitial.appendInPlace,i=e.media;if(r&&i===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&i)return void(this.detachedData={media:i});const r=e.transferMedia();this.log(`transfer MediaSource from ${e} ${Pf(r)}`),this.detachedData=r}else t&&i&&(this.shouldPlay||(this.shouldPlay=!i.paused))}transferMediaTo(e,t){var r,i;if(e.media===t)return;let s=null;const n=this.hls,a=e!==n,o=a&&e.interstitial.appendInPlace,l=null==(r=this.detachedData)?void 0:r.mediaSource;let c;if(n.media)o&&(s=n.transferMedia(),this.detachedData=s),c="Primary";else if(l){const e=this.getBufferingPlayer();e?(s=e.transferMedia(),c=`${e}`):c="detached MediaSource"}else c="detached media";if(!s)if(l)s=this.detachedData,this.log(`using detachedData: MediaSource ${Pf(s)}`);else if(!this.detachedData||n.media===t){const e=this.playerQueue;e.length>1&&e.forEach(e=>{if(a&&e.interstitial.appendInPlace!==o){const t=e.interstitial;this.clearInterstitial(e.interstitial,null),t.appendInPlace=!1,t.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${t}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}const d=s&&"mediaSource"in s&&"closed"!==(null==(i=s.mediaSource)?void 0:i.readyState),u=d&&s?s:t;this.log(`${d?"transfering MediaSource":"attaching media"} to ${a?e:"Primary"} from ${c} (media.currentTime: ${t.currentTime})`);const h=this.schedule;if(u===s&&h){const t=a&&e.assetId===h.assetIdAtEnd;u.overrides={duration:h.duration,endOfStream:!a||t,cueRemoval:!a}}e.attachMedia(u)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=null==e?void 0:e.events;if(!t||this.playbackDisabled||!this.media)return;-1===this.bufferedPos&&(this.bufferedPos=0);const r=this.timelinePos,i=this.effectivePlayingItem;if(-1===r){const r=this.hls.startPosition;if(this.log(mb("checkStart",r)),this.timelinePos=r,t.length&&t[0].cue.pre){const r=e.findEventIndex(t[0].identifier);this.setSchedulePosition(r)}else if(r>=0||!this.primaryLive){const t=this.timelinePos=r>0?r:0,i=e.findItemIndexAtTime(t);this.setSchedulePosition(i)}}else if(i&&!this.playingItem){const t=e.findItemIndex(i);this.setSchedulePosition(t)}}advanceAssetBuffering(e,t){const r=e.event,i=r.findAssetIndex(t),s=lb(r,i);if(r.isAssetPastPlayoutLimit(s)){if(this.schedule){var n;const t=null==(n=this.schedule.items)?void 0:n[this.findItemIndex(e)+1];t&&this.bufferedToItem(t)}}else this.bufferedToEvent(e,s)}advanceAfterAssetEnded(e,t,r){const i=lb(e,r);if(e.isAssetPastPlayoutLimit(i)){if(this.schedule){const r=this.schedule.items;if(r){const i=t+1;if(i>=r.length)return void this.setSchedulePosition(-1);const s=e.resumeTime;this.timelinePos<s&&(this.log(mb("advanceAfterAssetEnded",s)),this.timelinePos=s,e.appendInPlace&&this.advanceInPlace(s),this.checkBuffer(this.bufferedPos<s)),this.setSchedulePosition(i)}}}else{if(e.appendInPlace){const t=e.assetList[i];t&&this.advanceInPlace(t.timelineStart)}this.setSchedulePosition(t,i)}}setScheduleToAssetAtTime(e,t){const r=this.schedule;if(!r)return;const i=t.parentIdentifier,s=r.getEvent(i);if(s){const t=r.findEventIndex(i),n=r.findAssetIndex(s,e);this.advanceAfterAssetEnded(s,t,n-1)}}setSchedulePosition(e,t){var r;const i=null==(r=this.schedule)?void 0:r.items;if(!i||this.playbackDisabled)return;const s=e>=0?i[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${s?hb(s):s}) pos: ${this.timelinePos}`);const n=this.waitingItem||this.playingItem,a=this.playingLastItem;if(this.isInterstitial(n)){const r=n.event,c=this.playingAsset,d=null==c?void 0:c.identifier,u=d?this.getAssetPlayer(d):null;if(u&&d&&(!this.eventItemsMatch(n,s)||void 0!==t&&d!==r.assetList[t].identifier)){var o;const t=r.findAssetIndex(c);if(this.log(`INTERSTITIAL_ASSET_ENDED ${t+1}/${r.assetList.length} ${cb(c)}`),this.endedAsset=c,this.playingAsset=null,this.hls.trigger(Ou.INTERSTITIAL_ASSET_ENDED,{asset:c,assetListIndex:t,event:r,schedule:i.slice(0),scheduleIndex:e,player:u}),n!==this.playingItem)return void(this.itemsMatch(n,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(r,this.findItemIndex(this.playingItem),t));this.retreiveMediaSource(d,s),!u.media||null!=(o=this.detachedData)&&o.mediaSource||u.detachMedia()}if(!this.eventItemsMatch(n,s)&&(this.endedItem=n,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${r} ${hb(n)}`),r.hasPlayed=!0,this.hls.trigger(Ou.INTERSTITIAL_ENDED,{event:r,schedule:i.slice(0),scheduleIndex:e}),r.cue.once)){var l;this.updateSchedule();const e=null==(l=this.schedule)?void 0:l.items;if(s&&e){const r=this.findItemIndex(s);this.advanceSchedule(r,e,t,n,a)}return}}this.advanceSchedule(e,i,t,n,a)}advanceSchedule(e,t,r,i,s){const n=this.schedule;if(!n)return;const a=t[e]||null,o=this.primaryMedia,l=this.playerQueue;if(l.length&&l.forEach(t=>{const r=t.interstitial,i=n.findEventIndex(r.identifier);(i<e||i>e+1)&&this.clearInterstitial(r,a)}),this.isInterstitial(a)){this.timelinePos=Math.min(Math.max(this.timelinePos,a.start),a.end);const s=a.event;if(void 0===r){const t=lb(s,(r=n.findAssetIndex(s,this.timelinePos))-1);if(s.isAssetPastPlayoutLimit(t)||s.appendInPlace&&this.timelinePos===a.end)return void this.advanceAfterAssetEnded(s,e,r);r=t}const l=this.waitingItem;this.assetsBuffered(a,o)||this.setBufferingItem(a);let c=this.preloadAssets(s,r);if(this.eventItemsMatch(a,l||i)||(this.waitingItem=a,this.log(`INTERSTITIAL_STARTED ${hb(a)} ${s.appendInPlace?"append in place":""}`),this.hls.trigger(Ou.INTERSTITIAL_STARTED,{event:s,schedule:t.slice(0),scheduleIndex:e})),!s.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${s}`);if(s.assetListLoader&&(s.assetListLoader.destroy(),s.assetListLoader=void 0),!o)return void this.log(`Waiting for attachMedia to start Interstitial ${s}`);this.waitingItem=this.endedItem=null,this.playingItem=a;const d=s.assetList[r];if(!d)return void this.advanceAfterAssetEnded(s,e,r||0);if(c||(c=this.getAssetPlayer(d.identifier)),null===c||c.destroyed){const e=s.assetList.length;this.warn(`asset ${r+1}/${e} player destroyed ${s}`),c=this.createAssetPlayer(s,d,r),c.loadSource()}if(!this.eventItemsMatch(a,this.bufferingItem)&&s.appendInPlace&&this.isAssetBuffered(d))return;this.startAssetPlayer(c,r,t,e,o),this.shouldPlay&&pb(c.media)}else a?(this.resumePrimary(a,e,i),this.shouldPlay&&pb(this.hls.media)):s&&this.isInterstitial(i)&&(this.endedItem=null,this.playingItem=i,i.event.appendInPlace||this.attachPrimary(n.durations.primary,null))}get playbackDisabled(){return!1===this.hls.config.enableInterstitialPlayback}get primaryDetails(){var e;return null==(e=this.mediaSelection)?void 0:e.main.details}get primaryLive(){var e;return!(null==(e=this.primaryDetails)||!e.live)}resumePrimary(e,t,r){var i,s;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${hb(e)}`),null==(i=this.detachedData)||!i.mediaSource){let r=this.timelinePos;(r<e.start||r>=e.end)&&(r=this.getPrimaryResumption(e,t),this.log(mb("resumePrimary",r)),this.timelinePos=r),this.attachPrimary(r,e)}if(!r)return;const n=null==(s=this.schedule)?void 0:s.items;n&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${hb(e)}`),this.hls.trigger(Ou.INTERSTITIALS_PRIMARY_RESUMED,{schedule:n.slice(0),scheduleIndex:t}),this.checkBuffer())}getPrimaryResumption(e,t){const r=e.start;if(this.primaryLive){const e=this.primaryDetails;if(0===t)return this.hls.startPosition;if(e&&(r<e.fragmentStart||r>e.edge))return this.hls.liveSyncPosition||-1}return r}isAssetBuffered(e){const t=this.getAssetPlayer(e.identifier);if(null!=t&&t.hls)return t.hls.bufferedToEnd;return Rp.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,r){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const i=this.primaryMedia;if(!i)return;const s=this.hls;s.media?this.checkBuffer():(this.transferMediaTo(s,i),r&&this.startLoadingPrimaryAt(e,r)),r||(this.log(mb("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,r))}startLoadingPrimaryAt(e,t){var r;const i=this.hls;!i.loadingEnabled||!i.media||Math.abs(((null==(r=i.mainForwardBufferInfo)?void 0:r.start)||i.media.currentTime)-e)>.5?i.startLoad(e,t):i.bufferingEnabled||i.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),null==(e=this.schedule)||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(Ou.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(Ou.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(-1===t.level||!this.schedule)return;const r=this.hls.levels[t.level];if(!r.details)return;const i=Yu(Yu({},this.mediaSelection||this.altSelection),{},{main:r});this.mediaSelection=i,this.schedule.parseInterstitialDateRanges(i,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(e,t){const r=this.hls.audioTracks[t.id],i=this.mediaSelection;if(!i)return void(this.altSelection=Yu(Yu({},this.altSelection),{},{audio:r}));const s=Yu(Yu({},i),{},{audio:r});this.mediaSelection=s}onSubtitleTrackUpdated(e,t){const r=this.hls.subtitleTracks[t.id],i=this.mediaSelection;if(!i)return void(this.altSelection=Yu(Yu({},this.altSelection),{},{subtitles:r}));const s=Yu(Yu({},i),{},{subtitles:r});this.mediaSelection=s}onAudioTrackSwitching(e,t){const r=_f(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(r)))}onSubtitleTrackSwitch(e,t){const r=_f(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setSubtitleOption(t)||-1!==t.id&&e.setSubtitleOption(r)))}onBufferCodecs(e,t){const r=t.tracks;r&&(this.requiredTracks=r)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){const r=this.playingItem;if(r&&!this.itemsMatch(r,this.bufferingItem)&&!this.isInterstitial(r)){const e=this.timelinePos;this.bufferedPos=e,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;const t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let e=0;e<t.length;e++){const i=t[e];if(i.cue.post){var r;const e=this.schedule.findEventIndex(i.identifier),t=null==(r=this.schedule.items)?void 0:r[e];this.isInterstitial(t)&&this.eventItemsMatch(t,this.bufferingItem)&&this.bufferedToItem(t,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){const t=this.playingItem;if(!this.playingLastItem&&t){const e=this.findItemIndex(t);this.setSchedulePosition(e+1)}else this.shouldPlay=!1}updateItem(e,t){var r;const i=null==(r=this.schedule)?void 0:r.items;if(e&&i){return i[this.findItemIndex(e,t)]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((t,r)=>{e.event.isAssetPastPlayoutLimit(r)&&this.clearAssetPlayer(t.identifier,null)});const r=e.end+.25,i=Rp.bufferInfo(this.primaryMedia,r,0);if(i.end>r||(i.nextStart||0)>r){this.log(`trim buffered interstitial ${hb(e)} (was ${hb(t)})`);const i=!0;this.attachPrimary(r,null,i),this.flushFrontBuffer(r)}}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var r;return!!t&&(e===t||e.event.identifier===(null==(r=t.event)?void 0:r.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t;const r=this.mediaSelection;r&&(null==(t=this.schedule)||t.updateSchedule(r,[],e))}checkBuffer(e){var t;const r=null==(t=this.schedule)?void 0:t.items;if(!r)return;const i=Rp.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=i.len<1),this.updateBufferedPos(i.end,r,e)}updateBufferedPos(e,t,r){const i=this.schedule,s=this.bufferingItem;if(this.bufferedPos>e||!i)return;if(1===t.length&&this.itemsMatch(t[0],s))return void(this.bufferedPos=e);const n=this.playingItem,a=this.findItemIndex(n);let o=i.findItemIndexAtTime(e);if(this.bufferedPos<e){var l;const r=this.findItemIndex(s),i=Math.min(r+1,t.length-1),n=t[i];if((-1===o&&s&&e>=s.end||null!=(l=n.event)&&l.appendInPlace&&e+.01>=n.start)&&(o=i),this.isInterstitial(s)){const e=s.event;if(i-a>1&&!1===e.appendInPlace)return;if(0===e.assetList.length&&e.assetListLoader)return}if(this.bufferedPos=e,o>r&&o>a)this.bufferedToItem(n);else{const t=this.primaryDetails;this.primaryLive&&t&&e>t.edge-t.targetduration&&n.start<t.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(n)&&this.preloadAssets(n.event,0)}}else r&&n&&!this.itemsMatch(n,s)&&(o===a?this.bufferedToItem(n):o===a+1&&this.bufferedToItem(t[o]))}assetsBuffered(e,t){return 0!==e.event.assetList.length&&!e.event.assetList.some(e=>{const r=this.getAssetPlayer(e.identifier);return!(null!=r&&r.bufferedInPlaceToEnd(t))})}setBufferingItem(e){const t=this.bufferingItem,r=this.schedule;if(!this.itemsMatch(e,t)&&r){const{items:i,events:s}=r;if(!i||!s)return t;const n=this.isInterstitial(e),a=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const o=a?a.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${hb(e)}`+(t?` (${o.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(n){const t=r.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((e,r)=>{const i=this.getAssetPlayer(e.identifier);i&&(r===t&&i.loadSource(),i.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(e=>e.pauseBuffering());this.hls.trigger(Ou.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:s.slice(0),schedule:i.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){const r=this.setBufferingItem(e);if(!this.playbackDisabled)if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==r){this.bufferingAsset=null;const t=this.detachedData;if(t)if(t.mediaSource){const t=!0;this.attachPrimary(e.start,e,t)}else this.preloadPrimary(e);else this.preloadPrimary(e)}}preloadPrimary(e){const t=this.findItemIndex(e),r=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(r)}bufferedToEvent(e,t){const r=e.event,i=0===r.assetList.length&&!r.assetListLoader,s=r.cue.once;if(i||!s){const e=this.preloadAssets(r,t);if(null!=e&&e.interstitial.appendInPlace){const t=this.primaryMedia;t&&this.bufferAssetPlayer(e,t)}}}preloadAssets(e,t){const r=e.assetUrl,i=e.assetList.length,s=0===i&&!e.assetListLoader,n=e.cue.once;if(s){const s=e.timelineStart;if(e.appendInPlace){var a;const t=this.playingItem;this.isInterstitial(t)||(null==t||null==(a=t.nextEvent)?void 0:a.identifier)!==e.identifier||this.flushFrontBuffer(s+.25)}let n,o=0;if(!this.playingItem&&this.primaryLive&&(o=this.hls.startPosition,-1===o&&(o=this.hls.liveSyncPosition||0)),o&&!e.cue.pre&&!e.cue.post){const e=o-s;e>0&&(n=Math.round(1e3*e)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${r?1:i} ${e}${n?` live-start: ${o} start-offset: ${n}`:""}`),r)return this.createAsset(e,0,0,s,e.duration,r);const l=this.assetListLoader.loadAssetList(e,n);l&&(e.assetListLoader=l)}else if(!n&&i){for(let r=t;r<i;r++){const t=e.assetList[r],i=this.getAssetPlayerQueueIndex(t.identifier);-1!==i&&!this.playerQueue[i].destroyed||t.error||this.createAssetPlayer(e,t,r)}const r=e.assetList[t];if(r){const e=this.getAssetPlayer(r.identifier);return e&&e.loadSource(),e}}return null}flushFrontBuffer(e){const t=this.requiredTracks;if(!t)return;this.log(`Removing front buffer starting at ${e}`);Object.keys(t).forEach(t=>{this.hls.trigger(Ou.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:t})})}getAssetPlayerQueueIndex(e){const t=this.playerQueue;for(let r=0;r<t.length;r++)if(e===t[r].assetId)return r;return-1}getAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){const{playerQueue:e,primaryMedia:t}=this;if(t)for(let r=0;r<e.length;r++)if(e[r].media===t)return e[r];return null}createAsset(e,t,r,i,s,n){const a={parentIdentifier:e.identifier,identifier:sb(e,n,t),duration:s,startOffset:r,timelineStart:i,uri:n};return this.createAssetPlayer(e,a,t)}createAssetPlayer(e,t,r){const i=this.hls,s=i.userConfig;let n=s.videoPreference;const a=i.loadLevelObj||i.levels[i.currentLevel];(n||a)&&(n=Vu({},n),a.videoCodec&&(n.videoCodec=a.videoCodec),a.videoRange&&(n.allowedVideoRanges=[a.videoRange]));const o=i.audioTracks[i.audioTrack],l=i.subtitleTracks[i.subtitleTrack];let c=0;if(this.primaryLive||e.appendInPlace){const e=this.timelinePos-t.timelineStart;if(e>1){const r=t.duration;r&&e<r&&(c=e)}}const d=t.identifier,u=Yu(Yu({},s),{},{maxMaxBufferLength:Math.min(180,i.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:i.sessionId,assetPlayerId:d,abrEwmaDefaultEstimate:i.bandwidthEstimate,interstitialsController:void 0,startPosition:c,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:n,audioPreference:o||s.audioPreference,subtitlePreference:l||s.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(u.timelineOffset=t.timelineStart));const h=u.cmcd;null!=h&&h.sessionId&&h.contentId&&(u.cmcd=Vu({},h,{contentId:tb(t.uri)})),this.getAssetPlayer(d)&&this.warn(`Duplicate date range identifier ${e} and asset ${d}`);const f=new db(this.HlsPlayerClass,u,e,t);this.playerQueue.push(f),e.assetList[r]=t;let p=!0;const m=i=>{if(i.live){var s;const t=new Error(`Interstitials MUST be VOD assets ${e}`),i={fatal:!0,type:Du.OTHER_ERROR,details:_u.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},n=(null==(s=this.schedule)?void 0:s.findEventIndex(e.identifier))||-1;return void this.handleAssetItemError(i,e,n,r,t.message)}const n=i.edge-i.fragmentStart,a=t.duration;(p||null===a||n>a)&&(p=!1,this.log(`Interstitial asset "${d}" duration change ${a} > ${n}`),t.duration=n,this.updateSchedule())};f.on(Ou.LEVEL_UPDATED,(e,{details:t})=>m(t)),f.on(Ou.LEVEL_PTS_UPDATED,(e,{details:t})=>m(t)),f.on(Ou.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const g=(e,t)=>{const r=this.getAssetPlayer(d);if(r&&t.tracks){r.off(Ou.BUFFER_CODECS,g),r.tracks=t.tracks;const e=this.primaryMedia;this.bufferingAsset===r.assetItem&&e&&!r.media&&this.bufferAssetPlayer(r,e)}};f.on(Ou.BUFFER_CODECS,g);f.on(Ou.BUFFERED_TO_END,()=>{var r;const i=this.getAssetPlayer(d);if(this.log(`buffered to end of asset ${i}`),!i||!this.schedule)return;const s=this.schedule.findEventIndex(e.identifier),n=null==(r=this.schedule.items)?void 0:r[s];this.isInterstitial(n)&&this.advanceAssetBuffering(n,t)});const v=t=>()=>{if(!this.getAssetPlayer(d)||!this.schedule)return;this.shouldPlay=!0;const r=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,r,t)};return f.once(Ou.MEDIA_ENDED,v(r)),f.once(Ou.PLAYOUT_LIMIT_REACHED,v(1/0)),f.on(Ou.ERROR,(t,i)=>{if(!this.schedule)return;const s=this.getAssetPlayer(d);if(i.details===_u.BUFFER_STALLED_ERROR)return null!=s&&s.appendInPlace?void this.handleInPlaceStall(e):(this.onTimeupdate(),void this.checkBuffer(!0));this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),r,`Asset player error ${i.error} ${e}`)}),f.on(Ou.DESTROYING,()=>{if(!this.getAssetPlayer(d)||!this.schedule)return;const t=new Error(`Asset player destroyed unexpectedly ${d}`),i={fatal:!0,type:Du.OTHER_ERROR,details:_u.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),r,t.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${cb(t)}`),this.hls.trigger(Ou.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:r,event:e,player:f}),f}clearInterstitial(e,t){this.clearAssetPlayers(e,t),e.reset()}clearAssetPlayers(e,t){e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,t)})}resetAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);if(-1!==t){this.log(`reset asset player "${e}" after error`);const r=this.playerQueue[t];this.transferMediaFromPlayer(r,null),r.resetDetails()}}clearAssetPlayer(e,t){const r=this.getAssetPlayerQueueIndex(e);if(-1!==r){const e=this.playerQueue[r];this.log(`clear ${e} toSegment: ${t?hb(t):t}`),this.transferMediaFromPlayer(e,t),this.playerQueue.splice(r,1),e.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,r,i,s){const{interstitial:n,assetItem:a,assetId:o}=e,l=n.assetList.length,c=this.playingAsset;this.endedAsset=null,this.playingAsset=a,c&&c.identifier===o||(c&&(this.clearAssetPlayer(c.identifier,r[i]),delete c.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${l} ${cb(a)}`),this.hls.trigger(Ou.INTERSTITIAL_ASSET_STARTED,{asset:a,assetListIndex:t,event:n,schedule:r.slice(0),scheduleIndex:i,player:e})),this.bufferAssetPlayer(e,s)}bufferAssetPlayer(e,t){var r,i;if(!this.schedule)return;const{interstitial:s,assetItem:n}=e,a=this.schedule.findEventIndex(s.identifier),o=null==(r=this.schedule.items)?void 0:r[a];if(!o)return;e.loadSource(),this.setBufferingItem(o),this.bufferingAsset=n;const l=this.getBufferingPlayer();if(l===e)return;const c=s.appendInPlace;if(c&&!1===(null==l?void 0:l.interstitial.appendInPlace))return;const d=(null==l?void 0:l.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(c&&n!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(d&&!rh(d,e.tracks)){const t=new Error(`Asset ${cb(n)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(d)}')`),r={fatal:!0,type:Du.OTHER_ERROR,details:_u.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},i=s.findAssetIndex(n);return void this.handleAssetItemError(r,s,a,i,t.message)}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,r=this.primaryMedia;if(!t||!r)return;const i=r.currentTime,s=t.findAssetIndex(e,i),n=e.assetList[s];if(n){const a=this.getAssetPlayer(n.identifier);if(a){const o=a.currentTime||i-n.timelineStart,l=a.duration-o;if(this.warn(`Stalled at ${o} of ${o+l} in ${a} ${e} (media.currentTime: ${i})`),o&&(l/r.playbackRate<.5||a.bufferedInPlaceToEnd(r))&&a.hls){const r=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,r,s)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,r,i,s){if(e.details===_u.BUFFER_STALLED_ERROR)return;const n=t.assetList[i]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${n?cb(n):n} ${e.error}`),!this.schedule)return;const a=(null==n?void 0:n.identifier)||"",o=this.getAssetPlayerQueueIndex(a),l=this.playerQueue[o]||null,c=this.schedule.items,d=Vu({},e,{fatal:!1,errorAction:ap(!0),asset:n,assetListIndex:i,event:t,schedule:c,scheduleIndex:r,player:l});if(this.hls.trigger(Ou.INTERSTITIAL_ASSET_ERROR,d),!e.fatal)return;const u=this.playingAsset,h=this.bufferingAsset,f=new Error(s);if(n&&(this.clearAssetPlayer(a,null),n.error=f),t.assetList.some(e=>!e.error))for(let e=i;e<t.assetList.length;e++)this.resetAssetPlayer(t.assetList[e].identifier);else t.error=f;this.updateSchedule(!0),t.error?this.primaryFallback(t):u&&u.identifier===a?this.advanceAfterAssetEnded(t,r,i):h&&h.identifier===a&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,h)}primaryFallback(e){const t=e.timelineStart,r=this.effectivePlayingItem;let i=this.timelinePos;if(r){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${i} playing: ${hb(r)} error: ${e.error}`),-1===i&&(i=this.hls.startPosition);const s=this.updateItem(r,i);this.itemsMatch(r,s)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(-1===i)return void this.checkStart();if(!this.schedule)return;const s=this.schedule.findItemIndexAtTime(i);this.setSchedulePosition(s)}onAssetListLoaded(e,t){var r,i;const s=t.event,n=s.identifier,a=t.assetListResponse.ASSETS;if(null==(r=this.schedule)||!r.hasEvent(n))return;const o=s.timelineStart,l=s.duration;let c=0;a.forEach((e,t)=>{const r=parseFloat(e.DURATION);this.createAsset(s,t,c,o+c,r,e.URI),c+=r}),s.duration=c,this.log(`Loaded asset-list with duration: ${c} (was: ${l}) ${s}`);const d=this.waitingItem,u=(null==d?void 0:d.event.identifier)===n;this.updateSchedule();const h=null==(i=this.bufferingItem)?void 0:i.event;if(u){var f;const e=this.schedule.findEventIndex(n),t=null==(f=this.schedule.items)?void 0:f[e];if(t){if(!this.playingItem&&this.timelinePos>t.end){if(this.schedule.findItemIndexAtTime(this.timelinePos)!==e)return s.error=new Error(`Interstitial ${a.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${s}`),this.log(s.error.message),this.updateSchedule(!0),void this.primaryFallback(s)}this.setBufferingItem(t)}this.setSchedulePosition(e)}else if((null==h?void 0:h.identifier)===n){const e=s.assetList[0];if(e){const t=this.getAssetPlayer(e.identifier);if(h.appendInPlace){const e=this.primaryMedia;t&&e&&this.bufferAssetPlayer(t,e)}else t&&t.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case _u.ASSET_LIST_PARSING_ERROR:case _u.ASSET_LIST_LOAD_ERROR:case _u.ASSET_LIST_LOAD_TIMEOUT:{const e=t.interstitial;e&&(this.updateSchedule(!0),this.primaryFallback(e));break}case _u.BUFFER_STALLED_ERROR:{const e=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(e)&&e.event.appendInPlace)return void this.handleInPlaceStall(e.event);this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}});function EE(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(EE):Object.keys(e).reduce((t,r)=>(t[r]=EE(e[r]),t),{}):e}function wE(e,t){const r=e.loader;if(r!==pE&&r!==yE)t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1;else{(function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1})()&&(e.loader=pE,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}}class SE extends kp{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var e;null!=(e=this.media)&&e.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{var e;this.hls&&(this.ended=(null==(e=this.media)?void 0:e.currentTime)||1,this.hls.trigger(Ou.MEDIA_ENDED,{stalled:!1}))},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;const r=this.media=t.media;Wm(r,"playing",this.onMediaPlaying),Wm(r,"waiting",this.onMediaWaiting),Wm(r,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:r}=this;r&&(Ym(r,"playing",this.onMediaPlaying),Ym(r,"waiting",this.onMediaWaiting),Ym(r,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(null==(e=this.media)||!e.readyState||!this.hasBuffered)return;const t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}poll(e,t){var r,i;const s=null==(r=this.hls)?void 0:r.config;if(!s)return;const n=this.media;if(!n)return;const{seeking:a}=n,o=this.seeking&&!a,l=!this.seeking&&a,c=n.paused&&!a||n.ended||0===n.playbackRate;if(this.seeking=a,e!==t)return t&&(this.ended=0),this.moved=!0,a||(this.nudgeRetry=0,s.nudgeOnVideoHole&&!c&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(l||o)return void(o&&this.stallResolved(e));if(c)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&n.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(Ou.MEDIA_ENDED,{stalled:!1})));if(!Rp.getBuffered(n).length)return void(this.nudgeRetry=0);const d=Rp.bufferInfo(n,e,0),u=d.nextStart||0,h=this.fragmentTracker;if(a&&h&&this.hls){const t=TE(this.hls.inFlightFragments,e),r=d.len>2,i=!u||t||u-e>2&&!h.getPartialFragment(e);if(r||i)return;this.moved=!1}const f=null==(i=this.hls)?void 0:i.latestLevelDetails;if(!this.moved&&null!==this.stalled&&h){if(!(d.len>0)&&!u)return;const t=Math.max(u,d.start||0)-e,r=!(null==f||!f.live)?2*f.targetduration:2,i=AE(e,h);if(t>0&&(t<=r||i))return void(n.paused||this._trySkipBufferHole(i))}const p=s.detectStallWithCurrentTimeMs,m=self.performance.now(),g=this.waiting;let v=this.stalled;if(null===v){if(!(g>0&&m-g<p))return void(this.stalled=m);v=this.stalled=g}const y=m-v;if(!a&&(y>=p||g)&&this.hls){var b;if("ended"===(null==(b=this.mediaSource)?void 0:b.readyState)&&(null==f||!f.live)&&Math.abs(e-((null==f?void 0:f.edge)||0))<1){if(this.ended)return;return this.ended=e||1,void this.hls.trigger(Ou.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media||!this.hls)return}const E=Rp.bufferInfo(n,e,s.maxBufferHole);this._tryFixBufferStall(E,y,e)}stallResolved(e){const t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){const r=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(r)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(Ou.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var r;const i=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(r=this.buffered.audio)&&r.length&&i&&i.length>1&&e>i.end(0)){const r=Rp.bufferedInfo(Rp.timeRangesToArray(this.buffered.audio),e,0);if(r.len>1&&t>=r.start){const r=Rp.timeRangesToArray(i),s=Rp.bufferedInfo(r,t,0).bufferedIndex;if(s>-1&&s<r.length-1){const t=Rp.bufferedInfo(r,e,0).bufferedIndex,i=r[s].end,n=r[s+1].start;if((-1===t||t>s)&&n-i<1&&e-i<2){const r=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${i} -> ${n} buffered index: ${t}`);this.warn(r.message),this.media.currentTime+=1e-6;let s=AE(e,this.fragmentTracker);s&&"fragment"in s?s=s.fragment:s||(s=void 0);const a=Rp.bufferInfo(this.media,e,0);this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:r,reason:r.message,frag:s,buffer:a.len,bufferInfo:a})}}}}}_tryFixBufferStall(e,t,r){var i,s;const{fragmentTracker:n,media:a}=this,o=null==(i=this.hls)?void 0:i.config;if(!a||!n||!o)return;const l=null==(s=this.hls)?void 0:s.latestLevelDetails,c=AE(r,n);if(c||null!=l&&l.live&&r<l.fragmentStart){if(this._trySkipBufferHole(c)||!this.media)return}const d=e.buffered,u=this.adjacentTraversal(e,r);(d&&d.length>1&&e.len>o.maxBufferHole||e.nextStart&&(e.nextStart-r<o.maxBufferHole||u))&&(t>1e3*o.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){const r=this.fragmentTracker,i=e.nextStart;if(r&&i){const e=r.getFragAtPos(t,Bu),s=r.getFragAtPos(i,Bu);if(e&&s)return s.sn-e.sn<2}return!1}_reportStall(e){const{hls:t,media:r,stallReported:i,stalled:s}=this;if(!i&&null!==s&&r&&t){this.stallReported=!0;const i=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${Pf(e)})`);this.warn(i.message),t.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len,bufferInfo:e,stalled:{start:s}})}}_trySkipBufferHole(e){var t;const{fragmentTracker:r,media:i}=this,s=null==(t=this.hls)?void 0:t.config;if(!i||!r||!s)return 0;const n=i.currentTime,a=Rp.bufferInfo(i,n,0),o=n<a.start?a.start:a.nextStart;if(o&&this.hls){const t=a.len<=s.maxBufferHole,c=a.len>0&&a.len<1&&i.readyState<3,d=o-n;if(d>0&&(t||c)){if(d>s.maxBufferHole){let t=!1;if(0===n){const e=r.getAppendedFrag(0,Bu);e&&o<e.end&&(t=!0)}if(!t&&e){var l;if(null==(l=this.hls.loadLevelObj)||!l.details)return 0;if(TE(this.hls.inFlightFragments,o))return 0;let t=!1,i=e.end;for(;i<o;){const e=AE(i,r);if(!e){t=!0;break}i+=e.duration}if(t)return 0}}const t=Math.max(o+.05,n+.1);if(this.warn(`skipping hole, adjusting currentTime from ${n} to ${t}`),this.moved=!0,i.currentTime=t,null==e||!e.gap){const r=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${t}`),i={type:Du.MEDIA_ERROR,details:_u.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:r,reason:r.message,buffer:a.len,bufferInfo:a};e&&("fragment"in e?i.part=e:i.frag=e),this.hls.trigger(Ou.ERROR,i)}return t}}return 0}_tryNudgeBuffer(e){const{hls:t,media:r,nudgeRetry:i}=this,s=null==t?void 0:t.config;if(!r||!s)return 0;const n=r.currentTime;if(this.nudgeRetry++,i<s.nudgeMaxRetry){const a=n+(i+1)*s.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);this.warn(o.message),r.currentTime=a,t.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1,buffer:e.len,bufferInfo:e})}else{const r=new Error(`Playhead still not moving while enough data buffered @${n} after ${s.nudgeMaxRetry} nudges`);this.error(r.message),t.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.BUFFER_STALLED_ERROR,error:r,fatal:!0,buffer:e.len,bufferInfo:e})}}}function TE(e,t){const r=xE(e.main);if(r&&r.start<=t)return r;const i=xE(e.audio);return i&&i.start<=t?i:null}function xE(e){if(!e)return null;switch(e.state){case Xm:case qm:case ig:case sg:return null}return e.frag}function AE(e,t){return t.getAppendedFrag(e,Bu)||t.getPartialFragment(e)}function kE(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function LE(e,t,r,i,s){let n=new e(t,r,"");try{n.value=i,s&&(n.type=s)}catch(a){n=new e(t,r,Pf(s?Yu({type:s},i):i))}return n}const IE=(()=>{const e=kE();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class RE{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(Ou.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Ou.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Ou.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){var r;this.media=t.media,!1===(null==(r=t.overrides)?void 0:r.cueRemoval)&&(this.removeCues=!1)}onMediaAttached(){var e;const t=null==(e=this.hls)?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null;!!t.transferMedia||(this.id3Track&&(this.removeCues&&Zy(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const r=e[t];if("metadata"===r.kind&&"id3"===r.label)return Xy(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:r,enableID3MetadataCues:i}=this.hls.config;if(!r&&!i)return;const{samples:s}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const n=kE();if(n)for(let e=0;e<s.length;e++){const t=s[e].type;if(t===Fg.emsg&&!r||!i)continue;const a=_g(s[e].data),o=s[e].pts;let l=o+s[e].duration;l>IE&&(l=IE);l-o<=0&&(l=o+.25);for(let e=0;e<a.length;e++){const r=a[e];if(!Og(r)){this.updateId3CueEnds(o,t);const e=LE(n,o,l,r,t);e&&this.id3Track.addCue(e)}}}}updateId3CueEnds(e,t){var r;const i=null==(r=this.id3Track)?void 0:r.cues;if(i)for(let r=i.length;r--;){const s=i[r];s.type===t&&s.startTime<e&&s.endTime===IE&&(s.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:i}){const{id3Track:s,hls:n}=this;if(!n)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:o}}=n;if(s&&(a||o)){let e;e="audio"===i?e=>e.type===Fg.audioId3&&o:"video"===i?e=>e.type===Fg.emsg&&a:e=>e.type===Fg.audioId3&&o||e.type===Fg.emsg&&a,Jy(s,t,r,e)}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;const{assetPlayerId:r,timelineOffset:i,enableDateRangeMetadataCues:s,interstitialsController:n}=this.hls.config;if(!s)return;const a=kE();if(r&&i&&!n){const{fragmentStart:t,fragmentEnd:i}=e;let s=this.assetCue;s?(s.startTime=t,s.endTime=i):a&&(s=this.assetCue=LE(a,t,i,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),s&&(s.id=r,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(s),s.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:o}=this,{dateRanges:l}=e,c=Object.keys(l);let d=this.dateRangeCuesAppended;var u;if(o&&t)if(null!=(u=o.cues)&&u.length){const e=Object.keys(d).filter(e=>!c.includes(e));for(let t=e.length;t--;){var h;const r=e[t],i=null==(h=d[r])?void 0:h.cues;delete d[r],i&&Object.keys(i).forEach(e=>{const t=i[e];if(t){t.removeEventListener("enter",this.onEventCueEnter);try{o.removeCue(t)}catch(e){}}})}}else d=this.dateRangeCuesAppended={};const f=e.fragments[e.fragments.length-1];if(0!==c.length&&Ru(null==f?void 0:f.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let e=0;e<c.length;e++){const t=c[e],r=l[t],i=r.startTime,s=d[t],o=(null==s?void 0:s.cues)||{};let u=(null==s?void 0:s.durationKnown)||!1,h=IE;const{duration:f,endDate:p}=r;if(p&&null!==f)h=i+f,u=!0;else if(r.endOnNext&&!u){const e=c.reduce((e,t)=>{if(t!==r.id){const i=l[t];if(i.class===r.class&&i.startDate>r.startDate&&(!e||r.startDate<e.startDate))return i}return e},null);e&&(h=e.startTime,u=!0)}const m=Object.keys(r.attr);for(let e=0;e<m.length;e++){const l=m[e];if(!$p(l))continue;const c=o[l];if(c)!u||null!=s&&s.durationKnown?Math.abs(c.startTime-i)>.01&&(c.startTime=i,c.endTime=h):c.endTime=h;else if(a){let e=r.attr[l];Bp(l)&&(e=nh(e));const s=LE(a,i,h,{key:l,data:e},Fg.dateRange);s&&(s.id=t,this.id3Track.addCue(s),o[l]=s,n&&("X-ASSET-LIST"!==l&&"X-ASSET-URL"!==l||s.addEventListener("enter",this.onEventCueEnter)))}}d[t]={cues:o,dateRange:r,durationKnown:u}}}}}class PE{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:e}=this,t=this.levelDetails;if(!e||!t)return;this.currentTime=e.currentTime;const r=this.computeLatency();if(null===r)return;this._latency=r;const{lowLatencyMode:i,maxLiveSyncPlaybackRate:s}=this.config;if(!i||1===s||!t.live)return;const n=this.targetLatency;if(null===n)return;const a=r-n;if(a<Math.min(this.maxLatency,n+t.targetduration)&&a>.05&&this.forwardBufferLength>1){const t=Math.min(2,Math.max(1,s)),r=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20,i=Math.min(t,Math.max(1,r));this.changeMediaPlaybackRate(e,i)}else 1!==e.playbackRate&&0!==e.playbackRate&&this.changeMediaPlaybackRate(e,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(void 0!==e.liveMaxLatencyDuration)return e.liveMaxLatencyDuration;const t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const e=this.levelDetails;if(null===e||null===this.hls)return null;const{holdBack:t,partHoldBack:r,targetduration:i}=e,{liveSyncDuration:s,liveSyncDurationCount:n,lowLatencyMode:a}=this.config,o=this.hls.userConfig;let l=a&&r||t;(this._targetLatencyUpdated||o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==s?s:n*i);const c=i;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;const r=this.levelDetails;if(null===r)return null;const i=r.edge,s=e-t-this.edgeStalled,n=i-r.totalduration,a=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(n,s),a)}get drift(){const e=this.levelDetails;return null===e?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(null===e)return 0;const t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;const r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Ou.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Ou.ERROR,this.onError,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,t){var r;t.details===_u.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(r=this.levelDetails)&&r.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var r,i;e.playbackRate!==t&&(null==(r=this.hls)||r.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${null==(i=this.targetLatency)?void 0:i.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){const e=this.levelDetails;return null===e?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}class CE extends Bv{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Ou.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Ou.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Ou.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Ou.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const r=this.hls.config.preferManagedMediaSource,i=[],s={},n={};let a=!1,o=!1,l=!1;t.levels.forEach(e=>{const t=e.attrs;let{audioCodec:c,videoCodec:d}=e;c&&(e.audioCodec=c=of(c,r)||void 0),d&&(d=e.videoCodec=function(e){const t=e.split(",");for(let e=0;e<t.length;e++){const r=t[e].split(".");r.length>2&&"avc1"===r[0]&&(t[e]=`avc1.${parseInt(r[1]).toString(16)}${("000"+parseInt(r[2]).toString(16)).slice(-4)}`)}return t.join(",")}(d));const{width:u,height:h,unknownCodecs:f}=e,p=(null==f?void 0:f.length)||0;if(a||(a=!(!u||!h)),o||(o=!!d),l||(l=!!c),p||c&&!this.isAudioSupported(c)||d&&!this.isVideoSupported(d))return void this.log(`Some or all CODECS not supported "${t.CODECS}"`);const{CODECS:m,"FRAME-RATE":g,"HDCP-LEVEL":v,"PATHWAY-ID":y,RESOLUTION:b,"VIDEO-RANGE":E}=t,w=`${`${y||"."}-`}${e.bitrate}-${b}-${g}-${m}-${E}-${v}`;if(s[w])if(s[w].uri===e.url||e.attrs["PATHWAY-ID"])s[w].addGroupId("audio",t.AUDIO),s[w].addGroupId("text",t.SUBTITLES);else{const t=n[w]+=1;e.attrs["PATHWAY-ID"]=new Array(t+1).join(".");const r=this.createLevel(e);s[w]=r,i.push(r)}else{const t=this.createLevel(e);s[w]=t,n[w]=1,i.push(t)}}),this.filterAndSortMediaOptions(i,t,a,o,l)}createLevel(e){const t=new Lf(e),r=e.supplemental;if(null!=r&&r.videoCodec&&!this.isVideoSupported(r.videoCodec)){const e=new Error(`SUPPLEMENTAL-CODECS not supported "${r.videoCodec}"`);this.log(e.message),t.supportedResult=mf(e,[])}return t}isAudioSupported(e){return Jh(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Jh(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,r,i,s){var n;let a=[],o=[],l=e;const c=(null==(n=t.stats)?void 0:n.parsing)||{};if((r||i)&&s&&(l=l.filter(({videoCodec:e,videoRange:t,width:r,height:i})=>{return(!!e||!(!r||!i))&&(!!(s=t)&&wf.indexOf(s)>-1);var s})),0===l.length)return Promise.resolve().then(()=>{if(this.hls){let e="no level with compatible codecs found in manifest",r=e;t.levels.length&&(r=`one or more CODECS in variant not supported: ${Pf(t.levels.map(e=>e.attrs.CODECS).filter((e,t,r)=>r.indexOf(e)===t))}`,this.warn(r),e+=` (${r})`);const i=new Error(e);this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:i,reason:r})}}),void(c.end=performance.now());t.audioTracks&&(a=t.audioTracks.filter(e=>!e.audioCodec||this.isAudioSupported(e.audioCodec)),DE(a)),t.subtitles&&(o=t.subtitles,DE(o));const d=l.slice(0);l.sort((e,t)=>{if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return wf.indexOf(e.videoRange)-wf.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){const r=rf(e.videoCodec),i=rf(t.videoCodec);if(r!==i)return i-r}if(e.uri===t.uri&&e.codecSet!==t.codecSet){const r=sf(e.codecSet),i=sf(t.codecSet);if(r!==i)return i-r}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});let u=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length))for(let e=0;e<d.length;e++)if(d[e].pathwayId===l[0].pathwayId){u=d[e];break}this._levels=l;for(let e=0;e<l.length;e++)if(l[e]===u){var h;this._firstLevel=e;const t=u.bitrate,r=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${t}`),void 0===(null==(h=this.hls.userConfig)?void 0:h.abrEwmaDefaultEstimate)){const e=Math.min(t,this.hls.config.abrEwmaDefaultEstimateMax);e>r&&r===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=e)}break}const f=s&&!i,p=this.hls.config,m=!(!p.audioStreamController||!p.audioTrackController),g={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:s,video:i,altAudio:m&&!f&&a.some(e=>!!e.url)};c.end=performance.now(),this.hls.trigger(Ou.MANIFEST_PARSED,g)}get levels(){return 0===this._levels.length?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(0===t.length)return;if(e<0||e>=t.length){const r=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}const r=this.currentLevelIndex,i=this.currentLevel,s=i?i.attrs["PATHWAY-ID"]:void 0,n=t[e],a=n.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=n,r===e&&i&&s===a)return;this.log(`Switching to level ${e} (${n.height?n.height+"p ":""}${n.videoRange?n.videoRange+" ":""}${n.codecSet?n.codecSet+" ":""}@${n.bitrate})${a?" with Pathway "+a:""} from level ${r}${s?" with Pathway "+s:""}`);const o={level:e,attrs:n.attrs,details:n.details,bitrate:n.bitrate,averageBitrate:n.averageBitrate,maxBitrate:n.maxBitrate,realBitrate:n.realBitrate,width:n.width,height:n.height,codecSet:n.codecSet,audioCodec:n.audioCodec,videoCodec:n.videoCodec,audioGroups:n.audioGroups,subtitleGroups:n.subtitleGroups,loaded:n.loaded,loadError:n.loadError,fragmentError:n.fragmentError,name:n.name,id:n.id,uri:n.uri,url:n.url,urlId:0,audioGroupIds:n.audioGroupIds,textGroupIds:n.textGroupIds};this.hls.trigger(Ou.LEVEL_SWITCHING,o);const l=n.details;if(!l||l.live){const e=this.switchParams(n.uri,null==i?void 0:i.details,l);this.loadPlaylist(e)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(void 0===this._startLevel){const e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const t=this.steering.pathways(),r=e.filter(e=>-1!==t.indexOf(e));if(e.length<1)return void this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);this.steering.pathwayPriority=r}}onError(e,t){!t.fatal&&t.context&&t.context.type===Nu&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(void 0!==t&&t.type===Bu){const e=t.elementaryStreams;if(!Object.keys(e).some(t=>!!e[t]))return;const r=this._levels[t.level];null!=r&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(e,t){var r;const{level:i,details:s}=t,n=t.levelInfo;var a;if(!n)return this.warn(`Invalid level index ${i}`),void(null!=(a=t.deliveryDirectives)&&a.skip&&(s.deltaUpdateFailed=!0));if(n===this.currentLevel||t.withoutMultiVariant){0===n.fragmentError&&(n.loadError=0);let e=n.details;e===t.details&&e.advanced&&(e=void 0),this.playlistLoaded(i,t,e)}else null!=(r=t.deliveryDirectives)&&r.skip&&(s.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const r=this.getUrlWithDirectives(e.uri,t),i=this.currentLevelIndex,s=e.attrs["PATHWAY-ID"],n=e.details,a=null==n?void 0:n.age;this.log(`Loading level index ${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${s?" Pathway "+s:""}${a&&n.live?" age "+a.toFixed(1)+(n.type&&" "+n.type||""):""} ${r}`),this.hls.trigger(Ou.LEVEL_LOADING,{url:r,level:i,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(1===this._levels.length)return;const r=this._levels.filter((t,r)=>r!==e||(this.steering&&this.steering.removeLevel(t),t===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,t.details&&t.details.fragments.forEach(e=>e.level=-1)),!1));$m(r),this._levels=r,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const i=r.length-1;this._firstLevel=Math.min(this._firstLevel,i),this._startLevel&&(this._startLevel=Math.min(this._startLevel,i)),this.hls.trigger(Ou.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(Ou.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function DE(e){const t={};e.forEach(e=>{const r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++})}function _E(){return self.SourceBuffer||self.WebKitSourceBuffer}function OE(){if(!th())return!1;const e=_E();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}class ME extends og{constructor(e,t,r){super(e,t,r,"stream-controller",Bu),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const e=this.media,t=e?e.currentTime:null;if(null===t||!Ru(t))return;if(this.log(`Media seeked to ${t.toFixed(3)}`),!this.getBufferedFrag(t))return;const r=this.getFwdBufferInfoAtPos(e,t,Bu,0);null!==r&&0!==r.len?this.tick():this.warn(`Main forward buffer length at ${t} on "seeked" event ${r?r.len:"empty"})`)},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ou.LEVEL_LOADING,this.onLevelLoading,this),e.on(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Ou.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(Ou.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Ou.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(Ou.BUFFER_CREATED,this.onBufferCreated,this),e.on(Ou.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Ou.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Ou.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(Ou.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Ou.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(Ou.BUFFER_CREATED,this.onBufferCreated,this),e.off(Ou.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Ou.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){const{lastCurrentTime:r,hls:i}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let e=i.startLevel;-1===e&&(i.config.testBandwidth&&this.levels.length>1?(e=0,this.bitrateTest=!0):e=i.firstAutoLevel),i.nextLoadLevel=e,this.level=i.loadLevel,this._hasEnoughToStart=!!t}r>0&&-1===e&&!t&&(this.log(`Override startPosition with lastCurrentTime @${r.toFixed(3)}`),e=r),this.state=Xm,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=qm}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case ag:{const{levels:e,level:t}=this,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r&&!this.waitForLive(r))){if(this.waitForCdnTuneIn(i))break;this.state=Xm;break}if(this.hls.nextLoadLevel!==this.level){this.state=Xm;break}break}case Jm:this.checkRetryDate()}this.state===Xm&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),null!=(e=this.media)&&e.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:r,media:i}=this;if(null===t||!i&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;const s=this.buffering?e.nextLoadLevel:e.loadLevel;if(null==r||!r[s])return;const n=r[s],a=this.getMainFwdBufferInfo();if(null===a)return;const o=this.getLevelDetails();if(o&&this._streamEnded(a,o)){const e={};return 2===this.altAudio&&(e.type="video"),this.hls.trigger(Ou.BUFFER_EOS,e),void(this.state=ig)}if(!this.buffering)return;e.loadLevel!==s&&-1===e.manualLevel&&this.log(`Adapting to level ${s} from level ${this.level}`),this.level=e.nextLoadLevel=s;const l=n.details;if(!l||this.state===ag||this.waitForLive(n))return this.level=s,this.state=ag,void(this.startFragRequested=!1);const c=a.len,d=this.getMaxBufferLength(n.maxBitrate);if(c>=d)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const u=this.backtrackFragment?this.backtrackFragment.start:a.end;let h=this.getNextFragment(u,l);if(this.couldBacktrack&&!this.fragPrevious&&h&&Eh(h)&&this.fragmentTracker.getState(h)!==dp){var f;const e=(null!=(f=this.backtrackFragment)?f:h).sn-l.startSN,t=l.fragments[e-1];t&&h.cc===t.cc&&(h=t,this.fragmentTracker.removeFragment(t))}else this.backtrackFragment&&a.len&&(this.backtrackFragment=null);if(h&&this.isLoopLoading(h,u)){if(!h.gap){const e=this.audioOnly&&!this.altAudio?gh:vh,t=(e===vh?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,Bu)}h=this.getNextFragmentLoopLoading(h,l,a,Bu,d)}h&&(!h.initSegment||h.initSegment.data||this.bitrateTest||(h=h.initSegment),this.loadFragment(h,n,u))}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);i===op||i===cp?Eh(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,r):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,Bu)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(null!=t&&t.readyState){let r;const i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);const s=this.getLevelDetails();if(null!=s&&s.live){const e=this.getMainFwdBufferInfo();if(!e||e.len<2*s.targetduration)return}if(!t.paused&&e){const t=e[this.hls.nextLoadLevel],i=this.fragLastKbps;r=i&&this.fragCurrent?this.fragCurrent.duration*t.maxBitrate/(1e3*i)+1:0}else r=0;const n=this.getBufferedFrag(t.currentTime+r);if(n){const e=this.followingBufferedFrag(n);if(e){this.abortCurrentFrag();const t=e.maxStartPTS?e.maxStartPTS:e.start,r=e.duration,i=Math.max(n.end,t+Math.min(Math.max(r-this.config.maxFragLookUpTolerance,r*(this.couldBacktrack?.5:.125)),r*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(i,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case Qm:case Zm:case Jm:case tg:case rg:this.state=Xm}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,2===this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const r=t.media;Wm(r,"playing",this.onMediaPlaying),Wm(r,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:r}=this;r&&(Ym(r,"playing",this.onMediaPlaying),Ym(r,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t);!!t.transferMedia||(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(Ou.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,t){let r=!1,i=!1;for(let e=0;e<t.levels.length;e++){const s=t.levels[e].audioCodec;s&&(r=r||-1!==s.indexOf("mp4a.40.2"),i=i||-1!==s.indexOf("mp4a.40.5"))}this.audioCodecSwitch=r&&i&&!function(){var e;const t=_E();return"function"==typeof(null==t||null==(e=t.prototype)?void 0:e.changeType)}(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:r}=this;if(!r||this.state!==Xm)return;const i=t.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=ag)}onLevelLoaded(e,t){var r;const{levels:i,startFragRequested:s}=this,n=t.level,a=t.details,o=a.totalduration;if(!i)return void this.warn(`Levels were reset while loading level ${n}`);this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const l=t.levelInfo,c=this.fragCurrent;!c||this.state!==Zm&&this.state!==Jm||c.level!==t.level&&c.loader&&this.abortCurrentFrag();let d=0;if(a.live||null!=(r=l.details)&&r.live){var u;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;d=this.alignPlaylists(a,l.details,null==(u=this.levelLastLoaded)?void 0:u.details)}if(l.details=a,this.levelLastLoaded=l,s||this.setStartPosition(a,d),this.hls.trigger(Ou.LEVEL_UPDATED,{details:a,level:n}),this.state===ag){if(this.waitForCdnTuneIn(a))return;this.state=Xm}s&&a.live&&this.synchronizeToLiveEdge(a),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:r}=this;if(!r)return;const i=this.hls.liveSyncPosition,s=this.getLoadPosition(),n=e.fragmentStart,a=e.edge,o=s>=n-t.maxFragLookUpTolerance&&s<=a;if(null!==i&&r.duration>i&&(s<i||!o)){const n=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!o&&r.readyState<4||s<a-n)&&(this._hasEnoughToStart||(this.nextLoadPosition=i),r.readyState))if(this.warn(`Playback: ${s.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : ${i.toFixed(3)}`),"buffered"===this.config.liveSyncMode){var l;const e=Rp.bufferInfo(r,i,0);if(null==(l=e.buffered)||!l.length)return void(r.currentTime=i);if(e.start<=s)return void(r.currentTime=i);const{nextStart:t}=Rp.bufferedInfo(e.buffered,s,0);t&&(r.currentTime=t)}else r.currentTime=i}}_handleFragmentLoadProgress(e){var t;const r=e.frag,{part:i,payload:s}=e,{levels:n}=this;if(!n)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);const a=n[r.level];if(!a)return void this.warn(`Level ${r.level} not found on progress`);const o=a.details;if(!o)return this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),void this.fragmentTracker.removeFragment(r);const l=a.videoCodec,c=o.PTSKnown||!o.live,d=null==(t=r.initSegment)?void 0:t.data,u=this._getAudioCodec(a),h=this.transmuxer=this.transmuxer||new $v(this.hls,Bu,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,p=-1!==f,m=new Lp(r.level,r.sn,r.stats.chunkCount,s.byteLength,f,p),g=this.initPTS[r.cc];h.push(s,d,u,l,r,i,o.totalduration,c,m,g)}onAudioTrackSwitching(e,t){const r=this.hls,i=0!==this.altAudio;if($f(t.url,r))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const e=this.fragCurrent;e&&(this.log("Switching to main audio track, cancel main fragment load"),e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(i)return this.altAudio=0,this.fragmentTracker.removeAllFragments(),r.once(Ou.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(Ou.AUDIO_TRACK_SWITCHED,t)}),void r.trigger(Ou.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});r.trigger(Ou.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const r=$f(t.url,this.hls);if(r){const e=this.videoBuffer;e&&this.mediaBuffer!==e&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=e)}this.altAudio=r?2:0,this.tick()}onBufferCreated(e,t){const r=t.tracks;let i,s,n=!1;for(const e in r){const t=r[e];if("main"===t.id){if(s=e,i=t,"video"===e){const t=r[e];t&&(this.videoBuffer=t.buffer)}}else n=!0}n&&i?(this.log(`Alternate track found, use ${s}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:r,part:i}=t,s=r.type===Bu;if(s){if(this.fragContextChanged(r))return this.warn(`Fragment ${r.sn}${i?" p: "+i.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===rg&&(this.state=Xm));const e=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*e.total/(e.buffering.end-e.loading.first)),Eh(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}const n=this.media;n&&(!this._hasEnoughToStart&&Rp.getBuffered(n).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),s&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var r;if(t.fatal)this.state=sg;else switch(t.details){case _u.FRAG_GAP:case _u.FRAG_PARSING_ERROR:case _u.FRAG_DECRYPT_ERROR:case _u.FRAG_LOAD_ERROR:case _u.FRAG_LOAD_TIMEOUT:case _u.KEY_LOAD_ERROR:case _u.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Bu,t);break;case _u.LEVEL_LOAD_ERROR:case _u.LEVEL_LOAD_TIMEOUT:case _u.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==ag||(null==(r=t.context)?void 0:r.type)!==Nu||(this.state=Xm);break;case _u.BUFFER_ADD_CODEC_ERROR:case _u.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case _u.BUFFER_FULL_ERROR:if("main"!==t.parent)return;if(this.reduceLengthAndFlushBuffer(t)){!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}break;case _u.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onFragLoadEmergencyAborted(){this.state=Xm,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==gh||!this.altAudio){const e=(t===vh?this.videoBuffer:this.mediaBuffer)||this.media;e&&(this.afterBufferFlushed(e,t,Bu),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void this.log(`could not seek to ${r}, already seeking at ${t}`);const i=this.timelineOffset;i&&r&&(r+=i);const s=this.getLevelDetails(),n=Rp.getBuffered(e),a=n.length?n.start(0):0,o=a-r,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||o>0&&(o<l||this.loadingParts&&o<2*((null==s?void 0:s.partTarget)||0)))&&(this.log(`adjusting start position by ${o} to match buffer start`),r+=o,this.startPosition=r),t<r&&(this.log(`seek to target start position ${r} from current time ${t} buffer start ${a}`),e.currentTime=r)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(e=>{const{hls:r}=this,i=null==e?void 0:e.frag;if(!i||this.fragContextChanged(i))return;t.fragmentError=0,this.state=Xm,this.startFragRequested=!1,this.bitrateTest=!1;const s=i.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now(),r.trigger(Ou.FRAG_LOADED,e),i.bitrateTest=!1}).catch(t=>{this.state!==qm&&this.state!==sg&&(this.warn(t),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:r}=this,{remuxResult:i,chunkMeta:s}=e,n=this.getCurrentContext(s);if(!n)return void this.resetWhenMissingContext(s);const{frag:a,part:o,level:l}=n,{video:c,text:d,id3:u,initSegment:h}=i,{details:f}=l,p=this.altAudio?void 0:i.audio;if(this.fragContextChanged(a))this.fragmentTracker.removeFragment(a);else{if(this.state=tg,h){const e=h.tracks;if(e){const i=a.initSegment||a;if(this.unhandledEncryptionError(h,a))return;this._bufferInitSegment(l,e,i,s),r.trigger(Ou.FRAG_PARSING_INIT_SEGMENT,{frag:i,id:t,tracks:e})}const i=h.initPTS,n=h.timescale,o=this.initPTS[a.cc];if(Ru(i)&&(!o||o.baseTime!==i||o.timescale!==n)){const e=h.trackId;this.initPTS[a.cc]={baseTime:i,timescale:n,trackId:e},r.trigger(Ou.INIT_PTS_FOUND,{frag:a,id:t,initPTS:i,timescale:n,trackId:e})}}if(c&&f){p&&"audiovideo"===c.type&&this.logMuxedErr(a);const e=f.fragments[a.sn-1-f.startSN],t=a.sn===f.startSN,r=!e||a.cc>e.cc;if(!1!==i.independent){const{startPTS:e,endPTS:i,startDTS:n,endDTS:l}=c;if(o)o.elementaryStreams[c.type]={startPTS:e,endPTS:i,startDTS:n,endDTS:l};else if(c.firstKeyFrame&&c.independent&&1===s.id&&!r&&(this.couldBacktrack=!0),c.dropped&&c.independent){const s=this.getMainFwdBufferInfo(),n=(s?s.end:this.getLoadPosition())+this.config.maxBufferHole,o=c.firstKeyFramePTS?c.firstKeyFramePTS:e;if(!t&&n<o-this.config.maxBufferHole&&!r)return void this.backtrack(a);r&&(a.gap=!0),a.setElementaryStreamInfo(c.type,a.start,i,a.start,l,!0)}else t&&e-(f.appliedTimelineOffset||0)>2&&(a.gap=!0);a.setElementaryStreamInfo(c.type,e,i,n,l),this.backtrackFragment&&(this.backtrackFragment=a),this.bufferFragmentData(c,a,o,s,t||r)}else{if(!t&&!r)return void this.backtrack(a);a.gap=!0}}if(p){const{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=p;o&&(o.elementaryStreams[gh]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),a.setElementaryStreamInfo(gh,e,t,r,i),this.bufferFragmentData(p,a,o,s)}if(f&&null!=u&&u.samples.length){const e={id:t,frag:a,details:f,samples:u.samples};r.trigger(Ou.FRAG_PARSING_METADATA,e)}if(f&&d){const e={id:t,frag:a,details:f,samples:d.samples};r.trigger(Ou.FRAG_PARSING_USERDATA,e)}}}logMuxedErr(e){this.warn(`${Eh(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,r,i){if(this.state!==tg)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(r));const{audio:s,video:n,audiovideo:a}=t;if(s){const r=e.audioCodec;let i=lf(s.codec,r);"mp4a"===i&&(i="mp4a.40.5");const n=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){i&&(i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");const e=s.metadata;e&&"channelCount"in e&&1!==(e.channelCount||1)&&-1===n.indexOf("firefox")&&(i="mp4a.40.5")}i&&-1!==i.indexOf("mp4a.40.5")&&-1!==n.indexOf("android")&&"audio/mpeg"!==s.container&&(i="mp4a.40.2",this.log(`Android: force audio codec to ${i}`)),r&&r!==i&&this.log(`Swapping manifest audio codec "${r}" for "${i}"`),s.levelCodec=i,s.id=Bu,this.log(`Init audio buffer, container:${s.container}, codecs[selected/level/parsed]=[${i||""}/${r||""}/${s.codec}]`),delete t.audiovideo}if(n){n.levelCodec=e.videoCodec,n.id=Bu;const r=n.codec;if(4===(null==r?void 0:r.length))switch(r){case"hvc1":case"hev1":n.codec="hvc1.1.6.L120.90";break;case"av01":n.codec="av01.0.04M.08";break;case"avc1":n.codec="avc1.42e01e"}this.log(`Init video buffer, container:${n.container}, codecs[level/parsed]=[${e.videoCodec||""}/${r}]${n.codec!==r?" parsed-corrected="+n.codec:""}${n.supplemental?" supplemental="+n.supplemental:""}`),delete t.audiovideo}a&&(this.log(`Init audiovideo buffer, container:${a.container}, codecs[level/parsed]=[${e.codecs}/${a.codec}]`),delete t.video,delete t.audio);const o=Object.keys(t);if(o.length){if(this.hls.trigger(Ou.BUFFER_CODECS,t),!this.hls)return;o.forEach(e=>{const s=t[e].initSegment;null!=s&&s.byteLength&&this.hls.trigger(Ou.BUFFER_APPENDING,{type:e,data:s,frag:r,part:null,chunkMeta:i,parent:r.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,Bu)}get maxBufferLength(){const{levels:e,level:t}=this,r=null==e?void 0:e[t];return r?this.getMaxBufferLength(r.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=Xm}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&!1===e.seeking){const r=e.currentTime;if(Rp.isBuffered(e,r)?t=this.getAppendedFrag(r):Rp.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;const e=this.fragPlaying,r=t.level;e&&t.sn===e.sn&&e.level===r||(this.fragPlaying=t,this.hls.trigger(Ou.FRAG_CHANGED,{frag:t}),e&&e.level===r||this.hls.trigger(Ou.LEVEL_SWITCHED,{level:r}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return Ru(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(Ru(t)){const e=this.getLevelDetails(),r=this.currentFrag||(e?Uf(null,e.fragments,t):null);if(r){const e=r.programDateTime;if(null!==e){const i=e+1e3*(t-r.start);return new Date(i)}}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class NE extends Ku{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const r in this.keyIdToKeyInfo){const i=this.keyIdToKeyInfo[r].loader;if(i){var t;if(e&&e!==(null==(t=i.context)?void 0:t.frag.type))return;i.abort()}}}detach(){for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,t=_u.KEY_LOAD_ERROR,r,i,s){return new Ap({type:Du.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:s,error:r,networkDetails:i})}loadClear(e,t,r){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let i=0,s=t.length;i<s;i++){const n=t[i];if(e.cc<=n.cc&&(!Eh(e)||!Eh(n)||e.sn<n.sn)||!r&&i==s-1)return this.emeController.selectKeySystemFormat(n).then(e=>{if(!this.emeController)return;n.setKeyFormat(e);const t=rm(e);return t?this.emeController.getKeySystemAccess([t]):void 0})}if(this.config.requireKeySystemAccessOnStart){const e=sm(this.config);if(e.length)return this.emeController.getKeySystemAccess(e)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,i;t&&e.setKeyFormat(t);const s=e.decryptdata;if(!s){const r=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,_u.KEY_LOAD_ERROR,r))}const n=s.uri;if(!n)return Promise.reject(this.createKeyLoadError(e,_u.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${n}"`)));const a=FE(s);let o=this.keyIdToKeyInfo[a];if(null!=(r=o)&&r.decryptdata.key)return s.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if(this.emeController&&null!=(i=o)&&i.keyLoadPromise){switch(this.emeController.getKeyStatus(o.decryptdata)){case"usable":case"usable-in-future":return o.keyLoadPromise.then(t=>{const{keyInfo:r}=t;return s.key=r.decryptdata.key,{frag:e,keyInfo:r}})}}switch(this.log(`${this.keyIdToKeyInfo[a]?"Rel":"L"}oading${s.keyId?" keyId: "+sh(s.keyId):""} URI: ${s.uri} from ${e.type} ${e.level}`),o=this.keyIdToKeyInfo[a]={decryptdata:s,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},s.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===s.keyFormat?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,_u.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${s.method}"`)))}}loadKeyEME(e,t){const r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i;if(!e.decryptdata.keyId&&null!=(i=t.initSegment)&&i.data){const r=function(e){const t=[];return Uh(e,e=>t.push(e.subarray(8,24))),t}(t.initSegment.data);if(r.length){let t=r[0];t.some(e=>0!==e)?(this.log(`Using keyId found in init segment ${sh(t)}`),cm.setKeyIdForUri(e.decryptdata.uri,t)):(t=cm.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${sh(t)}`)),e.decryptdata.keyId=t}}if(!e.decryptdata.keyId&&!Eh(t))return Promise.resolve(r);const s=this.emeController.loadKey(r);return(e.keyLoadPromise=s.then(t=>(e.mediaKeySessionContext=t,r))).catch(r=>{throw e.keyLoadPromise=null,"data"in r&&(r.data.frag=t),r})}return Promise.resolve(r)}loadKeyHTTP(e,t){const r=this.config,i=new(0,r.loader)(r);return t.keyLoader=e.loader=i,e.keyLoadPromise=new Promise((s,n)=>{const a={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},o=r.keyLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(e,t,r,i)=>{const{frag:a,keyInfo:o}=r,l=FE(o.decryptdata);if(!a.decryptdata||o!==this.keyIdToKeyInfo[l])return n(this.createKeyLoadError(a,_u.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),i));o.decryptdata.key=a.decryptdata.key=new Uint8Array(e.data),a.keyLoader=null,o.loader=null,s({frag:a,keyInfo:o})},onError:(e,r,i,s)=>{this.resetLoader(r),n(this.createKeyLoadError(t,_u.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),i,Yu({url:a.url,data:void 0},e)))},onTimeout:(e,r,i)=>{this.resetLoader(r),n(this.createKeyLoadError(t,_u.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(e,r,i)=>{this.resetLoader(r),n(this.createKeyLoadError(t,_u.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};i.load(a,l,c)})}resetLoader(e){const{frag:t,keyInfo:r,url:i}=e,s=r.loader;t.keyLoader===s&&(t.keyLoader=null,r.loader=null);const n=FE(r.decryptdata)||i;delete this.keyIdToKeyInfo[n],s&&s.destroy()}}function FE(e){if(e.keyFormat!==Jp){const t=e.keyId;if(t)return sh(t)}return e.uri}function $E(e){const{type:t}=e;switch(t){case Fu:return Uu;case $u:return zu;default:return Bu}}function BE(e,t){let r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}class UE{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.LEVEL_LOADING,this.onLevelLoading,this),e.on(Ou.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(Ou.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.LEVEL_LOADING,this.onLevelLoading,this),e.off(Ou.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(Ou.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,r=t.pLoader,i=t.loader,s=new(r||i)(t);return this.loaders[e.type]=s,s}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Mu,url:r,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:r,level:i,pathwayId:s,url:n,deliveryDirectives:a,levelInfo:o}=t;this.load({id:r,level:i,pathwayId:s,responseType:"text",type:Nu,url:n,deliveryDirectives:a,levelOrTrack:o})}onAudioTrackLoading(e,t){const{id:r,groupId:i,url:s,deliveryDirectives:n,track:a}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:Fu,url:s,deliveryDirectives:n,levelOrTrack:a})}onSubtitleTrackLoading(e,t){const{id:r,groupId:i,url:s,deliveryDirectives:n,track:a}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:$u,url:s,deliveryDirectives:n,levelOrTrack:a})}onLevelsUpdated(e,t){const r=this.loaders[Nu];if(r){const e=r.context;e&&!t.levels.some(t=>t===e.levelOrTrack)&&(r.abort(),delete this.loaders[Nu])}}load(e){var t;const r=this.hls.config;let i,s=this.getInternalLoader(e);if(s){const t=this.hls.logger,r=s.context;if(r&&r.levelOrTrack===e.levelOrTrack&&(r.url===e.url||r.deliveryDirectives&&!e.deliveryDirectives))return void(r.url===e.url?t.log(`[playlist-loader]: ignore ${e.url} ongoing request`):t.log(`[playlist-loader]: ignore ${e.url} in favor of ${r.url}`));t.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}if(i=e.type===Mu?r.manifestLoadPolicy.default:Vu({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),Ru(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===Nu&&null!==e.level?t=this.hls.levels[e.level].details:e.type===Fu&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===$u&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){const e=t.partTarget,r=t.targetduration;if(e&&r){const t=1e3*Math.max(3*e,.8*r);i=Vu({},i,{maxTimeToFirstByteMs:Math.min(t,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,i.maxTimeToFirstByteMs)})}}}const n=i.errorRetry||i.timeoutRetry||{},a={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0},o={onSuccess:(e,t,r,i)=>{const s=this.getInternalLoader(r);this.resetInternalLoader(r.type);const n=e.data;t.parsing.start=performance.now(),gm.isMediaPlaylist(n)||r.type!==Mu?this.handleTrackOrLevelPlaylist(e,t,r,i||null,s):this.handleMasterPlaylist(e,t,r,i)},onError:(e,t,r,i)=>{this.handleNetworkError(t,r,!1,e,i)},onTimeout:(e,t,r)=>{this.handleNetworkError(t,r,!0,void 0,e)}};s.load(e,a,o)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:t},forceStartLoad:r}=this.hls;(e||r)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,r,i){const s=this.hls,n=e.data,a=BE(e,r),o=gm.parseMasterPlaylist(n,a);if(o.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);const{contentSteering:l,levels:c,sessionData:d,sessionKeys:u,startTimeOffset:h,variableList:f}=o;this.variableList=f,c.forEach(e=>{const{unknownCodecs:t}=e;if(t){const{preferManagedMediaSource:r}=this.hls.config;let{audioCodec:i,videoCodec:s}=e;for(let n=t.length;n--;){const a=t[n];Jh(a,"audio",r)?(e.audioCodec=i=i?`${i},${a}`:a,Qh.audio[i.substring(0,4)]=2,t.splice(n,1)):Jh(a,"video",r)&&(e.videoCodec=s=s?`${s},${a}`:a,Qh.video[s.substring(0,4)]=2,t.splice(n,1))}}});const{AUDIO:p=[],SUBTITLES:m,"CLOSED-CAPTIONS":g}=gm.parseMasterPlaylistMedia(n,a,o);if(p.length){p.some(e=>!e.url)||!c[0].audioCodec||c[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Fp({}),bitrate:0,url:""}))}s.trigger(Ou.MANIFEST_LOADED,{levels:c,audioTracks:p,subtitles:m,captions:g,contentSteering:l,url:a,stats:t,networkDetails:i,sessionData:d,sessionKeys:u,startTimeOffset:h,variableList:f})}handleTrackOrLevelPlaylist(e,t,r,i,s){const n=this.hls,{id:a,level:o,type:l}=r,c=BE(e,r),d=Ru(o)?o:Ru(a)?a:0,u=$E(r),h=gm.parseLevelPlaylist(e.data,c,d,u,0,this.variableList);if(l===Mu){const e={attrs:new Fp({}),bitrate:0,details:h,name:"",url:c};h.requestScheduled=t.loading.start+Om(h,0),n.trigger(Ou.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:c,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=h,this.handlePlaylistLoaded(h,e,t,r,i,s)}handleManifestParsingError(e,t,r,i,s){this.hls.trigger(Ou.ERROR,{type:Du.NETWORK_ERROR,details:_u.MANIFEST_PARSING_ERROR,fatal:t.type===Mu,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:s})}handleNetworkError(e,t,r=!1,i,s){let n=`A network ${r?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading ${e.type}`;e.type===Nu?n+=`: ${e.level} id: ${e.id}`:e.type!==Fu&&e.type!==$u||(n+=` id: ${e.id} group-id: "${e.groupId}"`);const a=new Error(n);this.hls.logger.warn(`[playlist-loader]: ${n}`);let o=_u.UNKNOWN,l=!1;const c=this.getInternalLoader(e);switch(e.type){case Mu:o=r?_u.MANIFEST_LOAD_TIMEOUT:_u.MANIFEST_LOAD_ERROR,l=!0;break;case Nu:o=r?_u.LEVEL_LOAD_TIMEOUT:_u.LEVEL_LOAD_ERROR,l=!1;break;case Fu:o=r?_u.AUDIO_TRACK_LOAD_TIMEOUT:_u.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case $u:o=r?_u.SUBTITLE_TRACK_LOAD_TIMEOUT:_u.SUBTITLE_LOAD_ERROR,l=!1}c&&this.resetInternalLoader(e.type);const d={type:Du.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:c,context:e,error:a,networkDetails:t,stats:s};if(i){const r=(null==t?void 0:t.url)||e.url;d.response=Yu({url:r,data:void 0},i)}this.hls.trigger(Ou.ERROR,d)}handlePlaylistLoaded(e,t,r,i,s,n){const a=this.hls,{type:o,level:l,levelOrTrack:c,id:d,groupId:u,deliveryDirectives:h}=i,f=BE(t,i),p=$E(i);let m="number"==typeof i.level&&p===Bu?l:void 0;const g=e.playlistParsingError;if(g){if(this.hls.logger.warn(`${g} ${e.url}`),!a.config.ignorePlaylistParsingErrors)return void a.trigger(Ou.ERROR,{type:Du.NETWORK_ERROR,details:_u.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:i,level:m,parent:p,networkDetails:s,stats:r});e.playlistParsingError=null}if(!e.fragments.length){const n=e.playlistParsingError=new Error("No Segments found in Playlist");return void a.trigger(Ou.ERROR,{type:Du.NETWORK_ERROR,details:_u.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:n,reason:n.message,response:t,context:i,level:m,parent:p,networkDetails:s,stats:r})}switch(e.live&&n&&(n.getCacheAge&&(e.ageHeader=n.getCacheAge()||0),n.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case Mu:case Nu:if(m)if(c){if(c!==a.levels[m]){const e=a.levels.indexOf(c);e>-1&&(m=e)}}else m=0;a.trigger(Ou.LEVEL_LOADED,{details:e,levelInfo:c||a.levels[0],level:m||0,id:d||0,stats:r,networkDetails:s,deliveryDirectives:h,withoutMultiVariant:o===Mu});break;case Fu:a.trigger(Ou.AUDIO_TRACK_LOADED,{details:e,track:c,id:d||0,groupId:u||"",stats:r,networkDetails:s,deliveryDirectives:h});break;case $u:a.trigger(Ou.SUBTITLE_TRACK_LOADED,{details:e,track:c,id:d||0,groupId:u||"",stats:r,networkDetails:s,deliveryDirectives:h})}}}class zE{static get version(){return pg}static isMSESupported(){return OE()}static isSupported(){return function(){if(!OE())return!1;const e=th();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(t=>e.isTypeSupported(tf(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(tf(t,"audio"))))}()}static getMediaSource(){return th()}static get Events(){return Ou}static get MetadataSchema(){return Fg}static get ErrorTypes(){return Du}static get ErrorDetails(){return _u}static get DefaultConfig(){return zE.defaultConfig?zE.defaultConfig:bE}static set DefaultConfig(e){zE.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new fg,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const t=this.logger=function(e,t,r){const i=Qu();if("object"==typeof console&&!0===e||"object"==typeof e){const s=["debug","log","info","warn","error"];s.forEach(t=>{i[t]=Zu(t,e,r)});try{i.log(`Debug logs enabled for "${t}" in hls.js version 1.6.15`)}catch(e){return Qu()}s.forEach(t=>{Ju[t]=Zu(t,e)})}else Vu(Ju,i);return i}(e.debug||!1,"Hls instance",e.assetPlayerId),r=this.config=function(e,t,r){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const i=EE(e),s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{const n=`${"level"===e?"playlist":e}LoadPolicy`,a=void 0===t[n],o=[];s.forEach(r=>{const s=`${e}Loading${r}`,l=t[s];if(void 0!==l&&a){o.push(s);const e=i[n].default;switch(t[n]={default:e},r){case"TimeOut":e.maxLoadTimeMs=l,e.maxTimeToFirstByteMs=l;break;case"MaxRetry":e.errorRetry.maxNumRetry=l,e.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":e.errorRetry.retryDelayMs=l,e.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":e.errorRetry.maxRetryDelayMs=l,e.timeoutRetry.maxRetryDelayMs=l}}}),o.length&&r.warn(`hls.js config: "${o.join('", "')}" setting(s) are deprecated, use "${n}": ${Pf(t[n])}`)}),Yu(Yu({},i),t)}(zE.DefaultConfig,e,t);this.userConfig=e,r.progressive&&wE(r,t);const{abrController:i,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=r,l=new a(this),c=this.abrController=new i(this),d=new up(this),u=r.interstitialsController,h=u?this.interstitialsController=new u(this,zE):null,f=this.bufferController=new s(this,d),p=this.capLevelController=new n(this),m=new o(this),g=new UE(this),v=r.contentSteeringController,y=v?new v(this):null,b=this.levelController=new CE(this,y),E=new RE(this),w=new NE(this.config,this.logger),S=this.streamController=new ME(this,d,w),T=this.gapController=new SE(this,d);p.setStreamController(S),m.setStreamController(S);const x=[g,b,S];h&&x.splice(1,0,h),y&&x.splice(1,0,y),this.networkControllers=x;const A=[c,f,T,p,m,E,d];this.audioTrackController=this.createController(r.audioTrackController,x);const k=r.audioStreamController;k&&x.push(this.audioStreamController=new k(this,d,w)),this.subtitleTrackController=this.createController(r.subtitleTrackController,x);const L=r.subtitleStreamController;L&&x.push(this.subtititleStreamController=new L(this,d,w)),this.createController(r.timelineController,A),w.emeController=this.emeController=this.createController(r.emeController,A),this.cmcdController=this.createController(r.cmcdController,A),this.latencyController=this.createController(PE,A),this.coreComponents=A,x.push(l);const I=l.onErrorOut;"function"==typeof I&&this.on(Ou.ERROR,I,l),this.on(Ou.MANIFEST_LOADED,g.onManifestLoaded,g)}createController(e,t){if(e){const r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,i){this._emitter.off(e,t,r,i)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;const r=e===Ou.ERROR;this.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.INTERNAL_EXCEPTION,fatal:r,event:e,error:t}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(Ou.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){const t=new Error(`attachMedia failed: invalid argument (${e})`);return void this.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const t="media"in e,r=t?e.media:e,i=t?e:{media:r};this._media=r,this.trigger(Ou.MEDIA_ATTACHING,i)}detachMedia(){this.logger.log("detachMedia"),this.trigger(Ou.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(Ou.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,r=this._url,i=this._url=ph.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${i}`),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(Ou.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(e,t),this.started&&this.networkControllers);r++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){const e={[Bu]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[Uu]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[zu]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(e){try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){let t=(new Date).getTime();const r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?r:3&r|8).toString(16)});return r}}}()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){(function(e){return Ef.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const r=e.length;for(let i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this;let i;if(i=-1===t&&null!=e&&e.length?e.length-1:t,r)for(let t=i;t--;){const i=e[t].attrs["HDCP-LEVEL"];if(i&&i<=r)return t}return i}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}get interstitialsManager(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){return vf(e,Df(t),navigator.mediaCapabilities)}}zE.defaultConfig=void 0;const GE=({file:e,startTime:s,poster:n,autoplay:o=!0,active:l=!0,visible:c=!0,muted:h=!0})=>{const f=r(null),{isReady:p,prewarm:m,setLowestResolution:g,startBufferBasedUpshift:v}=(({file:e,videoRef:t,autoplay:s=!0,startTime:n,enabled:o=!0,onReady:l,onError:c})=>{const h=r(null),f=r(null),p=r(0),m=r(0),g=r(!1),v=r(!1),[y,b]=a("idle"),[E,w]=a(0),[S,T]=a(!1),[A,k]=a([]),[L,I]=a("auto"),R=()=>{null!=f.current&&(clearTimeout(f.current),f.current=null)},P=(e=1e3)=>{if(null!=f.current)return;const t=p.current;if(t>=5)return b("error"),R(),void(null==c||c(new Error("Max retry reached")));const r=Math.min(15e3,e*Math.pow(2,Math.min(t,4)));b("loading"),console.log(`[HLS] schedule retry #${t+1} in ${r}ms`),f.current=window.setTimeout(()=>{f.current=null,p.current+=1,console.log(`[HLS] retryCount => ${p.current}`),w(e=>e+1)},r)};i(()=>{p.current=0,m.current=0,v.current=!1,T(!1),w(0),b(e?"loading":"idle"),R()},[e]);const C=u(()=>x(void 0,void 0,void 0,function*(){if(e)try{yield fetch(e,{method:"HEAD",mode:"cors",credentials:"omit"})}catch(e){}}),[e]);i(()=>{var r;const i=t.current;if(!i||!e||!o)return void(e&&!o&&(v.current=!1,T(!1),b("idle")));let n=()=>{};try{null===(r=h.current)||void 0===r||r.destroy()}catch(e){}if(h.current=null,v.current=!1,T(!1),b("loading"),zE.isSupported()){g.current=!1;const t=new zE({lowLatencyMode:!1,backBufferLength:0,maxBufferLength:2,maxMaxBufferLength:4,maxBufferSize:2e6,maxBufferHole:.5,startFragPrefetch:!0,capLevelToPlayerSize:!0});h.current=t;const r=()=>{const e=(t.levels||[]).map((e,t)=>{const r=e.height,i=e.width,s=e.bitrate,n=e.name;return{id:t,height:r,width:i,bitrate:s,name:n,label:n||(r?`${r}p`:`Level ${t}`)}});k(e);const r=t.currentLevel;I(null==r||r<0?"auto":r)},a=()=>{v.current||(v.current=!0,T(!0),b("ready"),p.current=0,R(),null==l||l(),s&&i.play().catch(()=>{}))};t.on(zE.Events.MANIFEST_PARSED,()=>{r(),s||_()}),t.on(zE.Events.FRAG_BUFFERED,a),t.on(zE.Events.BUFFER_APPENDED,a),t.on(zE.Events.LEVEL_SWITCHED,(e,t)=>{const r=null==t?void 0:t.level;I(null==r||r<0?"auto":r)}),t.on(zE.Events.ERROR,(e,r)=>{var i,s,n,a,o;const l=500===(null!==(a=null!==(s=null===(i=null==r?void 0:r.response)||void 0===i?void 0:i.code)&&void 0!==s?s:null===(n=null==r?void 0:r.response)||void 0===n?void 0:n.status)&&void 0!==a?a:null===(o=null==r?void 0:r.response)||void 0===o?void 0:o.statusCode);if(r.type!==zE.ErrorTypes.NETWORK_ERROR||r.fatal){if(r.fatal){if(r.type===zE.ErrorTypes.MEDIA_ERROR){if(m.current+=1,m.current<=2){try{t.recoverMediaError()}catch(e){}return void b("loading")}try{t.destroy()}catch(e){}return h.current=null,v.current=!1,T(!1),void P()}if(l){console.warn("[HLS] fatal 500 response - no retry");try{t.destroy()}catch(e){}return h.current=null,v.current=!1,T(!1),R(),b("error"),void(null==c||c(new Error("HTTP 500")))}try{t.destroy()}catch(e){}return h.current=null,v.current=!1,T(!1),void P()}}else{if(l){console.warn("[HLS] 500 response detected - no retry"),b("error");try{t.destroy()}catch(e){}return h.current=null,R(),void(null==c||c(new Error("HTTP 500")))}try{if(p.current>=5){b("error");try{t.destroy()}catch(e){}return h.current=null,void(null==c||c(new Error("Max retry reached")))}p.current+=1,console.log(`[HLS] non-fatal network retry => ${p.current}`),t.startLoad()}catch(e){}}}),t.attachMedia(i),t.loadSource(e),n=()=>{try{t.destroy()}catch(e){}h.current=null}}else if(i.canPlayType("application/vnd.apple.mpegURL")){g.current=!0,i.src!==e&&(i.src=e);const t=()=>{v.current||(v.current=!0,T(!0),b("ready"),p.current=0,R(),null==l||l(),s&&i.play().catch(()=>{}))},r=()=>{if(v.current=!1,T(!1),p.current>=5)return b("error"),void(null==c||c(new Error("Max retry reached")));P()};i.addEventListener("loadedmetadata",t),i.addEventListener("error",r),s&&i.play().catch(()=>{}),n=()=>{i.removeEventListener("loadedmetadata",t),i.removeEventListener("error",r)}}else b("error"),null==c||c(new Error("HLS not supported"));return()=>{n(),R()}},[e,E,s,l,c,t,o]),i(()=>{if(!S)return;if(null==n||n<=0)return;const e=t.current;if(e)try{Math.abs(e.currentTime-n)>.5&&(e.currentTime=n)}catch(e){}},[S,n,t]),i(()=>{const e=t.current;if(!e)return;const r=()=>b("ready"),i=()=>b("ready"),s=()=>{"error"!==y&&b("loading")},n=()=>b("loading"),a=()=>{b("error"),null==c||c()};return e.addEventListener("playing",r),e.addEventListener("canplay",i),e.addEventListener("waiting",s),e.addEventListener("stalled",n),e.addEventListener("error",a),()=>{e.removeEventListener("playing",r),e.removeEventListener("canplay",i),e.removeEventListener("waiting",s),e.removeEventListener("stalled",n),e.removeEventListener("error",a)}},[y,c,t]);const D=u(()=>{const e=h.current;e&&!g.current&&(console.log("Set auto resolution"),e.nextLevel=-1,I("auto"))},[]),_=u(()=>{var e,t;const r=h.current;if(!r)return;const i=r.levels||[];if(i.length){let s=0;for(let r=1;r<i.length;r++)(null!==(e=i[r].height)&&void 0!==e?e:99999)<(null!==(t=i[s].height)&&void 0!==t?t:99999)&&(s=r);r.currentLevel=s}},[]),O=u((e=2)=>{const r=h.current,i=t.current;if(!r||!i||g.current)return()=>{};let s=!1;const n=()=>{if(!s)if(r.autoLevelEnabled)s=!0;else try{i.buffered.length>0&&i.buffered.end(0)-i.currentTime>=e&&(r.nextLevel=-1,I("auto"),s=!0)}catch(e){}};return r.on(zE.Events.FRAG_BUFFERED,n),()=>{r.off(zE.Events.FRAG_BUFFERED,n)}},[t]);return{playbackStatus:y,isReady:S,qualities:A,currentLevel:L,isAutoQuality:d(()=>"auto"===L,[L]),canSetResolution:!g.current&&zE.isSupported(),setResolution:e=>{const t=h.current;if(!t||g.current)return;if("string"==typeof e&&"auto"===e.toLowerCase())return t.currentLevel=-1,void I("auto");const r="number"==typeof e?e:parseInt(e,10);if(!Number.isFinite(r)){const r=A.find(t=>t.label.toLowerCase()===String(e).toLowerCase());return void(r&&(t.currentLevel=r.id,I(r.id)))}const i=[...A].filter(e=>e.height).sort((e,t)=>(t.height||0)-(e.height||0)),s=i.find(e=>(e.height||0)<=r)||i[i.length-1];s&&(t.currentLevel=s.id,I(s.id))},setAutoResolution:D,prewarm:C,setLowestResolution:_,startBufferBasedUpshift:O}})({file:e,videoRef:f,autoplay:o,startTime:s,enabled:o||l});return i(()=>{m()},[m]),t.useEffect(()=>{var e,t;const r=f.current;if(r)if(l)null===(e=r.play)||void 0===e||e.call(r).catch(()=>{});else try{null===(t=r.pause)||void 0===t||t.call(r)}catch(e){}},[l,p]),i(()=>{if(!l)return;g();return v(2)},[l,g,v]),t.createElement("video",{ref:f,playsInline:!0,autoPlay:o,muted:h,poster:Ct(n||""),preload:"metadata",className:"w-full h-full object-cover object-center bg-black",style:{opacity:c&&p?1:0,transition:"opacity 200ms ease-in-out"}})},jE=({view:e})=>t.createElement("div",{className:"absolute",style:{top:8,left:8,borderRadius:"4px",color:"white",overflow:"hidden",fontSize:11}},t.createElement("span",{style:{backgroundColor:"rgba(62,213,69,0.71)",color:"white",padding:4,paddingLeft:9,paddingRight:9,display:"inline-block",lineHeight:1}},"다시보기"),t.createElement("span",{style:{backgroundColor:"rgba(58,58,58,0.52)",color:"white",padding:4,paddingLeft:9,paddingRight:9,display:"inline-block",lineHeight:1}},e," 시청")),HE=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:s,playback:n="hover"})=>{var a,o,l,c,d;const u=t.useRef(null),[h,f]=t.useState(!1),p=t.useRef(null),[m,g]=t.useState(!1),[v,y]=t.useState(!0),[b,E]=t.useState(!1),{boxSize:w}=Lu(r,u),S=e.thumbPath||(null===(o=null===(a=null==e?void 0:e.designInfo)||void 0===a?void 0:a.thumbPath)||void 0===o?void 0:o.preview),T=3===e.status,{API_BASE_URL:x,PLAYER_BASE_URL:A}=gt(),k=`${x}/hls/${null===(l=e.replay)||void 0===l?void 0:l.objectId}`;t.useEffect(()=>{const e=u.current;if(!e)return;const t=new IntersectionObserver(e=>{const t=e[0];E(t.isIntersecting&&t.intersectionRatio>=.5)},{root:null,threshold:[0,.5,1]});return t.observe(e),()=>t.disconnect()},[n]),t.useEffect(()=>{var e;if("undefined"!=typeof window&&window.matchMedia)try{const t=window.matchMedia("(pointer: fine)"),r=()=>y(t.matches);return r(),null===(e=t.addEventListener)||void 0===e||e.call(t,"change",r),()=>{var e;return null===(e=t.removeEventListener)||void 0===e?void 0:e.call(t,"change",r)}}catch(e){}},[n]);const L=()=>{null!=p.current&&(clearTimeout(p.current),p.current=null)},I=()=>{g(!0),L(),f(!1)};t.useEffect(()=>{const e=()=>g(!1);return window.addEventListener("mouseup",e),window.addEventListener("touchend",e),window.addEventListener("pointerup",e),()=>{window.removeEventListener("mouseup",e),window.removeEventListener("touchend",e),window.removeEventListener("pointerup",e)}},[n]);const R="hover"===n&&v,P=Boolean(k&&("autoplay"===n&&b||R&&h));return t.createElement("div",{className:"w-full h-full flex flex-col items-center justify-center",ref:u,onMouseEnter:()=>{"hover"===n&&v&&(m||(L(),p.current=window.setTimeout(()=>{f(!0)},150)))},onMouseLeave:()=>{L(),f(!1)},onMouseDown:I,onTouchStart:I},t.createElement("div",{className:"relative rounded overflow-hidden",style:{width:w.width?`${w.width}px`:"100%",height:w.height?`${w.height}px`:"100%",borderRadius:`${null!=s?s:10}px`,backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",aspectRatio:w.height?void 0:r,backgroundImage:S?`url(${Ct(S)})`:void 0,backgroundColor:S?void 0:"black"}},T?t.createElement("iframe",{src:`${A}/live/${e.eventId}`,className:"w-full h-full"}):t.createElement(t.Fragment,null,t.createElement("div",{className:"absolute inset-0 w-full h-full object-cover",style:{pointerEvents:"none"}},t.createElement(GE,{file:k,poster:S,autoplay:"autoplay"===n,active:"autoplay"===n&&b||R&&h,visible:P,muted:!0})),!P&&t.createElement(Au,null),t.createElement(jE,{view:null!==(d=null===(c=e.statistics)||void 0===c?void 0:c.pageView)&&void 0!==d?d:0}))))},VE=e=>{var r,i,s,n;const{content:a,title:o,aspectRatio:l="9/16",card:c,titleFontSize:u}=e,h=null!==(r=null==c?void 0:c.layout)&&void 0!==r?r:"slider",f=null!==(i=null==c?void 0:c.sliderPerView)&&void 0!==i?i:3,p=null!==(s=null==c?void 0:c.gridColumns)&&void 0!==s?s:3,m=null!==(n=null==c?void 0:c.gap)&&void 0!==n?n:12,g=null==c?void 0:c.width,v=g?"auto":f,y=d(()=>({fontSize:u?`${u}px`:void 0,fontWeight:600}),[u]),{PLAYER_BASE_URL:b}=gt();return a&&0!==a.length?t.createElement("div",{className:"flex flex-col w-full",style:{gap:m}},t.createElement("p",{className:"truncate",style:Object.assign(Object.assign({},y),{userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",cursor:"default"})},o||("past"===e.liveType?"지난 라이브":"예정된 라이브")),"slider"===h?t.createElement("div",null,t.createElement(Jn,{key:`${v}-${null!=g?g:""}-${m}`,slidesPerView:v,spaceBetween:m},a.map(r=>{var i,s;return t.createElement(ea,{key:r.eventId,style:g?{width:`${g}px`}:void 0},t.createElement("a",{href:`${b}/live/${r.eventId}`,target:"_blank",rel:"noopener noreferrer",className:"flex flex-col",style:{gap:6,textDecoration:"none",cursor:"pointer"}},"past"===e.liveType&&r.eventStatus!==xu.READY?t.createElement(HE,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius,playback:e.playback}):t.createElement(Iu,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius}),t.createElement("p",{className:"truncate",style:{color:null!==(s=null===(i=e.theme)||void 0===i?void 0:i.textColor)&&void 0!==s?s:"black",fontSize:14,userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"}},r.eventName)))}))):t.createElement("div",{style:{overflowY:"auto"}},t.createElement("div",{style:{display:"grid",gridTemplateColumns:g?`repeat(auto-fill, ${g}px)`:`repeat(${p}, minmax(0, 1fr))`,gap:m}},a.map(r=>{var i,s;return t.createElement("a",{key:r.eventId,href:`${b}/live/${r.eventId}`,target:"_blank",rel:"noopener noreferrer",className:"flex flex-col",style:{gap:6,textDecoration:"none",cursor:"pointer"}},"past"===e.liveType&&r.eventStatus!==xu.READY?t.createElement(HE,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius,playback:e.playback}):t.createElement(Iu,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius}),t.createElement("p",{className:"truncate",style:{color:null!==(s=null===(i=e.theme)||void 0===i?void 0:i.textColor)&&void 0!==s?s:"black",fontSize:14,userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"}},r.eventName))})))):null},WE=({content:e})=>{const r=t.useMemo(()=>qe(e.start).tz("Asia/Seoul").format("M월 D일 A HH:mm"),[e.start]),i=e.eventStatus!==xu.READY;return t.createElement("div",{className:"flex-1 flex flex-col gap-5 items-center justify-center"},t.createElement("p",{style:{fontWeight:"bold",fontSize:"24px"}},e.eventName),!i&&t.createElement("p",null,r),t.createElement("button",{onClick:()=>{window.open(`https://player.midibus.im/live/${e.eventId}`,"_blank")},className:"rounded bg-black text-white cursor-pointer",style:{width:"70%",padding:"10px"}},"라이브 입장하기"))},YE=e=>{var r,i;const{content:s,aspectRatio:n="9/16",videoAlign:a}=e,o=null===(r=e.card)||void 0===r?void 0:r.borderRadius,l=null===(i=e.card)||void 0===i?void 0:i.width,{PLAYER_BASE_URL:c}=gt();return t.createElement("div",{className:"flex w-full h-full items-center justify-center"},"only"===a?t.createElement("a",{className:"w-full h-full",href:`${c}/live/${s.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(Iu,{content:s,aspectRatio:n,borderRadius:o,cursor:"pointer"})):"left"===a?t.createElement(t.Fragment,null,t.createElement("div",{className:"flex-1"},t.createElement("a",{href:`${c}/live/${s.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(Iu,{content:s,aspectRatio:n,borderRadius:o,cursor:"pointer"}))),t.createElement(WE,{content:s})):t.createElement(t.Fragment,null,t.createElement(WE,{content:s}),t.createElement("div",{className:"flex-1"},t.createElement("a",{href:`${c}/live/${s.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(Iu,{content:s,aspectRatio:n,borderRadius:o,cursor:"pointer"})))))},KE=e=>{var r;const{theme:i,titleFontSize:s,title:n}=e;return t.createElement("div",{className:"w-full h-full flex flex-col",style:{color:null!==(r=null==i?void 0:i.textColor)&&void 0!==r?r:"#252525"}},t.createElement("p",{style:Object.assign(Object.assign({},s&&{fontSize:s}),{fontWeight:"bold",color:null==i?void 0:i.textColor,paddingTop:"10px",paddingBottom:"10px",marginBottom:"30px"})},n||("past"===e.liveType?"지난 라이브":"예정된 라이브")),t.createElement("div",{className:"self-center text-center h-full flex flex-col items-center justify-center",style:{minHeight:"200px"}},t.createElement("p",{style:{fontSize:"20px",marginBottom:"10px"}},"past"===e.liveType?"지난 라이브가 없어요.":"예정된 라이브가 없어요."),t.createElement("span",{style:{fontWeight:"lighter"}},"past"===e.liveType?"다른 콘텐츠도 확인해 보세요.":"곧 혜택 가득한 라이브로 찾아올게요!")))};function qE(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({className:St("animate-pulse rounded-md bg-gray-200",r)},i))}const XE=e=>{var r,i,s,n,a,o,l,c,d;const{card:u,aspectRatio:h="9/16",widgetType:f,layout:p,theme:m}=e,g=null!==(r=null==u?void 0:u.layout)&&void 0!==r?r:"slider",v=null!==(i=null==u?void 0:u.sliderPerView)&&void 0!==i?i:3,y=null!==(s=null==u?void 0:u.gridColumns)&&void 0!==s?s:3,b=null!==(n=null==u?void 0:u.gap)&&void 0!==n?n:12,E=null!==(a=null==u?void 0:u.borderRadius)&&void 0!==a?a:8,w=null!==(o=null==p?void 0:p.paddingTop)&&void 0!==o?o:0,S=null!==(l=null==p?void 0:p.paddingBottom)&&void 0!==l?l:0,T=null!==(c=null==p?void 0:p.paddingLeft)&&void 0!==c?c:0,x=null!==(d=null==p?void 0:p.paddingRight)&&void 0!==d?d:0,A="ONE"===f&&"past"!==e.liveType,k=A?1:(null==u?void 0:u.visibleCount)||6,L=A?1:"slider"===g?v:k;return t.createElement("div",{className:"w-full flex flex-col",style:{gap:b,paddingTop:w,paddingBottom:S,paddingLeft:T,paddingRight:x,backgroundColor:null==m?void 0:m.backgroundColor}},t.createElement(qE,{className:"h-5 w-36"}),t.createElement("div",{style:A||"scroll"!==g?{display:"flex",gap:b,overflow:"hidden"}:{display:"grid",gridTemplateColumns:`repeat(${y}, minmax(0, 1fr))`,gap:b}},Array.from({length:L}).map((e,r)=>t.createElement("div",{key:r,className:"flex flex-col flex-shrink-0",style:{flex:A||"slider"!==g?void 0:`0 0 calc((100% - ${b*(v-1)}px) / ${v})`,gap:6}},t.createElement(qE,{style:{aspectRatio:h,borderRadius:E,width:"100%"}}),t.createElement(qE,{className:"h-3.5 w-4/5"})))))},QE=e=>{var r,i,s,n;const{widgetType:a,theme:o,layout:l}=e,c=Tu(e=>e.liveWidget),d=null!==(r=null==l?void 0:l.paddingTop)&&void 0!==r?r:0,u=null!==(i=null==l?void 0:l.paddingBottom)&&void 0!==i?i:0,h=null!==(s=null==l?void 0:l.paddingLeft)&&void 0!==s?s:0,f=null!==(n=null==l?void 0:l.paddingRight)&&void 0!==n?n:0;return null===c?t.createElement(XE,Object.assign({},e)):0===c.length?t.createElement(KE,Object.assign({},e)):t.createElement("div",{className:"w-full h-full",style:{backgroundColor:null==o?void 0:o.backgroundColor,color:null==o?void 0:o.textColor,paddingTop:d,paddingBottom:u,paddingLeft:h,paddingRight:f}},"ONE"===a&&"past"!==e.liveType?t.createElement(YE,Object.assign({content:c[0]},e)):t.createElement(VE,Object.assign({content:c},e)))},ZE=e=>{const r=Tu(e=>e.liveWidget),s=Tu(e=>e.setLiveWidget),{userId:n,card:a,includeRepresentative:o=!1,liveType:l}=e;return i(()=>{if(!n)return;if(r&&(null==a?void 0:a.visibleCount)&&r.length>Number(a.visibleCount))return void s(r.slice(0,null==a?void 0:a.visibleCount));const t=new AbortController;return x(void 0,void 0,void 0,function*(){const r=yield _a(n,"past"===l?"FINISHED":"UPCOMING",(null==a?void 0:a.visibleCount)||6,o,e.sorting);if(!r||t.signal.aborted)return;s(r);const i=yield Promise.allSettled(r.map(e=>x(void 0,void 0,void 0,function*(){const t=yield((e,t)=>x(void 0,void 0,void 0,function*(){const{STATISTICS_BASE_URL:r}=gt(),i=`${r}/replay/${e}/${t}/summary`,s=yield fetch(i);if(404!==s.status){if(!s.ok){const e=yield s.text().catch(()=>"");return console.error(`[ReplayStatistics] ${s.status} ${s.statusText} ${e}`),{pageView:0,like:0}}return s.json()}}))(n,e.eventId);return Object.assign(Object.assign({},e),{statistics:t})})));t.signal.aborted||s(i.map((e,t)=>"fulfilled"===e.status?e.value:r[t]))}),()=>t.abort()},[n,null==a?void 0:a.visibleCount,l,e.sorting,o]),t.createElement(Sr.div,{className:"w-full h-full"},t.createElement(fo,null),t.createElement(QE,Object.assign({},e)))},JE=e=>t.createElement(Su,null,t.createElement(ZE,Object.assign({},e))),ew=({eventId:e})=>{const[r,i]=a(!1),{PLAYER_BASE_URL:s}=gt();if(r)return null;const{w:n,h:o,left:l,top:c}=(()=>{const e=window.visualViewport;return e?{w:e.width,h:e.height,left:e.offsetLeft,top:e.offsetTop}:{w:window.innerWidth,h:window.innerHeight,left:0,top:0}})();return t.createElement(vu,{minWidth:240,lockAspectRatio:9/17.05,style:{zIndex:99999},default:{width:240,height:455,x:l+n-240-50,y:c+o-427-28-50},bounds:"window",dragHandleClassName:"live-floating-drag-handle"},t.createElement("div",{className:"flex flex-col w-full h-full",style:{borderRadius:8,overflow:"hidden",boxShadow:"0 4px 24px rgba(0,0,0,0.4)"}},t.createElement("div",{className:"live-floating-drag-handle flex items-center justify-between",style:{height:28,minHeight:28,background:"#111",cursor:"grab",padding:"0 8px",userSelect:"none"}},t.createElement(Or,{size:16,color:"#888"}),t.createElement("button",{className:"cursor-pointer",style:{color:"#ccc",lineHeight:0},onClick:()=>i(!0),"aria-label":"Close"},t.createElement(zr,{size:16}))),t.createElement("iframe",{src:`${s}/live/${e}`,style:{flex:1,border:0,display:"block",minHeight:0},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade"})))},tw=({eventId:e})=>e?t.createElement(Sr.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:99999}},t.createElement(fo,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(ew,{eventId:e}))):null;export{Ed as CollectionShowcase,Eu as FloatingPlayer,tw as LiveFloatingPlayer,JE as LiveWidget,bo as PreviewPlayer,yo as ShoppingPlayer,Ot as ViewPlayer,vd as WidgetPlayer,mt as configure};
|
|
40
|
+
*/function Qr(t,r=[]){let i=[];const s=()=>{const r=i.map(t=>e.createContext(t));return function(i){const s=i?.[t]||r;return e.useMemo(()=>({[`__scope${t}`]:{...i,[t]:s}}),[i,s])}};return s.scopeName=t,[function(r,s){const n=e.createContext(s),a=i.length;i=[...i,s];const o=r=>{const{scope:i,children:s,...o}=r,l=i?.[t]?.[a]||n,c=e.useMemo(()=>o,Object.values(o));return b(l.Provider,{value:c,children:s})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||n,c=e.useContext(l);if(c)return c;if(void 0!==s)return s;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},Zr(s,...r)]}function Zr(...t){const r=t[0];if(1===t.length)return r;const i=()=>{const i=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const s=i.reduce((e,{useScope:r,scopeName:i})=>({...e,...r(t)[`__scope${i}`]}),{});return e.useMemo(()=>({[`__scope${r.scopeName}`]:s}),[s])}};return i.scopeName=r.scopeName,i}function Jr(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function ei(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Jr(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():Jr(e[t],null)}}}}function ti(...t){return e.useCallback(ei(...t),t)}var ri=e.forwardRef((t,r)=>{const{children:i,...s}=t,n=e.Children.toArray(i),a=n.find(ni);if(a){const t=a.props.children,i=n.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(ii,{...s,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(ii,{...s,ref:r,children:i})});ri.displayName="Slot";var ii=e.forwardRef((t,r)=>{const{children:i,...s}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),n=function(e,t){const r={...t};for(const i in t){const s=e[i],n=t[i];/^on[A-Z]/.test(i)?s&&n?r[i]=(...e)=>{n(...e),s(...e)}:s&&(r[i]=s):"style"===i?r[i]={...s,...n}:"className"===i&&(r[i]=[s,n].filter(Boolean).join(" "))}return{...e,...r}}(s,i.props);return i.type!==e.Fragment&&(n.ref=r?ei(r,t):t),e.cloneElement(i,n)}return e.Children.count(i)>1?e.Children.only(null):null});ii.displayName="SlotClone";var si=({children:e})=>b(E,{children:e});function ni(t){return e.isValidElement(t)&&t.type===si}function ai(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function oi(...e){return t=>{let r=!1;const i=e.map(e=>{const i=ai(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():ai(e[t],null)}}}}function li(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function ci(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}function di({prop:t,defaultProp:r,onChange:i=()=>{}}){const[s,n]=function({defaultProp:t,onChange:r}){const i=e.useState(t),[s]=i,n=e.useRef(s),a=ci(r);return e.useEffect(()=>{n.current!==s&&(a(s),n.current=s)},[s,n,a]),i}({defaultProp:r,onChange:i}),a=void 0!==t,o=a?t:s,l=ci(i);return[o,e.useCallback(e=>{if(a){const r="function"==typeof e?e(t):e;r!==t&&l(r)}else n(e)},[a,t,n,l])]}var ui=e.forwardRef((t,r)=>{const{children:i,...s}=t,n=e.Children.toArray(i),a=n.find(pi);if(a){const t=a.props.children,i=n.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(hi,{...s,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(hi,{...s,ref:r,children:i})});ui.displayName="Slot";var hi=e.forwardRef((t,r)=>{const{children:i,...s}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),n=function(e,t){const r={...t};for(const i in t){const s=e[i],n=t[i];/^on[A-Z]/.test(i)?s&&n?r[i]=(...e)=>{n(...e),s(...e)}:s&&(r[i]=s):"style"===i?r[i]={...s,...n}:"className"===i&&(r[i]=[s,n].filter(Boolean).join(" "))}return{...e,...r}}(s,i.props);return i.type!==e.Fragment&&(n.ref=r?oi(r,t):t),e.cloneElement(i,n)}return e.Children.count(i)>1?e.Children.only(null):null});hi.displayName="SlotClone";var fi=({children:e})=>b(E,{children:e});function pi(t){return e.isValidElement(t)&&t.type===fi}var mi=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((t,r)=>{const i=e.forwardRef((e,t)=>{const{asChild:i,...s}=e,n=i?ui:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(n,{...s,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{}),gi=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{};function vi(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function yi(...e){return t=>{let r=!1;const i=e.map(e=>{const i=vi(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():vi(e[t],null)}}}}function bi(...t){return e.useCallback(yi(...t),t)}var Ei=e.forwardRef((t,r)=>{const{children:i,...s}=t,n=e.Children.toArray(i),a=n.find(Ti);if(a){const t=a.props.children,i=n.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(wi,{...s,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return b(wi,{...s,ref:r,children:i})});Ei.displayName="Slot";var wi=e.forwardRef((t,r)=>{const{children:i,...s}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),n=function(e,t){const r={...t};for(const i in t){const s=e[i],n=t[i];/^on[A-Z]/.test(i)?s&&n?r[i]=(...e)=>{n(...e),s(...e)}:s&&(r[i]=s):"style"===i?r[i]={...s,...n}:"className"===i&&(r[i]=[s,n].filter(Boolean).join(" "))}return{...e,...r}}(s,i.props);return i.type!==e.Fragment&&(n.ref=r?yi(r,t):t),e.cloneElement(i,n)}return e.Children.count(i)>1?e.Children.only(null):null});wi.displayName="SlotClone";var Si=({children:e})=>b(E,{children:e});function Ti(t){return e.isValidElement(t)&&t.type===Si}var xi=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((t,r)=>{const i=e.forwardRef((e,t)=>{const{asChild:i,...s}=e,n=i?Ei:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(n,{...s,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{});var Ai=t=>{const{present:r,children:i}=t,s=function(t){const[r,i]=e.useState(),s=e.useRef({}),n=e.useRef(t),a=e.useRef("none"),o=t?"mounted":"unmounted",[l,c]=function(t,r){return e.useReducer((e,t)=>r[e][t]??e,t)}(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=ki(s.current);a.current="mounted"===l?e:"none"},[l]),gi(()=>{const e=s.current,r=n.current;if(r!==t){const i=a.current,s=ki(e);if(t)c("MOUNT");else if("none"===s||"none"===e?.display)c("UNMOUNT");else{c(r&&i!==s?"ANIMATION_OUT":"UNMOUNT")}n.current=t}},[t,c]),gi(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=ki(s.current).includes(i.animationName);if(i.target===r&&a&&(c("ANIMATION_END"),!n.current)){const i=r.style.animationFillMode;r.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===r.style.animationFillMode&&(r.style.animationFillMode=i)})}},o=e=>{e.target===r&&(a.current=ki(s.current))};return r.addEventListener("animationstart",o),r.addEventListener("animationcancel",i),r.addEventListener("animationend",i),()=>{t.clearTimeout(e),r.removeEventListener("animationstart",o),r.removeEventListener("animationcancel",i),r.removeEventListener("animationend",i)}}c("ANIMATION_END")},[r,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{e&&(s.current=getComputedStyle(e)),i(e)},[])}}(r),n="function"==typeof i?i({present:s.isPresent}):e.Children.only(i),a=bi(s.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(n));return"function"==typeof i||s.isPresent?e.cloneElement(n,{ref:a}):null};function ki(e){return e?.animationName||"none"}Ai.displayName="Presence";var Li=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{},Ii=e["useId".toString()]||(()=>{}),Ri=0;function Pi(t){const[r,i]=e.useState(Ii());return Li(()=>{i(e=>e??String(Ri++))},[t]),r?`radix-${r}`:""}var Ci="Collapsible",[Di,_i]=Qr(Ci),[Oi,Mi]=Di(Ci),Ni=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,open:s,defaultOpen:n,disabled:a,onOpenChange:o,...l}=t,[c=!1,d]=di({prop:s,defaultProp:n,onChange:o});return b(Oi,{scope:i,disabled:a,contentId:Pi(),open:c,onOpenToggle:e.useCallback(()=>d(e=>!e),[d]),children:b(xi.div,{"data-state":Gi(c),"data-disabled":a?"":void 0,...l,ref:r})})});Ni.displayName=Ci;var Fi="CollapsibleTrigger",$i=e.forwardRef((e,t)=>{const{__scopeCollapsible:r,...i}=e,s=Mi(Fi,r);return b(xi.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":Gi(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...i,ref:t,onClick:li(e.onClick,s.onOpenToggle)})});$i.displayName=Fi;var Bi="CollapsibleContent",Ui=e.forwardRef((e,t)=>{const{forceMount:r,...i}=e,s=Mi(Bi,e.__scopeCollapsible);return b(Ai,{present:r||s.open,children:({present:e})=>b(zi,{...i,ref:t,present:e})})});Ui.displayName=Bi;var zi=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,present:s,children:n,...a}=t,o=Mi(Bi,i),[l,c]=e.useState(s),d=e.useRef(null),u=bi(r,d),h=e.useRef(0),f=h.current,p=e.useRef(0),m=p.current,g=o.open||l,v=e.useRef(g),y=e.useRef(void 0);return e.useEffect(()=>{const e=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(e)},[]),gi(()=>{const e=d.current;if(e){y.current=y.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";const t=e.getBoundingClientRect();h.current=t.height,p.current=t.width,v.current||(e.style.transitionDuration=y.current.transitionDuration,e.style.animationName=y.current.animationName),c(s)}},[o.open,s]),b(xi.div,{"data-state":Gi(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!g,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...t.style},children:g&&n})});function Gi(e){return e?"open":"closed"}var ji=Ni,Hi=$i,Vi=Ui,Wi=e.createContext(void 0);var Yi="Accordion",Ki=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[qi,Xi,Qi]=function(e){const r=e+"CollectionProvider",[i,s]=Qr(r),[n,a]=i(r,{collectionRef:{current:null},itemMap:new Map}),o=e=>{const{scope:r,children:i}=e,s=t.useRef(null),a=t.useRef(new Map).current;return b(n,{scope:r,itemMap:a,collectionRef:s,children:i})};o.displayName=r;const l=e+"CollectionSlot",c=t.forwardRef((e,t)=>{const{scope:r,children:i}=e,s=ti(t,a(l,r).collectionRef);return b(ri,{ref:s,children:i})});c.displayName=l;const d=e+"CollectionItemSlot",u="data-radix-collection-item",h=t.forwardRef((e,r)=>{const{scope:i,children:s,...n}=e,o=t.useRef(null),l=ti(r,o),c=a(d,i);return t.useEffect(()=>(c.itemMap.set(o,{ref:o,...n}),()=>{c.itemMap.delete(o)})),b(ri,{[u]:"",ref:l,children:s})});return h.displayName=d,[{Provider:o,Slot:c,ItemSlot:h},function(r){const i=a(e+"CollectionConsumer",r),s=t.useCallback(()=>{const e=i.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll(`[${u}]`)),r=Array.from(i.itemMap.values()).sort((e,r)=>t.indexOf(e.ref.current)-t.indexOf(r.ref.current));return r},[i.collectionRef,i.itemMap]);return s},s]}(Yi),[Zi,Ji]=Qr(Yi,[Qi,_i]),es=_i(),ts=t.forwardRef((e,t)=>{const{type:r,...i}=e,s=i,n=i;return b(qi.Provider,{scope:e.__scopeAccordion,children:"multiple"===r?b(os,{...n,ref:t}):b(as,{...s,ref:t})})});ts.displayName=Yi;var[rs,is]=Zi(Yi),[ss,ns]=Zi(Yi,{collapsible:!1}),as=t.forwardRef((e,r)=>{const{value:i,defaultValue:s,onValueChange:n=()=>{},collapsible:a=!1,...o}=e,[l,c]=di({prop:i,defaultProp:s,onChange:n});return b(rs,{scope:e.__scopeAccordion,value:l?[l]:[],onItemOpen:c,onItemClose:t.useCallback(()=>a&&c(""),[a,c]),children:b(ss,{scope:e.__scopeAccordion,collapsible:a,children:b(ds,{...o,ref:r})})})}),os=t.forwardRef((e,r)=>{const{value:i,defaultValue:s,onValueChange:n=()=>{},...a}=e,[o=[],l]=di({prop:i,defaultProp:s,onChange:n}),c=t.useCallback(e=>l((t=[])=>[...t,e]),[l]),d=t.useCallback(e=>l((t=[])=>t.filter(t=>t!==e)),[l]);return b(rs,{scope:e.__scopeAccordion,value:o,onItemOpen:c,onItemClose:d,children:b(ss,{scope:e.__scopeAccordion,collapsible:!0,children:b(ds,{...a,ref:r})})})}),[ls,cs]=Zi(Yi),ds=t.forwardRef((r,i)=>{const{__scopeAccordion:s,disabled:n,dir:a,orientation:o="vertical",...l}=r,c=function(...t){return e.useCallback(oi(...t),t)}(t.useRef(null),i),d=Xi(s),u="ltr"===function(t){const r=e.useContext(Wi);return t||r||"ltr"}(a),h=li(r.onKeyDown,e=>{if(!Ki.includes(e.key))return;const t=e.target,r=d().filter(e=>!e.ref.current?.disabled),i=r.findIndex(e=>e.ref.current===t),s=r.length;if(-1===i)return;e.preventDefault();let n=i;const a=s-1,l=()=>{n=i+1,n>a&&(n=0)},c=()=>{n=i-1,n<0&&(n=a)};switch(e.key){case"Home":n=0;break;case"End":n=a;break;case"ArrowRight":"horizontal"===o&&(u?l():c());break;case"ArrowDown":"vertical"===o&&l();break;case"ArrowLeft":"horizontal"===o&&(u?c():l());break;case"ArrowUp":"vertical"===o&&c()}const h=n%s;r[h].ref.current?.focus()});return b(ls,{scope:s,disabled:n,direction:a,orientation:o,children:b(qi.Slot,{scope:s,children:b(mi.div,{...l,"data-orientation":o,ref:c,onKeyDown:n?void 0:h})})})}),us="AccordionItem",[hs,fs]=Zi(us),ps=t.forwardRef((e,t)=>{const{__scopeAccordion:r,value:i,...s}=e,n=cs(us,r),a=is(us,r),o=es(r),l=Pi(),c=i&&a.value.includes(i)||!1,d=n.disabled||e.disabled;return b(hs,{scope:r,open:c,disabled:d,triggerId:l,children:b(ji,{"data-orientation":n.orientation,"data-state":ws(c),...o,...s,ref:t,disabled:d,open:c,onOpenChange:e=>{e?a.onItemOpen(i):a.onItemClose(i)}})})});ps.displayName=us;var ms="AccordionHeader",gs=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,s=cs(Yi,r),n=fs(ms,r);return b(mi.h3,{"data-orientation":s.orientation,"data-state":ws(n.open),"data-disabled":n.disabled?"":void 0,...i,ref:t})});gs.displayName=ms;var vs="AccordionTrigger",ys=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,s=cs(Yi,r),n=fs(vs,r),a=ns(vs,r),o=es(r);return b(qi.ItemSlot,{scope:r,children:b(Hi,{"aria-disabled":n.open&&!a.collapsible||void 0,"data-orientation":s.orientation,id:n.triggerId,...o,...i,ref:t})})});ys.displayName=vs;var bs="AccordionContent",Es=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,s=cs(Yi,r),n=fs(bs,r),a=es(r);return b(Vi,{role:"region","aria-labelledby":n.triggerId,"data-orientation":s.orientation,...a,...i,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});function ws(e){return e?"open":"closed"}Es.displayName=bs;var Ss=ts,Ts=ps,xs=gs,As=ys,ks=Es;function Ls(t){var r=T(t,[]);return e.createElement(Ss,Object.assign({"data-slot":"accordion"},r))}function Is(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(Ts,Object.assign({"data-slot":"accordion-item",className:St("border-b last:border-b-0",r)},i))}function Rs(t){var{className:r,children:i}=t,s=T(t,["className","children"]);return e.createElement(xs,{className:"flex"},e.createElement(As,Object.assign({"data-slot":"accordion-trigger",className:St("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",r)},s),i,e.createElement(Rr,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"})))}function Ps(t){var{className:r,children:i}=t,s=T(t,["className","children"]);return e.createElement(ks,Object.assign({"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"},s),e.createElement("div",{className:St("pt-0 pb-4",r)},i))}const Cs=({title:e,content:r})=>t.createElement(Ls,{style:{borderRadius:"0.625rem"},type:"single",collapsible:!0,className:"bg-white px-4",defaultValue:"item"},t.createElement(Is,{value:"item"},t.createElement(Rs,{className:""},e),t.createElement(Ps,{className:"text-gray-700"},r))),Ds=({logo:e})=>t.createElement("div",{className:"w-full bg-zinc-700 h-[60px] flex"},t.createElement("div",{className:"my-0 mx-auto w-full px-[24px] flex items-center justify-between"},e?t.createElement("div",{className:"h-10 max-w-[160px]"},t.createElement("img",{src:e.thumbPath,alt:e.logoName,width:100,height:100,className:"object-contain w-full h-full"})):t.createElement("div",null),t.createElement("button",{className:"text-white cursor-pointer"},t.createElement(zr,null)))),_s=e=>{const{playerSettings:r,shortform:{description:i,productsInfo:s,logo:n,brand:a,title:o},player:l}=e;return t.createElement("div",{className:"w-full h-full bg-[#f4f4f4] overflow-scroll"},t.createElement(Ds,{logo:n}),t.createElement("div",{className:" w-full h-full flex justify-between p-10 gap-10"},t.createElement("div",{className:""},t.createElement("div",{className:"flex gap-4 w-full mb-2 h-[125px] flex-col"},a?t.createElement("div",{className:"items-center flex gap-3"},a.thumbPath&&t.createElement("div",{className:"w-16 h-16 bg-white rounded-full border "},t.createElement("img",{src:a.thumbPath,alt:a.brandName,width:100,height:100,className:"object-contain w-full h-full rounded-full"})),t.createElement("div",null,t.createElement("p",null,a.brandName),t.createElement("p",{className:"text-lg font-semibold"},o))):t.createElement("p",{className:"text-xl font-semibold"},o),t.createElement(Gr,null)),t.createElement("div",{className:"w-full pb-10 flex gap-4 justify-center"},t.createElement("div",{className:"flex gap-3"},l),t.createElement("div",{className:"flex flex-col gap-4 justify-end"},t.createElement(Kr,{rounded:!0}),t.createElement(qr,{rounded:!0}),t.createElement(Xr,{rounded:!0})))),t.createElement("div",{className:"flex flex-col gap-4 max-w-[40%]"},i&&t.createElement(Cs,{title:"숏클립 안내",content:t.createElement("p",{className:"font-medium"},i)}),t.createElement(Cs,{title:"상품 목록",content:t.createElement(t.Fragment,null,t.createElement("div",{className:"max-h-[300px] overflow-y-auto font-medium"},s.map((e,r)=>t.createElement(t.Fragment,null,t.createElement(Vr,{product:e}),r!==s.length-1&&t.createElement("div",{className:"h-1 w-full border-t my-2"})))),t.createElement("button",{className:"w-full mt-3 border rounded py-2 px-4 cursor-pointer",disabled:!(null==s?void 0:s.length)},"상품 전체 보기"))}),r.comment&&t.createElement(Cs,{title:"댓글",content:t.createElement(Wr,null)}))))};function Os(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function Ms(e,t){void 0===e&&(e={}),void 0===t&&(t={}),Object.keys(t).forEach(r=>{void 0===e[r]?e[r]=t[r]:Os(t[r])&&Os(e[r])&&Object.keys(t[r]).length>0&&Ms(e[r],t[r])})}const Ns={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function Fs(){const e="undefined"!=typeof document?document:{};return Ms(e,Ns),e}const $s={document:Ns,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:e=>"undefined"==typeof setTimeout?(e(),null):setTimeout(e,0),cancelAnimationFrame(e){"undefined"!=typeof setTimeout&&clearTimeout(e)}};function Bs(){const e="undefined"!=typeof window?window:{};return Ms(e,$s),e}function Us(e,t){return void 0===t&&(t=0),setTimeout(e,t)}function zs(){return Date.now()}function Gs(e,t){void 0===t&&(t="x");const r=Bs();let i,s,n;const a=function(e){const t=Bs();let r;return t.getComputedStyle&&(r=t.getComputedStyle(e,null)),!r&&e.currentStyle&&(r=e.currentStyle),r||(r=e.style),r}(e);return r.WebKitCSSMatrix?(s=a.transform||a.webkitTransform,s.split(",").length>6&&(s=s.split(", ").map(e=>e.replace(",",".")).join(", ")),n=new r.WebKitCSSMatrix("none"===s?"":s)):(n=a.MozTransform||a.OTransform||a.MsTransform||a.msTransform||a.transform||a.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),i=n.toString().split(",")),"x"===t&&(s=r.WebKitCSSMatrix?n.m41:16===i.length?parseFloat(i[12]):parseFloat(i[4])),"y"===t&&(s=r.WebKitCSSMatrix?n.m42:16===i.length?parseFloat(i[13]):parseFloat(i[5])),s||0}function js(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function Hs(e){return"undefined"!=typeof window&&void 0!==window.HTMLElement?e instanceof HTMLElement:e&&(1===e.nodeType||11===e.nodeType)}function Vs(){const e=Object(arguments.length<=0?void 0:arguments[0]),t=["__proto__","constructor","prototype"];for(let r=1;r<arguments.length;r+=1){const i=r<0||arguments.length<=r?void 0:arguments[r];if(null!=i&&!Hs(i)){const r=Object.keys(Object(i)).filter(e=>t.indexOf(e)<0);for(let t=0,s=r.length;t<s;t+=1){const s=r[t],n=Object.getOwnPropertyDescriptor(i,s);void 0!==n&&n.enumerable&&(js(e[s])&&js(i[s])?i[s].__swiper__?e[s]=i[s]:Vs(e[s],i[s]):!js(e[s])&&js(i[s])?(e[s]={},i[s].__swiper__?e[s]=i[s]:Vs(e[s],i[s])):e[s]=i[s])}}}return e}function Ws(e,t,r){e.style.setProperty(t,r)}function Ys(e){let{swiper:t,targetPosition:r,side:i}=e;const s=Bs(),n=-t.translate;let a,o=null;const l=t.params.speed;t.wrapperEl.style.scrollSnapType="none",s.cancelAnimationFrame(t.cssModeFrameID);const c=r>n?"next":"prev",d=(e,t)=>"next"===c&&e>=t||"prev"===c&&e<=t,u=()=>{a=(new Date).getTime(),null===o&&(o=a);const e=Math.max(Math.min((a-o)/l,1),0),c=.5-Math.cos(e*Math.PI)/2;let h=n+c*(r-n);if(d(h,r)&&(h=r),t.wrapperEl.scrollTo({[i]:h}),d(h,r))return t.wrapperEl.style.overflow="hidden",t.wrapperEl.style.scrollSnapType="",setTimeout(()=>{t.wrapperEl.style.overflow="",t.wrapperEl.scrollTo({[i]:h})}),void s.cancelAnimationFrame(t.cssModeFrameID);t.cssModeFrameID=s.requestAnimationFrame(u)};u()}function Ks(e){return e.querySelector(".swiper-slide-transform")||e.shadowRoot&&e.shadowRoot.querySelector(".swiper-slide-transform")||e}function qs(e,t){void 0===t&&(t="");const r=[...e.children];return e instanceof HTMLSlotElement&&r.push(...e.assignedElements()),t?r.filter(e=>e.matches(t)):r}function Xs(e){try{return void console.warn(e)}catch(e){}}function Qs(e,t){void 0===t&&(t=[]);const r=document.createElement(e);return r.classList.add(...Array.isArray(t)?t:function(e){return void 0===e&&(e=""),e.trim().split(" ").filter(e=>!!e.trim())}(t)),r}function Zs(e,t){return Bs().getComputedStyle(e,null).getPropertyValue(t)}function Js(e){let t,r=e;if(r){for(t=0;null!==(r=r.previousSibling);)1===r.nodeType&&(t+=1);return t}}function en(e,t,r){const i=Bs();return e["width"===t?"offsetWidth":"offsetHeight"]+parseFloat(i.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-right":"margin-top"))+parseFloat(i.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-left":"margin-bottom"))}function tn(e){return(Array.isArray(e)?e:[e]).filter(e=>!!e)}let rn,sn,nn;function an(){return rn||(rn=function(){const e=Bs(),t=Fs();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}()),rn}function on(e){return void 0===e&&(e={}),sn||(sn=function(e){let{userAgent:t}=void 0===e?{}:e;const r=an(),i=Bs(),s=i.navigator.platform,n=t||i.navigator.userAgent,a={ios:!1,android:!1},o=i.screen.width,l=i.screen.height,c=n.match(/(Android);?[\s\/]+([\d.]+)?/);let d=n.match(/(iPad).*OS\s([\d_]+)/);const u=n.match(/(iPod)(.*OS\s([\d_]+))?/),h=!d&&n.match(/(iPhone\sOS|iOS)\s([\d_]+)/),f="Win32"===s;let p="MacIntel"===s;return!d&&p&&r.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${o}x${l}`)>=0&&(d=n.match(/(Version)\/([\d.]+)/),d||(d=[0,1,"13_0_0"]),p=!1),c&&!f&&(a.os="android",a.android=!0),(d||h||u)&&(a.os="ios",a.ios=!0),a}(e)),sn}function ln(){return nn||(nn=function(){const e=Bs(),t=on();let r=!1;function i(){const t=e.navigator.userAgent.toLowerCase();return t.indexOf("safari")>=0&&t.indexOf("chrome")<0&&t.indexOf("android")<0}if(i()){const t=String(e.navigator.userAgent);if(t.includes("Version/")){const[e,i]=t.split("Version/")[1].split(" ")[0].split(".").map(e=>Number(e));r=e<16||16===e&&i<2}}const s=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),n=i();return{isSafari:r||n,needPerspectiveFix:r,need3dFix:n||s&&t.ios,isWebView:s}}()),nn}var cn={on(e,t,r){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;const s=r?"unshift":"push";return e.split(" ").forEach(e=>{i.eventsListeners[e]||(i.eventsListeners[e]=[]),i.eventsListeners[e][s](t)}),i},once(e,t,r){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;function s(){i.off(e,s),s.__emitterProxy&&delete s.__emitterProxy;for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];t.apply(i,n)}return s.__emitterProxy=t,i.on(e,s,r)},onAny(e,t){const r=this;if(!r.eventsListeners||r.destroyed)return r;if("function"!=typeof e)return r;const i=t?"unshift":"push";return r.eventsAnyListeners.indexOf(e)<0&&r.eventsAnyListeners[i](e),r},offAny(e){const t=this;if(!t.eventsListeners||t.destroyed)return t;if(!t.eventsAnyListeners)return t;const r=t.eventsAnyListeners.indexOf(e);return r>=0&&t.eventsAnyListeners.splice(r,1),t},off(e,t){const r=this;return!r.eventsListeners||r.destroyed?r:r.eventsListeners?(e.split(" ").forEach(e=>{void 0===t?r.eventsListeners[e]=[]:r.eventsListeners[e]&&r.eventsListeners[e].forEach((i,s)=>{(i===t||i.__emitterProxy&&i.__emitterProxy===t)&&r.eventsListeners[e].splice(s,1)})}),r):r},emit(){const e=this;if(!e.eventsListeners||e.destroyed)return e;if(!e.eventsListeners)return e;let t,r,i;for(var s=arguments.length,n=new Array(s),a=0;a<s;a++)n[a]=arguments[a];"string"==typeof n[0]||Array.isArray(n[0])?(t=n[0],r=n.slice(1,n.length),i=e):(t=n[0].events,r=n[0].data,i=n[0].context||e),r.unshift(i);return(Array.isArray(t)?t:t.split(" ")).forEach(t=>{e.eventsAnyListeners&&e.eventsAnyListeners.length&&e.eventsAnyListeners.forEach(e=>{e.apply(i,[t,...r])}),e.eventsListeners&&e.eventsListeners[t]&&e.eventsListeners[t].forEach(e=>{e.apply(i,r)})}),e}};const dn=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const un=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const hn=(e,t)=>{if(!e||e.destroyed||!e.params)return;const r=t.closest(e.isElement?"swiper-slide":`.${e.params.slideClass}`);if(r){let t=r.querySelector(`.${e.params.lazyPreloaderClass}`);!t&&e.isElement&&(r.shadowRoot?t=r.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`):requestAnimationFrame(()=>{r.shadowRoot&&(t=r.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`),t&&t.remove())})),t&&t.remove()}},fn=(e,t)=>{if(!e.slides[t])return;const r=e.slides[t].querySelector('[loading="lazy"]');r&&r.removeAttribute("loading")},pn=e=>{if(!e||e.destroyed||!e.params)return;let t=e.params.lazyPreloadPrevNext;const r=e.slides.length;if(!r||!t||t<0)return;t=Math.min(t,r);const i="auto"===e.params.slidesPerView?e.slidesPerViewDynamic():Math.ceil(e.params.slidesPerView),s=e.activeIndex;if(e.params.grid&&e.params.grid.rows>1){const r=s,n=[r-t];return n.push(...Array.from({length:t}).map((e,t)=>r+i+t)),void e.slides.forEach((t,r)=>{n.includes(t.column)&&fn(e,r)})}const n=s+i-1;if(e.params.rewind||e.params.loop)for(let i=s-t;i<=n+t;i+=1){const t=(i%r+r)%r;(t<s||t>n)&&fn(e,t)}else for(let i=Math.max(s-t,0);i<=Math.min(n+t,r-1);i+=1)i!==s&&(i>n||i<s)&&fn(e,i)};var mn={updateSize:function(){const e=this;let t,r;const i=e.el;t=void 0!==e.params.width&&null!==e.params.width?e.params.width:i.clientWidth,r=void 0!==e.params.height&&null!==e.params.height?e.params.height:i.clientHeight,0===t&&e.isHorizontal()||0===r&&e.isVertical()||(t=t-parseInt(Zs(i,"padding-left")||0,10)-parseInt(Zs(i,"padding-right")||0,10),r=r-parseInt(Zs(i,"padding-top")||0,10)-parseInt(Zs(i,"padding-bottom")||0,10),Number.isNaN(t)&&(t=0),Number.isNaN(r)&&(r=0),Object.assign(e,{width:t,height:r,size:e.isHorizontal()?t:r}))},updateSlides:function(){const e=this;function t(t,r){return parseFloat(t.getPropertyValue(e.getDirectionLabel(r))||0)}const r=e.params,{wrapperEl:i,slidesEl:s,size:n,rtlTranslate:a,wrongRTL:o}=e,l=e.virtual&&r.virtual.enabled,c=l?e.virtual.slides.length:e.slides.length,d=qs(s,`.${e.params.slideClass}, swiper-slide`),u=l?e.virtual.slides.length:d.length;let h=[];const f=[],p=[];let m=r.slidesOffsetBefore;"function"==typeof m&&(m=r.slidesOffsetBefore.call(e));let g=r.slidesOffsetAfter;"function"==typeof g&&(g=r.slidesOffsetAfter.call(e));const v=e.snapGrid.length,y=e.slidesGrid.length;let b=r.spaceBetween,E=-m,w=0,S=0;if(void 0===n)return;"string"==typeof b&&b.indexOf("%")>=0?b=parseFloat(b.replace("%",""))/100*n:"string"==typeof b&&(b=parseFloat(b)),e.virtualSize=-b,d.forEach(e=>{a?e.style.marginLeft="":e.style.marginRight="",e.style.marginBottom="",e.style.marginTop=""}),r.centeredSlides&&r.cssMode&&(Ws(i,"--swiper-centered-offset-before",""),Ws(i,"--swiper-centered-offset-after",""));const T=r.grid&&r.grid.rows>1&&e.grid;let x;T?e.grid.initSlides(d):e.grid&&e.grid.unsetSlides();const A="auto"===r.slidesPerView&&r.breakpoints&&Object.keys(r.breakpoints).filter(e=>void 0!==r.breakpoints[e].slidesPerView).length>0;for(let i=0;i<u;i+=1){let s;if(x=0,d[i]&&(s=d[i]),T&&e.grid.updateSlide(i,s,d),!d[i]||"none"!==Zs(s,"display")){if("auto"===r.slidesPerView){A&&(d[i].style[e.getDirectionLabel("width")]="");const n=getComputedStyle(s),a=s.style.transform,o=s.style.webkitTransform;if(a&&(s.style.transform="none"),o&&(s.style.webkitTransform="none"),r.roundLengths)x=e.isHorizontal()?en(s,"width"):en(s,"height");else{const e=t(n,"width"),r=t(n,"padding-left"),i=t(n,"padding-right"),a=t(n,"margin-left"),o=t(n,"margin-right"),l=n.getPropertyValue("box-sizing");if(l&&"border-box"===l)x=e+a+o;else{const{clientWidth:t,offsetWidth:n}=s;x=e+r+i+a+o+(n-t)}}a&&(s.style.transform=a),o&&(s.style.webkitTransform=o),r.roundLengths&&(x=Math.floor(x))}else x=(n-(r.slidesPerView-1)*b)/r.slidesPerView,r.roundLengths&&(x=Math.floor(x)),d[i]&&(d[i].style[e.getDirectionLabel("width")]=`${x}px`);d[i]&&(d[i].swiperSlideSize=x),p.push(x),r.centeredSlides?(E=E+x/2+w/2+b,0===w&&0!==i&&(E=E-n/2-b),0===i&&(E=E-n/2-b),Math.abs(E)<.001&&(E=0),r.roundLengths&&(E=Math.floor(E)),S%r.slidesPerGroup===0&&h.push(E),f.push(E)):(r.roundLengths&&(E=Math.floor(E)),(S-Math.min(e.params.slidesPerGroupSkip,S))%e.params.slidesPerGroup===0&&h.push(E),f.push(E),E=E+x+b),e.virtualSize+=x+b,w=x,S+=1}}if(e.virtualSize=Math.max(e.virtualSize,n)+g,a&&o&&("slide"===r.effect||"coverflow"===r.effect)&&(i.style.width=`${e.virtualSize+b}px`),r.setWrapperSize&&(i.style[e.getDirectionLabel("width")]=`${e.virtualSize+b}px`),T&&e.grid.updateWrapperSize(x,h),!r.centeredSlides){const t=[];for(let i=0;i<h.length;i+=1){let s=h[i];r.roundLengths&&(s=Math.floor(s)),h[i]<=e.virtualSize-n&&t.push(s)}h=t,Math.floor(e.virtualSize-n)-Math.floor(h[h.length-1])>1&&h.push(e.virtualSize-n)}if(l&&r.loop){const t=p[0]+b;if(r.slidesPerGroup>1){const i=Math.ceil((e.virtual.slidesBefore+e.virtual.slidesAfter)/r.slidesPerGroup),s=t*r.slidesPerGroup;for(let e=0;e<i;e+=1)h.push(h[h.length-1]+s)}for(let i=0;i<e.virtual.slidesBefore+e.virtual.slidesAfter;i+=1)1===r.slidesPerGroup&&h.push(h[h.length-1]+t),f.push(f[f.length-1]+t),e.virtualSize+=t}if(0===h.length&&(h=[0]),0!==b){const t=e.isHorizontal()&&a?"marginLeft":e.getDirectionLabel("marginRight");d.filter((e,t)=>!(r.cssMode&&!r.loop)||t!==d.length-1).forEach(e=>{e.style[t]=`${b}px`})}if(r.centeredSlides&&r.centeredSlidesBounds){let e=0;p.forEach(t=>{e+=t+(b||0)}),e-=b;const t=e>n?e-n:0;h=h.map(e=>e<=0?-m:e>t?t+g:e)}if(r.centerInsufficientSlides){let e=0;p.forEach(t=>{e+=t+(b||0)}),e-=b;const t=(r.slidesOffsetBefore||0)+(r.slidesOffsetAfter||0);if(e+t<n){const r=(n-e-t)/2;h.forEach((e,t)=>{h[t]=e-r}),f.forEach((e,t)=>{f[t]=e+r})}}if(Object.assign(e,{slides:d,snapGrid:h,slidesGrid:f,slidesSizesGrid:p}),r.centeredSlides&&r.cssMode&&!r.centeredSlidesBounds){Ws(i,"--swiper-centered-offset-before",-h[0]+"px"),Ws(i,"--swiper-centered-offset-after",e.size/2-p[p.length-1]/2+"px");const t=-e.snapGrid[0],r=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map(e=>e+t),e.slidesGrid=e.slidesGrid.map(e=>e+r)}if(u!==c&&e.emit("slidesLengthChange"),h.length!==v&&(e.params.watchOverflow&&e.checkOverflow(),e.emit("snapGridLengthChange")),f.length!==y&&e.emit("slidesGridLengthChange"),r.watchSlidesProgress&&e.updateSlidesOffset(),e.emit("slidesUpdated"),!(l||r.cssMode||"slide"!==r.effect&&"fade"!==r.effect)){const t=`${r.containerModifierClass}backface-hidden`,i=e.el.classList.contains(t);u<=r.maxBackfaceHiddenSlides?i||e.el.classList.add(t):i&&e.el.classList.remove(t)}},updateAutoHeight:function(e){const t=this,r=[],i=t.virtual&&t.params.virtual.enabled;let s,n=0;"number"==typeof e?t.setTransition(e):!0===e&&t.setTransition(t.params.speed);const a=e=>i?t.slides[t.getSlideIndexByData(e)]:t.slides[e];if("auto"!==t.params.slidesPerView&&t.params.slidesPerView>1)if(t.params.centeredSlides)(t.visibleSlides||[]).forEach(e=>{r.push(e)});else for(s=0;s<Math.ceil(t.params.slidesPerView);s+=1){const e=t.activeIndex+s;if(e>t.slides.length&&!i)break;r.push(a(e))}else r.push(a(t.activeIndex));for(s=0;s<r.length;s+=1)if(void 0!==r[s]){const e=r[s].offsetHeight;n=e>n?e:n}(n||0===n)&&(t.wrapperEl.style.height=`${n}px`)},updateSlidesOffset:function(){const e=this,t=e.slides,r=e.isElement?e.isHorizontal()?e.wrapperEl.offsetLeft:e.wrapperEl.offsetTop:0;for(let i=0;i<t.length;i+=1)t[i].swiperSlideOffset=(e.isHorizontal()?t[i].offsetLeft:t[i].offsetTop)-r-e.cssOverflowAdjustment()},updateSlidesProgress:function(e){void 0===e&&(e=this&&this.translate||0);const t=this,r=t.params,{slides:i,rtlTranslate:s,snapGrid:n}=t;if(0===i.length)return;void 0===i[0].swiperSlideOffset&&t.updateSlidesOffset();let a=-e;s&&(a=e),t.visibleSlidesIndexes=[],t.visibleSlides=[];let o=r.spaceBetween;"string"==typeof o&&o.indexOf("%")>=0?o=parseFloat(o.replace("%",""))/100*t.size:"string"==typeof o&&(o=parseFloat(o));for(let e=0;e<i.length;e+=1){const l=i[e];let c=l.swiperSlideOffset;r.cssMode&&r.centeredSlides&&(c-=i[0].swiperSlideOffset);const d=(a+(r.centeredSlides?t.minTranslate():0)-c)/(l.swiperSlideSize+o),u=(a-n[0]+(r.centeredSlides?t.minTranslate():0)-c)/(l.swiperSlideSize+o),h=-(a-c),f=h+t.slidesSizesGrid[e],p=h>=0&&h<=t.size-t.slidesSizesGrid[e],m=h>=0&&h<t.size-1||f>1&&f<=t.size||h<=0&&f>=t.size;m&&(t.visibleSlides.push(l),t.visibleSlidesIndexes.push(e)),dn(l,m,r.slideVisibleClass),dn(l,p,r.slideFullyVisibleClass),l.progress=s?-d:d,l.originalProgress=s?-u:u}},updateProgress:function(e){const t=this;if(void 0===e){const r=t.rtlTranslate?-1:1;e=t&&t.translate&&t.translate*r||0}const r=t.params,i=t.maxTranslate()-t.minTranslate();let{progress:s,isBeginning:n,isEnd:a,progressLoop:o}=t;const l=n,c=a;if(0===i)s=0,n=!0,a=!0;else{s=(e-t.minTranslate())/i;const r=Math.abs(e-t.minTranslate())<1,o=Math.abs(e-t.maxTranslate())<1;n=r||s<=0,a=o||s>=1,r&&(s=0),o&&(s=1)}if(r.loop){const r=t.getSlideIndexByData(0),i=t.getSlideIndexByData(t.slides.length-1),s=t.slidesGrid[r],n=t.slidesGrid[i],a=t.slidesGrid[t.slidesGrid.length-1],l=Math.abs(e);o=l>=s?(l-s)/a:(l+a-n)/a,o>1&&(o-=1)}Object.assign(t,{progress:s,progressLoop:o,isBeginning:n,isEnd:a}),(r.watchSlidesProgress||r.centeredSlides&&r.autoHeight)&&t.updateSlidesProgress(e),n&&!l&&t.emit("reachBeginning toEdge"),a&&!c&&t.emit("reachEnd toEdge"),(l&&!n||c&&!a)&&t.emit("fromEdge"),t.emit("progress",s)},updateSlidesClasses:function(){const e=this,{slides:t,params:r,slidesEl:i,activeIndex:s}=e,n=e.virtual&&r.virtual.enabled,a=e.grid&&r.grid&&r.grid.rows>1,o=e=>qs(i,`.${r.slideClass}${e}, swiper-slide${e}`)[0];let l,c,d;if(n)if(r.loop){let t=s-e.virtual.slidesBefore;t<0&&(t=e.virtual.slides.length+t),t>=e.virtual.slides.length&&(t-=e.virtual.slides.length),l=o(`[data-swiper-slide-index="${t}"]`)}else l=o(`[data-swiper-slide-index="${s}"]`);else a?(l=t.filter(e=>e.column===s)[0],d=t.filter(e=>e.column===s+1)[0],c=t.filter(e=>e.column===s-1)[0]):l=t[s];l&&(a||(d=function(e,t){const r=[];for(;e.nextElementSibling;){const i=e.nextElementSibling;t?i.matches(t)&&r.push(i):r.push(i),e=i}return r}(l,`.${r.slideClass}, swiper-slide`)[0],r.loop&&!d&&(d=t[0]),c=function(e,t){const r=[];for(;e.previousElementSibling;){const i=e.previousElementSibling;t?i.matches(t)&&r.push(i):r.push(i),e=i}return r}(l,`.${r.slideClass}, swiper-slide`)[0],r.loop&&0===!c&&(c=t[t.length-1]))),t.forEach(e=>{un(e,e===l,r.slideActiveClass),un(e,e===d,r.slideNextClass),un(e,e===c,r.slidePrevClass)}),e.emitSlidesClasses()},updateActiveIndex:function(e){const t=this,r=t.rtlTranslate?t.translate:-t.translate,{snapGrid:i,params:s,activeIndex:n,realIndex:a,snapIndex:o}=t;let l,c=e;const d=e=>{let r=e-t.virtual.slidesBefore;return r<0&&(r=t.virtual.slides.length+r),r>=t.virtual.slides.length&&(r-=t.virtual.slides.length),r};if(void 0===c&&(c=function(e){const{slidesGrid:t,params:r}=e,i=e.rtlTranslate?e.translate:-e.translate;let s;for(let e=0;e<t.length;e+=1)void 0!==t[e+1]?i>=t[e]&&i<t[e+1]-(t[e+1]-t[e])/2?s=e:i>=t[e]&&i<t[e+1]&&(s=e+1):i>=t[e]&&(s=e);return r.normalizeSlideIndex&&(s<0||void 0===s)&&(s=0),s}(t)),i.indexOf(r)>=0)l=i.indexOf(r);else{const e=Math.min(s.slidesPerGroupSkip,c);l=e+Math.floor((c-e)/s.slidesPerGroup)}if(l>=i.length&&(l=i.length-1),c===n&&!t.params.loop)return void(l!==o&&(t.snapIndex=l,t.emit("snapIndexChange")));if(c===n&&t.params.loop&&t.virtual&&t.params.virtual.enabled)return void(t.realIndex=d(c));const u=t.grid&&s.grid&&s.grid.rows>1;let h;if(t.virtual&&s.virtual.enabled&&s.loop)h=d(c);else if(u){const e=t.slides.filter(e=>e.column===c)[0];let r=parseInt(e.getAttribute("data-swiper-slide-index"),10);Number.isNaN(r)&&(r=Math.max(t.slides.indexOf(e),0)),h=Math.floor(r/s.grid.rows)}else if(t.slides[c]){const e=t.slides[c].getAttribute("data-swiper-slide-index");h=e?parseInt(e,10):c}else h=c;Object.assign(t,{previousSnapIndex:o,snapIndex:l,previousRealIndex:a,realIndex:h,previousIndex:n,activeIndex:c}),t.initialized&&pn(t),t.emit("activeIndexChange"),t.emit("snapIndexChange"),(t.initialized||t.params.runCallbacksOnInit)&&(a!==h&&t.emit("realIndexChange"),t.emit("slideChange"))},updateClickedSlide:function(e,t){const r=this,i=r.params;let s=e.closest(`.${i.slideClass}, swiper-slide`);!s&&r.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach(e=>{!s&&e.matches&&e.matches(`.${i.slideClass}, swiper-slide`)&&(s=e)});let n,a=!1;if(s)for(let e=0;e<r.slides.length;e+=1)if(r.slides[e]===s){a=!0,n=e;break}if(!s||!a)return r.clickedSlide=void 0,void(r.clickedIndex=void 0);r.clickedSlide=s,r.virtual&&r.params.virtual.enabled?r.clickedIndex=parseInt(s.getAttribute("data-swiper-slide-index"),10):r.clickedIndex=n,i.slideToClickedSlide&&void 0!==r.clickedIndex&&r.clickedIndex!==r.activeIndex&&r.slideToClickedSlide()}};var gn={getTranslate:function(e){void 0===e&&(e=this.isHorizontal()?"x":"y");const{params:t,rtlTranslate:r,translate:i,wrapperEl:s}=this;if(t.virtualTranslate)return r?-i:i;if(t.cssMode)return i;let n=Gs(s,e);return n+=this.cssOverflowAdjustment(),r&&(n=-n),n||0},setTranslate:function(e,t){const r=this,{rtlTranslate:i,params:s,wrapperEl:n,progress:a}=r;let o,l=0,c=0;r.isHorizontal()?l=i?-e:e:c=e,s.roundLengths&&(l=Math.floor(l),c=Math.floor(c)),r.previousTranslate=r.translate,r.translate=r.isHorizontal()?l:c,s.cssMode?n[r.isHorizontal()?"scrollLeft":"scrollTop"]=r.isHorizontal()?-l:-c:s.virtualTranslate||(r.isHorizontal()?l-=r.cssOverflowAdjustment():c-=r.cssOverflowAdjustment(),n.style.transform=`translate3d(${l}px, ${c}px, 0px)`);const d=r.maxTranslate()-r.minTranslate();o=0===d?0:(e-r.minTranslate())/d,o!==a&&r.updateProgress(e),r.emit("setTranslate",r.translate,t)},minTranslate:function(){return-this.snapGrid[0]},maxTranslate:function(){return-this.snapGrid[this.snapGrid.length-1]},translateTo:function(e,t,r,i,s){void 0===e&&(e=0),void 0===t&&(t=this.params.speed),void 0===r&&(r=!0),void 0===i&&(i=!0);const n=this,{params:a,wrapperEl:o}=n;if(n.animating&&a.preventInteractionOnTransition)return!1;const l=n.minTranslate(),c=n.maxTranslate();let d;if(d=i&&e>l?l:i&&e<c?c:e,n.updateProgress(d),a.cssMode){const e=n.isHorizontal();if(0===t)o[e?"scrollLeft":"scrollTop"]=-d;else{if(!n.support.smoothScroll)return Ys({swiper:n,targetPosition:-d,side:e?"left":"top"}),!0;o.scrollTo({[e?"left":"top"]:-d,behavior:"smooth"})}return!0}return 0===t?(n.setTransition(0),n.setTranslate(d),r&&(n.emit("beforeTransitionStart",t,s),n.emit("transitionEnd"))):(n.setTransition(t),n.setTranslate(d),r&&(n.emit("beforeTransitionStart",t,s),n.emit("transitionStart")),n.animating||(n.animating=!0,n.onTranslateToWrapperTransitionEnd||(n.onTranslateToWrapperTransitionEnd=function(e){n&&!n.destroyed&&e.target===this&&(n.wrapperEl.removeEventListener("transitionend",n.onTranslateToWrapperTransitionEnd),n.onTranslateToWrapperTransitionEnd=null,delete n.onTranslateToWrapperTransitionEnd,n.animating=!1,r&&n.emit("transitionEnd"))}),n.wrapperEl.addEventListener("transitionend",n.onTranslateToWrapperTransitionEnd))),!0}};function vn(e){let{swiper:t,runCallbacks:r,direction:i,step:s}=e;const{activeIndex:n,previousIndex:a}=t;let o=i;if(o||(o=n>a?"next":n<a?"prev":"reset"),t.emit(`transition${s}`),r&&n!==a){if("reset"===o)return void t.emit(`slideResetTransition${s}`);t.emit(`slideChangeTransition${s}`),"next"===o?t.emit(`slideNextTransition${s}`):t.emit(`slidePrevTransition${s}`)}}var yn={setTransition:function(e,t){const r=this;r.params.cssMode||(r.wrapperEl.style.transitionDuration=`${e}ms`,r.wrapperEl.style.transitionDelay=0===e?"0ms":""),r.emit("setTransition",e,t)},transitionStart:function(e,t){void 0===e&&(e=!0);const r=this,{params:i}=r;i.cssMode||(i.autoHeight&&r.updateAutoHeight(),vn({swiper:r,runCallbacks:e,direction:t,step:"Start"}))},transitionEnd:function(e,t){void 0===e&&(e=!0);const r=this,{params:i}=r;r.animating=!1,i.cssMode||(r.setTransition(0),vn({swiper:r,runCallbacks:e,direction:t,step:"End"}))}};var bn={slideTo:function(e,t,r,i,s){void 0===e&&(e=0),void 0===r&&(r=!0),"string"==typeof e&&(e=parseInt(e,10));const n=this;let a=e;a<0&&(a=0);const{params:o,snapGrid:l,slidesGrid:c,previousIndex:d,activeIndex:u,rtlTranslate:h,wrapperEl:f,enabled:p}=n;if(!p&&!i&&!s||n.destroyed||n.animating&&o.preventInteractionOnTransition)return!1;void 0===t&&(t=n.params.speed);const m=Math.min(n.params.slidesPerGroupSkip,a);let g=m+Math.floor((a-m)/n.params.slidesPerGroup);g>=l.length&&(g=l.length-1);const v=-l[g];if(o.normalizeSlideIndex)for(let e=0;e<c.length;e+=1){const t=-Math.floor(100*v),r=Math.floor(100*c[e]),i=Math.floor(100*c[e+1]);void 0!==c[e+1]?t>=r&&t<i-(i-r)/2?a=e:t>=r&&t<i&&(a=e+1):t>=r&&(a=e)}if(n.initialized&&a!==u){if(!n.allowSlideNext&&(h?v>n.translate&&v>n.minTranslate():v<n.translate&&v<n.minTranslate()))return!1;if(!n.allowSlidePrev&&v>n.translate&&v>n.maxTranslate()&&(u||0)!==a)return!1}let y;a!==(d||0)&&r&&n.emit("beforeSlideChangeStart"),n.updateProgress(v),y=a>u?"next":a<u?"prev":"reset";const b=n.virtual&&n.params.virtual.enabled;if(!(b&&s)&&(h&&-v===n.translate||!h&&v===n.translate))return n.updateActiveIndex(a),o.autoHeight&&n.updateAutoHeight(),n.updateSlidesClasses(),"slide"!==o.effect&&n.setTranslate(v),"reset"!==y&&(n.transitionStart(r,y),n.transitionEnd(r,y)),!1;if(o.cssMode){const e=n.isHorizontal(),r=h?v:-v;if(0===t)b&&(n.wrapperEl.style.scrollSnapType="none",n._immediateVirtual=!0),b&&!n._cssModeVirtualInitialSet&&n.params.initialSlide>0?(n._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{f[e?"scrollLeft":"scrollTop"]=r})):f[e?"scrollLeft":"scrollTop"]=r,b&&requestAnimationFrame(()=>{n.wrapperEl.style.scrollSnapType="",n._immediateVirtual=!1});else{if(!n.support.smoothScroll)return Ys({swiper:n,targetPosition:r,side:e?"left":"top"}),!0;f.scrollTo({[e?"left":"top"]:r,behavior:"smooth"})}return!0}return n.setTransition(t),n.setTranslate(v),n.updateActiveIndex(a),n.updateSlidesClasses(),n.emit("beforeTransitionStart",t,i),n.transitionStart(r,y),0===t?n.transitionEnd(r,y):n.animating||(n.animating=!0,n.onSlideToWrapperTransitionEnd||(n.onSlideToWrapperTransitionEnd=function(e){n&&!n.destroyed&&e.target===this&&(n.wrapperEl.removeEventListener("transitionend",n.onSlideToWrapperTransitionEnd),n.onSlideToWrapperTransitionEnd=null,delete n.onSlideToWrapperTransitionEnd,n.transitionEnd(r,y))}),n.wrapperEl.addEventListener("transitionend",n.onSlideToWrapperTransitionEnd)),!0},slideToLoop:function(e,t,r,i){if(void 0===e&&(e=0),void 0===r&&(r=!0),"string"==typeof e){e=parseInt(e,10)}const s=this;if(s.destroyed)return;void 0===t&&(t=s.params.speed);const n=s.grid&&s.params.grid&&s.params.grid.rows>1;let a=e;if(s.params.loop)if(s.virtual&&s.params.virtual.enabled)a+=s.virtual.slidesBefore;else{let e;if(n){const t=a*s.params.grid.rows;e=s.slides.filter(e=>1*e.getAttribute("data-swiper-slide-index")===t)[0].column}else e=s.getSlideIndexByData(a);const t=n?Math.ceil(s.slides.length/s.params.grid.rows):s.slides.length,{centeredSlides:r}=s.params;let o=s.params.slidesPerView;"auto"===o?o=s.slidesPerViewDynamic():(o=Math.ceil(parseFloat(s.params.slidesPerView,10)),r&&o%2==0&&(o+=1));let l=t-e<o;if(r&&(l=l||e<Math.ceil(o/2)),i&&r&&"auto"!==s.params.slidesPerView&&!n&&(l=!1),l){const i=r?e<s.activeIndex?"prev":"next":e-s.activeIndex-1<s.params.slidesPerView?"next":"prev";s.loopFix({direction:i,slideTo:!0,activeSlideIndex:"next"===i?e+1:e-t+1,slideRealIndex:"next"===i?s.realIndex:void 0})}if(n){const e=a*s.params.grid.rows;a=s.slides.filter(t=>1*t.getAttribute("data-swiper-slide-index")===e)[0].column}else a=s.getSlideIndexByData(a)}return requestAnimationFrame(()=>{s.slideTo(a,t,r,i)}),s},slideNext:function(e,t,r){void 0===t&&(t=!0);const i=this,{enabled:s,params:n,animating:a}=i;if(!s||i.destroyed)return i;void 0===e&&(e=i.params.speed);let o=n.slidesPerGroup;"auto"===n.slidesPerView&&1===n.slidesPerGroup&&n.slidesPerGroupAuto&&(o=Math.max(i.slidesPerViewDynamic("current",!0),1));const l=i.activeIndex<n.slidesPerGroupSkip?1:o,c=i.virtual&&n.virtual.enabled;if(n.loop){if(a&&!c&&n.loopPreventsSliding)return!1;if(i.loopFix({direction:"next"}),i._clientLeft=i.wrapperEl.clientLeft,i.activeIndex===i.slides.length-1&&n.cssMode)return requestAnimationFrame(()=>{i.slideTo(i.activeIndex+l,e,t,r)}),!0}return n.rewind&&i.isEnd?i.slideTo(0,e,t,r):i.slideTo(i.activeIndex+l,e,t,r)},slidePrev:function(e,t,r){void 0===t&&(t=!0);const i=this,{params:s,snapGrid:n,slidesGrid:a,rtlTranslate:o,enabled:l,animating:c}=i;if(!l||i.destroyed)return i;void 0===e&&(e=i.params.speed);const d=i.virtual&&s.virtual.enabled;if(s.loop){if(c&&!d&&s.loopPreventsSliding)return!1;i.loopFix({direction:"prev"}),i._clientLeft=i.wrapperEl.clientLeft}function u(e){return e<0?-Math.floor(Math.abs(e)):Math.floor(e)}const h=u(o?i.translate:-i.translate),f=n.map(e=>u(e));let p=n[f.indexOf(h)-1];if(void 0===p&&s.cssMode){let e;n.forEach((t,r)=>{h>=t&&(e=r)}),void 0!==e&&(p=n[e>0?e-1:e])}let m=0;if(void 0!==p&&(m=a.indexOf(p),m<0&&(m=i.activeIndex-1),"auto"===s.slidesPerView&&1===s.slidesPerGroup&&s.slidesPerGroupAuto&&(m=m-i.slidesPerViewDynamic("previous",!0)+1,m=Math.max(m,0))),s.rewind&&i.isBeginning){const s=i.params.virtual&&i.params.virtual.enabled&&i.virtual?i.virtual.slides.length-1:i.slides.length-1;return i.slideTo(s,e,t,r)}return s.loop&&0===i.activeIndex&&s.cssMode?(requestAnimationFrame(()=>{i.slideTo(m,e,t,r)}),!0):i.slideTo(m,e,t,r)},slideReset:function(e,t,r){void 0===t&&(t=!0);const i=this;if(!i.destroyed)return void 0===e&&(e=i.params.speed),i.slideTo(i.activeIndex,e,t,r)},slideToClosest:function(e,t,r,i){void 0===t&&(t=!0),void 0===i&&(i=.5);const s=this;if(s.destroyed)return;void 0===e&&(e=s.params.speed);let n=s.activeIndex;const a=Math.min(s.params.slidesPerGroupSkip,n),o=a+Math.floor((n-a)/s.params.slidesPerGroup),l=s.rtlTranslate?s.translate:-s.translate;if(l>=s.snapGrid[o]){const e=s.snapGrid[o];l-e>(s.snapGrid[o+1]-e)*i&&(n+=s.params.slidesPerGroup)}else{const e=s.snapGrid[o-1];l-e<=(s.snapGrid[o]-e)*i&&(n-=s.params.slidesPerGroup)}return n=Math.max(n,0),n=Math.min(n,s.slidesGrid.length-1),s.slideTo(n,e,t,r)},slideToClickedSlide:function(){const e=this;if(e.destroyed)return;const{params:t,slidesEl:r}=e,i="auto"===t.slidesPerView?e.slidesPerViewDynamic():t.slidesPerView;let s,n=e.clickedIndex;const a=e.isElement?"swiper-slide":`.${t.slideClass}`;if(t.loop){if(e.animating)return;s=parseInt(e.clickedSlide.getAttribute("data-swiper-slide-index"),10),t.centeredSlides?n<e.loopedSlides-i/2||n>e.slides.length-e.loopedSlides+i/2?(e.loopFix(),n=e.getSlideIndex(qs(r,`${a}[data-swiper-slide-index="${s}"]`)[0]),Us(()=>{e.slideTo(n)})):e.slideTo(n):n>e.slides.length-i?(e.loopFix(),n=e.getSlideIndex(qs(r,`${a}[data-swiper-slide-index="${s}"]`)[0]),Us(()=>{e.slideTo(n)})):e.slideTo(n)}else e.slideTo(n)}};var En={loopCreate:function(e){const t=this,{params:r,slidesEl:i}=t;if(!r.loop||t.virtual&&t.params.virtual.enabled)return;const s=()=>{qs(i,`.${r.slideClass}, swiper-slide`).forEach((e,t)=>{e.setAttribute("data-swiper-slide-index",t)})},n=t.grid&&r.grid&&r.grid.rows>1,a=r.slidesPerGroup*(n?r.grid.rows:1),o=t.slides.length%a!==0,l=n&&t.slides.length%r.grid.rows!==0,c=e=>{for(let i=0;i<e;i+=1){const e=t.isElement?Qs("swiper-slide",[r.slideBlankClass]):Qs("div",[r.slideClass,r.slideBlankClass]);t.slidesEl.append(e)}};if(o){if(r.loopAddBlankSlides){c(a-t.slides.length%a),t.recalcSlides(),t.updateSlides()}else Xs("Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");s()}else if(l){if(r.loopAddBlankSlides){c(r.grid.rows-t.slides.length%r.grid.rows),t.recalcSlides(),t.updateSlides()}else Xs("Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");s()}else s();t.loopFix({slideRealIndex:e,direction:r.centeredSlides?void 0:"next"})},loopFix:function(e){let{slideRealIndex:t,slideTo:r=!0,direction:i,setTranslate:s,activeSlideIndex:n,byController:a,byMousewheel:o}=void 0===e?{}:e;const l=this;if(!l.params.loop)return;l.emit("beforeLoopFix");const{slides:c,allowSlidePrev:d,allowSlideNext:u,slidesEl:h,params:f}=l,{centeredSlides:p}=f;if(l.allowSlidePrev=!0,l.allowSlideNext=!0,l.virtual&&f.virtual.enabled)return r&&(f.centeredSlides||0!==l.snapIndex?f.centeredSlides&&l.snapIndex<f.slidesPerView?l.slideTo(l.virtual.slides.length+l.snapIndex,0,!1,!0):l.snapIndex===l.snapGrid.length-1&&l.slideTo(l.virtual.slidesBefore,0,!1,!0):l.slideTo(l.virtual.slides.length,0,!1,!0)),l.allowSlidePrev=d,l.allowSlideNext=u,void l.emit("loopFix");let m=f.slidesPerView;"auto"===m?m=l.slidesPerViewDynamic():(m=Math.ceil(parseFloat(f.slidesPerView,10)),p&&m%2==0&&(m+=1));const g=f.slidesPerGroupAuto?m:f.slidesPerGroup;let v=g;v%g!==0&&(v+=g-v%g),v+=f.loopAdditionalSlides,l.loopedSlides=v;const y=l.grid&&f.grid&&f.grid.rows>1;c.length<m+v?Xs("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled and not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"):y&&"row"===f.grid.fill&&Xs("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");const b=[],E=[];let w=l.activeIndex;void 0===n?n=l.getSlideIndex(c.filter(e=>e.classList.contains(f.slideActiveClass))[0]):w=n;const S="next"===i||!i,T="prev"===i||!i;let x=0,A=0;const k=y?Math.ceil(c.length/f.grid.rows):c.length,L=(y?c[n].column:n)+(p&&void 0===s?-m/2+.5:0);if(L<v){x=Math.max(v-L,g);for(let e=0;e<v-L;e+=1){const t=e-Math.floor(e/k)*k;if(y){const e=k-t-1;for(let t=c.length-1;t>=0;t-=1)c[t].column===e&&b.push(t)}else b.push(k-t-1)}}else if(L+m>k-v){A=Math.max(L-(k-2*v),g);for(let e=0;e<A;e+=1){const t=e-Math.floor(e/k)*k;y?c.forEach((e,r)=>{e.column===t&&E.push(r)}):E.push(t)}}if(l.__preventObserver__=!0,requestAnimationFrame(()=>{l.__preventObserver__=!1}),T&&b.forEach(e=>{c[e].swiperLoopMoveDOM=!0,h.prepend(c[e]),c[e].swiperLoopMoveDOM=!1}),S&&E.forEach(e=>{c[e].swiperLoopMoveDOM=!0,h.append(c[e]),c[e].swiperLoopMoveDOM=!1}),l.recalcSlides(),"auto"===f.slidesPerView?l.updateSlides():y&&(b.length>0&&T||E.length>0&&S)&&l.slides.forEach((e,t)=>{l.grid.updateSlide(t,e,l.slides)}),f.watchSlidesProgress&&l.updateSlidesOffset(),r)if(b.length>0&&T){if(void 0===t){const e=l.slidesGrid[w],t=l.slidesGrid[w+x]-e;o?l.setTranslate(l.translate-t):(l.slideTo(w+Math.ceil(x),0,!1,!0),s&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-t,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-t))}else if(s){const e=y?b.length/f.grid.rows:b.length;l.slideTo(l.activeIndex+e,0,!1,!0),l.touchEventsData.currentTranslate=l.translate}}else if(E.length>0&&S)if(void 0===t){const e=l.slidesGrid[w],t=l.slidesGrid[w-A]-e;o?l.setTranslate(l.translate-t):(l.slideTo(w-A,0,!1,!0),s&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-t,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-t))}else{const e=y?E.length/f.grid.rows:E.length;l.slideTo(l.activeIndex-e,0,!1,!0)}if(l.allowSlidePrev=d,l.allowSlideNext=u,l.controller&&l.controller.control&&!a){const e={slideRealIndex:t,direction:i,setTranslate:s,activeSlideIndex:n,byController:!0};Array.isArray(l.controller.control)?l.controller.control.forEach(t=>{!t.destroyed&&t.params.loop&&t.loopFix({...e,slideTo:t.params.slidesPerView===f.slidesPerView&&r})}):l.controller.control instanceof l.constructor&&l.controller.control.params.loop&&l.controller.control.loopFix({...e,slideTo:l.controller.control.params.slidesPerView===f.slidesPerView&&r})}l.emit("loopFix")},loopDestroy:function(){const e=this,{params:t,slidesEl:r}=e;if(!t.loop||e.virtual&&e.params.virtual.enabled)return;e.recalcSlides();const i=[];e.slides.forEach(e=>{const t=void 0===e.swiperSlideIndex?1*e.getAttribute("data-swiper-slide-index"):e.swiperSlideIndex;i[t]=e}),e.slides.forEach(e=>{e.removeAttribute("data-swiper-slide-index")}),i.forEach(e=>{r.append(e)}),e.recalcSlides(),e.slideTo(e.realIndex,0)}};function wn(e,t,r){const i=Bs(),{params:s}=e,n=s.edgeSwipeDetection,a=s.edgeSwipeThreshold;return!n||!(r<=a||r>=i.innerWidth-a)||"prevent"===n&&(t.preventDefault(),!0)}function Sn(e){const t=this,r=Fs();let i=e;i.originalEvent&&(i=i.originalEvent);const s=t.touchEventsData;if("pointerdown"===i.type){if(null!==s.pointerId&&s.pointerId!==i.pointerId)return;s.pointerId=i.pointerId}else"touchstart"===i.type&&1===i.targetTouches.length&&(s.touchId=i.targetTouches[0].identifier);if("touchstart"===i.type)return void wn(t,i,i.targetTouches[0].pageX);const{params:n,touches:a,enabled:o}=t;if(!o)return;if(!n.simulateTouch&&"mouse"===i.pointerType)return;if(t.animating&&n.preventInteractionOnTransition)return;!t.animating&&n.cssMode&&n.loop&&t.loopFix();let l=i.target;if("wrapper"===n.touchEventsTarget&&!function(e,t){const r=t.contains(e);if(!r&&t instanceof HTMLSlotElement)return[...t.assignedElements()].includes(e);return r}(l,t.wrapperEl))return;if("which"in i&&3===i.which)return;if("button"in i&&i.button>0)return;if(s.isTouched&&s.isMoved)return;const c=!!n.noSwipingClass&&""!==n.noSwipingClass,d=i.composedPath?i.composedPath():i.path;c&&i.target&&i.target.shadowRoot&&d&&(l=d[0]);const u=n.noSwipingSelector?n.noSwipingSelector:`.${n.noSwipingClass}`,h=!(!i.target||!i.target.shadowRoot);if(n.noSwiping&&(h?function(e,t){return void 0===t&&(t=this),function t(r){if(!r||r===Fs()||r===Bs())return null;r.assignedSlot&&(r=r.assignedSlot);const i=r.closest(e);return i||r.getRootNode?i||t(r.getRootNode().host):null}(t)}(u,l):l.closest(u)))return void(t.allowClick=!0);if(n.swipeHandler&&!l.closest(n.swipeHandler))return;a.currentX=i.pageX,a.currentY=i.pageY;const f=a.currentX,p=a.currentY;if(!wn(t,i,f))return;Object.assign(s,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),a.startX=f,a.startY=p,s.touchStartTime=zs(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,n.threshold>0&&(s.allowThresholdMove=!1);let m=!0;l.matches(s.focusableElements)&&(m=!1,"SELECT"===l.nodeName&&(s.isTouched=!1)),r.activeElement&&r.activeElement.matches(s.focusableElements)&&r.activeElement!==l&&("mouse"===i.pointerType||"mouse"!==i.pointerType&&!l.matches(s.focusableElements))&&r.activeElement.blur();const g=m&&t.allowTouchMove&&n.touchStartPreventDefault;!n.touchStartForcePreventDefault&&!g||l.isContentEditable||i.preventDefault(),n.freeMode&&n.freeMode.enabled&&t.freeMode&&t.animating&&!n.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",i)}function Tn(e){const t=Fs(),r=this,i=r.touchEventsData,{params:s,touches:n,rtlTranslate:a,enabled:o}=r;if(!o)return;if(!s.simulateTouch&&"mouse"===e.pointerType)return;let l,c=e;if(c.originalEvent&&(c=c.originalEvent),"pointermove"===c.type){if(null!==i.touchId)return;if(c.pointerId!==i.pointerId)return}if("touchmove"===c.type){if(l=[...c.changedTouches].filter(e=>e.identifier===i.touchId)[0],!l||l.identifier!==i.touchId)return}else l=c;if(!i.isTouched)return void(i.startMoving&&i.isScrolling&&r.emit("touchMoveOpposite",c));const d=l.pageX,u=l.pageY;if(c.preventedByNestedSwiper)return n.startX=d,void(n.startY=u);if(!r.allowTouchMove)return c.target.matches(i.focusableElements)||(r.allowClick=!1),void(i.isTouched&&(Object.assign(n,{startX:d,startY:u,currentX:d,currentY:u}),i.touchStartTime=zs()));if(s.touchReleaseOnEdges&&!s.loop)if(r.isVertical()){if(u<n.startY&&r.translate<=r.maxTranslate()||u>n.startY&&r.translate>=r.minTranslate())return i.isTouched=!1,void(i.isMoved=!1)}else if(d<n.startX&&r.translate<=r.maxTranslate()||d>n.startX&&r.translate>=r.minTranslate())return;if(t.activeElement&&t.activeElement.matches(i.focusableElements)&&t.activeElement!==c.target&&"mouse"!==c.pointerType&&t.activeElement.blur(),t.activeElement&&c.target===t.activeElement&&c.target.matches(i.focusableElements))return i.isMoved=!0,void(r.allowClick=!1);i.allowTouchCallbacks&&r.emit("touchMove",c),n.previousX=n.currentX,n.previousY=n.currentY,n.currentX=d,n.currentY=u;const h=n.currentX-n.startX,f=n.currentY-n.startY;if(r.params.threshold&&Math.sqrt(h**2+f**2)<r.params.threshold)return;if(void 0===i.isScrolling){let e;r.isHorizontal()&&n.currentY===n.startY||r.isVertical()&&n.currentX===n.startX?i.isScrolling=!1:h*h+f*f>=25&&(e=180*Math.atan2(Math.abs(f),Math.abs(h))/Math.PI,i.isScrolling=r.isHorizontal()?e>s.touchAngle:90-e>s.touchAngle)}if(i.isScrolling&&r.emit("touchMoveOpposite",c),void 0===i.startMoving&&(n.currentX===n.startX&&n.currentY===n.startY||(i.startMoving=!0)),i.isScrolling||"touchmove"===c.type&&i.preventTouchMoveFromPointerMove)return void(i.isTouched=!1);if(!i.startMoving)return;r.allowClick=!1,!s.cssMode&&c.cancelable&&c.preventDefault(),s.touchMoveStopPropagation&&!s.nested&&c.stopPropagation();let p=r.isHorizontal()?h:f,m=r.isHorizontal()?n.currentX-n.previousX:n.currentY-n.previousY;s.oneWayMovement&&(p=Math.abs(p)*(a?1:-1),m=Math.abs(m)*(a?1:-1)),n.diff=p,p*=s.touchRatio,a&&(p=-p,m=-m);const g=r.touchesDirection;r.swipeDirection=p>0?"prev":"next",r.touchesDirection=m>0?"prev":"next";const v=r.params.loop&&!s.cssMode,y="next"===r.touchesDirection&&r.allowSlideNext||"prev"===r.touchesDirection&&r.allowSlidePrev;if(!i.isMoved){if(v&&y&&r.loopFix({direction:r.swipeDirection}),i.startTranslate=r.getTranslate(),r.setTransition(0),r.animating){const e=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});r.wrapperEl.dispatchEvent(e)}i.allowMomentumBounce=!1,!s.grabCursor||!0!==r.allowSlideNext&&!0!==r.allowSlidePrev||r.setGrabCursor(!0),r.emit("sliderFirstMove",c)}if((new Date).getTime(),i.isMoved&&i.allowThresholdMove&&g!==r.touchesDirection&&v&&y&&Math.abs(p)>=1)return Object.assign(n,{startX:d,startY:u,currentX:d,currentY:u,startTranslate:i.currentTranslate}),i.loopSwapReset=!0,void(i.startTranslate=i.currentTranslate);r.emit("sliderMove",c),i.isMoved=!0,i.currentTranslate=p+i.startTranslate;let b=!0,E=s.resistanceRatio;if(s.touchReleaseOnEdges&&(E=0),p>0?(v&&y&&i.allowThresholdMove&&i.currentTranslate>(s.centeredSlides?r.minTranslate()-r.slidesSizesGrid[r.activeIndex+1]-("auto"!==s.slidesPerView&&r.slides.length-s.slidesPerView>=2?r.slidesSizesGrid[r.activeIndex+1]+r.params.spaceBetween:0)-r.params.spaceBetween:r.minTranslate())&&r.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),i.currentTranslate>r.minTranslate()&&(b=!1,s.resistance&&(i.currentTranslate=r.minTranslate()-1+(-r.minTranslate()+i.startTranslate+p)**E))):p<0&&(v&&y&&i.allowThresholdMove&&i.currentTranslate<(s.centeredSlides?r.maxTranslate()+r.slidesSizesGrid[r.slidesSizesGrid.length-1]+r.params.spaceBetween+("auto"!==s.slidesPerView&&r.slides.length-s.slidesPerView>=2?r.slidesSizesGrid[r.slidesSizesGrid.length-1]+r.params.spaceBetween:0):r.maxTranslate())&&r.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:r.slides.length-("auto"===s.slidesPerView?r.slidesPerViewDynamic():Math.ceil(parseFloat(s.slidesPerView,10)))}),i.currentTranslate<r.maxTranslate()&&(b=!1,s.resistance&&(i.currentTranslate=r.maxTranslate()+1-(r.maxTranslate()-i.startTranslate-p)**E))),b&&(c.preventedByNestedSwiper=!0),!r.allowSlideNext&&"next"===r.swipeDirection&&i.currentTranslate<i.startTranslate&&(i.currentTranslate=i.startTranslate),!r.allowSlidePrev&&"prev"===r.swipeDirection&&i.currentTranslate>i.startTranslate&&(i.currentTranslate=i.startTranslate),r.allowSlidePrev||r.allowSlideNext||(i.currentTranslate=i.startTranslate),s.threshold>0){if(!(Math.abs(p)>s.threshold||i.allowThresholdMove))return void(i.currentTranslate=i.startTranslate);if(!i.allowThresholdMove)return i.allowThresholdMove=!0,n.startX=n.currentX,n.startY=n.currentY,i.currentTranslate=i.startTranslate,void(n.diff=r.isHorizontal()?n.currentX-n.startX:n.currentY-n.startY)}s.followFinger&&!s.cssMode&&((s.freeMode&&s.freeMode.enabled&&r.freeMode||s.watchSlidesProgress)&&(r.updateActiveIndex(),r.updateSlidesClasses()),s.freeMode&&s.freeMode.enabled&&r.freeMode&&r.freeMode.onTouchMove(),r.updateProgress(i.currentTranslate),r.setTranslate(i.currentTranslate))}function xn(e){const t=this,r=t.touchEventsData;let i,s=e;s.originalEvent&&(s=s.originalEvent);if("touchend"===s.type||"touchcancel"===s.type){if(i=[...s.changedTouches].filter(e=>e.identifier===r.touchId)[0],!i||i.identifier!==r.touchId)return}else{if(null!==r.touchId)return;if(s.pointerId!==r.pointerId)return;i=s}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(s.type)){if(!(["pointercancel","contextmenu"].includes(s.type)&&(t.browser.isSafari||t.browser.isWebView)))return}r.pointerId=null,r.touchId=null;const{params:n,touches:a,rtlTranslate:o,slidesGrid:l,enabled:c}=t;if(!c)return;if(!n.simulateTouch&&"mouse"===s.pointerType)return;if(r.allowTouchCallbacks&&t.emit("touchEnd",s),r.allowTouchCallbacks=!1,!r.isTouched)return r.isMoved&&n.grabCursor&&t.setGrabCursor(!1),r.isMoved=!1,void(r.startMoving=!1);n.grabCursor&&r.isMoved&&r.isTouched&&(!0===t.allowSlideNext||!0===t.allowSlidePrev)&&t.setGrabCursor(!1);const d=zs(),u=d-r.touchStartTime;if(t.allowClick){const e=s.path||s.composedPath&&s.composedPath();t.updateClickedSlide(e&&e[0]||s.target,e),t.emit("tap click",s),u<300&&d-r.lastClickTime<300&&t.emit("doubleTap doubleClick",s)}if(r.lastClickTime=zs(),Us(()=>{t.destroyed||(t.allowClick=!0)}),!r.isTouched||!r.isMoved||!t.swipeDirection||0===a.diff&&!r.loopSwapReset||r.currentTranslate===r.startTranslate&&!r.loopSwapReset)return r.isTouched=!1,r.isMoved=!1,void(r.startMoving=!1);let h;if(r.isTouched=!1,r.isMoved=!1,r.startMoving=!1,h=n.followFinger?o?t.translate:-t.translate:-r.currentTranslate,n.cssMode)return;if(n.freeMode&&n.freeMode.enabled)return void t.freeMode.onTouchEnd({currentPos:h});const f=h>=-t.maxTranslate()&&!t.params.loop;let p=0,m=t.slidesSizesGrid[0];for(let e=0;e<l.length;e+=e<n.slidesPerGroupSkip?1:n.slidesPerGroup){const t=e<n.slidesPerGroupSkip-1?1:n.slidesPerGroup;void 0!==l[e+t]?(f||h>=l[e]&&h<l[e+t])&&(p=e,m=l[e+t]-l[e]):(f||h>=l[e])&&(p=e,m=l[l.length-1]-l[l.length-2])}let g=null,v=null;n.rewind&&(t.isBeginning?v=n.virtual&&n.virtual.enabled&&t.virtual?t.virtual.slides.length-1:t.slides.length-1:t.isEnd&&(g=0));const y=(h-l[p])/m,b=p<n.slidesPerGroupSkip-1?1:n.slidesPerGroup;if(u>n.longSwipesMs){if(!n.longSwipes)return void t.slideTo(t.activeIndex);"next"===t.swipeDirection&&(y>=n.longSwipesRatio?t.slideTo(n.rewind&&t.isEnd?g:p+b):t.slideTo(p)),"prev"===t.swipeDirection&&(y>1-n.longSwipesRatio?t.slideTo(p+b):null!==v&&y<0&&Math.abs(y)>n.longSwipesRatio?t.slideTo(v):t.slideTo(p))}else{if(!n.shortSwipes)return void t.slideTo(t.activeIndex);t.navigation&&(s.target===t.navigation.nextEl||s.target===t.navigation.prevEl)?s.target===t.navigation.nextEl?t.slideTo(p+b):t.slideTo(p):("next"===t.swipeDirection&&t.slideTo(null!==g?g:p+b),"prev"===t.swipeDirection&&t.slideTo(null!==v?v:p))}}function An(){const e=this,{params:t,el:r}=e;if(r&&0===r.offsetWidth)return;t.breakpoints&&e.setBreakpoint();const{allowSlideNext:i,allowSlidePrev:s,snapGrid:n}=e,a=e.virtual&&e.params.virtual.enabled;e.allowSlideNext=!0,e.allowSlidePrev=!0,e.updateSize(),e.updateSlides(),e.updateSlidesClasses();const o=a&&t.loop;!("auto"===t.slidesPerView||t.slidesPerView>1)||!e.isEnd||e.isBeginning||e.params.centeredSlides||o?e.params.loop&&!a?e.slideToLoop(e.realIndex,0,!1,!0):e.slideTo(e.activeIndex,0,!1,!0):e.slideTo(e.slides.length-1,0,!1,!0),e.autoplay&&e.autoplay.running&&e.autoplay.paused&&(clearTimeout(e.autoplay.resizeTimeout),e.autoplay.resizeTimeout=setTimeout(()=>{e.autoplay&&e.autoplay.running&&e.autoplay.paused&&e.autoplay.resume()},500)),e.allowSlidePrev=s,e.allowSlideNext=i,e.params.watchOverflow&&n!==e.snapGrid&&e.checkOverflow()}function kn(e){const t=this;t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function Ln(){const e=this,{wrapperEl:t,rtlTranslate:r,enabled:i}=e;if(!i)return;let s;e.previousTranslate=e.translate,e.isHorizontal()?e.translate=-t.scrollLeft:e.translate=-t.scrollTop,0===e.translate&&(e.translate=0),e.updateActiveIndex(),e.updateSlidesClasses();const n=e.maxTranslate()-e.minTranslate();s=0===n?0:(e.translate-e.minTranslate())/n,s!==e.progress&&e.updateProgress(r?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}function In(e){const t=this;hn(t,e.target),t.params.cssMode||"auto"!==t.params.slidesPerView&&!t.params.autoHeight||t.update()}function Rn(){const e=this;e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}const Pn=(e,t)=>{const r=Fs(),{params:i,el:s,wrapperEl:n,device:a}=e,o=!!i.nested,l="on"===t?"addEventListener":"removeEventListener",c=t;s&&"string"!=typeof s&&(r[l]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:o}),s[l]("touchstart",e.onTouchStart,{passive:!1}),s[l]("pointerdown",e.onTouchStart,{passive:!1}),r[l]("touchmove",e.onTouchMove,{passive:!1,capture:o}),r[l]("pointermove",e.onTouchMove,{passive:!1,capture:o}),r[l]("touchend",e.onTouchEnd,{passive:!0}),r[l]("pointerup",e.onTouchEnd,{passive:!0}),r[l]("pointercancel",e.onTouchEnd,{passive:!0}),r[l]("touchcancel",e.onTouchEnd,{passive:!0}),r[l]("pointerout",e.onTouchEnd,{passive:!0}),r[l]("pointerleave",e.onTouchEnd,{passive:!0}),r[l]("contextmenu",e.onTouchEnd,{passive:!0}),(i.preventClicks||i.preventClicksPropagation)&&s[l]("click",e.onClick,!0),i.cssMode&&n[l]("scroll",e.onScroll),i.updateOnWindowResize?e[c](a.ios||a.android?"resize orientationchange observerUpdate":"resize observerUpdate",An,!0):e[c]("observerUpdate",An,!0),s[l]("load",e.onLoad,{capture:!0}))};const Cn=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var Dn={setBreakpoint:function(){const e=this,{realIndex:t,initialized:r,params:i,el:s}=e,n=i.breakpoints;if(!n||n&&0===Object.keys(n).length)return;const a=e.getBreakpoint(n,e.params.breakpointsBase,e.el);if(!a||e.currentBreakpoint===a)return;const o=(a in n?n[a]:void 0)||e.originalParams,l=Cn(e,i),c=Cn(e,o),d=e.params.grabCursor,u=o.grabCursor,h=i.enabled;l&&!c?(s.classList.remove(`${i.containerModifierClass}grid`,`${i.containerModifierClass}grid-column`),e.emitContainerClasses()):!l&&c&&(s.classList.add(`${i.containerModifierClass}grid`),(o.grid.fill&&"column"===o.grid.fill||!o.grid.fill&&"column"===i.grid.fill)&&s.classList.add(`${i.containerModifierClass}grid-column`),e.emitContainerClasses()),d&&!u?e.unsetGrabCursor():!d&&u&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(t=>{if(void 0===o[t])return;const r=i[t]&&i[t].enabled,s=o[t]&&o[t].enabled;r&&!s&&e[t].disable(),!r&&s&&e[t].enable()});const f=o.direction&&o.direction!==i.direction,p=i.loop&&(o.slidesPerView!==i.slidesPerView||f),m=i.loop;f&&r&&e.changeDirection(),Vs(e.params,o);const g=e.params.enabled,v=e.params.loop;Object.assign(e,{allowTouchMove:e.params.allowTouchMove,allowSlideNext:e.params.allowSlideNext,allowSlidePrev:e.params.allowSlidePrev}),h&&!g?e.disable():!h&&g&&e.enable(),e.currentBreakpoint=a,e.emit("_beforeBreakpoint",o),r&&(p?(e.loopDestroy(),e.loopCreate(t),e.updateSlides()):!m&&v?(e.loopCreate(t),e.updateSlides()):m&&!v&&e.loopDestroy()),e.emit("breakpoint",o)},getBreakpoint:function(e,t,r){if(void 0===t&&(t="window"),!e||"container"===t&&!r)return;let i=!1;const s=Bs(),n="window"===t?s.innerHeight:r.clientHeight,a=Object.keys(e).map(e=>{if("string"==typeof e&&0===e.indexOf("@")){const t=parseFloat(e.substr(1));return{value:n*t,point:e}}return{value:e,point:e}});a.sort((e,t)=>parseInt(e.value,10)-parseInt(t.value,10));for(let e=0;e<a.length;e+=1){const{point:n,value:o}=a[e];"window"===t?s.matchMedia(`(min-width: ${o}px)`).matches&&(i=n):o<=r.clientWidth&&(i=n)}return i||"max"}};var _n={init:!0,direction:"horizontal",oneWayMovement:!1,swiperElementNodeName:"SWIPER-CONTAINER",touchEventsTarget:"wrapper",initialSlide:0,speed:300,cssMode:!1,updateOnWindowResize:!0,resizeObserver:!0,nested:!1,createElements:!1,eventsPrefix:"swiper",enabled:!0,focusableElements:"input, select, option, textarea, button, video, label",width:null,height:null,preventInteractionOnTransition:!1,userAgent:null,url:null,edgeSwipeDetection:!1,edgeSwipeThreshold:20,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",breakpoints:void 0,breakpointsBase:"window",spaceBetween:0,slidesPerView:1,slidesPerGroup:1,slidesPerGroupSkip:0,slidesPerGroupAuto:!1,centeredSlides:!1,centeredSlidesBounds:!1,slidesOffsetBefore:0,slidesOffsetAfter:0,normalizeSlideIndex:!0,centerInsufficientSlides:!1,watchOverflow:!0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,allowTouchMove:!0,threshold:5,touchMoveStopPropagation:!1,touchStartPreventDefault:!0,touchStartForcePreventDefault:!1,touchReleaseOnEdges:!1,uniqueNavElements:!0,resistance:!0,resistanceRatio:.85,watchSlidesProgress:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,slideToClickedSlide:!1,loop:!1,loopAddBlankSlides:!0,loopAdditionalSlides:0,loopPreventsSliding:!0,rewind:!1,allowSlidePrev:!0,allowSlideNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:null,passiveListeners:!0,maxBackfaceHiddenSlides:10,containerModifierClass:"swiper-",slideClass:"swiper-slide",slideBlankClass:"swiper-slide-blank",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideFullyVisibleClass:"swiper-slide-fully-visible",slideNextClass:"swiper-slide-next",slidePrevClass:"swiper-slide-prev",wrapperClass:"swiper-wrapper",lazyPreloaderClass:"swiper-lazy-preloader",lazyPreloadPrevNext:0,runCallbacksOnInit:!0,_emitClasses:!1};function On(e,t){return function(r){void 0===r&&(r={});const i=Object.keys(r)[0],s=r[i];"object"==typeof s&&null!==s?(!0===e[i]&&(e[i]={enabled:!0}),"navigation"===i&&e[i]&&e[i].enabled&&!e[i].prevEl&&!e[i].nextEl&&(e[i].auto=!0),["pagination","scrollbar"].indexOf(i)>=0&&e[i]&&e[i].enabled&&!e[i].el&&(e[i].auto=!0),i in e&&"enabled"in s?("object"!=typeof e[i]||"enabled"in e[i]||(e[i].enabled=!0),e[i]||(e[i]={enabled:!1}),Vs(t,r)):Vs(t,r)):Vs(t,r)}}const Mn={eventsEmitter:cn,update:mn,translate:gn,transition:yn,slide:bn,loop:En,grabCursor:{setGrabCursor:function(e){const t=this;if(!t.params.simulateTouch||t.params.watchOverflow&&t.isLocked||t.params.cssMode)return;const r="container"===t.params.touchEventsTarget?t.el:t.wrapperEl;t.isElement&&(t.__preventObserver__=!0),r.style.cursor="move",r.style.cursor=e?"grabbing":"grab",t.isElement&&requestAnimationFrame(()=>{t.__preventObserver__=!1})},unsetGrabCursor:function(){const e=this;e.params.watchOverflow&&e.isLocked||e.params.cssMode||(e.isElement&&(e.__preventObserver__=!0),e["container"===e.params.touchEventsTarget?"el":"wrapperEl"].style.cursor="",e.isElement&&requestAnimationFrame(()=>{e.__preventObserver__=!1}))}},events:{attachEvents:function(){const e=this,{params:t}=e;e.onTouchStart=Sn.bind(e),e.onTouchMove=Tn.bind(e),e.onTouchEnd=xn.bind(e),e.onDocumentTouchStart=Rn.bind(e),t.cssMode&&(e.onScroll=Ln.bind(e)),e.onClick=kn.bind(e),e.onLoad=In.bind(e),Pn(e,"on")},detachEvents:function(){Pn(this,"off")}},breakpoints:Dn,checkOverflow:{checkOverflow:function(){const e=this,{isLocked:t,params:r}=e,{slidesOffsetBefore:i}=r;if(i){const t=e.slides.length-1,r=e.slidesGrid[t]+e.slidesSizesGrid[t]+2*i;e.isLocked=e.size>r}else e.isLocked=1===e.snapGrid.length;!0===r.allowSlideNext&&(e.allowSlideNext=!e.isLocked),!0===r.allowSlidePrev&&(e.allowSlidePrev=!e.isLocked),t&&t!==e.isLocked&&(e.isEnd=!1),t!==e.isLocked&&e.emit(e.isLocked?"lock":"unlock")}},classes:{addClasses:function(){const e=this,{classNames:t,params:r,rtl:i,el:s,device:n}=e,a=function(e,t){const r=[];return e.forEach(e=>{"object"==typeof e?Object.keys(e).forEach(i=>{e[i]&&r.push(t+i)}):"string"==typeof e&&r.push(t+e)}),r}(["initialized",r.direction,{"free-mode":e.params.freeMode&&r.freeMode.enabled},{autoheight:r.autoHeight},{rtl:i},{grid:r.grid&&r.grid.rows>1},{"grid-column":r.grid&&r.grid.rows>1&&"column"===r.grid.fill},{android:n.android},{ios:n.ios},{"css-mode":r.cssMode},{centered:r.cssMode&&r.centeredSlides},{"watch-progress":r.watchSlidesProgress}],r.containerModifierClass);t.push(...a),s.classList.add(...t),e.emitContainerClasses()},removeClasses:function(){const{el:e,classNames:t}=this;e&&"string"!=typeof e&&(e.classList.remove(...t),this.emitContainerClasses())}}},Nn={};let Fn=class e{constructor(){let t,r;for(var i=arguments.length,s=new Array(i),n=0;n<i;n++)s[n]=arguments[n];1===s.length&&s[0].constructor&&"Object"===Object.prototype.toString.call(s[0]).slice(8,-1)?r=s[0]:[t,r]=s,r||(r={}),r=Vs({},r),t&&!r.el&&(r.el=t);const a=Fs();if(r.el&&"string"==typeof r.el&&a.querySelectorAll(r.el).length>1){const t=[];return a.querySelectorAll(r.el).forEach(i=>{const s=Vs({},r,{el:i});t.push(new e(s))}),t}const o=this;o.__swiper__=!0,o.support=an(),o.device=on({userAgent:r.userAgent}),o.browser=ln(),o.eventsListeners={},o.eventsAnyListeners=[],o.modules=[...o.__modules__],r.modules&&Array.isArray(r.modules)&&o.modules.push(...r.modules);const l={};o.modules.forEach(e=>{e({params:r,swiper:o,extendParams:On(r,l),on:o.on.bind(o),once:o.once.bind(o),off:o.off.bind(o),emit:o.emit.bind(o)})});const c=Vs({},_n,l);return o.params=Vs({},c,Nn,r),o.originalParams=Vs({},o.params),o.passedParams=Vs({},r),o.params&&o.params.on&&Object.keys(o.params.on).forEach(e=>{o.on(e,o.params.on[e])}),o.params&&o.params.onAny&&o.onAny(o.params.onAny),Object.assign(o,{enabled:o.params.enabled,el:t,classNames:[],slides:[],slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal:()=>"horizontal"===o.params.direction,isVertical:()=>"vertical"===o.params.direction,activeIndex:0,realIndex:0,isBeginning:!0,isEnd:!1,translate:0,previousTranslate:0,progress:0,velocity:0,animating:!1,cssOverflowAdjustment(){return Math.trunc(this.translate/2**23)*2**23},allowSlideNext:o.params.allowSlideNext,allowSlidePrev:o.params.allowSlidePrev,touchEventsData:{isTouched:void 0,isMoved:void 0,allowTouchCallbacks:void 0,touchStartTime:void 0,isScrolling:void 0,currentTranslate:void 0,startTranslate:void 0,allowThresholdMove:void 0,focusableElements:o.params.focusableElements,lastClickTime:0,clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,startMoving:void 0,pointerId:null,touchId:null},allowClick:!0,allowTouchMove:o.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0}),o.emit("_swiper"),o.params.init&&o.init(),o}getDirectionLabel(e){return this.isHorizontal()?e:{width:"height","margin-top":"margin-left","margin-bottom ":"margin-right","margin-left":"margin-top","margin-right":"margin-bottom","padding-left":"padding-top","padding-right":"padding-bottom",marginRight:"marginBottom"}[e]}getSlideIndex(e){const{slidesEl:t,params:r}=this,i=Js(qs(t,`.${r.slideClass}, swiper-slide`)[0]);return Js(e)-i}getSlideIndexByData(e){return this.getSlideIndex(this.slides.filter(t=>1*t.getAttribute("data-swiper-slide-index")===e)[0])}recalcSlides(){const{slidesEl:e,params:t}=this;this.slides=qs(e,`.${t.slideClass}, swiper-slide`)}enable(){const e=this;e.enabled||(e.enabled=!0,e.params.grabCursor&&e.setGrabCursor(),e.emit("enable"))}disable(){const e=this;e.enabled&&(e.enabled=!1,e.params.grabCursor&&e.unsetGrabCursor(),e.emit("disable"))}setProgress(e,t){const r=this;e=Math.min(Math.max(e,0),1);const i=r.minTranslate(),s=(r.maxTranslate()-i)*e+i;r.translateTo(s,void 0===t?0:t),r.updateActiveIndex(),r.updateSlidesClasses()}emitContainerClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=e.el.className.split(" ").filter(t=>0===t.indexOf("swiper")||0===t.indexOf(e.params.containerModifierClass));e.emit("_containerClasses",t.join(" "))}getSlideClasses(e){const t=this;return t.destroyed?"":e.className.split(" ").filter(e=>0===e.indexOf("swiper-slide")||0===e.indexOf(t.params.slideClass)).join(" ")}emitSlidesClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=[];e.slides.forEach(r=>{const i=e.getSlideClasses(r);t.push({slideEl:r,classNames:i}),e.emit("_slideClass",r,i)}),e.emit("_slideClasses",t)}slidesPerViewDynamic(e,t){void 0===e&&(e="current"),void 0===t&&(t=!1);const{params:r,slides:i,slidesGrid:s,slidesSizesGrid:n,size:a,activeIndex:o}=this;let l=1;if("number"==typeof r.slidesPerView)return r.slidesPerView;if(r.centeredSlides){let e,t=i[o]?Math.ceil(i[o].swiperSlideSize):0;for(let r=o+1;r<i.length;r+=1)i[r]&&!e&&(t+=Math.ceil(i[r].swiperSlideSize),l+=1,t>a&&(e=!0));for(let r=o-1;r>=0;r-=1)i[r]&&!e&&(t+=i[r].swiperSlideSize,l+=1,t>a&&(e=!0))}else if("current"===e)for(let e=o+1;e<i.length;e+=1){(t?s[e]+n[e]-s[o]<a:s[e]-s[o]<a)&&(l+=1)}else for(let e=o-1;e>=0;e-=1){s[o]-s[e]<a&&(l+=1)}return l}update(){const e=this;if(!e||e.destroyed)return;const{snapGrid:t,params:r}=e;function i(){const t=e.rtlTranslate?-1*e.translate:e.translate,r=Math.min(Math.max(t,e.maxTranslate()),e.minTranslate());e.setTranslate(r),e.updateActiveIndex(),e.updateSlidesClasses()}let s;if(r.breakpoints&&e.setBreakpoint(),[...e.el.querySelectorAll('[loading="lazy"]')].forEach(t=>{t.complete&&hn(e,t)}),e.updateSize(),e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),r.freeMode&&r.freeMode.enabled&&!r.cssMode)i(),r.autoHeight&&e.updateAutoHeight();else{if(("auto"===r.slidesPerView||r.slidesPerView>1)&&e.isEnd&&!r.centeredSlides){const t=e.virtual&&r.virtual.enabled?e.virtual.slides:e.slides;s=e.slideTo(t.length-1,0,!1,!0)}else s=e.slideTo(e.activeIndex,0,!1,!0);s||i()}r.watchOverflow&&t!==e.snapGrid&&e.checkOverflow(),e.emit("update")}changeDirection(e,t){void 0===t&&(t=!0);const r=this,i=r.params.direction;return e||(e="horizontal"===i?"vertical":"horizontal"),e===i||"horizontal"!==e&&"vertical"!==e||(r.el.classList.remove(`${r.params.containerModifierClass}${i}`),r.el.classList.add(`${r.params.containerModifierClass}${e}`),r.emitContainerClasses(),r.params.direction=e,r.slides.forEach(t=>{"vertical"===e?t.style.width="":t.style.height=""}),r.emit("changeDirection"),t&&r.update()),r}changeLanguageDirection(e){const t=this;t.rtl&&"rtl"===e||!t.rtl&&"ltr"===e||(t.rtl="rtl"===e,t.rtlTranslate="horizontal"===t.params.direction&&t.rtl,t.rtl?(t.el.classList.add(`${t.params.containerModifierClass}rtl`),t.el.dir="rtl"):(t.el.classList.remove(`${t.params.containerModifierClass}rtl`),t.el.dir="ltr"),t.update())}mount(e){const t=this;if(t.mounted)return!0;let r=e||t.params.el;if("string"==typeof r&&(r=document.querySelector(r)),!r)return!1;r.swiper=t,r.parentNode&&r.parentNode.host&&r.parentNode.host.nodeName===t.params.swiperElementNodeName.toUpperCase()&&(t.isElement=!0);const i=()=>`.${(t.params.wrapperClass||"").trim().split(" ").join(".")}`;let s=(()=>{if(r&&r.shadowRoot&&r.shadowRoot.querySelector){return r.shadowRoot.querySelector(i())}return qs(r,i())[0]})();return!s&&t.params.createElements&&(s=Qs("div",t.params.wrapperClass),r.append(s),qs(r,`.${t.params.slideClass}`).forEach(e=>{s.append(e)})),Object.assign(t,{el:r,wrapperEl:s,slidesEl:t.isElement&&!r.parentNode.host.slideSlots?r.parentNode.host:s,hostEl:t.isElement?r.parentNode.host:r,mounted:!0,rtl:"rtl"===r.dir.toLowerCase()||"rtl"===Zs(r,"direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===r.dir.toLowerCase()||"rtl"===Zs(r,"direction")),wrongRTL:"-webkit-box"===Zs(s,"display")}),!0}init(e){const t=this;if(t.initialized)return t;if(!1===t.mount(e))return t;t.emit("beforeInit"),t.params.breakpoints&&t.setBreakpoint(),t.addClasses(),t.updateSize(),t.updateSlides(),t.params.watchOverflow&&t.checkOverflow(),t.params.grabCursor&&t.enabled&&t.setGrabCursor(),t.params.loop&&t.virtual&&t.params.virtual.enabled?t.slideTo(t.params.initialSlide+t.virtual.slidesBefore,0,t.params.runCallbacksOnInit,!1,!0):t.slideTo(t.params.initialSlide,0,t.params.runCallbacksOnInit,!1,!0),t.params.loop&&t.loopCreate(),t.attachEvents();const r=[...t.el.querySelectorAll('[loading="lazy"]')];return t.isElement&&r.push(...t.hostEl.querySelectorAll('[loading="lazy"]')),r.forEach(e=>{e.complete?hn(t,e):e.addEventListener("load",e=>{hn(t,e.target)})}),pn(t),t.initialized=!0,pn(t),t.emit("init"),t.emit("afterInit"),t}destroy(e,t){void 0===e&&(e=!0),void 0===t&&(t=!0);const r=this,{params:i,el:s,wrapperEl:n,slides:a}=r;return void 0===r.params||r.destroyed||(r.emit("beforeDestroy"),r.initialized=!1,r.detachEvents(),i.loop&&r.loopDestroy(),t&&(r.removeClasses(),s&&"string"!=typeof s&&s.removeAttribute("style"),n&&n.removeAttribute("style"),a&&a.length&&a.forEach(e=>{e.classList.remove(i.slideVisibleClass,i.slideFullyVisibleClass,i.slideActiveClass,i.slideNextClass,i.slidePrevClass),e.removeAttribute("style"),e.removeAttribute("data-swiper-slide-index")})),r.emit("destroy"),Object.keys(r.eventsListeners).forEach(e=>{r.off(e)}),!1!==e&&(r.el&&"string"!=typeof r.el&&(r.el.swiper=null),function(e){const t=e;Object.keys(t).forEach(e=>{try{t[e]=null}catch(e){}try{delete t[e]}catch(e){}})}(r)),r.destroyed=!0),null}static extendDefaults(e){Vs(Nn,e)}static get extendedDefaults(){return Nn}static get defaults(){return _n}static installModule(t){e.prototype.__modules__||(e.prototype.__modules__=[]);const r=e.prototype.__modules__;"function"==typeof t&&r.indexOf(t)<0&&r.push(t)}static use(t){return Array.isArray(t)?(t.forEach(t=>e.installModule(t)),e):(e.installModule(t),e)}};Object.keys(Mn).forEach(e=>{Object.keys(Mn[e]).forEach(t=>{Fn.prototype[t]=Mn[e][t]})}),Fn.use([function(e){let{swiper:t,on:r,emit:i}=e;const s=Bs();let n=null,a=null;const o=()=>{t&&!t.destroyed&&t.initialized&&(i("beforeResize"),i("resize"))},l=()=>{t&&!t.destroyed&&t.initialized&&i("orientationchange")};r("init",()=>{t.params.resizeObserver&&void 0!==s.ResizeObserver?t&&!t.destroyed&&t.initialized&&(n=new ResizeObserver(e=>{a=s.requestAnimationFrame(()=>{const{width:r,height:i}=t;let s=r,n=i;e.forEach(e=>{let{contentBoxSize:r,contentRect:i,target:a}=e;a&&a!==t.el||(s=i?i.width:(r[0]||r).inlineSize,n=i?i.height:(r[0]||r).blockSize)}),s===r&&n===i||o()})}),n.observe(t.el)):(s.addEventListener("resize",o),s.addEventListener("orientationchange",l))}),r("destroy",()=>{a&&s.cancelAnimationFrame(a),n&&n.unobserve&&t.el&&(n.unobserve(t.el),n=null),s.removeEventListener("resize",o),s.removeEventListener("orientationchange",l)})},function(e){let{swiper:t,extendParams:r,on:i,emit:s}=e;const n=[],a=Bs(),o=function(e,r){void 0===r&&(r={});const i=new(a.MutationObserver||a.WebkitMutationObserver)(e=>{if(t.__preventObserver__)return;if(1===e.length)return void s("observerUpdate",e[0]);const r=function(){s("observerUpdate",e[0])};a.requestAnimationFrame?a.requestAnimationFrame(r):a.setTimeout(r,0)});i.observe(e,{attributes:void 0===r.attributes||r.attributes,childList:t.isElement||(void 0===r.childList||r).childList,characterData:void 0===r.characterData||r.characterData}),n.push(i)};r({observer:!1,observeParents:!1,observeSlideChildren:!1}),i("init",()=>{if(t.params.observer){if(t.params.observeParents){const e=function(e){const t=[];let r=e.parentElement;for(;r;)t.push(r),r=r.parentElement;return t}(t.hostEl);for(let t=0;t<e.length;t+=1)o(e[t])}o(t.hostEl,{childList:t.params.observeSlideChildren}),o(t.wrapperEl,{attributes:!1})}}),i("destroy",()=>{n.forEach(e=>{e.disconnect()}),n.splice(0,n.length)})}]);const $n=["eventsPrefix","injectStyles","injectStylesUrls","modules","init","_direction","oneWayMovement","swiperElementNodeName","touchEventsTarget","initialSlide","_speed","cssMode","updateOnWindowResize","resizeObserver","nested","focusableElements","_enabled","_width","_height","preventInteractionOnTransition","userAgent","url","_edgeSwipeDetection","_edgeSwipeThreshold","_freeMode","_autoHeight","setWrapperSize","virtualTranslate","_effect","breakpoints","breakpointsBase","_spaceBetween","_slidesPerView","maxBackfaceHiddenSlides","_grid","_slidesPerGroup","_slidesPerGroupSkip","_slidesPerGroupAuto","_centeredSlides","_centeredSlidesBounds","_slidesOffsetBefore","_slidesOffsetAfter","normalizeSlideIndex","_centerInsufficientSlides","_watchOverflow","roundLengths","touchRatio","touchAngle","simulateTouch","_shortSwipes","_longSwipes","longSwipesRatio","longSwipesMs","_followFinger","allowTouchMove","_threshold","touchMoveStopPropagation","touchStartPreventDefault","touchStartForcePreventDefault","touchReleaseOnEdges","uniqueNavElements","_resistance","_resistanceRatio","_watchSlidesProgress","_grabCursor","preventClicks","preventClicksPropagation","_slideToClickedSlide","_loop","loopAdditionalSlides","loopAddBlankSlides","loopPreventsSliding","_rewind","_allowSlidePrev","_allowSlideNext","_swipeHandler","_noSwiping","noSwipingClass","noSwipingSelector","passiveListeners","containerModifierClass","slideClass","slideActiveClass","slideVisibleClass","slideFullyVisibleClass","slideNextClass","slidePrevClass","slideBlankClass","wrapperClass","lazyPreloaderClass","lazyPreloadPrevNext","runCallbacksOnInit","observer","observeParents","observeSlideChildren","a11y","_autoplay","_controller","coverflowEffect","cubeEffect","fadeEffect","flipEffect","creativeEffect","cardsEffect","hashNavigation","history","keyboard","mousewheel","_navigation","_pagination","parallax","_scrollbar","_thumbs","virtual","zoom","control"];function Bn(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)&&!e.__swiper__}function Un(e,t){const r=["__proto__","constructor","prototype"];Object.keys(t).filter(e=>r.indexOf(e)<0).forEach(r=>{void 0===e[r]?e[r]=t[r]:Bn(t[r])&&Bn(e[r])&&Object.keys(t[r]).length>0?t[r].__swiper__?e[r]=t[r]:Un(e[r],t[r]):e[r]=t[r]})}function zn(e){return void 0===e&&(e={}),e.navigation&&void 0===e.navigation.nextEl&&void 0===e.navigation.prevEl}function Gn(e){return void 0===e&&(e={}),e.pagination&&void 0===e.pagination.el}function jn(e){return void 0===e&&(e={}),e.scrollbar&&void 0===e.scrollbar.el}function Hn(e){void 0===e&&(e="");const t=e.split(" ").map(e=>e.trim()).filter(e=>!!e),r=[];return t.forEach(e=>{r.indexOf(e)<0&&r.push(e)}),r.join(" ")}function Vn(e){return void 0===e&&(e=""),e?e.includes("swiper-wrapper")?e:`swiper-wrapper ${e}`:"swiper-wrapper"}function Wn(){return Wn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},Wn.apply(this,arguments)}function Yn(e){return e.type&&e.type.displayName&&e.type.displayName.includes("SwiperSlide")}function Kn(e){const r=[];return t.Children.toArray(e).forEach(e=>{Yn(e)?r.push(e):e.props&&e.props.children&&Kn(e.props.children).forEach(e=>r.push(e))}),r}function qn(e){const r=[],i={"container-start":[],"container-end":[],"wrapper-start":[],"wrapper-end":[]};return t.Children.toArray(e).forEach(e=>{if(Yn(e))r.push(e);else if(e.props&&e.props.slot&&i[e.props.slot])i[e.props.slot].push(e);else if(e.props&&e.props.children){const t=Kn(e.props.children);t.length>0?t.forEach(e=>r.push(e)):i["container-end"].push(e)}else i["container-end"].push(e)}),{slides:r,slots:i}}function Xn(e,t){return"undefined"==typeof window?i(e,t):o(e,t)}const Qn=s(null),Zn=s(null),Jn=n(function(e,s){let{className:n,tag:o="div",wrapperTag:l="div",children:c,onSwiper:d,...u}=void 0===e?{}:e,h=!1;const[f,p]=a("swiper"),[m,g]=a(null),[v,y]=a(!1),b=r(!1),E=r(null),w=r(null),S=r(null),T=r(null),x=r(null),A=r(null),k=r(null),L=r(null),{params:I,passedParams:R,rest:P,events:C}=function(e,t){void 0===e&&(e={}),void 0===t&&(t=!0);const r={on:{}},i={},s={};Un(r,_n),r._emitClasses=!0,r.init=!1;const n={},a=$n.map(e=>e.replace(/_/,"")),o=Object.assign({},e);return Object.keys(o).forEach(o=>{void 0!==e[o]&&(a.indexOf(o)>=0?Bn(e[o])?(r[o]={},s[o]={},Un(r[o],e[o]),Un(s[o],e[o])):(r[o]=e[o],s[o]=e[o]):0===o.search(/on[A-Z]/)&&"function"==typeof e[o]?t?i[`${o[2].toLowerCase()}${o.substr(3)}`]=e[o]:r.on[`${o[2].toLowerCase()}${o.substr(3)}`]=e[o]:n[o]=e[o])}),["navigation","pagination","scrollbar"].forEach(e=>{!0===r[e]&&(r[e]={}),!1===r[e]&&delete r[e]}),{params:r,passedParams:s,rest:n,events:i}}(u),{slides:D,slots:_}=qn(c),O=()=>{y(!v)};Object.assign(I.on,{_containerClasses(e,t){p(t)}});const M=()=>{Object.assign(I.on,C),h=!0;const e={...I};if(delete e.wrapperClass,w.current=new Fn(e),w.current.virtual&&w.current.params.virtual.enabled){w.current.virtual.slides=D;const e={cache:!1,slides:D,renderExternal:g,renderExternalUpdate:!1};Un(w.current.params.virtual,e),Un(w.current.originalParams.virtual,e)}};E.current||M(),w.current&&w.current.on("_beforeBreakpoint",O);return i(()=>()=>{w.current&&w.current.off("_beforeBreakpoint",O)}),i(()=>{!b.current&&w.current&&(w.current.emitSlidesClasses(),b.current=!0)}),Xn(()=>{if(s&&(s.current=E.current),E.current)return w.current.destroyed&&M(),function(e,t){let{el:r,nextEl:i,prevEl:s,paginationEl:n,scrollbarEl:a,swiper:o}=e;zn(t)&&i&&s&&(o.params.navigation.nextEl=i,o.originalParams.navigation.nextEl=i,o.params.navigation.prevEl=s,o.originalParams.navigation.prevEl=s),Gn(t)&&n&&(o.params.pagination.el=n,o.originalParams.pagination.el=n),jn(t)&&a&&(o.params.scrollbar.el=a,o.originalParams.scrollbar.el=a),o.init(r)}({el:E.current,nextEl:x.current,prevEl:A.current,paginationEl:k.current,scrollbarEl:L.current,swiper:w.current},I),d&&!w.current.destroyed&&d(w.current),()=>{w.current&&!w.current.destroyed&&w.current.destroy(!0,!1)}},[]),Xn(()=>{!h&&C&&w.current&&Object.keys(C).forEach(e=>{w.current.on(e,C[e])});const e=function(e,t,r,i,s){const n=[];if(!t)return n;const a=e=>{n.indexOf(e)<0&&n.push(e)};if(r&&i){const e=i.map(s),t=r.map(s);e.join("")!==t.join("")&&a("children"),i.length!==r.length&&a("children")}return $n.filter(e=>"_"===e[0]).map(e=>e.replace(/_/,"")).forEach(r=>{if(r in e&&r in t)if(Bn(e[r])&&Bn(t[r])){const i=Object.keys(e[r]),s=Object.keys(t[r]);i.length!==s.length?a(r):(i.forEach(i=>{e[r][i]!==t[r][i]&&a(r)}),s.forEach(i=>{e[r][i]!==t[r][i]&&a(r)}))}else e[r]!==t[r]&&a(r)}),n}(R,S.current,D,T.current,e=>e.key);return S.current=R,T.current=D,e.length&&w.current&&!w.current.destroyed&&function(e){let{swiper:t,slides:r,passedParams:i,changedParams:s,nextEl:n,prevEl:a,scrollbarEl:o,paginationEl:l}=e;const c=s.filter(e=>"children"!==e&&"direction"!==e&&"wrapperClass"!==e),{params:d,pagination:u,navigation:h,scrollbar:f,virtual:p,thumbs:m}=t;let g,v,y,b,E,w,S,T;s.includes("thumbs")&&i.thumbs&&i.thumbs.swiper&&!i.thumbs.swiper.destroyed&&d.thumbs&&(!d.thumbs.swiper||d.thumbs.swiper.destroyed)&&(g=!0),s.includes("controller")&&i.controller&&i.controller.control&&d.controller&&!d.controller.control&&(v=!0),s.includes("pagination")&&i.pagination&&(i.pagination.el||l)&&(d.pagination||!1===d.pagination)&&u&&!u.el&&(y=!0),s.includes("scrollbar")&&i.scrollbar&&(i.scrollbar.el||o)&&(d.scrollbar||!1===d.scrollbar)&&f&&!f.el&&(b=!0),s.includes("navigation")&&i.navigation&&(i.navigation.prevEl||a)&&(i.navigation.nextEl||n)&&(d.navigation||!1===d.navigation)&&h&&!h.prevEl&&!h.nextEl&&(E=!0);const x=e=>{t[e]&&(t[e].destroy(),"navigation"===e?(t.isElement&&(t[e].prevEl.remove(),t[e].nextEl.remove()),d[e].prevEl=void 0,d[e].nextEl=void 0,t[e].prevEl=void 0,t[e].nextEl=void 0):(t.isElement&&t[e].el.remove(),d[e].el=void 0,t[e].el=void 0))};s.includes("loop")&&t.isElement&&(d.loop&&!i.loop?w=!0:!d.loop&&i.loop?S=!0:T=!0),c.forEach(e=>{if(Bn(d[e])&&Bn(i[e]))Object.assign(d[e],i[e]),"navigation"!==e&&"pagination"!==e&&"scrollbar"!==e||!("enabled"in i[e])||i[e].enabled||x(e);else{const t=i[e];!0!==t&&!1!==t||"navigation"!==e&&"pagination"!==e&&"scrollbar"!==e?d[e]=i[e]:!1===t&&x(e)}}),c.includes("controller")&&!v&&t.controller&&t.controller.control&&d.controller&&d.controller.control&&(t.controller.control=d.controller.control),s.includes("children")&&r&&p&&d.virtual.enabled?(p.slides=r,p.update(!0)):s.includes("virtual")&&p&&d.virtual.enabled&&(r&&(p.slides=r),p.update(!0)),s.includes("children")&&r&&d.loop&&(T=!0),g&&m.init()&&m.update(!0);v&&(t.controller.control=d.controller.control),y&&(!t.isElement||l&&"string"!=typeof l||(l=document.createElement("div"),l.classList.add("swiper-pagination"),l.part.add("pagination"),t.el.appendChild(l)),l&&(d.pagination.el=l),u.init(),u.render(),u.update()),b&&(!t.isElement||o&&"string"!=typeof o||(o=document.createElement("div"),o.classList.add("swiper-scrollbar"),o.part.add("scrollbar"),t.el.appendChild(o)),o&&(d.scrollbar.el=o),f.init(),f.updateSize(),f.setTranslate()),E&&(t.isElement&&(n&&"string"!=typeof n||(n=document.createElement("div"),n.classList.add("swiper-button-next"),n.innerHTML=t.hostEl.constructor.nextButtonSvg,n.part.add("button-next"),t.el.appendChild(n)),a&&"string"!=typeof a||(a=document.createElement("div"),a.classList.add("swiper-button-prev"),a.innerHTML=t.hostEl.constructor.prevButtonSvg,a.part.add("button-prev"),t.el.appendChild(a))),n&&(d.navigation.nextEl=n),a&&(d.navigation.prevEl=a),h.init(),h.update()),s.includes("allowSlideNext")&&(t.allowSlideNext=i.allowSlideNext),s.includes("allowSlidePrev")&&(t.allowSlidePrev=i.allowSlidePrev),s.includes("direction")&&t.changeDirection(i.direction,!1),(w||T)&&t.loopDestroy(),(S||T)&&t.loopCreate(),t.update()}({swiper:w.current,slides:D,passedParams:R,changedParams:e,nextEl:x.current,prevEl:A.current,scrollbarEl:L.current,paginationEl:k.current}),()=>{C&&w.current&&Object.keys(C).forEach(e=>{w.current.off(e,C[e])})}}),Xn(()=>{var e;!(e=w.current)||e.destroyed||!e.params.virtual||e.params.virtual&&!e.params.virtual.enabled||(e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),e.parallax&&e.params.parallax&&e.params.parallax.enabled&&e.parallax.setTranslate())},[m]),t.createElement(o,Wn({ref:E,className:Hn(`${f}${n?` ${n}`:""}`)},P),t.createElement(Zn.Provider,{value:w.current},_["container-start"],t.createElement(l,{className:Vn(I.wrapperClass)},_["wrapper-start"],I.virtual?function(e,r,i){if(!i)return null;const s=e=>{let t=e;return e<0?t=r.length+e:t>=r.length&&(t-=r.length),t},n=e.isHorizontal()?{[e.rtlTranslate?"right":"left"]:`${i.offset}px`}:{top:`${i.offset}px`},{from:a,to:o}=i,l=e.params.loop?-r.length:0,c=e.params.loop?2*r.length:r.length,d=[];for(let e=l;e<c;e+=1)e>=a&&e<=o&&d.push(r[s(e)]);return d.map((r,i)=>t.cloneElement(r,{swiper:e,style:n,key:r.props.virtualIndex||r.key||`slide-${i}`}))}(w.current,D,m):D.map((e,r)=>t.cloneElement(e,{swiper:w.current,swiperSlideIndex:r})),_["wrapper-end"]),zn(I)&&t.createElement(t.Fragment,null,t.createElement("div",{ref:A,className:"swiper-button-prev"}),t.createElement("div",{ref:x,className:"swiper-button-next"})),jn(I)&&t.createElement("div",{ref:L,className:"swiper-scrollbar"}),Gn(I)&&t.createElement("div",{ref:k,className:"swiper-pagination"}),_["container-end"]))});Jn.displayName="Swiper";const ea=n(function(e,i){let{tag:s="div",children:n,className:o="",swiper:l,zoom:c,lazy:d,virtualIndex:u,swiperSlideIndex:h,...f}=void 0===e?{}:e;const p=r(null),[m,g]=a("swiper-slide"),[v,y]=a(!1);function b(e,t,r){t===p.current&&g(r)}Xn(()=>{if(void 0!==h&&(p.current.swiperSlideIndex=h),i&&(i.current=p.current),p.current&&l){if(!l.destroyed)return l.on("_slideClass",b),()=>{l&&l.off("_slideClass",b)};"swiper-slide"!==m&&g("swiper-slide")}}),Xn(()=>{l&&p.current&&!l.destroyed&&g(l.getSlideClasses(p.current))},[l]);const E={isActive:m.indexOf("swiper-slide-active")>=0,isVisible:m.indexOf("swiper-slide-visible")>=0,isPrev:m.indexOf("swiper-slide-prev")>=0,isNext:m.indexOf("swiper-slide-next")>=0},w=()=>"function"==typeof n?n(E):n;return t.createElement(s,Wn({ref:p,className:Hn(`${m}${o?` ${o}`:""}`),"data-swiper-slide-index":u,onLoad:()=>{y(!0)}},f),c&&t.createElement(Qn.Provider,{value:E},t.createElement("div",{className:"swiper-zoom-container","data-swiper-zoom":"number"==typeof c?c:void 0},w(),d&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"}))),!c&&t.createElement(Qn.Provider,{value:E},w(),d&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"})))});function ta(e){let{swiper:t,extendParams:r,on:i,emit:s}=e;const n=Bs();let a;r({mousewheel:{enabled:!1,releaseOnEdges:!1,invert:!1,forceToAxis:!1,sensitivity:1,eventsTarget:"container",thresholdDelta:null,thresholdTime:null,noMousewheelClass:"swiper-no-mousewheel"}}),t.mousewheel={enabled:!1};let o,l=zs();const c=[];function d(){t.enabled&&(t.mouseEntered=!0)}function u(){t.enabled&&(t.mouseEntered=!1)}function h(e){return!(t.params.mousewheel.thresholdDelta&&e.delta<t.params.mousewheel.thresholdDelta)&&(!(t.params.mousewheel.thresholdTime&&zs()-l<t.params.mousewheel.thresholdTime)&&(e.delta>=6&&zs()-l<60||(e.direction<0?t.isEnd&&!t.params.loop||t.animating||(t.slideNext(),s("scroll",e.raw)):t.isBeginning&&!t.params.loop||t.animating||(t.slidePrev(),s("scroll",e.raw)),l=(new n.Date).getTime(),!1)))}function f(e){let r=e,i=!0;if(!t.enabled)return;if(e.target.closest(`.${t.params.mousewheel.noMousewheelClass}`))return;const n=t.params.mousewheel;t.params.cssMode&&r.preventDefault();let l=t.el;"container"!==t.params.mousewheel.eventsTarget&&(l=document.querySelector(t.params.mousewheel.eventsTarget));const d=l&&l.contains(r.target);if(!t.mouseEntered&&!d&&!n.releaseOnEdges)return!0;r.originalEvent&&(r=r.originalEvent);let u=0;const f=t.rtlTranslate?-1:1,p=function(e){let t=0,r=0,i=0,s=0;return"detail"in e&&(r=e.detail),"wheelDelta"in e&&(r=-e.wheelDelta/120),"wheelDeltaY"in e&&(r=-e.wheelDeltaY/120),"wheelDeltaX"in e&&(t=-e.wheelDeltaX/120),"axis"in e&&e.axis===e.HORIZONTAL_AXIS&&(t=r,r=0),i=10*t,s=10*r,"deltaY"in e&&(s=e.deltaY),"deltaX"in e&&(i=e.deltaX),e.shiftKey&&!i&&(i=s,s=0),(i||s)&&e.deltaMode&&(1===e.deltaMode?(i*=40,s*=40):(i*=800,s*=800)),i&&!t&&(t=i<1?-1:1),s&&!r&&(r=s<1?-1:1),{spinX:t,spinY:r,pixelX:i,pixelY:s}}(r);if(n.forceToAxis)if(t.isHorizontal()){if(!(Math.abs(p.pixelX)>Math.abs(p.pixelY)))return!0;u=-p.pixelX*f}else{if(!(Math.abs(p.pixelY)>Math.abs(p.pixelX)))return!0;u=-p.pixelY}else u=Math.abs(p.pixelX)>Math.abs(p.pixelY)?-p.pixelX*f:-p.pixelY;if(0===u)return!0;n.invert&&(u=-u);let m=t.getTranslate()+u*n.sensitivity;if(m>=t.minTranslate()&&(m=t.minTranslate()),m<=t.maxTranslate()&&(m=t.maxTranslate()),i=!!t.params.loop||!(m===t.minTranslate()||m===t.maxTranslate()),i&&t.params.nested&&r.stopPropagation(),t.params.freeMode&&t.params.freeMode.enabled){const e={time:zs(),delta:Math.abs(u),direction:Math.sign(u)},i=o&&e.time<o.time+500&&e.delta<=o.delta&&e.direction===o.direction;if(!i){o=void 0;let l=t.getTranslate()+u*n.sensitivity;const d=t.isBeginning,h=t.isEnd;if(l>=t.minTranslate()&&(l=t.minTranslate()),l<=t.maxTranslate()&&(l=t.maxTranslate()),t.setTransition(0),t.setTranslate(l),t.updateProgress(),t.updateActiveIndex(),t.updateSlidesClasses(),(!d&&t.isBeginning||!h&&t.isEnd)&&t.updateSlidesClasses(),t.params.loop&&t.loopFix({direction:e.direction<0?"next":"prev",byMousewheel:!0}),t.params.freeMode.sticky){clearTimeout(a),a=void 0,c.length>=15&&c.shift();const r=c.length?c[c.length-1]:void 0,i=c[0];if(c.push(e),r&&(e.delta>r.delta||e.direction!==r.direction))c.splice(0);else if(c.length>=15&&e.time-i.time<500&&i.delta-e.delta>=1&&e.delta<=6){const r=u>0?.8:.2;o=e,c.splice(0),a=Us(()=>{!t.destroyed&&t.params&&t.slideToClosest(t.params.speed,!0,void 0,r)},0)}a||(a=Us(()=>{if(t.destroyed||!t.params)return;o=e,c.splice(0),t.slideToClosest(t.params.speed,!0,void 0,.5)},500))}if(i||s("scroll",r),t.params.autoplay&&t.params.autoplayDisableOnInteraction&&t.autoplay.stop(),n.releaseOnEdges&&(l===t.minTranslate()||l===t.maxTranslate()))return!0}}else{const r={time:zs(),delta:Math.abs(u),direction:Math.sign(u),raw:e};c.length>=2&&c.shift();const i=c.length?c[c.length-1]:void 0;if(c.push(r),i?(r.direction!==i.direction||r.delta>i.delta||r.time>i.time+150)&&h(r):h(r),function(e){const r=t.params.mousewheel;if(e.direction<0){if(t.isEnd&&!t.params.loop&&r.releaseOnEdges)return!0}else if(t.isBeginning&&!t.params.loop&&r.releaseOnEdges)return!0;return!1}(r))return!0}return r.preventDefault?r.preventDefault():r.returnValue=!1,!1}function p(e){let r=t.el;"container"!==t.params.mousewheel.eventsTarget&&(r=document.querySelector(t.params.mousewheel.eventsTarget)),r[e]("mouseenter",d),r[e]("mouseleave",u),r[e]("wheel",f)}function m(){return t.params.cssMode?(t.wrapperEl.removeEventListener("wheel",f),!0):!t.mousewheel.enabled&&(p("addEventListener"),t.mousewheel.enabled=!0,!0)}function g(){return t.params.cssMode?(t.wrapperEl.addEventListener(event,f),!0):!!t.mousewheel.enabled&&(p("removeEventListener"),t.mousewheel.enabled=!1,!0)}i("init",()=>{!t.params.mousewheel.enabled&&t.params.cssMode&&g(),t.params.mousewheel.enabled&&m()}),i("destroy",()=>{t.params.cssMode&&m(),t.mousewheel.enabled&&g()}),Object.assign(t.mousewheel,{enable:m,disable:g})}function ra(e){let{swiper:t,extendParams:r,on:i,emit:s}=e;function n(e){let r;return e&&"string"==typeof e&&t.isElement&&(r=t.el.querySelector(e)||t.hostEl.querySelector(e),r)?r:(e&&("string"==typeof e&&(r=[...document.querySelectorAll(e)]),t.params.uniqueNavElements&&"string"==typeof e&&r&&r.length>1&&1===t.el.querySelectorAll(e).length?r=t.el.querySelector(e):r&&1===r.length&&(r=r[0])),e&&!r?e:r)}function a(e,r){const i=t.params.navigation;(e=tn(e)).forEach(e=>{e&&(e.classList[r?"add":"remove"](...i.disabledClass.split(" ")),"BUTTON"===e.tagName&&(e.disabled=r),t.params.watchOverflow&&t.enabled&&e.classList[t.isLocked?"add":"remove"](i.lockClass))})}function o(){const{nextEl:e,prevEl:r}=t.navigation;if(t.params.loop)return a(r,!1),void a(e,!1);a(r,t.isBeginning&&!t.params.rewind),a(e,t.isEnd&&!t.params.rewind)}function l(e){e.preventDefault(),(!t.isBeginning||t.params.loop||t.params.rewind)&&(t.slidePrev(),s("navigationPrev"))}function c(e){e.preventDefault(),(!t.isEnd||t.params.loop||t.params.rewind)&&(t.slideNext(),s("navigationNext"))}function d(){const e=t.params.navigation;if(t.params.navigation=function(e,t,r,i){return e.params.createElements&&Object.keys(i).forEach(s=>{if(!r[s]&&!0===r.auto){let n=qs(e.el,`.${i[s]}`)[0];n||(n=Qs("div",i[s]),n.className=i[s],e.el.append(n)),r[s]=n,t[s]=n}}),r}(t,t.originalParams.navigation,t.params.navigation,{nextEl:"swiper-button-next",prevEl:"swiper-button-prev"}),!e.nextEl&&!e.prevEl)return;let r=n(e.nextEl),i=n(e.prevEl);Object.assign(t.navigation,{nextEl:r,prevEl:i}),r=tn(r),i=tn(i);const s=(r,i)=>{r&&r.addEventListener("click","next"===i?c:l),!t.enabled&&r&&r.classList.add(...e.lockClass.split(" "))};r.forEach(e=>s(e,"next")),i.forEach(e=>s(e,"prev"))}function u(){let{nextEl:e,prevEl:r}=t.navigation;e=tn(e),r=tn(r);const i=(e,r)=>{e.removeEventListener("click","next"===r?c:l),e.classList.remove(...t.params.navigation.disabledClass.split(" "))};e.forEach(e=>i(e,"next")),r.forEach(e=>i(e,"prev"))}r({navigation:{nextEl:null,prevEl:null,hideOnClick:!1,disabledClass:"swiper-button-disabled",hiddenClass:"swiper-button-hidden",lockClass:"swiper-button-lock",navigationDisabledClass:"swiper-navigation-disabled"}}),t.navigation={nextEl:null,prevEl:null},i("init",()=>{!1===t.params.navigation.enabled?h():(d(),o())}),i("toEdge fromEdge lock unlock",()=>{o()}),i("destroy",()=>{u()}),i("enable disable",()=>{let{nextEl:e,prevEl:r}=t.navigation;e=tn(e),r=tn(r),t.enabled?o():[...e,...r].filter(e=>!!e).forEach(e=>e.classList.add(t.params.navigation.lockClass))}),i("click",(e,r)=>{let{nextEl:i,prevEl:n}=t.navigation;i=tn(i),n=tn(n);const a=r.target;let o=n.includes(a)||i.includes(a);if(t.isElement&&!o){const e=r.path||r.composedPath&&r.composedPath();e&&(o=e.find(e=>i.includes(e)||n.includes(e)))}if(t.params.navigation.hideOnClick&&!o){if(t.pagination&&t.params.pagination&&t.params.pagination.clickable&&(t.pagination.el===a||t.pagination.el.contains(a)))return;let e;i.length?e=i[0].classList.contains(t.params.navigation.hiddenClass):n.length&&(e=n[0].classList.contains(t.params.navigation.hiddenClass)),s(!0===e?"navigationShow":"navigationHide"),[...i,...n].filter(e=>!!e).forEach(e=>e.classList.toggle(t.params.navigation.hiddenClass))}});const h=()=>{t.el.classList.add(...t.params.navigation.navigationDisabledClass.split(" ")),u()};Object.assign(t.navigation,{enable:()=>{t.el.classList.remove(...t.params.navigation.navigationDisabledClass.split(" ")),d(),o()},disable:h,update:o,init:d,destroy:u})}function ia(e){let t,r,{swiper:i,extendParams:s,on:n,emit:a,params:o}=e;i.autoplay={running:!1,paused:!1,timeLeft:0},s({autoplay:{enabled:!1,delay:3e3,waitForTransition:!0,disableOnInteraction:!1,stopOnLastSlide:!1,reverseDirection:!1,pauseOnMouseEnter:!1}});let l,c,d,u,h,f,p,m,g=o&&o.autoplay?o.autoplay.delay:3e3,v=o&&o.autoplay?o.autoplay.delay:3e3,y=(new Date).getTime();function b(e){i&&!i.destroyed&&i.wrapperEl&&e.target===i.wrapperEl&&(i.wrapperEl.removeEventListener("transitionend",b),m||e.detail&&e.detail.bySwiperTouchMove||A())}const E=()=>{if(i.destroyed||!i.autoplay.running)return;i.autoplay.paused?c=!0:c&&(v=l,c=!1);const e=i.autoplay.paused?l:y+v-(new Date).getTime();i.autoplay.timeLeft=e,a("autoplayTimeLeft",e,e/g),r=requestAnimationFrame(()=>{E()})},w=e=>{if(i.destroyed||!i.autoplay.running)return;cancelAnimationFrame(r),E();let s=void 0===e?i.params.autoplay.delay:e;g=i.params.autoplay.delay,v=i.params.autoplay.delay;const n=(()=>{let e;if(e=i.virtual&&i.params.virtual.enabled?i.slides.filter(e=>e.classList.contains("swiper-slide-active"))[0]:i.slides[i.activeIndex],!e)return;return parseInt(e.getAttribute("data-swiper-autoplay"),10)})();!Number.isNaN(n)&&n>0&&void 0===e&&(s=n,g=n,v=n),l=s;const o=i.params.speed,c=()=>{i&&!i.destroyed&&(i.params.autoplay.reverseDirection?!i.isBeginning||i.params.loop||i.params.rewind?(i.slidePrev(o,!0,!0),a("autoplay")):i.params.autoplay.stopOnLastSlide||(i.slideTo(i.slides.length-1,o,!0,!0),a("autoplay")):!i.isEnd||i.params.loop||i.params.rewind?(i.slideNext(o,!0,!0),a("autoplay")):i.params.autoplay.stopOnLastSlide||(i.slideTo(0,o,!0,!0),a("autoplay")),i.params.cssMode&&(y=(new Date).getTime(),requestAnimationFrame(()=>{w()})))};return s>0?(clearTimeout(t),t=setTimeout(()=>{c()},s)):requestAnimationFrame(()=>{c()}),s},S=()=>{y=(new Date).getTime(),i.autoplay.running=!0,w(),a("autoplayStart")},T=()=>{i.autoplay.running=!1,clearTimeout(t),cancelAnimationFrame(r),a("autoplayStop")},x=(e,r)=>{if(i.destroyed||!i.autoplay.running)return;clearTimeout(t),e||(p=!0);const s=()=>{a("autoplayPause"),i.params.autoplay.waitForTransition?i.wrapperEl.addEventListener("transitionend",b):A()};if(i.autoplay.paused=!0,r)return f&&(l=i.params.autoplay.delay),f=!1,void s();const n=l||i.params.autoplay.delay;l=n-((new Date).getTime()-y),i.isEnd&&l<0&&!i.params.loop||(l<0&&(l=0),s())},A=()=>{i.isEnd&&l<0&&!i.params.loop||i.destroyed||!i.autoplay.running||(y=(new Date).getTime(),p?(p=!1,w(l)):w(),i.autoplay.paused=!1,a("autoplayResume"))},k=()=>{if(i.destroyed||!i.autoplay.running)return;const e=Fs();"hidden"===e.visibilityState&&(p=!0,x(!0)),"visible"===e.visibilityState&&A()},L=e=>{"mouse"===e.pointerType&&(p=!0,m=!0,i.animating||i.autoplay.paused||x(!0))},I=e=>{"mouse"===e.pointerType&&(m=!1,i.autoplay.paused&&A())};n("init",()=>{i.params.autoplay.enabled&&(i.params.autoplay.pauseOnMouseEnter&&(i.el.addEventListener("pointerenter",L),i.el.addEventListener("pointerleave",I)),Fs().addEventListener("visibilitychange",k),S())}),n("destroy",()=>{i.el&&"string"!=typeof i.el&&(i.el.removeEventListener("pointerenter",L),i.el.removeEventListener("pointerleave",I)),Fs().removeEventListener("visibilitychange",k),i.autoplay.running&&T()}),n("_freeModeStaticRelease",()=>{(u||p)&&A()}),n("_freeModeNoMomentumRelease",()=>{i.params.autoplay.disableOnInteraction?T():x(!0,!0)}),n("beforeTransitionStart",(e,t,r)=>{!i.destroyed&&i.autoplay.running&&(r||!i.params.autoplay.disableOnInteraction?x(!0,!0):T())}),n("sliderFirstMove",()=>{!i.destroyed&&i.autoplay.running&&(i.params.autoplay.disableOnInteraction?T():(d=!0,u=!1,p=!1,h=setTimeout(()=>{p=!0,u=!0,x(!0)},200)))}),n("touchEnd",()=>{if(!i.destroyed&&i.autoplay.running&&d){if(clearTimeout(h),clearTimeout(t),i.params.autoplay.disableOnInteraction)return u=!1,void(d=!1);u&&i.params.cssMode&&A(),u=!1,d=!1}}),n("slideChange",()=>{!i.destroyed&&i.autoplay.running&&(f=!0)}),Object.assign(i.autoplay,{start:S,stop:T,pause:x,resume:A})}function sa(e){let t,r,i,s,{swiper:n,extendParams:a,on:o}=e;a({grid:{rows:1,fill:"column"}});const l=()=>{let e=n.params.spaceBetween;return"string"==typeof e&&e.indexOf("%")>=0?e=parseFloat(e.replace("%",""))/100*n.size:"string"==typeof e&&(e=parseFloat(e)),e};o("init",()=>{s=n.params.grid&&n.params.grid.rows>1}),o("update",()=>{const{params:e,el:t}=n,r=e.grid&&e.grid.rows>1;s&&!r?(t.classList.remove(`${e.containerModifierClass}grid`,`${e.containerModifierClass}grid-column`),i=1,n.emitContainerClasses()):!s&&r&&(t.classList.add(`${e.containerModifierClass}grid`),"column"===e.grid.fill&&t.classList.add(`${e.containerModifierClass}grid-column`),n.emitContainerClasses()),s=r}),n.grid={initSlides:e=>{const{slidesPerView:s}=n.params,{rows:a,fill:o}=n.params.grid,l=n.virtual&&n.params.virtual.enabled?n.virtual.slides.length:e.length;i=Math.floor(l/a),t=Math.floor(l/a)===l/a?l:Math.ceil(l/a)*a,"auto"!==s&&"row"===o&&(t=Math.max(t,s*a)),r=t/a},unsetSlides:()=>{n.slides&&n.slides.forEach(e=>{e.swiperSlideGridSet&&(e.style.height="",e.style[n.getDirectionLabel("margin-top")]="")})},updateSlide:(e,s,a)=>{const{slidesPerGroup:o}=n.params,c=l(),{rows:d,fill:u}=n.params.grid,h=n.virtual&&n.params.virtual.enabled?n.virtual.slides.length:a.length;let f,p,m;if("row"===u&&o>1){const r=Math.floor(e/(o*d)),i=e-d*o*r,n=0===r?o:Math.min(Math.ceil((h-r*d*o)/d),o);m=Math.floor(i/n),p=i-m*n+r*o,f=p+m*t/d,s.style.order=f}else"column"===u?(p=Math.floor(e/d),m=e-p*d,(p>i||p===i&&m===d-1)&&(m+=1,m>=d&&(m=0,p+=1))):(m=Math.floor(e/r),p=e-m*r);s.row=m,s.column=p,s.style.height=`calc((100% - ${(d-1)*c}px) / ${d})`,s.style[n.getDirectionLabel("margin-top")]=0!==m?c&&`${c}px`:"",s.swiperSlideGridSet=!0},updateWrapperSize:(e,r)=>{const{centeredSlides:i,roundLengths:s}=n.params,a=l(),{rows:o}=n.params.grid;if(n.virtualSize=(e+a)*t,n.virtualSize=Math.ceil(n.virtualSize/o)-a,n.params.cssMode||(n.wrapperEl.style[n.getDirectionLabel("width")]=`${n.virtualSize+a}px`),i){const e=[];for(let t=0;t<r.length;t+=1){let i=r[t];s&&(i=Math.floor(i)),r[t]<n.virtualSize+r[0]&&e.push(i)}r.splice(0,r.length),r.push(...e)}}}}function na(e){const t=this,{params:r,slidesEl:i}=t;r.loop&&t.loopDestroy();const s=e=>{if("string"==typeof e){const t=document.createElement("div");t.innerHTML=e,i.append(t.children[0]),t.innerHTML=""}else i.append(e)};if("object"==typeof e&&"length"in e)for(let t=0;t<e.length;t+=1)e[t]&&s(e[t]);else s(e);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update()}function aa(e){const t=this,{params:r,activeIndex:i,slidesEl:s}=t;r.loop&&t.loopDestroy();let n=i+1;const a=e=>{if("string"==typeof e){const t=document.createElement("div");t.innerHTML=e,s.prepend(t.children[0]),t.innerHTML=""}else s.prepend(e)};if("object"==typeof e&&"length"in e){for(let t=0;t<e.length;t+=1)e[t]&&a(e[t]);n=i+e.length}else a(e);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update(),t.slideTo(n,0,!1)}function oa(e,t){const r=this,{params:i,activeIndex:s,slidesEl:n}=r;let a=s;i.loop&&(a-=r.loopedSlides,r.loopDestroy(),r.recalcSlides());const o=r.slides.length;if(e<=0)return void r.prependSlide(t);if(e>=o)return void r.appendSlide(t);let l=a>e?a+1:a;const c=[];for(let t=o-1;t>=e;t-=1){const e=r.slides[t];e.remove(),c.unshift(e)}if("object"==typeof t&&"length"in t){for(let e=0;e<t.length;e+=1)t[e]&&n.append(t[e]);l=a>e?a+t.length:a}else n.append(t);for(let e=0;e<c.length;e+=1)n.append(c[e]);r.recalcSlides(),i.loop&&r.loopCreate(),i.observer&&!r.isElement||r.update(),i.loop?r.slideTo(l+r.loopedSlides,0,!1):r.slideTo(l,0,!1)}function la(e){const t=this,{params:r,activeIndex:i}=t;let s=i;r.loop&&(s-=t.loopedSlides,t.loopDestroy());let n,a=s;if("object"==typeof e&&"length"in e){for(let r=0;r<e.length;r+=1)n=e[r],t.slides[n]&&t.slides[n].remove(),n<a&&(a-=1);a=Math.max(a,0)}else n=e,t.slides[n]&&t.slides[n].remove(),n<a&&(a-=1),a=Math.max(a,0);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update(),r.loop?t.slideTo(a+t.loopedSlides,0,!1):t.slideTo(a,0,!1)}function ca(){const e=this,t=[];for(let r=0;r<e.slides.length;r+=1)t.push(r);e.removeSlide(t)}function da(e){let{swiper:t}=e;Object.assign(t,{appendSlide:na.bind(t),prependSlide:aa.bind(t),addSlide:oa.bind(t),removeSlide:la.bind(t),removeAllSlides:ca.bind(t)})}function ua(e,t){const r=Ks(t);return r!==t&&(r.style.backfaceVisibility="hidden",r.style["-webkit-backface-visibility"]="hidden"),r}function ha(e){let{swiper:t,duration:r,transformElements:i,allSlides:s}=e;const{activeIndex:n}=t;if(t.params.virtualTranslate&&0!==r){let e,r=!1;e=s?i:i.filter(e=>{const r=e.classList.contains("swiper-slide-transform")?(e=>{if(!e.parentElement)return t.slides.filter(t=>t.shadowRoot&&t.shadowRoot===e.parentNode)[0];return e.parentElement})(e):e;return t.getSlideIndex(r)===n}),e.forEach(e=>{!function(e,t){t&&e.addEventListener("transitionend",function r(i){i.target===e&&(t.call(e,i),e.removeEventListener("transitionend",r))})}(e,()=>{if(r)return;if(!t||t.destroyed)return;r=!0,t.animating=!1;const e=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0});t.wrapperEl.dispatchEvent(e)})})}}function fa(e,t,r){const i=`swiper-slide-shadow swiper-slide-shadow-${e}`,s=Ks(t);let n=s.querySelector(`.${i.split(" ").join(".")}`);return n||(n=Qs("div",i.split(" ")),s.append(n)),n}function pa(e){let{swiper:t,extendParams:r,on:i}=e;r({cardsEffect:{slideShadows:!0,rotate:!0,perSlideRotate:2,perSlideOffset:8}});!function(e){const{effect:t,swiper:r,on:i,setTranslate:s,setTransition:n,overwriteParams:a,perspective:o,recreateShadows:l,getEffectParams:c}=e;let d;i("beforeInit",()=>{if(r.params.effect!==t)return;r.classNames.push(`${r.params.containerModifierClass}${t}`),o&&o()&&r.classNames.push(`${r.params.containerModifierClass}3d`);const e=a?a():{};Object.assign(r.params,e),Object.assign(r.originalParams,e)}),i("setTranslate",()=>{r.params.effect===t&&s()}),i("setTransition",(e,i)=>{r.params.effect===t&&n(i)}),i("transitionEnd",()=>{if(r.params.effect===t&&l){if(!c||!c().slideShadows)return;r.slides.forEach(e=>{e.querySelectorAll(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").forEach(e=>e.remove())}),l()}}),i("virtualUpdate",()=>{r.params.effect===t&&(r.slides.length||(d=!0),requestAnimationFrame(()=>{d&&r.slides&&r.slides.length&&(s(),d=!1)}))})}({effect:"cards",swiper:t,on:i,setTranslate:()=>{const{slides:e,activeIndex:r,rtlTranslate:i}=t,s=t.params.cardsEffect,{startTranslate:n,isTouched:a}=t.touchEventsData,o=i?-t.translate:t.translate;for(let l=0;l<e.length;l+=1){const c=e[l],d=c.progress,u=Math.min(Math.max(d,-4),4);let h=c.swiperSlideOffset;t.params.centeredSlides&&!t.params.cssMode&&(t.wrapperEl.style.transform=`translateX(${t.minTranslate()}px)`),t.params.centeredSlides&&t.params.cssMode&&(h-=e[0].swiperSlideOffset);let f=t.params.cssMode?-h-t.translate:-h,p=0;const m=-100*Math.abs(u);let g=1,v=-s.perSlideRotate*u,y=s.perSlideOffset-.75*Math.abs(u);const b=t.virtual&&t.params.virtual.enabled?t.virtual.from+l:l,E=(b===r||b===r-1)&&u>0&&u<1&&(a||t.params.cssMode)&&o<n,w=(b===r||b===r+1)&&u<0&&u>-1&&(a||t.params.cssMode)&&o>n;if(E||w){const e=(1-Math.abs((Math.abs(u)-.5)/.5))**.5;v+=-28*u*e,g+=-.5*e,y+=96*e,p=-25*e*Math.abs(u)+"%"}if(f=u<0?`calc(${f}px ${i?"-":"+"} (${y*Math.abs(u)}%))`:u>0?`calc(${f}px ${i?"-":"+"} (-${y*Math.abs(u)}%))`:`${f}px`,!t.isHorizontal()){const e=p;p=f,f=e}const S=u<0?""+(1+(1-g)*u):""+(1-(1-g)*u),T=`\n translate3d(${f}, ${p}, ${m}px)\n rotateZ(${s.rotate?i?-v:v:0}deg)\n scale(${S})\n `;if(s.slideShadows){let e=c.querySelector(".swiper-slide-shadow");e||(e=fa("cards",c)),e&&(e.style.opacity=Math.min(Math.max((Math.abs(u)-.5)/.5,0),1))}c.style.zIndex=-Math.abs(Math.round(d))+e.length;ua(0,c).style.transform=T}},setTransition:e=>{const r=t.slides.map(e=>Ks(e));r.forEach(t=>{t.style.transitionDuration=`${e}ms`,t.querySelectorAll(".swiper-slide-shadow").forEach(t=>{t.style.transitionDuration=`${e}ms`})}),ha({swiper:t,duration:e,transformElements:r})},perspective:()=>!0,overwriteParams:()=>({watchSlidesProgress:!0,virtualTranslate:!t.params.cssMode})})}ea.displayName="SwiperSlide";const ma=({product:e})=>{const[r,i]=a(!1);return t.createElement("a",{href:e.linkPath,target:"_blank",className:"apphref"},t.createElement("div",{className:"w-full h-full min-w-0 flex gap-2 flex-col"},t.createElement("div",{className:"mb-2 flex aspect-square w-full max-h-fit items-center justify-center overflow-hidden rounded border"},e.thumbPath&&!r?t.createElement(Hr,{product:e,onError:()=>i(!0)}):t.createElement(jr,null)),t.createElement("div",{className:"justify-center flex flex-col min-w-0"},e.brand&&t.createElement("p",{className:"max-w-52 break-keep line-clamp-1 text-xs text-gray-500"},e.brand.brandName),t.createElement("p",{className:"break-keep line-clamp-2"},e.productName),t.createElement("div",{className:"break-keep"},t.createElement("span",{className:"font-semibold text-red-500"},e.discount,"%"," "),t.createElement("span",{className:"font-semibold"},Tt(e.sellingPrice,e.currency))))))},ga=({products:e})=>{const i=r(null);return e&&t.createElement("div",{className:"relative flex h-full w-full max-w-[830px] items-center"},e.length>3&&t.createElement("button",{"aria-label":"prev",onClick:()=>{var e;null===(e=i.current)||void 0===e||e.slidePrev()},className:"absolute left-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(Pr,{size:32,strokeWidth:1})),t.createElement("div",{className:"w-full px-10"},t.createElement(Jn,{modules:[ra],onSwiper:e=>{i.current=e},slidesPerView:3,navigation:{prevEl:".slide__prev",nextEl:".slide__next"},spaceBetween:0},e.map(e=>t.createElement(ea,{key:e.productId},t.createElement("div",{className:"h-full px-3 md:px-4 lg:px-5"},t.createElement(ma,{product:e})))))),e.length>3&&t.createElement("button",{"aria-label":"next",onClick:()=>{var e;null===(e=i.current)||void 0===e||e.slideNext()},className:"absolute right-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(Cr,{size:32,strokeWidth:1})))},va=e=>{const{player:r,shortform:i}=e;return t.createElement("div",{className:"flex h-full w-full gap-5 bg-white items-center"},t.createElement("div",{className:"h-full shrink-0"},r),t.createElement("div",{className:"flex h-full w-full min-w-44 max-w-[800px] items-center overflow-hidden text-sm"},t.createElement(ga,{products:i.productsInfo})))},ya=({products:e})=>{const s=r(null),n=r(null),[o,l]=a(4);return i(()=>{const e=n.current;if(!e)return;const t=()=>{const t=e.clientHeight;if(!t)return;const r=Math.max(1,Math.floor((t+12)/112));l(r)};t();const r=new ResizeObserver(()=>t());return r.observe(e),window.addEventListener("resize",t),()=>{r.disconnect(),window.removeEventListener("resize",t)}},[]),t.createElement("div",{className:"flex h-[80%] min-h-0 w-full flex-col items-center",style:{height:500}},e.length>o&&t.createElement(Dr,{size:50,strokeWidth:1,className:"slide__prev shrink-0 cursor-pointer text-zinc-500"}),t.createElement("div",{ref:n,className:"min-h-0 w-full max-w-full flex-1"},t.createElement(Jn,{modules:[ta,ra],mousewheel:!0,onSwiper:e=>{s.current=e},spaceBetween:12,className:"h-full min-h-0 w-full max-w-full",slidesPerView:o,direction:"vertical",navigation:{prevEl:".slide__prev",nextEl:".slide__next"}},e.map(e=>t.createElement(ea,{key:e.productId},t.createElement("div",{className:"h-full items-center flex"},t.createElement(Vr,{product:e})))))),e.length>o&&t.createElement(Rr,{size:50,strokeWidth:1,className:"slide__next shrink-0 cursor-pointer text-zinc-500"}))},ba=e=>{const{playerSettings:r,shortform:{productsInfo:i},player:s}=e;return t.createElement("div",{className:"flex h-full w-full gap-5"},t.createElement("div",{className:" h-full "},s),t.createElement("div",{className:"max-w-[800px] overflow-hidden"},t.createElement(ya,{products:i})))},Ea=({products:e})=>{const i=r(null),s=e.length>6;return t.createElement("div",{className:"relative flex h-full w-full max-w-[830px] items-center text-sm"},s&&t.createElement("button",{"aria-label":"prev",onClick:()=>{var e;null===(e=i.current)||void 0===e||e.slidePrev()},className:"absolute left-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(Pr,{size:50,strokeWidth:1})),t.createElement("div",{className:"w-full px-14"},t.createElement(Jn,{onSwiper:e=>{i.current=e},slidesPerView:3,spaceBetween:20,modules:[sa],grid:{rows:2,fill:"row"}},e.map(e=>t.createElement(ea,{key:e.productId},t.createElement(ma,{product:e}))))),s&&t.createElement("button",{"aria-label":"next",onClick:()=>{var e;null===(e=i.current)||void 0===e||e.slideNext()},className:"absolute right-0 top-1/2 z-10 -translate-y-1/2 cursor-pointer text-zinc-500"},t.createElement(Cr,{size:50,strokeWidth:1})))},wa=e=>{const{player:r,shortform:{productsInfo:i}}=e;return t.createElement("div",{className:"flex gap-4 w-full h-full min-w-[768px] items-center"},t.createElement("div",{className:"flex-1 w-full h-full flex justify-center"},r),t.createElement("div",{className:"flex-[2] w-full h-full overflow-hidden"},t.createElement(Ea,{products:i})))},Sa="cursor-pointer text-zinc-500",Ta=e=>{const{collection:i,shortform:s,setShortform:n}=e,a=r(null);return t.createElement(t.Fragment,null,i.contents.length>1&&t.createElement("div",{className:"self-center flex gap-4 flex-col"},t.createElement(Dr,{size:44,strokeWidth:1,className:Sa,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(Rr,{size:44,strokeWidth:1,className:Sa,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slideNext()}})),t.createElement("div",{className:"h-full aspect-[9/16] relative"},t.createElement(Jn,{modules:[ta,da],mousewheel:!0,loop:i.contents.length>1,direction:"vertical",touchEventsTarget:"container",preventClicksPropagation:!1,preventClicks:!1,allowTouchMove:!1,slidesPerView:1.05,ref:a,className:"h-full z-10",onSlideChangeTransitionEnd:e=>{(e=>{const t=i.contents[e];t&&n(Object.assign({},t))})(e.realIndex)}},i.contents.map(e=>t.createElement(ea,{key:e.shortsId,className:"rounded-xl overflow-hidden aspect-[9/16]"},t.createElement("div",{className:"h-[95%] mb-2"},s.shortsId===e.shortsId&&t.createElement("div",{className:"h-[95%] overflow-hidden rounded-xl absolute z-[999] w-full"},t.createElement(L,{file:xt(s.media.objectId)})),t.createElement("img",{src:Ct(e.thumbPath),alt:e.title,className:"rounded-xl w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")})))))))};var xa;!function(e){e.latest="",e.views="pageView",e.likes="like"}(xa||(xa={}));let Aa=0;const ka=e=>x(void 0,void 0,void 0,function*(){const{PLAYER_BACK_BASE_URL:t}=gt(),{contentId:r,uuid:i,type:s,userId:n,isFirstPlay:a}=e;try{if(3===Aa)return;const e=`${t}/statistics/play`,o=Object.assign({contentId:r,uuid:i,type:s,date:kt(),userId:+n,playtime:0,isLive:!1,isFirstPlay:a},"shorts"===s&&{isFinished:!1,playedOver5Sec:!1});yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})}catch(e){console.error(`Error in statisticsApi.join - contentId: ${r}`),Dt(e),Aa++}}),La=e=>{const{PLAYER_BACK_BASE_URL:t}=gt(),{contentId:r,uuid:i,type:s,isFinished:n,playtime:a,userId:o}=e,l=Object.assign({contentId:r,uuid:i,playtime:a,type:s,date:kt(),userId:+o,isLive:!1},"shorts"===s&&{isFinished:n,playedOver5Sec:Number(a)>5});fetch(`${t}/statistics/play`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l),keepalive:!0})},Ia=e=>x(void 0,void 0,void 0,function*(){const{PLAYER_BACK_BASE_URL:t}=gt(),{contentProductId:r}=e;try{yield fetch(`${t}/statistics/products/${r}/clicks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({date:kt()},e)),keepalive:!0})}catch(e){console.error(`Error in statisticsApi.productClick - contentProductId: ${r}`),Dt(e)}}),Ra=e=>x(void 0,void 0,void 0,function*(){const{STATISTICS_BASE_URL:t}=gt();try{return(yield(yield fetch(`${t}/${e}/likes`)).json()).result||0}catch(t){return console.error(`Error in statisticsApi.getLike - contentId: ${e}`),Dt(t),0}}),Pa=e=>x(void 0,void 0,void 0,function*(){const{PLAYER_BACK_BASE_URL:t}=gt();try{yield fetch(`${t}/statistics/like`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contentId:e,isLive:!1,isFirst:!1})})}catch(t){console.error(`Error in statisticsApi.getLike - contentId: ${e}`),Dt(t)}}),Ca=e=>x(void 0,[e],void 0,function*({collectionId:e,nextKey:t,size:r=5}){const{PLAYER_BACK_BASE_URL:i}=gt();try{const s=new URLSearchParams;-1!==r&&s.set("size",String(r)),t&&s.set("nextKey",t);const n=yield fetch(`${i}/commerce/collection/${e}?${s.toString()}`);return n.ok?yield n.json():null}catch(e){return Dt(e),null}}),Da=(e,...t)=>x(void 0,[e,...t],void 0,function*(e,t=!1){const{API_BASE_URL:r,PLAYER_BACK_BASE_URL:i}=gt();if(t)try{const t=(yield(yield fetch(`${r}/shorts/player/${e}`)).json()).result;if(!t.media)return null;t.file=`${r}/direct/${t.media.objectId}`;const{player:{viewPlayer:{width:i,height:s}}}=t;return Object.assign(Object.assign(Object.assign(Object.assign({layout:t.player.layout},t.player.shoppingPlayer),{aspectRatio:_t(i,s)}),t),{uuid:Lt()})}catch(e){return Dt(e),null}try{const t=yield fetch(`${i}/commerce/short-form/${e}`),r=yield t.json();return r.shortsId?r:null}catch(e){return Dt(e),null}}),_a=(e,t,r,i,s)=>x(void 0,void 0,void 0,function*(){const{API_BASE_URL:n}=gt();try{const a=yield fetch(`${n}/live/${e}/list?size=${r||6}&status=${t}&includeMainLive=${i}${s&&xa[s]?`&sortBy=${xa[s]}`:""}`);if(!a.ok)return console.error("Error in getLiveWidgetContents "),null;const o=(yield a.json()).result;if(o.content){const{mainLive:e,content:t}=o;return[...e?[e]:[],...t]}return o}catch(e){return console.error("Error in getLiveWidgetContents: ",e),null}}),Oa=e=>{let t;const r=new Set,i=(e,i)=>{const s="function"==typeof e?e(t):e;if(!Object.is(s,t)){const e=t;t=(null!=i?i:"object"!=typeof s||null===s)?s:Object.assign({},t,s),r.forEach(r=>r(t,e))}},s=()=>t,n={setState:i,getState:s,getInitialState:()=>a,subscribe:e=>(r.add(e),()=>r.delete(e))},a=t=e(i,s,n);return n},Ma=e=>e?Oa(e):Oa,Na=e=>e;function Fa(e,r=Na){const i=t.useSyncExternalStore(e.subscribe,t.useCallback(()=>r(e.getState()),[e,r]),t.useCallback(()=>r(e.getInitialState()),[e,r]));return t.useDebugValue(i),i}const $a=e=>{const t=Ma(e),r=e=>Fa(t,e);return Object.assign(r,t),r},Ba=e=>e?$a(e):$a,Ua=Ba(e=>({priceText:"",isPreview:!1,memberOnly:!1,isMemberLoggedIn:!1,setPriceText:t=>e({priceText:t}),setIsPreview:t=>e({isPreview:t}),setMemberOnly:t=>e({memberOnly:t}),setIsMemberLoggedIn:t=>e({isMemberLoggedIn:t})})),za=()=>t.createElement("div",{className:"inline-block absolute pointer-events-none top-0 z-10 animate-float w-[24px] h-[24px]"},t.createElement(Mr,{className:"fill-red-500 text-transparent w-[24px] h-[24px]"})),Ga=({shortsId:e})=>{const{isPreview:r}=Ua(),[s,n]=a(r?123:0),[o,l]=a([]);i(()=>{r||x(void 0,void 0,void 0,function*(){try{const t=yield Ra(e);n(t)}catch(e){return console.error(`Error in statistics getLikeInLive: ${e.toString()}`),0}})},[r,e]);return t.createElement("div",{className:"flex justify-center flex-col items-center relative"},t.createElement("button",{onClick:()=>x(void 0,void 0,void 0,function*(){(()=>{const e=Date.now();l(t=>[...t,e]),setTimeout(()=>{l(t=>t.filter(t=>t!==e))},2e3)})(),n(e=>e+1),r||(yield x(void 0,void 0,void 0,function*(){yield Pa(e)}))}),className:"z-[5] cursor-pointer"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:"https://mbus-asset.s3.ap-northeast-2.amazonaws.com/mcom-player/heart.png",width:24,height:24,className:"block h-6 w-6 object-contain",alt:"like"}))),o.map(e=>t.createElement(za,{key:e})),t.createElement("span",{className:"break-keep text-[10px]"},At(s)))};var ja,Ha,Va={},Wa={exports:{}},Ya=Wa.exports;function Ka(){return ja||(ja=1,e=Wa,t=Wa.exports,function(r,i){var s="function",n="undefined",a="object",o="string",l="major",c="model",d="name",u="type",h="vendor",f="version",p="architecture",m="console",g="mobile",v="tablet",y="smarttv",b="wearable",E="embedded",w="Amazon",S="Apple",T="ASUS",x="BlackBerry",A="Browser",k="Chrome",L="Firefox",I="Google",R="Huawei",P="LG",C="Microsoft",D="Motorola",_="Opera",O="Samsung",M="Sharp",N="Sony",F="Xiaomi",$="Zebra",B="Facebook",U="Chromium OS",z="Mac OS",G=" Browser",j=function(e){for(var t={},r=0;r<e.length;r++)t[e[r].toUpperCase()]=e[r];return t},H=function(e,t){return typeof e===o&&-1!==V(t).indexOf(V(e))},V=function(e){return e.toLowerCase()},W=function(e,t){if(typeof e===o)return e=e.replace(/^\s\s*/,""),typeof t===n?e:e.substring(0,500)},Y=function(e,t){for(var r,n,o,l,c,d,u=0;u<t.length&&!c;){var h=t[u],f=t[u+1];for(r=n=0;r<h.length&&!c&&h[r];)if(c=h[r++].exec(e))for(o=0;o<f.length;o++)d=c[++n],typeof(l=f[o])===a&&l.length>0?2===l.length?typeof l[1]==s?this[l[0]]=l[1].call(this,d):this[l[0]]=l[1]:3===l.length?typeof l[1]!==s||l[1].exec&&l[1].test?this[l[0]]=d?d.replace(l[1],l[2]):i:this[l[0]]=d?l[1].call(this,d,l[2]):i:4===l.length&&(this[l[0]]=d?l[3].call(this,d.replace(l[1],l[2])):i):this[l]=d||i;u+=2}},K=function(e,t){for(var r in t)if(typeof t[r]===a&&t[r].length>0){for(var s=0;s<t[r].length;s++)if(H(t[r][s],e))return"?"===r?i:r}else if(H(t[r],e))return"?"===r?i:r;return t.hasOwnProperty("*")?t["*"]:e},q={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},X={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[f,[d,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[f,[d,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[d,f],[/opios[\/ ]+([\w\.]+)/i],[f,[d,_+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[f,[d,_+" GX"]],[/\bopr\/([\w\.]+)/i],[f,[d,_]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[f,[d,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[f,[d,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[d,f],[/quark(?:pc)?\/([-\w\.]+)/i],[f,[d,"Quark"]],[/\bddg\/([\w\.]+)/i],[f,[d,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[f,[d,"UC"+A]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[f,[d,"WeChat"]],[/konqueror\/([\w\.]+)/i],[f,[d,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[f,[d,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[f,[d,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[f,[d,"Smart Lenovo "+A]],[/(avast|avg)\/([\w\.]+)/i],[[d,/(.+)/,"$1 Secure "+A],f],[/\bfocus\/([\w\.]+)/i],[f,[d,L+" Focus"]],[/\bopt\/([\w\.]+)/i],[f,[d,_+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[f,[d,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[f,[d,"Dolphin"]],[/coast\/([\w\.]+)/i],[f,[d,_+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[f,[d,"MIUI"+G]],[/fxios\/([\w\.-]+)/i],[f,[d,L]],[/\bqihoobrowser\/?([\w\.]*)/i],[f,[d,"360"]],[/\b(qq)\/([\w\.]+)/i],[[d,/(.+)/,"$1Browser"],f],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[d,/(.+)/,"$1"+G],f],[/samsungbrowser\/([\w\.]+)/i],[f,[d,O+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[f,[d,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[d,"Sogou Mobile"],f],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[d,f],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[d],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[f,d],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[d,B],f],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[d,f],[/\bgsa\/([\w\.]+) .*safari\//i],[f,[d,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[f,[d,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[f,[d,k+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[d,k+" WebView"],f],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[f,[d,"Android "+A]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[d,f],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[f,[d,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[f,d],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[d,[f,K,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[d,f],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[d,"Netscape"],f],[/(wolvic|librewolf)\/([\w\.]+)/i],[d,f],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[f,[d,L+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i],[d,[f,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[d,[f,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[p,"amd64"]],[/(ia32(?=;))/i],[[p,V]],[/((?:i[346]|x)86)[;\)]/i],[[p,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[p,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[p,"armhf"]],[/windows (ce|mobile); ppc;/i],[[p,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[p,/ower/,"",V]],[/(sun4\w)[;\)]/i],[[p,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[p,V]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[c,[h,O],[u,v]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[c,[h,O],[u,g]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[c,[h,S],[u,g]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[c,[h,S],[u,v]],[/(macintosh);/i],[c,[h,S]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[c,[h,M],[u,g]],[/(?:honor)([-\w ]+)[;\)]/i],[c,[h,"Honor"],[u,g]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[c,[h,R],[u,v]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[c,[h,R],[u,g]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i],[[c,/_/g," "],[h,F],[u,g]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[c,/_/g," "],[h,F],[u,v]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[c,[h,"OPPO"],[u,g]],[/\b(opd2\d{3}a?) bui/i],[c,[h,"OPPO"],[u,v]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[c,[h,"Vivo"],[u,g]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[c,[h,"Realme"],[u,g]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[c,[h,D],[u,g]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[c,[h,D],[u,v]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[c,[h,P],[u,v]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[c,[h,P],[u,g]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[c,[h,"Lenovo"],[u,v]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[c,/_/g," "],[h,"Nokia"],[u,g]],[/(pixel c)\b/i],[c,[h,I],[u,v]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[c,[h,I],[u,g]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[c,[h,N],[u,g]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[c,"Xperia Tablet"],[h,N],[u,v]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[c,[h,"OnePlus"],[u,g]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[c,[h,w],[u,v]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[c,/(.+)/g,"Fire Phone $1"],[h,w],[u,g]],[/(playbook);[-\w\),; ]+(rim)/i],[c,h,[u,v]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[c,[h,x],[u,g]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[c,[h,T],[u,v]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[c,[h,T],[u,g]],[/(nexus 9)/i],[c,[h,"HTC"],[u,v]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[c,/_/g," "],[u,g]],[/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])\w*(\)| bui)/i],[c,[h,"TCL"],[u,v]],[/(itel) ((\w+))/i],[[h,V],c,[u,K,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[c,[h,"Acer"],[u,v]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[c,[h,"Meizu"],[u,g]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[c,[h,"Ulefone"],[u,g]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[c,[h,"Energizer"],[u,g]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[c,[h,"Cat"],[u,g]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[c,[h,"Smartfren"],[u,g]],[/droid.+; (a(?:015|06[35]|142p?))/i],[c,[h,"Nothing"],[u,g]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (imo) ((?!tab)[\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[h,c,[u,g]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[h,c,[u,v]],[/(surface duo)/i],[c,[h,C],[u,v]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[c,[h,"Fairphone"],[u,g]],[/(u304aa)/i],[c,[h,"AT&T"],[u,g]],[/\bsie-(\w*)/i],[c,[h,"Siemens"],[u,g]],[/\b(rct\w+) b/i],[c,[h,"RCA"],[u,v]],[/\b(venue[\d ]{2,7}) b/i],[c,[h,"Dell"],[u,v]],[/\b(q(?:mv|ta)\w+) b/i],[c,[h,"Verizon"],[u,v]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[c,[h,"Barnes & Noble"],[u,v]],[/\b(tm\d{3}\w+) b/i],[c,[h,"NuVision"],[u,v]],[/\b(k88) b/i],[c,[h,"ZTE"],[u,v]],[/\b(nx\d{3}j) b/i],[c,[h,"ZTE"],[u,g]],[/\b(gen\d{3}) b.+49h/i],[c,[h,"Swiss"],[u,g]],[/\b(zur\d{3}) b/i],[c,[h,"Swiss"],[u,v]],[/\b((zeki)?tb.*\b) b/i],[c,[h,"Zeki"],[u,v]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,"Dragon Touch"],c,[u,v]],[/\b(ns-?\w{0,9}) b/i],[c,[h,"Insignia"],[u,v]],[/\b((nxa|next)-?\w{0,9}) b/i],[c,[h,"NextBook"],[u,v]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,"Voice"],c,[u,g]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,"LvTel"],c,[u,g]],[/\b(ph-1) /i],[c,[h,"Essential"],[u,g]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[c,[h,"Envizen"],[u,v]],[/\b(trio[-\w\. ]+) b/i],[c,[h,"MachSpeed"],[u,v]],[/\btu_(1491) b/i],[c,[h,"Rotor"],[u,v]],[/(shield[\w ]+) b/i],[c,[h,"Nvidia"],[u,v]],[/(sprint) (\w+)/i],[h,c,[u,g]],[/(kin\.[onetw]{3})/i],[[c,/\./g," "],[h,C],[u,g]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[c,[h,$],[u,v]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[c,[h,$],[u,g]],[/smart-tv.+(samsung)/i],[h,[u,y]],[/hbbtv.+maple;(\d+)/i],[[c,/^/,"SmartTV"],[h,O],[u,y]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,P],[u,y]],[/(apple) ?tv/i],[h,[c,S+" TV"],[u,y]],[/crkey/i],[[c,k+"cast"],[h,I],[u,y]],[/droid.+aft(\w+)( bui|\))/i],[c,[h,w],[u,y]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[c,[h,M],[u,y]],[/(bravia[\w ]+)( bui|\))/i],[c,[h,N],[u,y]],[/(mitv-\w{5}) bui/i],[c,[h,F],[u,y]],[/Hbbtv.*(technisat) (.*);/i],[h,c,[u,y]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,W],[c,W],[u,y]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[u,y]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,c,[u,m]],[/droid.+; (shield) bui/i],[c,[h,"Nvidia"],[u,m]],[/(playstation [345portablevi]+)/i],[c,[h,N],[u,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[c,[h,C],[u,m]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[c,[h,O],[u,b]],[/((pebble))app/i],[h,c,[u,b]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[c,[h,S],[u,b]],[/droid.+; (glass) \d/i],[c,[h,I],[u,b]],[/droid.+; (wt63?0{2,3})\)/i],[c,[h,$],[u,b]],[/droid.+; (glass) \d/i],[c,[h,I],[u,b]],[/(pico) (4|neo3(?: link|pro)?)/i],[h,c,[u,b]],[/; (quest( \d| pro)?)/i],[c,[h,B],[u,b]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[u,E]],[/(aeobc)\b/i],[c,[h,w],[u,E]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[c,[u,g]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[c,[u,v]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[u,v]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[u,g]],[/(android[-\w\. ]{0,9});.+buil/i],[c,[h,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[f,[d,"EdgeHTML"]],[/(arkweb)\/([\w\.]+)/i],[d,f],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[f,[d,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[d,f],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[f,d]],os:[[/microsoft (windows) (vista|xp)/i],[d,f],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[d,[f,K,q]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[f,K,q],[d,"Windows"]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[f,/_/g,"."],[d,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[d,z],[f,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[f,d],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[d,f],[/\(bb(10);/i],[f,[d,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[f,[d,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[f,[d,L+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[f,[d,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[f,[d,"watchOS"]],[/crkey\/([\d\.]+)/i],[f,[d,k+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[d,U],f],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[d,f],[/(sunos) ?([\w\.\d]*)/i],[[d,"Solaris"],f],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[d,f]]},Q=function(e,t){if(typeof e===a&&(t=e,e=i),!(this instanceof Q))return new Q(e,t).getResult();var m=typeof r!==n&&r.navigator?r.navigator:i,y=e||(m&&m.userAgent?m.userAgent:""),b=m&&m.userAgentData?m.userAgentData:i,E=t?function(e,t){var r={};for(var i in e)t[i]&&t[i].length%2==0?r[i]=t[i].concat(e[i]):r[i]=e[i];return r}(X,t):X,w=m&&m.userAgent==y;return this.getBrowser=function(){var e={};return e[d]=i,e[f]=i,Y.call(e,y,E.browser),e[l]=function(e){return typeof e===o?e.replace(/[^\d\.]/g,"").split(".")[0]:i}(e[f]),w&&m&&m.brave&&typeof m.brave.isBrave==s&&(e[d]="Brave"),e},this.getCPU=function(){var e={};return e[p]=i,Y.call(e,y,E.cpu),e},this.getDevice=function(){var e={};return e[h]=i,e[c]=i,e[u]=i,Y.call(e,y,E.device),w&&!e[u]&&b&&b.mobile&&(e[u]=g),w&&"Macintosh"==e[c]&&m&&typeof m.standalone!==n&&m.maxTouchPoints&&m.maxTouchPoints>2&&(e[c]="iPad",e[u]=v),e},this.getEngine=function(){var e={};return e[d]=i,e[f]=i,Y.call(e,y,E.engine),e},this.getOS=function(){var e={};return e[d]=i,e[f]=i,Y.call(e,y,E.os),w&&!e[d]&&b&&b.platform&&"Unknown"!=b.platform&&(e[d]=b.platform.replace(/chrome os/i,U).replace(/macos/i,z)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return y},this.setUA=function(e){return y=typeof e===o&&e.length>500?W(e,500):e,this},this.setUA(y),this};Q.VERSION="1.0.40",Q.BROWSER=j([d,f,l]),Q.CPU=j([p]),Q.DEVICE=j([c,h,u,m,g,y,v,b,E]),Q.ENGINE=Q.OS=j([d,f]),e.exports&&(t=e.exports=Q),t.UAParser=Q;var Z=typeof r!==n&&(r.jQuery||r.Zepto);if(Z&&!Z.ua){var J=new Q;Z.ua=J.getResult(),Z.ua.get=function(){return J.getUA()},Z.ua.set=function(e){J.setUA(e);var t=J.getResult();for(var r in t)Z.ua[r]=t[r]}}}("object"==typeof window?window:Ya)),Wa.exports;var e,t}var qa=function(){if(Ha)return Va;Ha=1,Object.defineProperty(Va,"__esModule",{value:!0});var e,r=t,i=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,s=Ka(),n=new s,a=n.getBrowser(),o=n.getCPU(),l=n.getDevice(),c=n.getEngine(),d=n.getOS(),u=n.getUA(),h=function(e){return n.setUA(e)},f=function(e){if(e){var t=new s(e);return{UA:t,browser:t.getBrowser(),cpu:t.getCPU(),device:t.getDevice(),engine:t.getEngine(),os:t.getOS(),ua:t.getUA(),setUserAgent:function(e){return t.setUA(e)}}}console.error("No userAgent string was provided")},p=Object.freeze({ClientUAInstance:n,browser:a,cpu:o,device:l,engine:c,os:d,ua:u,setUa:h,parseUserAgent:f});function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function g(e){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g(e)}function v(e,t,r){return t&&function(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}(e.prototype,t),e}function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(){return b=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},b.apply(this,arguments)}function E(e){return E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},E(e)}function w(e,t){return w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},w(e,t)}function S(e,t){if(null==e)return{};var r,i,s=function(e,t){if(null==e)return{};var r,i,s={},n=Object.keys(e);for(i=0;i<n.length;i++)r=n[i],t.indexOf(r)>=0||(s[r]=e[r]);return s}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(i=0;i<n.length;i++)r=n[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(s[r]=e[r])}return s}function T(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var i,s,n=[],a=!0,o=!1;try{for(r=r.call(e);!(a=(i=r.next()).done)&&(n.push(i.value),!t||n.length!==t);a=!0);}catch(e){o=!0,s=e}finally{try{a||null==r.return||r.return()}finally{if(o)throw s}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return A(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return A(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}var k="mobile",L="tablet",I="smarttv",R="console",P="wearable",C="embedded",D=void 0,_={Chrome:"Chrome",Firefox:"Firefox",Opera:"Opera",Yandex:"Yandex",Safari:"Safari",InternetExplorer:"Internet Explorer",Edge:"Edge",Chromium:"Chromium",Ie:"IE",MobileSafari:"Mobile Safari",EdgeChromium:"Edge Chromium",MIUI:"MIUI Browser",SamsungBrowser:"Samsung Browser"},O={IOS:"iOS",Android:"Android",WindowsPhone:"Windows Phone",Windows:"Windows",MAC_OS:"Mac OS"},M={isMobile:!1,isTablet:!1,isBrowser:!1,isSmartTV:!1,isConsole:!1,isWearable:!1},N=function(e){return e||(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"none")},F=function(){return!("undefined"==typeof window||!window.navigator&&!navigator)&&(window.navigator||navigator)},$=function(e){var t=F();return t&&t.platform&&(-1!==t.platform.indexOf(e)||"MacIntel"===t.platform&&t.maxTouchPoints>1&&!window.MSStream)},B=function(e,t,r,i){return function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach(function(t){y(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({},e,{vendor:N(t.vendor),model:N(t.model),os:N(r.name),osVersion:N(r.version),ua:N(i)})},U=function(e){return e.type===k},z=function(e){return e.type===L},G=function(e){var t=e.type;return t===k||t===L},j=function(e){return e.type===I},H=function(e){return e.type===D},V=function(e){return e.type===P},W=function(e){return e.type===R},Y=function(e){return e.type===C},K=function(e){var t=e.vendor;return N(t)},q=function(e){var t=e.model;return N(t)},X=function(e){var t=e.type;return N(t,"browser")},Q=function(e){return e.name===O.Android},Z=function(e){return e.name===O.Windows},J=function(e){return e.name===O.MAC_OS},ee=function(e){return e.name===O.WindowsPhone},te=function(e){return e.name===O.IOS},re=function(e){var t=e.version;return N(t)},ie=function(e){var t=e.name;return N(t)},se=function(e){return e.name===_.Chrome},ne=function(e){return e.name===_.Firefox},ae=function(e){return e.name===_.Chromium},oe=function(e){return e.name===_.Edge},le=function(e){return e.name===_.Yandex},ce=function(e){var t=e.name;return t===_.Safari||t===_.MobileSafari},de=function(e){return e.name===_.MobileSafari},ue=function(e){return e.name===_.Opera},he=function(e){var t=e.name;return t===_.InternetExplorer||t===_.Ie},fe=function(e){return e.name===_.MIUI},pe=function(e){return e.name===_.SamsungBrowser},me=function(e){var t=e.version;return N(t)},ge=function(e){var t=e.major;return N(t)},ve=function(e){var t=e.name;return N(t)},ye=function(e){var t=e.name;return N(t)},be=function(e){var t=e.version;return N(t)},Ee=function(){var e=F(),t=e&&e.userAgent&&e.userAgent.toLowerCase();return"string"==typeof t&&/electron/.test(t)},we=function(e){return"string"==typeof e&&-1!==e.indexOf("Edg/")},Se=function(){var e=F();return e&&(/iPad|iPhone|iPod/.test(e.platform)||"MacIntel"===e.platform&&e.maxTouchPoints>1)&&!window.MSStream},Te=function(){return $("iPad")},xe=function(){return $("iPhone")},Ae=function(){return $("iPod")},ke=function(e){return N(e)};function Le(e){var t=e||p,r=t.device,i=t.browser,s=t.os,n=t.engine,a=t.ua;return{isSmartTV:j(r),isConsole:W(r),isWearable:V(r),isEmbedded:Y(r),isMobileSafari:de(i)||Te(),isChromium:ae(i),isMobile:G(r)||Te(),isMobileOnly:U(r),isTablet:z(r)||Te(),isBrowser:H(r),isDesktop:H(r),isAndroid:Q(s),isWinPhone:ee(s),isIOS:te(s)||Te(),isChrome:se(i),isFirefox:ne(i),isSafari:ce(i),isOpera:ue(i),isIE:he(i),osVersion:re(s),osName:ie(s),fullBrowserVersion:me(i),browserVersion:ge(i),browserName:ve(i),mobileVendor:K(r),mobileModel:q(r),engineName:ye(n),engineVersion:be(n),getUA:ke(a),isEdge:oe(i)||we(a),isYandex:le(i),deviceType:X(r),isIOS13:Se(),isIPad13:Te(),isIPhone13:xe(),isIPod13:Ae(),isElectron:Ee(),isEdgeChromium:we(a),isLegacyEdge:oe(i)&&!we(a),isWindows:Z(s),isMacOs:J(s),isMIUI:fe(i),isSamsungBrowser:pe(i)}}var Ie=j(l),Re=W(l),Pe=V(l),Ce=Y(l),De=de(a)||Te(),_e=ae(a),Oe=G(l)||Te(),Me=U(l),Ne=z(l)||Te(),Fe=H(l),$e=H(l),Be=Q(d),Ue=ee(d),ze=te(d)||Te(),Ge=se(a),je=ne(a),He=ce(a),Ve=ue(a),We=he(a),Ye=re(d),Ke=ie(d),qe=me(a),Xe=ge(a),Qe=ve(a),Ze=K(l),Je=q(l),et=ye(c),tt=be(c),rt=ke(u),it=oe(a)||we(u),st=le(a),nt=X(l),at=Se(),ot=Te(),lt=xe(),ct=Ae(),dt=Ee(),ut=we(u),ht=oe(a)&&!we(u),ft=Z(d),pt=J(d),mt=fe(a),gt=pe(a);function vt(e){var t=e||window.navigator.userAgent;return f(t)}return Va.AndroidView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Be?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.BrowserTypes=_,Va.BrowserView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Fe?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.ConsoleView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Re?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.CustomView=function(e){var t=e.renderWithFragment,s=e.children;e.viewClassName,e.style;var n=e.condition,a=S(e,["renderWithFragment","children","viewClassName","style","condition"]);return n?t?i.createElement(r.Fragment,null,s):i.createElement("div",a,s):null},Va.IEView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return We?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.IOSView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return ze?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.MobileOnlyView=function(e){var t=e.renderWithFragment,s=e.children;e.viewClassName,e.style;var n=S(e,["renderWithFragment","children","viewClassName","style"]);return Me?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.MobileView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Oe?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.OsTypes=O,Va.SmartTVView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Ie?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.TabletView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Ne?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.WearableView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Pe?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.WinPhoneView=function(e){var t=e.renderWithFragment,s=e.children,n=S(e,["renderWithFragment","children"]);return Ue?t?i.createElement(r.Fragment,null,s):i.createElement("div",n,s):null},Va.browserName=Qe,Va.browserVersion=Xe,Va.deviceDetect=function(e){var t=e?f(e):p,r=t.device,i=t.browser,s=t.engine,n=t.os,a=t.ua,o=function(e){switch(e){case k:return{isMobile:!0};case L:return{isTablet:!0};case I:return{isSmartTV:!0};case R:return{isConsole:!0};case P:return{isWearable:!0};case D:return{isBrowser:!0};case C:return{isEmbedded:!0};default:return M}}(r.type),l=o.isBrowser,c=o.isMobile,d=o.isTablet,u=o.isSmartTV,h=o.isConsole,m=o.isWearable,g=o.isEmbedded;return l?function(e,t,r,i,s){return{isBrowser:e,browserMajorVersion:N(t.major),browserFullVersion:N(t.version),browserName:N(t.name),engineName:N(r.name),engineVersion:N(r.version),osName:N(i.name),osVersion:N(i.version),userAgent:N(s)}}(l,i,s,n,a):u?function(e,t,r,i){return{isSmartTV:e,engineName:N(t.name),engineVersion:N(t.version),osName:N(r.name),osVersion:N(r.version),userAgent:N(i)}}(u,s,n,a):h?function(e,t,r,i){return{isConsole:e,engineName:N(t.name),engineVersion:N(t.version),osName:N(r.name),osVersion:N(r.version),userAgent:N(i)}}(h,s,n,a):c||d?B(o,r,n,a):m?function(e,t,r,i){return{isWearable:e,engineName:N(t.name),engineVersion:N(t.version),osName:N(r.name),osVersion:N(r.version),userAgent:N(i)}}(m,s,n,a):g?function(e,t,r,i,s){return{isEmbedded:e,vendor:N(t.vendor),model:N(t.model),engineName:N(r.name),engineVersion:N(r.version),osName:N(i.name),osVersion:N(i.version),userAgent:N(s)}}(g,r,s,n,a):void 0},Va.deviceType=nt,Va.engineName=et,Va.engineVersion=tt,Va.fullBrowserVersion=qe,Va.getSelectorsByUserAgent=function(e){if(e&&"string"==typeof e){var t=f(e);return Le({device:t.device,browser:t.browser,os:t.os,engine:t.engine,ua:t.ua})}console.error("No valid user agent string was provided")},Va.getUA=rt,Va.isAndroid=Be,Va.isBrowser=Fe,Va.isChrome=Ge,Va.isChromium=_e,Va.isConsole=Re,Va.isDesktop=$e,Va.isEdge=it,Va.isEdgeChromium=ut,Va.isElectron=dt,Va.isEmbedded=Ce,Va.isFirefox=je,Va.isIE=We,Va.isIOS=ze,Va.isIOS13=at,Va.isIPad13=ot,Va.isIPhone13=lt,Va.isIPod13=ct,Va.isLegacyEdge=ht,Va.isMIUI=mt,Va.isMacOs=pt,Va.isMobile=Oe,Va.isMobileOnly=Me,Va.isMobileSafari=De,Va.isOpera=Ve,Va.isSafari=He,Va.isSamsungBrowser=gt,Va.isSmartTV=Ie,Va.isTablet=Ne,Va.isWearable=Pe,Va.isWinPhone=Ue,Va.isWindows=ft,Va.isYandex=st,Va.mobileModel=Je,Va.mobileVendor=Ze,Va.osName=Ke,Va.osVersion=Ye,Va.parseUserAgent=f,Va.setUserAgent=function(e){return h(e)},Va.useDeviceData=vt,Va.useDeviceSelectors=function(e){var t=vt(e||window.navigator.userAgent);return[Le(t),t]},Va.useMobileOrientation=function(){var e=x(r.useState(function(){var e=window.innerWidth>window.innerHeight?90:0;return{isPortrait:0===e,isLandscape:90===e,orientation:0===e?"portrait":"landscape"}}),2),t=e[0],i=e[1],s=r.useCallback(function(){var e=window.innerWidth>window.innerHeight?90:0,r={isPortrait:0===e,isLandscape:90===e,orientation:0===e?"portrait":"landscape"};t.orientation!==r.orientation&&i(r)},[t.orientation]);return r.useEffect(function(){return void 0!==("undefined"==typeof window?"undefined":g(window))&&Oe&&(s(),window.addEventListener("load",s,!1),window.addEventListener("resize",s,!1)),function(){window.removeEventListener("resize",s,!1),window.removeEventListener("load",s,!1)}},[s]),t},Va.withOrientationChange=function(e){return function(t){function r(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),(t=function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return T(e)}(this,E(r).call(this,e))).isEventListenerAdded=!1,t.handleOrientationChange=t.handleOrientationChange.bind(T(t)),t.onOrientationChange=t.onOrientationChange.bind(T(t)),t.onPageLoad=t.onPageLoad.bind(T(t)),t.state={isLandscape:!1,isPortrait:!1},t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&w(e,t)}(r,t),v(r,[{key:"handleOrientationChange",value:function(){this.isEventListenerAdded||(this.isEventListenerAdded=!0);var e=window.innerWidth>window.innerHeight?90:0;this.setState({isPortrait:0===e,isLandscape:90===e})}},{key:"onOrientationChange",value:function(){this.handleOrientationChange()}},{key:"onPageLoad",value:function(){this.handleOrientationChange()}},{key:"componentDidMount",value:function(){void 0!==("undefined"==typeof window?"undefined":g(window))&&Oe&&(this.isEventListenerAdded?window.removeEventListener("load",this.onPageLoad,!1):(this.handleOrientationChange(),window.addEventListener("load",this.onPageLoad,!1)),window.addEventListener("resize",this.onOrientationChange,!1))}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.onOrientationChange,!1)}},{key:"render",value:function(){return i.createElement(e,b({},this.props,{isLandscape:this.state.isLandscape,isPortrait:this.state.isPortrait}))}}]),r}(i.Component)},Va}();function Xa({message:e,duration:r=3e3,visible:s,setVisible:n}){return i(()=>{const e=setTimeout(()=>n(!1),r);return()=>clearTimeout(e)},[s]),s?t.createElement("div",{style:{position:"fixed",top:"1rem",left:"50%",transform:"translateX(-50%)",background:"rgba(0,0,0,0.8)",color:"#fff",padding:"0.75rem 1.25rem",borderRadius:"0.375rem",fontSize:"14px",zIndex:9999,boxShadow:"0 2px 10px rgba(0,0,0,0.2)"}},e):null}const Qa=({shortForm:e,shareUrl:r})=>{const i=null!=r?r:window.location.href,[s,n]=a(!1);return t.createElement(t.Fragment,null,t.createElement("button",{onClick:()=>x(void 0,void 0,void 0,function*(){try{n(!0),qa.isMobile&&navigator.share&&e?yield navigator.share({title:e.title,url:i}):(e=>{if(void 0!==navigator.clipboard)navigator.clipboard.writeText(e).then(()=>{});else{const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),t.setSelectionRange(0,99999);try{document.execCommand("copy")}catch(e){console.error("복사 실패",e)}t.setSelectionRange(0,0),document.body.removeChild(t)}})(i)}catch(e){console.error("Fail to copy on clipboard")}}),className:"cursor-pointer"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:"https://mbus-asset.s3.ap-northeast-2.amazonaws.com/mcom-player/share.png",alt:"share",width:24,height:24,className:"block h-6 w-6 object-contain"})),t.createElement(Xa,{message:"공유 링크 복사 완료",setVisible:n,visible:s})))},Za=({product:e,useDirectLink:r,contentId:i})=>{var s;const{isPreview:n,priceText:o,memberOnly:l,isMemberLoggedIn:c}=Ua(),d=l&&!c,[u,h]=a(!1),f=t=>{if(!r)return;if(n)return void t.preventDefault();Ia({contentProductId:e.eventProductId,contentId:i,productId:e.productId});(e=>{if("undefined"==typeof window)return!1;const t=window.goDetail;return"function"==typeof t&&(t(e),!0)})(t.currentTarget)&&t.preventDefault()},p=t.createElement(t.Fragment,null,t.createElement("div",{className:"w-1/3 h-full shrink-0"},e.thumbPath&&!u?t.createElement(Hr,{product:e,onError:()=>h(!0)}):t.createElement(jr,null)),t.createElement("div",{className:"flex flex-col text-left p-2 w-full justify-center"},e.brand&&t.createElement("span",{className:"break-keep line-clamp-1 text-gray-500",style:{fontSize:"10px"}},e.brand.brandName),t.createElement("div",{className:"text-gray-800 text-ellipsis line-clamp-1 ",style:{fontSize:"12px"}},e.productName),t.createElement("div",{className:"text-red-500 break-keep",style:{fontSize:"12px"}},d?t.createElement("span",{className:"font-semibold break-keep"},"판매가 회원 공개"):t.createElement(t.Fragment,null,o?o+" ":"할인가 ",t.createElement("span",{className:"font-semibold break-keep"},Tt(e.sellingPrice,e.currency))))));return r?t.createElement("a",{href:null!==(s=e.linkPath)&&void 0!==s?s:void 0,"data-mgcode":e.mallProductCode,target:"_blank",draggable:!1,rel:"noopener noreferrer",style:{height:"80px",textDecoration:"none",color:"inherit"},className:"apphref flex gap-2 items-center w-full",onClick:f},p):t.createElement("div",{style:{height:"80px"},className:"flex gap-2 items-center w-full",onClick:f},p)},Ja=({products:e,contentId:r})=>{const i=d(()=>(e=>{if(e.length>=3)return e;const t=[...e];for(;t.length<3;)t.push(...e);return t})(e),[e]),s=1===(null==e?void 0:e.length);return(null==e?void 0:e.length)?t.createElement("div",{className:"w-full",style:{height:"80px"}},s?t.createElement("div",{className:"bg-white overflow-hidden rounded-xl w-full",style:{borderRadius:"10px",height:"80px"}},t.createElement(Za,{product:e[0],useDirectLink:!0,contentId:r})):t.createElement(Jn,{nested:!0,modules:[pa,ia],slidesPerView:1.1,effect:"cards",autoplay:!0,loop:!0,grabCursor:!0,threshold:10,onClick:(e,t)=>{var r;const i=e.slides[e.activeIndex],s=null==i?void 0:i.querySelector("a.apphref");if(!s)return;const n=e.el.getRootNode(),a=t,o=null===(r=n.elementFromPoint)||void 0===r?void 0:r.call(n,a.clientX,a.clientY);o&&s.contains(o)||s.click()},cardsEffect:{rotate:!1},className:"w-full",style:{height:"80px"}},i.map((e,i)=>t.createElement(ea,{key:i+e.productId,className:"bg-white overflow-hidden rounded-xl",style:{borderRadius:"10px",height:"80px"}},t.createElement(Za,{product:e,useDirectLink:!0,contentId:r}))))):null},eo="https://mbus-asset.s3.ap-northeast-2.amazonaws.com/mcom-player",to=({shortForm:e,isPopup:r,hideProductCarousel:i,hideOverlay:s,shareUrl:n,handleClose:o})=>{const[l,c]=a(!Boolean(r)),[d,u]=a(!0),h=()=>{c(e=>!e)},f=()=>{u(e=>!e)},{logo:p,productsInfo:m,thumbPath:g,title:v,media:y,brand:b,shortsId:E}=e,w=r?"mb-1 max-h-10 max-w-20 object-contain":"mb-1 max-h-10 max-w-28 object-contain",S=e=>{e.stopPropagation()},T=r?t.createElement("div",{className:"justify-self-end flex gap-2"},t.createElement("button",{className:"cursor-pointer text-white",onClick:f},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},d?t.createElement(Nr,{size:24}):t.createElement(Fr,{size:24}))),t.createElement("button",{className:"cursor-pointer text-white",onClick:h},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:`${eo}/${l?"sound_off":"sound"}.png`,alt:l?"muted":"volume",width:24,height:24,className:"block h-6 w-6 object-contain"}))),o?t.createElement("button",{className:"cursor-pointer text-white",onClick:o},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement(zr,{size:24}))):null):t.createElement("div",{className:"flex flex-col gap-3 items-end"},t.createElement("button",{type:"button",className:"text-white",onClick:e=>{S(e),h()},"aria-label":l?"음소거 해제":"음소거"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement("img",{src:`${eo}/${l?"sound_off":"sound"}.png`,alt:l?"muted":"volume",width:24,height:24,className:"block h-6 w-6 object-contain"}))),o?t.createElement("button",{type:"button",className:"text-white",onClick:e=>{S(e),o()},"aria-label":"닫기"},t.createElement("div",{className:"glass-panel flex h-10 w-10 items-center justify-center rounded-full"},t.createElement(zr,{size:24}))):null);return t.createElement("div",{className:"h-full w-full text-sm overflow-hidden text-white relative",onClick:r?void 0:f},t.createElement("div",{className:"pointer-events-none absolute inset-0 z-[1] flex h-full w-full flex-col justify-between bg-gradient-to-b from-black/40 via-transparent to-black/40 p-4"},t.createElement("div",{className:"flex gap-2 justify-between pointer-events-auto",onClick:S},t.createElement("div",null,!s&&(null==p?void 0:p.thumbPath)?t.createElement("img",{className:w,src:p.thumbPath,alt:p.logoName,width:100,height:100}):null),!s&&T),t.createElement("div",{className:"h-full w-full"}),t.createElement("div",{className:"mb-6 pointer-events-auto",onClick:S},!s&&t.createElement("div",{className:"flex justify-between items-end mb-3 gap-3"},t.createElement("div",{className:"w-full"},b&&t.createElement("div",{className:"items-center flex gap-3 mb-2"},t.createElement("div",{className:"w-14 h-14 bg-white rounded-full border overflow-hidden shrink-0"},t.createElement("img",{src:b.thumbPath,alt:b.brandName,width:100,height:100,className:"object-contain w-full h-full"})),t.createElement("p",{className:"mb-2 text-start text-sm line-clamp-1"},null==b?void 0:b.brandName)),t.createElement("p",{className:"text-start text-base line-clamp-2"},v)),t.createElement("div",{className:"flex flex-col gap-4 items-center"},t.createElement(Ga,{shortsId:E}),t.createElement("div",{className:"flex items-center justify-center"},t.createElement(Qa,{shortForm:e,shareUrl:n})))),!i&&(null==m?void 0:m.length)>0&&t.createElement(Ja,{products:m,contentId:e.shortsId}))),t.createElement(L,{file:xt(null==y?void 0:y.objectId),thumbnail:`${Ct(g)}`,mute:l,isVertical:(null==y?void 0:y.height)>(null==y?void 0:y.width),play:d}))},ro="cursor-pointer text-zinc-500",io=e=>{const{collection:i,shortform:s,setShortform:n}=e,a=r(null);return t.createElement("div",{className:"flex h-full gap-2 items-center justify-center mx-auto"},t.createElement("div",{className:"flex flex-col gap-4"},t.createElement(Dr,{size:44,strokeWidth:1,className:ro,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(Rr,{size:44,strokeWidth:1,className:ro,onClick:()=>{var e;null===(e=a.current)||void 0===e||e.swiper.slideNext()}})),t.createElement("div",{className:"h-full aspect-[9/16] max-w-fit relative"},t.createElement(Jn,{modules:[ta,da],mousewheel:!0,direction:"vertical",slidesPerView:1,ref:a,onSlideChangeTransitionEnd:e=>{(e=>{const t=i.contents[e];t&&n(Object.assign({},t))})(e.realIndex)},className:"h-full",preventClicksPropagation:!1,preventClicks:!1,noSwiping:!0,allowTouchMove:!1,loop:!0},i.contents.map(e=>t.createElement(ea,{key:e.shortsId},t.createElement("div",{className:"flex justify-center gap-3 h-full"},s.shortsId===e.shortsId&&t.createElement("div",{className:"h-full absolute z-[999] w-full bg-white"},t.createElement(to,{shortForm:s,hideProductCarousel:!0})),t.createElement("img",{src:Ct(e.thumbPath),alt:e.title,className:"w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")})))))))},so=()=>t.createElement("div",{className:"w-full h-full bg-black/50 absolute top-0 left-0 z-[999] flex items-center justify-center pointer-events-none"},t.createElement("div",{className:"flex flex-col gap-5 items-center justify-center"},t.createElement(_r,{size:80,strokeWidth:1.2,className:"text-white"}),t.createElement("p",{className:"text-white"},"위아래로 스와이프 해보세요"))),no=({collection:e,playerSettings:r})=>{const[i,s]=a(e.contents[0]),[n,o]=a(!0),l=u(()=>{n&&o(!1)},[n]);return t.createElement("div",{className:"flex-1 md:flex md:justify-center w-full h-full bg-black relative",onClick:l},n&&t.createElement(so,null),t.createElement("div",{className:"h-full w-full"},t.createElement(Jn,{modules:[ta,da],loop:!0,mousewheel:!0,direction:"vertical",touchEventsTarget:"container",slidesPerView:1,onSlideChangeTransitionEnd:t=>{const r=e.contents[t.realIndex];s(Object.assign({},r))},className:"h-full md:aspect-[9/16] md:mx-auto"},e.contents.map(e=>t.createElement(ea,{key:e.shortsId,className:"rounded-xl overflow-hidden"},i.shortsId===e.shortsId&&t.createElement("div",{className:"w-full h-full md:flex md:justify-center absolute z-[999]"},t.createElement(to,{shortForm:i})),t.createElement("img",{src:Ct(e.thumbPath),alt:e.title,className:"rounded-xl w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")}))))))};const ao='/*! tailwindcss v4.0.12 | MIT License | https://tailwindcss.com */@layer theme, base, components, utilities;@layer theme{:host,:root{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-500:oklch(0.637 0.237 25.331);--color-blue-200:oklch(0.882 0.059 254.128);--color-blue-300:oklch(0.809 0.105 251.813);--color-gray-200:oklch(0.928 0.006 264.531);--color-gray-400:oklch(0.707 0.022 261.325);--color-gray-500:oklch(0.551 0.027 264.364);--color-gray-700:oklch(0.373 0.034 259.733);--color-gray-800:oklch(0.278 0.033 256.848);--color-gray-900:oklch(0.21 0.034 264.665);--color-zinc-500:oklch(0.552 0.016 285.938);--color-zinc-700:oklch(0.37 0.013 285.805);--color-black:#000;--color-white:#fff;--spacing:0.25rem;--container-lg:32rem;--text-xs:0.75rem;--text-xs--line-height:1.33333;--text-sm:0.875rem;--text-sm--line-height:1.42857;--text-base:1rem;--text-base--line-height:1.5;--text-lg:1.125rem;--text-lg--line-height:1.55556;--text-xl:1.25rem;--text-xl--line-height:1.4;--font-weight-medium:500;--font-weight-semibold:600;--leading-tight:1.25;--ease-in:cubic-bezier(0.4,0,1,1);--ease-in-out:cubic-bezier(0.4,0,0.2,1);--animate-pulse:pulse 2s cubic-bezier(0.4,0,0.6,1) infinite;--aspect-video:16/9;--default-transition-duration:150ms;--default-transition-timing-function:cubic-bezier(0.4,0,0.2,1);--default-font-family:var(--font-sans);--default-font-feature-settings:var(--font-sans--font-feature-settings);--default-font-variation-settings:var(\n --font-sans--font-variation-settings\n );--default-mono-font-family:var(--font-mono);--default-mono-font-feature-settings:var(\n --font-mono--font-feature-settings\n );--default-mono-font-variation-settings:var(\n --font-mono--font-variation-settings\n );--animate-float:float 2s ease}}@layer base{*,::backdrop,::file-selector-button,:after,:before{border:0 solid;box-sizing:border-box;margin:0;padding:0}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:var(--default-font-feature-settings,normal);-webkit-tap-highlight-color:transparent;font-family:var( --default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji" );font-variation-settings:var( --default-font-variation-settings,normal );line-height:1.5;tab-size:4}body{line-height:inherit}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:var( --default-mono-font-feature-settings,normal );font-family:var( --default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace );font-size:1em;font-variation-settings:var( --default-mono-font-variation-settings,normal )}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}::file-selector-button,button,input,optgroup,select,textarea{font-feature-settings:inherit;background-color:transparent;border-radius:0;color:inherit;font:inherit;font-variation-settings:inherit;letter-spacing:inherit;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{color:color-mix(in oklab,currentColor 50%,transparent);opacity:1}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-year-field{padding-block:0}:-moz-ui-invalid{box-shadow:none}::file-selector-button,button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.inset-0{inset:calc(var(--spacing)*0)}.top-0{top:calc(var(--spacing)*0)}.top-1\\/2{top:50%}.top-4{top:calc(var(--spacing)*4)}.right-0{right:calc(var(--spacing)*0)}.right-4{right:calc(var(--spacing)*4)}.bottom-0{bottom:calc(var(--spacing)*0)}.left-0{left:calc(var(--spacing)*0)}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.z-\\[1\\]{z-index:1}.z-\\[5\\]{z-index:5}.z-\\[999\\]{z-index:999}.container{width:100%;@media (width >= 40rem){max-width:40rem}@media (width >= 48rem){max-width:48rem}@media (width >= 64rem){max-width:64rem}@media (width >= 80rem){max-width:80rem}@media (width >= 96rem){max-width:96rem}}.mx-0{margin-inline:calc(var(--spacing)*0)}.mx-auto{margin-inline:auto}.my-0{margin-block:calc(var(--spacing)*0)}.my-2{margin-block:calc(var(--spacing)*2)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.line-clamp-1{-webkit-line-clamp:1}.line-clamp-1,.line-clamp-2{-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-2{-webkit-line-clamp:2}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.table{display:table}.aspect-\\[9\\/16\\]{aspect-ratio:9/16}.aspect-square{aspect-ratio:1/1}.aspect-video{aspect-ratio:var(--aspect-video)}.size-3{height:calc(var(--spacing)*3);width:calc(var(--spacing)*3)}.size-4{height:calc(var(--spacing)*4);width:calc(var(--spacing)*4)}.h-1{height:calc(var(--spacing)*1)}.h-3\\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-16{height:calc(var(--spacing)*16)}.h-\\[24px\\]{height:24px}.h-\\[60px\\]{height:60px}.h-\\[80\\%\\]{height:80%}.h-\\[95\\%\\]{height:95%}.h-\\[100px\\]{height:100px}.h-\\[125px\\]{height:125px}.h-\\[500px\\]{height:500px}.h-\\[600px\\]{height:600px}.h-full{height:100%}.max-h-10{max-height:calc(var(--spacing)*10)}.max-h-\\[150px\\]{max-height:150px}.max-h-\\[300px\\]{max-height:300px}.max-h-fit{max-height:fit-content}.max-h-full{max-height:100%}.min-h-0{min-height:calc(var(--spacing)*0)}.\\!w-auto{width:auto!important}.w-1\\/3{width:33.33333%}.w-4{width:calc(var(--spacing)*4)}.w-4\\/5{width:80%}.w-6{width:calc(var(--spacing)*6)}.w-10{width:calc(var(--spacing)*10)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-16{width:calc(var(--spacing)*16)}.w-36{width:calc(var(--spacing)*36)}.w-\\[24px\\]{width:24px}.w-\\[400px\\]{width:400px}.w-\\[500px\\]{width:500px}.w-\\[1024px\\]{width:1024px}.w-full{width:100%}.max-w-20{max-width:calc(var(--spacing)*20)}.max-w-28{max-width:calc(var(--spacing)*28)}.max-w-52{max-width:calc(var(--spacing)*52)}.max-w-\\[40\\%\\]{max-width:40%}.max-w-\\[160px\\]{max-width:160px}.max-w-\\[800px\\]{max-width:800px}.max-w-\\[830px\\]{max-width:830px}.max-w-fit{max-width:fit-content}.max-w-full{max-width:100%}.max-w-lg{max-width:var(--container-lg)}.max-w-none{max-width:none}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-44{min-width:calc(var(--spacing)*44)}.min-w-\\[768px\\]{min-width:768px}.flex-1{flex:1}.flex-\\[2\\]{flex:2}.flex-shrink-0,.shrink-0{flex-shrink:0}.grow{flex-grow:1}.border-collapse{border-collapse:collapse}.-translate-y-1\\/2{--tw-translate-y:-50%}.-translate-y-1\\/2,.translate-y-0\\.5{translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-0\\.5{--tw-translate-y:calc(var(--spacing)*0.5)}.transform{transform:var(--tw-rotate-x) var(--tw-rotate-y) var(--tw-rotate-z) var(--tw-skew-x) var(--tw-skew-y)}.animate-float{animation:var(--animate-float)}.animate-pulse{animation:var(--animate-pulse)}.cursor-default{cursor:default}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.resize{resize:both}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-1{gap:calc(var(--spacing)*1)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-8{gap:calc(var(--spacing)*8)}.gap-10{gap:calc(var(--spacing)*10)}.self-center{align-self:center}.justify-self-end{justify-self:flex-end}.truncate{text-overflow:ellipsis;white-space:nowrap}.overflow-hidden,.truncate{overflow:hidden}.overflow-scroll{overflow:scroll}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:calc(infinity * 1px)}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-xl{border-radius:calc(var(--radius) + 4px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-none{--tw-border-style:none;border-style:none}.bg-\\[\\#0ab060\\]{background-color:#0ab060}.bg-\\[\\#eeeeee\\]{background-color:#eee}.bg-\\[\\#f4f4f4\\]{background-color:#f4f4f4}.bg-\\[rgba\\(0\\,0\\,0\\,\\.3\\)\\]{background-color:rgba(0,0,0,.3)}.bg-black{background-color:var(--color-black)}.bg-black\\/50{background-color:color-mix(in oklab,var(--color-black) 50%,transparent)}.bg-blue-200{background-color:var(--color-blue-200)}.bg-blue-300{background-color:var(--color-blue-300)}.bg-gray-200{background-color:var(--color-gray-200)}.bg-white{background-color:var(--color-white)}.bg-zinc-700{background-color:var(--color-zinc-700)}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-black\\/40{--tw-gradient-from:color-mix(in oklab,var(--color-black) 40%,transparent);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}.via-transparent{--tw-gradient-via:transparent;--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-via) var(--tw-gradient-via-position),var(--tw-gradient-to) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-black\\/40{--tw-gradient-to:color-mix(in oklab,var(--color-black) 40%,transparent);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from) var(--tw-gradient-from-position),var(--tw-gradient-to) var(--tw-gradient-to-position))}.fill-black{fill:var(--color-black)}.fill-red-500{fill:var(--color-red-500)}.fill-white{fill:var(--color-white)}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-center{object-position:center}.p-0{padding:calc(var(--spacing)*0)}.p-1{padding:calc(var(--spacing)*1)}.p-2{padding:calc(var(--spacing)*2)}.p-4{padding:calc(var(--spacing)*4)}.p-6{padding:calc(var(--spacing)*6)}.p-10{padding:calc(var(--spacing)*10)}.p-\\[3px\\]{padding:3px}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-10{padding-inline:calc(var(--spacing)*10)}.px-14{padding-inline:calc(var(--spacing)*14)}.px-\\[24px\\]{padding-inline:24px}.py-2{padding-block:calc(var(--spacing)*2)}.py-4{padding-block:calc(var(--spacing)*4)}.pt-0{padding-top:calc(var(--spacing)*0)}.pr-1{padding-right:calc(var(--spacing)*1)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pb-10{padding-bottom:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-start{text-align:start}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[10px\\]{font-size:10px}.text-\\[12px\\]{font-size:12px}.leading-none{--tw-leading:1;line-height:1}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.break-keep{word-break:keep-all}.text-clip{text-overflow:clip}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.text-black{color:var(--color-black)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-700{color:var(--color-gray-700)}.text-gray-800{color:var(--color-gray-800)}.text-gray-900{color:var(--color-gray-900)}.text-muted-foreground{color:var(--muted-foreground)}.text-red-500{color:var(--color-red-500)}.text-transparent{color:transparent}.text-white{color:var(--color-white)}.text-zinc-500{color:var(--color-zinc-500)}.line-through{text-decoration-line:line-through}.opacity-50{opacity:50%}.opacity-70{opacity:70%}.shadow,.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,rgba(0,0,0,.1)),0 1px 2px -1px var(--tw-shadow-color,rgba(0,0,0,.1));box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-ring\\/30{--tw-ring-color:color-mix(in oklab,var(--ring) 30%,transparent)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.transition{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-\\[color\\,box-shadow\\]{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:color,box-shadow;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-all{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-opacity{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-transform{transition-duration:var(--tw-duration,var(--default-transition-duration));transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.duration-200{--tw-duration:200ms;transition-duration:.2s}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.duration-200{animation-duration:.2s}.ease-in{animation-timing-function:cubic-bezier(.4,0,1,1)}.ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.fade-in{--tw-enter-opacity:0}.last\\:border-b-0{&:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}}.hover\\:underline{&:hover{@media (hover:hover){text-decoration-line:underline}}}.hover\\:opacity-100{&:hover{@media (hover:hover){opacity:100%}}}.hover\\:ring-4{&:hover{@media (hover:hover){--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}}.focus\\:ring-2{&:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus\\:ring-ring{&:focus{--tw-ring-color:var(--ring)}}.focus\\:ring-offset-2{&:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}}.focus\\:ring-offset-background{&:focus{--tw-ring-offset-color:var(--background)}}.focus\\:outline-none{&:focus{--tw-outline-style:none;outline-style:none}}.focus-visible\\:border-ring{&:focus-visible{border-color:var(--ring)}}.focus-visible\\:ring-4{&:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus-visible\\:ring-\\[3px\\]{&:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentColor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}}.focus-visible\\:ring-ring\\/50{&:focus-visible{--tw-ring-color:color-mix(in oklab,var(--ring) 50%,transparent)}}.focus-visible\\:outline-hidden{&:focus-visible{--tw-outline-style:none;outline-style:none;@media (forced-colors:active){outline:2px solid transparent;outline-offset:2px}}}.disabled\\:pointer-events-none{&:disabled{pointer-events:none}}.disabled\\:opacity-50{&:disabled{opacity:50%}}.data-\\[disabled\\]\\:opacity-50{&[data-disabled]{opacity:50%}}.data-\\[orientation\\=horizontal\\]\\:h-1\\.5{&[data-orientation=horizontal]{height:calc(var(--spacing)*1.5)}}.data-\\[orientation\\=horizontal\\]\\:h-full{&[data-orientation=horizontal]{height:100%}}.data-\\[orientation\\=horizontal\\]\\:w-full{&[data-orientation=horizontal]{width:100%}}.data-\\[orientation\\=vertical\\]\\:h-full{&[data-orientation=vertical]{height:100%}}.data-\\[orientation\\=vertical\\]\\:min-h-44{&[data-orientation=vertical]{min-height:calc(var(--spacing)*44)}}.data-\\[orientation\\=vertical\\]\\:w-1\\.5{&[data-orientation=vertical]{width:calc(var(--spacing)*1.5)}}.data-\\[orientation\\=vertical\\]\\:w-auto{&[data-orientation=vertical]{width:auto}}.data-\\[orientation\\=vertical\\]\\:w-full{&[data-orientation=vertical]{width:100%}}.data-\\[orientation\\=vertical\\]\\:flex-col{&[data-orientation=vertical]{flex-direction:column}}.\\[\\&\\[data-state\\=open\\]\\>svg\\]\\:rotate-180,.lg\\:px-5,.md\\:aspect-\\[9\\/16\\],.md\\:flex,.md\\:justify-center,.md\\:mx-auto,.md\\:px-4,.sm\\:flex-row,.sm\\:justify-end,.sm\\:mx-0{&[data-state=open]>svg{rotate:180deg}}}body{--background:oklch(1 0 0);--foreground:oklch(0.145 0 0);--card:oklch(1 0 0);--card-foreground:oklch(0.145 0 0);--popover:oklch(1 0 0);--popover-foreground:oklch(0.145 0 0);--primary:oklch(0.205 0 0);--primary-foreground:oklch(0.985 0 0);--secondary:oklch(0.97 0 0);--secondary-foreground:oklch(0.205 0 0);--muted:oklch(0.97 0 0);--muted-foreground:oklch(0.556 0 0);--accent:oklch(0.97 0 0);--accent-foreground:oklch(0.205 0 0);--destructive:oklch(0.577 0.245 27.325);--destructive-foreground:oklch(0.577 0.245 27.325);--border:oklch(0.922 0 0);--input:oklch(0.922 0 0);--ring:oklch(0.708 0 0);--chart-1:oklch(0.646 0.222 41.116);--chart-2:oklch(0.6 0.118 184.704);--chart-3:oklch(0.398 0.07 227.392);--chart-4:oklch(0.828 0.189 84.429);--chart-5:oklch(0.769 0.188 70.08);--radius:0.625rem;--sidebar:oklch(0.985 0 0);--sidebar-foreground:oklch(0.145 0 0);--sidebar-primary:oklch(0.205 0 0);--sidebar-primary-foreground:oklch(0.985 0 0);--sidebar-accent:oklch(0.97 0 0);--sidebar-accent-foreground:oklch(0.205 0 0);--sidebar-border:oklch(0.922 0 0);--sidebar-ring:oklch(0.708 0 0);outline:none}.dark{--background:oklch(0.145 0 0);--foreground:oklch(0.985 0 0);--card:oklch(0.145 0 0);--card-foreground:oklch(0.985 0 0);--popover:oklch(0.145 0 0);--popover-foreground:oklch(0.985 0 0);--primary:oklch(0.985 0 0);--primary-foreground:oklch(0.205 0 0);--secondary:oklch(0.269 0 0);--secondary-foreground:oklch(0.985 0 0);--muted:oklch(0.269 0 0);--muted-foreground:oklch(0.708 0 0);--accent:oklch(0.269 0 0);--accent-foreground:oklch(0.985 0 0);--destructive:oklch(0.396 0.141 25.723);--destructive-foreground:oklch(0.637 0.237 25.331);--border:oklch(0.269 0 0);--input:oklch(0.269 0 0);--ring:oklch(0.439 0 0);--chart-1:oklch(0.488 0.243 264.376);--chart-2:oklch(0.696 0.17 162.48);--chart-3:oklch(0.769 0.188 70.08);--chart-4:oklch(0.627 0.265 303.9);--chart-5:oklch(0.645 0.246 16.439);--sidebar:oklch(0.205 0 0);--sidebar-foreground:oklch(0.985 0 0);--sidebar-primary:oklch(0.488 0.243 264.376);--sidebar-primary-foreground:oklch(0.985 0 0);--sidebar-accent:oklch(0.269 0 0);--sidebar-accent-foreground:oklch(0.985 0 0);--sidebar-border:oklch(0.269 0 0);--sidebar-ring:oklch(0.439 0 0)}@layer base{*{border-color:var(--border);outline-color:color-mix(in oklab,var(--ring) 50%,transparent)}body{background-color:var(--background);color:var(--foreground)}}html.overflow-hidden{overflow:hidden}.scrollbar-hide::-webkit-scrollbar{display:none}.scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.bg-insta{background-image:linear-gradient(to top right,#facc15,#ec4899,#9333ea)}.glass-panel{backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);background:hsla(0,0%,100%,.1);border:1px solid hsla(0,0%,100%,.1)}.product-banner{align-items:center;background:#fff;border-radius:8px;cursor:pointer;display:flex;gap:8px;position:relative}.product-banner__clip{border-radius:inherit;overflow:hidden}.product-banner__clip,.product-banner__sheen{inset:0;pointer-events:none;position:absolute;z-index:1}.product-banner__sheen{background:linear-gradient(270deg,rgba(0,0,0,.1),transparent);transform:translateX(100%);transition:transform .3s ease}.product-banner:hover .product-banner__sheen{transform:translateX(0)}.product-banner__arrow{opacity:0;pointer-events:none;position:absolute;right:8px;top:50%;transform:translate(4px,-50%);transition:transform .3s ease,opacity .3s ease;z-index:2}.product-banner:hover .product-banner__arrow{opacity:1;transform:translateY(-50%)}.product-dialog-container{max-height:70vh;max-width:min(82vw,500px);overflow-y:auto;width:100%}.border{border:1px solid oklch(.922 0 0)}@font-face{font-family:swiper-icons;font-style:normal;font-weight:400;src:url("data:application/font-woff;charset=utf-8;base64, d09GRgABAAAAAAZgABAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAGRAAAABoAAAAci6qHkUdERUYAAAWgAAAAIwAAACQAYABXR1BPUwAABhQAAAAuAAAANuAY7+xHU1VCAAAFxAAAAFAAAABm2fPczU9TLzIAAAHcAAAASgAAAGBP9V5RY21hcAAAAkQAAACIAAABYt6F0cBjdnQgAAACzAAAAAQAAAAEABEBRGdhc3AAAAWYAAAACAAAAAj//wADZ2x5ZgAAAywAAADMAAAD2MHtryVoZWFkAAABbAAAADAAAAA2E2+eoWhoZWEAAAGcAAAAHwAAACQC9gDzaG10eAAAAigAAAAZAAAArgJkABFsb2NhAAAC0AAAAFoAAABaFQAUGG1heHAAAAG8AAAAHwAAACAAcABAbmFtZQAAA/gAAAE5AAACXvFdBwlwb3N0AAAFNAAAAGIAAACE5s74hXjaY2BkYGAAYpf5Hu/j+W2+MnAzMYDAzaX6QjD6/4//Bxj5GA8AuRwMYGkAPywL13jaY2BkYGA88P8Agx4j+/8fQDYfA1AEBWgDAIB2BOoAeNpjYGRgYNBh4GdgYgABEMnIABJzYNADCQAACWgAsQB42mNgYfzCOIGBlYGB0YcxjYGBwR1Kf2WQZGhhYGBiYGVmgAFGBiQQkOaawtDAoMBQxXjg/wEGPcYDDA4wNUA2CCgwsAAAO4EL6gAAeNpj2M0gyAACqxgGNWBkZ2D4/wMA+xkDdgAAAHjaY2BgYGaAYBkGRgYQiAHyGMF8FgYHIM3DwMHABGQrMOgyWDLEM1T9/w8UBfEMgLzE////P/5//f/V/xv+r4eaAAeMbAxwIUYmIMHEgKYAYjUcsDAwsLKxc3BycfPw8jEQA/gZBASFhEVExcQlJKWkZWTl5BUUlZRVVNXUNTQZBgMAAMR+E+gAEQFEAAAAKgAqACoANAA+AEgAUgBcAGYAcAB6AIQAjgCYAKIArAC2AMAAygDUAN4A6ADyAPwBBgEQARoBJAEuATgBQgFMAVYBYAFqAXQBfgGIAZIBnAGmAbIBzgHsAAB42u2NMQ6CUAyGW568x9AneYYgm4MJbhKFaExIOAVX8ApewSt4Bic4AfeAid3VOBixDxfPYEza5O+Xfi04YADggiUIULCuEJK8VhO4bSvpdnktHI5QCYtdi2sl8ZnXaHlqUrNKzdKcT8cjlq+rwZSvIVczNiezsfnP/uznmfPFBNODM2K7MTQ45YEAZqGP81AmGGcF3iPqOop0r1SPTaTbVkfUe4HXj97wYE+yNwWYxwWu4v1ugWHgo3S1XdZEVqWM7ET0cfnLGxWfkgR42o2PvWrDMBSFj/IHLaF0zKjRgdiVMwScNRAoWUoH78Y2icB/yIY09An6AH2Bdu/UB+yxopYshQiEvnvu0dURgDt8QeC8PDw7Fpji3fEA4z/PEJ6YOB5hKh4dj3EvXhxPqH/SKUY3rJ7srZ4FZnh1PMAtPhwP6fl2PMJMPDgeQ4rY8YT6Gzao0eAEA409DuggmTnFnOcSCiEiLMgxCiTI6Cq5DZUd3Qmp10vO0LaLTd2cjN4fOumlc7lUYbSQcZFkutRG7g6JKZKy0RmdLY680CDnEJ+UMkpFFe1RN7nxdVpXrC4aTtnaurOnYercZg2YVmLN/d/gczfEimrE/fs/bOuq29Zmn8tloORaXgZgGa78yO9/cnXm2BpaGvq25Dv9S4E9+5SIc9PqupJKhYFSSl47+Qcr1mYNAAAAeNptw0cKwkAAAMDZJA8Q7OUJvkLsPfZ6zFVERPy8qHh2YER+3i/BP83vIBLLySsoKimrqKqpa2hp6+jq6RsYGhmbmJqZSy0sraxtbO3sHRydnEMU4uR6yx7JJXveP7WrDycAAAAAAAH//wACeNpjYGRgYOABYhkgZgJCZgZNBkYGLQZtIJsFLMYAAAw3ALgAeNolizEKgDAQBCchRbC2sFER0YD6qVQiBCv/H9ezGI6Z5XBAw8CBK/m5iQQVauVbXLnOrMZv2oLdKFa8Pjuru2hJzGabmOSLzNMzvutpB3N42mNgZGBg4GKQYzBhYMxJLMlj4GBgAYow/P/PAJJhLM6sSoWKfWCAAwDAjgbRAAB42mNgYGBkAIIbCZo5IPrmUn0hGA0AO8EFTQAA")}:root{--swiper-theme-color:#007aff}:host{display:block;margin-left:auto;margin-right:auto;position:relative;z-index:1}.swiper{display:block;list-style:none;margin-left:auto;margin-right:auto;overflow:hidden;padding:0;position:relative;z-index:1}.swiper-vertical>.swiper-wrapper{flex-direction:column}.swiper-wrapper{box-sizing:content-box;display:flex;height:100%;position:relative;transition-property:transform;transition-timing-function:var(--swiper-wrapper-transition-timing-function,initial);width:100%;z-index:1}.swiper-android .swiper-slide,.swiper-ios .swiper-slide,.swiper-wrapper{transform:translateZ(0)}.swiper-horizontal{touch-action:pan-y}.swiper-vertical{touch-action:pan-x}.swiper-slide{display:block;flex-shrink:0;height:100%;position:relative;transition-property:transform;width:100%}.swiper-slide-invisible-blank{visibility:hidden}.swiper-autoheight,.swiper-autoheight .swiper-slide{height:auto}.swiper-autoheight .swiper-wrapper{align-items:flex-start;transition-property:transform,height}.swiper-backface-hidden .swiper-slide{-webkit-backface-visibility:hidden;backface-visibility:hidden;transform:translateZ(0)}.swiper-3d.swiper-css-mode .swiper-wrapper{perspective:1200px}.swiper-3d .swiper-wrapper{transform-style:preserve-3d}.swiper-3d{perspective:1200px}.swiper-3d .swiper-cube-shadow,.swiper-3d .swiper-slide{transform-style:preserve-3d}.swiper-css-mode>.swiper-wrapper{-ms-overflow-style:none;overflow:auto;scrollbar-width:none}.swiper-css-mode>.swiper-wrapper::-webkit-scrollbar{display:none}.swiper-css-mode>.swiper-wrapper>.swiper-slide{scroll-snap-align:start start}.swiper-css-mode.swiper-horizontal>.swiper-wrapper{scroll-snap-type:x mandatory}.swiper-css-mode.swiper-vertical>.swiper-wrapper{scroll-snap-type:y mandatory}.swiper-css-mode.swiper-free-mode>.swiper-wrapper{scroll-snap-type:none}.swiper-css-mode.swiper-free-mode>.swiper-wrapper>.swiper-slide{scroll-snap-align:none}.swiper-css-mode.swiper-centered>.swiper-wrapper:before{content:"";flex-shrink:0;order:9999}.swiper-css-mode.swiper-centered>.swiper-wrapper>.swiper-slide{scroll-snap-align:center center;scroll-snap-stop:always}.swiper-css-mode.swiper-centered.swiper-horizontal>.swiper-wrapper>.swiper-slide:first-child{margin-inline-start:var(--swiper-centered-offset-before)}.swiper-css-mode.swiper-centered.swiper-horizontal>.swiper-wrapper:before{height:100%;min-height:1px;width:var(--swiper-centered-offset-after)}.swiper-css-mode.swiper-centered.swiper-vertical>.swiper-wrapper>.swiper-slide:first-child{margin-block-start:var(--swiper-centered-offset-before)}.swiper-css-mode.swiper-centered.swiper-vertical>.swiper-wrapper:before{height:var(--swiper-centered-offset-after);min-width:1px;width:100%}.swiper-3d .swiper-slide-shadow,.swiper-3d .swiper-slide-shadow-bottom,.swiper-3d .swiper-slide-shadow-left,.swiper-3d .swiper-slide-shadow-right,.swiper-3d .swiper-slide-shadow-top{height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:10}.swiper-3d .swiper-slide-shadow{background:rgba(0,0,0,.15)}.swiper-3d .swiper-slide-shadow-left{background-image:linear-gradient(270deg,rgba(0,0,0,.5),transparent)}.swiper-3d .swiper-slide-shadow-right{background-image:linear-gradient(90deg,rgba(0,0,0,.5),transparent)}.swiper-3d .swiper-slide-shadow-top{background-image:linear-gradient(0deg,rgba(0,0,0,.5),transparent)}.swiper-3d .swiper-slide-shadow-bottom{background-image:linear-gradient(180deg,rgba(0,0,0,.5),transparent)}.swiper-lazy-preloader{border:4px solid var(--swiper-preloader-color,var(--swiper-theme-color));border-radius:50%;border-top:4px solid transparent;box-sizing:border-box;height:42px;left:50%;margin-left:-21px;margin-top:-21px;position:absolute;top:50%;transform-origin:50%;width:42px;z-index:10}.swiper-watch-progress .swiper-slide-visible .swiper-lazy-preloader,.swiper:not(.swiper-watch-progress) .swiper-lazy-preloader{animation:swiper-preloader-spin 1s linear infinite}.swiper-lazy-preloader-white{--swiper-preloader-color:#fff}.swiper-lazy-preloader-black{--swiper-preloader-color:#000}@keyframes swiper-preloader-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.swiper.swiper-cards{overflow:visible}.swiper-cards .swiper-slide{-webkit-backface-visibility:hidden;backface-visibility:hidden;overflow:hidden;transform-origin:center bottom}.swiper-grid>.swiper-wrapper{flex-wrap:wrap}.swiper-grid-column>.swiper-wrapper{flex-direction:column;flex-wrap:wrap}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false;initial-value:rotateX(0)}@property --tw-rotate-y{syntax:"*";inherits:false;initial-value:rotateY(0)}@property --tw-rotate-z{syntax:"*";inherits:false;initial-value:rotateZ(0)}@property --tw-skew-x{syntax:"*";inherits:false;initial-value:skewX(0)}@property --tw-skew-y{syntax:"*";inherits:false;initial-value:skewY(0)}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"<color>";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"<length-percentage>";inherits:false;initial-value:0}@property --tw-gradient-via-position{syntax:"<length-percentage>";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"<length-percentage>";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes pulse{50%{opacity:.5}}@keyframes float{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-200px)}}',oo=ao.trim().length>0,lo="undefined"!=typeof window&&"adoptedStyleSheets"in Document.prototype&&"undefined"!=typeof CSSStyleSheet&&"replaceSync"in CSSStyleSheet.prototype;let co=null;function uo(e){return co||(co=new CSSStyleSheet,co.replaceSync(e)),co}function ho(){return oo?ao:function(){const e=[];for(const t of Array.from(document.styleSheets))try{e.push(Array.from(t.cssRules).map(e=>e.cssText).join("\n"))}catch(e){}return e.join("\n")}()}const fo=({extra:e})=>{const r=ho()+(e?"\n"+e:"");return t.createElement("style",null,r)};const po=Ba(e=>({open:!1,setOpen:t=>e({open:t})}));function mo(){const[e,s]=t.useState(null),n=r(null),{open:a,setOpen:o}=po();return i(()=>{n.current&&(n.current.style.display=a?"block":"none")},[a]),t.useLayoutEffect(()=>{const e=document.createElement("div");e.style.position="fixed",e.style.inset="0",e.style.zIndex="214748348",e.style.display="none",document.body.appendChild(e),n.current=e;const t=e.attachShadow({mode:"open"});!function(e){const t=ho();if(lo)e.adoptedStyleSheets=[uo(t)];else{const r=document.createElement("style");r.textContent=t,e.appendChild(r)}}(t);const r=document.createElement("style");r.innerHTML="\n .product-dialog-container{\n max-height: 70vh;\n overflow-y: auto;\n width: 100%;\n max-width: min(82vw, 500px) !important;\n }\n ",t.appendChild(r);const i=document.createElement("div");return t.appendChild(i),s(i),()=>e.remove()},[]),{container:e,setOpen:o}}const go=t.createContext(null),vo=e=>{const{isMobile:r}=e,s=Ua(e=>e.setIsPreview),[n,o]=a("collection"in e?e.collection.contents[0]:null);if(i(()=>{var t;const r=Ua.getState().isPreview;return s(null===(t=e.isPreview)||void 0===t||t),()=>{s(r)}},[e.isPreview,s]),r){if("shortform"in e)return t.createElement(to,{shortForm:e.shortform});if(e.collection)return t.createElement(no,{collection:e.collection,playerSettings:e.collection.player.shoppingPlayer})}if("shortform"in e){const{layout:r}=e.shortform.player,i=e.shortform.player.shoppingPlayer;switch(r){case wr.PLATFORM:return t.createElement(_s,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"aspect-[9/16] h-full rounded-xl border overflow-hidden"},t.createElement(to,{shortForm:e.shortform,hideProductCarousel:!0,hideOverlay:!0}))});case wr.HORIZONTAL:return t.createElement(va,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(to,{shortForm:e.shortform,hideProductCarousel:!0}))});case wr.VERTICAL:return t.createElement(ba,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"aspect-[9/16] h-full"},t.createElement(to,{shortForm:e.shortform,hideProductCarousel:!0}))});case wr.GRID:return t.createElement(wa,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(to,{shortForm:e.shortform,hideProductCarousel:!0}))})}}else{if(!e.collection||!n)return null;{const{layout:r}=e.collection.player,i=e.collection.player.shoppingPlayer;switch(r){case wr.PLATFORM:return t.createElement(_s,{shortform:n,playerSettings:i,player:t.createElement("div",{className:"w-full flex items-center justify-center gap-4",style:{height:"calc(-220px + 100vh)"}},t.createElement(Ta,{collection:e.collection,playerSettings:i,shortform:n,setShortform:o}))});case wr.HORIZONTAL:return t.createElement(va,{shortform:n,playerSettings:Object.assign({},i),player:t.createElement(io,{collection:e.collection,playerSettings:i,shortform:n,setShortform:o})});case wr.VERTICAL:return t.createElement(ba,{playerSettings:Object.assign({},i),shortform:n,player:t.createElement(io,{collection:e.collection,playerSettings:i,shortform:n,setShortform:o})});case wr.GRID:return t.createElement(wa,{shortform:n,playerSettings:Object.assign({},i),player:t.createElement(io,{collection:e.collection,playerSettings:i,shortform:n,setShortform:o})})}}}},yo=e=>{const{container:r}=mo();return r?t.createElement(Sr.div,{style:{display:"block",width:"100%",height:"100%"}},t.createElement(fo,null),t.createElement(go.Provider,{value:r},t.createElement(vo,Object.assign({},e)))):null},bo=e=>{const{container:r}=mo();return r?t.createElement(Sr.div,{style:{display:"block",width:"100%",height:"100%"}},t.createElement(fo,null),t.createElement(go.Provider,{value:r},t.createElement(to,Object.assign({},e)))):null},Eo=e=>(document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}),wo=()=>document.visibilityState,So=()=>{throw Error("useVisibilityChange is a client-only hook")};function To(){return"visible"===e.useSyncExternalStore(Eo,wo,So)}var xo=(e,t,s=!0)=>{const n=r(e),a=r(null),o=()=>{a.current&&(clearInterval(a.current),a.current=null)},l=u(()=>{a.current||(a.current=setInterval(()=>n.current(),t))},[t]);return i(()=>{n.current=e},[e]),i(()=>(s&&l(),()=>o()),[l,s]),{clear:o,run:l}};const Ao=()=>{const[e,t]=a(0);xo(()=>{t(e=>e+1)},1e3);return{playtime:e,resetPlaytime:()=>t(0)}},ko=t.createContext(null),Lo=({children:e})=>{const r=t.useRef(null);return r.current||(r.current=Ma(e=>({collection:null,setCollection:t=>e({collection:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})}))),t.createElement(ko.Provider,{value:r.current},e)},Io=()=>(e=>{const r=t.useContext(ko);if(!r)throw new Error("Missing CollectionProvider");return Fa(r,e)})(e=>e),Ro=(e,t)=>{const{collection:r,setCollection:s,isFetching:n,setIsFetching:a,nextKey:o,setNextKey:l}=Io(),{isPreview:c}=Ua(),d=(null==e?void 0:e.media)?e.media.duration.split(":").reduce((e,t,r)=>e+ +t*60**(2-r),0):0;const{resetPlaytime:u,playtime:h}=Ao(),{playtime:f,resetPlaytime:p}=Ao(),m=To(),g=()=>{if(!r)return;const{colId:t,uuid:i,userId:s}=r,n=Ge,a=Math.floor((new Date).getTime()/1e3);localStorage.setItem(n,a.toString()),c||(La({contentId:t,uuid:i,type:wt.COLLECTION,userId:s,playtime:f}),e&&La({contentId:e.shortsId,uuid:e.uuid,type:wt.SHORTS,userId:s,playtime:h,isFinished:h>=d}),p(),u())};i(()=>{m||g()},[m]);return{onSlideChange:i=>x(void 0,void 0,void 0,function*(){if(e&&r&&(yield(e=>x(void 0,void 0,void 0,function*(){var t,i;if(!r)return;const{contents:c,count:d}=r;if((null!=d?d:Number.MAX_SAFE_INTEGER)>c.length&&e>=c.length-5&&!n){a(!0);try{const e=yield Ca({collectionId:r.colId,nextKey:o});if(!e||!(null===(t=e.contents)||void 0===t?void 0:t.length))return;l((null===(i=e.contents.at(-1))||void 0===i?void 0:i.shortsId)||"");const n=new Set(r.contents.map(e=>e.shortsId)),a=e.contents.filter(e=>!n.has(e.shortsId));if(!a.length)return;const c=r.contents.concat(a);s(Object.assign(Object.assign({},r),{contents:c}))}catch(e){console.error(e)}finally{a(!1)}}}))(i),!c)){const{shortsId:s,uuid:n,userId:a}=e;La({contentId:s,uuid:n,type:wt.SHORTS,playtime:h,isFinished:h>=d,userId:a}),u();const o=Lt(),l=r.contents[i];t(Object.assign(Object.assign({},l),{uuid:o})),yield ka({contentId:l.shortsId,uuid:o,type:wt.SHORTS,userId:l.userId,isFirstPlay:!Rt(l.shortsId)})}}),onCollectionClose:g}};function Po(){const[e,t]=a({width:window.innerWidth,height:window.innerHeight});return i(()=>{const e=()=>t({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}const Co=t.memo(({shortform:e,shareUrl:r,handleClose:i})=>t.createElement(t.Fragment,null,t.createElement("div",{onClick:e=>e.stopPropagation(),className:"overflow-hidden",style:{borderRadius:"10px",overflow:"hidden",width:"100%",height:"100%",backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",backgroundImage:`url(${Ct(e.thumbPath)})`}},t.createElement(to,{handleClose:i,shortForm:e,isPopup:!0,shareUrl:r})))),Do=t.memo(({shortform:e})=>t.createElement("div",{onClick:e=>{e.stopPropagation()},style:{width:"100%",height:"100%",borderRadius:"10px",backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",backgroundImage:`url(${e.thumbPath.includes("https")?e.thumbPath:`https://${e.thumbPath}`})`}})),_o=({shortform:e,shareUrl:r,handleClose:i})=>{const{isActive:s}=c(Qn),n=c(Zn),a=Po().width<430||qa.isMobile;return t.createElement("div",{className:"flex items-center justify-center w-full h-full select-none",onClick:e=>{i()}},t.createElement("div",{className:"max-h-full flex items-center justify-center",style:{width:"100%",aspectRatio:a?"auto":"9 / 16",height:a?"100dvh":"auto",maxHeight:a?void 0:"90vh",transform:a?void 0:`scale(${s?1:.8})`,transition:"transform 180ms ease"}},s?t.createElement("div",{className:"flex items-center justify-between w-full h-full text-white relative"},t.createElement("div",{className:"cursor-pointer absolute",onClick:e=>{e.stopPropagation(),n.slidePrev()},style:{zIndex:1e5,left:a?"0":"-30px",top:"50%",transform:"translateY(-50%)",width:30,height:30,display:"grid",placeItems:"center",pointerEvents:"auto"}},t.createElement(Pr,{size:28})),t.createElement(Co,{shortform:e,shareUrl:r,handleClose:i}),t.createElement("div",{className:"cursor-pointer absolute",style:{zIndex:1e5,right:a?"0":"-30px",top:"50%",transform:"translateY(-50%)",width:30,height:30,display:"grid",placeItems:"center",pointerEvents:"auto"},onClick:e=>{e.stopPropagation(),n.slideNext()}},t.createElement(Cr,{size:28}))):t.createElement(Do,{shortform:e})))},Oo=({collection:e,initialShortsId:i,onSlideChange:s,onClosePlayer:n})=>{var a;const{PLAYER_BASE_URL:o}=gt(),l=d(()=>Math.max(e.contents.findIndex(e=>e.shortsId===i),0),[e.contents,i]),c=e.contents.length,u=Math.max(c,10),h=null!==(a=Po().width)&&void 0!==a?a:0,f=h<430||qa.isMobile,p=f?1:h>=1200?4:h>=900?3:2,m=d(()=>(e=>{const t=[...e];for(;t.length<u;)t.push(...e);return t})(e.contents),[e.contents]),g=r(null);return t.createElement("div",{style:{minHeight:100,minWidth:300},className:"w-full"},t.createElement(Jn,{style:{minHeight:100,overflow:"visible"},initialSlide:l,ref:g,lazyPreloadPrevNext:2,className:"w-full",spaceBetween:f?8:h>=1200?24:h>=900?25:16,slidesPerView:p,grabCursor:!0,centeredSlides:1!==p,onSlideChangeTransitionEnd:t=>{const r=t.realIndex%c;null==s||s(r);const i=e.contents[(r+1)%c];var n;n=xt(i.media.objectId),A||(A=document.createElement("video"),A.muted=!0,A.playsInline=!0,A.preload="metadata",A.loop=!0,A.style.cssText="position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;opacity:0",document.body.appendChild(A)),k!==n&&(A.src=n,A.load(),k=n)},loop:!0,onClick:e=>{const t=e.clickedIndex;if("number"!=typeof t||Number.isNaN(t))return;const r=t-e.activeIndex,i=Math.min(Math.abs(r),p);for(let t=0;t<i;t+=1)r>0?e.slideNext():e.slidePrev()}},m.map((r,i)=>t.createElement(ea,{key:i},t.createElement(_o,{handleClose:n,shortform:r,shareUrl:`${o}/collection/${e.colId}?start=${r.shortsId}&layout=5`})))))},Mo=({shortform:e,onThumbnailClick:r,iconSize:i,exposeTitle:s,borderLine:n})=>{const a=d(()=>Pt(n),[n])?{background:"linear-gradient(#fff,#fff) padding-box, conic-gradient(#f58529,#f77737,#fd1d1d,#833ab4,#c13584,#f58529) border-box",border:"3px solid transparent"}:{background:"#fff",border:"3px solid #fff"};return t.createElement("div",{className:"flex flex-col w-full gap-2",onClick:()=>r(e.shortsId)},t.createElement("div",{className:"rounded-full overflow-hidden cursor-pointer",style:Object.assign({width:i,height:i,padding:4},a)},t.createElement("img",{src:Ct(e.thumbPath),alt:"thumbnail",className:"w-full h-full object-cover block rounded-full"})),s&&t.createElement("span",{style:{width:i},className:"text-black overflow-hidden text-[12px] whitespace-nowrap text-center text-clip cursor-default"},e.title))},No=({product:e,productLength:r,hideMoreBadge:i=!1,contentId:s,lineClamp:n,showMoreBtn:a=!1,openProductPopup:o})=>{var l;const{isPreview:c}=Ua(),d=t=>{i&&(c?t.preventDefault():Ia({contentProductId:e.eventProductId,contentId:s,productId:e.productId}))},u=t.createElement(t.Fragment,null,t.createElement("span",{className:"product-banner__clip","aria-hidden":!0},t.createElement("span",{className:"product-banner__sheen"})),t.createElement("div",{className:"relative",style:{width:"40%",minWidth:"40%"}},t.createElement("img",{style:{borderRadius:"0.625rem"},className:"aspect-square rounded-lg object-cover w-full",src:Ct(e.thumbPath),alt:e.productName}),!i&&t.createElement("p",{className:"absolute text-white rounded-lg",style:{backgroundColor:"#797979",top:-10,right:-10,padding:"2px 4px",fontSize:"10px",borderRadius:"0.625rem"}},"+",r)),t.createElement("div",{style:{position:"relative",zIndex:2,minWidth:0,flex:1,paddingRight:24}},t.createElement("p",{style:{display:"-webkit-box",WebkitLineClamp:n||2,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word",fontWeight:600,color:"#494949"}},e.productName)),t.createElement("span",{className:"product-banner__arrow","aria-hidden":!0},"›"));return t.createElement(t.Fragment,null,i?t.createElement("a",{href:null!==(l=e.linkPath)&&void 0!==l?l:void 0,target:"_blank",rel:"noopener noreferrer",className:"apphref product-banner border mbus-border",style:{textDecoration:"none",color:"inherit"},onClick:d},u):t.createElement("div",{className:"product-banner border mbus-border",onClick:d},u),a&&r>1&&t.createElement("div",{onClick:o,className:" flex items-center justify-center border mbus-border cursor-pointer",style:{borderRadius:"0.625rem",padding:"10px",backgroundColor:"#f5f5f5",fontWeight:600}},"+ 더보기 (",r,")"))},Fo=({products:e,iconSize:r,contentId:i,setSelectedProducts:s,showMoreBtn:n,hideMoreBadge:a})=>{const{setOpen:o}=po(),l=()=>{s({productsInfo:e,shortsId:i}),o(!0)};return t.createElement(t.Fragment,null,t.createElement("div",{onClick:()=>x(void 0,void 0,void 0,function*(){1===e.length||n||l()}),className:"flex flex-col gap-2 mt-4 text-gray-800",style:{maxWidth:r||"100%",fontSize:13}},t.createElement(No,{showMoreBtn:n,lineClamp:2,product:e[0],contentId:i,productLength:e.length,hideMoreBadge:null!=a?a:1===e.length,openProductPopup:l})))},$o=({product:e,maxWidth:r="100%",height:i,cardWidth:s})=>{const n=Ua(e=>e.memberOnly&&!e.isMemberLoggedIn);return t.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,borderRadius:8,backgroundColor:"#ffffff",color:"#111827",maxWidth:r,height:i,width:"100%",paddingRight:8}},t.createElement("img",{src:Ct(e.thumbPath),alt:e.productName,style:{height:"100%",aspectRatio:"1 / 1",borderRadius:6,objectFit:"cover",flexShrink:0}}),t.createElement("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",justifyContent:"center"}},t.createElement("span",{style:{lineHeight:1.25,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontSize:12}},e.productName),t.createElement("span",{style:{lineHeight:1.25,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontSize:11}},(()=>{if(n)return t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},"판매가 회원 공개");return"number"==typeof e.sellingPrice&&e.sellingPrice<e.price?"number"==typeof s&&s>=190?t.createElement(t.Fragment,null,t.createElement("span",{style:{color:"#dc2626",fontWeight:600,marginRight:4}},Tt(e.sellingPrice,e.currency)),t.createElement("span",{style:{color:"#9ca3af",textDecoration:"line-through"}},Tt(e.price,e.currency))):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},Tt(e.sellingPrice,e.currency)):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},Tt(e.price,e.currency))})())))},Bo=({playUrl:e,poster:r})=>t.createElement("div",{className:"w-full h-full absolute top-0 left-0 z-10 pointer-events-none",style:{backgroundImage:`url(${r})`,backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat"}},t.createElement("video",{src:e,autoPlay:!0,muted:!0,preload:"auto",playsInline:!0,loop:!0,className:"w-full h-full object-cover"})),Uo=({shortform:e,onThumbnailClick:r,onPreviewPlay:i,iconSize:s,exposeTitle:n,rounded:o,borderLine:l,titlePosition:c,exposeProductBanner:u,setSelectedProducts:h,iconRatio:f,hoverPlay:p,exposeProductBadge:m})=>{var g;const v=d(()=>Pt(l),[l]),[y,b]=a(!1),{API_BASE_URL:E}=gt();return t.createElement("div",{className:"relative"},t.createElement("div",{onMouseEnter:()=>{b(!0),p&&i(e.shortsId)},onMouseLeave:()=>b(!1),onClick:()=>r(e.shortsId),style:Object.assign({width:s,aspectRatio:f},o&&{borderRadius:"10px"}),className:`cursor-pointer p-[3px] ${o&&"rounded-xl"} ${v&&"bg-insta"} relative overflow-hidden`},y&&p&&t.createElement(Bo,{playUrl:`${E}/direct/${e.media.objectId}`,poster:Ct(e.thumbPath)}),t.createElement("img",{style:Object.assign({},o&&{borderRadius:"10px"}),src:Ct(e.thumbPath),alt:"thumbnail",className:`w-full h-full object-cover ${o&&"rounded-xl"}`}),m&&(null===(g=e.productsInfo)||void 0===g?void 0:g.length)>0&&!(p&&y)&&t.createElement("div",{className:"absolute pointer-events-none flex items-center justify-center z-20",style:{left:2,right:2,bottom:10,height:"20%"}},t.createElement("div",{className:"h-full inline-block",style:{width:"95%"}},t.createElement($o,{product:e.productsInfo[0],maxWidth:"100%",height:"100%",cardWidth:s}))),n&&c===Be.INNER&&!(p&&y)&&t.createElement("p",{style:Object.assign({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},m?{bottom:"22%"}:{}),className:"absolute bottom-0 left-0 w-full my-2 text-white px-2 z-10 text-[12px] cursor-default truncate"},e.title)),n&&c!==Be.INNER&&t.createElement("p",{style:{width:s,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},className:"my-2 text-[12px] cursor-default truncate"},e.title),u&&t.createElement(Fo,{setSelectedProducts:h,products:e.productsInfo,iconSize:s,contentId:e.shortsId}))},zo=e=>{const{iconShape:r,collection:i}=e;return r===Ne.MANY?t.createElement(Go,Object.assign({},e)):t.createElement(jo,Object.assign({},e,{shortform:i.contents[0]}))},Go=e=>{const{collection:r}=e,{thumbnailAutoPlay:i}=e,{setCollection:s,nextKey:n,setNextKey:a,isFetching:o,setIsFetching:l}=Io();return t.createElement(Jn,{freeMode:!0,slidesPerView:"auto",spaceBetween:12,onReachEnd:()=>x(void 0,void 0,void 0,function*(){var e,t,i;if(r&&!(o||(null!==(e=r.count)&&void 0!==e?e:Number.MAX_SAFE_INTEGER)<=r.contents.length)){l(!0);try{const e=yield Ca({collectionId:r.colId,nextKey:n});if(!e||!(null===(t=e.contents)||void 0===t?void 0:t.length))return;a((null===(i=e.contents.at(-1))||void 0===i?void 0:i.shortsId)||"");const o=new Set(r.contents.map(e=>e.shortsId)),l=e.contents.filter(e=>!o.has(e.shortsId));if(!l.length)return;s(Object.assign(Object.assign({},r),{contents:[...r.contents,...l]}))}catch(e){console.error(e)}finally{l(!1)}}}),modules:i?[ia]:[],autoplay:!!i&&{delay:3e3,disableOnInteraction:!1,pauseOnMouseEnter:!0},loop:i||void 0},null==r?void 0:r.contents.map(r=>t.createElement(ea,{key:r.shortsId,className:"!w-auto"},t.createElement(jo,Object.assign({},e,{shortform:r})))))},jo=e=>{const{iconForm:r}=e;return r===Me.INSTA?t.createElement(Mo,Object.assign({},e)):t.createElement(Uo,Object.assign({},e))};function Ho(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function Vo(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Wo(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Vo(e,t);return r||"function"!=typeof i||(r=!0),i});if(r)return()=>{for(let t=0;t<i.length;t++){const r=i[t];"function"==typeof r?r():Vo(e[t],null)}}}}function Yo(...t){return e.useCallback(Wo(...t),t)}function Ko(...t){const r=t[0];if(1===t.length)return r;const i=()=>{const i=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const s=i.reduce((e,{useScope:r,scopeName:i})=>({...e,...r(t)[`__scope${i}`]}),{});return e.useMemo(()=>({[`__scope${r.scopeName}`]:s}),[s])}};return i.scopeName=r.scopeName,i}var qo=globalThis?.document?e.useLayoutEffect:()=>{},Xo=e[" useId ".trim().toString()]||(()=>{}),Qo=0;function Zo(t){const[r,i]=e.useState(Xo());return qo(()=>{t||i(e=>e??String(Qo++))},[t]),t||(r?`radix-${r}`:"")}var Jo=e[" useInsertionEffect ".trim().toString()]||qo;function el({prop:t,defaultProp:r,onChange:i=()=>{},caller:s}){const[n,a,o]=function({defaultProp:t,onChange:r}){const[i,s]=e.useState(t),n=e.useRef(i),a=e.useRef(r);return Jo(()=>{a.current=r},[r]),e.useEffect(()=>{n.current!==i&&(a.current?.(i),n.current=i)},[i,n]),[i,s,a]}({defaultProp:r,onChange:i}),l=void 0!==t,c=l?t:n;{const r=e.useRef(void 0!==t);e.useEffect(()=>{const e=r.current;if(e!==l){const t=e?"controlled":"uncontrolled",r=l?"controlled":"uncontrolled";console.warn(`${s} is changing from ${t} to ${r}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}r.current=l},[l,s])}const d=e.useCallback(e=>{if(l){const r=function(e){return"function"==typeof e}(e)?e(t):e;r!==t&&o.current?.(r)}else a(e)},[l,t,a,o]);return[c,d]}function tl(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function rl(t){const r=il(t),i=e.forwardRef((t,i)=>{const{children:s,...n}=t,a=e.Children.toArray(s),o=a.find(nl);if(o){const t=o.props.children,s=a.map(r=>r===o?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return b(r,{...n,ref:i,children:e.isValidElement(t)?e.cloneElement(t,void 0,s):null})}return b(r,{...n,ref:i,children:s})});return i.displayName=`${t}.Slot`,i}function il(t){const r=e.forwardRef((t,r)=>{const{children:i,...s}=t;if(e.isValidElement(i)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),n=function(e,t){const r={...t};for(const i in t){const s=e[i],n=t[i];/^on[A-Z]/.test(i)?s&&n?r[i]=(...e)=>{const t=n(...e);return s(...e),t}:s&&(r[i]=s):"style"===i?r[i]={...s,...n}:"className"===i&&(r[i]=[s,n].filter(Boolean).join(" "))}return{...e,...r}}(s,i.props);return i.type!==e.Fragment&&(n.ref=r?Wo(r,t):t),e.cloneElement(i,n)}return e.Children.count(i)>1?e.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}var sl=Symbol("radix.slottable");function nl(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===sl}var al=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=rl(`Primitive.${r}`),s=e.forwardRef((e,t)=>{const{asChild:s,...n}=e,a=s?i:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),b(a,{...n,ref:t})});return s.displayName=`Primitive.${r}`,{...t,[r]:s}},{});function ol(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}var ll,cl="dismissableLayer.update",dl="dismissableLayer.pointerDownOutside",ul="dismissableLayer.focusOutside",hl=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),fl=e.forwardRef((t,r)=>{const{disableOutsidePointerEvents:i=!1,onEscapeKeyDown:s,onPointerDownOutside:n,onFocusOutside:a,onInteractOutside:o,onDismiss:l,...c}=t,d=e.useContext(hl),[u,h]=e.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=e.useState({}),m=Yo(r,e=>h(e)),g=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(v),E=u?g.indexOf(u):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,S=E>=y,T=function(t,r=globalThis?.document){const i=ol(t),s=e.useRef(!1),n=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!s.current){let t=function(){ml(dl,i,s,{discrete:!0})};const s={originalEvent:e};"touch"===e.pointerType?(r.removeEventListener("click",n.current),n.current=t,r.addEventListener("click",n.current,{once:!0})):t()}else r.removeEventListener("click",n.current);s.current=!1},t=window.setTimeout(()=>{r.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),r.removeEventListener("pointerdown",e),r.removeEventListener("click",n.current)}},[r,i]),{onPointerDownCapture:()=>s.current=!0}}(e=>{const t=e.target,r=[...d.branches].some(e=>e.contains(t));S&&!r&&(n?.(e),o?.(e),e.defaultPrevented||l?.())},f),x=function(t,r=globalThis?.document){const i=ol(t),s=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!s.current){ml(ul,i,{originalEvent:e},{discrete:!1})}};return r.addEventListener("focusin",e),()=>r.removeEventListener("focusin",e)},[r,i]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}(e=>{const t=e.target;[...d.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||l?.())},f);return function(t,r=globalThis?.document){const i=ol(t);e.useEffect(()=>{const e=e=>{"Escape"===e.key&&i(e)};return r.addEventListener("keydown",e,{capture:!0}),()=>r.removeEventListener("keydown",e,{capture:!0})},[i,r])}(e=>{E===d.layers.size-1&&(s?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),e.useEffect(()=>{if(u)return i&&(0===d.layersWithOutsidePointerEventsDisabled.size&&(ll=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(u)),d.layers.add(u),pl(),()=>{i&&1===d.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=ll)}},[u,f,i,d]),e.useEffect(()=>()=>{u&&(d.layers.delete(u),d.layersWithOutsidePointerEventsDisabled.delete(u),pl())},[u,d]),e.useEffect(()=>{const e=()=>p({});return document.addEventListener(cl,e),()=>document.removeEventListener(cl,e)},[]),b(al.div,{...c,ref:m,style:{pointerEvents:w?S?"auto":"none":void 0,...t.style},onFocusCapture:tl(t.onFocusCapture,x.onFocusCapture),onBlurCapture:tl(t.onBlurCapture,x.onBlurCapture),onPointerDownCapture:tl(t.onPointerDownCapture,T.onPointerDownCapture)})});fl.displayName="DismissableLayer";function pl(){const e=new CustomEvent(cl);document.dispatchEvent(e)}function ml(e,t,r,{discrete:i}){const s=r.originalEvent.target,n=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&s.addEventListener(e,t,{once:!0}),i?function(e,t){e&&p.flushSync(()=>e.dispatchEvent(t))}(s,n):s.dispatchEvent(n)}e.forwardRef((t,r)=>{const i=e.useContext(hl),s=e.useRef(null),n=Yo(r,s);return e.useEffect(()=>{const e=s.current;if(e)return i.branches.add(e),()=>{i.branches.delete(e)}},[i.branches]),b(al.div,{...t,ref:n})}).displayName="DismissableLayerBranch";var gl="focusScope.autoFocusOnMount",vl="focusScope.autoFocusOnUnmount",yl={bubbles:!1,cancelable:!0},bl=e.forwardRef((t,r)=>{const{loop:i=!1,trapped:s=!1,onMountAutoFocus:n,onUnmountAutoFocus:a,...o}=t,[l,c]=e.useState(null),d=ol(n),u=ol(a),h=e.useRef(null),f=Yo(r,e=>c(e)),p=e.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;e.useEffect(()=>{if(s){let e=function(e){if(p.paused||!l)return;const t=e.target;l.contains(t)?h.current=t:Tl(h.current,{select:!0})},t=function(e){if(p.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||Tl(h.current,{select:!0}))},r=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&Tl(l)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const i=new MutationObserver(r);return l&&i.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),i.disconnect()}}},[s,l,p.paused]),e.useEffect(()=>{if(l){xl.add(p);const t=document.activeElement;if(!l.contains(t)){const r=new CustomEvent(gl,yl);l.addEventListener(gl,d),l.dispatchEvent(r),r.defaultPrevented||(!function(e,{select:t=!1}={}){const r=document.activeElement;for(const i of e)if(Tl(i,{select:t}),document.activeElement!==r)return}((e=El(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&Tl(l))}return()=>{l.removeEventListener(gl,d),setTimeout(()=>{const e=new CustomEvent(vl,yl);l.addEventListener(vl,u),l.dispatchEvent(e),e.defaultPrevented||Tl(t??document.body,{select:!0}),l.removeEventListener(vl,u),xl.remove(p)},0)}}var e},[l,d,u,p]);const m=e.useCallback(e=>{if(!i&&!s)return;if(p.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,r=document.activeElement;if(t&&r){const t=e.currentTarget,[s,n]=function(e){const t=El(e),r=wl(t,e),i=wl(t.reverse(),e);return[r,i]}(t);s&&n?e.shiftKey||r!==n?e.shiftKey&&r===s&&(e.preventDefault(),i&&Tl(n,{select:!0})):(e.preventDefault(),i&&Tl(s,{select:!0})):r===t&&e.preventDefault()}},[i,s,p.paused]);return b(al.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});function El(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function wl(e,t){for(const r of e)if(!Sl(r,{upTo:t}))return r}function Sl(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function Tl(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}bl.displayName="FocusScope";var xl=function(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=Al(e,t),e.unshift(t)},remove(t){e=Al(e,t),e[0]?.resume()}}}();function Al(e,t){const r=[...e],i=r.indexOf(t);return-1!==i&&r.splice(i,1),r}var kl=e.forwardRef((t,r)=>{const{container:i,...s}=t,[n,a]=e.useState(!1);qo(()=>a(!0),[]);const o=i||n&&globalThis?.document?.body;return o?m.createPortal(b(al.div,{...s,ref:r}),o):null});kl.displayName="Portal";var Ll=t=>{const{present:r,children:i}=t,s=function(t){const[r,i]=e.useState(),s=e.useRef(null),n=e.useRef(t),a=e.useRef("none"),o=t?"mounted":"unmounted",[l,c]=function(t,r){return e.useReducer((e,t)=>r[e][t]??e,t)}(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return e.useEffect(()=>{const e=Il(s.current);a.current="mounted"===l?e:"none"},[l]),qo(()=>{const e=s.current,r=n.current;if(r!==t){const i=a.current,s=Il(e);if(t)c("MOUNT");else if("none"===s||"none"===e?.display)c("UNMOUNT");else{c(r&&i!==s?"ANIMATION_OUT":"UNMOUNT")}n.current=t}},[t,c]),qo(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=Il(s.current).includes(CSS.escape(i.animationName));if(i.target===r&&a&&(c("ANIMATION_END"),!n.current)){const i=r.style.animationFillMode;r.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===r.style.animationFillMode&&(r.style.animationFillMode=i)})}},o=e=>{e.target===r&&(a.current=Il(s.current))};return r.addEventListener("animationstart",o),r.addEventListener("animationcancel",i),r.addEventListener("animationend",i),()=>{t.clearTimeout(e),r.removeEventListener("animationstart",o),r.removeEventListener("animationcancel",i),r.removeEventListener("animationend",i)}}c("ANIMATION_END")},[r,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{s.current=e?getComputedStyle(e):null,i(e)},[])}}(r),n="function"==typeof i?i({present:s.isPresent}):e.Children.only(i),a=Yo(s.ref,function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;if(r)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(n));return"function"==typeof i||s.isPresent?e.cloneElement(n,{ref:a}):null};function Il(e){return e?.animationName||"none"}Ll.displayName="Presence";var Rl=0;function Pl(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Cl="right-scroll-bar-position",Dl="width-before-scroll-bar";function _l(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var Ol="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,Ml=new WeakMap;function Nl(e,t){var r,i,s,n=(r=null,i=function(t){return e.forEach(function(e){return _l(e,t)})},(s=a(function(){return{value:r,callback:i,facade:{get current(){return s.value},set current(e){var t=s.value;t!==e&&(s.value=e,s.callback(e,t))}}}})[0]).callback=i,s.facade);return Ol(function(){var t=Ml.get(n);if(t){var r=new Set(t),i=new Set(e),s=n.current;r.forEach(function(e){i.has(e)||_l(e,null)}),i.forEach(function(e){r.has(e)||_l(e,s)})}Ml.set(n,e)},[e]),n}function Fl(e){return e}var $l=function(t){var r=t.sideCar,i=T(t,["sideCar"]);if(!r)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=r.read();if(!s)throw new Error("Sidecar medium not found");return e.createElement(s,S({},i))};$l.isSideCarExport=!0;var Bl=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=Fl);var r=[],i=!1,s={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(e){var s=t(e,i);return r.push(s),function(){r=r.filter(function(e){return e!==s})}},assignSyncMedium:function(e){for(i=!0;r.length;){var t=r;r=[],t.forEach(e)}r={push:function(t){return e(t)},filter:function(){return r}}},assignMedium:function(e){i=!0;var t=[];if(r.length){var s=r;r=[],s.forEach(e),t=r}var n=function(){var r=t;t=[],r.forEach(e)},a=function(){return Promise.resolve().then(n)};a(),r={push:function(e){t.push(e),a()},filter:function(e){return t=t.filter(e),r}}}};return s}(null);return t.options=S({async:!0,ssr:!1},e),t}(),Ul=function(){},zl=e.forwardRef(function(t,r){var i=e.useRef(null),s=e.useState({onScrollCapture:Ul,onWheelCapture:Ul,onTouchMoveCapture:Ul}),n=s[0],a=s[1],o=t.forwardProps,l=t.children,c=t.className,d=t.removeScrollBar,u=t.enabled,h=t.shards,f=t.sideCar,p=t.noRelative,m=t.noIsolation,g=t.inert,v=t.allowPinchZoom,y=t.as,b=void 0===y?"div":y,E=t.gapMode,w=T(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),x=f,A=Nl([i,r]),k=S(S({},w),n);return e.createElement(e.Fragment,null,u&&e.createElement(x,{sideCar:Bl,removeScrollBar:d,shards:h,noRelative:p,noIsolation:m,inert:g,setCallbacks:a,allowPinchZoom:!!v,lockRef:i,gapMode:E}),o?e.cloneElement(e.Children.only(l),S(S({},k),{ref:A})):e.createElement(b,S({},k,{className:c,ref:A}),l))});zl.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},zl.classNames={fullWidth:Dl,zeroRight:Cl};function Gl(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=function(){if("undefined"!=typeof __webpack_nonce__)return __webpack_nonce__}();return t&&e.setAttribute("nonce",t),e}var jl=function(){var e=0,t=null;return{add:function(r){var i,s;0==e&&(t=Gl())&&(s=r,(i=t).styleSheet?i.styleSheet.cssText=s:i.appendChild(document.createTextNode(s)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Hl=function(){var t,r=(t=jl(),function(r,i){e.useEffect(function(){return t.add(r),function(){t.remove()}},[r&&i])});return function(e){var t=e.styles,i=e.dynamic;return r(t,i),null}},Vl={left:0,top:0,right:0,gap:0},Wl=function(e){return parseInt(e||"",10)||0},Yl=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return Vl;var t=function(e){var t=window.getComputedStyle(document.body),r=t["padding"===e?"paddingLeft":"marginLeft"],i=t["padding"===e?"paddingTop":"marginTop"],s=t["padding"===e?"paddingRight":"marginRight"];return[Wl(r),Wl(i),Wl(s)]}(e),r=document.documentElement.clientWidth,i=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,i-r+t[2]-t[0])}},Kl=Hl(),ql="data-scroll-locked",Xl=function(e,t,r,i){var s=e.left,n=e.top,a=e.right,o=e.gap;return void 0===r&&(r="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(i,";\n padding-right: ").concat(o,"px ").concat(i,";\n }\n body[").concat(ql,"] {\n overflow: hidden ").concat(i,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(i,";"),"margin"===r&&"\n padding-left: ".concat(s,"px;\n padding-top: ").concat(n,"px;\n padding-right: ").concat(a,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(o,"px ").concat(i,";\n "),"padding"===r&&"padding-right: ".concat(o,"px ").concat(i,";")].filter(Boolean).join(""),"\n }\n \n .").concat(Cl," {\n right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat(Dl," {\n margin-right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat(Cl," .").concat(Cl," {\n right: 0 ").concat(i,";\n }\n \n .").concat(Dl," .").concat(Dl," {\n margin-right: 0 ").concat(i,";\n }\n \n body[").concat(ql,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(o,"px;\n }\n")},Ql=function(){var e=parseInt(document.body.getAttribute(ql)||"0",10);return isFinite(e)?e:0},Zl=function(t){var r=t.noRelative,i=t.noImportant,s=t.gapMode,n=void 0===s?"margin":s;e.useEffect(function(){return document.body.setAttribute(ql,(Ql()+1).toString()),function(){var e=Ql()-1;e<=0?document.body.removeAttribute(ql):document.body.setAttribute(ql,e.toString())}},[]);var a=e.useMemo(function(){return Yl(n)},[n]);return e.createElement(Kl,{styles:Xl(a,!r,n,i?"":"!important")})},Jl=!1;if("undefined"!=typeof window)try{var ec=Object.defineProperty({},"passive",{get:function(){return Jl=!0,!0}});window.addEventListener("test",ec,ec),window.removeEventListener("test",ec,ec)}catch(e){Jl=!1}var tc=!!Jl&&{passive:!1},rc=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return"hidden"!==r[t]&&!(r.overflowY===r.overflowX&&!function(e){return"TEXTAREA"===e.tagName}(e)&&"visible"===r[t])},ic=function(e,t){var r=t.ownerDocument,i=t;do{if("undefined"!=typeof ShadowRoot&&i instanceof ShadowRoot&&(i=i.host),sc(e,i)){var s=nc(e,i);if(s[1]>s[2])return!0}i=i.parentNode}while(i&&i!==r.body);return!1},sc=function(e,t){return"v"===e?function(e){return rc(e,"overflowY")}(t):function(e){return rc(e,"overflowX")}(t)},nc=function(e,t){return"v"===e?[(r=t).scrollTop,r.scrollHeight,r.clientHeight]:function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]}(t);var r},ac=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},oc=function(e){return[e.deltaX,e.deltaY]},lc=function(e){return e&&"current"in e?e.current:e},cc=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},dc=0,uc=[];function hc(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var fc,pc=(fc=function(t){var r=e.useRef([]),i=e.useRef([0,0]),s=e.useRef(),n=e.useState(dc++)[0],a=e.useState(Hl)[0],o=e.useRef(t);e.useEffect(function(){o.current=t},[t]),e.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(n));var e=function(e,t,r){if(r||2===arguments.length)for(var i,s=0,n=t.length;s<n;s++)!i&&s in t||(i||(i=Array.prototype.slice.call(t,0,s)),i[s]=t[s]);return e.concat(i||Array.prototype.slice.call(t))}([t.lockRef.current],(t.shards||[]).map(lc),!0).filter(Boolean);return e.forEach(function(e){return e.classList.add("allow-interactivity-".concat(n))}),function(){document.body.classList.remove("block-interactivity-".concat(n)),e.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(n))})}}},[t.inert,t.lockRef.current,t.shards]);var l=e.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!o.current.allowPinchZoom;var r,n=ac(e),a=i.current,l="deltaX"in e?e.deltaX:a[0]-n[0],c="deltaY"in e?e.deltaY:a[1]-n[1],d=e.target,u=Math.abs(l)>Math.abs(c)?"h":"v";if("touches"in e&&"h"===u&&"range"===d.type)return!1;var h=ic(u,d);if(!h)return!0;if(h?r=u:(r="v"===u?"h":"v",h=ic(u,d)),!h)return!1;if(!s.current&&"changedTouches"in e&&(l||c)&&(s.current=r),!r)return!0;var f=s.current||r;return function(e,t,r,i,s){var n=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),a=n*i,o=r.target,l=t.contains(o),c=!1,d=a>0,u=0,h=0;do{if(!o)break;var f=nc(e,o),p=f[0],m=f[1]-f[2]-n*p;(p||m)&&sc(e,o)&&(u+=m,h+=p);var g=o.parentNode;o=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!l&&o!==document.body||l&&(t.contains(o)||t===o));return d&&(Math.abs(u)<1||!s)?c=!0:d||!(Math.abs(h)<1)&&s||(c=!0),c}(f,t,e,"h"===f?l:c,!0)},[]),c=e.useCallback(function(e){var t=e;if(uc.length&&uc[uc.length-1]===a){var i="deltaY"in t?oc(t):ac(t),s=r.current.filter(function(e){return e.name===t.type&&(e.target===t.target||t.target===e.shadowParent)&&function(e,t){return e[0]===t[0]&&e[1]===t[1]}(e.delta,i)})[0];if(s&&s.should)t.cancelable&&t.preventDefault();else if(!s){var n=(o.current.shards||[]).map(lc).filter(Boolean).filter(function(e){return e.contains(t.target)});(n.length>0?l(t,n[0]):!o.current.noIsolation)&&t.cancelable&&t.preventDefault()}}},[]),d=e.useCallback(function(e,t,i,s){var n={name:e,delta:t,target:i,should:s,shadowParent:hc(i)};r.current.push(n),setTimeout(function(){r.current=r.current.filter(function(e){return e!==n})},1)},[]),u=e.useCallback(function(e){i.current=ac(e),s.current=void 0},[]),h=e.useCallback(function(e){d(e.type,oc(e),e.target,l(e,t.lockRef.current))},[]),f=e.useCallback(function(e){d(e.type,ac(e),e.target,l(e,t.lockRef.current))},[]);e.useEffect(function(){return uc.push(a),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",c,tc),document.addEventListener("touchmove",c,tc),document.addEventListener("touchstart",u,tc),function(){uc=uc.filter(function(e){return e!==a}),document.removeEventListener("wheel",c,tc),document.removeEventListener("touchmove",c,tc),document.removeEventListener("touchstart",u,tc)}},[]);var p=t.removeScrollBar,m=t.inert;return e.createElement(e.Fragment,null,m?e.createElement(a,{styles:cc(n)}):null,p?e.createElement(Zl,{noRelative:t.noRelative,gapMode:t.gapMode}):null)},Bl.useMedium(fc),$l),mc=e.forwardRef(function(t,r){return e.createElement(zl,S({},t,{ref:r,sideCar:pc}))});mc.classNames=zl.classNames;var gc=new WeakMap,vc=new WeakMap,yc={},bc=0,Ec=function(e){return e&&(e.host||Ec(e.parentNode))},wc=function(e,t,r,i){var s=function(e,t){return t.map(function(t){if(e.contains(t))return t;var r=Ec(t);return r&&e.contains(r)?r:(console.error("aria-hidden",t,"in not contained inside",e,". Doing nothing"),null)}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);yc[r]||(yc[r]=new WeakMap);var n=yc[r],a=[],o=new Set,l=new Set(s),c=function(e){e&&!o.has(e)&&(o.add(e),c(e.parentNode))};s.forEach(c);var d=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(o.has(e))d(e);else try{var t=e.getAttribute(i),s=null!==t&&"false"!==t,l=(gc.get(e)||0)+1,c=(n.get(e)||0)+1;gc.set(e,l),n.set(e,c),a.push(e),1===l&&s&&vc.set(e,!0),1===c&&e.setAttribute(r,"true"),s||e.setAttribute(i,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return d(t),o.clear(),bc++,function(){a.forEach(function(e){var t=gc.get(e)-1,s=n.get(e)-1;gc.set(e,t),n.set(e,s),t||(vc.has(e)||e.removeAttribute(i),vc.delete(e)),s||e.removeAttribute(r)}),--bc||(gc=new WeakMap,gc=new WeakMap,vc=new WeakMap,yc={})}},Sc=function(e,t,r){void 0===r&&(r="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),s=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return s?(i.push.apply(i,Array.from(s.querySelectorAll("[aria-live], script"))),wc(i,s,r,"aria-hidden")):function(){return null}},Tc="Dialog",[xc,Ac]=function(t,r=[]){let i=[];const s=()=>{const r=i.map(t=>e.createContext(t));return function(i){const s=i?.[t]||r;return e.useMemo(()=>({[`__scope${t}`]:{...i,[t]:s}}),[i,s])}};return s.scopeName=t,[function(r,s){const n=e.createContext(s),a=i.length;i=[...i,s];const o=r=>{const{scope:i,children:s,...o}=r,l=i?.[t]?.[a]||n,c=e.useMemo(()=>o,Object.values(o));return b(l.Provider,{value:c,children:s})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||n,c=e.useContext(l);if(c)return c;if(void 0!==s)return s;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},Ko(s,...r)]}(Tc),[kc,Lc]=xc(Tc),Ic=t=>{const{__scopeDialog:r,children:i,open:s,defaultOpen:n,onOpenChange:a,modal:o=!0}=t,l=e.useRef(null),c=e.useRef(null),[d,u]=el({prop:s,defaultProp:n??!1,onChange:a,caller:Tc});return b(kc,{scope:r,triggerRef:l,contentRef:c,contentId:Zo(),titleId:Zo(),descriptionId:Zo(),open:d,onOpenChange:u,onOpenToggle:e.useCallback(()=>u(e=>!e),[u]),modal:o,children:i})};Ic.displayName=Tc;var Rc="DialogTrigger";e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,s=Lc(Rc,r),n=Yo(t,s.triggerRef);return b(al.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":qc(s.open),...i,ref:n,onClick:Ho(e.onClick,s.onOpenToggle)})}).displayName=Rc;var Pc="DialogPortal",[Cc,Dc]=xc(Pc,{forceMount:void 0}),_c=t=>{const{__scopeDialog:r,forceMount:i,children:s,container:n}=t,a=Lc(Pc,r);return b(Cc,{scope:r,forceMount:i,children:e.Children.map(s,e=>b(Ll,{present:i||a.open,children:b(kl,{asChild:!0,container:n,children:e})}))})};_c.displayName=Pc;var Oc="DialogOverlay",Mc=e.forwardRef((e,t)=>{const r=Dc(Oc,e.__scopeDialog),{forceMount:i=r.forceMount,...s}=e,n=Lc(Oc,e.__scopeDialog);return n.modal?b(Ll,{present:i||n.open,children:b(Fc,{...s,ref:t})}):null});Mc.displayName=Oc;var Nc=rl("DialogOverlay.RemoveScroll"),Fc=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,s=Lc(Oc,r);return b(mc,{as:Nc,allowPinchZoom:!0,shards:[s.contentRef],children:b(al.div,{"data-state":qc(s.open),...i,ref:t,style:{pointerEvents:"auto",...i.style}})})}),$c="DialogContent",Bc=e.forwardRef((e,t)=>{const r=Dc($c,e.__scopeDialog),{forceMount:i=r.forceMount,...s}=e,n=Lc($c,e.__scopeDialog);return b(Ll,{present:i||n.open,children:n.modal?b(Uc,{...s,ref:t}):b(zc,{...s,ref:t})})});Bc.displayName=$c;var Uc=e.forwardRef((t,r)=>{const i=Lc($c,t.__scopeDialog),s=e.useRef(null),n=Yo(r,i.contentRef,s);return e.useEffect(()=>{const e=s.current;if(e)return Sc(e)},[]),b(Gc,{...t,ref:n,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ho(t.onCloseAutoFocus,e=>{e.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:Ho(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;(2===t.button||r)&&e.preventDefault()}),onFocusOutside:Ho(t.onFocusOutside,e=>e.preventDefault())})}),zc=e.forwardRef((t,r)=>{const i=Lc($c,t.__scopeDialog),s=e.useRef(!1),n=e.useRef(!1);return b(Gc,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),e.defaultPrevented||(s.current||i.triggerRef.current?.focus(),e.preventDefault()),s.current=!1,n.current=!1},onInteractOutside:e=>{t.onInteractOutside?.(e),e.defaultPrevented||(s.current=!0,"pointerdown"===e.detail.originalEvent.type&&(n.current=!0));const r=e.target,a=i.triggerRef.current?.contains(r);a&&e.preventDefault(),"focusin"===e.detail.originalEvent.type&&n.current&&e.preventDefault()}})}),Gc=e.forwardRef((t,r)=>{const{__scopeDialog:i,trapFocus:s,onOpenAutoFocus:n,onCloseAutoFocus:a,...o}=t,l=Lc($c,i),c=e.useRef(null),d=Yo(r,c);return e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Pl()),document.body.insertAdjacentElement("beforeend",e[1]??Pl()),Rl++,()=>{1===Rl&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Rl--}},[]),w(E,{children:[b(bl,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:n,onUnmountAutoFocus:a,children:b(fl,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":qc(l.open),...o,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),w(E,{children:[b(Jc,{titleId:l.titleId}),b(ed,{contentRef:c,descriptionId:l.descriptionId})]})]})}),jc="DialogTitle",Hc=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,s=Lc(jc,r);return b(al.h2,{id:s.titleId,...i,ref:t})});Hc.displayName=jc;var Vc="DialogDescription",Wc=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,s=Lc(Vc,r);return b(al.p,{id:s.descriptionId,...i,ref:t})});Wc.displayName=Vc;var Yc="DialogClose",Kc=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,s=Lc(Yc,r);return b(al.button,{type:"button",...i,ref:t,onClick:Ho(e.onClick,()=>s.onOpenChange(!1))})});function qc(e){return e?"open":"closed"}Kc.displayName=Yc;var Xc="DialogTitleWarning",[Qc,Zc]=function(t,r){const i=e.createContext(r),s=t=>{const{children:r,...s}=t,n=e.useMemo(()=>s,Object.values(s));return b(i.Provider,{value:n,children:r})};return s.displayName=t+"Provider",[s,function(s){const n=e.useContext(i);if(n)return n;if(void 0!==r)return r;throw new Error(`\`${s}\` must be used within \`${t}\``)}]}(Xc,{contentName:$c,titleName:jc,docsSlug:"dialog"}),Jc=({titleId:t})=>{const r=Zc(Xc),i=`\`${r.contentName}\` requires a \`${r.titleName}\` for the component to be accessible for screen reader users.\n\nIf you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return e.useEffect(()=>{if(t){document.getElementById(t)||console.error(i)}},[i,t]),null},ed=({contentRef:t,descriptionId:r})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Zc("DialogDescriptionWarning").contentName}}.`;return e.useEffect(()=>{const e=t.current?.getAttribute("aria-describedby");if(r&&e){document.getElementById(r)||console.warn(i)}},[i,t,r]),null},td=Ic,rd=_c,id=Mc,sd=Bc,nd=Hc,ad=Kc;function od(t){return e.createElement(td,Object.assign({"data-slot":"dialog"},t))}function ld(t){var r=T(t,[]);return e.createElement(rd,Object.assign({"data-slot":"dialog-portal"},r))}function cd(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(id,Object.assign({"data-slot":"dialog-overlay",className:St("fixed inset-0 z-50 bg-black/50",r)},i))}function dd(t){var{className:r,children:i,showCloseButton:s=!0,container:n}=t,a=T(t,["className","children","showCloseButton","container"]);return e.createElement(ld,{"data-slot":"dialog-portal",container:n},e.createElement(cd,null),e.createElement(sd,Object.assign({"data-slot":"dialog-content",style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",outline:"none"},className:St("fixed","z-50 grid w-full max-w-lg sm:mx-0 gap-4 p-6",r)},a),i,s&&e.createElement(ad,{"data-slot":"dialog-close",style:{right:"calc(var(--spacing) * 4)",top:"calc(var(--spacing) * 4)",outline:"none"},className:St("absolute right-4 top-4 rounded opacity-70 transition-opacity","hover:opacity-100 focus:outline-none","focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background","disabled:pointer-events-none"),"aria-label":"Close"},e.createElement(zr,{className:"h-4 w-4 pointer-events-none shrink-0",style:{height:"calc(var(--spacing) * 4)",width:"calc(var(--spacing) * 4)"}}))))}function ud(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({"data-slot":"dialog-header",className:St("flex flex-col gap-2 text-left",r)},i))}function hd(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(nd,Object.assign({"data-slot":"dialog-title",className:St("text-lg leading-none font-semibold",r)},i))}function fd({title:e,children:r,contentClassName:i,hideCloseButton:s=!1,portalContainer:n,description:a}){const{open:o,setOpen:l}=po();return t.createElement(od,{open:o,onOpenChange:l},t.createElement(dd,{container:n,className:i,showCloseButton:!s},e&&t.createElement(ud,null,t.createElement(hd,{style:{color:"#494949"}},e||""),t.createElement(Wc,{style:{color:"#5e5e5e",fontSize:"12.5px"}},a||"")),r))}const pd=({products:e,contentId:r})=>{const i=Po().width<430||qa.isMobile;return t.createElement("div",{onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),className:"grid gap-2 "+(i?"grid-cols-1":"grid-cols-2"),style:{fontSize:13}},e.map(i=>t.createElement(No,{key:i.productId,product:i,hideMoreBadge:!0,productLength:e.length,contentId:r})))},md=({widgetPlayerOption:e,setCollectionUuid:s,portalContainer:n})=>{const{PLAYER_BASE_URL:o}=gt(),{player:l}=e,[c,d]=a(null),{collection:h}=Io(),{isPreview:f}=Ua(),{onSlideChange:p,onCollectionClose:m}=Ro(c,d),g=r(null),v=r(new Set),y=u(e=>{f||h&&(v.current.has(e)||(v.current.add(e),ka({contentId:e,uuid:Lt(),type:wt.SHORTS,userId:h.userId,isFirstPlay:!It(e)}).catch(e=>console.error("Error joining shorts PV:",e))))},[f,h]);i(()=>{if(f)return;if(!h)return;if(g.current===h.colId)return;g.current=h.colId;const e=Lt();s(e),ka({contentId:h.colId,uuid:e,type:wt.COLLECTION,userId:h.userId,isFirstPlay:!Rt(h.colId)}).catch(e=>console.error("Error joining collection PV:",e))},[f,null==h?void 0:h.colId]);const{setOpen:b,open:E}=po();i(()=>{E||(c&&(m(),d(null)),w&&S(null))},[E]);const[w,S]=a();return t.createElement(t.Fragment,null,h&&t.createElement(zo,Object.assign({collection:h},e,{onThumbnailClick:e=>x(void 0,void 0,void 0,function*(){if(l===$e.POPUP){const t=Lt();if(d(Object.assign(Object.assign({},h.contents.find(t=>t.shortsId===e)),{uuid:t})),b(!0),f)return;try{yield ka({contentId:e,uuid:t,type:wt.SHORTS,userId:h.userId,isFirstPlay:!Rt(e)})}catch(e){console.error("Error joining shorts PV:",e)}}else{const t=(e=>{switch(e){case $e.HORIZONTAL:return Ue.HORIZONTAL;case $e.VERTICAL:return Ue.VERTICAL;case $e.GRID:return Ue.PRODUCTS;case $e.TABLET:return Ue.TABLET;default:return Ue.PLATFORM}})(l),r=null==h?void 0:h.contents.findIndex(t=>t.shortsId===e);let i="";r&&(i=(null==h?void 0:h.contents[r-1].shortsId)||"");const s=new URLSearchParams(Object.assign(Object.assign({},i&&{nextKey:i}),{layout:String(t)}));open(`${o}/collection/${h.colId}?${s.toString()}`)}}),onPreviewPlay:y,setSelectedProducts:S})),w&&t.createElement(fd,{portalContainer:n,title:"상품 목록",contentClassName:"bg-white rounded p-4 product-dialog-container",description:"상품 정보를 확인해 보세요"},t.createElement(pd,{products:w.productsInfo,contentId:w.shortsId})),h&&c&&t.createElement(fd,{portalContainer:n,hideCloseButton:!0,contentClassName:"w-full max-w-none p-0 mx-0"},t.createElement(Oo,{collection:h,initialShortsId:c.shortsId,onClosePlayer:()=>x(void 0,void 0,void 0,function*(){m(),b(!1)}),onSlideChange:p})))};const gd=e=>{const{collectionId:r,isPreview:s,priceText:n,memberOnly:a,container:o}=e,{setIsPreview:l,setPriceText:c,setMemberOnly:d,setIsMemberLoggedIn:u}=Ua(),{setCollection:h,setNextKey:f,collection:p}=Io();i(()=>{n&&c(n);const e=Boolean(s);e&&l(e),a&&(d(!0),u(Boolean(window.MEMBER_UID)))},[]),i(()=>{x(void 0,void 0,void 0,function*(){var e;const t=yield Ca({collectionId:r,size:10});if(!t)return;const{contents:i,count:s}=t;(null==i?void 0:i.length)&&f(null===(e=i.at(-1))||void 0===e?void 0:e.shortsId),h(Object.assign(Object.assign({},t),{count:s}))})},[r]);const m=function(e){var t,r,i,s,n,a,o,l,c,d,u,h;const f=null!==(t=e.iconForm)&&void 0!==t?t:Me.INSTA,p={collectionId:e.collectionId,iconForm:f,iconShape:null!==(r=e.iconShape)&&void 0!==r?r:Ne.MANY,iconSize:null!==(i=e.iconSize)&&void 0!==i?i:120,borderLine:null!==(s=e.borderLine)&&void 0!==s?s:Fe.DAY,exposeTitle:null===(n=e.exposeTitle)||void 0===n||n,player:null!==(a=e.player)&&void 0!==a?a:$e.POPUP,rounded:null===(o=e.rounded)||void 0===o||o,titlePosition:null!==(l=e.titlePosition)&&void 0!==l?l:Be.BOTTOM,exposeProductBanner:null!==(c=e.exposeProductBanner)&&void 0!==c&&c,exposeProductBadge:null!==(d=e.exposeProductBadge)&&void 0!==d&&d,priceText:e.priceText||"할인가",hoverPlay:null!==(u=e.hoverPlay)&&void 0!==u&&u,thumbnailAutoPlay:null!==(h=e.thumbnailAutoPlay)&&void 0!==h&&h};return f===Me.YOUTUBE?Object.assign(Object.assign({},p),{iconForm:Me.YOUTUBE,iconRatio:e.iconRatio||"9/16"}):Object.assign(Object.assign({},p),{iconForm:Me.INSTA})}(e),{containerRef:g}=function({collectionId:e,iconSize:r}){const{collection:i,setCollection:s,nextKey:n,setNextKey:a,isFetching:o,setIsFetching:l}=Io(),c=t.useRef(null),[d,u]=t.useState(0);return t.useEffect(()=>{if(!c.current)return;const e=new ResizeObserver(e=>{var t,r,i;const s=null!==(i=null===(r=null===(t=e[0])||void 0===t?void 0:t.contentRect)||void 0===r?void 0:r.width)&&void 0!==i?i:0;u(s)});return e.observe(c.current),()=>e.disconnect()},[]),t.useEffect(()=>{var e;if(!i||!i.contents)return;const t=Math.max(1,r+12),c=Math.ceil((d||0)/t)+4,u=null!==(e=i.count)&&void 0!==e?e:Number.MAX_SAFE_INTEGER,h=Math.min(u,c);if(i.contents.length>=h||o)return;let f=!1;return(()=>{x(this,void 0,void 0,function*(){var e,t,r,o,c;try{l(!0);let d=i,u=n||(null===(e=d.contents.at(-1))||void 0===e?void 0:e.shortsId)||void 0;const p=new Set(d.contents.map(e=>e.shortsId));for(;!f&&d.contents.length<h;){const e=Math.max(6,h-d.contents.length),i=yield Ca({collectionId:d.colId,nextKey:u,size:e});if(!i||!(null===(t=i.contents)||void 0===t?void 0:t.length))break;u=null!==(o=null===(r=i.contents.at(-1))||void 0===r?void 0:r.shortsId)&&void 0!==o?o:u;const n=i.contents.filter(e=>!p.has(e.shortsId));if(!n.length)break;if(n.forEach(e=>p.add(e.shortsId)),d=Object.assign(Object.assign({},d),{contents:[...d.contents,...n]}),s(d),a(u||""),d.contents.length>=(null!==(c=d.count)&&void 0!==c?c:Number.MAX_SAFE_INTEGER))break}}finally{l(!1)}})})(),()=>{f=!0}},[null==i?void 0:i.colId,null==i?void 0:i.count,null==i?void 0:i.contents.length,d,r,o,n,s,l,a]),{containerRef:c}}({collectionId:r,iconSize:m.iconSize});return t.createElement(Sr.div,null,t.createElement(fo,null),t.createElement("div",{ref:g},t.createElement(md,{widgetPlayerOption:m,setCollectionUuid:e=>{h(Object.assign(Object.assign({},p),{uuid:e}))},portalContainer:o})))},vd=e=>{const{container:r}=mo();return r?t.createElement(Lo,null,t.createElement(gd,Object.assign({},e,{container:r}))):null},yd=({portalContainer:e,aspectRatio:r})=>{var s;const{collection:n,setNextKey:o}=Io(),[l,c]=a(),{setOpen:d,open:u}=po();i(()=>{u||l&&c(null)},[u]);const h=(null!==(s=Po().width)&&void 0!==s?s:0)<430||qa.isMobile;return t.createElement(t.Fragment,null,t.createElement("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${h?2:5}, 1fr)`}},null==n?void 0:n.contents.map(e=>t.createElement("div",null,t.createElement("div",{className:"overflow-hidden",style:{borderRadius:"0.625rem",aspectRatio:null!=r?r:"9/16"}},t.createElement("video",{loop:!0,className:"w-full h-full object-cover",muted:!0,autoPlay:!0,playsInline:!0,src:xt(e.media.objectId),poster:Ct(e.thumbPath)})),t.createElement(Fo,{hideMoreBadge:!0,showMoreBtn:!0,products:e.productsInfo,contentId:e.shortsId,setSelectedProducts:c})))),l&&t.createElement(fd,{portalContainer:e,title:"상품 목록",contentClassName:"bg-white rounded p-4 product-dialog-container",description:"연결된 전체 상품 정보를 확인해 보세요"},t.createElement(pd,{products:l.productsInfo,contentId:l.shortsId})))},bd=({collectionId:e,aspectRatio:r,container:s,isPreview:n})=>{const{setCollection:a,setNextKey:o}=Io();return i(()=>{x(void 0,void 0,void 0,function*(){var t;const r=yield Ca({collectionId:e,size:-1});if(!r)return;const{contents:i,count:s}=r;(null==i?void 0:i.length)&&o(null===(t=i.at(-1))||void 0===t?void 0:t.shortsId),a(Object.assign(Object.assign({},r),{count:s}))})},[e]),t.createElement(Sr.div,null,t.createElement(fo,null),t.createElement(yd,{portalContainer:s,aspectRatio:r}))},Ed=e=>{const{container:r}=mo();return r?t.createElement(Lo,null,t.createElement(bd,Object.assign({},e,{container:r}))):null},wd=Ba(e=>({shortform:null,setShortform:t=>e({shortform:t})}));var Sd={exports:{}},Td={};function xd(e){var t,r,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(r=xd(e[t]))&&(i&&(i+=" "),i+=r);else for(t in e)e[t]&&(i&&(i+=" "),i+=t);return i}function Ad(){for(var e,t,r=0,i="";r<arguments.length;)(e=arguments[r++])&&(t=xd(e))&&(i&&(i+=" "),i+=t);return i}var kd,Ld=He(Object.freeze({__proto__:null,clsx:Ad,default:Ad})),Id={},Rd={};function Pd(){if(kd)return Rd;return kd=1,Object.defineProperty(Rd,"__esModule",{value:!0}),Rd.dontSetMe=function(e,t,r){if(e[t])return new Error("Invalid prop ".concat(t," passed to ").concat(r," - do not set this, set it on the child."))},Rd.findInArray=function(e,t){for(let r=0,i=e.length;r<i;r++)if(t.apply(t,[e[r],r,e]))return e[r]},Rd.int=function(e){return parseInt(e,10)},Rd.isFunction=function(e){return"function"==typeof e||"[object Function]"===Object.prototype.toString.call(e)},Rd.isNum=function(e){return"number"==typeof e&&!isNaN(e)},Rd}var Cd,Dd,_d={};function Od(){if(Dd)return Id;Dd=1,Object.defineProperty(Id,"__esModule",{value:!0}),Id.addClassName=a,Id.addEvent=function(e,t,r,i){if(!e)return;const s={capture:!0,...i};e.addEventListener?e.addEventListener(t,r,s):e.attachEvent?e.attachEvent("on"+t,r):e["on"+t]=r},Id.addUserSelectStyles=function(e){if(!e)return;let t=e.getElementById("react-draggable-style-el");t||(t=e.createElement("style"),t.type="text/css",t.id="react-draggable-style-el",t.innerHTML=".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n",t.innerHTML+=".react-draggable-transparent-selection *::selection {all: inherit;}\n",e.getElementsByTagName("head")[0].appendChild(t));e.body&&a(e.body,"react-draggable-transparent-selection")},Id.createCSSTransform=function(e,r){const i=n(e,r,"px");return{[(0,t.browserPrefixToKey)("transform",t.default)]:i}},Id.createSVGTransform=function(e,t){return n(e,t,"")},Id.getTouch=function(t,r){return t.targetTouches&&(0,e.findInArray)(t.targetTouches,e=>r===e.identifier)||t.changedTouches&&(0,e.findInArray)(t.changedTouches,e=>r===e.identifier)},Id.getTouchIdentifier=function(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier},Id.getTranslation=n,Id.innerHeight=function(t){let r=t.clientHeight;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r-=(0,e.int)(i.paddingTop),r-=(0,e.int)(i.paddingBottom),r},Id.innerWidth=function(t){let r=t.clientWidth;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r-=(0,e.int)(i.paddingLeft),r-=(0,e.int)(i.paddingRight),r},Id.matchesSelector=s,Id.matchesSelectorAndParentsTo=function(e,t,r){let i=e;do{if(s(i,t))return!0;if(i===r)return!1;i=i.parentNode}while(i);return!1},Id.offsetXYFromParent=function(e,t,r){const i=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect(),s=(e.clientX+t.scrollLeft-i.left)/r,n=(e.clientY+t.scrollTop-i.top)/r;return{x:s,y:n}},Id.outerHeight=function(t){let r=t.clientHeight;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r+=(0,e.int)(i.borderTopWidth),r+=(0,e.int)(i.borderBottomWidth),r},Id.outerWidth=function(t){let r=t.clientWidth;const i=t.ownerDocument.defaultView.getComputedStyle(t);return r+=(0,e.int)(i.borderLeftWidth),r+=(0,e.int)(i.borderRightWidth),r},Id.removeClassName=o,Id.removeEvent=function(e,t,r,i){if(!e)return;const s={capture:!0,...i};e.removeEventListener?e.removeEventListener(t,r,s):e.detachEvent?e.detachEvent("on"+t,r):e["on"+t]=null},Id.removeUserSelectStyles=function(e){if(!e)return;try{if(e.body&&o(e.body,"react-draggable-transparent-selection"),e.selection)e.selection.empty();else{const t=(e.defaultView||window).getSelection();t&&"Caret"!==t.type&&t.removeAllRanges()}}catch(e){}};var e=Pd(),t=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var i=r(t);if(i&&i.has(e))return i.get(e);var s={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var o=n?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(s,a,o):s[a]=e[a]}s.default=e,i&&i.set(e,s);return s}(function(){if(Cd)return _d;Cd=1,Object.defineProperty(_d,"__esModule",{value:!0}),_d.browserPrefixToKey=r,_d.browserPrefixToStyle=function(e,t){return t?"-".concat(t.toLowerCase(),"-").concat(e):e},_d.default=void 0,_d.getPrefix=t;const e=["Moz","Webkit","O","ms"];function t(){var t;let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"transform";if("undefined"==typeof window)return"";const s=null===(t=window.document)||void 0===t||null===(t=t.documentElement)||void 0===t?void 0:t.style;if(!s)return"";if(i in s)return"";for(let t=0;t<e.length;t++)if(r(i,e[t])in s)return e[t];return""}function r(e,t){return t?"".concat(t).concat(function(e){let t="",r=!0;for(let i=0;i<e.length;i++)r?(t+=e[i].toUpperCase(),r=!1):"-"===e[i]?r=!0:t+=e[i];return t}(e)):e}return _d.default=t(),_d}());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}let i="";function s(t,r){return i||(i=(0,e.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(r){return(0,e.isFunction)(t[r])})),!!(0,e.isFunction)(t[i])&&t[i](r)}function n(e,t,r){let{x:i,y:s}=e,n="translate(".concat(i).concat(r,",").concat(s).concat(r,")");if(t){const e="".concat("string"==typeof t.x?t.x:t.x+r),i="".concat("string"==typeof t.y?t.y:t.y+r);n="translate(".concat(e,", ").concat(i,")")+n}return n}function a(e,t){e.classList?e.classList.add(t):e.className.match(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)")))||(e.className+=" ".concat(t))}function o(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)"),"g"),"")}return Id}var Md,Nd={};function Fd(){if(Md)return Nd;Md=1,Object.defineProperty(Nd,"__esModule",{value:!0}),Nd.canDragX=function(e){return"both"===e.props.axis||"x"===e.props.axis},Nd.canDragY=function(e){return"both"===e.props.axis||"y"===e.props.axis},Nd.createCoreData=function(t,i,s){const n=!(0,e.isNum)(t.lastX),a=r(t);return n?{node:a,deltaX:0,deltaY:0,lastX:i,lastY:s,x:i,y:s}:{node:a,deltaX:i-t.lastX,deltaY:s-t.lastY,lastX:t.lastX,lastY:t.lastY,x:i,y:s}},Nd.createDraggableData=function(e,t){const r=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/r,y:e.state.y+t.deltaY/r,deltaX:t.deltaX/r,deltaY:t.deltaY/r,lastX:e.state.x,lastY:e.state.y}},Nd.getBoundPosition=function(i,s,n){if(!i.props.bounds)return[s,n];let{bounds:a}=i.props;a="string"==typeof a?a:function(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}(a);const o=r(i);if("string"==typeof a){const{ownerDocument:r}=o,i=r.defaultView;let s;if(s="parent"===a?o.parentNode:r.querySelector(a),!(s instanceof i.HTMLElement))throw new Error('Bounds selector "'+a+'" could not find an element.');const n=s,l=i.getComputedStyle(o),c=i.getComputedStyle(n);a={left:-o.offsetLeft+(0,e.int)(c.paddingLeft)+(0,e.int)(l.marginLeft),top:-o.offsetTop+(0,e.int)(c.paddingTop)+(0,e.int)(l.marginTop),right:(0,t.innerWidth)(n)-(0,t.outerWidth)(o)-o.offsetLeft+(0,e.int)(c.paddingRight)-(0,e.int)(l.marginRight),bottom:(0,t.innerHeight)(n)-(0,t.outerHeight)(o)-o.offsetTop+(0,e.int)(c.paddingBottom)-(0,e.int)(l.marginBottom)}}(0,e.isNum)(a.right)&&(s=Math.min(s,a.right));(0,e.isNum)(a.bottom)&&(n=Math.min(n,a.bottom));(0,e.isNum)(a.left)&&(s=Math.max(s,a.left));(0,e.isNum)(a.top)&&(n=Math.max(n,a.top));return[s,n]},Nd.getControlPosition=function(e,i,s){const n="number"==typeof i?(0,t.getTouch)(e,i):null;if("number"==typeof i&&!n)return null;const a=r(s),o=s.props.offsetParent||a.offsetParent||a.ownerDocument.body;return(0,t.offsetXYFromParent)(n||e,o,s.props.scale)},Nd.snapToGrid=function(e,t,r){const i=Math.round(t/e[0])*e[0],s=Math.round(r/e[1])*e[1];return[i,s]};var e=Pd(),t=Od();function r(e){const t=e.findDOMNode();if(!t)throw new Error("<DraggableCore>: Unmounted during event!");return t}return Nd}var $d,Bd,Ud,zd,Gd={},jd={};function Hd(){if($d)return jd;return $d=1,Object.defineProperty(jd,"__esModule",{value:!0}),jd.default=function(){},jd}function Vd(){if(Bd)return Gd;Bd=1,Object.defineProperty(Gd,"__esModule",{value:!0}),Gd.default=void 0;var e=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=c(t);if(r&&r.has(e))return r.get(e);var i={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if("default"!==n&&Object.prototype.hasOwnProperty.call(e,n)){var a=s?Object.getOwnPropertyDescriptor(e,n):null;a&&(a.get||a.set)?Object.defineProperty(i,n,a):i[n]=e[n]}i.default=e,r&&r.set(e,i);return i}(t),r=l(lr()),i=l(m),s=Od(),n=Fd(),a=Pd(),o=l(Hd());function l(e){return e&&e.__esModule?e:{default:e}}function c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(c=function(e){return e?r:t})(e)}function d(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const u={start:"touchstart",move:"touchmove",stop:"touchend"},h={start:"mousedown",move:"mousemove",stop:"mouseup"};let f=h,p=class extends e.Component{constructor(){super(...arguments),d(this,"dragging",!1),d(this,"lastX",NaN),d(this,"lastY",NaN),d(this,"touchIdentifier",null),d(this,"mounted",!1),d(this,"handleDragStart",e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&"number"==typeof e.button&&0!==e.button)return!1;const t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");const{ownerDocument:r}=t;if(this.props.disabled||!(e.target instanceof r.defaultView.Node)||this.props.handle&&!(0,s.matchesSelectorAndParentsTo)(e.target,this.props.handle,t)||this.props.cancel&&(0,s.matchesSelectorAndParentsTo)(e.target,this.props.cancel,t))return;"touchstart"===e.type&&e.preventDefault();const i=(0,s.getTouchIdentifier)(e);this.touchIdentifier=i;const a=(0,n.getControlPosition)(e,i,this);if(null==a)return;const{x:l,y:c}=a,d=(0,n.createCoreData)(this,l,c);(0,o.default)("DraggableCore: handleDragStart: %j",d),(0,o.default)("calling",this.props.onStart);!1!==this.props.onStart(e,d)&&!1!==this.mounted&&(this.props.enableUserSelectHack&&(0,s.addUserSelectStyles)(r),this.dragging=!0,this.lastX=l,this.lastY=c,(0,s.addEvent)(r,f.move,this.handleDrag),(0,s.addEvent)(r,f.stop,this.handleDragStop))}),d(this,"handleDrag",e=>{const t=(0,n.getControlPosition)(e,this.touchIdentifier,this);if(null==t)return;let{x:r,y:i}=t;if(Array.isArray(this.props.grid)){let e=r-this.lastX,t=i-this.lastY;if([e,t]=(0,n.snapToGrid)(this.props.grid,e,t),!e&&!t)return;r=this.lastX+e,i=this.lastY+t}const s=(0,n.createCoreData)(this,r,i);(0,o.default)("DraggableCore: handleDrag: %j",s);if(!1!==this.props.onDrag(e,s)&&!1!==this.mounted)this.lastX=r,this.lastY=i;else try{this.handleDragStop(new MouseEvent("mouseup"))}catch(e){const t=document.createEvent("MouseEvents");t.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(t)}}),d(this,"handleDragStop",e=>{if(!this.dragging)return;const t=(0,n.getControlPosition)(e,this.touchIdentifier,this);if(null==t)return;let{x:r,y:i}=t;if(Array.isArray(this.props.grid)){let e=r-this.lastX||0,t=i-this.lastY||0;[e,t]=(0,n.snapToGrid)(this.props.grid,e,t),r=this.lastX+e,i=this.lastY+t}const a=(0,n.createCoreData)(this,r,i);if(!1===this.props.onStop(e,a)||!1===this.mounted)return!1;const l=this.findDOMNode();l&&this.props.enableUserSelectHack&&(0,s.removeUserSelectStyles)(l.ownerDocument),(0,o.default)("DraggableCore: handleDragStop: %j",a),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,l&&((0,o.default)("DraggableCore: Removing handlers"),(0,s.removeEvent)(l.ownerDocument,f.move,this.handleDrag),(0,s.removeEvent)(l.ownerDocument,f.stop,this.handleDragStop))}),d(this,"onMouseDown",e=>(f=h,this.handleDragStart(e))),d(this,"onMouseUp",e=>(f=h,this.handleDragStop(e))),d(this,"onTouchStart",e=>(f=u,this.handleDragStart(e))),d(this,"onTouchEnd",e=>(f=u,this.handleDragStop(e)))}componentDidMount(){this.mounted=!0;const e=this.findDOMNode();e&&(0,s.addEvent)(e,u.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const e=this.findDOMNode();if(e){const{ownerDocument:t}=e;(0,s.removeEvent)(t,h.move,this.handleDrag),(0,s.removeEvent)(t,u.move,this.handleDrag),(0,s.removeEvent)(t,h.stop,this.handleDragStop),(0,s.removeEvent)(t,u.stop,this.handleDragStop),(0,s.removeEvent)(e,u.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,s.removeUserSelectStyles)(t)}}findDOMNode(){var e,t;return null!==(e=this.props)&&void 0!==e&&e.nodeRef?null===(t=this.props)||void 0===t||null===(t=t.nodeRef)||void 0===t?void 0:t.current:i.default.findDOMNode(this)}render(){return e.cloneElement(e.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};return Gd.default=p,d(p,"displayName","DraggableCore"),d(p,"propTypes",{allowAnyClick:r.default.bool,children:r.default.node.isRequired,disabled:r.default.bool,enableUserSelectHack:r.default.bool,offsetParent:function(e,t){if(e[t]&&1!==e[t].nodeType)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:r.default.arrayOf(r.default.number),handle:r.default.string,cancel:r.default.string,nodeRef:r.default.object,onStart:r.default.func,onDrag:r.default.func,onStop:r.default.func,onMouseDown:r.default.func,scale:r.default.number,className:a.dontSetMe,style:a.dontSetMe,transform:a.dontSetMe}),d(p,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1}),Gd}function Wd(){return Ud||(Ud=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return c.default}}),e.default=void 0;var r=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=h(t);if(r&&r.has(e))return r.get(e);var i={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if("default"!==n&&Object.prototype.hasOwnProperty.call(e,n)){var a=s?Object.getOwnPropertyDescriptor(e,n):null;a&&(a.get||a.set)?Object.defineProperty(i,n,a):i[n]=e[n]}i.default=e,r&&r.set(e,i);return i}(t),i=u(lr()),s=u(m),n=u(Ld),a=Od(),o=Fd(),l=Pd(),c=u(Vd()),d=u(Hd());function u(e){return e&&e.__esModule?e:{default:e}}function h(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(h=function(e){return e?r:t})(e)}function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},f.apply(this,arguments)}function p(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class g extends r.Component{static getDerivedStateFromProps(e,t){let{position:r}=e,{prevPropsPosition:i}=t;return!r||i&&r.x===i.x&&r.y===i.y?null:((0,d.default)("Draggable: getDerivedStateFromProps %j",{position:r,prevPropsPosition:i}),{x:r.x,y:r.y,prevPropsPosition:{...r}})}constructor(e){super(e),p(this,"onDragStart",(e,t)=>{(0,d.default)("Draggable: onDragStart: %j",t);if(!1===this.props.onStart(e,(0,o.createDraggableData)(this,t)))return!1;this.setState({dragging:!0,dragged:!0})}),p(this,"onDrag",(e,t)=>{if(!this.state.dragging)return!1;(0,d.default)("Draggable: onDrag: %j",t);const r=(0,o.createDraggableData)(this,t),i={x:r.x,y:r.y,slackX:0,slackY:0};if(this.props.bounds){const{x:e,y:t}=i;i.x+=this.state.slackX,i.y+=this.state.slackY;const[s,n]=(0,o.getBoundPosition)(this,i.x,i.y);i.x=s,i.y=n,i.slackX=this.state.slackX+(e-i.x),i.slackY=this.state.slackY+(t-i.y),r.x=i.x,r.y=i.y,r.deltaX=i.x-this.state.x,r.deltaY=i.y-this.state.y}if(!1===this.props.onDrag(e,r))return!1;this.setState(i)}),p(this,"onDragStop",(e,t)=>{if(!this.state.dragging)return!1;if(!1===this.props.onStop(e,(0,o.createDraggableData)(this,t)))return!1;(0,d.default)("Draggable: onDragStop: %j",t);const r={dragging:!1,slackX:0,slackY:0};if(Boolean(this.props.position)){const{x:e,y:t}=this.props.position;r.x=e,r.y=t}this.setState(r)}),this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},!e.position||e.onDrag||e.onStop||console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){void 0!==window.SVGElement&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.setState({dragging:!1})}findDOMNode(){var e,t;return null!==(e=null===(t=this.props)||void 0===t||null===(t=t.nodeRef)||void 0===t?void 0:t.current)&&void 0!==e?e:s.default.findDOMNode(this)}render(){const{axis:e,bounds:t,children:i,defaultPosition:s,defaultClassName:l,defaultClassNameDragging:d,defaultClassNameDragged:u,position:h,positionOffset:p,scale:m,...g}=this.props;let v={},y=null;const b=!Boolean(h)||this.state.dragging,E=h||s,w={x:(0,o.canDragX)(this)&&b?this.state.x:E.x,y:(0,o.canDragY)(this)&&b?this.state.y:E.y};this.state.isElementSVG?y=(0,a.createSVGTransform)(w,p):v=(0,a.createCSSTransform)(w,p);const S=(0,n.default)(i.props.className||"",l,{[d]:this.state.dragging,[u]:this.state.dragged});return r.createElement(c.default,f({},g,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),r.cloneElement(r.Children.only(i),{className:S,style:{...i.props.style,...v},transform:y}))}}e.default=g,p(g,"displayName","Draggable"),p(g,"propTypes",{...c.default.propTypes,axis:i.default.oneOf(["both","x","y","none"]),bounds:i.default.oneOfType([i.default.shape({left:i.default.number,right:i.default.number,top:i.default.number,bottom:i.default.number}),i.default.string,i.default.oneOf([!1])]),defaultClassName:i.default.string,defaultClassNameDragging:i.default.string,defaultClassNameDragged:i.default.string,defaultPosition:i.default.shape({x:i.default.number,y:i.default.number}),positionOffset:i.default.shape({x:i.default.oneOfType([i.default.number,i.default.string]),y:i.default.oneOfType([i.default.number,i.default.string])}),position:i.default.shape({x:i.default.number,y:i.default.number}),className:l.dontSetMe,style:l.dontSetMe,transform:l.dontSetMe}),p(g,"defaultProps",{...c.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})}(Td)),Td}var Yd=function(){if(zd)return Sd.exports;zd=1;const{default:e,DraggableCore:t}=Wd();return Sd.exports=e,Sd.exports.default=e,Sd.exports.DraggableCore=t,Sd.exports}(),Kd=je(Yd),qd=function(){return qd=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},qd.apply(this,arguments)},Xd={width:"100%",height:"10px",top:"0px",left:"0px",cursor:"row-resize"},Qd={width:"10px",height:"100%",top:"0px",left:"0px",cursor:"col-resize"},Zd={width:"20px",height:"20px",position:"absolute",zIndex:1},Jd={top:qd(qd({},Xd),{top:"-5px"}),right:qd(qd({},Qd),{left:void 0,right:"-5px"}),bottom:qd(qd({},Xd),{top:void 0,bottom:"-5px"}),left:qd(qd({},Qd),{left:"-5px"}),topRight:qd(qd({},Zd),{right:"-10px",top:"-10px",cursor:"ne-resize"}),bottomRight:qd(qd({},Zd),{right:"-10px",bottom:"-10px",cursor:"se-resize"}),bottomLeft:qd(qd({},Zd),{left:"-10px",bottom:"-10px",cursor:"sw-resize"}),topLeft:qd(qd({},Zd),{left:"-10px",top:"-10px",cursor:"nw-resize"})},eu=h(function(e){var t=e.onResizeStart,r=e.direction,i=e.children,s=e.replaceStyles,n=e.className,a=u(function(e){t(e,r)},[t,r]),o=u(function(e){t(e,r)},[t,r]),l=d(function(){return qd(qd({position:"absolute",userSelect:"none"},Jd[r]),null!=s?s:{})},[s,r]);return b("div",{className:n||void 0,style:l,onMouseDown:a,onTouchStart:o,children:i})}),tu=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),ru=function(){return ru=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},ru.apply(this,arguments)},iu={width:"auto",height:"auto"},su=function(e,t,r){return Math.max(Math.min(e,r),t)},nu=function(e,t,r){var i=Math.round(e/t);return i*t+r*(i-1)},au=function(e,t){return new RegExp(e,"i").test(t)},ou=function(e){return Boolean(e.touches&&e.touches.length)},lu=function(e,t,r){void 0===r&&(r=0);var i=t.reduce(function(r,i,s){return Math.abs(i-e)<Math.abs(t[r]-e)?s:r},0),s=Math.abs(t[i]-e);return 0===r||s<r?t[i]:e},cu=function(e){return"auto"===(e=e.toString())||e.endsWith("px")||e.endsWith("%")||e.endsWith("vh")||e.endsWith("vw")||e.endsWith("vmax")||e.endsWith("vmin")?e:"".concat(e,"px")},du=function(e,t,r,i){if(e&&"string"==typeof e){if(e.endsWith("px"))return Number(e.replace("px",""));if(e.endsWith("%"))return t*(Number(e.replace("%",""))/100);if(e.endsWith("vw"))return r*(Number(e.replace("vw",""))/100);if(e.endsWith("vh"))return i*(Number(e.replace("vh",""))/100)}return e},uu=["as","ref","style","className","grid","gridGap","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],hu="__resizable_base__",fu=function(e){function t(t){var r,i,s,n,a=e.call(this,t)||this;return a.ratio=1,a.resizable=null,a.parentLeft=0,a.parentTop=0,a.resizableLeft=0,a.resizableRight=0,a.resizableTop=0,a.resizableBottom=0,a.targetLeft=0,a.targetTop=0,a.delta={width:0,height:0},a.appendBase=function(){if(!a.resizable||!a.window)return null;var e=a.parentNode;if(!e)return null;var t=a.window.document.createElement("div");return t.style.width="100%",t.style.height="100%",t.style.position="absolute",t.style.transform="scale(0, 0)",t.style.left="0",t.style.flex="0 0 100%",t.classList?t.classList.add(hu):t.className+=hu,e.appendChild(t),t},a.removeBase=function(e){var t=a.parentNode;t&&t.removeChild(e)},a.state={isResizing:!1,width:null!==(i=null===(r=a.propsSize)||void 0===r?void 0:r.width)&&void 0!==i?i:"auto",height:null!==(n=null===(s=a.propsSize)||void 0===s?void 0:s.height)&&void 0!==n?n:"auto",direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},a.onResizeStart=a.onResizeStart.bind(a),a.onMouseMove=a.onMouseMove.bind(a),a.onMouseUp=a.onMouseUp.bind(a),a}return tu(t,e),Object.defineProperty(t.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"window",{get:function(){return this.resizable&&this.resizable.ownerDocument?this.resizable.ownerDocument.defaultView:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||iu},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){var e=0,t=0;if(this.resizable&&this.window){var r=this.resizable.offsetWidth,i=this.resizable.offsetHeight,s=this.resizable.style.position;"relative"!==s&&(this.resizable.style.position="relative"),e="auto"!==this.resizable.style.width?this.resizable.offsetWidth:r,t="auto"!==this.resizable.style.height?this.resizable.offsetHeight:i,this.resizable.style.position=s}return{width:e,height:t}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sizeStyle",{get:function(){var e=this,t=this.props.size,r=function(t){var r;if(void 0===e.state[t]||"auto"===e.state[t])return"auto";if(e.propsSize&&e.propsSize[t]&&(null===(r=e.propsSize[t])||void 0===r?void 0:r.toString().endsWith("%"))){if(e.state[t].toString().endsWith("%"))return e.state[t].toString();var i=e.getParentSize(),s=Number(e.state[t].toString().replace("px",""))/i[t]*100;return"".concat(s,"%")}return cu(e.state[t])};return{width:t&&void 0!==t.width&&!this.state.isResizing?cu(t.width):r("width"),height:t&&void 0!==t.height&&!this.state.isResizing?cu(t.height):r("height")}},enumerable:!1,configurable:!0}),t.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var e=this.appendBase();if(!e)return{width:0,height:0};var t=!1,r=this.parentNode.style.flexWrap;"wrap"!==r&&(t=!0,this.parentNode.style.flexWrap="wrap"),e.style.position="relative",e.style.minWidth="100%",e.style.minHeight="100%";var i={width:e.offsetWidth,height:e.offsetHeight};return t&&(this.parentNode.style.flexWrap=r),this.removeBase(e),i},t.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},t.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},t.prototype.componentDidMount=function(){if(this.resizable&&this.window){var e=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:"auto"!==e.flexBasis?e.flexBasis:void 0})}},t.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},t.prototype.createSizeForCssProperty=function(e,t){var r=this.propsSize&&this.propsSize[t];return"auto"!==this.state[t]||this.state.original[t]!==e||void 0!==r&&"auto"!==r?e:"auto"},t.prototype.calculateNewMaxFromBoundary=function(e,t){var r,i,s=this.props.boundsByDirection,n=this.state.direction,a=s&&au("left",n),o=s&&au("top",n);if("parent"===this.props.bounds){var l=this.parentNode;l&&(r=a?this.resizableRight-this.parentLeft:l.offsetWidth+(this.parentLeft-this.resizableLeft),i=o?this.resizableBottom-this.parentTop:l.offsetHeight+(this.parentTop-this.resizableTop))}else"window"===this.props.bounds?this.window&&(r=a?this.resizableRight:this.window.innerWidth-this.resizableLeft,i=o?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(r=a?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),i=o?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return r&&Number.isFinite(r)&&(e=e&&e<r?e:r),i&&Number.isFinite(i)&&(t=t&&t<i?t:i),{maxWidth:e,maxHeight:t}},t.prototype.calculateNewSizeFromDirection=function(e,t){var r,i=this.props.scale||1,s=(r=this.props.resizeRatio||1,Array.isArray(r)?r:[r,r]),n=s[0],a=s[1],o=this.state,l=o.direction,c=o.original,d=this.props,u=d.lockAspectRatio,h=d.lockAspectRatioExtraHeight,f=d.lockAspectRatioExtraWidth,p=c.width,m=c.height,g=h||0,v=f||0;return au("right",l)&&(p=c.width+(e-c.x)*n/i,u&&(m=(p-v)/this.ratio+g)),au("left",l)&&(p=c.width-(e-c.x)*n/i,u&&(m=(p-v)/this.ratio+g)),au("bottom",l)&&(m=c.height+(t-c.y)*a/i,u&&(p=(m-g)*this.ratio+v)),au("top",l)&&(m=c.height-(t-c.y)*a/i,u&&(p=(m-g)*this.ratio+v)),{newWidth:p,newHeight:m}},t.prototype.calculateNewSizeFromAspectRatio=function(e,t,r,i){var s=this.props,n=s.lockAspectRatio,a=s.lockAspectRatioExtraHeight,o=s.lockAspectRatioExtraWidth,l=void 0===i.width?10:i.width,c=void 0===r.width||r.width<0?e:r.width,d=void 0===i.height?10:i.height,u=void 0===r.height||r.height<0?t:r.height,h=a||0,f=o||0;if(n){var p=(d-h)*this.ratio+f,m=(u-h)*this.ratio+f,g=(l-f)/this.ratio+h,v=(c-f)/this.ratio+h,y=Math.max(l,p),b=Math.min(c,m),E=Math.max(d,g),w=Math.min(u,v);e=su(e,y,b),t=su(t,E,w)}else e=su(e,l,c),t=su(t,d,u);return{newWidth:e,newHeight:t}},t.prototype.setBoundingClientRect=function(){var e=1/(this.props.scale||1);if("parent"===this.props.bounds){var t=this.parentNode;if(t){var r=t.getBoundingClientRect();this.parentLeft=r.left*e,this.parentTop=r.top*e}}if(this.props.bounds&&"string"!=typeof this.props.bounds){var i=this.props.bounds.getBoundingClientRect();this.targetLeft=i.left*e,this.targetTop=i.top*e}if(this.resizable){var s=this.resizable.getBoundingClientRect(),n=s.left,a=s.top,o=s.right,l=s.bottom;this.resizableLeft=n*e,this.resizableRight=o*e,this.resizableTop=a*e,this.resizableBottom=l*e}},t.prototype.onResizeStart=function(e,t){if(this.resizable&&this.window){var r,i=0,s=0;if(e.nativeEvent&&function(e){return Boolean((e.clientX||0===e.clientX)&&(e.clientY||0===e.clientY))}(e.nativeEvent)?(i=e.nativeEvent.clientX,s=e.nativeEvent.clientY):e.nativeEvent&&ou(e.nativeEvent)&&(i=e.nativeEvent.touches[0].clientX,s=e.nativeEvent.touches[0].clientY),this.props.onResizeStart)if(this.resizable)if(!1===this.props.onResizeStart(e,t,this.resizable))return;this.props.size&&(void 0!==this.props.size.height&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),void 0!==this.props.size.width&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio="number"==typeof this.props.lockAspectRatio?this.props.lockAspectRatio:this.size.width/this.size.height;var n=this.window.getComputedStyle(this.resizable);if("auto"!==n.flexBasis){var a=this.parentNode;if(a){var o=this.window.getComputedStyle(a).flexDirection;this.flexDir=o.startsWith("row")?"row":"column",r=n.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var l={original:{x:i,y:s,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:ru(ru({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(e.target).cursor||"auto"}),direction:t,flexBasis:r};this.setState(l)}},t.prototype.onMouseMove=function(e){var t=this;if(this.state.isResizing&&this.resizable&&this.window){if(this.window.TouchEvent&&ou(e))try{e.preventDefault(),e.stopPropagation()}catch(e){}var r=this.props,i=r.maxWidth,s=r.maxHeight,n=r.minWidth,a=r.minHeight,o=ou(e)?e.touches[0].clientX:e.clientX,l=ou(e)?e.touches[0].clientY:e.clientY,c=this.state,d=c.direction,u=c.original,h=c.width,f=c.height,p=this.getParentSize(),m=function(e,t,r,i,s,n,a){return i=du(i,e.width,t,r),s=du(s,e.height,t,r),n=du(n,e.width,t,r),a=du(a,e.height,t,r),{maxWidth:void 0===i?void 0:Number(i),maxHeight:void 0===s?void 0:Number(s),minWidth:void 0===n?void 0:Number(n),minHeight:void 0===a?void 0:Number(a)}}(p,this.window.innerWidth,this.window.innerHeight,i,s,n,a);i=m.maxWidth,s=m.maxHeight,n=m.minWidth,a=m.minHeight;var g=this.calculateNewSizeFromDirection(o,l),y=g.newHeight,b=g.newWidth,E=this.calculateNewMaxFromBoundary(i,s);this.props.snap&&this.props.snap.x&&(b=lu(b,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(y=lu(y,this.props.snap.y,this.props.snapGap));var w=this.calculateNewSizeFromAspectRatio(b,y,{width:E.maxWidth,height:E.maxHeight},{width:n,height:a});if(b=w.newWidth,y=w.newHeight,this.props.grid){var S=nu(b,this.props.grid[0],this.props.gridGap?this.props.gridGap[0]:0),T=nu(y,this.props.grid[1],this.props.gridGap?this.props.gridGap[1]:0),x=this.props.snapGap||0;b=0===x||Math.abs(S-b)<=x?S:b,y=0===x||Math.abs(T-y)<=x?T:y}var A={width:b-u.width,height:y-u.height};if(this.delta=A,h&&"string"==typeof h)if(h.endsWith("%")){var k=b/p.width*100;b="".concat(k,"%")}else if(h.endsWith("vw")){var L=b/this.window.innerWidth*100;b="".concat(L,"vw")}else if(h.endsWith("vh")){var I=b/this.window.innerHeight*100;b="".concat(I,"vh")}if(f&&"string"==typeof f)if(f.endsWith("%")){k=y/p.height*100;y="".concat(k,"%")}else if(f.endsWith("vw")){L=y/this.window.innerWidth*100;y="".concat(L,"vw")}else if(f.endsWith("vh")){I=y/this.window.innerHeight*100;y="".concat(I,"vh")}var R={width:this.createSizeForCssProperty(b,"width"),height:this.createSizeForCssProperty(y,"height")};"row"===this.flexDir?R.flexBasis=R.width:"column"===this.flexDir&&(R.flexBasis=R.height);var P=this.state.width!==R.width,C=this.state.height!==R.height,D=this.state.flexBasis!==R.flexBasis,_=P||C||D;_&&v(function(){t.setState(R)}),this.props.onResize&&_&&this.props.onResize(e,d,this.resizable,A)}},t.prototype.onMouseUp=function(e){var t,r,i=this.state,s=i.isResizing,n=i.direction;i.original,s&&this.resizable&&(this.props.onResizeStop&&this.props.onResizeStop(e,n,this.resizable,this.delta),this.props.size&&this.setState({width:null!==(t=this.props.size.width)&&void 0!==t?t:"auto",height:null!==(r=this.props.size.height)&&void 0!==r?r:"auto"}),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:ru(ru({},this.state.backgroundStyle),{cursor:"auto"})}))},t.prototype.updateSize=function(e){var t,r;this.setState({width:null!==(t=e.width)&&void 0!==t?t:"auto",height:null!==(r=e.height)&&void 0!==r?r:"auto"})},t.prototype.renderResizer=function(){var e=this,t=this.props,r=t.enable,i=t.handleStyles,s=t.handleClasses,n=t.handleWrapperStyle,a=t.handleWrapperClass,o=t.handleComponent;if(!r)return null;var l=Object.keys(r).map(function(t){return!1!==r[t]?b(eu,{direction:t,onResizeStart:e.onResizeStart,replaceStyles:i&&i[t],className:s&&s[t],children:o&&o[t]?o[t]:null},t):null});return b("div",{className:a,style:n,children:l})},t.prototype.render=function(){var e=this,t=Object.keys(this.props).reduce(function(t,r){return-1!==uu.indexOf(r)||(t[r]=e.props[r]),t},{}),r=ru(ru(ru({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(r.flexBasis=this.state.flexBasis);var i=this.props.as||"div";return w(i,ru({style:r,className:this.props.className},t,{ref:function(t){t&&(e.resizable=t)},children:[this.state.isResizing&&b("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer()]}))},t.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],gridGap:[0,0],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},t}(f),pu=function(e,t){return pu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},pu(e,t)};var mu=function(){return mu=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},mu.apply(this,arguments)};var gu={width:"auto",height:"auto",display:"inline-block",position:"absolute",top:0,left:0},vu=function(e){function t(t){var r=e.call(this,t)||this;return r.resizingPosition={x:0,y:0},r.offsetFromParent={left:0,top:0},r.resizableElement={current:null},r.originalPosition={x:0,y:0},r.state={resizing:!1,bounds:{top:0,right:0,bottom:0,left:0},maxWidth:t.maxWidth,maxHeight:t.maxHeight},r.onResizeStart=r.onResizeStart.bind(r),r.onResize=r.onResize.bind(r),r.onResizeStop=r.onResizeStop.bind(r),r.onDragStart=r.onDragStart.bind(r),r.onDrag=r.onDrag.bind(r),r.onDragStop=r.onDragStop.bind(r),r.getMaxSizesFromProps=r.getMaxSizesFromProps.bind(r),r}return function(e,t){function r(){this.constructor=e}pu(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.prototype.componentDidMount=function(){this.updateOffsetFromParent();var e=this.offsetFromParent,t=e.left,r=e.top,i=this.getDraggablePosition(),s=i.x,n=i.y;this.draggable.setState({x:s-t,y:n-r}),this.forceUpdate()},t.prototype.getDraggablePosition=function(){var e=this.draggable.state;return{x:e.x,y:e.y}},t.prototype.getParent=function(){return this.resizable&&this.resizable.parentNode},t.prototype.getParentSize=function(){return this.resizable.getParentSize()},t.prototype.getMaxSizesFromProps=function(){return{maxWidth:void 0===this.props.maxWidth?Number.MAX_SAFE_INTEGER:this.props.maxWidth,maxHeight:void 0===this.props.maxHeight?Number.MAX_SAFE_INTEGER:this.props.maxHeight}},t.prototype.getSelfElement=function(){return this.resizable&&this.resizable.resizable},t.prototype.getOffsetHeight=function(e){var t=this.props.scale;switch(this.props.bounds){case"window":return window.innerHeight/t;case"body":return document.body.offsetHeight/t;default:return e.offsetHeight}},t.prototype.getOffsetWidth=function(e){var t=this.props.scale;switch(this.props.bounds){case"window":return window.innerWidth/t;case"body":return document.body.offsetWidth/t;default:return e.offsetWidth}},t.prototype.onDragStart=function(e,t){this.props.onDragStart&&this.props.onDragStart(e,t);var r=this.getDraggablePosition();if(this.originalPosition=r,this.props.bounds){var i,s=this.getParent(),n=this.props.scale;if("parent"===this.props.bounds)i=s;else{if("body"===this.props.bounds){var a=s.getBoundingClientRect(),o=a.left,l=a.top,c=document.body.getBoundingClientRect(),d=-(o-s.offsetLeft*n-c.left)/n,u=-(l-s.offsetTop*n-c.top)/n,h=(document.body.offsetWidth-this.resizable.size.width*n)/n+d,f=(document.body.offsetHeight-this.resizable.size.height*n)/n+u;return this.setState({bounds:{top:u,right:h,bottom:f,left:d}})}if("window"===this.props.bounds){if(!this.resizable)return;var p=s.getBoundingClientRect(),m=p.left,g=p.top,v=-(m-s.offsetLeft*n)/n,y=-(g-s.offsetTop*n)/n;h=(window.innerWidth-this.resizable.size.width*n)/n+v,f=(window.innerHeight-this.resizable.size.height*n)/n+y;return this.setState({bounds:{top:y,right:h,bottom:f,left:v}})}"string"==typeof this.props.bounds?i=document.querySelector(this.props.bounds):this.props.bounds instanceof HTMLElement&&(i=this.props.bounds)}if(i instanceof HTMLElement&&s instanceof HTMLElement){var b=i.getBoundingClientRect(),E=b.left,w=b.top,S=s.getBoundingClientRect(),T=(E-S.left)/n,x=w-S.top;if(this.resizable){this.updateOffsetFromParent();var A=this.offsetFromParent;this.setState({bounds:{top:x-A.top,right:T+(i.offsetWidth-this.resizable.size.width)-A.left/n,bottom:x+(i.offsetHeight-this.resizable.size.height)-A.top,left:T-A.left/n}})}}}},t.prototype.onDrag=function(e,t){if(this.props.onDrag){var r=this.offsetFromParent,i=r.left,s=r.top;return this.props.dragAxis&&"both"!==this.props.dragAxis?"x"===this.props.dragAxis?this.props.onDrag(e,mu(mu({},t),{x:t.x+i,y:this.originalPosition.y+s,deltaY:0})):"y"===this.props.dragAxis?this.props.onDrag(e,mu(mu({},t),{x:this.originalPosition.x+i,y:t.y+s,deltaX:0})):void 0:this.props.onDrag(e,mu(mu({},t),{x:t.x+i,y:t.y+s}))}},t.prototype.onDragStop=function(e,t){if(this.props.onDragStop){var r=this.offsetFromParent,i=r.left,s=r.top;return this.props.dragAxis&&"both"!==this.props.dragAxis?"x"===this.props.dragAxis?this.props.onDragStop(e,mu(mu({},t),{x:t.x+i,y:this.originalPosition.y+s,deltaY:0})):"y"===this.props.dragAxis?this.props.onDragStop(e,mu(mu({},t),{x:this.originalPosition.x+i,y:t.y+s,deltaX:0})):void 0:this.props.onDragStop(e,mu(mu({},t),{x:t.x+i,y:t.y+s}))}},t.prototype.onResizeStart=function(e,t,r){e.stopPropagation(),this.setState({resizing:!0});var i=this.props.scale,s=this.offsetFromParent,n=this.getDraggablePosition();if(this.resizingPosition={x:n.x+s.left,y:n.y+s.top},this.originalPosition=n,this.props.bounds){var a=this.getParent(),o=void 0;"parent"===this.props.bounds?o=a:"body"===this.props.bounds?o=document.body:"window"===this.props.bounds?o=window:"string"==typeof this.props.bounds?o=document.querySelector(this.props.bounds):this.props.bounds instanceof HTMLElement&&(o=this.props.bounds);var l=this.getSelfElement();if(l instanceof Element&&(o instanceof HTMLElement||o===window)&&a instanceof HTMLElement){var c=this.getMaxSizesFromProps(),d=c.maxWidth,u=c.maxHeight,h=this.getParentSize();if(d&&"string"==typeof d)if(d.endsWith("%")){var f=Number(d.replace("%",""))/100;d=h.width*f}else d.endsWith("px")&&(d=Number(d.replace("px","")));if(u&&"string"==typeof u)if(u.endsWith("%")){f=Number(u.replace("%",""))/100;u=h.height*f}else u.endsWith("px")&&(u=Number(u.replace("px","")));var p=l.getBoundingClientRect(),m=p.left,g=p.top,v="window"===this.props.bounds?{left:0,top:0}:o.getBoundingClientRect(),y=v.left,b=v.top,E=this.getOffsetWidth(o),w=this.getOffsetHeight(o),S=t.toLowerCase().endsWith("left"),T=t.toLowerCase().endsWith("right"),x=t.startsWith("top"),A=t.startsWith("bottom");if((S||x)&&this.resizable){var k=(m-y)/i+this.resizable.size.width;this.setState({maxWidth:k>Number(d)?d:k})}if(T||this.props.lockAspectRatio&&!S&&!x){k=E+(y-m)/i;this.setState({maxWidth:k>Number(d)?d:k})}if((x||S)&&this.resizable){k=(g-b)/i+this.resizable.size.height;this.setState({maxHeight:k>Number(u)?u:k})}if(A||this.props.lockAspectRatio&&!x&&!S){k=w+(b-g)/i;this.setState({maxHeight:k>Number(u)?u:k})}}}else this.setState({maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight});this.props.onResizeStart&&this.props.onResizeStart(e,t,r)},t.prototype.onResize=function(e,t,r,i){var s=this,n={x:this.originalPosition.x,y:this.originalPosition.y},a=-i.width,o=-i.height;["top","left","topLeft","bottomLeft","topRight"].includes(t)&&("bottomLeft"===t?n.x+=a:("topRight"===t||(n.x+=a),n.y+=o));var l=this.draggable.state;n.x===l.x&&n.y===l.y||v(function(){s.draggable.setState(n)}),this.updateOffsetFromParent();var c=this.offsetFromParent,d=this.getDraggablePosition().x+c.left,u=this.getDraggablePosition().y+c.top;this.resizingPosition={x:d,y:u},this.props.onResize&&this.props.onResize(e,t,r,i,{x:d,y:u})},t.prototype.onResizeStop=function(e,t,r,i){this.setState({resizing:!1});var s=this.getMaxSizesFromProps(),n=s.maxWidth,a=s.maxHeight;this.setState({maxWidth:n,maxHeight:a}),this.props.onResizeStop&&this.props.onResizeStop(e,t,r,i,this.resizingPosition)},t.prototype.updateSize=function(e){this.resizable&&this.resizable.updateSize({width:e.width,height:e.height})},t.prototype.updatePosition=function(e){this.draggable.setState(e)},t.prototype.updateOffsetFromParent=function(){var e=this.props.scale,t=this.getParent(),r=this.getSelfElement();if(!t||null===r)return{top:0,left:0};var i=t.getBoundingClientRect(),s=i.left,n=i.top,a=r.getBoundingClientRect(),o=this.getDraggablePosition(),l=t.scrollLeft,c=t.scrollTop;this.offsetFromParent={left:a.left-s+l-o.x*e,top:a.top-n+c-o.y*e}},t.prototype.render=function(){var e=this,t=this.props,r=t.disableDragging,i=t.style,s=t.dragHandleClassName,n=t.position,a=t.onMouseDown,o=t.onMouseUp,c=t.dragAxis,d=t.dragGrid,u=t.bounds,h=t.enableUserSelectHack,f=t.cancel,p=t.children;t.onResizeStart,t.onResize,t.onResizeStop,t.onDragStart,t.onDrag,t.onDragStop;var m=t.resizeHandleStyles,g=t.resizeHandleClasses,v=t.resizeHandleComponent,y=t.enableResizing,b=t.resizeGrid,E=t.resizeHandleWrapperClass,w=t.resizeHandleWrapperStyle,S=t.scale,T=t.allowAnyClick,x=t.dragPositionOffset,A=function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(i=Object.getOwnPropertySymbols(e);s<i.length;s++)t.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(e,i[s])&&(r[i[s]]=e[i[s]])}return r}(t,["disableDragging","style","dragHandleClassName","position","onMouseDown","onMouseUp","dragAxis","dragGrid","bounds","enableUserSelectHack","cancel","children","onResizeStart","onResize","onResizeStop","onDragStart","onDrag","onDragStop","resizeHandleStyles","resizeHandleClasses","resizeHandleComponent","enableResizing","resizeGrid","resizeHandleWrapperClass","resizeHandleWrapperStyle","scale","allowAnyClick","dragPositionOffset"]),k=this.props.default?mu({},this.props.default):void 0;delete A.default;var L,I=r||s?{cursor:"auto"}:{cursor:"move"},R=mu(mu(mu({},gu),I),i),P=this.offsetFromParent,C=P.left,D=P.top;n&&(L={x:n.x-C,y:n.y-D});var _,O=this.state.resizing?void 0:L,M=this.state.resizing?"both":c;return l(Kd,{ref:function(t){t&&(e.draggable=t)},handle:s?".".concat(s):void 0,defaultPosition:k,onMouseDown:a,onMouseUp:o,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop,axis:M,disabled:r,grid:d,bounds:u?this.state.bounds:void 0,position:O,enableUserSelectHack:h,cancel:f,scale:S,allowAnyClick:T,nodeRef:this.resizableElement,positionOffset:x},l(fu,mu({},A,{ref:function(t){t&&(e.resizable=t,e.resizableElement.current=t.resizable)},defaultSize:k,size:this.props.size,enable:"boolean"==typeof y?(_=y,{bottom:_,bottomLeft:_,bottomRight:_,left:_,right:_,top:_,topLeft:_,topRight:_}):y,onResizeStart:this.onResizeStart,onResize:this.onResize,onResizeStop:this.onResizeStop,style:R,minWidth:this.props.minWidth,minHeight:this.props.minHeight,maxWidth:this.state.resizing?this.state.maxWidth:this.props.maxWidth,maxHeight:this.state.resizing?this.state.maxHeight:this.props.maxHeight,grid:b,handleWrapperClass:E,handleWrapperStyle:w,lockAspectRatio:this.props.lockAspectRatio,lockAspectRatioExtraWidth:this.props.lockAspectRatioExtraWidth,lockAspectRatioExtraHeight:this.props.lockAspectRatioExtraHeight,handleStyles:m,handleClasses:g,handleComponent:v,scale:this.props.scale}),p))},t.defaultProps={maxWidth:Number.MAX_SAFE_INTEGER,maxHeight:Number.MAX_SAFE_INTEGER,scale:1,onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},onDragStart:function(){},onDrag:function(){},onDragStop:function(){}},t}(f);const yu=({shortform:e,setClose:r})=>{const[s,n]=t.useState(!0),[o,l]=a(!0),[c,d]=a(!1),u=t.useRef(null),h=()=>{u.current&&(window.clearTimeout(u.current),u.current=null)},f=(e=1500)=>{h(),u.current=window.setTimeout(()=>d(!1),e)};return i(()=>()=>h(),[]),t.createElement("div",{className:"relative w-full h-full",onClick:()=>{d(!0),f(2e3)},onMouseLeave:()=>f(800),onMouseEnter:()=>c&&f(1500)},t.createElement("div",{className:"absolute inset-0 bg-black",style:{zIndex:1,opacity:c?.4:0,transition:"opacity 300ms ease",pointerEvents:c?"auto":"none"}}),t.createElement("div",{className:"absolute inset-0",style:{zIndex:2,opacity:c?1:0,transition:"opacity 300ms ease",pointerEvents:c?"auto":"none"}},t.createElement("div",{className:"absolute text-white flex gap-2",style:{zIndex:3,top:8,right:8}},t.createElement("button",{className:"cursor-pointer",onClick:e=>{e.stopPropagation(),n(e=>!e)},"aria-label":s?"Unmute":"Mute"},s?t.createElement(Ur,{size:20}):t.createElement(Br,{size:20})),t.createElement("button",{className:"cursor-pointer",onClick:e=>{null==e||e.stopPropagation(),r()},"aria-label":"Close"},t.createElement(zr,{size:20}))),t.createElement("div",{className:"absolute inset-0 flex items-center justify-center",style:{pointerEvents:"none"}},t.createElement("button",{onClick:e=>{null==e||e.stopPropagation(),l(e=>!e)},"aria-label":o?"Pause":"Play",className:"cursor-pointer text-white p-2 ",style:{pointerEvents:"auto"}},o?t.createElement(Nr,{size:28}):t.createElement(Fr,{size:28})))),t.createElement(Ot,{shortform:e,mute:s,play:o}))},bu=({shortsId:e,type:r})=>{const{shortform:s}=wd(),[n,o]=a(!1),{playtime:l}=Ao(),c=()=>{if(!s)return;o(!0);const{shortsId:e,uuid:t,userId:r}=s;La({contentId:e,uuid:t,type:wt.SHORTS,playtime:l,userId:r})};(({shorform:e,playtime:t})=>{i(()=>{if(!e)return;const{shortsId:t,shortsUuid:r,userId:i}=e;ka({contentId:t,uuid:r,type:wt.SHORTS,userId:i,isFirstPlay:!Rt(t)})},[]);const r=To();i(()=>{if(!e||r)return;const{shortsId:i,uuid:s,userId:n}=e;La({contentId:i,uuid:s,type:wt.SHORTS,playtime:t,userId:n})},[r])})({shorform:s,playtime:l});const{w:d,h:u,left:h,top:f}=(()=>{const e=window.visualViewport;return e?{w:e.width,h:e.height,left:e.offsetLeft,top:e.offsetTop}:{w:window.innerWidth,h:window.innerHeight,left:0,top:0}})();return s&&!n&&t.createElement(vu,{minWidth:240,lockAspectRatio:9/16,style:{zIndex:99999},default:{width:240,height:427,x:h+d-240-50,y:f+u-427-50},bounds:"window"},"shopping"===r&&s.productsInfo.length>0?t.createElement(to,{shortForm:s,handleClose:c}):t.createElement(yu,{shortform:s,setClose:c}))},Eu=({shortsId:e,type:r,isPreview:s})=>{const{setShortform:n,shortform:a}=wd();return i(()=>{if(!e)return;e&&x(void 0,void 0,void 0,function*(){const t=yield Da(e,s);t&&n(Object.assign(Object.assign({},t),{uuid:Lt()}))})},[e]),a?t.createElement(Sr.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:99999}},t.createElement(fo,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(bu,{shortsId:e,type:r}))):null},wu=t.createContext(null),Su=({children:e})=>{const r=t.useRef(null);return r.current||(r.current=Ma(e=>({liveWidget:null,setLiveWidget:t=>e({liveWidget:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})}))),t.createElement(wu.Provider,{value:r.current},e)};function Tu(e){const r=t.useContext(wu);if(!r)throw new Error("Missing LiveWidgetProvider");return Fa(r,e)}var xu;!function(e){e[e.READY=1]="READY",e[e.STREAMING=2]="STREAMING",e[e.PAUSED=3]="PAUSED"}(xu||(xu={}));const Au=({opacity:e=.4,className:r})=>{const i=Math.max(0,Math.min(1,e));return t.createElement("div",{"aria-hidden":!0,role:"presentation",className:`absolute inset-0 pointer-events-none ${null!=r?r:""}`,style:{backgroundColor:`rgba(0,0,0,${i})`,borderRadius:"inherit"}})},ku=({content:e})=>{const{PLAYER_BASE_URL:r}=gt();return t.createElement("iframe",{src:`${r}/live/${e.eventId}`,className:"w-full h-full block",style:{border:0,display:"block"},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade"})},Lu=(e,r)=>{const[i,s]=t.useState({}),[n,a]=t.useState({primary:20,secondary:12});return t.useLayoutEffect(()=>{s({})},[e]),t.useEffect(()=>{const t=r.current;if(!t)return;const i=()=>{const r=t.getBoundingClientRect(),i=Math.max(0,Math.floor(r.width)),n=Math.max(0,Math.floor(r.height)),[o,l]=e.includes("/")?e.split("/").map(e=>parseFloat(e)):[1,1],c=l/o;let d,u;i>0&&n>0?(d=i,u=Math.round(d*c),u>n&&(u=n,d=Math.round(u/c)),s({width:d,height:u})):s({});const h="number"==typeof d?d:i,f=Math.max(16,Math.round(.075*h)),p=Math.max(11,Math.round(.042*h));a({primary:f,secondary:p})};if("undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>i());return e.observe(t),()=>e.disconnect()}{const e=()=>i();return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}},[e]),{fontSize:n,boxSize:i}},Iu=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:s})=>{var n,o;const{leftTime:l}=(e=>{const{start:t}=e,r=qe().tz("Asia/Seoul").unix(),[i,s]=a(t-r>0?t-r:0);return xo(()=>{s(i<=0?0:e=>e-1)},1e3),{leftTime:i}})(e),c=null===(o=null===(n=null==e?void 0:e.designInfo)||void 0===n?void 0:n.thumbPath)||void 0===o?void 0:o.preview,d=t.useRef(null),{boxSize:u,fontSize:h}=Lu(r,d),{PLAYER_BASE_URL:f}=gt(),p=Math.floor(Date.now()/1e3),m="number"==typeof e.end&&e.end>0&&e.end<p;return t.createElement("div",{className:"w-full h-full flex items-center justify-center",ref:d},t.createElement("div",{className:"relative rounded overflow-hidden",style:{width:u.width?`${u.width}px`:"100%",height:u.height?`${u.height}px`:"100%",borderRadius:`${null!=s?s:10}px`,backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",aspectRatio:u.height?void 0:r,backgroundImage:c?`url(${Ct(c)})`:void 0,backgroundColor:c?void 0:"black"}},1===e.openStatus?t.createElement(t.Fragment,null,t.createElement(ku,{content:e}),t.createElement("a",{href:`${f}/live/${e.eventId}`,target:"_blank",rel:"noopener noreferrer","aria-label":`${e.eventName} 바로가기`,style:{position:"absolute",inset:0,zIndex:30,display:"block",textDecoration:"none",cursor:"pointer",background:"transparent"}})):m?t.createElement(t.Fragment,null,t.createElement(Au,null),t.createElement("div",{className:"text-white flex flex-col items-center justify-center absolute inset-0",style:{zIndex:10,gap:"12px",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",cursor:i,pointerEvents:"none"}},t.createElement("p",{style:{fontSize:`${h.primary}px`,fontWeight:700}},"다시보기"),t.createElement("p",{style:{fontSize:`${h.secondary}px`}},"라이브가 종료되었습니다"))):t.createElement(t.Fragment,null,t.createElement(Au,null),t.createElement("div",{className:"text-white flex flex-col items-center justify-center absolute inset-0",style:{zIndex:10,gap:"20px",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",cursor:i,pointerEvents:"none"}},t.createElement("p",{style:{fontSize:`${h.primary}px`}},((e,t)=>{if(e>86400)return qe.unix(t).tz("Asia/Seoul").format("M월 D일 A h시 mm분");const r=qe.duration(e,"seconds");return`${r.hours().toString().padStart(2,"0")}:${r.minutes().toString().padStart(2,"0")}:${r.seconds().toString().padStart(2,"0")}`})(l,e.start)),t.createElement("p",{style:{fontSize:`${h.secondary}px`}},"곧 라이브가 시작됩니다!")))))},Ru=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},Pu=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=Cu},Cu=Number.MAX_SAFE_INTEGER||9007199254740991;let Du=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),_u=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),Ou=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.STALL_RESOLVED="hlsStallResolved",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({});var Mu="manifest",Nu="level",Fu="audioTrack",$u="subtitleTrack",Bu="main",Uu="audio",zu="subtitle";class Gu{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){const r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class ju{constructor(e,t,r,i=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Gu(e),this.fast_=new Gu(t),this.defaultTTFB_=i,this.ttfb_=new Gu(e)}update(e,t){const{slow_:r,fast_:i,ttfb_:s}=this;r.halfLife!==e&&(this.slow_=new Gu(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new Gu(t,i.getEstimate(),i.getTotalWeight())),s.halfLife!==e&&(this.ttfb_=new Gu(e,s.getEstimate(),s.getTotalWeight()))}sample(e,t){const r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)}sampleTTFB(e){const t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function Hu(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Vu(){return Vu=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},Vu.apply(null,arguments)}function Wu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function Yu(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Wu(Object(r),!0).forEach(function(t){Hu(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Wu(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class Ku{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const r=`[${e}]:`;this.trace=qu,this.debug=t.debug.bind(null,r),this.log=t.log.bind(null,r),this.warn=t.warn.bind(null,r),this.info=t.info.bind(null,r),this.error=t.error.bind(null,r)}}const qu=function(){},Xu={trace:qu,debug:qu,log:qu,warn:qu,info:qu,error:qu};function Qu(){return Vu({},Xu)}function Zu(e,t,r){return t[e]?t[e].bind(t):function(e,t){const r=self.console[e];return r?r.bind(self.console,`${t?"["+t+"] ":""}[${e}] >`):qu}(e,r)}const Ju=Qu();const eh=Ju;function th(e=!0){if("undefined"==typeof self)return;return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function rh(e,t){const r=Object.keys(e),i=Object.keys(t),s=r.length,n=i.length;return!s||!n||s===n&&!r.some(e=>-1===i.indexOf(e))}function ih(e,t=!1){if("undefined"!=typeof TextDecoder){const r=new TextDecoder("utf-8").decode(e);if(t){const e=r.indexOf("\0");return-1!==e?r.substring(0,e):r}return r.replace(/\0/g,"")}const r=e.length;let i,s,n,a="",o=0;for(;o<r;){if(i=e[o++],0===i&&t)return a;if(0!==i&&3!==i)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:s=e[o++],a+=String.fromCharCode((31&i)<<6|63&s);break;case 14:s=e[o++],n=e[o++],a+=String.fromCharCode((15&i)<<12|(63&s)<<6|63&n)}}return a}function sh(e){let t="";for(let r=0;r<e.length;r++){let i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t}function nh(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function ah(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var oh,lh={exports:{}};var ch,dh,uh,hh,fh,ph=oh?lh.exports:(oh=1,ch=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,dh=/^(?=([^\/?#]*))\1([^]*)$/,uh=/(?:\/|^)\.(?=\/)/g,hh=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,lh.exports=fh={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=fh.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=fh.normalizePath(i.path),fh.buildURLFromParts(i)}var s=fh.parseURL(t);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return r.alwaysNormalize?(s.path=fh.normalizePath(s.path),fh.buildURLFromParts(s)):t;var n=fh.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");if(!n.netLoc&&n.path&&"/"!==n.path[0]){var a=dh.exec(n.path);n.netLoc=a[1],n.path=a[2]}n.netLoc&&!n.path&&(n.path="/");var o={scheme:n.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(o.netLoc=n.netLoc,"/"!==s.path[0]))if(s.path){var l=n.path,c=l.substring(0,l.lastIndexOf("/")+1)+s.path;o.path=fh.normalizePath(c)}else o.path=n.path,s.params||(o.params=n.params,s.query||(o.query=n.query));return null===o.path&&(o.path=r.alwaysNormalize?fh.normalizePath(s.path):s.path),fh.buildURLFromParts(o)},parseURL:function(e){var t=ch.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(uh,"");e.length!==(e=e.replace(hh,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}});class mh{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var gh="audio",vh="video",yh="audiovideo";class bh{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof e&&(e={url:e}),this.base=e,function(e,t){const r=Th(e,t);r&&(r.enumerable=!0,Object.defineProperty(e,t,r))}(this,"stats")}setByteRange(e,t){const r=e.split("@",2);let i;i=1===r.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(r[1]),this._byteRange=[i,parseInt(r[0])+i]}get baseurl(){return this.base.url}get byteRange(){return null===this._byteRange?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return null===this._streams&&(this._streams={[gh]:null,[vh]:null,[yh]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return null!==this._stats}get hasStreams(){return null!==this._streams}get stats(){return null===this._stats&&(this._stats=new mh),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=ph.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[gh]=null,e[vh]=null,e[yh]=null}}function Eh(e){return"initSegment"!==e.sn}class wh extends bh{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if(Ru(e)&&Ru(t))return t-e}return null}get bitrate(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){var e;const{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(null==(e=this._decryptdata)||!e.keyId){const e=Object.keys(t);if(1===e.length){const r=this._decryptdata=t[e[0]]||null;r&&(this._decryptdata=r.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;const e=Ru(this.duration)?this.duration:0;return this.programDateTime+1e3*e}get encrypted(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t;const e=Object.keys(this.levelkeys),r=e.length;if(r>1||1===r&&null!=(t=this.levelkeys[e[0]])&&t.encrypted)return!0}return!1}get programDateTime(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){Ru(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}get ref(){return Eh(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){const t=this.levelkeys;if(t){var r;const i=t[e];!i||null!=(r=this._decryptdata)&&r.keyId||(this._decryptdata=i.getDecryptData(this.sn,t))}}abortRequests(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}setElementaryStreamInfo(e,t,r,i,s,n=!1){const{elementaryStreams:a}=this,o=a[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,s)):a[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:s,partial:n}}}class Sh extends bh{constructor(e,t,r,i,s){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=i;const n=e.enumeratedString("BYTERANGE");n&&this.setByteRange(n,s),s&&(this.fragOffset=s.fragOffset+s.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}function Th(e,t){const r=Object.getPrototypeOf(e);if(r){const e=Object.getOwnPropertyDescriptor(r,t);return e||Th(r,t)}}const xh=Math.pow(2,32)-1,Ah=[].push,kh={video:1,audio:2,id3:3,text:4};function Lh(e){return String.fromCharCode.apply(null,e)}function Ih(e,t){const r=e[t]<<8|e[t+1];return r<0?65536+r:r}function Rh(e,t){const r=Ch(e,t);return r<0?4294967296+r:r}function Ph(e,t){let r=Rh(e,t);return r*=Math.pow(2,32),r+=Rh(e,t+4),r}function Ch(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function Dh(e,t){const r=[];if(!t.length)return r;const i=e.byteLength;for(let s=0;s<i;){const n=Rh(e,s),a=n>1?s+n:i;if(Lh(e.subarray(s+4,s+8))===t[0])if(1===t.length)r.push(e.subarray(s+8,a));else{const i=Dh(e.subarray(s+8,a),t.slice(1));i.length&&Ah.apply(r,i)}s=a}return r}function _h(e){const t=[],r=e[0];let i=8;const s=Rh(e,i);i+=4;let n=0,a=0;0===r?(n=Rh(e,i),a=Rh(e,i+4),i+=8):(n=Ph(e,i),a=Ph(e,i+8),i+=16),i+=2;let o=e.length+a;const l=Ih(e,i);i+=2;for(let r=0;r<l;r++){let r=i;const n=Rh(e,r);r+=4;const a=2147483647&n;if(1===(2147483648&n)>>>31)return eh.warn("SIDX has hierarchical references (not supported)"),null;const l=Rh(e,r);r+=4,t.push({referenceSize:a,subsegmentDuration:l,info:{duration:l/s,start:o,end:o+a-1}}),o+=a,r+=4,i=r}return{earliestPresentationTime:n,timescale:s,version:r,referencesCount:l,references:t}}function Oh(e){const t=[],r=Dh(e,["moov","trak"]);for(let e=0;e<r.length;e++){const i=r[e],s=Dh(i,["tkhd"])[0];if(s){let e=s[0];const r=Rh(s,0===e?12:20),n=Dh(i,["mdia","mdhd"])[0];if(n){e=n[0];const s=Rh(n,0===e?12:20),a=Dh(i,["mdia","hdlr"])[0];if(a){const e=Lh(a.subarray(8,12)),n={soun:gh,vide:vh}[e],o=Mh(Dh(i,["mdia","minf","stbl","stsd"])[0]);n?(t[r]={timescale:s,type:n,stsd:o},t[n]=Yu({timescale:s,id:r},o)):t[r]={timescale:s,type:e,stsd:o}}}}}return Dh(e,["moov","mvex","trex"]).forEach(e=>{const r=Rh(e,4),i=t[r];i&&(i.default={duration:Rh(e,12),flags:Rh(e,20)})}),t}function Mh(e){const t=e.subarray(8),r=t.subarray(86),i=Lh(t.subarray(4,8));let s,n=i;const a="enca"===i||"encv"===i;if(a){const e=Dh(t,[i])[0];Dh(e.subarray("enca"===i?28:78),["sinf"]).forEach(e=>{const t=Dh(e,["schm"])[0];if(t){const r=Lh(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=Dh(e,["frma"])[0];t&&(n=Lh(t))}}})}const o=n;switch(n){case"avc1":case"avc2":case"avc3":case"avc4":{const e=Dh(r,["avcC"])[0];e&&e.length>3&&(n+="."+$h(e[1])+$h(e[2])+$h(e[3]),s=Nh("avc1"===o?"dva1":"dvav",r));break}case"mp4a":{const e=Dh(t,[i])[0],r=Dh(e.subarray(28),["esds"])[0];if(r&&r.length>7){let e=4;if(3!==r[e++])break;e=Fh(r,e),e+=2;const t=r[e++];if(128&t&&(e+=2),64&t&&(e+=r[e++]),4!==r[e++])break;e=Fh(r,e);const i=r[e++];if(64!==i)break;if(n+="."+$h(i),e+=12,5!==r[e++])break;e=Fh(r,e);const s=r[e++];let a=(248&s)>>3;31===a&&(a+=1+((7&s)<<3)+((224&r[e])>>5)),n+="."+a}break}case"hvc1":case"hev1":{const e=Dh(r,["hvcC"])[0];if(e&&e.length>12){const t=e[1],r=["","A","B","C"][t>>6],i=31&t,s=Rh(e,2),a=(32&t)>>5?"H":"L",o=e[12],l=e.subarray(6,12);n+="."+r+i,n+="."+function(e){let t=0;for(let r=0;r<32;r++)t|=(e>>r&1)<<31-r;return t>>>0}(s).toString(16).toUpperCase(),n+="."+a+o;let c="";for(let e=l.length;e--;){const t=l[e];if(t||c){c="."+t.toString(16).toUpperCase()+c}}n+=c}s=Nh("hev1"==o?"dvhe":"dvh1",r);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":n=Nh(n,r)||n;break;case"vp09":{const e=Dh(r,["vpcC"])[0];if(e&&e.length>6){const t=e[4],r=e[5],i=e[6]>>4&15;n+="."+Bh(t)+"."+Bh(r)+"."+Bh(i)}break}case"av01":{const e=Dh(r,["av1C"])[0];if(e&&e.length>2){const t=e[1]>>>5,i=31&e[1],a=e[2]>>>7?"H":"M",o=(64&e[2])>>6,l=(32&e[2])>>5,c=2===t&&o?l?12:10:o?10:8,d=(16&e[2])>>4,u=(8&e[2])>>3,h=(4&e[2])>>2,f=3&e[2],p=1,m=1,g=1,v=0;n+="."+t+"."+Bh(i)+a+"."+Bh(c)+"."+d+"."+u+h+f+"."+Bh(p)+"."+Bh(m)+"."+Bh(g)+"."+v,s=Nh("dav1",r)}break}}return{codec:n,encrypted:a,supplemental:s}}function Nh(e,t){const r=Dh(t,["dvvC"]),i=r.length?r[0]:Dh(t,["dvcC"])[0];if(i){const t=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return e+"."+Bh(t)+"."+Bh(r)}}function Fh(e,t){const r=t+5;for(;128&e[t++]&&t<r;);return t}function $h(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function Bh(e){return(e<10?"0":"")+e}function Uh(e,t){Dh(e,["moov","trak"]).forEach(e=>{const r=Dh(e,["mdia","minf","stbl","stsd"])[0];if(!r)return;const i=r.subarray(8);let s=Dh(i,["enca"]);const n=s.length>0;n||(s=Dh(i,["encv"])),s.forEach(e=>{Dh(n?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{const r=zh(e);r&&t(r,n)})})})}function zh(e){const t=Dh(e,["schm"])[0];if(t){const r=Lh(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=Dh(e,["schi","tenc"])[0];if(t)return t}}}function Gh(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function jh(e,t){const r=[],i=t.samples,s=t.timescale,n=t.id;let a=!1;return Dh(i,["moof"]).map(o=>{const l=o.byteOffset-8;Dh(o,["traf"]).map(o=>{const c=Dh(o,["tfdt"]).map(e=>{const t=e[0];let r=Rh(e,4);return 1===t&&(r*=Math.pow(2,32),r+=Rh(e,8)),r/s})[0];return void 0!==c&&(e=c),Dh(o,["tfhd"]).map(c=>{const d=Rh(c,4),u=16777215&Rh(c,0);let h=0;const f=!!(16&u);let p=0;const m=!!(32&u);let g=8;d===n&&(!!(1&u)&&(g+=8),!!(2&u)&&(g+=4),!!(8&u)&&(h=Rh(c,g),g+=4),f&&(p=Rh(c,g),g+=4),m&&(g+=4),"video"===t.type&&(a=Hh(t.codec)),Dh(o,["trun"]).map(n=>{const o=n[0],c=16777215&Rh(n,0),d=!!(1&c);let u=0;const f=!!(4&c),m=!!(256&c);let g=0;const v=!!(512&c);let y=0;const b=!!(1024&c),E=!!(2048&c);let w=0;const S=Rh(n,4);let T=8;d&&(u=Rh(n,T),T+=4),f&&(T+=4);let x=u+l;for(let l=0;l<S;l++){if(m?(g=Rh(n,T),T+=4):g=h,v?(y=Rh(n,T),T+=4):y=p,b&&(T+=4),E&&(w=0===o?Rh(n,T):Ch(n,T),T+=4),t.type===vh){let t=0;for(;t<y;){const n=Rh(i,x);if(x+=4,Vh(a,i[x])){Wh(i.subarray(x,x+n),a?2:1,e+w/s,r)}x+=n,t+=n+4}}e+=g/s}}))})})}),r}function Hh(e){if(!e)return!1;const t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function Vh(e,t){if(e){const e=t>>1&63;return 39===e||40===e}return 6===(31&t)}function Wh(e,t,r,i){const s=Yh(e);let n=0;n+=t;let a=0,o=0,l=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;l=s[n++],a+=l}while(255===l);o=0;do{if(n>=s.length)break;l=s[n++],o+=l}while(255===l);const e=s.length-n;let t=n;if(o<e)n+=o;else if(o>e){eh.error(`Malformed SEI payload. ${o} is too small, only ${e} bytes left to parse.`);break}if(4===a){if(181===s[t++]){const e=Ih(s,t);if(t+=2,49===e){const e=Rh(s,t);if(t+=4,1195456820===e){const e=s[t++];if(3===e){const n=s[t++],o=64&n,l=o?2+3*(31&n):0,c=new Uint8Array(l);if(o){c[0]=n;for(let e=1;e<l;e++)c[e]=s[t++]}i.push({type:e,payloadType:a,pts:r,bytes:c})}}}}}else if(5===a&&o>16){const e=[];for(let r=0;r<16;r++){const i=s[t++].toString(16);e.push(1==i.length?"0"+i:i),3!==r&&5!==r&&7!==r&&9!==r||e.push("-")}const n=o-16,l=new Uint8Array(n);for(let e=0;e<n;e++)l[e]=s[t++];i.push({payloadType:a,pts:r,uuid:e.join(""),userData:ih(l),userDataBytes:l})}}}function Yh(e){const t=e.byteLength,r=[];let i=1;for(;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;const s=t-r.length,n=new Uint8Array(s);let a=0;for(i=0;i<s;a++,i++)a===r[0]&&(a++,r.shift()),n[i]=e[a];return n}function Kh(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");let i,s,n;i=0,s=new Uint8Array,n=new Uint8Array;const a=new Uint8Array(4);return r.byteLength>0&&new DataView(a.buffer).setUint32(0,r.byteLength,!1),function(e,...t){const r=t.length;let i=8,s=r;for(;s--;)i+=t[s].byteLength;const n=new Uint8Array(i);for(n[0]=i>>24&255,n[1]=i>>16&255,n[2]=i>>8&255,n[3]=255&i,n.set(e,4),s=0,i=8;s<r;s++)n.set(t[s],i),i+=t[s].byteLength;return n}([112,115,115,104],new Uint8Array([0,0,0,0]),e,n,s,a,r)}function qh(e){const t=e.getUint32(0),r=e.byteOffset,i=e.byteLength;if(i<t)return{offset:r,size:i};if(1886614376!==e.getUint32(4))return{offset:r,size:t};const s=e.getUint32(8)>>>24;if(0!==s&&1!==s)return{offset:r,size:t};const n=e.buffer,a=sh(new Uint8Array(n,r+12,16));let o=null,l=null,c=0;if(0===s)c=28;else{const s=e.getUint32(28);if(!s||i<32+16*s)return{offset:r,size:t};o=[];for(let e=0;e<s;e++)o.push(new Uint8Array(n,r+32+16*e,16));c=32+16*s}if(!c)return{offset:r,size:t};const d=e.getUint32(c);return t-32<d?{offset:r,size:t}:(l=new Uint8Array(n,r+c+4,d),{version:s,systemId:a,kids:o,data:l,offset:r,size:t})}const Xh=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),Qh={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Zh(e,t){const r=Qh[t];return!!r&&!!r[e.slice(0,4)]}function Jh(e,t,r=!0){return!e.split(",").some(e=>!ef(e,t,r))}function ef(e,t,r=!0){var i;const s=th(r);return null!=(i=null==s?void 0:s.isTypeSupported(tf(e,t)))&&i}function tf(e,t){return`${t}/mp4;codecs=${e}`}function rf(e){if(e){const t=e.substring(0,4);return Qh.video[t]}return 2}function sf(e){const t=Xh();return e.split(",").reduce((e,r)=>{const i=t&&Hh(r)?9:Qh.video[r];return i?(2*i+e)/(e?3:2):(Qh.audio[r]+e)/(e?2:1)},0)}const nf={};const af=/flac|opus|mp4a\.40\.34/i;function of(e,t=!0){return e.replace(af,e=>function(e,t=!0){if(nf[e])return nf[e];const r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e];for(let s=0;s<r.length;s++){var i;if(ef(r[s],"audio",t))return nf[e]=r[s],r[s];if("mp3"===r[s]&&null!=(i=th(t))&&i.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t))}function lf(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(cf(e,"audio")||cf(e,"video")))return e;if(t){const r=t.split(",");if(r.length>1){if(e)for(let t=r.length;t--;)if(r[t].substring(0,4)===e.substring(0,4))return r[t];return r[0]}}return t||e}function cf(e,t){return Zh(e,t)&&ef(e,t)}function df(e){if(e.startsWith("av01.")){const t=e.split("."),r=["0","111","01","01","01","0"];for(let e=t.length;e>4&&e<10;e++)t[e]=r[e-4];return t.join(".")}return e}function uf(e){const t=th(e)||{isTypeSupported:()=>!1};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}function hf(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const ff={supported:!1,smooth:!1,powerEfficient:!1},pf={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function mf(e,t){return{supported:!1,configurations:t,decodingInfoResults:[ff],error:e}}function gf(e,t,r,i,s,n){const a=e.videoCodec,o=e.audioCodec?e.audioGroups:null,l=null==n?void 0:n.audioCodec,c=null==n?void 0:n.channels,d=c?parseInt(c):l?1/0:2;let u=null;if(null!=o&&o.length)try{u=1===o.length&&o[0]?t.groups[o[0]].channels:o.reduce((e,r)=>{if(r){const i=t.groups[r];if(!i)throw new Error(`Audio track group ${r} not found`);Object.keys(i.channels).forEach(t=>{e[t]=(e[t]||0)+i.channels[t]})}return e},{2:0})}catch(e){return!0}return void 0!==a&&(a.split(",").some(e=>Hh(e))||e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(i,30)||"SDR"!==e.videoRange&&e.videoRange!==r||e.bitrate>Math.max(s,8e6))||!!u&&Ru(d)&&Object.keys(u).some(e=>parseInt(e)>d)}function vf(e,t,r,i={}){const s=e.videoCodec;if(!s&&!e.audioCodec||!r)return Promise.resolve(pf);const n=[],a=function(e){var t;const r=null==(t=e.videoCodec)?void 0:t.split(","),i=bf(e),s=e.width||640,n=e.height||480,a=e.frameRate||30,o=e.videoRange.toLowerCase();return r?r.map(e=>{const t={contentType:tf(df(e),"video"),width:s,height:n,bitrate:i,framerate:a};return"sdr"!==o&&(t.transferFunction=o),t}):[]}(e),o=a.length,l=function(e,t,r){var i;const s=null==(i=e.audioCodec)?void 0:i.split(","),n=bf(e);if(s&&e.audioGroups)return e.audioGroups.reduce((e,i)=>{var a;const o=i?null==(a=t.groups[i])?void 0:a.tracks:null;return o?o.reduce((e,t)=>{if(t.groupId===i){const i=parseFloat(t.channels||"");s.forEach(t=>{const s={contentType:tf(t,"audio"),bitrate:r?yf(t,n):n};i&&(s.channels=""+i),e.push(s)})}return e},e):e},[]);return[]}(e,t,o>0),c=l.length;for(let e=o||1*c||1;e--;){const t={type:"media-source"};if(o&&(t.video=a[e%o]),c){t.audio=l[e%c];const r=t.audio.bitrate;t.video&&r&&(t.video.bitrate-=r)}n.push(t)}if(s){const e=navigator.userAgent;if(s.split(",").some(e=>Hh(e))&&Xh())return Promise.resolve(mf(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${e})`),n))}return Promise.all(n.map(e=>{const t=function(e){let t="";const{audio:r,video:i}=e;if(i){t+=`${hf(i.contentType)}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(r){t+=`${i?"_":""}${hf(r.contentType)}_c${r.channels}`}return t}(e);return i[t]||(i[t]=r.decodingInfo(e))})).then(e=>({supported:!e.some(e=>!e.supported),configurations:n,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:n,decodingInfoResults:[],error:e}))}function yf(e,t){if(t<=1)return 1;let r=128e3;return"ec-3"===e?r=768e3:"ac-3"===e&&(r=64e4),Math.min(t/2,r)}function bf(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}const Ef=["NONE","TYPE-0","TYPE-1",null];const wf=["SDR","PQ","HLG"];var Sf="",Tf="YES",xf="v2";function Af(e){const{canSkipUntil:t,canSkipDateRanges:r,age:i}=e;return t&&i<t/2?r?xf:Tf:Sf}class kf{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){const t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class Lf{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(e=>!!e).map(e=>e.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const r=null==(t=e.supplemental)?void 0:t.videoCodec;r&&r!==e.videoCodec&&(this.codecSet+=`,${r.substring(0,4)}`)}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return If(this._audioGroups,e)}hasSubtitleGroup(e){return If(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t)if("audio"===e){let e=this._audioGroups;e||(e=this._audioGroups=[]),-1===e.indexOf(t)&&e.push(t)}else if("text"===e){let e=this._subtitleGroups;e||(e=this._subtitleGroups=[]),-1===e.indexOf(t)&&e.push(t)}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return null==(e=this.audioGroups)?void 0:e[0]}get textGroupId(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}addFallback(){}}function If(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function Rf(e,t){let r=!1,i=[];if(e&&(r="SDR"!==e,i=[e]),t){i=t.allowedVideoRanges||wf.slice(0);const e="SDR"!==i.join("")&&!t.videoCodec;r=void 0!==t.preferHDR?t.preferHDR:e&&function(){if("function"==typeof matchMedia){const e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}(),r||(i=["SDR"])}return{preferHDR:r,allowedVideoRanges:i}}const Pf=(e,t)=>JSON.stringify(e,(e=>{const t=new WeakSet;return(r,i)=>{if(e&&(i=e(r,i)),"object"==typeof i&&null!==i){if(t.has(i))return;t.add(i)}return i}})(t));function Cf(e,t){eh.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function Df(e){return e.reduce((e,t)=>{let r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);const i=t.channels||"2";return r.channels[i]=(r.channels[i]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function _f(e){if(!e)return e;const{lang:t,assocLang:r,characteristics:i,channels:s,audioCodec:n}=e;return{lang:t,assocLang:r,characteristics:i,channels:s,audioCodec:n}}function Of(e,t,r){if("attrs"in e){const r=t.indexOf(e);if(-1!==r)return r}for(let i=0;i<t.length;i++){if(Mf(e,t[i],r))return i}return-1}function Mf(e,t,r){const{groupId:i,name:s,lang:n,assocLang:a,default:o}=e,l=e.forced;return(void 0===i||t.groupId===i)&&(void 0===s||t.name===s)&&(void 0===n||function(e,t="--"){if(e.length===t.length)return e===t;return e.startsWith(t)||t.startsWith(e)}(n,t.lang))&&(void 0===n||t.assocLang===a)&&(void 0===o||t.default===o)&&(void 0===l||t.forced===l)&&(!("characteristics"in e)||function(e,t=""){const r=e.split(","),i=t.split(",");return r.length===i.length&&!r.some(e=>-1===i.indexOf(e))}(e.characteristics||"",t.characteristics))&&(void 0===r||r(e,t))}function Nf(e,t){const{audioCodec:r,channels:i}=e;return!(void 0!==r&&(t.audioCodec||"").substring(0,4)!==r.substring(0,4)||void 0!==i&&i!==(t.channels||"2"))}function Ff(e,t,r){for(let i=t;i>-1;i--)if(r(e[i]))return i;for(let i=t+1;i<e.length;i++)if(r(e[i]))return i;return-1}function $f(e,t){var r;return!!e&&e!==(null==(r=t.loadLevelObj)?void 0:r.uri)}const Bf=function(e,t){let r=0,i=e.length-1,s=null,n=null;for(;r<=i;){s=(r+i)/2|0,n=e[s];const a=t(n);if(a>0)r=s+1;else{if(!(a<0))return n;i=s-1}}return null};function Uf(e,t,r=0,i=0,s=.005){let n=null;if(e){n=t[1+e.sn-t[0].sn]||null;const i=e.endDTS-r;i>0&&i<15e-7&&(r+=15e-7),n&&e.level!==n.level&&n.end<=e.end&&(n=t[2+e.sn-t[0].sn]||null)}else 0===r&&0===t[0].start&&(n=t[0]);if(n&&((!e||e.level===n.level)&&0===zf(r,i,n)||function(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){const i=t.tagList.reduce((e,t)=>("INF"===t[0]&&(e+=parseFloat(t[1])),e),r);return e.start<=i}return!1}(n,e,Math.min(s,i))))return n;const a=Bf(t,zf.bind(null,r,i));return!a||a===e&&n?n:a}function zf(e=0,t=0,r){if(r.start<=e&&r.start+r.duration>e)return 0;const i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function Gf(e,t,r){const i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function jf(e,t,r){if(e&&e.startCC<=t&&e.endCC>=t){let i=e.fragments;const{fragmentHint:s}=e;let n;return s&&(i=i.concat(s)),Bf(i,e=>e.cc<t?1:e.cc>t?-1:(n=e,e.end<=r?1:e.start>r?-1:0)),n||null}return null}function Hf(e){switch(e.details){case _u.FRAG_LOAD_TIMEOUT:case _u.KEY_LOAD_TIMEOUT:case _u.LEVEL_LOAD_TIMEOUT:case _u.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Vf(e){return e.details.startsWith("key")}function Wf(e){return Vf(e)&&!!e.frag&&!e.frag.decryptdata}function Yf(e,t){const r=Hf(t);return e.default[(r?"timeout":"error")+"Retry"]}function Kf(e,t){const r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function qf(e){return Yu(Yu({},e),{errorRetry:null,timeoutRetry:null})}function Xf(e,t,r,i){if(!e)return!1;const s=null==i?void 0:i.code,n=t<e.maxNumRetry&&(function(e){return Qf(e)||!!e&&(e<400||e>499)}(s)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,n):n}function Qf(e){return 0===e&&!1===navigator.onLine}var Zf=0,Jf=2,ep=3,tp=5,rp=0,ip=1,sp=2,np=4;function ap(e){const t={action:Zf,flags:rp};return e&&(t.resolved=!0),t}var op="NOT_LOADED",lp="APPENDING",cp="PARTIAL",dp="OK";class up{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e&&(e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Ou.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Ou.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Ou.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Ou.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const r=this.activePartLists[t];if(r)for(let t=r.length;t--;){const i=r[t];if(!i)break;if(i.start<=e&&e<=i.end&&i.loaded)return i}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,r){const{fragments:i}=this,s=Object.keys(i);for(let n=s.length;n--;){const a=i[s[n]];if((null==a?void 0:a.body.type)===t&&(!r||a.buffered)){const t=a.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,r,i,s){this.timeRanges&&(this.timeRanges[e]=t);const n=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach(i=>{const a=this.fragments[i];if(!a)return;if(n>=a.body.sn)return;if(!a.buffered&&(!a.loaded||s))return void(a.body.type===r&&this.removeFragment(a.body));const o=a.range[e];o&&(0!==o.time.length?o.time.some(e=>{const r=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&this.removeFragment(a.body),r}):this.removeFragment(a.body))})}detectPartialFragments(e){const t=this.timeRanges;if(!t||"initSegment"===e.frag.sn)return;const r=e.frag,i=fp(r),s=this.fragments[i];if(!s||s.buffered&&r.gap)return;const n=!r.relurl;Object.keys(t).forEach(i=>{const a=r.elementaryStreams[i];if(!a)return;const o=t[i],l=n||!0===a.partial;s.range[i]=this.getBufferedTimes(r,e.part,l,o)}),s.loaded=null,Object.keys(s.range).length?(this.bufferedEnd(s,r),hp(s)||this.removeParts(r.sn-1,r.type)):this.removeFragment(s.body)}bufferedEnd(e,t){e.buffered=!0;(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}removeParts(e,t){const r=this.activePartLists[t];r&&(this.activePartLists[t]=pp(r,t=>t.fragment.sn>=e))}fragBuffered(e,t){const r=fp(e);let i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,this.bufferedEnd(i,e))}getBufferedTimes(e,t,r,i){const s={time:[],partial:r},n=e.start,a=e.end,o=e.minEndPTS||a,l=e.maxStartPTS||n;for(let e=0;e<i.length;e++){const t=i.start(e)-this.bufferPadding,r=i.end(e)+this.bufferPadding;if(l>=t&&o<=r){s.time.push({startPTS:Math.max(n,i.start(e)),endPTS:Math.min(a,i.end(e))});break}if(n<r&&a>t){const t=Math.max(n,i.start(e)),r=Math.min(a,i.end(e));r>t&&(s.partial=!0,s.time.push({startPTS:t,endPTS:r}))}else if(a<=t)break}return s}getPartialFragment(e){let t,r,i,s=null,n=0;const{bufferPadding:a,fragments:o}=this;return Object.keys(o).forEach(l=>{const c=o[l];c&&hp(c)&&(r=c.body.start-a,i=c.body.end+a,e>=r&&e<=i&&(t=Math.min(e-r,i-e),n<=t&&(s=c.body,n=t)))}),s}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||hp(t))}getState(e){const t=fp(e),r=this.fragments[t];return r?r.buffered?hp(r)?cp:dp:lp:op}isTimeBuffered(e,t,r){let i,s;for(let n=0;n<r.length;n++){if(i=r.start(n)-this.bufferPadding,s=r.end(n)+this.bufferPadding,e>=i&&t<=s)return!0;if(t<=i)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if("initSegment"===t.frag.sn||t.frag.bitrateTest)return;const r=t.frag,i=t.part?null:t,s=fp(r);this.fragments[s]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:r,part:i,timeRanges:s,type:n}=t;if("initSegment"===r.sn)return;const a=r.type;if(i){let e=this.activePartLists[a];e||(this.activePartLists[a]=e=[]),e.push(i)}this.timeRanges=s;const o=s[n];this.detectEvictedFragments(n,o,a,i)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=fp(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,r=Object.keys(t);if(!e)return r.length>0;for(let i=r.length;i--;){const s=t[r[i]];if((null==s?void 0:s.body.type)===e)return!0}return!1}hasParts(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}removeFragmentsInRange(e,t,r,i,s){i&&!this.hasGaps||Object.keys(this.fragments).forEach(n=>{const a=this.fragments[n];if(!a)return;const o=a.body;o.type!==r||i&&!o.gap||o.start<t&&o.end>e&&(a.buffered||s)&&this.removeFragment(o)})}removeFragment(e){const t=fp(e);e.clearElementaryStreamInfo();const r=this.activePartLists[e.type];if(r){const t=e.sn;this.activePartLists[e.type]=pp(r,e=>e.fragment.sn!==t)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const t=null==(e=this.hls)||null==(e=e.latestLevelDetails)?void 0:e.partList;t&&t.forEach(e=>e.clearElementaryStreamInfo())}}function hp(e){var t,r,i;return e.buffered&&!!(e.body.gap||null!=(t=e.range.video)&&t.partial||null!=(r=e.range.audio)&&r.partial||null!=(i=e.range.audiovideo)&&i.partial)}function fp(e){return`${e.type}_${e.level}_${e.sn}`}function pp(e,t){return e.filter(e=>{const r=t(e);return r||e.clearElementaryStreamInfo(),r})}var mp=0,gp=1;class vp{constructor(e,t,r){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=r}decrypt(e,t){switch(this.aesMode){case mp:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case gp:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}class yp{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const t=new DataView(e),r=new Uint32Array(4);for(let e=0;e<4;e++)r[e]=t.getUint32(4*e);return r}initTable(){const e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],s=r[1],n=r[2],a=r[3],o=this.invSubMix,l=o[0],c=o[1],d=o[2],u=o[3],h=new Uint32Array(256);let f=0,p=0,m=0;for(m=0;m<256;m++)h[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){let r=p^p<<1^p<<2^p<<3^p<<4;r=r>>>8^255&r^99,e[f]=r,t[r]=f;const o=h[f],m=h[o],g=h[m];let v=257*h[r]^16843008*r;i[f]=v<<24|v>>>8,s[f]=v<<16|v>>>16,n[f]=v<<8|v>>>24,a[f]=v,v=16843009*g^65537*m^257*o^16843008*f,l[r]=v<<24|v>>>8,c[r]=v<<16|v>>>16,d[r]=v<<8|v>>>24,u[r]=v,f?(f=o^h[h[h[g^o]]],p^=h[h[p]]):f=p=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let r=!0,i=0;for(;i<t.length&&r;)r=t[i]===this.key[i],i++;if(r)return;this.key=t;const s=this.keySize=t.length;if(4!==s&&6!==s&&8!==s)throw new Error("Invalid aes key size="+s);const n=this.ksRows=4*(s+6+1);let a,o;const l=this.keySchedule=new Uint32Array(n),c=this.invKeySchedule=new Uint32Array(n),d=this.sBox,u=this.rcon,h=this.invSubMix,f=h[0],p=h[1],m=h[2],g=h[3];let v,y;for(a=0;a<n;a++)a<s?v=l[a]=t[a]:(y=v,a%s===0?(y=y<<8|y>>>24,y=d[y>>>24]<<24|d[y>>>16&255]<<16|d[y>>>8&255]<<8|d[255&y],y^=u[a/s|0]<<24):s>6&&a%s===4&&(y=d[y>>>24]<<24|d[y>>>16&255]<<16|d[y>>>8&255]<<8|d[255&y]),l[a]=v=(l[a-s]^y)>>>0);for(o=0;o<n;o++)a=n-o,y=3&o?l[a]:l[a-4],c[o]=o<4||a<=4?y:f[d[y>>>24]]^p[d[y>>>16&255]]^m[d[y>>>8&255]]^g[d[255&y]],c[o]=c[o]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,r){const i=this.keySize+6,s=this.invKeySchedule,n=this.invSBox,a=this.invSubMix,o=a[0],l=a[1],c=a[2],d=a[3],u=this.uint8ArrayToUint32Array_(r);let h=u[0],f=u[1],p=u[2],m=u[3];const g=new Int32Array(e),v=new Int32Array(g.length);let y,b,E,w,S,T,x,A,k,L,I,R,P,C;const D=this.networkToHostOrderSwap;for(;t<g.length;){for(k=D(g[t]),L=D(g[t+1]),I=D(g[t+2]),R=D(g[t+3]),S=k^s[0],T=R^s[1],x=I^s[2],A=L^s[3],P=4,C=1;C<i;C++)y=o[S>>>24]^l[T>>16&255]^c[x>>8&255]^d[255&A]^s[P],b=o[T>>>24]^l[x>>16&255]^c[A>>8&255]^d[255&S]^s[P+1],E=o[x>>>24]^l[A>>16&255]^c[S>>8&255]^d[255&T]^s[P+2],w=o[A>>>24]^l[S>>16&255]^c[T>>8&255]^d[255&x]^s[P+3],S=y,T=b,x=E,A=w,P+=4;y=n[S>>>24]<<24^n[T>>16&255]<<16^n[x>>8&255]<<8^n[255&A]^s[P],b=n[T>>>24]<<24^n[x>>16&255]<<16^n[A>>8&255]<<8^n[255&S]^s[P+1],E=n[x>>>24]<<24^n[A>>16&255]<<16^n[S>>8&255]<<8^n[255&T]^s[P+2],w=n[A>>>24]<<24^n[S>>16&255]<<16^n[T>>8&255]<<8^n[255&x]^s[P+3],v[t]=D(y^h),v[t+1]=D(w^f),v[t+2]=D(E^p),v[t+3]=D(b^m),h=k,f=L,p=I,m=R,t+=4}return v.buffer}}class bp{constructor(e,t,r){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=r}expandKey(){const e=function(e){switch(e){case mp:return"AES-CBC";case gp:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${e}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}class Ep{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?function(e){const t=e.byteLength,r=t&&new DataView(e.buffer).getUint8(t-1);return r?e.slice(0,t-r):e}(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r,i){return this.useSoftware?new Promise((s,n)=>{const a=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(a,t,r,i);const o=this.flush();o?s(o.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r,i)}softwareDecrypt(e,t,r,i){const{currentIV:s,currentResult:n,remainderData:a}=this;if(i!==mp||16!==t.byteLength)return eh.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),a&&(e=Gh(a,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;s&&(r=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new yp),l.expandKey(t);const c=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=o.slice(-16).buffer,c||null}webCryptoDecrypt(e,t,r,i){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r,i));this.key=t,this.fastAesKey=new bp(this.subtle,t,i)}return this.fastAesKey.expandKey().then(t=>{if(!this.subtle)return Promise.reject(new Error("web crypto not initialized"));this.logOnce("WebCrypto AES decrypt");return new vp(this.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)}).catch(s=>(eh.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${s.name}: ${s.message}`),this.onWebCryptoError(e,t,r,i)))}onWebCryptoError(e,t,r,i){const s=this.enableSoftwareAES;if(s){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,i);const s=this.flush();if(s)return s.buffer}throw new Error("WebCrypto"+(s?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const r=e.length-e.length%16;return r!==e.length&&(t=e.slice(0,r),this.remainderData=e.slice(r)),t}logOnce(e){this.logEnabled&&(eh.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const wp=Math.pow(2,17);class Sp{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const r=e.url;if(!r)return Promise.reject(new Ap({type:Du.NETWORK_ERROR,details:_u.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(r?"part list":"url")),networkDetails:null}));this.abort();const i=this.config,s=i.fLoader,n=i.loader;return new Promise((a,o)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some(e=>"GAP"===e[0]))return void o(xp(e));e.gap=!1}const l=this.loader=s?new s(i):new n(i),c=Tp(e);e.loader=l;const d=qf(i.fragLoadPolicy.default),u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:wp};e.stats=l.stats;const h={onSuccess:(t,r,i,s)=>{this.resetLoader(e,l);let n=t.data;i.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(n.slice(0,16)),n=n.slice(16)),a({frag:e,part:null,payload:n,networkDetails:s})},onError:(t,i,s,n)=>{this.resetLoader(e,l),o(new Ap({type:Du.NETWORK_ERROR,details:_u.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Yu({url:r,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:s,stats:n}))},onAbort:(t,r,i)=>{this.resetLoader(e,l),o(new Ap({type:Du.NETWORK_ERROR,details:_u.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:(t,r,i)=>{this.resetLoader(e,l),o(new Ap({type:Du.NETWORK_ERROR,details:_u.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:i,stats:t}))}};t&&(h.onProgress=(r,i,s,n)=>t({frag:e,part:null,payload:s,networkDetails:n})),l.load(c,u,h)})}loadPart(e,t,r){this.abort();const i=this.config,s=i.fLoader,n=i.loader;return new Promise((a,o)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void o(xp(e,t));const l=this.loader=s?new s(i):new n(i),c=Tp(e,t);e.loader=l;const d=qf(i.fragLoadPolicy.default),u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:wp};t.stats=l.stats,l.load(c,u,{onSuccess:(i,s,n,o)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const c={frag:e,part:t,payload:i.data,networkDetails:o};r(c),a(c)},onError:(r,i,s,n)=>{this.resetLoader(e,l),o(new Ap({type:Du.NETWORK_ERROR,details:_u.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Yu({url:c.url,data:void 0},r),error:new Error(`HTTP Error ${r.code} ${r.text}`),networkDetails:s,stats:n}))},onAbort:(r,i,s)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),o(new Ap({type:Du.NETWORK_ERROR,details:_u.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:s,stats:r}))},onTimeout:(r,i,s)=>{this.resetLoader(e,l),o(new Ap({type:Du.NETWORK_ERROR,details:_u.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:s,stats:r}))}})})}updateStatsFromPart(e,t){const r=e.stats,i=t.stats,s=i.total;if(r.loaded+=i.loaded,s){const i=Math.round(e.duration/t.duration),n=Math.min(Math.round(r.loaded/s),i),a=(i-n)*Math.round(r.loaded/n);r.total=r.loaded+a}else r.total=Math.max(r.loaded,r.total);const n=r.loading,a=i.loading;n.start?n.first+=a.first-a.start:(n.start=a.start,n.first=a.first),n.end=a.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function Tp(e,t=null){const r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},s=r.byteRangeStartOffset,n=r.byteRangeEndOffset;if(Ru(s)&&Ru(n)){var a;let t=s,r=n;if("initSegment"===e.sn&&("AES-128"===(o=null==(a=e.decryptdata)?void 0:a.method)||"AES-256"===o)){const e=n-s;e%16&&(r=n+(16-e%16)),0!==s&&(i.resetIV=!0,t=s-16)}i.rangeStart=t,i.rangeEnd=r}var o;return i}function xp(e,t){const r=new Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:Du.MEDIA_ERROR,details:_u.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new Ap(i)}class Ap extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class kp extends Ku{constructor(e,t){super(e,t),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class Lp{constructor(e,t,r,i=0,s=-1,n=!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=e,this.sn=t,this.id=r,this.size=i,this.part=s,this.partial=n}}const Ip={length:0,start:()=>0,end:()=>0};class Rp{static isBuffered(e,t){if(e){const r=Rp.getBuffered(e);for(let e=r.length;e--;)if(t>=r.start(e)&&t<=r.end(e))return!0}return!1}static bufferedRanges(e){if(e){const t=Rp.getBuffered(e);return Rp.timeRangesToArray(t)}return[]}static timeRangesToArray(e){const t=[];for(let r=0;r<e.length;r++)t.push({start:e.start(r),end:e.end(r)});return t}static bufferInfo(e,t,r){if(e){const i=Rp.bufferedRanges(e);if(i.length)return Rp.bufferedInfo(i,t,r)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.length>1&&e.sort((e,t)=>e.start-t.start||t.end-e.end);let i=-1,s=[];if(r)for(let n=0;n<e.length;n++){t>=e[n].start&&t<=e[n].end&&(i=n);const a=s.length;if(a){const t=s[a-1].end;e[n].start-t<r?e[n].end>t&&(s[a-1].end=e[n].end):s.push(e[n])}else s.push(e[n])}else s=e;let n,a=0,o=t,l=t;for(let e=0;e<s.length;e++){const c=s[e].start,d=s[e].end;if(-1===i&&t>=c&&t<=d&&(i=e),t+r>=c&&t<d)o=c,l=d,a=l-t;else if(t+r<c){n=c;break}}return{len:a,start:o||0,end:l||0,nextStart:n,buffered:e,bufferedIndex:i}}static getBuffered(e){try{return e.buffered||Ip}catch(e){return eh.log("failed to get media.buffered",e),Ip}}}const Pp=/\{\$([a-zA-Z0-9-_]+)\}/g;function Cp(e){return Pp.test(e)}function Dp(e,t){if(null!==e.variableList||e.hasVariableRefs){const r=e.variableList;return t.replace(Pp,t=>{const i=t.substring(2,t.length-1),s=null==r?void 0:r[i];return void 0===s?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"`)),t):s})}return t}function _p(e,t,r){let i,s,n=e.variableList;if(n||(e.variableList=n={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{const e=new self.URL(r).searchParams;if(!e.has(i))throw new Error(`"${i}" does not match any query parameter in URI: "${r}"`);s=e.get(i)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else i=t.NAME,s=t.VALUE;i in n?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):n[i]=s||""}function Op(e,t,r){const i=t.IMPORT;if(r&&i in r){let t=e.variableList;t||(e.variableList=t={}),t[i]=r[i]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}const Mp=/^(\d+)x(\d+)$/,Np=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Fp{constructor(e,t){"string"==typeof e&&(e=Fp.parseAttrList(e,t)),Vu(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>"X-"===e.substring(0,2))}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;const r=new Uint8Array(t.length/2);for(let e=0;e<t.length/2;e++)r[e]=parseInt(t.slice(2*e,2*e+2),16);return r}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){const r=this[e];return(r?r.split(/[ ,]+/):[]).reduce((e,t)=>(e[t.toLowerCase()]=!0,e),t)}bool(e){return"YES"===this[e]}decimalResolution(e){const t=Mp.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let r;const i={};for(Np.lastIndex=0;null!==(r=Np.exec(e));){const s=r[1].trim();let n=r[2];const a=0===n.indexOf('"')&&n.lastIndexOf('"')===n.length-1;let o=!1;if(a)n=n.slice(1,-1);else switch(s){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":o=!0}if(t&&(a||o))n=Dp(t,n);else if(!o&&!a)switch(s){case"CLOSED-CAPTIONS":if("NONE"===n)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":eh.warn(`${e}: attribute ${s} is missing quotes`)}i[s]=n}return i}}function $p(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function Bp(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}class Up{constructor(e,t,r=0){var i;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==t?void 0:t.tagAnchor)||null,this.tagOrder=null!=(i=null==t?void 0:t.tagOrder)?i:r,t){const r=t.attr;for(const t in r)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==r[t]){eh.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=Vu(new Fp({}),r,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const e=(null==t?void 0:t.endDate)||new Date(this.attr["END-DATE"]);Ru(e.getTime())&&(this._endDate=e)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}get startTime(){const{tagAnchor:e}=this;return null===e||null===e.programDateTime?(eh.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const e=this._endDate||this._dateAtEnd;if(e)return e;const t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(Ru(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return"com.apple.hls.interstitial"===this.class}get isValid(){return!!this.id&&!this._badValueForSameId&&Ru(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}class zp{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!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.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e)return this.advanced=!0,void(this.updated=!0);const t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some(t=>{let r=t.decryptdata;return r||(t.setKeyFormat(e.keyFormat),r=t.decryptdata),!!r&&e.matches(r)})}get hasProgramDateTime(){return!!this.fragments.length&&Ru(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const e=this.driftEndTime-this.driftStartTime;if(e>0){return 1e3*(this.driftEnd-this.driftStart)/e}return 1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){const e=this.partList;if(e){const t=this.lastPartIndex;if(-1!==t){for(let r=e.length;r--;)if(e[r].index>t)return e[r].index;return t}}return 0}get lastPartSn(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function Gp(e,t){return e.length===t.length&&!e.some((e,r)=>e!==t[r])}function jp(e,t){return!e&&!t||!(!e||!t)&&Gp(e,t)}function Hp(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function Vp(e){switch(e){case"AES-128":case"AES-256":return mp;case"AES-256-CTR":return gp;default:throw new Error(`invalid full segment method ${e}`)}}function Wp(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function Yp(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function Kp(e){const t=function(e,t,r){const i=e[t];e[t]=e[r],e[r]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function qp(e){const t=e.split(":");let r=null;if("data"===t[0]&&2===t.length){const e=t[1].split(";"),i=e[e.length-1].split(",");if(2===i.length){const t="base64"===i[0],s=i[1];t?(e.splice(-1,1),r=Wp(s)):r=function(e){const t=Yp(e).subarray(0,16),r=new Uint8Array(16);return r.set(t,16-t.length),r}(s)}}return r}const Xp="undefined"!=typeof self?self:void 0;var Qp={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Zp="org.w3.clearkey",Jp="com.apple.streamingkeydelivery",em="com.microsoft.playready",tm="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function rm(e){switch(e){case Jp:return Qp.FAIRPLAY;case em:return Qp.PLAYREADY;case tm:return Qp.WIDEVINE;case Zp:return Qp.CLEARKEY}}function im(e){switch(e){case Qp.FAIRPLAY:return Jp;case Qp.PLAYREADY:return em;case Qp.WIDEVINE:return tm;case Qp.CLEARKEY:return Zp}}function sm(e){const{drmSystems:t,widevineLicenseUrl:r}=e,i=t?[Qp.FAIRPLAY,Qp.WIDEVINE,Qp.PLAYREADY,Qp.CLEARKEY].filter(e=>!!t[e]):[];return!i[Qp.WIDEVINE]&&r&&i.push(Qp.WIDEVINE),i}const nm=null!=Xp&&null!=(am=Xp.navigator)&&am.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var am;function om(e){const t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),r=String.fromCharCode.apply(null,Array.from(t)),i=r.substring(r.indexOf("<"),r.length),s=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(s){const e=s.childNodes[0]?s.childNodes[0].nodeValue:s.getAttribute("VALUE");if(e){const t=Wp(e).subarray(0,16);return Kp(t),t}}return null}let lm={};class cm{static clearKeyUriToKeyIdMap(){lm={}}static setKeyIdForUri(e,t){lm[e]=t}static addKeyIdForUri(e){const t=Object.keys(lm).length%Number.MAX_SAFE_INTEGER,r=new Uint8Array(16);return new DataView(r.buffer,12,4).setUint32(0,t),lm[e]=r,r}constructor(e,t,r,i=[1],s=null,n){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=s,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&!Hp(e),null!=n&&n.startsWith("0x")&&(this.keyId=new Uint8Array(nh(n)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&Gp(e.keyFormatVersions,this.keyFormatVersions)&&jp(e.iv,this.iv)&&jp(e.keyId,this.keyId)}isSupported(){if(this.method){if(Hp(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case Jp:case tm:case em:case Zp:return-1!==["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e,t){if(!this.encrypted||!this.uri)return null;if(Hp(this.method)){let t=this.iv;t||("number"!=typeof e&&(eh.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),t=function(e){const t=new Uint8Array(16);for(let r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}(e));return new cm(this.method,this.uri,"identity",this.keyFormatVersions,t)}if(this.keyId){const e=lm[this.uri];if(e&&!Gp(this.keyId,e)&&cm.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const r=qp(this.uri);if(r)switch(this.keyFormat){case tm:if(this.pssh=r,!this.keyId){const e=function(e){const t=[];if(e instanceof ArrayBuffer){const r=e.byteLength;let i=0;for(;i+32<r;){const r=qh(new DataView(e,i));t.push(r),i+=r.size}}return t}(r.buffer);if(e.length){var i;const t=e[0];this.keyId=null!=(i=t.kids)&&i.length?t.kids[0]:null}}this.keyId||(this.keyId=dm(t));break;case em:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Kh(e,0,r),this.keyId=om(r);break}default:{let e=r.subarray(0,16);if(16!==e.length){const t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e;break}}if(!this.keyId||16!==this.keyId.byteLength){let e;e=function(e){const t=null==e?void 0:e[tm];if(t)return t.keyId;return null}(t),e||(e=dm(t),e||(e=lm[this.uri])),e&&(this.keyId=e,cm.setKeyIdForUri(this.uri,e))}return this}}function dm(e){const t=null==e?void 0:e[em];if(t){const e=qp(t.uri);if(e)return om(e)}return null}const um=/#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,hm=/#EXT-X-MEDIA:(.*)/g,fm=/^#EXT(?:INF|-X-TARGETDURATION):/m,pm=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),mm=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class gm{static findGroup(e,t){for(let r=0;r<e.length;r++){const i=e[r];if(i.id===t)return i}}static resolve(e,t){return ph.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return fm.test(e)}static parseMasterPlaylist(e,t){const r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Cp(e)},i=[];if(um.lastIndex=0,!e.startsWith("#EXTM3U"))return r.playlistParsingError=new Error("no EXTM3U delimiter"),r;let s;for(;null!=(s=um.exec(e));)if(s[1]){var n;const e=new Fp(s[1],r),a=Dp(r,s[2]),o={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:gm.resolve(a,t)},l=e.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),wm(e.CODECS,o);const c=e["SUPPLEMENTAL-CODECS"];c&&(o.supplemental={},wm(c,o.supplemental)),null!=(n=o.unknownCodecs)&&n.length||i.push(o),r.levels.push(o)}else if(s[3]){const e=s[3],i=s[4];switch(e){case"SESSION-DATA":{const e=new Fp(i,r),t=e["DATA-ID"];t&&(null===r.sessionData&&(r.sessionData={}),r.sessionData[t]=e);break}case"SESSION-KEY":{const e=bm(i,t,r);e.encrypted&&e.isSupported()?(null===r.sessionKeys&&(r.sessionKeys=[]),r.sessionKeys.push(e)):eh.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":_p(r,new Fp(i,r),t);break;case"CONTENT-STEERING":{const e=new Fp(i,r);r.contentSteering={uri:gm.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":r.startTimeOffset=Em(i)}}const a=i.length>0&&i.length<r.levels.length;return r.levels=a?i:r.levels,0===r.levels.length&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,r){let i;const s={},n=r.levels,a={AUDIO:n.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:n.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]};let o=0;for(hm.lastIndex=0;null!==(i=hm.exec(e));){const e=new Fp(i[1],r),n=e.TYPE;if(n){const r=a[n],i=s[n]||[];s[n]=i;const l=e.LANGUAGE,c=e["ASSOC-LANGUAGE"],d=e.CHANNELS,u=e.CHARACTERISTICS,h=e["INSTREAM-ID"],f={attrs:e,bitrate:0,id:o++,groupId:e["GROUP-ID"]||"",name:e.NAME||l||"",type:n,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:l,url:e.URI?gm.resolve(e.URI,t):""};if(c&&(f.assocLang=c),d&&(f.channels=d),u&&(f.characteristics=u),h&&(f.instreamId=h),null!=r&&r.length){const e=gm.findGroup(r,f.groupId)||r[0];Sm(f,e,"audioCodec"),Sm(f,e,"textCodec")}i.push(f)}}return s}static parseLevelPlaylist(e,t,r,i,s,n){var a;const o={url:t},l=new zp(t),c=l.fragments,d=[];let u,h,f,p,m=null,g=0,v=0,y=0,b=0,E=0,w=null,S=new wh(i,o),T=-1,x=!1,A=null;if(pm.lastIndex=0,l.m3u8=e,l.hasVariableRefs=Cp(e),"#EXTM3U"!==(null==(a=pm.exec(e))?void 0:a[0]))return l.playlistParsingError=new Error("Missing format identifier #EXTM3U"),l;for(;null!==(u=pm.exec(e));){x&&(x=!1,S=new wh(i,o),S.playlistOffset=y,S.setStart(y),S.sn=g,S.cc=b,E&&(S.bitrate=E),S.level=r,m&&(S.initSegment=m,m.rawProgramDateTime&&(S.rawProgramDateTime=m.rawProgramDateTime,m.rawProgramDateTime=null),A&&(S.setByteRange(A),A=null)));const e=u[1];if(e){S.duration=parseFloat(e);const t=(" "+u[2]).slice(1);S.title=t||null,S.tagList.push(t?["INF",e,t]:["INF",e])}else if(u[3]){if(Ru(S.duration)){S.playlistOffset=y,S.setStart(y),f&&Am(S,f,l),S.sn=g,S.level=r,S.cc=b,c.push(S);const e=(" "+u[3]).slice(1);S.relurl=Dp(l,e),Tm(S,w,d),w=S,y+=S.duration,g++,v=0,x=!0}}else{if(u=u[0].match(mm),!u){eh.warn("No matches on slow regex match for level playlist!");continue}for(h=1;h<u.length&&void 0===u[h];h++);const e=(" "+u[h]).slice(1),s=(" "+u[h+1]).slice(1),a=u[h+2]?(" "+u[h+2]).slice(1):null;switch(e){case"BYTERANGE":w?S.setByteRange(s,w):S.setByteRange(s);break;case"PROGRAM-DATE-TIME":S.rawProgramDateTime=s,S.tagList.push(["PROGRAM-DATE-TIME",s]),-1===T&&(T=c.length);break;case"PLAYLIST-TYPE":l.type&&km(l,e,u),l.type=s.toUpperCase();break;case"MEDIA-SEQUENCE":0!==l.startSN?km(l,e,u):c.length>0&&Lm(l,e,u),g=l.startSN=parseInt(s);break;case"SKIP":{l.skippedSegments&&km(l,e,u);const t=new Fp(s,l),r=t.decimalInteger("SKIPPED-SEGMENTS");if(Ru(r)){l.skippedSegments+=r;for(let e=r;e--;)c.push(null);g+=r}const i=t.enumeratedString("RECENTLY-REMOVED-DATERANGES");i&&(l.recentlyRemovedDateranges=(l.recentlyRemovedDateranges||[]).concat(i.split("\t")));break}case"TARGETDURATION":0!==l.targetduration&&km(l,e,u),l.targetduration=Math.max(parseInt(s),1);break;case"VERSION":null!==l.version&&km(l,e,u),l.version=parseInt(s);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":l.live||km(l,e,u),l.live=!1;break;case"#":(s||a)&&S.tagList.push(a?[s,a]:[s]);break;case"DISCONTINUITY":b++,S.tagList.push(["DIS"]);break;case"GAP":S.gap=!0,S.tagList.push([e]);break;case"BITRATE":S.tagList.push([e,s]),E=1e3*parseInt(s),Ru(E)?S.bitrate=E:E=0;break;case"DATERANGE":{const e=new Fp(s,l),t=new Up(e,l.dateRanges[e.ID],l.dateRangeTagCount);l.dateRangeTagCount++,t.isValid||l.skippedSegments?l.dateRanges[t.id]=t:eh.warn(`Ignoring invalid DATERANGE tag: "${s}"`),S.tagList.push(["EXT-X-DATERANGE",s]);break}case"DEFINE":{const e=new Fp(s,l);"IMPORT"in e?Op(l,e,n):_p(l,e,t)}break;case"DISCONTINUITY-SEQUENCE":0!==l.startCC?km(l,e,u):c.length>0&&Lm(l,e,u),l.startCC=b=parseInt(s);break;case"KEY":{const e=bm(s,t,l);if(e.isSupported()){if("NONE"===e.method){f=void 0;break}f||(f={});const t=f[e.keyFormat];null!=t&&t.matches(e)||(t&&(f=Vu({},f)),f[e.keyFormat]=e)}else eh.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${s}"`);break}case"START":l.startTimeOffset=Em(s);break;case"MAP":{const e=new Fp(s,l);if(S.duration){const t=new wh(i,o);xm(t,e,r,f),m=t,S.initSegment=m,m.rawProgramDateTime&&!S.rawProgramDateTime&&(S.rawProgramDateTime=m.rawProgramDateTime)}else{const t=S.byteRangeEndOffset;if(t){const e=S.byteRangeStartOffset;A=`${t-e}@${e}`}else A=null;xm(S,e,r,f),m=S,x=!0}m.cc=b;break}case"SERVER-CONTROL":p&&km(l,e,u),p=new Fp(s),l.canBlockReload=p.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=p.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&p.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=p.optionalFloat("PART-HOLD-BACK",0),l.holdBack=p.optionalFloat("HOLD-BACK",0);break;case"PART-INF":{l.partTarget&&km(l,e,u);const t=new Fp(s);l.partTarget=t.decimalFloatingPoint("PART-TARGET");break}case"PART":{let e=l.partList;e||(e=l.partList=[]);const t=v>0?e[e.length-1]:void 0,r=v++,i=new Fp(s,l),n=new Sh(i,S,o,r,t);e.push(n),S.duration+=n.duration;break}case"PRELOAD-HINT":{const e=new Fp(s,l);l.preloadHint=e;break}case"RENDITION-REPORT":{const e=new Fp(s,l);l.renditionReports=l.renditionReports||[],l.renditionReports.push(e);break}default:eh.warn(`line parsed but not handled: ${u}`)}}}w&&!w.relurl?(c.pop(),y-=w.duration,l.partList&&(l.fragmentHint=w)):l.partList&&(Tm(S,w,d),S.cc=b,l.fragmentHint=S,f&&Am(S,f,l)),l.targetduration||(l.playlistParsingError=new Error("Missing Target Duration"));const k=c.length,L=c[0],I=c[k-1];if(y+=l.skippedSegments*l.targetduration,y>0&&k&&I){l.averagetargetduration=y/k;const e=I.sn;l.endSN="initSegment"!==e?e:0,l.live||(I.endList=!0),T>0&&(!function(e,t){let r=e[t];for(let i=t;i--;){const t=e[i];if(!t)return;t.programDateTime=r.programDateTime-1e3*t.duration,r=t}}(c,T),L&&d.unshift(L))}return l.fragmentHint&&(y+=l.fragmentHint.duration),l.totalduration=y,d.length&&l.dateRangeTagCount&&L&&vm(d,l),l.endCC=b,l}}function vm(e,t){let r=e.length;if(!r){if(!t.hasProgramDateTime)return;{const i=t.fragments[t.fragments.length-1];e.push(i),r++}}const i=e[r-1],s=t.live?1/0:t.totalduration,n=Object.keys(t.dateRanges);for(let o=n.length;o--;){const l=t.dateRanges[n[o]],c=l.startDate.getTime();l.tagAnchor=i.ref;for(let i=r;i--;){var a;if((null==(a=e[i])?void 0:a.sn)<t.startSN)break;const r=ym(t,c,e,i,s);if(-1!==r){l.tagAnchor=t.fragments[r].ref;break}}}}function ym(e,t,r,i,s){const n=r[i];if(n){const o=n.programDateTime;if(t>=o||0===i){var a;if(t<=o+1e3*(((null==(a=r[i+1])?void 0:a.start)||s)-n.start)){const s=r[i].sn-e.startSN;if(s<0)return-1;const n=e.fragments;if(n.length>r.length){for(let a=(r[i+1]||n[n.length-1]).sn-e.startSN;a>s;a--){const e=n[a].programDateTime;if(t>=e&&t<e+1e3*n[a].duration)return a}}return s}}}return-1}function bm(e,t,r){var i,s;const n=new Fp(e,r),a=null!=(i=n.METHOD)?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),c=n.KEYFORMATVERSIONS,d=null!=(s=n.KEYFORMAT)?s:"identity";o&&n.IV&&!l&&eh.error(`Invalid IV: ${n.IV}`);const u=o?gm.resolve(o,t):"",h=(c||"1").split("/").map(Number).filter(Number.isFinite);return new cm(a,u,d,h,l,n.KEYID)}function Em(e){const t=new Fp(e).decimalFloatingPoint("TIME-OFFSET");return Ru(t)?t:null}function wm(e,t){let r=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{const i=r.filter(t=>Zh(t,e));i.length&&(t[`${e}Codec`]=i.map(e=>e.split("/")[0]).join(","),r=r.filter(e=>-1===i.indexOf(e)))}),t.unknownCodecs=r}function Sm(e,t,r){const i=t[r];i&&(e[r]=i)}function Tm(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function xm(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function Am(e,t,r){e.levelkeys=t;const{encryptedFragments:i}=r;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some(e=>t[e].isCommonEncryption)||i.push(e)}function km(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${r[0]})`)}function Lm(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${r[0]})`)}function Im(e,t){const r=t.startPTS;if(Ru(r)){let i,s=0;t.sn>e.sn?(s=r-e.start,i=e):(s=e.start-r,i=t),i.duration!==s&&i.setDuration(s)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration)}else t.setStart(Math.max(e.start-t.duration,0))}function Rm(e,t,r,i,s,n,a){i-r<=0&&(a.warn("Fragment should have a positive duration",t),i=r+t.duration,n=s+t.duration);let o=r,l=i;const c=t.startPTS,d=t.endPTS;if(Ru(c)){const u=Math.abs(c-r);e&&u>e.totalduration?a.warn(`media timestamps and playlist times differ by ${u}s for level ${t.level} ${e.url}`):Ru(t.deltaPTS)?t.deltaPTS=Math.max(u,t.deltaPTS):t.deltaPTS=u,o=Math.max(r,c),r=Math.min(r,c),s=void 0!==t.startDTS?Math.min(s,t.startDTS):s,l=Math.min(i,d),i=Math.max(i,d),n=void 0!==t.endDTS?Math.max(n,t.endDTS):n}const u=r-t.start;0!==t.start&&t.setStart(r),t.setDuration(i-t.start),t.startPTS=r,t.maxStartPTS=o,t.startDTS=s,t.endPTS=i,t.minEndPTS=l,t.endDTS=n;const h=t.sn;if(!e||h<e.startSN||h>e.endSN)return 0;let f;const p=h-e.startSN,m=e.fragments;for(m[p]=t,f=p;f>0;f--)Im(m[f],m[f-1]);for(f=p;f<m.length-1;f++)Im(m[f],m[f+1]);return e.fragmentHint&&Im(m[m.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,u}function Pm(e,t,r){if(e===t)return;let i=null;const s=e.fragments;for(let e=s.length-1;e>=0;e--){const t=s[e].initSegment;if(t){i=t;break}}let n;e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,r){const i=t.skippedSegments,s=Math.max(e.startSN,t.startSN)-t.startSN,n=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,a=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;for(let c=s;c<=n;c++){const s=l[a+c];let n=o[c];if(i&&!n&&s&&(n=t.fragments[c]=s),s&&n){r(s,n,c,o);const i=s.relurl,a=n.relurl;if(i&&Bm(i,a))return void(t.playlistParsingError=Cm(`media sequence mismatch ${n.sn}:`,e,t,s,n));if(s.cc!==n.cc)return void(t.playlistParsingError=Cm(`discontinuity sequence mismatch (${s.cc}!=${n.cc})`,e,t,s,n))}}}(e,t,(e,r,s,a)=>{if((!t.startCC||t.skippedSegments)&&r.cc!==e.cc){const i=e.cc-r.cc;for(let e=s;e<a.length;e++)a[e].cc+=i;t.endCC=a[a.length-1].cc}Ru(e.startPTS)&&Ru(e.endPTS)&&(r.setStart(r.startPTS=e.startPTS),r.startDTS=e.startDTS,r.maxStartPTS=e.maxStartPTS,r.endPTS=e.endPTS,r.endDTS=e.endDTS,r.minEndPTS=e.minEndPTS,r.setDuration(e.endPTS-e.startPTS),r.duration&&(n=r),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(r.elementaryStreams=e.elementaryStreams),r.loader=e.loader,e.hasStats&&(r.stats=e.stats),e.initSegment&&(r.initSegment=e.initSegment,i=e.initSegment)});const a=t.fragments,o=t.fragmentHint?a.concat(t.fragmentHint):a;if(i&&o.forEach(e=>{var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=i)?void 0:t.relurl)||(e.initSegment=i)}),t.skippedSegments){if(t.deltaUpdateFailed=a.some(e=>!e),t.deltaUpdateFailed){r.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=t.skippedSegments;e--;)a.shift();t.startSN=a[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=function(e,t,r){const{dateRanges:i,recentlyRemovedDateranges:s}=t,n=Vu({},e);s&&s.forEach(e=>{delete n[e]});const a=Object.keys(n).length;if(!a)return i;return Object.keys(i).forEach(e=>{const t=n[e],s=new Up(i[e].attr,t);s.isValid?(n[e]=s,t||(s.tagOrder+=a)):r.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${Pf(i[e].attr)}"`)}),n}(e.dateRanges,t,r));const i=e.fragments.filter(e=>e.rawProgramDateTime);if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(let e=1;e<o.length;e++)null===o[e].programDateTime&&Tm(o[e],o[e-1],i);vm(i,t)}t.endCC=a[a.length-1].cc}if(!t.startCC){var l;const r=Mm(e,t.startSN-1);t.startCC=null!=(l=null==r?void 0:r.cc)?l:a[0].cc}!function(e,t,r){if(e&&t){let i=0;for(let s=0,n=e.length;s<=n;s++){const n=e[s],a=t[s+i];n&&a&&n.index===a.index&&n.fragment.sn===a.fragment.sn?r(n,a):i--}}}(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),n?Rm(t,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS,r):Dm(e,t),a.length&&(t.totalduration=t.edge-a[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;const c=t.advancedDateTime;if(t.advanced&&c){const e=t.edge;t.driftStart||(t.driftStartTime=c,t.driftStart=e),t.driftEndTime=c,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}function Cm(e,t,r,i,s){return new Error(`${e} ${s.url}\nPlaylist starting @${t.startSN}\n${t.m3u8}\n\nPlaylist starting @${r.startSN}\n${r.m3u8}`)}function Dm(e,t,r=!0){const i=t.startSN+t.skippedSegments-e.startSN,s=e.fragments,n=i>=0;let a=0;if(n&&i<s.length)a=s[i].start;else if(n&&t.startSN===e.endSN+1)a=e.fragmentEnd;else if(n&&r)a=e.fragmentStart+i*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;a=e.fragmentStart}_m(t,a)}function _m(e,t){if(t){const r=e.fragments;for(let i=e.skippedSegments;i<r.length;i++)r[i].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function Om(e,t=1/0){let r=1e3*e.targetduration;if(e.updated){const i=e.fragments,s=4;if(i.length&&r*s>t){const e=1e3*i[i.length-1].duration;e<r&&(r=e)}}else r/=2;return Math.round(r)}function Mm(e,t,r){if(!e)return null;let i=e.fragments[t-e.startSN];return i||(i=e.fragmentHint,i&&i.sn===t?i:t<e.startSN&&r&&r.sn===t?r:null)}function Nm(e,t,r){return e?Fm(e.partList,t,r):null}function Fm(e,t,r){if(e)for(let i=e.length;i--;){const s=e[i];if(s.index===r&&s.fragment.sn===t)return s}return null}function $m(e){e.forEach((e,t)=>{var r;null==(r=e.details)||r.fragments.forEach(e=>{e.level=t,e.initSegment&&(e.initSegment.level=t)})})}function Bm(e,t){return!(e===t||!t)&&Um(e)!==Um(t)}function Um(e){return e.replace(/\?[^?]*$/,"")}function zm(e,t){for(let i=0,s=e.length;i<s;i++){var r;if((null==(r=e[i])?void 0:r.cc)===t)return e[i]}return null}function Gm(e,t){const r=e.start+t;e.startPTS=r,e.setStart(r),e.endPTS=r+e.duration}function jm(e,t){const r=t.fragments;for(let t=0,i=r.length;t<i;t++)Gm(r[t],e);t.fragmentHint&&Gm(t.fragmentHint,e),t.alignedSliding=!0}function Hm(e,t){if(!function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e))return;const r=Math.min(t.endCC,e.endCC),i=zm(t.fragments,r),s=zm(e.fragments,r);if(!i||!s)return;eh.log(`Aligning playlist at start of dicontinuity sequence ${r}`);jm(i.start-s.start,e)}function Vm(e,t){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;const r=e.fragments,i=t.fragments;if(!r.length||!i.length)return;let s,n;const a=Math.min(t.endCC,e.endCC);t.startCC<a&&e.startCC<a&&(s=zm(i,a),n=zm(r,a)),s&&n||(s=i[Math.floor(i.length/2)],n=zm(r,s.cc)||r[Math.floor(r.length/2)]);const o=s.programDateTime,l=n.programDateTime;if(!o||!l)return;jm((l-o)/1e3-(n.start-s.start),e)}function Wm(e,t,r){Ym(e,t,r),e.addEventListener(t,r)}function Ym(e,t,r){e.removeEventListener(t,r)}const Km=function(e){let t="";const r=e.length;for(let i=0;i<r;i++)t+=`[${e.start(i).toFixed(3)}-${e.end(i).toFixed(3)}]`;return t},qm="STOPPED",Xm="IDLE",Qm="KEY_LOADING",Zm="FRAG_LOADING",Jm="FRAG_LOADING_WAITING_RETRY",eg="WAITING_TRACK",tg="PARSING",rg="PARSED",ig="ENDED",sg="ERROR",ng="WAITING_INIT_PTS",ag="WAITING_LEVEL";class og extends kp{constructor(e,t,r,i,s){super(i,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=qm,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:e,fragCurrent:t,media:r,mediaBuffer:i,state:s}=this,n=r?r.currentTime:0,a=Rp.bufferInfo(i||r,n,e.maxBufferHole),o=!a.len;if(this.log(`Media seeking to ${Ru(n)?n.toFixed(3):n}, state: ${s}, ${o?"out of":"in"} buffer`),this.state===ig)this.resetLoadingState();else if(t){const r=e.maxFragLookUpTolerance,i=t.start-r,s=t.start+t.duration+r;if(o||s<a.start||i>a.end){const e=n>s;(n<i||e)&&(e&&t.loader&&(this.log(`Cancelling fragment load for seek (sn: ${t.sn})`),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(r){this.fragmentTracker.removeFragmentsInRange(n,1/0,this.playlistType,!0);if(n>this.lastCurrentTime&&(this.lastCurrentTime=n),!this.loadingParts){const e=Math.max(a.end,n),t=this.shouldLoadParts(this.getLevelDetails(),e);t&&(this.log(`LL-Part loading ON after seeking to ${n.toFixed(2)} with buffer @${e.toFixed(2)}`),this.loadingParts=t)}}this.hls.hasEnoughToStart||(this.log(`Setting ${o?"startPosition":"nextLoadPosition"} to ${n} for seek without enough to start`),this.nextLoadPosition=n,o&&(this.startPosition=n)),o&&this.state===Xm&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=s,this.hls=e,this.fragmentLoader=new Sp(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Ep(e.config)}registerListeners(){const{hls:e}=this;e.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Ou.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Ou.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===qm)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=qm}get startPositionValue(){const{nextLoadPosition:e,startPosition:t}=this;return-1===t&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;const r=e.end||0,i=this.config.timelineOffset||0;if(r<=i)return!1;const s=e.buffered;this.config.maxBufferHole&&s&&s.length>1&&(e=Rp.bufferedInfo(s,e.start,0));const n=e.nextStart;if(n&&n>i&&n<t.edge)return!1;if(this.media.currentTime<e.start)return!1;const a=t.partList;if(null!=a&&a.length){const e=a[a.length-1];return Rp.isBuffered(this.media,e.start+e.duration/2)}const o=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(o)}getLevelDetails(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details}get timelineOffset(){const e=this.config.timelineOffset;var t;return e?(null==(t=this.getLevelDetails())?void 0:t.appliedTimelineOffset)||e:0}onMediaAttached(e,t){const r=this.media=this.mediaBuffer=t.media;Wm(r,"seeking",this.onMediaSeeking),Wm(r,"ended",this.onMediaEnded);const i=this.config;this.levels&&i.autoStartLoad&&this.state===qm&&this.startLoad(i.startPosition)}onMediaDetaching(e,t){const r=!!t.transferMedia,i=this.media;if(null!==i){if(i.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),Ym(i,"seeking",this.onMediaSeeking),Ym(i,"ended",this.onMediaEnded),this.keyLoader&&!r&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,r)return this.resetLoadingState(),void this.resetTransmuxer();this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=qm,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this.startFragRequested=!0,this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){this._doFragLoad(e,t,r,e=>{const t=e.frag;if(this.fragContextChanged(t))return this.warn(`${t.type} sn: ${t.sn}${e.part?" part: "+e.part.index:""} of ${this.fragInfo(t,!1,e.part)}) was dropped during download.`),void this.fragmentTracker.removeFragment(t);t.stats.chunkCount++,this._handleFragmentLoadProgress(e)}).then(e=>{if(!e)return;const t=this.state,r=e.frag;this.fragContextChanged(r)?(t===Zm||!this.fragCurrent&&t===tg)&&(this.fragmentTracker.removeFragment(r),this.state=Xm):("payload"in e&&(this.log(`Loaded ${r.type} sn: ${r.sn} of ${this.playlistLabel()} ${r.level}`),this.hls.trigger(Ou.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))}).catch(t=>{this.state!==qm&&this.state!==sg&&(this.warn(`Frag error: ${(null==t?void 0:t.message)||t}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:r}=this;if(r.getState(e)===lp){const t=e.type,i=this.getFwdBufferInfo(this.mediaBuffer,t),s=Math.max(e.duration,i?i.len:this.config.maxBufferLength),n=this.backtrackFragment;(1===(n?e.sn-n.sn:0)||this.reduceMaxBufferLength(s,e.duration))&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===cp&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}waitForLive(e){const t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,r=null){if(!(e-t))return;const i={startOffset:e,endOffset:t,type:r};this.hls.trigger(Ou.BUFFER_FLUSHING,i)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(e=>{const t=null==e?void 0:e.frag;if(!t||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return e}).then(e=>{const{hls:t}=this,{frag:r,payload:i}=e,s=r.decryptdata;if(i&&i.byteLength>0&&null!=s&&s.key&&s.iv&&Hp(s.method)){const n=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer,Vp(s.method)).catch(e=>{throw t.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e}).then(i=>{const s=self.performance.now();return t.trigger(Ou.FRAG_DECRYPTED,{frag:r,payload:i,stats:{tstart:n,tdecrypt:s}}),e.payload=i,this.completeInitSegmentLoad(e)})}return this.completeInitSegmentLoad(e)}).catch(t=>{this.state!==qm&&this.state!==sg&&(this.warn(t),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const r=e.frag.stats;this.state!==qm&&(this.state=Xm),e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(e,t){var r,i;const s=e.tracks;if(s&&!t.encrypted&&(null!=(r=s.audio)&&r.encrypted||null!=(i=s.video)&&i.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const e=this.media,r=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${e?"attached mediaKeys: "+e.mediaKeys:"detached"})`);return this.warn(r.message),!e||e.mediaKeys?!1:(this.hls.trigger(Ou.ERROR,{type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_NO_KEYS,fatal:!1,error:r,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){const r=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${r?Km(Rp.getBuffered(r)):"(detached)"})`),Eh(e)){var i;if(e.type!==zu){const t=e.elementaryStreams;if(!Object.keys(t).some(e=>!!t[e]))return void(this.state=Xm)}const t=null==(i=this.levels)?void 0:i[e.level];null!=t&&t.fragmentError&&(this.log(`Resetting level fragment error count of ${t.fragmentError} on frag buffered`),t.fragmentError=0)}this.state=Xm}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:r,part:i,partsLoaded:s}=e,n=!s||0===s.length||s.some(e=>!e),a=new Lp(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!n);t.flush(a)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,i){var s;this.fragCurrent=e;const n=t.details;if(!this.levels||!n)throw new Error(`frag load aborted, missing level${n?"":" detail"}s`);let a=null;if(!e.encrypted||null!=(s=e.decryptdata)&&s.key)e.encrypted||(a=this.keyLoader.loadClear(e,n.encryptedFragments,this.startFragRequested),a&&this.log("[eme] blocking frag load until media-keys acquired"));else if(this.log(`Loading key for ${e.sn} of [${n.startSN}-${n.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=Qm,this.fragCurrent=e,a=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(Ou.KEY_LOADED,e),this.state===Qm&&(this.state=Xm),e}),this.hls.trigger(Ou.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);const o=this.fragPrevious;if(Eh(e)&&(!o||e.sn!==o.sn)){const r=this.shouldLoadParts(t.details,e.end);r!==this.loadingParts&&(this.log(`LL-Part loading ${r?"ON":"OFF"} loading sn ${null==o?void 0:o.sn}->${e.sn}`),this.loadingParts=r)}if(r=Math.max(e.start,r||0),this.loadingParts&&Eh(e)){const s=n.partList;if(s&&i){r>n.fragmentEnd&&n.fragmentHint&&(e=n.fragmentHint);const o=this.getNextPart(s,e,r);if(o>-1){const l=s[o];let c;return e=this.fragCurrent=l.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${l.index} (${o}/${s.length-1}) of ${this.fragInfo(e,!1,l)}) cc: ${e.cc} [${n.startSN}-${n.endSN}], target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=Zm,c=a?a.then(r=>!r||this.fragContextChanged(r.frag)?null:this.doFragPartsLoad(e,l,t,i)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(e,l,t,i).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(Ou.FRAG_LOADING,{frag:e,part:l,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!e.url||this.loadedEndOfParts(s,r))return Promise.resolve(null)}}var l;if(Eh(e)&&this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${r.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${null==(l=n.partList)?void 0:l.filter(e=>e.loaded).map(e=>`[${e.start}-${e.end}]`)}`),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+n.startSN+"-"+n.endSN+"]"}, target: ${parseFloat(r.toFixed(3))}`),Ru(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Zm;const c=this.config.progressive&&e.type!==zu;let d;return d=c&&a?a.then(t=>!t||this.fragContextChanged(t.frag)?null:this.fragmentLoader.load(e,i)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,c?i:void 0),a]).then(([e])=>(!c&&i&&i(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(Ou.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,i){return new Promise((s,n)=>{var a;const o=[],l=null==(a=r.details)?void 0:a.partList,c=t=>{this.fragmentLoader.loadPart(e,t,i).then(i=>{o[t.index]=i;const n=i.part;this.hls.trigger(Ou.FRAG_LOADED,i);const a=Nm(r.details,e.sn,t.index+1)||Fm(l,e.sn,t.index+1);if(!a)return s({frag:e,part:n,partsLoaded:o});c(a)}).catch(n)};c(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===_u.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===Du.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(Ou.ERROR,t)}else this.hls.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==tg)return void(this.fragCurrent||this.state===qm||this.state===sg||(this.state=Xm));const{frag:r,part:i,level:s}=t,n=self.performance.now();r.stats.parsing.end=n,i&&(i.stats.parsing.end=n);const a=this.getLevelDetails(),o=a&&r.sn>a.endSN||this.shouldLoadParts(a,r.end);o!==this.loadingParts&&(this.log(`LL-Part loading ${o?"ON":"OFF"} after parsing segment ending @${r.end.toFixed(2)}`),this.loadingParts=o),this.updateLevelTiming(r,i,s,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var r;const s=e.partList[0];if(s.fragment.type===zu)return!1;if(t>=s.end+((null==(r=e.fragmentHint)?void 0:r.duration)||0)){var i;if((this.hls.hasEnoughToStart?(null==(i=this.media)?void 0:i.currentTime)||this.lastCurrentTime:this.getLoadPosition())>s.start-s.fragment.duration)return!0}}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:r}=this,{level:i,sn:s,part:n}=e;if(null==t||!t[i])return this.warn(`Levels object was unset while buffering fragment ${s} of ${this.playlistLabel()} ${i}. The current chunk will not be buffered.`),null;const a=t[i],o=a.details,l=n>-1?Nm(o,s,n):null,c=l?l.fragment:Mm(o,s,r);return c?(r&&r!==c&&(c.stats=r.stats),{frag:c,part:l,level:a}):null}bufferFragmentData(e,t,r,i,s){if(this.state!==tg)return;const{data1:n,data2:a}=e;let o=n;if(a&&(o=Gh(n,a)),!o.length)return;const l=this.initPTS[t.cc],c=l?-l.baseTime/l.timescale:void 0,d={type:e.type,frag:t,part:r,chunkMeta:i,offset:c,parent:t.type,data:o};if(this.hls.trigger(Ou.BUFFER_APPENDING,d),e.dropped&&e.independent&&!r){if(s)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Rp.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);const r=t.currentTime,i=Rp.bufferInfo(t,r,0),s=e.duration,n=Math.min(2*this.config.maxFragLookUpTolerance,.25*s),a=Math.max(Math.min(e.start-n,i.end-n),r+n);e.start-a>n&&this.flushMainBuffer(a,e.start)}getFwdBufferInfo(e,t){var r;const i=this.getLoadPosition();if(!Ru(i))return null;const s=this.lastCurrentTime>i||null!=(r=this.media)&&r.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,i,t,s)}getFwdBufferInfoAtPos(e,t,r,i){const s=Rp.bufferInfo(e,t,i);if(0===s.len&&void 0!==s.nextStart){const n=this.fragmentTracker.getBufferedFrag(t,r);if(n&&(s.nextStart<=n.end||n.gap)){const r=Math.max(Math.min(s.nextStart,n.end)-t,i);return Rp.bufferInfo(e,t,r)}}return s}getMaxBufferLength(e){const{config:t}=this;let r;return r=e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const r=this.config,i=Math.max(Math.min(e-t,r.maxBufferLength),t),s=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return s>=i&&(r.maxMaxBufferLength=s,this.warn(`Reduce max buffer length to ${s}s`),!0)}getAppendedFrag(e,t=Bu){const r=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){const r=t.fragments,i=r.length;if(!i)return null;const{config:s}=this,n=r[0].start,a=s.lowLatencyMode&&!!t.partList;let o=null;if(t.live){const r=s.initialLiveManifestSize;if(i<r)return this.warn(`Not enough fragments to start playback (have: ${i}, need: ${r})`),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<n){var l;a&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),o=this.getInitialLiveFragment(t);const r=this.hls.startPosition,i=this.hls.liveSyncPosition,s=o?(-1!==r&&r>=n?r:i)||o.start:e;this.log(`Setting startPosition to ${s} to match start frag at live edge. mainStart: ${r} liveSyncPosition: ${i} frag.start: ${null==(l=o)?void 0:l.start}`),this.startPosition=this.nextLoadPosition=s}}else e<=n&&(o=r[0]);if(!o){const r=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,r,t)}let c=this.filterReplacedPrimary(o,t);if(!c&&o){const e=o.sn-t.startSN;c=this.filterReplacedPrimary(r[e+1]||null,t)}return this.mapToInitFragWhenRequired(c)}isLoopLoading(e,t){const r=this.fragmentTracker.getState(e);return(r===dp||r===cp&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,i,s){let n=null;if(e.gap&&(n=this.getNextFragment(this.nextLoadPosition,t),n&&!n.gap&&r.nextStart)){const e=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i,0);if(null!==e&&r.len+e.len>=s){const e=n.sn;return this.loopSn!==e&&(this.log(`buffer full after gaps in "${i}" playlist starting at sn: ${e}`),this.loopSn=e),null}}return this.loopSn=void 0,n}get primaryPrefetch(){if(lg(this.config)){var e;if(null==(e=this.hls.interstitialsManager)||null==(e=e.playingItem)?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(lg(this.config)&&e.type!==zu){const r=this.hls.interstitialsManager,i=null==r?void 0:r.bufferingItem;if(i){const r=i.event;if(r){if(r.appendInPlace||Math.abs(e.start-i.start)>1||0===i.start)return null}else{if(e.end<=i.start&&!1===(null==t?void 0:t.live))return null;if(e.start>i.end&&i.nextEvent&&(i.nextEvent.appendInPlace||e.start-i.end>1))return null}}const s=null==r?void 0:r.playerQueue;if(s)for(let t=s.length;t--;){const r=s[t].interstitial;if(r.appendInPlace&&e.start>=r.startTime&&e.end<=r.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(e,t,r){let i=-1,s=!1,n=!0;for(let a=0,o=e.length;a<o;a++){const o=e[a];if(n=n&&!o.independent,i>-1&&r<o.start)break;const l=o.loaded;l?i=-1:(s||(o.independent||n)&&o.fragment===t)&&(o.fragment!==t&&this.warn(`Need buffer at ${r} but next unloaded part starts at ${o.start}`),i=a),s=l}return i}loadedEndOfParts(e,t){let r;for(let i=e.length;i--;){if(r=e[i],!r.loaded)return!1;if(t>r.start)return!0}return!1}getInitialLiveFragment(e){const t=e.fragments,r=this.fragPrevious;let i=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),i=function(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!Ru(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;for(let i=0;i<e.length;++i){const s=e[i];if(Gf(t,r,s))return s}return null}(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){const s=r.sn+1;if(s>=e.startSN&&s<=e.endSN){const n=t[s-e.startSN];r.cc===n.cc&&(i=n,this.log(`Live playlist, switching playlist, load frag with next SN: ${i.sn}`))}i||(i=jf(e,r.cc,r.end),i&&this.log(`Live playlist, switching playlist, load frag with same CC: ${i.sn}`))}}else{const t=this.hls.liveSyncPosition;null!==t&&(i=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i}getFragmentAtPosition(e,t,r){const{config:i}=this;let{fragPrevious:s}=this,{fragments:n,endSN:a}=r;const{fragmentHint:o}=r,{maxFragLookUpTolerance:l}=i,c=r.partList,d=!!(this.loadingParts&&null!=c&&c.length&&o);let u;if(d&&!this.bitrateTest&&c[c.length-1].fragment.sn===o.sn&&(n=n.concat(o),a=o.sn),e<t){var h;u=Uf(s,n,e,e<this.lastCurrentTime||e>t-l||null!=(h=this.media)&&h.paused||!this.startFragRequested?0:l)}else u=n[n.length-1];if(u){const e=u.sn-r.startSN,t=this.fragmentTracker.getState(u);if((t===dp||t===cp&&u.gap)&&(s=u),s&&u.sn===s.sn&&(!d||c[0].fragment.sn>u.sn||!r.live)){if(u.level===s.level){const t=n[e+1];u=u.sn<a&&this.fragmentTracker.getState(t)!==dp?t:null}}}return u}alignPlaylists(e,t,r){const i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;const s=e.fragmentStart,n=!t,a=e.alignedSliding&&Ru(s);if(n||!a&&!s){!function(e,t){e&&(Hm(t,e),t.alignedSliding||Vm(t,e),t.alignedSliding||t.skippedSegments||Dm(e,t,!1))}(r,e);const s=e.fragmentStart;return this.log(`Live playlist sliding: ${s.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${i}`),s}return s}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}setStartPosition(e,t){let r=this.startPosition;r<t&&(r=-1);const i=this.timelineOffset;if(-1===r){const s=null!==this.startTimeOffset,n=s?this.startTimeOffset:e.startTimeOffset;null!==n&&Ru(n)?(r=t+n,n<0&&(r+=e.edge),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Setting startPosition to ${r} for start time offset ${n} found in ${s?"multivariant":"media"} playlist`),this.startPosition=r):e.live?(r=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${r}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=r=0),this.lastCurrentTime=r+i}this.nextLoadPosition=r+i}getLoadPosition(){var e;const{media:t}=this;let r=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?r=t.currentTime:this.nextLoadPosition>=0&&(r=this.nextLoadPosition),r}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&Eh(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===Jm)||(this.state=Xm)}onFragmentOrKeyLoadError(e,t){var r;if(t.chunkMeta&&!t.frag){const e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}const i=t.frag;if(!i||i.type!==e||!this.levels)return;var s;if(this.fragContextChanged(i))return void this.warn(`Frag load error must match current frag to retry ${i.url} > ${null==(s=this.fragCurrent)?void 0:s.url}`);const n=t.details===_u.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,!0);const a=t.errorAction;if(!a)return void(this.state=sg);const{action:o,flags:l,retryCount:c=0,retryConfig:d}=a,u=!!d,h=u&&o===tp,f=u&&!a.resolved&&l===ip,p=null==(r=this.hls.latestLevelDetails)?void 0:r.live;if(!h&&f&&Eh(i)&&!i.endList&&p&&!Wf(t))this.resetFragmentErrors(e),this.treatAsGap(i),a.resolved=!0;else if((h||f)&&c<d.maxNumRetry){var m;const r=Qf(null==(m=t.response)?void 0:m.code),s=Kf(d,c);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+s,this.state=Jm,a.resolved=!0,r)return this.log("Waiting for connection (offline)"),this.retryDate=1/0,void(t.reason="offline");this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${c+1}/${d.maxNumRetry} in ${s}ms`)}else if(d){if(this.resetFragmentErrors(e),!(c<d.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${c})`);n||o===ep||(a.resolved=!0)}else this.state=o===Jf?ag:sg;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,r=t===1/0;(!t||e>=t||r&&!Qf(0))&&(r&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=Xm)}reduceLengthAndFlushBuffer(e){if(this.state===tg||this.state===rg){const t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),s=i&&i.len>.5;s&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);const n=!s;return n&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${r} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===Uu&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==qm&&(this.state=Xm)}afterBufferFlushed(e,t,r){if(!e)return;const i=Rp.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===ig&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==qm&&(this.state=Xm)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=this.levelLastLoaded,t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${-1===e.level?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,i){const s=r.details;if(!s)return void this.warn("level.details undefined");if(!Object.keys(e.elementaryStreams).reduce((t,n)=>{const a=e.elementaryStreams[n];if(a){const o=a.endPTS-a.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${e.sn} ${n} duration reliably (${o})`),t||!1;const l=i?0:Rm(s,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS,this);return this.hls.trigger(Ou.LEVEL_PTS_UPDATED,{details:s,level:r,drift:l,type:n,frag:e,start:a.startPTS,end:a.endPTS}),!0}return t},!1)){var n;const t=null===(null==(n=this.transmuxer)?void 0:n.error);if((0===r.fragmentError||t&&(r.fragmentError<2||e.endList))&&this.treatAsGap(e,r),t){const t=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(t.message),this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=rg,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(Ou.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===Bu?"level":"track"}fragInfo(e,t=!0,r){var i,s;return`${this.playlistLabel()} ${e.level} (${r?"part":"frag"}:[${(null!=(i=t&&!r?e.startPTS:(r||e).start)?i:NaN).toFixed(3)}-${(null!=(s=t&&!r?e.endPTS:(r||e).end)?s:NaN).toFixed(3)}]${r&&"main"===e.type?"INDEPENDENT="+(r.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}resetTransmuxer(){var e;null==(e=this.transmuxer)||e.reset()}recoverWorkerError(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function lg(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}class cg{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let r;return e.length?(r=1===e.length?e[0]:function(e,t){const r=new Uint8Array(t);let i=0;for(let t=0;t<e.length;t++){const s=e[t];r.set(s,i),i+=s.length}return r}(e,t),this.reset(),r):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}var dg,ug={exports:{}};var hg=(dg||(dg=1,function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function n(e,t,i,n,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new s(i,n||e,a),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function a(e,t){0===--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,s=[];if(0===this._eventsCount)return s;for(i in e=this._events)t.call(e,i)&&s.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var s=0,n=i.length,a=new Array(n);s<n;s++)a[s]=i[s].fn;return a},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,s,n,a){var o=r?r+e:e;if(!this._events[o])return!1;var l,c,d=this._events[o],u=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),u){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,s),!0;case 5:return d.fn.call(d.context,t,i,s,n),!0;case 6:return d.fn.call(d.context,t,i,s,n,a),!0}for(c=1,l=new Array(u-1);c<u;c++)l[c-1]=arguments[c];d.fn.apply(d.context,l)}else{var h,f=d.length;for(c=0;c<f;c++)switch(d[c].once&&this.removeListener(e,d[c].fn,void 0,!0),u){case 1:d[c].fn.call(d[c].context);break;case 2:d[c].fn.call(d[c].context,t);break;case 3:d[c].fn.call(d[c].context,t,i);break;case 4:d[c].fn.call(d[c].context,t,i,s);break;default:if(!l)for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];d[c].fn.apply(d[c].context,l)}}return!0},o.prototype.on=function(e,t,r){return n(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return n(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,s){var n=r?r+e:e;if(!this._events[n])return this;if(!t)return a(this,n),this;var o=this._events[n];if(o.fn)o.fn!==t||s&&!o.once||i&&o.context!==i||a(this,n);else{for(var l=0,c=[],d=o.length;l<d;l++)(o[l].fn!==t||s&&!o[l].once||i&&o[l].context!==i)&&c.push(o[l]);c.length?this._events[n]=1===c.length?c[0]:c:a(this,n)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(ug)),ug.exports),fg=ah(hg);const pg="1.6.15",mg={};function gg(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function vg(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function yg(e,t){let r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3],r}function bg(e,t){const r=t;let i=0;for(;vg(e,t);){i+=10;i+=yg(e,t+6),gg(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(r,r+i)}function Eg(e,t){return 255===e[t]&&240==(246&e[t+1])}function wg(e,t){return 1&e[t+1]?7:9}function Sg(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Tg(e,t){return t+1<e.length&&Eg(e,t)}function xg(e,t){if(Tg(e,t)){const r=wg(e,t);if(t+r>=e.length)return!1;const i=Sg(e,t);if(i<=r)return!1;const s=t+i;return s===e.length||Tg(e,s)}return!1}function Ag(e,t,r,i,s){if(!e.samplerate){const n=function(e,t,r,i){const s=t[r+2],n=s>>2&15;if(n>12){const t=new Error(`invalid ADTS sampling index:${n}`);return void e.emit(Ou.ERROR,Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.FRAG_PARSING_ERROR,fatal:!0,error:t,reason:t.message})}const a=1+(s>>6&3),o=t[r+3]>>6&3|(1&s)<<2,l="mp4a.40."+a,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][n];let d=n;5!==a&&29!==a||(d-=3);const u=[a<<3|(14&d)>>1,(1&d)<<7|o<<3];return eh.log(`manifest codec:${i}, parsed codec:${l}, channels:${o}, rate:${c} (ADTS object type:${a} sampling index:${n})`),{config:u,samplerate:c,channelCount:o,codec:l,parsedCodec:l,manifestCodec:i}}(t,r,i,s);if(!n)return;Vu(e,n)}}function kg(e){return 9216e4/e}function Lg(e,t,r,i,s){const n=i+s*kg(e.samplerate),a=function(e,t){const r=wg(e,t);if(t+r<=e.length){const i=Sg(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);let o;if(a){const{frameLength:i,headerLength:s}=a,l=s+i,c=Math.max(0,r+l-t.length);c?(o=new Uint8Array(l-s),o.set(t.subarray(r+s,t.length),0)):o=t.subarray(r+s,r+l);const d={unit:o,pts:n};return c||e.samples.push(d),{sample:d,length:l,missing:c}}const l=t.length-r;o=new Uint8Array(l),o.set(t.subarray(r,t.length),0);return{sample:{unit:o,pts:n},length:l,missing:-1}}function Ig(e,t){return vg(e,t)&&yg(e,t+6)+10<=e.length-t}function Rg(e,t=0,r=1/0){return function(e,t,r,i){const s=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e);let n=1;"BYTES_PER_ELEMENT"in i&&(n=i.BYTES_PER_ELEMENT);const a=(u=e,u&&u.buffer instanceof ArrayBuffer&&void 0!==u.byteLength&&void 0!==u.byteOffset?e.byteOffset:0),o=(a+e.byteLength)/n,l=(a+t)/n,c=Math.floor(Math.max(0,Math.min(l,o))),d=Math.floor(Math.min(c+Math.max(r,0),o));var u;return new i(s,c,d-c)}(e,t,r,Uint8Array)}function Pg(e){const t={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(e.size<2)return;if(3!==e.data[0])return void console.log("Ignore frame with unrecognized character encoding");const r=e.data.subarray(1).indexOf(0);if(-1===r)return;const i=ih(Rg(e.data,1,r)),s=e.data[2+r],n=e.data.subarray(3+r).indexOf(0);if(-1===n)return;const a=ih(Rg(e.data,3+r,n));let o;return o="--\x3e"===i?ih(Rg(e.data,4+r+n)):function(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}(e.data.subarray(4+r+n)),t.mimeType=i,t.pictureType=s,t.description=a,t.data=o,t}function Cg(e){return"PRIV"===e.type?function(e){if(e.size<2)return;const t=ih(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;let t=1;const r=ih(e.data.subarray(t),!0);t+=r.length+1;const i=ih(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=ih(e.data);return{key:e.type,info:"",data:t}}(e):"APIC"===e.type?Pg(e):function(e){if(e.size<2)return;if("TXXX"===e.type){let t=1;const r=ih(e.data.subarray(t),!0);t+=r.length+1;const i=ih(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=ih(e.data.subarray(1));return{key:e.type,info:"",data:t}}(e)}function Dg(e){const t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=yg(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}function _g(e){let t=0;const r=[];for(;vg(e,t);){const i=yg(e,t+6);e[t+5]>>6&1&&(t+=10),t+=10;const s=t+i;for(;t+10<s;){const i=Dg(e.subarray(t)),s=Cg(i);s&&r.push(s),t+=i.size+10}gg(e,t)&&(t+=10)}return r}function Og(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function Mg(e){if(8===e.data.byteLength){const t=new Uint8Array(e.data),r=1&t[3];let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}}function Ng(e){const t=_g(e);for(let e=0;e<t.length;e++){const r=t[e];if(Og(r))return Mg(r)}}let Fg=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function $g(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class Bg{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=Gh(this.cachedData,e),this.cachedData=null);let r,i=bg(e,0),s=i?i.length:0;const n=this._audioTrack,a=this._id3Track,o=i?Ng(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&Ru(o))&&(this.basePTS=Ug(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Fg.audioId3,duration:Number.POSITIVE_INFINITY});s<l;){if(this.canParse(e,s)){const t=this.appendFrame(n,e,s);t?(this.frameIndex++,this.lastPTS=t.sample.pts,s+=t.length,r=s):s=l}else Ig(e,s)?(i=bg(e,s),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Fg.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,r=s):s++;if(s===l&&r!==l){const t=e.slice(r);this.cachedData?this.cachedData=Gh(this.cachedData,t):this.cachedData=t}}return{audioTrack:n,videoTrack:$g(),id3Track:a,textTrack:$g()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:$g(),id3Track:this._id3Track,textTrack:$g()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const Ug=(e,t,r)=>{if(Ru(e))return 90*e;return 9e4*t+(r?9e4*r.baseTime/r.timescale:0)};let zg=null;const Gg=[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],jg=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Hg=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Vg=[0,1,1,4];function Wg(e,t,r,i,s){if(r+24>t.length)return;const n=Yg(t,r);if(n&&r+n.frameLength<=t.length){const a=i+s*(9e4*n.samplesPerFrame/n.sampleRate),o={unit:t.subarray(r,r+n.frameLength),pts:a,dts:a};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(o),{sample:o,length:n.frameLength,missing:0}}}function Yg(e,t){const r=e[t+1]>>3&3,i=e[t+1]>>1&3,s=e[t+2]>>4&15,n=e[t+2]>>2&3;if(1!==r&&0!==s&&15!==s&&3!==n){const a=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*Gg[14*(3===r?3-i:3===i?3:4)+s-1],c=jg[3*(3===r?0:2===r?1:2)+n],d=3===o?1:2,u=Hg[r][i],h=Vg[i],f=8*u*h,p=Math.floor(u*l/c+a)*h;if(null===zg){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);zg=e?parseInt(e[1]):0}return!!zg&&zg<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:c,channelCount:d,frameLength:p,samplesPerFrame:f}}}function Kg(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function qg(e,t){return t+1<e.length&&Kg(e,t)}function Xg(e,t){if(t+1<e.length&&Kg(e,t)){const r=4,i=Yg(e,t);let s=r;null!=i&&i.frameLength&&(s=i.frameLength);const n=t+s;return n===e.length||qg(e,n)}return!1}const Qg=(e,t)=>{let r=0,i=5;t+=i;const s=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=e[t];const o=Math.min(i,8),l=8-o;n[0]=4278190080>>>24+l<<l,s[0]=(a[0]&n[0])>>l,r=r?r<<o|s[0]:s[0],t+=1,i-=o}return r};class Zg extends Bg{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,r){const i=Jg(e,t,r,this.basePTS,this.frameIndex);if(-1!==i){return{sample:e.samples[e.samples.length-1],length:i,missing:0}}}static probe(e){if(!e)return!1;const t=bg(e,0);if(!t)return!1;const r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==Ng(t)&&Qg(e,r)<16}}function Jg(e,t,r,i,s){if(r+8>t.length)return-1;if(11!==t[r]||119!==t[r+1])return-1;const n=t[r+4]>>6;if(n>=3)return-1;const a=[48e3,44100,32e3][n],o=63&t[r+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+n];if(r+l>t.length)return-1;const c=t[r+6]>>5;let d=0;2===c?d+=2:(1&c&&1!==c&&(d+=2),4&c&&(d+=2));const u=(t[r+6]<<8|t[r+7])>>12-d&1,h=[2,1,2,3,3,4,4,5][c]+u,f=t[r+5]>>3,p=7&t[r+5],m=new Uint8Array([n<<6|f<<1|p>>2,(3&p)<<6|c<<3|u<<2|o>>4,o<<4&224]),g=i+s*(1536/a*9e4),v=t.subarray(r,r+l);return e.config=m,e.channelCount=h,e.samplerate=a,e.samples.push({unit:v,pts:g}),l}const ev=/\/emsg[-/]ID3/i;function tv(e,t){return Ru(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}class rv{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Ep(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,mp)}decryptAacSample(e,t,r){const i=e[t].unit;if(i.length<=16)return;const s=i.subarray(16,i.length-i.length%16),n=s.buffer.slice(s.byteOffset,s.byteOffset+s.length);this.decryptBuffer(n).then(s=>{const n=new Uint8Array(s);i.set(n,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)}).catch(r)}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)r.set(e.subarray(t,t+16),i);return r}getAvcDecryptedUnit(e,t){const r=new Uint8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)e.set(r.subarray(i,i+16),t);return e}decryptAvcSample(e,t,r,i,s){const n=Yh(s.data),a=this.getAvcEncryptedData(n);this.decryptBuffer(a.buffer).then(a=>{s.data=this.getAvcDecryptedUnit(n,a),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,i)}).catch(i)}decryptAvcSamples(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();const s=e[t].units;for(;!(r>=s.length);r++){const n=s[r];if(!(n.data.length<=48||1!==n.type&&5!==n.type||(this.decryptAvcSample(e,t,r,i,n),this.decrypter.isSync())))return}}}}class iv{constructor(){this.VideoSample=null}createVideoSample(e,t,r){return{key:e,frame:!1,pts:t,dts:r,units:[],length:0}}getLastNalUnit(e){var t;let r,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){const e=i.units;r=e[e.length-1]}return r}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){const r=t.samples,i=r.length;if(!i)return void t.dropped++;{const t=r[i-1];e.pts=t.pts,e.dts=t.dts}}t.samples.push(e)}}parseNALu(e,t,r){const i=t.byteLength;let s=e.naluState||0;const n=s,a=[];let o,l,c,d=0,u=-1,h=0;for(-1===s&&(u=0,h=this.getNALuType(t,0),s=0,d=1);d<i;)if(o=t[d++],s)if(1!==s)if(o)if(1===o){if(l=d-s-1,u>=0){const e={data:t.subarray(u,l),type:h};a.push(e)}else{const r=this.getLastNalUnit(e.samples);r&&(n&&d<=4-n&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-n)),l>0&&(r.data=Gh(r.data,t.subarray(0,l)),r.state=0))}d<i?(c=this.getNALuType(t,d),u=d,h=c,s=0):s=-1}else s=0;else s=3;else s=o?0:2;else s=o?0:1;if(u>=0&&s>=0){const e={data:t.subarray(u,i),type:h,state:s};a.push(e)}if(0===a.length){const r=this.getLastNalUnit(e.samples);r&&(r.data=Gh(r.data,t))}return e.naluState=s,a}}class sv{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),s=Math.min(4,t);if(0===s)throw new Error("no bytes available");i.set(e.subarray(r,r+s)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*s,this.bytesAvailable-=s}skipBits(e){let t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(t=(e-=this.bitsAvailable)>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const r=this.word>>>32-t;if(e>32&&eh.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class nv extends iv{parsePES(e,t,r,i){const s=this.parseNALu(e,r.data,i);let n,a=this.VideoSample,o=!1;r.data=null,a&&s.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),s.forEach(i=>{var s,l;switch(i.type){case 1:{let t=!1;n=!0;const s=i.data;if(o&&s.length>4){const e=this.readSliceType(s);2!==e&&4!==e&&7!==e&&9!==e||(t=!0)}var c;if(t)null!=(c=a)&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.frame=!0,a.key=t;break}case 5:n=!0,null!=(s=a)&&s.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0,a.frame=!0;break;case 6:n=!0,Wh(i.data,1,r.pts,t.samples);break;case 7:{var d,u;n=!0,o=!0;const t=i.data,r=this.readSPS(t);if(!e.sps||e.width!==r.width||e.height!==r.height||(null==(d=e.pixelRatio)?void 0:d[0])!==r.pixelRatio[0]||(null==(u=e.pixelRatio)?void 0:u[1])!==r.pixelRatio[1]){e.width=r.width,e.height=r.height,e.pixelRatio=r.pixelRatio,e.sps=[t];const i=t.subarray(1,4);let s="avc1.";for(let e=0;e<3;e++){let t=i[e].toString(16);t.length<2&&(t="0"+t),s+=t}e.codec=s}break}case 8:n=!0,e.pps=[i.data];break;case 9:n=!0,e.audFound=!0,null!=(l=a)&&l.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts));break;case 12:n=!0;break;default:n=!1}if(a&&n){a.units.push(i)}}),i&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}getNALuType(e,t){return 31&e[t]}readSliceType(e){const t=new sv(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let r,i=8,s=8;for(let n=0;n<e;n++)0!==s&&(r=t.readEG(),s=(i+r+256)%256),i=0===s?i:s}readSPS(e){const t=new sv(e);let r,i,s,n=0,a=0,o=0,l=0;const c=t.readUByte.bind(t),d=t.readBits.bind(t),u=t.readUEG.bind(t),h=t.readBoolean.bind(t),f=t.skipBits.bind(t),p=t.skipEG.bind(t),m=t.skipUEG.bind(t),g=this.skipScalingList.bind(this);c();const v=c();if(d(5),f(3),c(),m(),100===v||110===v||122===v||244===v||44===v||83===v||86===v||118===v||128===v){const e=u();if(3===e&&f(1),m(),m(),f(1),h())for(i=3!==e?8:12,s=0;s<i;s++)h()&&g(s<6?16:64,t)}m();const y=u();if(0===y)u();else if(1===y)for(f(1),p(),p(),r=u(),s=0;s<r;s++)p();m(),f(1);const b=u(),E=u(),w=d(1);0===w&&f(1),f(1),h()&&(n=u(),a=u(),o=u(),l=u());let S=[1,1];if(h()&&h()){switch(c()){case 1:S=[1,1];break;case 2:S=[12,11];break;case 3:S=[10,11];break;case 4:S=[16,11];break;case 5:S=[40,33];break;case 6:S=[24,11];break;case 7:S=[20,11];break;case 8:S=[32,11];break;case 9:S=[80,33];break;case 10:S=[18,11];break;case 11:S=[15,11];break;case 12:S=[64,33];break;case 13:S=[160,99];break;case 14:S=[4,3];break;case 15:S=[3,2];break;case 16:S=[2,1];break;case 255:S=[c()<<8|c(),c()<<8|c()]}}return{width:Math.ceil(16*(b+1)-2*n-2*a),height:(2-w)*(E+1)*16-(w?2:4)*(o+l),pixelRatio:S}}}class av extends iv{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,r,i){const s=this.parseNALu(e,r.data,i);let n,a=this.VideoSample,o=!1;r.data=null,a&&s.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),s.forEach(i=>{var s,l;switch(i.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:a||(a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),a.frame=!0,n=!0;break;case 16:case 17:case 18:case 21:var c;if(n=!0,o)null!=(c=a)&&c.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null);a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0,a.frame=!0;break;case 19:case 20:n=!0,null!=(s=a)&&s.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0,a.frame=!0;break;case 39:n=!0,Wh(i.data,2,r.pts,t.samples);break;case 32:n=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=Vu(e.params,this.readVPS(i.data)),this.initVPS=i.data),e.vps=[i.data];break;case 33:if(n=!0,o=!0,void 0===e.vps||e.vps[0]===this.initVPS||void 0===e.sps||this.matchSPS(e.sps[0],i.data)||(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const t=this.readSPS(i.data);e.width=t.width,e.height=t.height,e.pixelRatio=t.pixelRatio,e.codec=t.codecString,e.sps=[],"object"!=typeof e.params&&(e.params={});for(const r in t.params)e.params[r]=t.params[r]}this.pushParameterSet(e.sps,i.data,e.vps),a||(a=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts)),a.key=!0;break;case 34:if(n=!0,"object"==typeof e.params){if(!e.pps){e.pps=[];const t=this.readPPS(i.data);for(const r in t)e.params[r]=t[r]}this.pushParameterSet(e.pps,i.data,e.vps)}break;case 35:n=!0,e.audFound=!0,null!=(l=a)&&l.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts));break;default:n=!1}if(a&&n){a.units.push(i)}}),i&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}pushParameterSet(e,t,r){(r&&r[0]===this.initVPS||!r&&!e.length)&&e.push(t)}getNALuType(e,t){return(126&e[t])>>>1}ebsp2rbsp(e){const t=new Uint8Array(e.byteLength);let r=0;for(let i=0;i<e.byteLength;i++)i>=2&&3===e[i]&&0===e[i-1]&&0===e[i-2]||(t[r]=e[i],r++);return new Uint8Array(t.buffer,0,r)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){const t=new sv(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);return{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}}readSPS(e){const t=new sv(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const r=t.readBits(3);t.readBoolean();const i=t.readBits(2),s=t.readBoolean(),n=t.readBits(5),a=t.readUByte(),o=t.readUByte(),l=t.readUByte(),c=t.readUByte(),d=t.readUByte(),u=t.readUByte(),h=t.readUByte(),f=t.readUByte(),p=t.readUByte(),m=t.readUByte(),g=t.readUByte(),v=[],y=[];for(let e=0;e<r;e++)v.push(t.readBoolean()),y.push(t.readBoolean());if(r>0)for(let e=r;e<8;e++)t.readBits(2);for(let e=0;e<r;e++)v[e]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),y[e]&&t.readUByte();t.readUEG();const b=t.readUEG();3==b&&t.skipBits(1);const E=t.readUEG(),w=t.readUEG(),S=t.readBoolean();let T=0,x=0,A=0,k=0;S&&(T+=t.readUEG(),x+=t.readUEG(),A+=t.readUEG(),k+=t.readUEG());const L=t.readUEG(),I=t.readUEG(),R=t.readUEG();for(let e=t.readBoolean()?0:r;e<=r;e++)t.skipUEG(),t.skipUEG(),t.skipUEG();t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.readBoolean()){if(t.readBoolean())for(let e=0;e<4;e++)for(let r=0;r<(3===e?2:6);r++){if(t.readBoolean()){const r=Math.min(64,1<<4+(e<<1));e>1&&t.readEG();for(let e=0;e<r;e++)t.readEG()}else t.readUEG()}}t.readBoolean(),t.readBoolean();t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const P=t.readUEG();let C=0;for(let e=0;e<P;e++){let r=!1;if(0!==e&&(r=t.readBoolean()),r){e===P&&t.readUEG(),t.readBoolean(),t.readUEG();let r=0;for(let e=0;e<=C;e++){const e=t.readBoolean();let i=!1;e||(i=t.readBoolean()),(e||i)&&r++}C=r}else{const e=t.readUEG(),r=t.readUEG();C=e+r;for(let r=0;r<e;r++)t.readUEG(),t.readBoolean();for(let e=0;e<r;e++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const e=t.readUEG();for(let r=0;r<e;r++){for(let e=0;e<R+4;e++)t.readBits(1);t.readBits(1)}}let D=0,_=1,O=1,M=!0,N=1,F=0;t.readBoolean(),t.readBoolean();let $=!1;if(t.readBoolean()){if(t.readBoolean()){const e=t.readUByte();e>0&&e<16?(_=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][e-1],O=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][e-1]):255===e&&(_=t.readBits(16),O=t.readBits(16))}t.readBoolean()&&t.readBoolean();if(t.readBoolean()){t.readBits(3),t.readBoolean();t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())}t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),$=t.readBoolean(),$&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG());if(t.readBoolean()){N=t.readBits(32),F=t.readBits(32);t.readBoolean()&&t.readUEG();if(t.readBoolean()){const e=t.readBoolean(),i=t.readBoolean();let s=!1;(e||i)&&(s=t.readBoolean(),s&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),s&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let n=0;n<=r;n++){M=t.readBoolean();let r=!1;M||t.readBoolean()?t.readEG():r=t.readBoolean();const n=r?1:t.readUEG()+1;if(e)for(let e=0;e<n;e++)t.readUEG(),t.readUEG(),s&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(i)for(let e=0;e<n;e++)t.readUEG(),t.readUEG(),s&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),D=t.readUEG())}let B=E,U=w;if(S){let e=1,t=1;1===b?e=t=2:2==b&&(e=2),B=E-e*x-e*T,U=w-t*k-t*A}const z=i?["A","B","C"][i]:"",G=a<<24|o<<16|l<<8|c;let j=0;for(let e=0;e<32;e++)j=(j|(G>>e&1)<<31-e)>>>0;let H=j.toString(16);1===n&&"2"===H&&(H="6");return{codecString:`hvc1.${z}${n}.${H}.${s?"H":"L"}${g}.B0`,params:{general_tier_flag:s,general_profile_idc:n,general_profile_space:i,general_profile_compatibility_flags:[a,o,l,c],general_constraint_indicator_flags:[d,u,h,f,p,m],general_level_idc:g,bit_depth:L+8,bit_depth_luma_minus8:L,bit_depth_chroma_minus8:I,min_spatial_segmentation_idc:D,chroma_format_idc:b,frame_rate:{fixed:M,fps:F/N}},width:B,height:U,pixelRatio:[_,O]}}readPPS(e){const t=new sv(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2);t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);const r=t.readBoolean(),i=t.readBoolean();let s=1;return i&&r?s=0:i?s=3:r&&(s=2),{parallelismType:s}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const ov=188;class lv{constructor(e,t,r,i){this.logger=void 0,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._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.logger=i,this.videoParser=null}static probe(e,t){const r=lv.syncOffset(e);return r>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${r}`),-1!==r}static syncOffset(e){const t=e.length;let r=Math.min(940,t-ov)+1,i=0;for(;i<r;){let s=!1,n=-1,a=0;for(let o=i;o<t;o+=ov){if(71!==e[o]||t-o!==ov&&71!==e[o+ov]){if(a)return-1;break}if(a++,-1===n&&(n=o,0!==n&&(r=Math.min(n+18612,e.length-ov)+1)),s||(s=0===cv(e,o)),s&&a>1&&(0===n&&a>2||o+ov>r))return n}i++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:kh[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=lv.createTrack("video"),this._videoTrack.duration=i,this._audioTrack=lv.createTrack("audio",i),this._id3Track=lv.createTrack("id3"),this._txtTrack=lv.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,r=!1,i=!1){let s;r||(this.sampleAes=null);const n=this._videoTrack,a=this._audioTrack,o=this._id3Track,l=this._txtTrack;let c=n.pid,d=n.pesData,u=a.pid,h=o.pid,f=a.pesData,p=o.pesData,m=null,g=this.pmtParsed,v=this._pmtId,y=e.length;if(this.remainderData&&(y=(e=Gh(this.remainderData,e)).length,this.remainderData=null),y<ov&&!i)return this.remainderData=e,{audioTrack:a,videoTrack:n,id3Track:o,textTrack:l};const b=Math.max(0,lv.syncOffset(e));y-=(y-b)%ov,y<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,y,e.buffer.byteLength-y));let E=0;for(let t=b;t<y;t+=ov)if(71===e[t]){const i=!!(64&e[t+1]),y=cv(e,t);let E;if((48&e[t+3])>>4>1){if(E=t+5+e[t+4],E===t+ov)continue}else E=t+4;switch(y){case c:i&&(d&&(s=pv(d,this.logger))&&(this.readyVideoParser(n.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(n,l,s,!1)),d={data:[],size:0}),d&&(d.data.push(e.subarray(E,t+ov)),d.size+=t+ov-E);break;case u:if(i){if(f&&(s=pv(f,this.logger)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,s);break;case"mp3":this.parseMPEGPES(a,s);break;case"ac3":this.parseAC3PES(a,s)}f={data:[],size:0}}f&&(f.data.push(e.subarray(E,t+ov)),f.size+=t+ov-E);break;case h:i&&(p&&(s=pv(p,this.logger))&&this.parseID3PES(o,s),p={data:[],size:0}),p&&(p.data.push(e.subarray(E,t+ov)),p.size+=t+ov-E);break;case 0:i&&(E+=e[E]+1),v=this._pmtId=dv(e,E);break;case v:{i&&(E+=e[E]+1);const s=uv(e,E,this.typeSupported,r,this.observer,this.logger);c=s.videoPid,c>0&&(n.pid=c,n.segmentCodec=s.segmentVideoCodec),u=s.audioPid,u>0&&(a.pid=u,a.segmentCodec=s.segmentAudioCodec),h=s.id3Pid,h>0&&(o.pid=h),null===m||g||(this.logger.warn(`MPEG-TS PMT found at ${t} after unknown PID '${m}'. Backtracking to sync byte @${b} to parse all TS packets.`),m=null,t=b-188),g=this.pmtParsed=!0;break}case 17:case 8191:break;default:m=y}}else E++;E>0&&hv(this.observer,new Error(`Found ${E} TS packet/s that do not start with 0x47`),void 0,this.logger),n.pesData=d,a.pesData=f,o.pesData=p;const w={audioTrack:a,videoTrack:n,id3Track:o,textTrack:l};return i&&this.extractRemainingSamples(w),w}flush(){const{remainderData:e}=this;let t;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:r,id3Track:i,textTrack:s}=e,n=r.pesData,a=t.pesData,o=i.pesData;let l;if(n&&(l=pv(n,this.logger))?(this.readyVideoParser(r.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(r,s,l,!0),r.pesData=null)):r.pesData=n,a&&(l=pv(a,this.logger))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,l);break;case"mp3":this.parseMPEGPES(t,l);break;case"ac3":this.parseAC3PES(t,l)}t.pesData=null}else null!=a&&a.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=a;o&&(l=pv(o,this.logger))?(this.parseID3PES(i,l),i.pesData=null):i.pesData=o}demuxSampleAes(e,t,r){const i=this.demux(e,r,!0,!this.config.progressive),s=this.sampleAes=new rv(this.observer,this.config,t);return this.decrypt(i,s)}readyVideoParser(e){null===this.videoParser&&("avc"===e?this.videoParser=new nv:"hevc"===e&&(this.videoParser=new av))}decrypt(e,t){return new Promise(r=>{const{audioTrack:i,videoTrack:s}=e;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,()=>{s.samples?t.decryptAvcSamples(s.samples,0,0,()=>{r(e)}):r(e)}):s.samples&&t.decryptAvcSamples(s.samples,0,0,()=>{r(e)})})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}parseAACPES(e,t){let r=0;const i=this.aacOverFlow;let s,n,a,o=t.data;if(i){this.aacOverFlow=null;const t=i.missing,s=i.sample.unit.byteLength;if(-1===t)o=Gh(i.sample.unit,o);else{const n=s-t;i.sample.unit.set(o.subarray(0,t),n),e.samples.push(i.sample),r=i.missing}}for(s=r,n=o.length;s<n-1&&!Tg(o,s);s++);if(s!==r){let e;const t=s<n-1;if(e=t?`AAC PES did not start with ADTS header,offset:${s}`:"No ADTS header found in AAC PES",hv(this.observer,new Error(e),t,this.logger),!t)return}if(Ag(e,this.observer,o,s,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!i)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");{const t=kg(e.samplerate);a=i.sample.pts+t}}let l,c=0;for(;s<n;){if(l=Lg(e,o,s,a,c),s+=l.length,l.missing){this.aacOverFlow=l;break}for(c++;s<n-1&&!Tg(o,s);s++);}}parseMPEGPES(e,t){const r=t.data,i=r.length;let s=0,n=0;const a=t.pts;if(void 0!==a)for(;n<i;)if(qg(r,n)){const t=Wg(e,r,n,a,s);if(!t)break;n+=t.length,s++}else n++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseAC3PES(e,t){{const r=t.data,i=t.pts;if(void 0===i)return void this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");const s=r.length;let n,a=0,o=0;for(;o<s&&(n=Jg(e,r,o,i,a++))>0;)o+=n}}parseID3PES(e,t){if(void 0===t.pts)return void this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");const r=Vu({},t,{type:this._videoTrack?Fg.emsg:Fg.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}}function cv(e,t){return((31&e[t+1])<<8)+e[t+2]}function dv(e,t){return(31&e[t+10])<<8|e[t+11]}function uv(e,t,r,i,s,n){const a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<o;){const o=cv(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){fv("ADTS AAC",n);break}case 15:-1===a.audioPid&&(a.audioPid=o);break;case 21:-1===a.id3Pid&&(a.id3Pid=o);break;case 219:if(!i){fv("H.264",n);break}case 27:-1===a.videoPid&&(a.videoPid=o);break;case 3:case 4:r.mpeg||r.mp3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="mp3"):n.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){fv("AC-3",n);break}case 129:r.ac3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="ac3"):n.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===a.audioPid&&l>0){let i=t+5,s=l;for(;s>2;){if(106===e[i])!0!==r.ac3?n.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=o,a.segmentAudioCodec="ac3");const t=e[i+1]+2;i+=t,s-=t}}break;case 194:case 135:return hv(s,new Error("Unsupported EC-3 in M2TS found"),void 0,n),a;case 36:-1===a.videoPid&&(a.videoPid=o,a.segmentVideoCodec="hevc",n.log("HEVC in M2TS found"))}t+=l+5}return a}function hv(e,t,r,i){i.warn(`parsing error: ${t.message}`),e.emit(Ou.ERROR,Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function fv(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function pv(e,t){let r,i,s,n,a,o=0;const l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=Gh(l[0],l[1]),l.splice(1,1);r=l[0];if(1===(r[0]<<16)+(r[1]<<8)+r[2]){if(i=(r[4]<<8)+r[5],i&&i>e.size-6)return null;const c=r[7];192&c&&(n=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&c?(a=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2,n-a>54e5&&(t.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=r[8];let d=s+9;if(e.size<=d)return null;e.size-=d;const u=new Uint8Array(e.size);for(let e=0,t=l.length;e<t;e++){r=l[e];let t=r.byteLength;if(d){if(d>t){d-=t;continue}r=r.subarray(d),t-=d,d=0}u.set(r,o),o+=t}return i&&(i-=s+3),{data:u,pts:n,dts:a,len:i}}return null}class mv{static getSilentFrame(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}const gv=Math.pow(2,32)-1;class vv{static init(){let e;for(e in vv.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},vv.types)vv.types.hasOwnProperty(e)&&(vv.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=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]),r=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]);vv.HDLR_TYPES={video:t,audio:r};const i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);vv.STTS=vv.STSC=vv.STCO=s,vv.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),vv.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),vv.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),vv.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const n=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),o=new Uint8Array([0,0,0,1]);vv.FTYP=vv.box(vv.types.ftyp,n,o,n,a),vv.DINF=vv.box(vv.types.dinf,vv.box(vv.types.dref,i))}static box(e,...t){let r=8,i=t.length;const s=i;for(;i--;)r+=t[i].byteLength;const n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=255&r,n.set(e,4),i=0,r=8;i<s;i++)n.set(t[i],r),r+=t[i].byteLength;return n}static hdlr(e){return vv.box(vv.types.hdlr,vv.HDLR_TYPES[e])}static mdat(e){return vv.box(vv.types.mdat,e)}static mdhd(e,t){t*=e;const r=Math.floor(t/(gv+1)),i=Math.floor(t%(gv+1));return vv.box(vv.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))}static mdia(e){return vv.box(vv.types.mdia,vv.mdhd(e.timescale||0,e.duration||0),vv.hdlr(e.type),vv.minf(e))}static mfhd(e){return vv.box(vv.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?vv.box(vv.types.minf,vv.box(vv.types.smhd,vv.SMHD),vv.DINF,vv.stbl(e)):vv.box(vv.types.minf,vv.box(vv.types.vmhd,vv.VMHD),vv.DINF,vv.stbl(e))}static moof(e,t,r){return vv.box(vv.types.moof,vv.mfhd(e),vv.traf(r,t))}static moov(e){let t=e.length;const r=[];for(;t--;)r[t]=vv.trak(e[t]);return vv.box.apply(null,[vv.types.moov,vv.mvhd(e[0].timescale||0,e[0].duration||0)].concat(r).concat(vv.mvex(e)))}static mvex(e){let t=e.length;const r=[];for(;t--;)r[t]=vv.trex(e[t]);return vv.box.apply(null,[vv.types.mvex,...r])}static mvhd(e,t){t*=e;const r=Math.floor(t/(gv+1)),i=Math.floor(t%(gv+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return vv.box(vv.types.mvhd,s)}static sdtp(e){const t=e.samples||[],r=new Uint8Array(4+t.length);let i,s;for(i=0;i<t.length;i++)s=t[i].flags,r[i+4]=s.dependsOn<<4|s.isDependedOn<<2|s.hasRedundancy;return vv.box(vv.types.sdtp,r)}static stbl(e){return vv.box(vv.types.stbl,vv.stsd(e),vv.box(vv.types.stts,vv.STTS),vv.box(vv.types.stsc,vv.STSC),vv.box(vv.types.stsz,vv.STSZ),vv.box(vv.types.stco,vv.STCO))}static avc1(e){let t,r,i,s=[],n=[];for(t=0;t<e.sps.length;t++)r=e.sps[t],i=r.byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(r));for(t=0;t<e.pps.length;t++)r=e.pps[t],i=r.byteLength,n.push(i>>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(r));const a=vv.box(vv.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|e.sps.length].concat(s).concat([e.pps.length]).concat(n))),o=e.width,l=e.height,c=e.pixelRatio[0],d=e.pixelRatio[1];return vv.box(vv.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a,vv.box(vv.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),vv.box(vv.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d])))}static esds(e){const t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}static audioStsd(e){const t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,255&t,0,0])}static mp4a(e){return vv.box(vv.types.mp4a,vv.audioStsd(e),vv.box(vv.types.esds,vv.esds(e)))}static mp3(e){return vv.box(vv.types[".mp3"],vv.audioStsd(e))}static ac3(e){return vv.box(vv.types["ac-3"],vv.audioStsd(e),vv.box(vv.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if("audio"===e.type){if("aac"===t)return vv.box(vv.types.stsd,vv.STSD,vv.mp4a(e));if("ac3"===t&&e.config)return vv.box(vv.types.stsd,vv.STSD,vv.ac3(e));if("mp3"===t&&"mp3"===e.codec)return vv.box(vv.types.stsd,vv.STSD,vv.mp3(e))}else{if(!e.pps||!e.sps)throw new Error("video track missing pps or sps");if("avc"===t)return vv.box(vv.types.stsd,vv.STSD,vv.avc1(e));if("hevc"===t&&e.vps)return vv.box(vv.types.stsd,vv.STSD,vv.hvc1(e))}throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){const t=e.id,r=(e.duration||0)*(e.timescale||0),i=e.width||0,s=e.height||0,n=Math.floor(r/(gv+1)),a=Math.floor(r%(gv+1));return vv.box(vv.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,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,s>>8&255,255&s,0,0]))}static traf(e,t){const r=vv.sdtp(e),i=e.id,s=Math.floor(t/(gv+1)),n=Math.floor(t%(gv+1));return vv.box(vv.types.traf,vv.box(vv.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),vv.box(vv.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,n>>24,n>>16&255,n>>8&255,255&n])),vv.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,vv.box(vv.types.trak,vv.tkhd(e),vv.mdia(e))}static trex(e){const t=e.id;return vv.box(vv.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const r=e.samples||[],i=r.length,s=12+16*i,n=new Uint8Array(s);let a,o,l,c,d,u;for(t+=8+s,n.set(["video"===e.type?1:0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),a=0;a<i;a++)o=r[a],l=o.duration,c=o.size,d=o.flags,u=o.cts,n.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,c>>>24&255,c>>>16&255,c>>>8&255,255&c,d.isLeading<<2|d.dependsOn,d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|d.isNonSync,61440&d.degradPrio,15&d.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*a);return vv.box(vv.types.trun,n)}static initSegment(e){vv.types||vv.init();const t=vv.moov(e);return Gh(vv.FTYP,t)}static hvc1(e){const t=e.params,r=[e.vps,e.sps,e.pps],i=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),3|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),r.length]);let s=i.length;for(let e=0;e<r.length;e+=1){s+=3;for(let t=0;t<r[e].length;t+=1)s+=2+r[e][t].length}const n=new Uint8Array(s);n.set(i,0),s=i.length;const a=r.length-1;for(let e=0;e<r.length;e+=1){n.set(new Uint8Array([32+e|(e===a?128:0),0,r[e].length]),s),s+=3;for(let t=0;t<r[e].length;t+=1)n.set(new Uint8Array([r[e][t].length>>8,255&r[e][t].length]),s),s+=2,n.set(r[e][t],s),s+=r[e][t].length}const o=vv.box(vv.types.hvcC,n),l=e.width,c=e.height,d=e.pixelRatio[0],u=e.pixelRatio[1];return vv.box(vv.types.hvc1,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,l>>8&255,255&l,c>>8&255,255&c,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]),o,vv.box(vv.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),vv.box(vv.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,u>>24,u>>16&255,u>>8&255,255&u])))}}vv.types=void 0,vv.HDLR_TYPES=void 0,vv.STTS=void 0,vv.STSC=void 0,vv.STCO=void 0,vv.STSZ=void 0,vv.VMHD=void 0,vv.SMHD=void 0,vv.STSD=void 0,vv.FTYP=void 0,vv.DINF=void 0;function yv(e,t,r=1,i=!1){const s=e*t*r;return i?Math.round(s):s}function bv(e,t=!1){return yv(e,1e3,1/9e4,t)}function Ev(e){const{baseTime:t,timescale:r,trackId:i}=e;return`${t/r} (${t}/${r}) trackId: ${i}`}let wv,Sv=null,Tv=null;function xv(e,t,r,i){return{duration:t,size:r,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}class Av extends Ku{constructor(e,t,r,i){if(super("mp4-remuxer",i),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===Sv){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Sv=e?parseInt(e[1]):0}if(null===Tv){const e=navigator.userAgent.match(/Safari\/(\d+)/i);Tv=e?parseInt(e[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){const t=this._initPTS;t&&e&&e.trackId===t.trackId&&e.baseTime===t.baseTime&&e.timescale===t.timescale||this.log(`Reset initPTS: ${t?Ev(t):t} > ${e?Ev(e):e}`),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const r=e[0].pts,i=e.reduce((e,i)=>{let s=i.pts,n=s-e;return n<-4294967296&&(t=!0,s=kv(s,r),n=s-e),n>0?e:s},r);return t&&this.debug("PTS rollover detected"),i}remux(e,t,r,i,s,n,a,o){let l,c,d,u,h,f,p=s,m=s;const g=e.pid>-1,v=t.pid>-1,y=t.samples.length,b=e.samples.length>0,E=a&&y>0||y>1;if((!g||b)&&(!v||E)||this.ISGenerated||a){if(this.ISGenerated){var w,S,T,x;const e=this.videoTrackConfig;(e&&(t.width!==e.width||t.height!==e.height||(null==(w=t.pixelRatio)?void 0:w[0])!==(null==(S=e.pixelRatio)?void 0:S[0])||(null==(T=t.pixelRatio)?void 0:T[1])!==(null==(x=e.pixelRatio)?void 0:x[1]))||!e&&E||null===this.nextAudioTs&&b)&&this.resetInitSegment()}this.ISGenerated||(d=this.generateIS(e,t,s,n));const r=this.isVideoContiguous;let i,a=-1;if(E&&(a=function(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!r&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,a>0){this.warn(`Dropped ${a} out of ${y} video samples due to a missing keyframe`);const e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(a),t.dropped+=a,m+=(t.samples[0].pts-e)/t.inputTimeScale,i=m}else-1===a&&(this.warn(`No keyframe found out of ${y} video samples`),f=!1);if(this.ISGenerated){if(b&&E){const r=this.getVideoStartPts(t.samples),i=(kv(e.samples[0].pts,r)-r)/t.inputTimeScale;p+=Math.max(0,i),m+=Math.max(0,-i)}if(b){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),d=this.generateIS(e,t,s,n)),c=this.remuxAudio(e,p,this.isAudioContiguous,n,v||E||o===Uu?m:void 0),E){const i=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),d=this.generateIS(e,t,s,n)),l=this.remuxVideo(t,m,r,i)}}else E&&(l=this.remuxVideo(t,m,r,0));l&&(l.firstKeyFrame=a,l.independent=-1!==a,l.firstKeyFramePTS=i)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(h=Lv(r,s,this._initPTS,this._initDTS)),i.samples.length&&(u=Iv(i,s,this._initPTS))),{audio:c,video:l,initSegment:d,independent:f,text:u,id3:h}}computeInitPts(e,t,r,i){const s=Math.round(r*t);let n=kv(e,s);if(n<s+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(s-n)/t} ${i}`);n<s+t;)n+=8589934592;return n-s}generateIS(e,t,r,i){const s=e.samples,n=t.samples,a=this.typeSupported,o={},l=this._initPTS;let c,d,u,h=!l||i,f="audio/mp4",p=-1;if(h&&(c=d=1/0),e.config&&s.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":a.mpeg?(f="audio/mpeg",e.codec=""):a.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}o.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&a.mpeg?new Uint8Array(0):vv.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(p=e.id,u=e.inputTimeScale,l&&u===l.timescale?h=!1:c=d=this.computeInitPts(s[0].pts,u,r,"audio"))}if(t.sps&&t.pps&&n.length){if(t.timescale=t.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:vv.initSegment([t]),metadata:{width:t.width,height:t.height}},h)if(p=t.id,u=t.inputTimeScale,l&&u===l.timescale)h=!1;else{const e=this.getVideoStartPts(n),t=kv(n[0].dts,e),i=this.computeInitPts(t,u,r,"video"),s=this.computeInitPts(e,u,r,"video");d=Math.min(d,i),c=Math.min(c,s)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(o).length)return this.ISGenerated=!0,h?(l&&this.warn(`Timestamps at playlist time: ${i?"":"~"}${r} ${c/u} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${r} offset: ${c/u} (${c}/${u}) trackId: ${p}`),this._initPTS={baseTime:c,timescale:u,trackId:p},this._initDTS={baseTime:d,timescale:u,trackId:p}):c=u=void 0,{tracks:o,initPTS:c,timescale:u,trackId:p}}remuxVideo(e,t,r,i){const s=e.inputTimeScale,n=e.samples,a=[],o=n.length,l=this._initPTS,c=l.baseTime*s/l.timescale;let d,u,h=this.nextVideoTs,f=8,p=this.videoSampleDuration,m=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,v=!1;if(!r||null===h){const e=c+t*s,i=n[0].pts-kv(n[0].dts,n[0].pts);Sv&&null!==h&&Math.abs(e-i-(h+c))<15e3?r=!0:h=e-i-c}const y=h+c;for(let e=0;e<o;e++){const t=n[e];t.pts=kv(t.pts,y),t.dts=kv(t.dts,y),t.dts<n[e>0?e-1:e].dts&&(v=!0)}v&&n.sort(function(e,t){const r=e.dts-t.dts,i=e.pts-t.pts;return r||i}),d=n[0].dts,u=n[n.length-1].dts;const b=u-d,E=b?Math.round(b/(o-1)):p||e.inputTimeScale/30;if(r){const r=d-y,i=r>E,s=r<-1;if((i||s)&&(i?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${bv(r,!0)} ms (${r}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${bv(-r,!0)} ms (${r}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!s||y>=n[0].pts||Sv)){d=y;const e=n[0].pts-r;if(i)n[0].dts=d,n[0].pts=e;else{let t=!0;for(let i=0;i<n.length&&!(n[i].dts>e&&t);i++){const e=n[i].pts;if(n[i].dts-=r,n[i].pts-=r,i<n.length-1){const r=n[i+1].pts;t=r<=n[i].pts==r<=e}}}this.log(`Video: Initial PTS/DTS adjusted: ${bv(e,!0)}/${bv(d,!0)}, delta: ${bv(r,!0)} ms`)}}d=Math.max(0,d);let w=0,S=0,T=d;for(let e=0;e<o;e++){const t=n[e],r=t.units,i=r.length;let s=0;for(let e=0;e<i;e++)s+=r[e].data.length;S+=s,w+=i,t.length=s,t.dts<T?(t.dts=T,T+=E/4|0||1):T=t.dts,m=Math.min(t.pts,m),g=Math.max(t.pts,g)}u=n[o-1].dts;const x=S+4*w+8;let A;try{A=new Uint8Array(x)}catch(e){return void this.observer.emit(Ou.ERROR,Ou.ERROR,{type:Du.MUX_ERROR,details:_u.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:x,reason:`fail allocating video mdat ${x}`})}const k=new DataView(A.buffer);k.setUint32(0,x),A.set(vv.types.mdat,4);let L=!1,I=Number.POSITIVE_INFINITY,R=Number.POSITIVE_INFINITY,P=Number.NEGATIVE_INFINITY,C=Number.NEGATIVE_INFINITY;for(let e=0;e<o;e++){const t=n[e],r=t.units;let l,d=0;for(let e=0,t=r.length;e<t;e++){const t=r[e],i=t.data,s=t.data.byteLength;k.setUint32(f,s),f+=4,A.set(i,f),f+=s,d+=4+s}if(e<o-1)p=n[e+1].dts-t.dts,l=n[e+1].pts-t.pts;else{const r=this.config,a=e>0?t.dts-n[e-1].dts:E;if(l=e>0?t.pts-n[e-1].pts:E,r.stretchShortVideoTrack&&null!==this.nextAudioTs){const e=Math.floor(r.maxBufferHole*s),n=(i?m+i*s:this.nextAudioTs+c)-t.pts;n>e?(p=n-a,p<0?p=a:L=!0,this.log(`It is approximately ${n/90} ms to the next segment; using duration ${p/90} ms for the last video frame.`)):p=a}else p=a}const u=Math.round(t.pts-t.dts);I=Math.min(I,p),P=Math.max(P,p),R=Math.min(R,l),C=Math.max(C,l),a.push(xv(t.key,p,d,u))}if(a.length)if(Sv){if(Sv<70){const e=a[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(Tv&&C-R<P-I&&E/P<.025&&0===a[0].cts){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let e=d;for(let t=0,r=a.length;t<r;t++){const i=e+a[t].duration,s=e+a[t].cts;if(t<r-1){const e=i+a[t+1].cts;a[t].duration=e-s}else a[t].duration=t?a[t-1].duration:E;a[t].cts=0,e=i}}p=L||!p?E:p;const D=u+p;this.nextVideoTs=h=D-c,this.videoSampleDuration=p,this.isVideoContiguous=!0;const _={data1:vv.moof(e.sequenceNumber++,d,Vu(e,{samples:a})),data2:A,startPTS:(m-c)/s,endPTS:(g+p-c)/s,startDTS:(d-c)/s,endDTS:h/s,type:"video",hasAudio:!1,hasVideo:!0,nb:a.length,dropped:e.dropped};return e.samples=[],e.dropped=0,_}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}remuxAudio(e,t,r,i,s){const n=e.inputTimeScale,a=n/(e.samplerate?e.samplerate:n),o=this.getSamplesPerFrame(e),l=o*a,c=this._initPTS,d="mp3"===e.segmentCodec&&this.typeSupported.mpeg,u=[],h=void 0!==s;let f=e.samples,p=d?0:8,m=this.nextAudioTs||-1;const g=c.baseTime*n/c.timescale,v=g+t*n;if(this.isAudioContiguous=r=r||f.length&&m>0&&(i&&Math.abs(v-(m+g))<9e3||Math.abs(kv(f[0].pts,v)-(m+g))<20*l),f.forEach(function(e){e.pts=kv(e.pts,v)}),!r||m<0){const e=f.length;if(f=f.filter(e=>e.pts>=0),e!==f.length&&this.warn(`Removed ${f.length-e} of ${e} samples (initPTS ${g} / ${n})`),!f.length)return;m=0===s?0:i&&!h?Math.max(0,v-g):f[0].pts-g}if("aac"===e.segmentCodec){const t=this.config.maxAudioFramesDrift;for(let r=0,i=m+g;r<f.length;r++){const s=f[r],a=s.pts,o=a-i,c=Math.abs(1e3*o/n);if(o<=-t*l&&h)0===r&&(this.warn(`Audio frame @ ${(a/n).toFixed(3)}s overlaps marker by ${Math.round(1e3*o/n)} ms.`),this.nextAudioTs=m=a-g,i=a);else if(o>=t*l&&c<1e4&&h){let t=Math.round(o/l);for(i=a-t*l;i<0&&t&&l;)t--,i+=l;0===r&&(this.nextAudioTs=m=i-g),this.warn(`Injecting ${t} audio frames @ ${((i-g)/n).toFixed(3)}s due to ${Math.round(1e3*o/n)} ms gap.`);for(let n=0;n<t;n++){let t=mv.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);t||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),t=s.unit.subarray()),f.splice(r,0,{unit:t,pts:i}),i+=l,r++}}s.pts=i,i+=l}}let y,b=null,E=null,w=0,S=f.length;for(;S--;)w+=f[S].unit.byteLength;for(let t=0,i=f.length;t<i;t++){const i=f[t],s=i.unit;let n=i.pts;if(null!==E){u[t-1].duration=Math.round((n-E)/a)}else{if(r&&"aac"===e.segmentCodec&&(n=m+g),b=n,!(w>0))return;w+=p;try{y=new Uint8Array(w)}catch(e){return void this.observer.emit(Ou.ERROR,Ou.ERROR,{type:Du.MUX_ERROR,details:_u.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:w,reason:`fail allocating audio mdat ${w}`})}if(!d){new DataView(y.buffer).setUint32(0,w),y.set(vv.types.mdat,4)}}y.set(s,p);const l=s.byteLength;p+=l,u.push(xv(!0,o,l,0)),E=n}const T=u.length;if(!T)return;const x=u[u.length-1];m=E-g,this.nextAudioTs=m+a*x.duration;const A=d?new Uint8Array(0):vv.moof(e.sequenceNumber++,b/a,Vu({},e,{samples:u}));e.samples=[];const k=(b-g)/n,L=this.nextAudioTs/n,I={data1:A,data2:y,startPTS:k,endPTS:L,startDTS:k,endDTS:L,type:"audio",hasAudio:!0,hasVideo:!1,nb:T};return this.isAudioContiguous=!0,I}}function kv(e,t){let r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}function Lv(e,t,r,i){const s=e.samples.length;if(!s)return;const n=e.inputTimeScale;for(let a=0;a<s;a++){const s=e.samples[a];s.pts=kv(s.pts-r.baseTime*n/r.timescale,t*n)/n,s.dts=kv(s.dts-i.baseTime*n/i.timescale,t*n)/n}const a=e.samples;return e.samples=[],{samples:a}}function Iv(e,t,r){const i=e.samples.length;if(!i)return;const s=e.inputTimeScale;for(let n=0;n<i;n++){const i=e.samples[n];i.pts=kv(i.pts-r.baseTime*s/r.timescale,t*s)/s}e.samples.sort((e,t)=>e.pts-t.pts);const n=e.samples;return e.samples=[],{samples:n}}function Rv(e,t,r=!1){return void 0!==(null==e?void 0:e.start)?(e.start+(r?e.duration:0))/e.timescale:t}function Pv(e,t,r){const i=e.codec;if(i&&i.length>4)return i;if(t===gh){if("ec-3"===i||"ac-3"===i||"alac"===i)return i;if("fLaC"===i||"Opus"===i){return of(i,!1)}return r.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"}return r.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1"}try{wv=self.performance.now.bind(self.performance)}catch(e){wv=Date.now}const Cv=[{demux:class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,i){const s=this.videoTrack=$g("video",1),n=this.audioTrack=$g("audio",1),a=this.txtTrack=$g("text",1);if(this.id3Track=$g("id3",1),this.timeOffset=0,null==e||!e.byteLength)return;const o=Oh(e);if(o.video){const{id:e,timescale:t,codec:r,supplemental:i}=o.video;s.id=e,s.timescale=a.timescale=t,s.codec=r,s.supplemental=i}if(o.audio){const{id:e,timescale:t,codec:r}=o.audio;n.id=e,n.timescale=t,n.codec=r}a.id=kh.text,s.sampleDuration=0,s.duration=n.duration=i}resetContiguity(){this.remainderData=null}static probe(e){return function(e){const t=e.byteLength;for(let r=0;r<t;){const i=Rh(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}(e)}demux(e,t){this.timeOffset=t;let r=e;const i=this.videoTrack,s=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Gh(this.remainderData,e));const t=function(e){const t={valid:null,remainder:null},r=Dh(e,["moof"]);if(r.length<2)return t.remainder=e,t;const i=r[r.length-1];return t.valid=e.slice(0,i.byteOffset-8),t.remainder=e.slice(i.byteOffset-8),t}(r);this.remainderData=t.remainder,i.samples=t.valid||new Uint8Array}else i.samples=r;const n=this.extractID3Track(i,t);return s.samples=jh(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const i=this.extractID3Track(t,this.timeOffset);return r.samples=jh(e,t),{videoTrack:t,audioTrack:$g(),id3Track:i,textTrack:$g()}}extractID3Track(e,t){const r=this.id3Track;if(e.samples.length){const i=Dh(e.samples,["emsg"]);i&&i.forEach(e=>{const i=function(e){const t=e[0];let r="",i="",s=0,n=0,a=0,o=0,l=0,c=0;if(0===t){for(;"\0"!==Lh(e.subarray(c,c+1));)r+=Lh(e.subarray(c,c+1)),c+=1;for(r+=Lh(e.subarray(c,c+1)),c+=1;"\0"!==Lh(e.subarray(c,c+1));)i+=Lh(e.subarray(c,c+1)),c+=1;i+=Lh(e.subarray(c,c+1)),c+=1,s=Rh(e,12),n=Rh(e,16),o=Rh(e,20),l=Rh(e,24),c=28}else if(1===t){c+=4,s=Rh(e,c),c+=4;const t=Rh(e,c);c+=4;const n=Rh(e,c);for(c+=4,a=2**32*t+n,Pu(a)||(a=Number.MAX_SAFE_INTEGER,eh.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Rh(e,c),c+=4,l=Rh(e,c),c+=4;"\0"!==Lh(e.subarray(c,c+1));)r+=Lh(e.subarray(c,c+1)),c+=1;for(r+=Lh(e.subarray(c,c+1)),c+=1;"\0"!==Lh(e.subarray(c,c+1));)i+=Lh(e.subarray(c,c+1)),c+=1;i+=Lh(e.subarray(c,c+1)),c+=1}return{schemeIdUri:r,value:i,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:e.subarray(c,e.byteLength)}}(e);if(ev.test(i.schemeIdUri)){const e=tv(i,t);let s=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;s<=.001&&(s=Number.POSITIVE_INFINITY);const n=i.payload;r.samples.push({data:n,len:n.byteLength,dts:e,pts:e,type:Fg.emsg,duration:s})}else if(this.config.enableEmsgKLVMetadata&&i.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const e=tv(i,t);r.samples.push({data:i.payload,len:i.payload.byteLength,dts:e,pts:e,type:Fg.misbklv,duration:Number.POSITIVE_INFINITY})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}},remux:class extends Ku{constructor(e,t,r,i){super("passthrough-remuxer",i),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,this.isVideoContiguous=!1}destroy(){}resetTimeStamp(e){this.lastEndTime=null;const t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(e,i),this.emitInitSegment=!0}generateInitSegment(e,t){let{audioCodec:r,videoCodec:i}=this;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const{audio:s,video:n}=this.initData=Oh(e);if(t)!function(e,t){if(!e||!t)return;const r=t.keyId;r&&t.isCommonEncryption&&Uh(e,(e,t)=>{const i=e.subarray(8,24);i.some(e=>0!==e)||(eh.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${sh(i)} -> ${sh(r)}`),e.set(r,8))})}(e,t);else{const e=s||n;null!=e&&e.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${e.codec}")!`)}s&&(r=Pv(s,gh,this)),n&&(i=Pv(n,vh,this));const a={};s&&n?a.audiovideo={container:"video/mp4",codec:r+","+i,supplemental:n.supplemental,encrypted:n.encrypted,initSegment:e,id:"main"}:s?a.audio={container:"audio/mp4",codec:r,encrypted:s.encrypted,initSegment:e,id:"audio"}:n?a.video={container:"video/mp4",codec:i,supplemental:n.supplemental,encrypted:n.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=a}remux(e,t,r,i,s,n){var a,o;let{initPTS:l,lastEndTime:c}=this;const d={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};Ru(c)||(c=this.lastEndTime=s||0);const u=t.samples;if(!u.length)return d;const h={initPTS:void 0,timescale:void 0,trackId:void 0};let f=this.initData;if(null!=(a=f)&&a.length||(this.generateInitSegment(u),f=this.initData),null==(o=f)||!o.length)return this.warn("Failed to generate initSegment."),d;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1);const p=function(e,t,r){const i={},s=Dh(e,["moof","traf"]);for(let e=0;e<s.length;e++){const n=s[e],a=Dh(n,["tfhd"])[0],o=Rh(a,4),l=t[o];if(!l)continue;i[o]||(i[o]={start:NaN,duration:0,sampleCount:0,timescale:l.timescale,type:l.type});const c=i[o],d=Dh(n,["tfdt"])[0];if(d){const e=d[0];let t=Rh(d,4);1===e&&(t===xh?r.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(t*=xh+1,t+=Rh(d,8))),Ru(t)&&(!Ru(c.start)||t<c.start)&&(c.start=t)}const u=l.default,h=Rh(a,0)|(null==u?void 0:u.flags);let f=(null==u?void 0:u.duration)||0;8&h&&(f=Rh(a,2&h?12:8));const p=Dh(n,["trun"]);let m=c.start||0,g=0,v=f;for(let e=0;e<p.length;e++){const t=p[e],r=Rh(t,4),i=c.sampleCount;c.sampleCount+=r;const s=1&t[3],n=4&t[3],a=1&t[2],o=2&t[2],l=4&t[2],d=8&t[2];let u=8,h=r;for(s&&(u+=4),n&&r&&(1&t[u+1]||void 0!==c.keyFrameIndex||(c.keyFrameIndex=i),u+=4,a?(v=Rh(t,u),u+=4):v=f,o&&(u+=4),d&&(u+=4),m+=v,g+=v,h--);h--;)a?(v=Rh(t,u),u+=4):v=f,o&&(u+=4),l&&(1&t[u+1]||void 0===c.keyFrameIndex&&(c.keyFrameIndex=c.sampleCount-(h+1),c.keyFrameStart=m),u+=4),d&&(u+=4),m+=v,g+=v;!g&&f&&(g+=f*r)}c.duration+=g}if(!Object.keys(i).some(e=>i[e].duration)){let t=1/0,r=0;const s=Dh(e,["sidx"]);for(let e=0;e<s.length;e++){const i=_h(s[e]);if(null!=i&&i.references){t=Math.min(t,i.earliestPresentationTime/i.timescale);const e=i.references.reduce((e,t)=>e+t.info.duration||0,0);r=Math.max(r,e+i.earliestPresentationTime/i.timescale)}}r&&Ru(r)&&Object.keys(i).forEach(e=>{i[e].duration||(i[e].duration=r*i[e].timescale-i[e].start)})}return i}(u,f,this),m=f.audio?p[f.audio.id]:null,g=f.video?p[f.video.id]:null,v=Rv(g,1/0),y=Rv(m,1/0),b=Rv(g,0,!0),E=Rv(m,0,!0);let w=s,S=0;const T=m&&(!g||!l&&y<v||l&&l.trackId===f.audio.id),x=T?m:g;if(x){const e=x.timescale,t=x.start-s*e,r=T?f.audio.id:f.video.id;w=x.start/e,S=T?E-y:b-v,!n&&l||!function(e,t,r,i){if(null===e)return!0;const s=Math.max(i,1),n=t-e.baseTime/e.timescale;return Math.abs(n-r)>s}(l,w,s,S)&&e===l.timescale||(l&&this.warn(`Timestamps at playlist time: ${n?"":"~"}${s} ${t/e} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${s} offset: ${w-s} (${t}/${e}) trackId: ${r}`),l=null,h.initPTS=t,h.timescale=e,h.trackId=r)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${s}`);l?(h.initPTS=l.baseTime,h.timescale=l.timescale,h.trackId=l.trackId):(h.timescale&&void 0!==h.trackId&&void 0!==h.initPTS||(this.warn("Could not set initPTS"),h.initPTS=w,h.timescale=1,h.trackId=-1),this.initPTS=l={baseTime:h.initPTS,timescale:h.timescale,trackId:h.trackId});const A=w-l.baseTime/l.timescale,k=A+S;S>0?this.lastEndTime=k:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const L=!!f.audio,I=!!f.video;let R="";L&&(R+="audio"),I&&(R+="video");const P={data1:u,startPTS:A,startDTS:A,endPTS:k,endDTS:k,type:R,hasAudio:L,hasVideo:I,nb:1,dropped:0,encrypted:!!f.audio&&f.audio.encrypted||!!f.video&&f.video.encrypted};d.audio=L&&!I?P:void 0,d.video=I?P:void 0;const C=null==g?void 0:g.sampleCount;if(C){const e=g.keyFrameIndex,t=-1!==e;P.nb=C,P.dropped=0===e||this.isVideoContiguous?0:t?e:C,P.independent=t,P.firstKeyFrame=e,t&&g.keyFrameStart&&(P.firstKeyFramePTS=(g.keyFrameStart-l.baseTime)/l.timescale),this.isVideoContiguous||(d.independent=t),this.isVideoContiguous||(this.isVideoContiguous=t),P.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${e}/${C} dropped: ${P.dropped} start: ${P.firstKeyFramePTS||"NA"}`)}return d.initSegment=h,d.id3=Lv(r,s,l,l),i.samples.length&&(d.text=Iv(i,s,l)),d}}},{demux:lv,remux:Av},{demux:class extends Bg{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;const r=bg(e,0);let i=(null==r?void 0:r.length)||0;if(Xg(e,i))return!1;for(let r=e.length;i<r;i++)if(xg(e,i))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&Eg(e,t)&&Sg(e,t)<=e.length-t}(e,t)}appendFrame(e,t,r){Ag(e,this.observer,t,r,e.manifestCodec);const i=Lg(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}},remux:Av},{demux:class extends Bg{resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=bg(e,0);let r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==Ng(t)&&Qg(e,r)<=16)return!1;for(let t=e.length;r<t;r++)if(Xg(e,r))return eh.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return Kg(e,t)&&4<=e.length-t}(e,t)}appendFrame(e,t,r){if(null!==this.basePTS)return Wg(e,t,r,this.basePTS,this.frameIndex)}},remux:Av}];Cv.splice(2,0,{demux:Zg,remux:Av});class Dv{constructor(e,t,r,i,s,n){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.id=s,this.logger=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,i){const s=r.transmuxing;s.executeStart=wv();let n=new Uint8Array(e);const{currentTransmuxState:a,transmuxConfig:o}=this;i&&(this.currentTransmuxState=i);const{contiguous:l,discontinuity:c,trackSwitch:d,accurateTimeOffset:u,timeOffset:h,initSegmentChange:f}=i||a,{audioCodec:p,videoCodec:m,defaultInitPts:g,duration:v,initSegmentData:y}=o,b=function(e,t){let r=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t);return r}(n,t);if(b&&Hp(b.method)){const e=this.getDecrypter(),t=Vp(b.method);if(!e.isSync())return this.asyncResult=!0,this.decryptionPromise=e.webCryptoDecrypt(n,b.key.buffer,b.iv.buffer,t).then(e=>{const t=this.push(e,null,r);return this.decryptionPromise=null,t}),this.decryptionPromise;{let i=e.softwareDecrypt(n,b.key.buffer,b.iv.buffer,t);if(r.part>-1){const t=e.flush();i=t?t.buffer:t}if(!i)return s.executeEnd=wv(),_v(r);n=new Uint8Array(i)}}const E=this.needsProbing(c,d);if(E){const e=this.configureTransmuxer(n);if(e)return this.logger.warn(`[transmuxer] ${e.message}`),this.observer.emit(Ou.ERROR,Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),s.executeEnd=wv(),_v(r)}(c||d||f||E)&&this.resetInitSegment(y,p,m,v,t),(c||f||E)&&this.resetInitialTimestamp(g),l||this.resetContiguity();const w=this.transmux(n,b,h,u,r);this.asyncResult=Ov(w);const S=this.currentTransmuxState;return S.contiguous=!0,S.discontinuity=!1,S.trackSwitch=!1,s.executeEnd=wv(),w}flush(e){const t=e.transmuxing;t.executeStart=wv();const{decrypter:r,currentTransmuxState:i,decryptionPromise:s}=this;if(s)return this.asyncResult=!0,s.then(()=>this.flush(e));const n=[],{timeOffset:a}=i;if(r){const t=r.flush();t&&n.push(this.push(t.buffer,null,e))}const{demuxer:o,remuxer:l}=this;if(!o||!l){t.executeEnd=wv();const r=[_v(e)];return this.asyncResult?Promise.resolve(r):r}const c=o.flush(a);return Ov(c)?(this.asyncResult=!0,c.then(t=>(this.flushRemux(n,t,e),n))):(this.flushRemux(n,c,e),this.asyncResult?Promise.resolve(n):n)}flushRemux(e,t,r){const{audioTrack:i,videoTrack:s,id3Track:n,textTrack:a}=t,{accurateTimeOffset:o,timeOffset:l}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${r.sn}${r.part>-1?" part: "+r.part:""} of ${this.id===Bu?"level":"track"} ${r.level}`);const c=this.remuxer.remux(i,s,n,a,l,o,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=wv()}resetInitialTimestamp(e){const{demuxer:t,remuxer:r}=this;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,i,s){const{demuxer:n,remuxer:a}=this;n&&a&&(n.resetInitSegment(e,t,r,i),a.resetInitSegment(e,t,r,s))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,i,s){let n;return n=t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,s):this.transmuxUnencrypted(e,r,i,s),n}transmuxUnencrypted(e,t,r,i){const{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(s,n,a,o,t,r,!1,this.id),chunkMeta:i}}transmuxSampleAes(e,t,r,i,s){return this.demuxer.demuxSampleAes(e,t,r).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,this.id),chunkMeta:s}))}configureTransmuxer(e){const{config:t,observer:r,typeSupported:i}=this;let s;for(let t=0,r=Cv.length;t<r;t++){var n;if(null!=(n=Cv[t].demux)&&n.probe(e,this.logger)){s=Cv[t];break}}if(!s)return new Error("Failed to find demuxer by probing fragment data");const a=this.demuxer,o=this.remuxer,l=s.remux,c=s.demux;o&&o instanceof l||(this.remuxer=new l(r,t,i,this.logger)),a&&a instanceof c||(this.demuxer=new c(r,t,i,this.logger),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Ep(this.config)),e}}const _v=e=>({remuxResult:{},chunkMeta:e});function Ov(e){return"then"in e&&e.then instanceof Function}class Mv{constructor(e,t,r,i,s){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=s||null}}class Nv{constructor(e,t,r,i,s,n){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=s,this.initSegmentChange=n}}let Fv=0;class $v{constructor(e,t,r,i){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Fv++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=e=>{const t=e.data,r=this.hls;if(r&&null!=t&&t.event&&t.instanceNo===this.instanceNo)switch(t.event){case"init":{var i;const e=null==(i=this.workerContext)?void 0:i.objectURL;e&&self.URL.revokeObjectURL(e);break}case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":r.logger[t.data.logType]&&r.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.part=this.part,t.data.id=this.id,r.trigger(t.event,t.data)}},this.onWorkerError=e=>{if(!this.hls)return;const t=new Error(`${e.message} (${e.filename}:${e.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})};const s=e.config;this.hls=e,this.id=t,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;const n=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===Ou.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new fg,this.observer.on(Ou.FRAG_DECRYPTED,n),this.observer.on(Ou.ERROR,n);const a=uf(s.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){const r=this.hls.logger;if(s.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{s.workerPath?(r.log(`loading Web Worker ${s.workerPath} for "${t}"`),this.workerContext=function(e){const t=mg[e];if(t)return t.clientCount++,t;const r=new self.URL(e,self.location.href).href,i={worker:new self.Worker(r),scriptURL:r,clientCount:1};return mg[e]=i,i}(s.workerPath)):(r.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){const e=mg[pg];if(e)return e.clientCount++,e;const t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),r=self.URL.createObjectURL(t),i={worker:new self.Worker(r),objectURL:r,clientCount:1};return mg[pg]=i,i}());const{worker:e}=this.workerContext;e.addEventListener("message",this.onWorkerMessage),e.addEventListener("error",this.onWorkerError),e.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:a,id:t,config:Pf(s)})}catch(i){r.warn(`Error setting up "${t}" Web Worker, fallback to inline`,i),this.terminateWorker(),this.error=null,this.transmuxer=new Dv(this.observer,a,s,"",t,e.logger)}return}}this.transmuxer=new Dv(this.observer,a,s,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=Fv++;const t=this.hls.config,r=uf(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:Pf(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),function(e){const t=mg[e||pg];if(t&&1===t.clientCount--){const{worker:r,objectURL:i}=t;delete mg[e||pg],i&&self.URL.revokeObjectURL(i),r.terminate()}}(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,r,i,s,n,a,o,l,c){var d,u;l.transmuxing.start=self.performance.now();const{instanceNo:h,transmuxer:f}=this,p=n?n.start:s.start,m=s.decryptdata,g=this.frag,v=!(g&&s.cc===g.cc),y=!(g&&l.level===g.level),b=g?l.sn-g.sn:-1,E=this.part?l.part-this.part.index:-1,w=0===b&&l.id>1&&l.id===(null==g?void 0:g.stats.chunkCount),S=!y&&(1===b||0===b&&(1===E||w&&E<=0)),T=self.performance.now();(y||b||0===s.stats.parsing.start)&&(s.stats.parsing.start=T),!n||!E&&S||(n.stats.parsing.start=T);const x=!(g&&(null==(d=s.initSegment)?void 0:d.url)===(null==(u=g.initSegment)?void 0:u.url)),A=new Nv(v,S,o,y,p,x);if(!S||v||x){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${s.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id===Bu?"level":"track"}: ${l.level} id: ${l.id}\n discontinuity: ${v}\n trackSwitch: ${y}\n contiguous: ${S}\n accurateTimeOffset: ${o}\n timeOffset: ${p}\n initSegmentChange: ${x}`);const e=new Mv(r,i,t,a,c);this.configureTransmuxer(e)}if(this.frag=s,this.part=n,this.workerContext)this.workerContext.worker.postMessage({instanceNo:h,cmd:"demux",data:e,decryptdata:m,chunkMeta:l,state:A},e instanceof ArrayBuffer?[e]:[]);else if(f){const t=f.push(e,m,l,A);Ov(t)?t.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,l,"transmuxer-interface push error")}):this.handleTransmuxComplete(t)}}flush(e){e.transmuxing.start=self.performance.now();const{instanceNo:t,transmuxer:r}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(r){const t=r.flush(e);Ov(t)?t.then(t=>{this.handleFlushResult(t,e)}).catch(t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")}):this.handleFlushResult(t,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}configureTransmuxer(e){const{instanceNo:t,transmuxer:r}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):r&&r.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}class Bv extends Ku{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,r){const i=null==t?void 0:t.renditionReports;if(i){let s=-1;for(let r=0;r<i.length;r++){const n=i[r];let a;try{a=new self.URL(n.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),a=n.URI||""}if(a===e){s=r;break}a===e.substring(0,a.length)&&(s=r)}if(-1!==s){const e=i[s],n=parseInt(e["LAST-MSN"])||t.lastPartSn;let a=parseInt(e["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const e=Math.min(t.age-t.partTarget,t.targetduration);a>=0&&e>t.partTarget&&(a+=1)}const o=r&&Af(r);return new kf(n,a>=0?a:void 0,o)}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}return e}playlistLoaded(e,t,r){const{details:i,stats:s}=t,n=self.performance.now(),a=s.loading.first?Math.max(0,n-s.loading.first):0;i.advancedDateTime=Date.now()-a;const o=this.hls.config.timelineOffset;if(o!==i.appliedTimelineOffset){const e=Math.max(o||0,0);i.appliedTimelineOffset=e,i.fragments.forEach(t=>{t.setStart(t.playlistOffset+e)})}if(i.live||null!=r&&r.live){const o="levelInfo"in t?t.levelInfo:t.track;if(i.reloaded(r),r&&i.fragments.length>0){Pm(r,i,this);const e=i.playlistParsingError;if(e){this.warn(e);const r=this.hls;if(!r.config.ignorePlaylistParsingErrors){var l;const{networkDetails:n}=t;return void r.trigger(Ou.ERROR,{type:Du.NETWORK_ERROR,details:_u.LEVEL_PARSING_ERROR,fatal:!1,url:i.url,error:e,reason:e.message,level:t.level||void 0,parent:null==(l=i.fragments[0])?void 0:l.type,networkDetails:n,stats:s})}i.playlistParsingError=null}}-1===i.requestScheduled&&(i.requestScheduled=s.loading.start);const c=this.hls.mainForwardBufferInfo,d=c?c.end-c.len:0,u=Om(i,1e3*(i.edge-d));if(i.requestScheduled+u<n?i.requestScheduled=n:i.requestScheduled+=u,this.log(`live playlist ${e} ${i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED"}`),!this.canLoad||!i.live)return;let h,f,p;if(i.canBlockReload&&i.endSN&&i.advanced){const e=this.hls.config.lowLatencyMode,s=i.lastPartSn,a=i.endSN,l=i.lastPartIndex,c=s===a;-1!==l?c?(f=a+1,p=e?0:l):(f=s,p=e?l+1:i.maxPartIndex):f=a+1;const d=i.age,u=d+i.ageHeader;let m=Math.min(u-i.partTarget,1.5*i.targetduration);if(m>0){if(u>3*i.targetduration)this.log(`Playlist last advanced ${d.toFixed(2)}s ago. Omitting segment and part directives.`),f=void 0,p=void 0;else if(null!=r&&r.tuneInGoal&&u-i.partTarget>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${m} with playlist age: ${i.age}`),m=0;else{const e=Math.floor(m/i.targetduration);if(f+=e,void 0!==p){p+=Math.round(m%i.targetduration/i.partTarget)}this.log(`CDN Tune-in age: ${i.ageHeader}s last advanced ${d.toFixed(2)}s goal: ${m} skip sn ${e} to part ${p}`)}i.tuneInGoal=m}if(h=this.getDeliveryDirectives(i,t.deliveryDirectives,f,p),e||!c)return i.requestScheduled=n,void this.loadingPlaylist(o,h)}else(i.canBlockReload||i.canSkipUntil)&&(h=this.getDeliveryDirectives(i,t.deliveryDirectives,f,p));h&&void 0!==f&&i.canBlockReload&&(i.requestScheduled=s.loading.first+Math.max(u-2*a,u/2)),this.scheduleLoading(o,h,i)}else this.clearTimer()}scheduleLoading(e,t,r){const i=r||e.details;if(!i)return void this.loadingPlaylist(e,t);const s=self.performance.now(),n=i.requestScheduled;if(s>=n)return void this.loadingPlaylist(e,t);const a=n-s;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(a)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),a)}getDeliveryDirectives(e,t,r,i){let s=Af(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,s=Sf),new kf(r,i,s)}checkRetry(e){const t=e.details,r=Hf(e),i=e.errorAction,{action:s,retryCount:n=0,retryConfig:a}=i||{},o=!!i&&!!a&&(s===tp||!i.resolved&&s===Jf);if(o){var l;if(n>=a.maxNumRetry)return!1;if(r&&null!=(l=e.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${n+1}/${a.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const e=Kf(a,n);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),e),this.warn(`Retrying playlist loading ${n+1}/${a.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,i.resolved=!0}return o}}function Uv(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!zv(e[r].attrs,t[r].attrs))return!1;return!0}function zv(e,t,r){const i=e["STABLE-RENDITION-ID"];return i&&!r?i===t["STABLE-RENDITION-ID"]:!(r||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(r=>e[r]!==t[r])}function Gv(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}class jv{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,r){if(null===this.queues||null===this.tracks)return;const i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)}appendBlocker(e){return new Promise(t=>{const r={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(r,e)})}prependBlocker(e){return new Promise(t=>{if(this.queues){const r={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(r)}})}removeBlockers(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;const r=null==(t=e[0])?void 0:t.label;"async-blocker"!==r&&"async-blocker-prepend"!==r||(e[0].execute(),e.splice(0,1))})}unblockAudio(e){if(null===this.queues)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")}executeNext(e){if(null===this.queues||null===this.tracks)return;const t=this.queues[e];if(t.length){const i=t[0];try{i.execute()}catch(t){var r;if(i.onError(t),null===this.queues||null===this.tracks)return;const s=null==(r=this.tracks[e])?void 0:r.buffer;null!=s&&s.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}toString(){const{queues:e,tracks:t}=this;return null===e||null===t?"<destroyed>":`\n${this.list("video")}\n${this.list("audio")}\n${this.list("audiovideo")}}`}list(e){var t,r;return null!=(t=this.queues)&&t[e]||null!=(r=this.tracks)&&r[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;const r=null==(t=this.tracks)?void 0:t[e],i=null==r?void 0:r.buffer;return i?`SourceBuffer${i.updating?" updating":""}${r.ended?" ended":""}${r.ending?" ending":""}`:"none"}listOps(e){var t;return(null==(t=this.queues)?void 0:t[e].map(e=>e.label).join(", "))||""}}const Hv=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Vv="HlsJsTrackRemovedError";class Wv extends Error{constructor(e){super(e),this.name=Vv}}function Yv(e){const t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function Kv(e){return"audio"===e?1:0}class qv{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(Ou.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Ou.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(Ou.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Ou.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&Ru(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);const e=this.hls.levels;if(e.length){const t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${r}: ${e[r].height}p@${e[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=r,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const r=t.filter((t,r)=>this.isLevelAllowed(t)&&r<=e);return this.clientRect=null,qv.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return!this.restrictedLevels.some(t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height)}static getMaxLevelByMediaSize(e,t,r){if(null==e||!e.length)return-1;const i=(e,t)=>!t||(e.width!==t.width||e.height!==t.height);let s=e.length-1;const n=Math.max(t,r);for(let t=0;t<e.length;t+=1){const r=e[t];if((r.width>=n||r.height>=n)&&i(r,e[t+1])){s=t;break}}return s}}const Xv={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},Qv={HLS:"h"};class Zv{constructor(e,t){Array.isArray(e)&&(e=e.map(e=>e instanceof Zv?e:new Zv(e))),this.value=e,this.params=t}}function Jv(e,t,r,i){return new Error(`failed to ${e} "${s=t,Array.isArray(s)?JSON.stringify(s):s instanceof Map?"Map{}":s instanceof Set?"Set{}":"object"==typeof s?JSON.stringify(s):String(s)}" as ${r}`,{cause:i});var s}function ey(e,t,r){return Jv("serialize",e,t,r)}class ty{constructor(e){this.description=e}}const ry="Bare Item";function iy(e){if(!1===ArrayBuffer.isView(e))throw ey(e,"Byte Sequence");return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function sy(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw ey(e,"Integer");return e.toString()}function ny(e,t){if(e<0)return-ny(-e,t);const r=Math.pow(10,t);if(Math.abs(e*r%1-.5)<Number.EPSILON){const t=Math.floor(e*r);return(t%2==0?t:t+1)/r}return Math.round(e*r)/r}function ay(e){const t=ny(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw ey(e,"Decimal");const r=t.toString();return r.includes(".")?r:`${r}.0`}const oy=/[\x00-\x1f\x7f]+/;function ly(e){const t=(r=e).description||r.toString().slice(7,-1);var r;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw ey(t,"Token");return t}function cy(e){switch(typeof e){case"number":if(!Ru(e))throw ey(e,ry);return Number.isInteger(e)?sy(e):ay(e);case"string":return function(e){if(oy.test(e))throw ey(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return ly(e);case"boolean":return function(e){if("boolean"!=typeof e)throw ey(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${sy(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return iy(e);if(e instanceof ty)return ly(e);default:throw ey(e,ry)}}function dy(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw ey(e,"Key");return e}function uy(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${dy(e)}`:`;${dy(e)}=${cy(t)}`).join("")}function hy(e){return e instanceof Zv?`${cy(e.value)}${uy(e.params)}`:cy(e)}function fy(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw ey(e,"Dict");const r=e instanceof Map?e.entries():Object.entries(e),i=(null==t?void 0:t.whitespace)?" ":"";return Array.from(r).map(([e,t])=>{t instanceof Zv==!1&&(t=new Zv(t));let r=dy(e);var i;return!0===t.value?r+=uy(t.params):(r+="=",Array.isArray(t.value)?r+=`(${(i=t).value.map(hy).join(" ")})${uy(i.params)}`:r+=hy(t)),r}).join(`,${i}`)}function py(e,t){return fy(e,t)}const my="CMCD-Object",gy="CMCD-Request",vy="CMCD-Session",yy="CMCD-Status",by={br:my,ab:my,d:my,ot:my,tb:my,tpb:my,lb:my,tab:my,lab:my,url:my,pb:gy,bl:gy,tbl:gy,dl:gy,ltc:gy,mtp:gy,nor:gy,nrr:gy,rc:gy,sn:gy,sta:gy,su:gy,ttfb:gy,ttfbb:gy,ttlb:gy,cmsdd:gy,cmsds:gy,smrt:gy,df:gy,cs:gy,ts:gy,cid:vy,pr:vy,sf:vy,sid:vy,st:vy,v:vy,msd:vy,bs:yy,bsd:yy,cdn:yy,rtp:yy,bg:yy,pt:yy,ec:yy,e:yy},Ey=gy;function wy(e,t){const r={};if(!e)return r;const i=Object.keys(e),s=t?(n=t,Object.keys(n).reduce((e,t)=>{var r;return null===(r=n[t])||void 0===r||r.forEach(r=>e[r]=t),e},{})):{};var n;return i.reduce((t,r)=>{var i;const n=by[r]||s[r]||Ey;return(null!==(i=t[n])&&void 0!==i?i:t[n]={})[r]=e[r],t},r)}const Sy="event";const Ty=e=>Math.round(e),xy=(e,t)=>Array.isArray(e)?e.map(e=>xy(e,t)):e instanceof Zv&&"string"==typeof e.value?new Zv(xy(e.value,t),e.params):(t.baseUrl&&(e=function(e,t){const r=new URL(e),i=new URL(t);if(r.origin!==i.origin)return e;const s=r.pathname.split("/").slice(1),n=i.pathname.split("/").slice(1,-1);for(;s[0]===n[0];)s.shift(),n.shift();for(;n.length;)n.shift(),s.unshift("..");return s.join("/")+r.search+r.hash}(e,t.baseUrl)),1===t.version?encodeURIComponent(e):e),Ay=e=>100*Ty(e/100),ky={br:Ty,d:Ty,bl:Ay,dl:Ay,mtp:Ay,nor:(e,t)=>{let r=e;return t.version>=2&&(e instanceof Zv&&"string"==typeof e.value?r=new Zv([e]):"string"==typeof e&&(r=[e])),xy(r,t)},rtp:Ay,tb:Ty},Ly="request",Iy="response",Ry=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],Py=["e"],Cy=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function Dy(e){return Cy.test(e)}const _y=["d","dl","nor","ot","rtp","su"];const Oy=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];const My=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function Ny(e){return My.includes(e)||Dy(e)}const Fy={[Iy]:function(e){return Ry.includes(e)||_y.includes(e)||Oy.includes(e)||Dy(e)},[Sy]:function(e){return Ry.includes(e)||Py.includes(e)||Dy(e)},[Ly]:function(e){return Ry.includes(e)||_y.includes(e)||Dy(e)}};function $y(e,t={}){const r={};if(null==e||"object"!=typeof e)return r;const i=t.version||e.v||1,s=t.reportingMode||Ly,n=1===i?Ny:Fy[s];let a=Object.keys(e).filter(n);const o=t.filter;"function"==typeof o&&(a=a.filter(o));const l=s===Iy||s===Sy;l&&!a.includes("ts")&&a.push("ts"),i>1&&!a.includes("v")&&a.push("v");const c=Vu({},ky,t.formatters),d={version:i,reportingMode:s,baseUrl:t.baseUrl};return a.sort().forEach(t=>{let s=e[t];const n=c[t];if("function"==typeof n&&(s=n(s,d)),"v"===t){if(1===i)return;s=i}"pr"==t&&1===s||(l&&"ts"===t&&!Ru(s)&&(s=Date.now()),function(e){return"number"==typeof e?Ru(e):null!=e&&""!==e&&!1!==e}(s)&&(function(e){return["ot","sf","st","e","sta"].includes(e)}(t)&&"string"==typeof s&&(s=new ty(s)),r[t]=s))}),r}function By(e,t,r){return Vu(e,function(e,t={}){const r={};if(!e)return r;const i=wy($y(e,t),null==t?void 0:t.customHeaderMap);return Object.entries(i).reduce((e,[t,r])=>{const i=py(r,{whitespace:!1});return i&&(e[t]=i),e},r)}(t,r))}function Uy(e,t={}){if(!e)return"";const r=function(e,t={}){return e?py($y(e,t),{whitespace:!1}):""}(e,t);return encodeURIComponent(r)}const zy=/CMCD=[^&#]+/;function Gy(e,t,r){const i=function(e,t={}){return e?`CMCD=${Uy(e,t)}`:""}(t,r);if(!i)return e;if(zy.test(e))return e.replace(zy,i);const s=e.includes("?")?"&":"?";return`${e}${s}${i}`}function jy(e,t,r,i){e&&Object.keys(t).forEach(s=>{const n=e.filter(e=>e.groupId===s).map(e=>{const n=Vu({},e);return n.details=void 0,n.attrs=new Fp(n.attrs),n.url=n.attrs.URI=Hy(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),n.groupId=n.attrs["GROUP-ID"]=t[s],n.attrs["PATHWAY-ID"]=i,n});e.push(...n)})}function Hy(e,t,r,i){const{HOST:s,PARAMS:n,[r]:a}=i;let o;t&&(o=null==a?void 0:a[t],o&&(e=o));const l=new self.URL(e);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(e=>{e&&l.searchParams.set(e,n[e])}),l.href}class Vy extends Ku{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=Vy.CDMCleanupPromise?[Vy.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=e=>{const{initDataType:t,initData:r}=e,i=`"${e.type}" event: init data type: "${t}"`;if(this.debug(i),null!==r){if(!this.keyFormatPromise){let e=Object.keys(this.keySystemAccessPromises);e.length||(e=sm(this.config));const t=e.map(im).filter(e=>!!e);this.keyFormatPromise=this.getKeyFormatPromise(t)}this.keyFormatPromise.then(s=>{const n=rm(s);if("sinf"!==t||n!==Qp.FAIRPLAY)return void this.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${n}`);let a;try{const e=Lh(new Uint8Array(r)),t=zh(Wp(JSON.parse(e).sinf));if(!t)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");a=new Uint8Array(t.subarray(8,24))}catch(e){return void this.warn(`${i} Failed to parse sinf: ${e}`)}const o=sh(a),{keyIdToKeySessionPromise:l,mediaKeySessions:c}=this;let d=l[o];for(let e=0;e<c.length;e++){const i=c[e],s=i.decryptdata;if(!s.keyId)continue;const n=sh(s.keyId);if(Gp(a,s.keyId)||-1!==s.uri.replace(/-/g,"").indexOf(o)){if(d=l[n],!d)continue;if(s.pssh)break;delete l[n],s.pssh=new Uint8Array(r),s.keyId=a,d=l[o]=d.then(()=>this.generateRequestWithPreferredKeySession(i,t,r,"encrypted-event-key-match")),d.catch(e=>this.handleError(e));break}}d||this.handleError(new Error(`Key ID ${o} not encountered in playlist. Key-system sessions ${c.length}.`))}).catch(e=>this.handleError(e))}},this.onWaitingForKey=e=>{this.log(`"${e.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Ou.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(Ou.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Ou.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(Ou.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:r}=this.config,i=null==t?void 0:t[e];return i?i.licenseUrl:e===Qp.WIDEVINE&&r?r:void 0}getLicenseServerUrlOrThrow(e){const t=this.getLicenseServerUrl(e);if(void 0===t)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){const{drmSystems:t}=this.config,r=null==t?void 0:t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,r=(e,t,r)=>!!e&&r.indexOf(e)===t,i=t.map(e=>e.audioCodec).filter(r),s=t.map(e=>e.videoCodec).filter(r);return i.length+s.length===0&&s.push("avc1.42e01e"),new Promise((t,r)=>{const n=e=>{const a=e.shift();this.getMediaKeysPromise(a,i,s).then(e=>t({keySystem:a,mediaKeys:e})).catch(t=>{e.length?n(e):r(t instanceof Ky?t:new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};n(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:r}=this.config;if("function"!=typeof r){let e=`Configured requestMediaKeySystemAccess is not a function ${r}`;return null===nm&&"http:"===self.location.protocol&&(e=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(e))}return r(e,t)}getMediaKeysPromise(e,t,r){var i;const s=function(e,t,r,i){let s;switch(e){case Qp.FAIRPLAY:s=["cenc","sinf"];break;case Qp.WIDEVINE:case Qp.PLAYREADY:s=["cenc"];break;case Qp.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${e}`)}return function(e,t,r,i){return[{initDataTypes:e,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(e=>({contentType:`audio/mp4; codecs=${e}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:r.map(e=>({contentType:`video/mp4; codecs=${e}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}(s,t,r,i)}(e,t,r,this.config.drmSystemOptions||{});let n=this.keySystemAccessPromises[e],a=null==(i=n)?void 0:i.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${Pf(s)}`),a=this.requestMediaKeySystemAccess(e,s);const t=n=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),a.then(r=>{this.log(`Access for key-system "${r.keySystem}" obtained`);const i=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);const s=t.mediaKeys=r.createMediaKeys().then(r=>(this.log(`Media-keys created for "${e}"`),t.hasMediaKeys=!0,i.then(t=>t?this.setMediaKeysServerCertificate(r,e,t):r)));return s.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),s})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${sh(e.keyId||[])} keyUri: ${e.uri}`);const i=r.createSession(),s={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(s),s}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const r=this.createMediaKeySessionContext(e),i=Wy(t),s="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,s,t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}updateKeySession(e,t){const r=e.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyId ${sh(e.decryptdata.keyId||[])}\n } (data length: ${t.byteLength})`),r.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>im(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:e,mediaKeys:t})=>this.attemptSetMediaKeys(e,t))}selectKeySystem(e){return new Promise((t,r)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:e})=>{const i=im(e);i?t(i):r(new Error(`Unable to find format for key-system "${e}"`))}).catch(r)})}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){const t=sm(this.config),r=e.map(rm).filter(e=>!!e&&-1!==t.indexOf(e));return this.selectKeySystem(r)}getKeyStatus(e){const{mediaKeySessions:t}=this;for(let r=0;r<t.length;r++){const i=Yy(e,t[r]);if(i)return i}}loadKey(e){const t=e.keyInfo.decryptdata,r=Wy(t),i=this.bannedKeyIds[r];if(i||"internal-error"===this.getKeyStatus(t)){const r=qy(i||"internal-error",t);return this.handleError(r,e.frag),Promise.reject(r)}const s=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);const n=this.keyIdToKeySessionPromise[r];if(!n){const i=this.getKeySystemForKeyPromise(t).then(({keySystem:r,mediaKeys:i})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(r,i).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:r,mediaKeys:i,decryptdata:t}))))).then(e=>{const r=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(e,"cenc",r,"playlist-key")});return i.catch(t=>this.handleError(t,e.frag)),this.keyIdToKeySessionPromise[r]=i,i}return n.catch(r=>{if(r instanceof Ky){const i=Yu({},r.data);"internal-error"===this.getKeyStatus(t)&&(i.decryptdata=t);const s=new Ky(i,r.message);this.handleError(s,e.frag)}}),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof Ky){t&&(e.data.frag=t);const r=e.data.decryptdata;this.error(`${e.message}${r?` (${sh(r.keyId||[])})`:""}`),this.hls.trigger(Ou.ERROR,e.data)}else this.error(e.message),this.hls.trigger(Ou.ERROR,{type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){const t=Wy(e),r=this.keyIdToKeySessionPromise[t];if(!r){const t=rm(e.keyFormat),r=t?[t]:sm(this.config);return this.attemptKeySystemAccess(r)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=sm(this.config)),0===e.length)throw new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${Pf({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();const r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const i=Promise.all(r).then(()=>this.media?this.media.setMediaKeys(t):new Promise((e,r)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return r(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(e).catch(r)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(i),i.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(i),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===r.indexOf(e))})}generateRequestWithPreferredKeySession(e,t,r,i){var s;const n=null==(s=this.config.drmSystems)||null==(s=s[e.keySystem])?void 0:s.generateRequest;if(n)try{const i=n.call(this.hls,t,r,e);if(!i)throw new Error("Invalid response from configured generateRequest filter");t=i.initDataType,r=i.initData?i.initData:null,e.decryptdata.pssh=r?new Uint8Array(r):null}catch(e){if(this.warn(e.message),this.hls&&this.hls.config.debug)throw e}if(null===r)return this.log(`Skipping key-session request for "${i}" (no initData)`),Promise.resolve(e);const a=Wy(e.decryptdata),o=e.decryptdata.uri;this.log(`Generating key-session request for "${i}" keyId: ${a} URI: ${o} (init data type: ${t} length: ${r.byteLength})`);const l=new fg,c=e._onmessage=t=>{const r=e.mediaKeysSession;if(!r)return void l.emit("error",new Error("invalid state"));const{messageType:i,message:s}=t;this.log(`"${i}" message event for session "${r.sessionId}" message size: ${s.byteLength}`),"license-request"===i||"license-renewal"===i?this.renewLicense(e,s).catch(e=>{l.eventNames().length?l.emit("error",e):this.handleError(e)}):"license-release"===i?e.keySystem===Qp.FAIRPLAY&&this.updateKeySession(e,Yp("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${i}"`)},d=(e,t)=>{let r;t.keyStatus=e,e.startsWith("usable")?l.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?r=qy(e,t.decryptdata):"expired"===e?r=new Error(`key expired (keyId: ${a})`):"released"===e?r=new Error("key released"):"status-pending"===e||this.warn(`unhandled key status change "${e}" (keyId: ${a})`),r&&(l.eventNames().length?l.emit("error",r):this.handleError(r))},u=e._onkeystatuseschange=t=>{if(!e.mediaKeysSession)return void l.emit("error",new Error("invalid state"));const r=this.getKeyStatuses(e);if(!Object.keys(r).some(e=>"status-pending"!==r[e]))return;if("expired"===r[a])return this.log(`Expired key ${Pf(r)} in key-session "${e.mediaKeysSession.sessionId}"`),void this.renewKeySession(e);let i=r[a];if(i)d(i,e);else{var s;const t=1e3;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(s=e.keyStatusTimeouts)[a]||(s[a]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;const r=this.getKeyStatus(e.decryptdata);if(r&&"status-pending"!==r)return this.log(`No status for keyId ${a} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${r} from other session.`),d(r,e);this.log(`key status for ${a} in key-session "${e.mediaKeysSession.sessionId}" timed out after ${t}ms`),i="internal-error",d(i,e)},t)),this.log(`No status for keyId ${a} (${Pf(r)}).`)}};Wm(e.mediaKeysSession,"message",c),Wm(e.mediaKeysSession,"keystatuseschange",u);const h=new Promise((e,t)=>{l.on("error",t),l.on("resolved",e)});return e.mediaKeysSession.generateRequest(t,r).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${a} URI: ${o}`)}).catch(t=>{throw new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_NO_SESSION,error:t,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${t}`)}).then(()=>h).catch(t=>(l.removeAllListeners(),this.removeSession(e).then(()=>{throw t}))).then(()=>(l.removeAllListeners(),e))}getKeyStatuses(e){const t={};return e.mediaKeysSession.keyStatuses.forEach((r,i)=>{if("string"==typeof i&&"object"==typeof r){const e=i;i=r,r=e}const s="buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i);if(e.keySystem===Qp.PLAYREADY&&16===s.length){const e=sh(s);t[e]=r,Kp(s)}const n=sh(s);"internal-error"===r&&(this.bannedKeyIds[n]=r),this.log(`key status change "${r}" for keyStatuses keyId: ${n} key-session "${e.mediaKeysSession.sessionId}"`),t[n]=r}),t}fetchServerCertificate(e){const t=this.config,r=new(0,t.loader)(t),i=this.getServerCertificateUrl(e);return i?(this.log(`Fetching server certificate for "${e}"`),new Promise((s,n)=>{const a={responseType:"arraybuffer",url:i},o=t.certLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(e,t,r,i)=>{s(e.data)},onError:(t,r,s,o)=>{n(new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:s,response:Yu({url:a.url,data:void 0},t)},`"${e}" certificate request failed (${i}). Status: ${t.code} (${t.text})`))},onTimeout:(t,r,s)=>{n(new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:s,response:{url:a.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(e,t,r)=>{n(new Error("aborted"))}};r.load(a,l,c)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((i,s)=>{e.setServerCertificate(r).then(s=>{this.log(`setServerCertificate ${s?"success":"not supported by CDM"} (${r.byteLength}) on "${t}"`),i(e)}).catch(e=>{s(new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(t=>this.updateKeySession(e,new Uint8Array(t)).catch(t=>{throw new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:t,fatal:!1},t.message)}))}unpackPlayReadyKeyMessage(e,t){const r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const i=(new DOMParser).parseFromString(r,"application/xml"),s=i.querySelectorAll("HttpHeader");if(s.length>0){let t;for(let r=0,i=s.length;r<i;r++){var n,a;t=s[r];const i=null==(n=t.querySelector("name"))?void 0:n.textContent,o=null==(a=t.querySelector("value"))?void 0:a.textContent;i&&o&&e.setRequestHeader(i,o)}}const o=i.querySelector("Challenge"),l=null==o?void 0:o.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return Yp(atob(l))}setupLicenseXHR(e,t,r,i){const s=this.config.licenseXhrSetup;return s?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return s.call(this.hls,e,t,r,i)}).catch(n=>{if(!r.decryptdata)throw n;return e.open("POST",t,!0),s.call(this.hls,e,t,r,i)}).then(r=>{e.readyState||e.open("POST",t,!0);return{xhr:e,licenseChallenge:r||i}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))}requestLicense(e,t){const r=this.config.keyLoadPolicy.default;return new Promise((i,s)=>{const n=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${n}`);const a=new XMLHttpRequest;a.responseType="arraybuffer",a.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return s(new Error("invalid state"));if(4===a.readyState)if(200===a.status){this._requestLicenseFailureCount=0;let t=a.response;this.log(`License received ${t instanceof ArrayBuffer?t.byteLength:t}`);const r=this.config.licenseResponseCallback;if(r)try{t=r.call(this.hls,a,n,e)}catch(e){this.error(e)}i(t)}else{const o=r.errorRetry,l=o?o.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||a.status>=400&&a.status<500)s(new Ky({type:Du.KEY_SYSTEM_ERROR,details:_u.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:a,response:{url:n,data:void 0,code:a.status,text:a.statusText}},`License Request XHR failed (${n}). Status: ${a.status} (${a.statusText})`));else{const r=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${r} attempts left`),this.requestLicense(e,t).then(i,s)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=a,this.setupLicenseXHR(a,n,e,t).then(({xhr:t,licenseChallenge:r})=>{e.keySystem==Qp.PLAYREADY&&(r=this.unpackPlayReadyKeyMessage(t,r)),t.send(r)}).catch(s)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const r=t.media;this.media=r,Wm(r,"encrypted",this.onMediaEncrypted),Wm(r,"waitingforkey",this.onWaitingForKey);const i=this.mediaResolved;i?i():this.mediaKeys=r.mediaKeys}onMediaDetached(){const e=this.media;e&&(Ym(e,"encrypted",this.onMediaEncrypted),Ym(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};const t=this.mediaResolved;if(t&&t(),!this.mediaKeys&&!this.mediaKeySessions.length)return;const r=this.media,i=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,cm.clearKeyUriToKeyIdMap();const s=i.length;Vy.CDMCleanupPromise=Promise.all(i.map(e=>this.removeSession(e)).concat((null==r||null==(e=r.setMediaKeys(null))?void 0:e.catch(e=>{this.log(`Could not clear media keys: ${e}`),this.hls&&this.hls.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${e}`)})}))||Promise.resolve())).catch(e=>{this.log(`Could not close sessions and clear media keys: ${e}`),this.hls&&this.hls.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${e}`)})}).then(()=>{s&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this._clear()}onManifestLoaded(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){const e=t.reduce((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e),[]);this.log(`Selecting key-system from session-keys ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:r,decryptdata:i}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${sh((null==i?void 0:i.keyId)||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const s=this.mediaKeySessions.indexOf(e);s>-1&&this.mediaKeySessions.splice(s,1);const{keyStatusTimeouts:n}=e;n&&Object.keys(n).forEach(e=>self.clearTimeout(n[e]));const{drmSystemOptions:a}=this.config,o=function(e){var t;return!(!e||"persistent-license"!==e.sessionType&&(null==(t=e.sessionTypes)||!t.some(e=>"persistent-license"===e)))}(a)?new Promise((e,r)=>{self.setTimeout(()=>r(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(e).catch(r)}):Promise.resolve();return o.catch(e=>{this.log(`Could not remove session: ${e}`),this.hls&&this.hls.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${e}`)})}).then(()=>t.close()).catch(e=>{this.log(`Could not close session: ${e}`),this.hls&&this.hls.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}function Wy(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return sh(e.keyId)}function Yy(e,t){return e.keyId&&t.mediaKeysSession.keyStatuses.has(e.keyId)?t.mediaKeysSession.keyStatuses.get(e.keyId):e.matches(t.decryptdata)?t.keyStatus:void 0}Vy.CDMCleanupPromise=void 0;class Ky extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}function qy(e,t){const r="output-restricted"===e,i=r?_u.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:_u.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new Ky({type:Du.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:t},r?"HDCP level output restricted":`key status changed to "${e}"`)}function Xy(e,t){let r;try{r=new Event("addtrack")}catch(e){r=document.createEvent("Event"),r.initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function Qy(e,t){const r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(r){eh.debug(`[texttrack-utils]: ${r}`);try{const r=new self.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,e.addCue(r)}catch(e){eh.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===r&&(e.mode=r)}function Zy(e,t){const r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues)for(let r=e.cues.length;r--;)t&&e.cues[r].removeEventListener("enter",t),e.removeCue(e.cues[r]);"disabled"===r&&(e.mode=r)}function Jy(e,t,r,i){const s=e.mode;if("disabled"===s&&(e.mode="hidden"),e.cues&&e.cues.length>0){const s=function(e,t,r){const i=[],s=function(e,t){if(t<=e[0].startTime)return 0;const r=e.length-1;if(t>e[r].endTime)return-1;let i,s=0,n=r;for(;s<=n;)if(i=Math.floor((n+s)/2),t<e[i].startTime)n=i-1;else{if(!(t>e[i].startTime&&s<r))return i;s=i+1}return e[s].startTime-t<t-e[n].startTime?s:n}(e,t);if(s>-1)for(let n=s,a=e.length;n<a;n++){const s=e[n];if(s.startTime>=t&&s.endTime<=r)i.push(s);else if(s.startTime>r)return i}return i}(e.cues,t,r);for(let t=0;t<s.length;t++)i&&!i(s[t])||e.removeCue(s[t])}"disabled"===s&&(e.mode=s)}function eb(e){const t=[];for(let r=0;r<e.length;r++){const i=e[r];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||t.push(e[r])}return t}function tb(e){let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}const rb=.025;let ib=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function sb(e,t,r){return`${e.identifier}-${r+1}-${tb(t)}`}class nb{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var e;this.appendInPlaceStarted=!1,null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;const r=this.playoutLimit;if(e<=0||isNaN(r))return!1;if(0===r)return!0;return((null==(t=this.assetList[e])?void 0:t.startOffset)||0)>r}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const e=this.dateRange.startTime;if(this.snapOptions.out){const t=this.dateRange.tagAnchor;if(t)return ab(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(0===this.startTime||this.snapOptions.out)return!0;const e=this.dateRange.tagAnchor;if(e){const t=this.dateRange.startTime;return t-ab(t,e)<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=Ru(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){const e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const t=this.resumeAnchor;if(t)return ab(e,t)}return e}get appendInPlace(){return!!this.appendInPlaceStarted||!this.appendInPlaceDisabled&&!(this.cue.once||this.cue.pre||!this.startIsAligned||!(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<rb))}set appendInPlace(e){this.appendInPlaceStarted?this.resetOnResume=!e:this.appendInPlaceDisabled=!e}get timelineStart(){return null!==this._timelineStart?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){const e=this.playoutLimit;let t;return t=null!==this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?ib.Range:ib.Point}get supplementsPrimary(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}get contentMayVary(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||null!==this.assetListResponse}toString(){return`["${(e=this).identifier}" ${e.cue.pre?"<pre>":e.cue.post?"<post>":""}${e.timelineStart.toFixed(2)}-${e.resumeTime.toFixed(2)}]`;var e}}function ab(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<rb)?t.start:t.start+t.duration}function ob(e,t,r){const i=new self.URL(e,r);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function lb(e,t){for(;null!=(r=e.assetList[++t])&&r.error;)var r;return t}function cb(e){const t=e.timelineStart,r=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+r).toFixed(2)}]`}class db{constructor(e,t,r,i){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(Ou.PLAYOUT_LIMIT_REACHED,{})};const s=this.hls=new e(t);this.interstitial=r,this.assetItem=i;const n=()=>{this.hasDetails=!0};s.once(Ou.LEVEL_LOADED,n),s.once(Ou.AUDIO_TRACK_LOADED,n),s.once(Ou.SUBTITLE_TRACK_LOADED,n),s.on(Ou.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t;this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&s.on(Ou.BUFFER_APPENDED,()=>{const e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,s.trigger(Ou.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=ob(t,e.config.primarySessionId||"").href}catch(e){}e.loadSource(t)}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return!1;if(null!=(t=this.hls)&&t.bufferedToEnd)return!0;if(!e)return!1;const r=Math.min(this._bufferedEosTime||1/0,this.duration),i=this.timelineOffset,s=Rp.bufferInfo(e,i,0);return this.getAssetTime(s.end)>=r-.02}reachedPlayout(e){const t=this.interstitial.playoutLimit;return this.startOffset+e>=t}get destroyed(){var e;return!(null!=(e=this.hls)&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return(null==(e=this.hls)?void 0:e.media)||null}get bufferedEnd(){const e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const t=Rp.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){const e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){const e=this.assetItem.duration;if(!e)return 0;const t=this.interstitial.playoutLimit;if(t){const r=t-this.startOffset;if(r>0&&r<e)return r}return e}get remaining(){const e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return(null==(e=this.hls)?void 0:e.config.timelineOffset)||0}set timelineOffset(e){const t=this.timelineOffset;if(e!==t){const r=e-t;if(Math.abs(r)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}getAssetTime(e){const t=this.timelineOffset,r=this.duration;return Math.min(Math.max(0,e-t),r)}removeMediaListeners(){const e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){var e;this.mediaAttached&&(null!=(e=this.hls)&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd))}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),null==(t=this.hls)||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,null==(e=this.hls)||e.detachMedia()}resumeBuffering(){var e;null==(e=this.hls)||e.resumeBuffering()}pauseBuffering(){var e;null==(e=this.hls)||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),(null==(e=this.hls)?void 0:e.transferMedia())||null}resetDetails(){const e=this.hls;if(e&&this.hasDetails){e.stopLoad();const t=e=>delete e.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,r){var i;null==(i=this.hls)||i.on(e,t)}once(e,t,r){var i;null==(i=this.hls)||i.once(e,t)}off(e,t,r){var i;null==(i=this.hls)||i.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${cb(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}class ub extends Ku{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((r,i)=>e<=i.startOffset&&t>i.startOffset?(delete i.error,r+1):r,0):0}get duration(){const e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let r=-1;e.nextEvent?r=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(r=this.findEventIndex(e.previousEvent.identifier)+1);const i=this.items;if(i)for(i[r]||(void 0===t&&(t=e.start),r=this.findItemIndexAtTime(t));r>=0&&null!=(s=i[r])&&s.event;){var s;r--}return r}findItemIndexAtTime(e,t){const r=this.items;if(r)for(let i=0;i<r.length;i++){let s=r[i];if(t&&"primary"!==t&&(s=s[t]),e===s.start||e>s.start&&e<s.end)return i}return-1}findJumpRestrictedIndex(e,t){const r=this.items;if(r)for(let i=e;i<=t&&r[i];i++){const e=r[i].event;if(null!=e&&e.restrictions.jump&&!e.appendInPlace)return i}return-1}findEventIndex(e){const t=this.items;if(t)for(let i=t.length;i--;){var r;if((null==(r=t[i].event)?void 0:r.identifier)===e)return i}return-1}findAssetIndex(e,t){const r=e.assetList,i=r.length;if(i>1)for(let e=0;e<i;e++){const s=r[e];if(!s.error){const r=s.timelineStart;if(t===r||t>r&&(t<r+(s.duration||0)||e===i-1))return e}}return 0}get assetIdAtEnd(){var e;const t=null==(e=this.items)||null==(e=e[this.length-1])?void 0:e.event;if(t){const e=t.assetList,r=e[e.length-1];if(r)return r.identifier}return null}parseInterstitialDateRanges(e,t){const r=e.main.details,{dateRanges:i}=r,s=this.events,n=this.parseDateRanges(i,{url:r.url},t),a=Object.keys(i),o=s?s.filter(e=>!a.includes(e.identifier)):[];n.length&&n.sort((e,t)=>{const r=e.cue.pre,i=e.cue.post,s=t.cue.pre,n=t.cue.post;if(r&&!s)return-1;if(s&&!r)return 1;if(i&&!n)return 1;if(n&&!i)return-1;if(!(r||s||i||n)){const r=e.startTime,i=t.startTime;if(r!==i)return r-i}return e.dateRange.tagOrder-t.dateRange.tagOrder}),this.events=n,o.forEach(e=>{this.removeEvent(e)}),this.updateSchedule(e,o)}updateSchedule(e,t=[],r=!1){const i=this.events||[];if(i.length||t.length||this.length<2){const s=this.items,n=this.parseSchedule(i,e),a=r||t.length||(null==s?void 0:s.length)!==n.length||n.some((e,t)=>Math.abs(e.playout.start-s[t].playout.start)>.005||Math.abs(e.playout.end-s[t].playout.end)>.005);a&&(this.items=n,this.onScheduleUpdate(t,s))}}parseDateRanges(e,t,r){const i=[],s=Object.keys(e);for(let n=0;n<s.length;n++){const a=s[n],o=e[a];if(o.isInterstitial){let e=this.eventMap[a];e?e.setDateRange(o):(e=new nb(o,t),this.eventMap[a]=e,!1===r&&(e.appendInPlace=r)),i.push(e)}}return i}parseSchedule(e,t){const r=[],i=t.main.details,s=i.live?1/0:i.edge;let n=0;if((e=e.filter(e=>!(e.error||e.cue.once&&e.hasPlayed))).length){this.resolveOffsets(e,t);let i=0,o=0;if(e.forEach((t,a)=>{const l=t.cue.pre,c=t.cue.post,d=e[a-1]||null,u=t.appendInPlace,h=c?s:t.startOffset,f=t.duration,p=t.timelineOccupancy===ib.Range?f:0,m=t.resumptionOffset,g=(null==d?void 0:d.startTime)===h,v=h+t.cumulativeDuration;let y=u?v+f:h+m;if(l||!c&&h<=0){const e=o;o+=p,t.timelineStart=v;const i=n;n+=f,r.push({event:t,start:v,end:y,playout:{start:i,end:n},integrated:{start:e,end:o}})}else{if(!(h<=s))return;{if(!g){const s=h-i;if(s>.033){const l=i,c=o;o+=s;const d=n;n+=s;const u={previousEvent:e[a-1]||null,nextEvent:t,start:l,end:l+s,playout:{start:d,end:n},integrated:{start:c,end:o}};r.push(u)}else s>0&&d&&(d.cumulativeDuration+=s,r[r.length-1].end=h)}c&&(y=v),t.timelineStart=v;const s=o;o+=p;const l=n;n+=f,r.push({event:t,start:v,end:y,playout:{start:l,end:n},integrated:{start:s,end:o}})}}const b=t.resumeTime;i=c||b>s?s:b}),i<s){var a;const e=i,t=o,l=s-i;o+=l;const c=n;n+=l,r.push({previousEvent:(null==(a=r[r.length-1])?void 0:a.event)||null,nextEvent:null,start:i,end:e+l,playout:{start:c,end:n},integrated:{start:t,end:o}})}this.setDurations(s,n,o)}else{const e=0;r.push({previousEvent:null,nextEvent:null,start:e,end:s,playout:{start:e,end:s},integrated:{start:e,end:s}}),this.setDurations(s,s,s)}return r}setDurations(e,t,r){this.durations={primary:e,playout:t,integrated:r}}resolveOffsets(e,t){const r=t.main.details,i=r.live?1/0:r.edge;let s=0,n=-1;e.forEach((a,o)=>{const l=a.cue.pre,c=a.cue.post,d=l?0:c?i:a.startTime;this.updateAssetDurations(a);if(n===d?a.cumulativeDuration=s:(s=0,n=d),!c&&a.snapOptions.in&&(a.resumeAnchor=Uf(null,r.fragments,a.startOffset+a.resumptionOffset,0,0)||void 0),a.appendInPlace&&!a.appendInPlaceStarted){this.primaryCanResumeInPlaceAt(a,t)||(a.appendInPlace=!1)}if(!a.appendInPlace&&o+1<e.length){e[o+1].startTime-e[o].resumeTime<.033&&(e[o+1].appendInPlace=!1,e[o+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${a}`))}const u=Ru(a.resumeOffset)?a.resumeOffset:a.duration;s+=u})}primaryCanResumeInPlaceAt(e,t){const r=e.resumeTime,i=e.startTime+e.resumptionOffset;if(Math.abs(r-i)>rb)return this.log(`"${e.identifier}" resumption ${r} not aligned with estimated timeline end ${i}`),!1;return!Object.keys(t).some(i=>{const s=t[i].details,n=s.edge;if(r>=n)return this.log(`"${e.identifier}" resumption ${r} past ${i} playlist end ${n}`),!1;const a=Uf(null,s.fragments,r);if(!a)return this.log(`"${e.identifier}" resumption ${r} does not align with any fragments in ${i} playlist (${s.fragStart}-${s.fragmentEnd})`),!0;const o="audio"===i?.175:0;return!(Math.abs(a.start-r)<rb+o||Math.abs(a.end-r)<rb+o)&&(this.log(`"${e.identifier}" resumption ${r} not aligned with ${i} fragment bounds (${a.start}-${a.end} sn: ${a.sn} cc: ${a.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let r=0,i=!1,s=!1;for(let n=0;n<e.assetList.length;n++){const a=e.assetList[n],o=t+r;a.startOffset=r,a.timelineStart=o,i||(i=null===a.duration),s||(s=!!a.error);r+=a.error?0:a.duration||0}e.duration=i&&!s?Math.max(r,e.duration):r}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function hb(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}class fb{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const r=e.assetListUrl;let i;try{i=ob(r,this.hls.sessionId,e.baseUrl)}catch(t){const i=this.assignAssetListError(e,_u.ASSET_LIST_LOAD_ERROR,t,r);return void this.hls.trigger(Ou.ERROR,i)}t&&"data:"!==i.protocol&&i.searchParams.set("_HLS_start_offset",""+t);const s=this.hls.config,n=new(0,s.loader)(s),a={responseType:"json",url:i.href},o=s.interstitialAssetListLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(t,r,i,s)=>{const n=t.data,a=null==n?void 0:n.ASSETS;if(!Array.isArray(a)){const t=this.assignAssetListError(e,_u.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),i.url,r,s);return void this.hls.trigger(Ou.ERROR,t)}e.assetListResponse=n,this.hls.trigger(Ou.ASSET_LIST_LOADED,{event:e,assetListResponse:n,networkDetails:s})},onError:(t,r,i,s)=>{const n=this.assignAssetListError(e,_u.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${r.url})`),r.url,s,i);this.hls.trigger(Ou.ERROR,n)},onTimeout:(t,r,i)=>{const s=this.assignAssetListError(e,_u.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${r.url})`),r.url,t,i);this.hls.trigger(Ou.ERROR,s)}};return n.load(a,l,c),this.hls.trigger(Ou.ASSET_LIST_LOADING,{event:e}),n}assignAssetListError(e,t,r,i,s,n){return e.error=r,{type:Du.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:r,networkDetails:n,stats:s}}}function pb(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function mb(e,t){return`[${e}] Advancing timeline position to ${t}`}class gb{constructor(e){this.buffered=void 0;const t=(t,r,i)=>{if((r>>>=0)>i-1)throw new DOMException(`Failed to execute '${t}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${i})`);return e[r][t]};this.buffered={get length(){return e.length},end:r=>t("end",r,e.length),start:r=>t("start",r,e.length)}}}const vb={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},yb=e=>String.fromCharCode(vb[e]||e),bb=15,Eb=100,wb={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Sb={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Tb={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},xb={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Ab=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class kb{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const r="function"==typeof t?t():t;eh.log(`${this.time} [${e}] ${r}`)}}}const Lb=function(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t};class Ib{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){const i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class Rb{constructor(){this.uchar=" ",this.penState=new Ib}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class Pb{constructor(e){this.chars=[],this.pos=0,this.currPenState=new Ib,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<Eb;e++)this.chars.push(new Rb);this.logger=e}equals(e){for(let t=0;t<Eb;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Eb;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Eb;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Eb&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Eb)}moveCursor(e){const t=this.pos+e;if(e>1)for(let e=this.pos+1;e<t+1;e++)this.chars[e].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=yb(e);this.pos>=Eb?this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}clearFromPos(e){let t;for(t=e;t<Eb;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let r=0;r<Eb;r++){const i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e);this.chars[this.pos].setPenState(this.currPenState)}}class Cb{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<bb;t++)this.rows.push(new Pb(e));this.logger=e}reset(){for(let e=0;e<bb;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let r=0;r<bb;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<bb;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<bb;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e);this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+Pf(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let e=0;e<bb;e++)this.rows[e].clear();const e=this.currRow+1-this.nrRollUpRows,r=this.lastOutputScreen;if(r){const i=r.rows[e].cueStartTime,s=this.logger.time;if(null!==i&&null!==s&&i<s)for(let i=0;i<this.nrRollUpRows;i++)this.rows[t-this.nrRollUpRows+i+1].copy(r.rows[e+i])}}this.currRow=t;const r=this.rows[this.currRow];if(null!==e.indent){const t=e.indent,i=Math.max(t-1,0);r.setCursor(e.indent),e.color=r.chars[i].penState.foreground}const i={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(i)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+Pf(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let r="",i=-1;for(let r=0;r<bb;r++){const s=this.rows[r].getTextString();s&&(i=r+1,e?t.push("Row "+i+": '"+s+"'"):t.push(s.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}getTextAndFormat(){return this.rows}}class Db{constructor(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Cb(r),this.nonDisplayedMemory=new Cb(r),this.lastOutputScreen=new Cb(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{const r=Math.floor(e/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=i[r]}this.logger.log(2,"MIDROW: "+Pf(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class _b{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;const i=this.logger=new kb;this.channels=[null,new Db(e,t,i),new Db(e+1,r,i)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let e=0;e<t.length;e+=2){const r=127&t[e],i=127&t[e+1];let s=!1,n=null;if(0===r&&0===i)continue;this.logger.log(3,()=>"["+Lb([t[e],t[e+1]])+"] -> ("+Lb([r,i])+")");const a=this.cmdHistory;if(r>=16&&r<=31){if(Mb(r,i,a)){Ob(null,null,a),this.logger.log(3,()=>"Repeated command ("+Lb([r,i])+") is dropped");continue}Ob(r,i,this.cmdHistory),s=this.parseCmd(r,i),s||(s=this.parseMidrow(r,i)),s||(s=this.parsePAC(r,i)),s||(s=this.parseBackgroundAttributes(r,i))}else Ob(null,null,a);if(!s&&(n=this.parseChars(r,i),n)){const e=this.currentChannel;if(e&&e>0){this.channels[e].insertChars(n)}else this.logger.log(2,"No channel found yet. TEXT-MODE?")}s||n||this.logger.log(2,()=>"Couldn't parse cleaned data "+Lb([r,i])+" orig: "+Lb([t[e],t[e+1]]))}}parseCmd(e,t){if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;const r=20===e||21===e||23===e?1:2,i=this.channels[r];return 20===e||21===e||28===e||29===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),this.currentChannel=r,!0}parseMidrow(e,t){let r=0;if((17===e||25===e)&&t>=32&&t<=47){if(r=17===e?1:2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+Lb([e,t])+")"),!0)}return!1}parsePAC(e,t){let r;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;const i=e<=23?1:2;r=t>=64&&t<=95?1===i?wb[e]:Tb[e]:1===i?Sb[e]:xb[e];const s=this.channels[i];return!!s&&(s.setPAC(this.interpretPAC(r,t)),this.currentChannel=i,!0)}interpretPAC(e,t){let r;const i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=!(1&~r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i}parseChars(e,t){let r,i=null,s=null;if(e>=25?(r=2,s=e-8):(r=1,s=e),s>=17&&s<=19){let e;e=17===s?t+80:18===s?t+112:t+144,this.logger.log(2,()=>"Special char '"+yb(e)+"' in channel "+r),i=[e]}else e>=32&&e<=127&&(i=0===t?[e]:[e,t]);return i&&this.logger.log(3,()=>"Char codes = "+Lb(i).join(",")),i}parseBackgroundAttributes(e,t){if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;let r;const i={};16===e||24===e?(r=Math.floor((t-32)/2),i.background=Ab[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));const s=e<=23?1:2;return this.channels[s].setBkgData(i),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}Ob(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const r=this.channels[t];r&&r.cueSplitAtTime(e)}}}function Ob(e,t,r){r.a=e,r.b=t}function Mb(e,t,r){return r.a===e&&r.b===t}var Nb=function(){if(null!=Xp&&Xp.VTTCue)return self.VTTCue;const e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;const r=t.toLowerCase();return!!~e.indexOf(r)&&r}function i(e){return r(t,e)}function s(e,...t){let r=1;for(;r<arguments.length;r++){const t=arguments[r];for(const r in t)e[r]=t[r]}return e}function n(t,n,a){const o=this,l={enumerable:!0};o.hasBeenReset=!1;let c="",d=!1,u=t,h=n,f=a,p=null,m="",g=!0,v="auto",y="start",b=50,E="middle",w=50,S="middle";Object.defineProperty(o,"id",s({},l,{get:function(){return c},set:function(e){c=""+e}})),Object.defineProperty(o,"pauseOnExit",s({},l,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(o,"startTime",s({},l,{get:function(){return u},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");u=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",s({},l,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",s({},l,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",s({},l,{get:function(){return p},set:function(e){p=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",s({},l,{get:function(){return m},set:function(t){const i=function(t){return r(e,t)}(t);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");m=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",s({},l,{get:function(){return g},set:function(e){g=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",s({},l,{get:function(){return v},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",s({},l,{get:function(){return y},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",s({},l,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",s({},l,{get:function(){return E},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",s({},l,{get:function(){return w},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");w=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",s({},l,{get:function(){return S},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");S=t,this.hasBeenReset=!0}})),o.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n}();class Fb{decode(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function $b(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+parseFloat(i||0)}const r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}class Bb{constructor(){this.values=Object.create(null)}set(e,t){this.get(e)||""===t||(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}function Ub(e,t,r,i){const s=i?e.split(i):[e];for(const e in s){if("string"!=typeof s[e])continue;const i=s[e].split(r);if(2!==i.length)continue;t(i[0],i[1])}}const zb=new Nb(0,0,""),Gb="middle"===zb.align?"middle":"center";function jb(e,t,r){const i=e;function s(){const t=$b(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function n(){e=e.replace(/^\s+/,"")}if(n(),t.startTime=s(),n(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.slice(3),n(),t.endTime=s(),n(),function(e,t){const i=new Bb;Ub(e,function(e,t){let s;switch(e){case"region":for(let s=r.length-1;s>=0;s--)if(r[s].id===t){i.set(e,r[s].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":s=t.split(","),i.integer(e,s[0]),i.percent(e,s[0])&&i.set("snapToLines",!1),i.alt(e,s[0],["auto"]),2===s.length&&i.alt("lineAlign",s[1],["start",Gb,"end"]);break;case"position":s=t.split(","),i.percent(e,s[0]),2===s.length&&i.alt("positionAlign",s[1],["start",Gb,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",Gb,"end","left","right"])}},/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");let s=i.get("line","auto");"auto"===s&&-1===zb.line&&(s=-1),t.line=s,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",Gb);let n=i.get("position","auto");"auto"===n&&50===zb.position&&(n="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=n}(e,t)}function Hb(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class Vb{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Fb,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;function r(){let e=t.buffer,r=0;for(e=Hb(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;const i=e.slice(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.slice(r),i}function i(e){Ub(e,function(e,t){},/:/)}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{let e="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;e=r();const i=e.match(/^()?WEBVTT([ \t].*)?$/);if(null==i||!i[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let s=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(s?s=!1:e=r(),t.state){case"HEADER":/:/.test(e)?i(e):e||(t.state="ID");continue;case"NOTE":e||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){t.state="NOTE";break}if(!e)continue;if(t.cue=new Nb(0,0,""),t.state="CUE",-1===e.indexOf("--\x3e")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{jb(e,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const r=-1!==e.indexOf("--\x3e");if(!e||r&&(s=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=e}continue;case"BADCUE":e||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const Wb=/\r\n|\n\r|\n|\r/g,Yb=function(e,t,r=0){return e.slice(r,r+t.length)===t};function Kb(e,t,r){return tb(e.toString())+tb(t.toString())+tb(r)}function qb(e,t,r,i,s,n,a){const o=new Vb,l=ih(new Uint8Array(e)).trim().replace(Wb,"\n").split("\n"),c=[],d=t?function(e,t=1){return yv(e,9e4,1/t)}(t.baseTime,t.timescale):0;let u,h="00:00.000",f=0,p=0,m=!0;o.oncue=function(e){const n=r[i];let a=r.ccOffset;const o=(f-d)/9e4;if(null!=n&&n.new&&(void 0!==p?a=r.ccOffset=n.start:function(e,t,r){let i=e[t],s=e[i.prevCC];if(!s||!s.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;null!=(n=s)&&n.new;){var n;e.ccOffset+=i.start-s.start,i.new=!1,i=s,s=e[i.prevCC]}e.presentationOffset=r}(r,i,o)),o){if(!t)return void(u=new Error("Missing initPTS for VTT MPEGTS"));a=o-r.presentationOffset}const l=e.endTime-e.startTime,h=kv(9e4*(e.startTime+a-p),9e4*s)/9e4;e.startTime=Math.max(h,0),e.endTime=Math.max(h+l,0);const m=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(m)),e.id||(e.id=Kb(e.startTime,e.endTime,m)),e.endTime>0&&c.push(e)},o.onparsingerror=function(e){u=e},o.onflush=function(){u?a(u):n(c)},l.forEach(e=>{if(m){if(Yb(e,"X-TIMESTAMP-MAP=")){m=!1,e.slice(16).split(",").forEach(e=>{Yb(e,"LOCAL:")?h=e.slice(6):Yb(e,"MPEGTS:")&&(f=parseInt(e.slice(7)))});try{p=function(e){let t=parseInt(e.slice(-3));const r=parseInt(e.slice(-6,-4)),i=parseInt(e.slice(-9,-7)),s=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(Ru(t)&&Ru(r)&&Ru(i)&&Ru(s)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=6e4*i,t+=36e5*s,t}(h)/1e3}catch(e){u=e}return}""===e&&(m=!1)}o.parse(e+"\n")}),o.flush()}const Xb="stpp.ttml.im1t",Qb=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Zb=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Jb={left:"start",center:"center",right:"end",start:"start",end:"end"};function eE(e,t,r,i){const s=Dh(new Uint8Array(e),["mdat"]);if(0===s.length)return void i(new Error("Could not parse IMSC1 mdat"));const n=s.map(e=>ih(e)),a=function(e,t,r=1,i=!1){return yv(e,t,1/r,i)}(t.baseTime,1,t.timescale);try{n.forEach(e=>r(function(e,t){const r=(new DOMParser).parseFromString(e,"text/xml"),i=r.getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");const s={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(s).reduce((e,t)=>(e[t]=i.getAttribute(`ttp:${t}`)||s[t],e),{}),a="preserve"!==i.getAttribute("xml:space"),o=rE(tE(i,"styling","style")),l=rE(tE(i,"layout","region")),c=tE(i,"body","[begin]");return[].map.call(c,e=>{const r=iE(e,a);if(!r||!e.hasAttribute("begin"))return null;const i=aE(e.getAttribute("begin"),n),s=aE(e.getAttribute("dur"),n);let c=aE(e.getAttribute("end"),n);if(null===i)throw nE(e);if(null===c){if(null===s)throw nE(e);c=i+s}const d=new Nb(i-t,c-t,r);d.id=Kb(d.startTime,d.endTime,d.text);const u=function(e,t,r){const i="http://www.w3.org/ns/ttml#styling";let s=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;a&&r.hasOwnProperty(a)&&(s=r[a]);return n.reduce((r,n)=>{const a=sE(t,i,n)||sE(e,i,n)||sE(s,i,n);return a&&(r[n]=a),r},{})}(l[e.getAttribute("region")],o[e.getAttribute("style")],o),{textAlign:h}=u;if(h){const e=Jb[h];e&&(d.lineAlign=e),d.align=h}return Vu(d,u),d}).filter(e=>null!==e)}(e,a)))}catch(e){i(e)}}function tE(e,t,r){const i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function rE(e){return e.reduce((e,t)=>{const r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function iE(e,t){return[].slice.call(e.childNodes).reduce((e,r,i)=>{var s;return"br"===r.nodeName&&i?e+"\n":null!=(s=r.childNodes)&&s.length?iE(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function sE(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function nE(e){return new Error(`Could not parse ttml timestamp ${e}`)}function aE(e,t){if(!e)return null;let r=$b(e);return null===r&&(Qb.test(e)?r=function(e,t){const r=Qb.exec(e),i=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/t.frameRate}(e,t):Zb.test(e)&&(r=function(e,t){const r=Zb.exec(e),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),r}class oE{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}function lE(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function cE(e,t){return!!e&&e.kind===lE(t)&&Gv(t,e)}function dE(e,t,r,i){return Math.min(t,i)-Math.max(e,r)}const uE=/\s/,hE={newCue(e,t,r,i){const s=[];let n,a,o,l,c;const d=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(n=i.rows[h],o=!0,l=0,c="",!n.isEmpty()){var u;for(let e=0;e<n.chars.length;e++)uE.test(n.chars[e].uchar)&&o?l++:(c+=n.chars[e].uchar,o=!1);n.cueStartTime=t,t===r&&(r+=1e-4),l>=16?l--:l++;const i=Hb(c.trim()),f=Kb(t,r,i);null!=e&&null!=(u=e.cues)&&u.getCueById(f)||(a=new d(t,r,i),a.id=f,a.line=h+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*l/32)),s.push(a))}return e&&s.length&&(s.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),s.forEach(t=>Qy(e,t))),s}};const fE=/(\d+)-(\d+)\/(\d+)/;class pE{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||mE,this.controller=new self.AbortController,this.stats=new mh}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){const i=this.stats;if(i.loading.start)throw new Error("Loader can only be used once.");i.loading.start=self.performance.now();const s=function(e,t){const r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(Vu({},e.headers))};e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return r}(e,this.controller.signal),n="arraybuffer"===e.responseType,a=n?"byteLength":"length",{maxTimeToFirstByteMs:o,maxLoadTimeMs:l}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),t.timeout=o&&Ru(o)?o:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},t.timeout);(Ov(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(r=>{var s;this.response=this.loader=r;const a=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},l-(a-i.loading.start)),!r.ok){const{status:e,statusText:t}=r;throw new gE(t||"fetch, bad network response",e,r)}i.loading.first=a,i.total=function(e){const t=e.get("Content-Range");if(t){const e=function(e){const t=fE.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(Ru(e))return e}const r=e.get("Content-Length");if(r)return parseInt(r)}(r.headers)||i.total;const o=null==(s=this.callbacks)?void 0:s.onProgress;return o&&Ru(t.highWaterMark)?this.loadProgressively(r,i,e,t.highWaterMark,o):n?r.arrayBuffer():"json"===e.responseType?r.json():r.text()}).then(r=>{var s,n;const o=this.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);const l=r[a];l&&(i.loaded=i.total=l);const c={url:o.url,data:r,code:o.status},d=null==(s=this.callbacks)?void 0:s.onProgress;d&&!Ru(t.highWaterMark)&&d(i,e,r,o),null==(n=this.callbacks)||n.onSuccess(c,i,e,o)}).catch(t=>{var r;if(self.clearTimeout(this.requestTimeout),i.aborted)return;const s=t&&t.code||0,n=t?t.message:null;null==(r=this.callbacks)||r.onError({code:s,text:n},e,t?t.details:null,i)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,i=0,s){const n=new cg,a=e.body.getReader(),o=()=>a.read().then(a=>{if(a.done)return n.dataLength&&s(t,r,n.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const l=a.value,c=l.length;return t.loaded+=c,c<i||n.dataLength?(n.push(l),n.dataLength>=i&&s(t,r,n.flush().buffer,e)):s(t,r,l.buffer,e),o()}).catch(()=>Promise.reject());return o()}}function mE(e,t){return new self.Request(e.url,t)}class gE extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}}const vE=/^age:\s*[\d.]+\s*$/im;class yE{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new mh,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;const s=this.xhrSetup;s?Promise.resolve().then(()=>{if(this.loader===r&&!this.stats.aborted)return s(r,t.url)}).catch(e=>{if(this.loader===r&&!this.stats.aborted)return r.open("GET",t.url,!0),s(r,t.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(e=>{var s;null==(s=this.callbacks)||s.onError({code:r.status,text:e.message},t,r,i)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);const i=t.headers,{maxTimeToFirstByteMs:s,maxLoadTimeMs:n}=r.loadPolicy;if(i)for(const t in i)e.setRequestHeader(t,i[t]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=s&&Ru(s)?s:n,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:r}=this;if(!e||!t)return;const i=t.readyState,s=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),s.timeout!==s.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),s.timeout=s.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const i=t.status,l="text"===t.responseType?t.responseText:null;if(i>=200&&i<300){const s=null!=l?l:t.response;if(null!=s){var n,a;r.loading.end=Math.max(self.performance.now(),r.loading.first);const o="arraybuffer"===t.responseType?s.byteLength:s.length;r.loaded=r.total=o,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first);const l=null==(n=this.callbacks)?void 0:n.onProgress;l&&l(r,e,s,t);const c={url:t.responseURL,data:s,code:i};return void(null==(a=this.callbacks)||a.onSuccess(c,r,e,t))}}const c=s.loadPolicy.errorRetry;var o;if(Xf(c,r.retry,!1,{url:e.url,data:void 0,code:i}))this.retry(c);else eh.error(`${i} while loading ${e.url}`),null==(o=this.callbacks)||o.onError({code:i,text:t.statusText},e,t,r)}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry;if(Xf(e,this.stats.retry,!0))this.retry(e);else{var t;eh.warn(`timeout while loading ${null==(t=this.context)?void 0:t.url}`);const e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:r}=this;this.retryDelay=Kf(e,r.retry),r.retry++,eh.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==t?void 0:t.url}, retrying ${r.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&vE.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const bE=Yu(Yu({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,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,ignorePlaylistParsingErrors:!1,loader:yE,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class extends Ku{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=e=>{var t;const{fragCurrent:r,partCurrent:i,hls:s}=this,{autoLevelEnabled:n,media:a}=s;if(!r||!a)return;const o=performance.now(),l=i?i.stats:r.stats,c=i?i.duration:r.duration,d=o-l.loading.start,u=s.minAutoLevel,h=r.level,f=this._nextAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||h<=u)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!n)return;const p=f>-1&&f!==h,m=!!e||p;if(!m&&(a.paused||!a.playbackRate||!a.readyState))return;const g=s.mainForwardBufferInfo;if(!m&&null===g)return;const v=this.bwEstimator.getEstimateTTFB(),y=Math.abs(a.playbackRate);if(d<=Math.max(v,c/(2*y)*1e3))return;const b=g?g.len/y:0,E=l.loading.first?l.loading.first-l.loading.start:-1,w=l.loaded&&E>-1,S=this.getBwEstimate(),T=s.levels,x=T[h],A=Math.max(l.loaded,Math.round(c*(r.bitrate||x.averageBitrate)/8));let k=w?d-E:d;k<1&&w&&(k=Math.min(d,8*l.loaded/S));const L=w?1e3*l.loaded/k:0,I=v/1e3,R=L?(A-l.loaded)/L:8*A/S+I;if(R<=b)return;const P=L?8*L:S,C=!0===(null==(t=(null==e?void 0:e.details)||this.hls.latestLevelDetails)?void 0:t.live),D=this.hls.config.abrBandWidthUpFactor;let _,O=Number.POSITIVE_INFINITY;for(_=h-1;_>u;_--){const e=T[_].maxBitrate,t=!T[_].details||C;if(O=this.getTimeToLoadFrag(I,P,c*e,t),O<Math.min(b,c+I))break}if(O>=R)return;if(O>10*c)return;w?this.bwEstimator.sample(d-Math.min(v,E),l.loaded):this.bwEstimator.sampleTTFB(d);const M=T[_].maxBitrate;this.getBwEstimate()*D>M&&this.resetEstimator(M);const N=this.findBestLevel(M,u,_,0,b,1,1);N>-1&&(_=N),this.warn(`Fragment ${r.sn}${i?" part "+i.index:""} of level ${h} is loading too slowly;\n Fragment duration: ${r.duration.toFixed(3)}\n Time to underbuffer: ${b.toFixed(3)} s\n Estimated load time for current fragment: ${R.toFixed(3)} s\n Estimated load time for down switch fragment: ${O.toFixed(3)} s\n TTFB estimate: ${0|E} ms\n Current BW estimate: ${Ru(S)?0|S:"Unknown"} bps\n New BW estimate: ${0|this.getBwEstimate()} bps\n Switching to level ${_} @ ${0|M} bps`),s.nextLoadLevel=s.nextAutoLevel=_,this.clearTimer();const F=()=>{if(this.clearTimer(),this.fragCurrent===r&&this.hls.loadLevel===_&&_>0){const e=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${_>0?"and switching down":""}\n Fragment duration: ${r.duration.toFixed(3)} s\n Time to underbuffer: ${e.toFixed(3)} s`),r.abortRequests(),this.fragCurrent=this.partCurrent=null,_>u){let t=this.findBestLevel(this.hls.levels[u].bitrate,u,_,0,e,1,1);-1===t&&(t=u),this.hls.nextLoadLevel=this.hls.nextAutoLevel=t,this.resetEstimator(this.hls.levels[t].bitrate)}}};p||R>2*O?F():this.timer=self.setInterval(F,1e3*O),s.trigger(Ou.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:i,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new ju(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.FRAG_LOADING,this.onFragLoading,this),e.on(Ou.FRAG_LOADED,this.onFragLoaded,this),e.on(Ou.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Ou.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Ou.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(Ou.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.FRAG_LOADING,this.onFragLoading,this),e.off(Ou.FRAG_LOADED,this.onFragLoaded,this),e.off(Ou.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Ou.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Ou.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(Ou.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const r=t.frag;if(!this.ignoreFragment(r)){var i;if(!r.bitrateTest)this.fragCurrent=r,this.partCurrent=null!=(i=t.part)?i:null;this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case _u.BUFFER_ADD_CODEC_ERROR:case _u.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case _u.FRAG_LOAD_TIMEOUT:{const e=t.frag,{fragCurrent:r,partCurrent:i}=this;if(e&&r&&e.sn===r.sn&&e.level===r.level){const t=performance.now(),r=i?i.stats:e.stats,s=t-r.loading.start,n=r.loading.first?r.loading.first-r.loading.start:-1;if(r.loaded&&n>-1){const e=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(s-Math.min(e,n),r.loaded)}else this.bwEstimator.sampleTTFB(s)}break}}}getTimeToLoadFrag(e,t,r,i){return e+r/t+(i?e+this.lastLevelLoadSec:0)}onLevelLoaded(e,t){const r=this.hls.config,{loading:i}=t.stats,s=i.end-i.first;Ru(s)&&(this.lastLevelLoadSec=s/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,{frag:t,part:r}){const i=r?r.stats:t.stats;if(t.type===Bu&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const e=r?r.duration:t.duration,s=this.hls.levels[t.level],n=(s.loaded?s.loaded.bytes:0)+i.loaded,a=(s.loaded?s.loaded.duration:0)+e;s.loaded={bytes:n,duration:a},s.realBitrate=Math.round(8*n/a)}if(t.bitrateTest){const e={stats:i,frag:t,part:r,id:t.type};this.onFragBuffered(Ou.FRAG_BUFFERED,e),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:r,part:i}=t,s=null!=i&&i.stats.loaded?i.stats:r.stats;if(s.aborted)return;if(this.ignoreFragment(r))return;const n=s.parsing.end-s.loading.start-Math.min(s.loading.first-s.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,s.loaded),s.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==Bu||"initSegment"===e.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,r=this.getBwEstimate(),i=this.hls.config.maxStarvationDelay,s=this.findBestLevel(r,t,e,0,i,1,1);if(s>-1)return s;const n=this.hls.firstLevel,a=Math.min(Math.max(n,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${n} clamped to ${a}`),a}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;const i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){const t=this.hls.levels;if(t.length>Math.max(e,i)&&t[e].loadError<=t[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:r}=this;if(r.levels.length<=1)return r.loadLevel;const{maxAutoLevel:i,config:s,minAutoLevel:n}=r,a=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay();let c=s.abrBandWidthFactor,d=s.abrBandWidthUpFactor;if(l){const e=this.findBestLevel(o,n,i,l,0,c,d);if(e>=0)return this.rebufferNotice=-1,e}let u=a?Math.min(a,s.maxStarvationDelay):s.maxStarvationDelay;if(!l){const e=this.bitrateTestDelay;if(e){u=(a?Math.min(a,s.maxLoadingDelay):s.maxLoadingDelay)-e,this.info(`bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*u)} ms`),c=d=1}}const h=this.findBestLevel(o,n,i,l,u,c,d);if(this.rebufferNotice!==h&&(this.rebufferNotice=h,this.info(`${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${h}`)),h>-1)return h;const f=r.levels[n],p=r.loadLevelObj;return p&&(null==f?void 0:f.bitrate)<p.bitrate?n:r.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/r}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,r,i,s,n,a){var o;const l=i+s,c=this.lastLoadedFragLevel,d=-1===c?this.hls.firstLevel:c,{fragCurrent:u,partCurrent:h}=this,{levels:f,allAudioTracks:p,loadLevel:m,config:g}=this.hls;if(1===f.length)return 0;const v=f[d],y=!(null==(o=this.hls.latestLevelDetails)||!o.live),b=-1===m||-1===c;let E,w="SDR",S=(null==v?void 0:v.frameRate)||0;const{audioPreference:T,videoPreference:x}=g,A=this.audioTracksByGroup||(this.audioTracksByGroup=Df(p));let k=-1;if(b){if(-1!==this.firstSelection)return this.firstSelection;const i=this.codecTiers||(this.codecTiers=function(e,t,r,i){return e.slice(r,i+1).reduce((e,r,i)=>{if(!r.codecSet)return e;const s=r.audioGroups;let n=e[r.codecSet];n||(e[r.codecSet]=n={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!s,fragmentError:0}),n.minBitrate=Math.min(n.minBitrate,r.bitrate);const a=Math.min(r.height,r.width);return n.minHeight=Math.min(n.minHeight,a),n.minFramerate=Math.min(n.minFramerate,r.frameRate),n.minIndex=Math.min(n.minIndex,i),n.maxScore=Math.max(n.maxScore,r.score),n.fragmentError+=r.fragmentError,n.videoRanges[r.videoRange]=(n.videoRanges[r.videoRange]||0)+1,s&&s.forEach(e=>{if(!e)return;const r=t.groups[e];r&&(n.hasDefaultAudio=n.hasDefaultAudio||t.hasDefaultAudio?r.hasDefault:r.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(r.channels).forEach(e=>{n.channels[e]=(n.channels[e]||0)+r.channels[e]}))}),e},{})}(f,A,t,r)),s=function(e,t,r,i,s){const n=Object.keys(e),a=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,l=null==s?void 0:s.videoCodec,c=a&&2===parseInt(a);let d=!1,u=!1,h=1/0,f=1/0,p=1/0,m=1/0,g=0,v=[];const{preferHDR:y,allowedVideoRanges:b}=Rf(t,s);for(let t=n.length;t--;){const r=e[n[t]];d||(d=r.channels[2]>0),h=Math.min(h,r.minHeight),f=Math.min(f,r.minFramerate),p=Math.min(p,r.minBitrate),b.filter(e=>r.videoRanges[e]>0).length>0&&(u=!0)}h=Ru(h)?h:0,f=Ru(f)?f:0;const E=Math.max(1080,h),w=Math.max(30,f);p=Ru(p)?p:r,r=Math.max(p,r),u||(t=void 0);const S=n.length>1;return{codecSet:n.reduce((t,i)=>{const s=e[i];if(i===t)return t;if(v=u?b.filter(e=>s.videoRanges[e]>0):[],S){if(s.minBitrate>r)return Cf(i,`min bitrate of ${s.minBitrate} > current estimate of ${r}`),t;if(!s.hasDefaultAudio)return Cf(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!=0)return Cf(i,`audio codec preference "${o}" not found`),t;if(a&&!c){if(!s.channels[a])return Cf(i,`no renditions with ${a} channel sound found (channels options: ${Object.keys(s.channels)})`),t}else if((!o||c)&&d&&0===s.channels[2])return Cf(i,"no renditions with stereo sound found"),t;if(s.minHeight>E)return Cf(i,`min resolution of ${s.minHeight} > maximum of ${E}`),t;if(s.minFramerate>w)return Cf(i,`min framerate of ${s.minFramerate} > maximum of ${w}`),t;if(!v.some(e=>s.videoRanges[e]>0))return Cf(i,`no variants with VIDEO-RANGE of ${Pf(v)} found`),t;if(l&&i.indexOf(l.substring(0,4))%5!=0)return Cf(i,`video codec preference "${l}" not found`),t;if(s.maxScore<g)return Cf(i,`max score of ${s.maxScore} < selected max of ${g}`),t}return t&&(sf(i)>=sf(t)||s.fragmentError>e[t].fragmentError)?t:(m=s.minIndex,g=s.maxScore,i)},void 0),videoRanges:v,preferHDR:y,minFramerate:f,minBitrate:p,minIndex:m}}(i,w,e,T,x),{codecSet:n,videoRanges:a,minFramerate:o,minBitrate:l,minIndex:c,preferHDR:d}=s;k=c,E=n,w=d?a[a.length-1]:a[0],S=o,e=Math.max(e,l),this.log(`picked start tier ${Pf(s)}`)}else E=null==v?void 0:v.codecSet,w=null==v?void 0:v.videoRange;const L=h?h.duration:u?u.duration:0,I=this.bwEstimator.getEstimateTTFB()/1e3,R=[];for(let o=r;o>=t;o--){var P;const t=f[o],u=o>d;if(!t)continue;if(g.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){const r=navigator.mediaCapabilities;"function"==typeof(null==r?void 0:r.decodingInfo)&&gf(t,A,w,S,e,T)?(t.supportedPromise=vf(t,A,r,this.supportedCache),t.supportedPromise.then(e=>{if(!this.hls)return;t.supportedResult=e;const r=this.hls.levels,i=r.indexOf(t);e.error?this.warn(`MediaCapabilities decodingInfo error: "${e.error}" for level ${i} ${Pf(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&this.log(`MediaCapabilities decodingInfo for level ${i} not smooth or powerEfficient: ${Pf(e)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${i} ${Pf(e)}`),i>-1&&r.length>1&&(this.log(`Removing unsupported level ${i}`),this.hls.removeLevel(i),-1===this.hls.loadLevel&&(this.hls.nextLoadLevel=0)))}).catch(e=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${e}`)})):t.supportedResult=pf}if((E&&t.codecSet!==E||w&&t.videoRange!==w||u&&S>t.frameRate||!u&&S>0&&S<t.frameRate||null!=(P=t.supportedResult)&&null!=(P=P.decodingInfoResults)&&P.some(e=>!1===e.smooth))&&(!b||o!==k)){R.push(o);continue}const p=t.details,v=(h?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||L;let x;x=u?a*e:n*e;const C=L&&i>=2*L&&0===s?t.averageBitrate:t.maxBitrate,D=this.getTimeToLoadFrag(I,x,C*v,void 0===p);if(x>=C&&(o===c||0===t.loadError&&0===t.fragmentError)&&(D<=I||!Ru(D)||y&&!this.bitrateTestDelay||D<l)){const e=this.forcedAutoLevel;return o===m||-1!==e&&e===m||(R.length&&this.trace(`Skipped level(s) ${R.join(",")} of ${r} max with CODECS and VIDEO-RANGE:"${f[R[0]].codecs}" ${f[R[0]].videoRange}; not compatible with "${E}" ${w}`),this.info(`switch candidate:${d}->${o} adjustedbw(${Math.round(x)})-bitrate=${Math.round(x-C)} ttfb:${I.toFixed(1)} avgDuration:${v.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${D.toFixed(1)} firstSelection:${b} codecSet:${t.codecSet} videoRange:${t.videoRange} hls.loadLevel:${m}`)),b&&(this.firstSelection=o),o}}return-1}set nextAutoLevel(e){const t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:r}=this.hls;return Math.min(Math.max(e,r),t)}},bufferController:class extends Ku{constructor(e,t){var r;super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=e=>{var t;this.hls&&"open"===(null==(t=this.mediaSource)?void 0:t.readyState)&&this.hls.pauseBuffering()},this._onStartStreaming=e=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=e=>{const{media:t,mediaSource:r}=this;e&&this.log("Media source opened"),t&&r&&(r.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(Ou.MEDIA_ATTACHED,{media:t,mediaSource:r}),null!==this.mediaSource&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:e,_objectUrl:t}=this;e!==t&&this.error(`Media element src was set while attaching MediaSource (${t} > ${e})`)},this.hls=e,this.fragmentTracker=t,this.appendSource=(r=th(e.config.preferManagedMediaSource),"undefined"!=typeof self&&r===self.ManagedMediaSource),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}registerListeners(){const{hls:e}=this;e.on(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ou.BUFFER_RESET,this.onBufferReset,this),e.on(Ou.BUFFER_APPENDING,this.onBufferAppending,this),e.on(Ou.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Ou.BUFFER_EOS,this.onBufferEos,this),e.on(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Ou.FRAG_PARSED,this.onFragParsed,this),e.on(Ou.FRAG_CHANGED,this.onFragChanged,this),e.on(Ou.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ou.BUFFER_RESET,this.onBufferReset,this),e.off(Ou.BUFFER_APPENDING,this.onBufferAppending,this),e.off(Ou.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Ou.BUFFER_EOS,this.onBufferEos,this),e.off(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Ou.FRAG_PARSED,this.onFragParsed,this),e.off(Ou.FRAG_CHANGED,this.onFragChanged,this),e.off(Ou.ERROR,this.onError,this)}transferMedia(){const{media:e,mediaSource:t}=this;if(!e)return null;const r={};if(this.operationQueue){const e=this.isUpdating();e||this.operationQueue.removeBlockers();const t=this.isQueued();(e||t)&&this.warn(`Transfering MediaSource with${t?" operations in queue":""}${e?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const i=this.transferData;return!this.sourceBufferCount&&i&&i.mediaSource===t?Vu(r,i.tracks):this.sourceBuffers.forEach(e=>{const[t]=e;t&&(r[t]=Vu({},this.tracks[t]),this.removeBuffer(t)),e[0]=e[1]=null}),{media:e,mediaSource:t,tracks:r}}initTracks(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){var r;let i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsTotal=i,this.log(`${i} bufferCodec event(s) expected.`),null!=(r=this.transferData)&&r.mediaSource&&this.sourceBufferCount&&i&&this.bufferCreated()}onMediaAttaching(e,t){const r=this.media=t.media;this.transferData=this.overrides=void 0;const i=th(this.appendSource);if(i){const e=!!t.mediaSource;(e||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const s=this.mediaSource=t.mediaSource||new i;if(this.assignMediaSource(s),e)this._objectUrl=r.src,this.attachTransferred();else{const e=this._objectUrl=self.URL.createObjectURL(s);if(this.appendSource)try{r.removeAttribute("src");const t=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||t&&s instanceof t,Yv(r),function(e,t){const r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(r,e),r.load()}catch(t){r.src=e}else r.src=e}r.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(e){var t,r;this.log(`${(null==(t=this.transferData)?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${null==(r=e.constructor)?void 0:r.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}attachTransferred(){const e=this.media,t=this.transferData;if(!t||!e)return;const r=this.tracks,i=t.tracks,s=i?Object.keys(i):null,n=s?s.length:0,a=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(i&&s&&n){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})\nrequired tracks: ${Pf(r,(e,t)=>"initSegment"===e?void 0:t)};\ntransfer tracks: ${Pf(i,(e,t)=>"initSegment"===e?void 0:t)}}`),!rh(i,r)){t.mediaSource=null,t.tracks=void 0;const s=e.currentTime,n=this.details,a=Math.max(s,(null==n?void 0:n.fragments[0].start)||0);return a-s>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${s} -> ${a}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(i)}"->"${Object.keys(r)}") start time: ${a} currentTime: ${s}`),this.onMediaDetaching(Ou.MEDIA_DETACHING,{}),this.onMediaAttaching(Ou.MEDIA_ATTACHING,t),void(e.currentTime=a))}this.transferData=void 0,s.forEach(e=>{const t=e,r=i[t];if(r){const e=r.buffer;if(e){const i=this.fragmentTracker,s=r.id;if(i.hasFragments(s)||i.hasParts(s)){const r=Rp.getBuffered(e);i.detectEvictedFragments(t,r,s,null,!0)}const n=Kv(t),a=[t,e];this.sourceBuffers[n]=a,e.updating&&this.operationQueue&&this.operationQueue.prependBlocker(t),this.trackSourceBuffer(t,r)}}}),a(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),a()}get mediaSourceOpenOrEnded(){var e;const t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}onMediaDetaching(e,t){const r=!!t.transferMedia;this.transferData=this.overrides=void 0;const{media:i,mediaSource:s,_objectUrl:n}=this;if(s){if(this.log("media source "+(r?"transferring":"detaching")),r)this.sourceBuffers.forEach(([e])=>{e&&this.removeBuffer(e)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const e="open"===s.readyState;try{const t=s.sourceBuffers;for(let r=t.length;r--;)e&&t[r].abort(),s.removeSourceBuffer(t[r]);e&&s.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(s.removeEventListener("startstreaming",this._onStartStreaming),s.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}i&&(i.removeEventListener("emptied",this._onMediaEmptied),r||(n&&self.URL.revokeObjectURL(n),this.mediaSrc===n?(i.removeAttribute("src"),this.appendSource&&Yv(i),i.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(Ou.MEDIA_DETACHED,t)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t;const r=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),r)try{var i;null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(r)}catch(t){this.warn(`onBufferReset ${e}`,t)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[Kv(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new jv(this.tracks)}onBufferCodecs(e,t){var r;const i=this.tracks,s=Object.keys(t);this.log(`BUFFER_CODECS: "${s}" (current SB count ${this.sourceBufferCount})`);const n="audiovideo"in t&&(i.audio||i.video)||i.audiovideo&&("audio"in t||"video"in t),a=!n&&this.sourceBufferCount&&this.media&&s.some(e=>!i[e]);n||a?this.warn(`Unsupported transition between "${Object.keys(i)}" and "${s}" SourceBuffers`):(s.forEach(e=>{var r,s;const n=t[e],{id:a,codec:o,levelCodec:l,container:c,metadata:d,supplemental:u}=n;let h=i[e];const f=null==(r=this.transferData)||null==(r=r.tracks)?void 0:r[e],p=null!=f&&f.buffer?f:h,m=(null==p?void 0:p.pendingCodec)||(null==p?void 0:p.codec),g=null==p?void 0:p.levelCodec;h||(h=i[e]={buffer:void 0,listeners:[],codec:o,supplemental:u,container:c,levelCodec:l,metadata:d,id:a});const v=lf(m,g),y=null==v?void 0:v.replace(Hv,"$1");let b=lf(o,l);const E=null==(s=b)?void 0:s.replace(Hv,"$1");b&&v&&y!==E&&("audio"===e.slice(0,5)&&(b=of(b,this.appendSource)),this.log(`switching codec ${m} to ${b}`),b!==(h.pendingCodec||h.codec)&&(h.pendingCodec=b),h.container=c,this.appendChangeType(e,c,b))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&"main"===(null==(r=t.audio)?void 0:r.id)&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{const r=this.tracks[t];return e[t]={id:r.id,container:r.container,codec:r.codec,levelCodec:r.levelCodec},e},{})}appendChangeType(e,t,r){const i=`${t};codecs=${r}`,s={label:`change-type=${i}`,execute:()=>{const s=this.tracks[e];if(s){const n=s.buffer;null!=n&&n.changeType&&(this.log(`changing ${e} sourceBuffer type to ${i}`),n.changeType(i),s.codec=r,s.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};this.append(s,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;const r=e.start,i=r+.05*e.duration;if(!0===(null==(t=this.fragmentTracker.getAppendedFrag(r,Bu))?void 0:t.gap))return;const s={label:"block-audio",execute:()=>{var e;const t=this.tracks.video;(this.lastVideoAppendEnd>i||null!=t&&t.buffer&&Rp.isBuffered(t.buffer,i)||!0===(null==(e=this.fragmentTracker.getAppendedFrag(i,Bu))?void 0:e.gap))&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:s,frag:e},this.append(s,"audio",!0)}unblockAudio(){const{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}onBufferAppending(e,t){const{tracks:r}=this,{data:i,type:s,parent:n,frag:a,part:o,chunkMeta:l,offset:c}=t,d=l.buffering[s],{sn:u,cc:h}=a,f=self.performance.now();d.start=f;const p=a.stats.buffering,m=o?o.stats.buffering:null;0===p.start&&(p.start=f),m&&0===m.start&&(m.start=f);const g=r.audio;let v=!1;"audio"===s&&"audio/mpeg"===(null==g?void 0:g.container)&&(v=!this.lastMpegAudioChunk||1===l.id||this.lastMpegAudioChunk.sn!==l.sn,this.lastMpegAudioChunk=l);const y=r.video,b=null==y?void 0:y.buffer;if(b&&"initSegment"!==u){const e=o||a,t=this.blockedAudioAppend;if("audio"!==s||"main"===n||this.blockedAudioAppend||y.ending||y.ended){if("video"===s){const r=e.end;if(t){const e=t.frag.start;(r>e||r<this.lastVideoAppendEnd||Rp.isBuffered(b,e))&&this.unblockAudio()}this.lastVideoAppendEnd=r}}else{const t=e.start+.05*e.duration,r=b.buffered,i=this.currentOp("video");r.length||i?!i&&!Rp.isBuffered(b,t)&&this.lastVideoAppendEnd<t&&this.blockAudio(e):this.blockAudio(e)}}const E=(o||a).start,w={label:`append-${s}`,execute:()=>{var e;d.executeStart=self.performance.now();const t=null==(e=this.tracks[s])?void 0:e.buffer;t&&(v?this.updateTimestampOffset(t,E,.1,s,u,h):void 0!==c&&Ru(c)&&this.updateTimestampOffset(t,c,1e-6,s,u,h)),this.appendExecutor(i,s)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();d.executeEnd=d.end=e,0===p.first&&(p.first=e),m&&0===m.first&&(m.first=e);const t={};this.sourceBuffers.forEach(([e,r])=>{e&&(t[e]=Rp.getBuffered(r))}),this.appendErrors[s]=0,"audio"===s||"video"===s?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(Ou.BUFFER_APPENDED,{type:s,frag:a,part:o,chunkMeta:l,parent:a.type,timeRanges:t})},onError:e=>{var t;const r={type:Du.MEDIA_ERROR,parent:a.type,details:_u.BUFFER_APPEND_ERROR,sourceBufferName:s,frag:a,part:o,chunkMeta:l,error:e,err:e,fatal:!1},i=null==(t=this.media)?void 0:t.error;if(e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e)r.details=_u.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!i)r.errorAction=ap(!0);else if(e.name===Vv&&0===this.sourceBufferCount)r.errorAction=ap(!0);else{const e=++this.appendErrors[s];this.warn(`Failed ${e}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${s}" sourceBuffer (${i||"no media error"})`),(e>=this.hls.config.appendErrorMaxRetry||i)&&(r.fatal=!0)}this.hls.trigger(Ou.ERROR,r)}};this.log(`queuing "${s}" append sn: ${u}${o?" p: "+o.index:""} of ${a.type===Bu?"level":"track"} ${a.level} cc: ${h}`),this.append(w,s,this.isPending(this.tracks[s]))}getFlushOp(e,t,r){return this.log(`queuing "${e}" remove ${t}-${r}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,r)},onStart:()=>{},onComplete:()=>{this.hls.trigger(Ou.BUFFER_FLUSHED,{type:e})},onError:i=>{this.warn(`Failed to remove ${t}-${r} from "${e}" SourceBuffer`,i)}}}onBufferFlushing(e,t){const{type:r,startOffset:i,endOffset:s}=t;r?this.append(this.getFlushOp(r,i,s),r):this.sourceBuffers.forEach(([e])=>{e&&this.append(this.getFlushOp(e,i,s),e)})}onFragParsed(e,t){const{frag:r,part:i}=t,s=[],n=i?i.elementaryStreams:r.elementaryStreams;n[yh]?s.push("audiovideo"):(n[gh]&&s.push("audio"),n[vh]&&s.push("video"));0===s.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(()=>{const e=self.performance.now();r.stats.buffering.end=e,i&&(i.stats.buffering.end=e);const t=i?i.stats:r.stats;this.hls.trigger(Ou.FRAG_BUFFERED,{frag:r,part:i,stats:t,id:r.type})},s).catch(e=>{this.warn(`Fragment buffered callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){const t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}onBufferEos(e,t){var r;this.sourceBuffers.forEach(([e])=>{if(e){const r=this.tracks[e];t.type&&t.type!==e||(r.ending=!0,r.ended||(r.ended=!0,this.log(`${e} buffer reached EOS`)))}});const i=!1!==(null==(r=this.overrides)?void 0:r.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{var t;return e&&!(null!=(t=this.tracks[e])&&t.ended)})?i?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:e}=this;e&&"open"===e.readyState?(this.log("Calling mediaSource.endOfStream()"),e.endOfStream(),this.hls.trigger(Ou.BUFFERED_TO_END,void 0)):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})):(this.tracksEnded(),this.hls.trigger(Ou.BUFFERED_TO_END,void 0)):"video"===t.type&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(null!==e){const t=this.tracks[e];t&&(t.ending=!1)}})}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{const e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}onError(e,t){if(t.details===_u.BUFFER_APPEND_ERROR&&t.frag){var r;const e=null==(r=t.errorAction)?void 0:r.nextAutoLevel;Ru(e)&&e!==t.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:e,details:t,media:r}=this;if(!r||null===t)return;if(!this.sourceBufferCount)return;const i=e.config,s=r.currentTime,n=t.levelTargetDuration,a=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(Ru(a)&&a>=0){const e=Math.max(a,n),t=Math.floor(s/n)*n-e;this.flushBackBuffer(s,n,t)}const o=i.frontBufferFlushThreshold;if(Ru(o)&&o>0){const e=Math.max(i.maxBufferLength,o),t=Math.max(e,n),r=Math.floor(s/n)*n+t;this.flushFrontBuffer(s,n,r)}}flushBackBuffer(e,t,r){this.sourceBuffers.forEach(([e,t])=>{if(t){const s=Rp.getBuffered(t);if(s.length>0&&r>s.start(0)){var i;this.hls.trigger(Ou.BACK_BUFFER_REACHED,{bufferEnd:r});const t=this.tracks[e];if(null!=(i=this.details)&&i.live)this.hls.trigger(Ou.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(null!=t&&t.ended)return void this.log(`Cannot flush ${e} back buffer while SourceBuffer is in ended state`);this.hls.trigger(Ou.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:e})}}})}flushFrontBuffer(e,t,r){this.sourceBuffers.forEach(([t,i])=>{if(i){const s=Rp.getBuffered(i),n=s.length;if(n<2)return;const a=s.start(n-1),o=s.end(n-1);if(r>a||e>=a&&e<=o)return;this.hls.trigger(Ou.BUFFER_FLUSHING,{startOffset:a,endOffset:1/0,type:t})}})}getDurationAndRange(){var e;const{details:t,mediaSource:r}=this;if(!t||!this.media||"open"!==(null==r?void 0:r.readyState))return null;const i=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&r.setLiveSeekableRange){const e=Math.max(0,t.fragmentStart);return{duration:1/0,start:e,end:Math.max(e,i)}}return{duration:1/0}}const s=null==(e=this.overrides)?void 0:e.duration;if(s)return Ru(s)?{duration:s}:null;const n=this.media.duration;return i>(Ru(r.duration)?r.duration:0)&&i>n||!Ru(n)?{duration:i}:null}updateMediaSource({duration:e,start:t,end:r}){const i=this.mediaSource;this.media&&i&&"open"===i.readyState&&(i.duration!==e&&(Ru(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),i.duration=e),void 0!==t&&void 0!==r&&(this.log(`MediaSource duration is set to ${i.duration}. Setting seekable range to ${t}-${r}.`),i.setLiveSeekableRange(t,r)))}get tracksReady(){const e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:r}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${Pf(r)}`),this.tracksReady){var i;const e=null==(i=this.transferData)?void 0:i.tracks;e&&Object.keys(e).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const e={};this.sourceBuffers.forEach(([t,r])=>{if(t){const i=this.tracks[t];e[t]={buffer:r,container:i.container,codec:i.codec,supplemental:i.supplemental,levelCodec:i.levelCodec,id:i.id,metadata:i.metadata}}}),this.hls.trigger(Ou.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([e])=>{this.executeNext(e)})}else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){const{tracks:e,sourceBuffers:t,mediaSource:r}=this;if(!r)throw new Error("createSourceBuffers called when mediaSource was null");for(const s in e){const n=s,a=e[n];if(this.isPending(a)){const e=this.getTrackCodec(a,n),s=`${a.container};codecs=${e}`;a.codec=e,this.log(`creating sourceBuffer(${s})${this.currentOp(n)?" Queued":""} ${Pf(a)}`);try{const e=r.addSourceBuffer(s),i=Kv(n),o=[n,e];t[i]=o,a.buffer=e}catch(e){var i;return this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(n),null==(i=this.operationQueue)||i.removeBlockers(),delete this.tracks[n],void this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:n,mimeType:s,parent:a.id})}this.trackSourceBuffer(n,a)}}this.bufferCreated()}getTrackCodec(e,t){const r=e.supplemental;let i=e.codec;r&&("video"===t||"audiovideo"===t)&&Jh(r,"video")&&(i=function(e,t){const r=[];if(e){const t=e.split(",");for(let e=0;e<t.length;e++)Zh(t[e],"video")||r.push(t[e])}return t&&r.push(t),r.join(",")}(i,r));const s=lf(i,e.levelCodec);return s?"audio"===t.slice(0,5)?of(s,this.appendSource):s:""}trackSourceBuffer(e,t){const r=t.buffer;if(!r)return;const i=this.getTrackCodec(t,e);this.tracks[e]={buffer:r,codec:i,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(e,t)=>{const r=t.removedRanges;null!=r&&r.length&&this.hls.trigger(Ou.BUFFER_FLUSHED,{type:e})})}get mediaSrc(){var e,t;const r=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==r?void 0:r.src}onSBUpdateStart(e){const t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t;if("closed"===(null==(t=this.mediaSource)?void 0:t.readyState))return void this.resetBuffer(e);const r=this.currentOp(e);r&&(r.onComplete(),this.shiftAndExecuteNext(e))}onSBUpdateError(e,t){var r;const i=new Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(r=this.mediaSource)?void 0:r.readyState}`);this.error(`${i}`,t),this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});const s=this.currentOp(e);s&&s.onError(i)}updateTimestampOffset(e,t,r,i,s,n){const a=t-e.timestampOffset;Math.abs(a)>=r&&(this.log(`Updating ${i} SourceBuffer timestampOffset to ${t} (sn: ${s} cc: ${n})`),e.timestampOffset=t)}removeExecutor(e,t,r){const{media:i,mediaSource:s}=this,n=this.tracks[e],a=null==n?void 0:n.buffer;if(!i||!s||!a)return this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void this.shiftAndExecuteNext(e);const o=Ru(i.duration)?i.duration:1/0,l=Ru(s.duration)?s.duration:1/0,c=Math.max(0,t),d=Math.min(r,o,l);d>c&&(!n.ending||n.ended)?(n.ended=!1,this.log(`Removing [${c},${d}] from the ${e} SourceBuffer`),a.remove(c,d)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const r=this.tracks[t],i=null==r?void 0:r.buffer;if(!i)throw new Wv(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);r.ending=!1,r.ended=!1,i.appendBuffer(e)}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(e=>{this.warn(`SourceBuffer blocked callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(e){this.warn(`Callback run without blocking ${this.operationQueue} ${e}`)}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);const{operationQueue:r}=this,i=t.map(e=>this.appendBlocker(e));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(i).then(t=>{r===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(e=>{var t;const r=null==(t=this.tracks[e])?void 0:t.buffer;r&&!r.updating&&this.shiftAndExecuteNext(e)})}append(e,t,r){this.operationQueue&&this.operationQueue.append(e,t,r)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,r){const i=this.tracks[e];if(!i)return;const s=i.buffer;if(!s)return;const n=r.bind(this,e);i.listeners.push({event:t,listener:n}),s.addEventListener(t,n)}removeBufferListeners(e){const t=this.tracks[e];if(!t)return;const r=t.buffer;r&&(t.listeners.forEach(e=>{r.removeEventListener(e.event,e.listener)}),t.listeners.length=0)}},capLevelController:qv,errorController:class extends Ku{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(Ou.ERROR,this.onError,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(Ou.ERROR,this.onError,this),e.off(Ou.ERROR,this.onErrorOut,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(null==e?void 0:e.type)===Bu?e.level:this.getVariantIndex()}getVariantIndex(){var e;const t=this.hls,r=t.currentLevel;return null!=(e=t.loadLevelObj)&&e.details||-1===r?t.loadLevel:r}variantHasKey(e,t){if(e){var r;if(null!=(r=e.details)&&r.hasKey(t))return!0;const i=e.audioGroups;if(i){return this.hls.allAudioTracks.filter(e=>i.indexOf(e.groupId)>=0).some(e=>{var r;return null==(r=e.details)?void 0:r.hasKey(t)})}}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var r;if(t.fatal)return;const i=this.hls,s=t.context;switch(t.details){case _u.FRAG_LOAD_ERROR:case _u.FRAG_LOAD_TIMEOUT:case _u.KEY_LOAD_ERROR:case _u.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case _u.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=ap());case _u.FRAG_GAP:case _u.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=Jf);case _u.LEVEL_EMPTY_ERROR:case _u.LEVEL_PARSING_ERROR:{var n;const e=t.parent===Bu?t.level:i.loadLevel;t.details===_u.LEVEL_EMPTY_ERROR&&null!=(n=t.context)&&null!=(n=n.levelDetails)&&n.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case _u.LEVEL_LOAD_ERROR:case _u.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==s?void 0:s.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.level)));case _u.AUDIO_TRACK_LOAD_ERROR:case _u.AUDIO_TRACK_LOAD_TIMEOUT:case _u.SUBTITLE_LOAD_ERROR:case _u.SUBTITLE_TRACK_LOAD_TIMEOUT:if(s){const e=i.loadLevelObj;if(e&&(s.type===Fu&&e.hasAudioGroup(s.groupId)||s.type===$u&&e.hasSubtitleGroup(s.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=Jf,void(t.errorAction.flags=ip)}return;case _u.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:Jf,flags:sp});case _u.KEY_SYSTEM_SESSION_UPDATE_FAILED:case _u.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case _u.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:Jf,flags:np});case _u.BUFFER_ADD_CODEC_ERROR:case _u.REMUX_ALLOC_ERROR:case _u.BUFFER_APPEND_ERROR:var a;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(a=t.level)?a:i.loadLevel);return;case _u.INTERNAL_EXCEPTION:case _u.BUFFER_APPENDING_ERROR:case _u.BUFFER_FULL_ERROR:case _u.LEVEL_SWITCH_ERROR:case _u.BUFFER_STALLED_ERROR:case _u.BUFFER_SEEK_OVER_HOLE:case _u.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=ap())}t.type===Du.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=ap())}getPlaylistRetryOrSwitchAction(e,t){const r=Yf(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(Xf(r,i,Hf(e),e.response))return{action:tp,flags:rp,retryConfig:r,retryCount:i};const s=this.getLevelSwitchAction(e,t);return r&&(s.retryConfig=r,s.retryCount=i),s}getFragRetryOrSwitchAction(e){const t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],{fragLoadPolicy:s,keyLoadPolicy:n}=t.config,a=Yf(Vf(e)?n:s,e),o=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(i&&(e.details!==_u.FRAG_GAP&&i.fragmentError++,!Wf(e))){if(Xf(a,o,Hf(e),e.response))return{action:tp,flags:rp,retryConfig:a,retryCount:o}}const l=this.getLevelSwitchAction(e,r);return a&&(l.retryConfig=a,l.retryCount=o),l}getLevelSwitchAction(e,t){const r=this.hls;null==t&&(t=r.loadLevel);const i=this.hls.levels[t];if(i){var s,n;const t=e.details;i.loadError++,t===_u.BUFFER_APPEND_ERROR&&i.fragmentError++;let l=-1;const{levels:c,loadLevel:d,minAutoLevel:u,maxAutoLevel:h}=r;r.autoLevelEnabled||r.config.preserveManualLevelOnError||(r.loadLevel=-1);const f=null==(s=e.frag)?void 0:s.type,p=(f===Uu&&t===_u.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(t===_u.BUFFER_ADD_CODEC_ERROR||t===_u.BUFFER_APPEND_ERROR))&&c.some(({audioCodec:e})=>i.audioCodec!==e),m="video"===e.sourceBufferName&&(t===_u.BUFFER_ADD_CODEC_ERROR||t===_u.BUFFER_APPEND_ERROR)&&c.some(({codecSet:e,audioCodec:t})=>i.codecSet!==e&&i.audioCodec===t),{type:g,groupId:v}=null!=(n=e.context)?n:{};for(let r=c.length;r--;){const s=(r+d)%c.length;if(s!==d&&s>=u&&s<=h&&0===c[s].loadError){var a,o;const r=c[s];if(t===_u.FRAG_GAP&&f===Bu&&e.frag){const t=c[s].details;if(t){const r=Uf(e.frag,t.fragments,e.frag.start);if(null!=r&&r.gap)continue}}else{if(g===Fu&&r.hasAudioGroup(v)||g===$u&&r.hasSubtitleGroup(v))continue;if(f===Uu&&null!=(a=i.audioGroups)&&a.some(e=>r.hasAudioGroup(e))||f===zu&&null!=(o=i.subtitleGroups)&&o.some(e=>r.hasSubtitleGroup(e))||p&&i.audioCodec===r.audioCodec||m&&i.codecSet===r.codecSet||!p&&i.codecSet!==r.codecSet)continue}l=s;break}}if(l>-1&&r.loadLevel!==l)return e.levelRetry=!0,this.playlistError=0,{action:Jf,flags:rp,nextAutoLevel:l}}return{action:Jf,flags:ip}}onErrorOut(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case Zf:break;case Jf:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===_u.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(e){const t=this.hls,r=e.errorAction;if(!r)return;const{flags:i}=r,s=r.nextAutoLevel;switch(i){case rp:this.switchLevel(e,s);break;case sp:{const i=this.getVariantLevelIndex(e.frag),s=t.levels[i],n=null==s?void 0:s.attrs["HDCP-LEVEL"];if(r.hdcpLevel=n,"NONE"===n)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(n){t.maxHdcpLevel=Ef[Ef.indexOf(n)-1],r.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case np:{const t=e.decryptdata;if(t){const i=this.hls.levels,s=i.length;for(let r=s;r--;){var n,a;if(this.variantHasKey(i[r],t))this.log(`Banned key found in level ${r} (${i[r].bitrate}bps) or audio group "${null==(n=i[r].audioGroups)?void 0:n.join(",")}" (${null==(a=e.frag)?void 0:a.type} fragment) ${sh(t.keyId||[])}`),i[r].fragmentError++,i[r].loadError++,this.log(`Removing level ${r} with key error (${e.error})`),this.hls.removeLevel(r)}const o=e.frag;if(this.hls.levels.length<s)r.resolved=!0;else if(o&&o.type!==Bu){const e=o.decryptdata;e&&!t.matches(e)&&(r.resolved=!0)}}break}}r.resolved||this.switchLevel(e,s)}switchLevel(e,t){if(void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===_u.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName)){const t=hf(e.mimeType),r=this.hls.levels;for(let i=r.length;i--;)r[i][`${e.sourceBufferName}Codec`]===t&&(this.log(`Removing level ${i} for ${e.details} ("${t}" not supported)`),this.hls.removeLevel(i))}}},fpsController:class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const r=this.hls.config;if(r.capLevelOnFPSDrop){const e=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=e,e&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,r){const i=performance.now();if(t){if(this.lastTime){const e=i-this.lastTime,s=r-this.lastDroppedFrames,n=t-this.lastDecodedFrames,a=1e3*s/e,o=this.hls;if(o.trigger(Ou.FPS_DROP,{currentDropped:s,currentDecoded:n,totalDroppedFrames:r}),a>0&&s>o.config.fpsDroppedMonitoringThreshold*n){let e=o.currentLevel;o.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===o.autoLevelCapping||o.autoLevelCapping>=e)&&(e-=1,o.trigger(Ou.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:o.currentLevel}),o.autoLevelCapping=e,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:nm,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,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}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,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:hE,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends og{constructor(e,t,r){super(e,t,r,"subtitle-stream-controller",zu),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Ou.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Ou.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Ou.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Ou.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Ou.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Ou.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Ou.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Ou.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=Xm,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:r,success:i}=t;if(this.fragContextChanged(r)||(Eh(r)&&(this.fragPrevious=r),this.state=Xm),!i)return;const s=this.tracksBuffered[this.currentTrackId];if(!s)return;let n;const a=r.start;for(let e=0;e<s.length;e++)if(a>=s[e].start&&a<=s[e].end){n=s[e];break}const o=r.start+r.duration;n?n.end=o:(n={start:a,end:o},s.push(n)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null),this.media&&this.tick()}onBufferFlushing(e,t){const{startOffset:r,endOffset:i}=t;if(0===r&&i!==Number.POSITIVE_INFINITY){const e=i-1;if(e<=0)return;t.endOffsetSubtitles=Math.max(0,e),this.tracksBuffered.forEach(t=>{for(let r=0;r<t.length;)if(t[r].end<=e)t.shift();else{if(!(t[r].start<e))break;t[r].start=e,r++}}),this.fragmentTracker.removeFragmentsInRange(r,e,zu)}}onError(e,t){const r=t.frag;(null==r?void 0:r.type)===zu&&(t.details===_u.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==qm&&(this.state=Xm))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){this.levels&&Uv(this.levels,t)?this.levels=t.map(e=>new Lf(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{const t=new Lf(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,zu),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(e,t){var r;if(this.currentTrackId=t.id,null==(r=this.levels)||!r.length||-1===this.currentTrackId)return void this.clearInterval();const i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.state!==qm&&this.setInterval(500)}onSubtitleTrackLoaded(e,t){var r;const{currentTrackId:i,levels:s}=this,{details:n,id:a}=t;if(!s)return void this.warn(`Subtitle tracks were reset while loading level ${a}`);const o=s[a];if(a>=s.length||!o)return;this.log(`Subtitle track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(n.live||null!=(r=o.details)&&r.live){if(n.deltaUpdateFailed)return;const e=this.mainDetails;if(!e)return void(this.startFragRequested=!1);const t=e.fragments[0];var c;if(o.details)l=this.alignPlaylists(n,o.details,null==(c=this.levelLastLoaded)?void 0:c.details),0===l&&t&&(l=t.start,_m(n,l));else n.hasProgramDateTime&&e.hasProgramDateTime?(Vm(n,e),l=n.fragmentStart):t&&(l=t.start,_m(n,l));e&&!this.startFragRequested&&this.setStartPosition(e,l)}if(o.details=n,this.levelLastLoaded=o,a===i&&(this.hls.trigger(Ou.SUBTITLE_TRACK_UPDATED,{details:n,id:a,groupId:t.groupId}),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===Xm)){Uf(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)}}_handleFragmentLoadComplete(e){const{frag:t,payload:r}=e,i=t.decryptdata,s=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&null!=i&&i.key&&i.iv&&Hp(i.method)){const e=performance.now();this.decrypter.decrypt(new Uint8Array(r),i.key.buffer,i.iv.buffer,Vp(i.method)).catch(e=>{throw s.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(r=>{const i=performance.now();s.trigger(Ou.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:e,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=Xm})}}doTick(){if(this.media){if(this.state===Xm){const{currentTrackId:e,levels:t}=this,r=null==t?void 0:t[e];if(!r||!t.length||!r.details)return;if(this.waitForLive(r))return;const{config:i}=this,s=this.getLoadPosition(),n=Rp.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],s,i.maxBufferHole),{end:a,len:o}=n,l=r.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;const c=l.fragments,d=c.length,u=l.edge;let h=null;const f=this.fragPrevious;if(a<u){const e=i.maxFragLookUpTolerance,t=a>u-e?0:e;h=Uf(f,c,Math.max(c[0].start,a),t),!h&&f&&f.start<c[0].start&&(h=c[0])}else h=c[d-1];if(h=this.filterReplacedPrimary(h,r.details),!h)return;const p=c[h.sn-l.startSN-1];if(p&&p.cc===h.cc&&this.fragmentTracker.getState(p)===op&&(h=p),this.fragmentTracker.getState(h)===op){const e=this.mapToInitFragWhenRequired(h);e&&this.loadFragment(e,r,a)}}}else this.state=Xm}loadFragment(e,t,r){Eh(e)?super.loadFragment(e,t,r):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new gb(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends Bv{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=null;const t=eb(this.media.textTracks);for(let r=0;r<t.length;r++)if("hidden"===t[r].mode)e=t[r];else if("showing"===t[r].mode){e=t[r];break}const r=this.findTrackForTextTrack(e);this.subtitleTrack!==r&&this.setSubtitleTrack(r)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ou.LEVEL_LOADING,this.onLevelLoading,this),e.on(Ou.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Ou.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Ou.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ou.LEVEL_LOADING,this.onLevelLoading,this),e.off(Ou.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Ou.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Ou.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(e,t){const r=this.media;if(!r)return;const i=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||r.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,i)return;eb(r.textTracks).forEach(e=>{Zy(e)})}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:r,groupId:i,details:s}=t,n=this.tracksInGroup[r];if(!n||n.groupId!==i)return void this.warn(`Subtitle track with id:${r} and group:${i} not found in active group ${null==n?void 0:n.groupId}`);const a=n.details;n.details=t.details,this.log(`Subtitle track ${r} "${n.name}" lang:${n.lang} group:${i} loaded [${s.startSN}-${s.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.subtitleGroups||null,i=this.groupIds;let s=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&r.some(e=>-1===(null==i?void 0:i.indexOf(e)))){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter(e=>!r||-1!==r.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>{e.id=t});else if(!s&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.subtitlePreference;if(!s&&t){this.selectDefaultTrack=!1;const r=Of(t,e);if(r>-1)s=e[r];else{const e=Of(t,this.tracks);s=this.tracks[e]}}let i=this.findTrackId(s);-1===i&&s&&(i=this.findTrackId(null));const n={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${null==r?void 0:r.join(",")}" group-id`),this.hls.trigger(Ou.SUBTITLE_TRACKS_UPDATED,n),-1!==i&&-1===this.trackId&&this.setSubtitleTrack(i)}}findTrackId(e){const t=this.tracksInGroup,r=this.selectDefaultTrack;for(let i=0;i<t.length;i++){const s=t[i];if((!r||s.default)&&(r||e)&&(!e||Mf(s,e)))return i}if(e){for(let r=0;r<t.length;r++){const i=t[r];if(zv(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(zv(e.attrs,i.attrs,["LANGUAGE"]))return r}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){if(Gv(t[r],e))return r}}return-1}onError(e,t){!t.fatal&&t.context&&(t.context.type!==$u||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const r=this.currentTrack;if(r&&Mf(e,r))return r;const i=Of(e,this.tracksInGroup);if(i>-1){const e=this.tracksInGroup[i];return this.setSubtitleTrack(i),e}if(r)return null;{const r=Of(e,t);if(r>-1)return t[r]}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const r=e.id,i=e.groupId,s=this.getUrlWithDirectives(e.url,t),n=e.details,a=null==n?void 0:n.age;this.log(`Loading subtitle ${r} "${e.name}" lang:${e.lang} group:${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${a&&n.live?" age "+a.toFixed(1)+(n.type&&" "+n.type||""):""} ${s}`),this.hls.trigger(Ou.SUBTITLE_TRACK_LOADING,{url:s,id:r,groupId:i,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=eb(e.textTracks),r=this.currentTrack;let i;if(r&&(i=t.filter(e=>Gv(r,e))[0],i||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(t).forEach(e=>{"disabled"!==e.mode&&e!==i&&(e.mode="disabled")}),i){const e=this.subtitleDisplay?"showing":"hidden";i.mode!==e&&(i.mode=e)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=e);if(e<-1||e>=t.length||!Ru(e))return void this.warn(`Invalid subtitle track id: ${e}`);this.selectDefaultTrack=!1;const r=this.currentTrack,i=t[e]||null;if(this.trackId=e,this.currentTrack=i,this.toggleTrackModes(),!i)return void this.hls.trigger(Ou.SUBTITLE_TRACK_SWITCH,{id:e});const s=!!i.details&&!i.details.live;if(e===this.trackId&&i===r&&s)return;this.log(`Switching to subtitle-track ${e}`+(i?` "${i.name}" lang:${i.lang} group:${i.groupId}`:""));const{id:n,groupId:a="",name:o,type:l,url:c}=i;this.hls.trigger(Ou.SUBTITLE_TRACK_SWITCH,{id:n,groupId:a,name:o,type:l,url:c});const d=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(d)}},timelineController:class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Ou.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Ou.FRAG_LOADING,this.onFragLoading,this),e.on(Ou.FRAG_LOADED,this.onFragLoaded,this),e.on(Ou.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(Ou.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(Ou.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Ou.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Ou.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Ou.FRAG_LOADING,this.onFragLoading,this),e.off(Ou.FRAG_LOADED,this.onFragLoaded,this),e.off(Ou.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(Ou.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(Ou.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Ou.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new oE(this,"textTrack1"),t=new oE(this,"textTrack2"),r=new oE(this,"textTrack3"),i=new oE(this,"textTrack4");this.cea608Parser1=new _b(1,e,t),this.cea608Parser2=new _b(3,r,i)}addCues(e,t,r,i,s){let n=!1;for(let e=s.length;e--;){const i=s[e],a=dE(i[0],i[1],t,r);if(a>=0&&(i[0]=Math.min(i[0],t),i[1]=Math.max(i[1],r),n=!0,a/(r-t)>.5))return}if(n||s.push([t,r]),this.config.renderTextTracksNatively){const s=this.captionsTracks[e];this.Cues.newCue(s,t,r,i)}else{const s=this.Cues.newCue(null,t,r,i);this.hls.trigger(Ou.CUES_PARSED,{type:"captions",cues:s,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:s,trackId:n}){const{unparsedVttFrags:a}=this;r===Bu&&(this.initPTS[t.cc]={baseTime:i,timescale:s,trackId:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(Ou.FRAG_LOADED,e):this.hls.trigger(Ou.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,t){const{media:r}=this;if(r)for(let i=0;i<r.textTracks.length;i++){const s=r.textTracks[i];if(cE(s,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return s}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:r,media:i}=this,{label:s,languageCode:n}=t[e],a=this.getExistingTrack(s,n);if(a)r[e]=a,Zy(r[e]),Xy(r[e],i);else{const t=this.createTextTrack("captions",s,n);t&&(t[e]=!0,r[e]=t)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(Ou.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}createTextTrack(e,t,r){const i=this.media;if(i)return i.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}onMediaDetaching(e,t){const r=!!t.transferMedia;if(this.media=null,r)return;const{captionsTracks:i}=this;Object.keys(i).forEach(e=>{Zy(i[e]),delete i[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,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())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let e=0;e<t.length;e++)Zy(t[e])}onSubtitleTracksUpdated(e,t){const r=t.subtitleTracks||[],i=r.some(e=>e.textCodec===Xb);if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(Uv(this.tracks,r))return void(this.tracks=r);if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const e=this.media,t=e?eb(e.textTracks):null;if(this.tracks.forEach((e,r)=>{let i;if(t){let r=null;for(let i=0;i<t.length;i++)if(t[i]&&cE(t[i],e)){r=t[i],t[i]=null;break}r&&(i=r)}if(i)Zy(i);else{const t=lE(e);i=this.createTextTrack(t,e.name,e.lang),i&&(i.mode="disabled")}i&&this.textTracks.push(i)}),null!=t&&t.length){const e=t.filter(e=>null!==e).map(e=>e.label);e.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${e.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const e=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(Ou.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{const t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(!t)return;const r=`textTrack${t[1]}`,i=this.captionsProperties[r];i&&(i.label=e.name,e.lang&&(i.languageCode=e.lang),i.media=e)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===Bu){var r,i;const{cea608Parser1:e,cea608Parser2:s,lastSn:n}=this,{cc:a,sn:o}=t.frag,l=null!=(r=null==(i=t.part)?void 0:i.index)?r:-1;e&&s&&(o!==n+1||o===n&&l!==this.lastPartIndex+1||a!==this.lastCc)&&(e.reset(),s.reset()),this.lastCc=a,this.lastSn=o,this.lastPartIndex=l}}onFragLoaded(e,t){const{frag:r,payload:i}=t;if(r.type===zu)if(i.byteLength){const e=r.decryptdata,s="stats"in t;if(null==e||!e.encrypted||s){const e=this.tracks[r.level],s=this.vttCCs;s[r.cc]||(s[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),e&&e.textCodec===Xb?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(Ou.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;eE(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),r.trigger(Ou.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{r.logger.log(`Failed to parse IMSC1: ${t}`),r.trigger(Ou.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}_parseVTTs(e){var t;const{frag:r,payload:i}=e,{initPTS:s,unparsedVttFrags:n}=this,a=s.length-1;if(!s[r.cc]&&-1===a)return void n.push(e);const o=this.hls;qb(null!=(t=r.initSegment)&&t.data?Gh(r.initSegment.data,new Uint8Array(i)).buffer:i,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,e=>{this._appendCues(e,r.level),o.trigger(Ou.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},t=>{const s="Missing initPTS for VTT MPEGTS"===t.message;s?n.push(e):this._fallbackToIMSC1(r,i),o.logger.log(`Failed to parse VTT cue: ${t}`),s&&a>r.cc||o.trigger(Ou.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:t})})}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||eE(t,this.initPTS[e.cc],()=>{r.textCodec=Xb,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){const r=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];if(!r||"disabled"===r.mode)return;e.forEach(e=>Qy(r,e))}else{const i=this.tracks[t];if(!i)return;const s=i.default?"default":"subtitles"+t;r.trigger(Ou.CUES_PARSED,{type:"subtitles",cues:e,track:s})}}onFragDecrypted(e,t){const{frag:r}=t;r.type===zu&&this.onFragLoaded(Ou.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:r,samples:i}=t;if(r.type!==Bu||"NONE"!==this.closedCaptionsForLevel(r))for(let e=0;e<i.length;e++){const t=i[e].bytes;if(t){this.cea608Parser1||this.initCea608Parsers();const r=this.extractCea608Data(t);this.cea608Parser1.addData(i[e].pts,r[0]),this.cea608Parser2.addData(i[e].pts,r[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:i,type:s}){const{media:n}=this;if(n&&!(n.currentTime<r)){if(!s||"video"===s){const{captionsTracks:e}=this;Object.keys(e).forEach(i=>Jy(e[i],t,r))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==i){const{textTracks:e}=this;Object.keys(e).forEach(r=>Jy(e[r],t,i))}}}extractCea608Data(e){const t=[[],[]],r=31&e[0];let i=2;for(let s=0;s<r;s++){const r=e[i++],s=127&e[i++],n=127&e[i++];if(0===s&&0===n)continue;if(!!(4&r)){const e=3&r;0!==e&&1!==e||(t[e].push(s),t[e].push(n))}}return t}},audioStreamController:class extends og{constructor(e,t,r){super(e,t,r,"audio-stream-controller",Uu),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Ou.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(Ou.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Ou.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Ou.BUFFER_RESET,this.onBufferReset,this),e.on(Ou.BUFFER_CREATED,this.onBufferCreated,this),e.on(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Ou.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Ou.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(Ou.FRAG_LOADING,this.onFragLoading,this),e.on(Ou.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Ou.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(Ou.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Ou.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Ou.BUFFER_RESET,this.onBufferReset,this),e.off(Ou.BUFFER_CREATED,this.onBufferCreated,this),e.off(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Ou.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Ou.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(Ou.FRAG_LOADING,this.onFragLoading,this),e.off(Ou.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:s,trackId:n}){if(r===Bu){const e=t.cc,r=this.fragCurrent;if(this.initPTS[e]={baseTime:i,timescale:s,trackId:n},this.log(`InitPTS for cc: ${e} found from main: ${i/s} (${i}/${s}) trackId: ${n}`),this.mainAnchor=t,this.state===ng){const r=this.waitingData;(!r&&!this.loadingParts||r&&r.frag.cc!==e)&&this.syncWithAnchor(t,null==r?void 0:r.frag)}else!this.hls.hasEnoughToStart&&r&&r.cc!==e?(r.abortRequests(),this.syncWithAnchor(t,r)):this.state===Xm&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var r;const i=(null==(r=this.mainFragLoading)?void 0:r.frag)||null;if(t&&(null==i?void 0:i.cc)===t.cc)return;const s=(i||e).cc,n=jf(this.getLevelDetails(),s,this.getLoadPosition());n&&(this.log(`Syncing with main frag at ${n.start} cc ${n.cc}`),this.startFragRequested=!1,this.nextLoadPosition=n.start,this.resetLoadingState(),this.state===Xm&&this.doTickIdle())}startLoad(e,t){if(!this.levels)return this.startPosition=e,void(this.state=qm);const r=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),r>0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${r.toFixed(3)}`),e=r,this.state=Xm):this.state=eg,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case Xm:this.doTickIdle();break;case eg:{const{levels:e,trackId:t}=this,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&!this.waitForLive(r)){if(this.waitForCdnTuneIn(i))break;this.state=ng}break}case Jm:this.checkRetryDate();break;case ng:{const e=this.waitingData;if(e){const{frag:t,part:r,cache:i,complete:s}=e,n=this.mainAnchor;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.state=Zm;const e={frag:t,part:r,payload:i.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(e),s&&super._handleFragmentLoadComplete(e)}else n&&n.cc!==e.frag.cc&&this.syncWithAnchor(n,e.frag)}else this.state=Xm}}this.onTickEnd()}resetLoadingState(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:e}=this;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){var e;const{hls:t,levels:r,media:i,trackId:s}=this,n=t.config;if(!this.buffering||!i&&!this.primaryPrefetch&&(this.startFragRequested||!n.startFragPrefetch)||null==r||!r[s])return;const a=r[s],o=a.details;if(!o||this.waitForLive(a)||this.waitForCdnTuneIn(o))return this.state=eg,void(this.startFragRequested=!1);const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,gh,Uu));const c=this.getFwdBufferInfo(l,Uu);if(null===c)return;if(!this.switchingTrack&&this._streamEnded(c,o))return t.trigger(Ou.BUFFER_EOS,{type:"audio"}),void(this.state=ig);const d=c.len,u=t.maxBufferLength,h=o.fragments,f=h[0].start,p=this.getLoadPosition(),m=this.flushing?p:c.end;if(this.switchingTrack&&i){const e=p;o.PTSKnown&&e<f&&(c.end>f||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=f+.05)}if(d>=u&&!this.switchingTrack&&m<h[h.length-1].start)return;let g=this.getNextFragment(m,o);if(g&&this.isLoopLoading(g,m)&&(g=this.getNextFragmentLoopLoading(g,o,c,Bu,u)),!g)return void(this.bufferFlushed=!0);let v=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&v&&Eh(g)&&!g.endList&&(!o.live||!this.loadingParts&&m<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(v)===dp&&(this.mainFragLoading=v=null),v&&Eh(v))){if(g.start>v.end){const e=this.fragmentTracker.getFragAtPos(m,Bu);e&&e.end>v.end&&(v=e,this.mainFragLoading={frag:e,targetBufferTime:null})}if(g.start>v.end)return}this.loadFragment(g,a,m)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new Lf(e))}onAudioTrackSwitching(e,t){const r=!!t.url;this.trackId=t.id;const{fragCurrent:i}=this;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),r?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==qm&&(this.setInterval(100),this.state=Xm,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;const r=this.cachedTrackLoadedData;r&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(Ou.AUDIO_TRACK_LOADED,r))}onAudioTrackLoaded(e,t){var r;const{levels:i}=this,{details:s,id:n,groupId:a,track:o}=t;if(!i)return void this.warn(`Audio tracks reset while loading track ${n} "${o.name}" of "${a}"`);const l=this.mainDetails;if(!l||s.endCC>l.endCC||l.expired)return this.cachedTrackLoadedData=t,void(this.state!==qm&&(this.state=eg));this.cachedTrackLoadedData=null,this.log(`Audio track ${n} "${o.name}" of "${a}" loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""},duration:${s.totalduration}`);const c=i[n];let d=0;if(s.live||null!=(r=c.details)&&r.live){if(this.checkLiveUpdate(s),s.deltaUpdateFailed)return;var u;if(c.details)d=this.alignPlaylists(s,c.details,null==(u=this.levelLastLoaded)?void 0:u.details);s.alignedSliding||(Hm(s,l),s.alignedSliding||Vm(s,l),d=s.fragmentStart)}c.details=s,this.levelLastLoaded=c,this.startFragRequested||this.setStartPosition(l,d),this.hls.trigger(Ou.AUDIO_TRACK_UPDATED,{details:s,id:n,groupId:t.groupId}),this.state!==eg||this.waitForCdnTuneIn(s)||(this.state=Xm),this.tick()}_handleFragmentLoadProgress(e){var t;const r=e.frag,{part:i,payload:s}=e,{config:n,trackId:a,levels:o}=this;if(!o)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);const l=o[a];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const c=l.details;if(!c)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);const d=n.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let u=this.transmuxer;u||(u=this.transmuxer=new $v(this.hls,Uu,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const h=this.initPTS[r.cc],f=null==(t=r.initSegment)?void 0:t.data;if(void 0!==h){const e=!1,t=i?i.index:-1,n=-1!==t,a=new Lp(r.level,r.sn,r.stats.chunkCount,s.byteLength,t,n);u.push(s,f,d,"",r,i,c.totalduration,e,a,h)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${c.startSN} ,${c.endSN}],track ${a}`);const{cache:e}=this.waitingData=this.waitingData||{frag:r,part:i,cache:new cg,complete:!1};e.push(new Uint8Array(s)),this.state!==qm&&(this.state=ng)}}_handleFragmentLoadComplete(e){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;const r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===Bu&&Eh(t.frag)&&(this.mainFragLoading=t,this.state===Xm&&this.tick())}onFragBuffered(e,t){const{frag:r,part:i}=t;if(r.type===Uu)if(this.fragContextChanged(r))this.warn(`Fragment ${r.sn}${i?" p: "+i.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if(Eh(r)){this.fragPrevious=r;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(Ou.AUDIO_TRACK_SWITCHED,Yu({},e)))}this.fragBufferedComplete(r,i),this.media&&this.tick()}else this.audioOnly||r.type!==Bu||r.elementaryStreams.video||r.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}onError(e,t){var r;if(t.fatal)this.state=sg;else switch(t.details){case _u.FRAG_GAP:case _u.FRAG_PARSING_ERROR:case _u.FRAG_DECRYPT_ERROR:case _u.FRAG_LOAD_ERROR:case _u.FRAG_LOAD_TIMEOUT:case _u.KEY_LOAD_ERROR:case _u.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Uu,t);break;case _u.AUDIO_TRACK_LOAD_ERROR:case _u.AUDIO_TRACK_LOAD_TIMEOUT:case _u.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==eg||(null==(r=t.context)?void 0:r.type)!==Fu||(this.state=Xm);break;case _u.BUFFER_ADD_CODEC_ERROR:case _u.BUFFER_APPEND_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case _u.BUFFER_FULL_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case _u.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,{type:t}){t!==vh&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==vh){this.flushing=!1,this.bufferFlushed=!0,this.state===ig&&(this.state=Xm);const e=this.mediaBuffer||this.media;e&&(this.afterBufferFlushed(e,t,Uu),this.tick())}}_handleTransmuxComplete(e){var t;const r="audio",{hls:i}=this,{remuxResult:s,chunkMeta:n}=e,a=this.getCurrentContext(n);if(!a)return void this.resetWhenMissingContext(n);const{frag:o,part:l,level:c}=a,{details:d}=c,{audio:u,text:h,id3:f,initSegment:p}=s;if(!this.fragContextChanged(o)&&d){if(this.state=tg,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=p&&p.tracks){const e=o.initSegment||o;if(this.unhandledEncryptionError(p,o))return;this._bufferInitSegment(c,p.tracks,e,n),i.trigger(Ou.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:r,tracks:p.tracks})}if(u){const{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=u;l&&(l.elementaryStreams[gh]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(gh,e,t,r,i),this.bufferFragmentData(u,o,l,n)}if(null!=f&&null!=(t=f.samples)&&t.length){const e=Vu({id:r,frag:o,details:d},f);i.trigger(Ou.FRAG_PARSING_METADATA,e)}if(h){const e=Vu({id:r,frag:o,details:d},h);i.trigger(Ou.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(e,t,r,i){if(this.state!==tg)return;if(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio)return;const s=t.audio;s.id=Uu;const n=e.audioCodec;this.log(`Init audio buffer, container:${s.container}, codecs[level/parsed]=[${n}/${s.codec}]`),n&&1===n.split(",").length&&(s.levelCodec=n),this.hls.trigger(Ou.BUFFER_CODECS,t);const a=s.initSegment;if(null!=a&&a.byteLength){const e={type:"audio",frag:r,part:null,chunkMeta:i,parent:r.type,data:a};this.hls.trigger(Ou.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);var s;if(this.switchingTrack||i===op||i===cp)if(Eh(e))if(null!=(s=t.details)&&s.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=ng;const r=this.mainDetails;r&&r.fragmentStart!==t.details.fragmentStart&&Vm(t.details,r)}else super.loadFragment(e,t,r);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){const{name:t,lang:r,assocLang:i,characteristics:s,audioCodec:n,channels:a}=this.bufferedTrack;Mf({name:t,lang:r,assocLang:i,characteristics:s,audioCodec:n,channels:a},e,Nf)||($f(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(Ou.AUDIO_TRACK_SWITCHED,Yu({},e))}},audioTrackController:class extends Bv{constructor(e){super(e,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ou.LEVEL_LOADING,this.onLevelLoading,this),e.on(Ou.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Ou.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Ou.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ou.LEVEL_LOADING,this.onLevelLoading,this),e.off(Ou.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Ou.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Ou.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:r,groupId:i,details:s}=t,n=this.tracksInGroup[r];if(!n||n.groupId!==i)return void this.warn(`Audio track with id:${r} and group:${i} not found in active group ${null==n?void 0:n.groupId}`);const a=n.details;n.details=t.details,this.log(`Audio track ${r} "${n.name}" lang:${n.lang} group:${i} loaded [${s.startSN}-${s.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.audioGroups||null,i=this.groupIds;let s=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&r.some(e=>-1===(null==i?void 0:i.indexOf(e)))){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter(e=>!r||-1!==r.indexOf(e.groupId));if(e.length)this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),e.forEach((e,t)=>{e.id=t});else if(!s&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.audioPreference;if(!s&&t){const r=Of(t,e,Nf);if(r>-1)s=e[r];else{const e=Of(t,this.tracks);s=this.tracks[e]}}let i=this.findTrackId(s);-1===i&&s&&(i=this.findTrackId(null));const a={audioTracks:e};this.log(`Updating audio tracks, ${e.length} track(s) found in group(s): ${null==r?void 0:r.join(",")}`),this.hls.trigger(Ou.AUDIO_TRACKS_UPDATED,a);const o=this.trackId;if(-1!==i&&-1===o)this.setAudioTrack(i);else if(e.length&&-1===o){var n;const t=new Error(`No audio track selected for current audio group-ID(s): ${null==(n=this.groupIds)?void 0:n.join(",")} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}}onError(e,t){!t.fatal&&t.context&&(t.context.type!==Fu||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){const i=this.currentTrack;if(i&&Mf(e,i,Nf))return i;const s=Of(e,this.tracksInGroup,Nf);if(s>-1){const e=this.tracksInGroup[s];return this.setAudioTrack(s),e}if(i){let i=t.loadLevel;-1===i&&(i=t.firstAutoLevel);const s=function(e,t,r,i,s){const n=t[i],a=t.reduce((e,t,r)=>{const i=t.uri;return(e[i]||(e[i]=[])).push(r),e},{})[n.uri];a.length>1&&(i=Math.max.apply(Math,a));const o=n.videoRange,l=n.frameRate,c=n.codecSet.substring(0,4),d=Ff(t,i,t=>{if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==c)return!1;const i=t.audioGroups,n=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return Of(e,n,s)>-1});return d>-1?d:Ff(t,i,t=>{const i=t.audioGroups,n=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return Of(e,n,s)>-1})}(e,t.levels,r,i,Nf);if(-1===s)return null;t.nextLoadLevel=s}if(e.channels||e.audioCodec){const t=Of(e,r);if(t>-1)return r[t]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length)return void this.warn(`Invalid audio track id: ${e}`);this.selectDefaultTrack=!1;const r=this.currentTrack,i=t[e],s=i.details&&!i.details.live;if(e===this.trackId&&i===r&&s)return;if(this.log(`Switching to audio-track ${e} "${i.name}" lang:${i.lang} group:${i.groupId} channels:${i.channels}`),this.trackId=e,this.currentTrack=i,this.hls.trigger(Ou.AUDIO_TRACK_SWITCHING,Yu({},i)),s)return;const n=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(n)}findTrackId(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||Mf(e,i,Nf)))return r}if(e){const{name:r,lang:i,assocLang:s,characteristics:n,audioCodec:a,channels:o}=e;for(let e=0;e<t.length;e++){if(Mf({name:r,lang:i,assocLang:s,characteristics:n,audioCodec:a,channels:o},t[e],Nf))return e}for(let r=0;r<t.length;r++){const i=t[r];if(zv(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(zv(e.attrs,i.attrs,["LANGUAGE"]))return r}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&$f(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const r=e.id,i=e.groupId,s=this.getUrlWithDirectives(e.url,t),n=e.details,a=null==n?void 0:n.age;this.log(`Loading audio-track ${r} "${e.name}" lang:${e.lang} group:${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${a&&n.live?" age "+a.toFixed(1)+(n.type&&" "+n.type||""):""} ${s}`),this.hls.trigger(Ou.AUDIO_TRACK_LOADING,{url:s,id:r,groupId:i,deliveryDirectives:t||null,track:e})}},emeController:Vy,cmcdController:class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=e=>{try{this.apply(e,{ot:Xv.MANIFEST,su:!this.initialized})}catch(e){this.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{const{frag:t,part:r}=e,i=this.hls.levels[t.level],s=this.getObjectType(t),n={d:1e3*(r||t).duration,ot:s};s!==Xv.VIDEO&&s!==Xv.AUDIO&&s!=Xv.MUXED||(n.br=i.bitrate/1e3,n.tb=this.getTopBandwidth(s)/1e3,n.bl=this.getBufferLength(s));const a=r?this.getNextPart(r):this.getNextFrag(t);null!=a&&a.url&&a.url!==t.url&&(n.nor=a.url),this.apply(e,n)}catch(e){this.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=e;const t=this.config=e.config,{cmcd:r}=t;null!=r&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||e.sessionId,this.cid=r.contentId,this.useHeaders=!0===r.useHeaders,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ou.MEDIA_DETACHED,this.onMediaDetached,this),e.on(Ou.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ou.MEDIA_DETACHED,this.onMediaDetached,this),e.off(Ou.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,i;this.audioBuffer=null==(r=t.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(i=t.tracks.video)?void 0:i.buffer}createData(){var e;return{v:1,sf:Qv.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Vu(t,this.createData());const r=t.ot===Xv.INIT||t.ot===Xv.VIDEO||t.ot===Xv.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);const{includeKeys:i}=this;i&&(t=Object.keys(t).reduce((e,r)=>(i.includes(r)&&(e[r]=t[r]),e),{}));const s={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),By(e.headers,t,s)):e.url=Gy(e.url,t,s)}getNextFrag(e){var t;const r=null==(t=this.hls.levels[e.level])?void 0:t.details;if(r){const t=e.sn-r.startSN;return r.fragments[t+1]}}getNextPart(e){var t;const{index:r,fragment:i}=e,s=null==(t=this.hls.levels[i.level])||null==(t=t.details)?void 0:t.partList;if(s){const{sn:e}=i;for(let t=s.length-1;t>=0;t--){const i=s[t];if(i.index===r&&i.fragment.sn===e)return s[t+1]}}}getObjectType(e){const{type:t}=e;return"subtitle"===t?Xv.TIMED_TEXT:"initSegment"===e.sn?Xv.INIT:"audio"===t?Xv.AUDIO:"main"===t?this.hls.audioTracks.length?Xv.VIDEO:Xv.MUXED:void 0}getTopBandwidth(e){let t,r=0;const i=this.hls;if(e===Xv.AUDIO)t=i.audioTracks;else{const e=i.maxAutoLevel,r=e>-1?e+1:i.levels.length;t=i.levels.slice(0,r)}return t.forEach(e=>{e.bitrate>r&&(r=e.bitrate)}),r>0?r:NaN}getBufferLength(e){const t=this.media,r=e===Xv.AUDIO?this.audioBuffer:this.videoBuffer;if(!r||!t)return NaN;return 1e3*Rp.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new r(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,r,i){t(e),this.loader.load(e,r,i)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new r(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,r,i){t(e),this.loader.load(e,r,i)}}}},contentSteeringController:class extends Ku{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ou.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ou.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:r}=t;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:r}=t;if((null==r?void 0:r.action)===Jf&&r.flags===ip){const e=this.levels;let i=this._pathwayPriority,s=this.pathwayId;if(t.context){const{groupId:r,pathwayId:i,type:n}=t.context;r&&e?s=this.getPathwayForGroupId(r,n,s):i&&(s=i)}s in this.penalizedPathways||(this.penalizedPathways[s]=performance.now()),!i&&e&&(i=this.pathways()),i&&i.length>1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==s),t.details!==_u.BUFFER_APPEND_ERROR||t.fatal?r.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${s} levels: ${e?e.length:e} priorities: ${Pf(i)} penalized: ${Pf(this.penalizedPathways)}`):r.resolved=!0}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){const r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){let t;this._pathwayPriority=e;const r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(e=>{i-r[e]>3e5&&delete r[e]});for(let i=0;i<e.length;i++){const s=e[i];if(s in r)continue;if(s===this.pathwayId)return;const n=this.hls.nextLoadLevel,a=this.hls.levels[n];if(t=this.getLevelsForPathway(s),t.length>0){this.log(`Setting Pathway to "${s}"`),this.pathwayId=s,$m(t),this.hls.trigger(Ou.LEVELS_UPDATED,{levels:t});const e=this.hls.levels[n];a&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==a.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==a.bitrate&&this.log(`Unstable Pathways change from bitrate ${a.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=n);break}}}getPathwayForGroupId(e,t,r){const i=this.getLevelsForPathway(r).concat(this.levels||[]);for(let r=0;r<i.length;r++)if(t===Fu&&i[r].hasAudioGroup(e)||t===$u&&i[r].hasSubtitleGroup(e))return i[r].pathwayId;return r}clonePathways(e){const t=this.levels;if(!t)return;const r={},i={};e.forEach(e=>{const{ID:s,"BASE-ID":n,"URI-REPLACEMENT":a}=e;if(t.some(e=>e.pathwayId===s))return;const o=this.getLevelsForPathway(n).map(e=>{const t=new Fp(e.attrs);t["PATHWAY-ID"]=s;const n=t.AUDIO&&`${t.AUDIO}_clone_${s}`,o=t.SUBTITLES&&`${t.SUBTITLES}_clone_${s}`;n&&(r[t.AUDIO]=n,t.AUDIO=n),o&&(i[t.SUBTITLES]=o,t.SUBTITLES=o);const l=Hy(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),c=new Lf({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:l,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(let t=1;t<e.audioGroups.length;t++)c.addGroupId("audio",`${e.audioGroups[t]}_clone_${s}`);if(e.subtitleGroups)for(let t=1;t<e.subtitleGroups.length;t++)c.addGroupId("text",`${e.subtitleGroups[t]}_clone_${s}`);return c});t.push(...o),jy(this.audioTracks,r,a,s),jy(this.subtitleTracks,i,a,s)})}loadSteeringManifest(e){const t=this.hls.config,r=t.loader;let i;this.loader&&this.loader.destroy(),this.loader=new r(t);try{i=new self.URL(e)}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${e}`)}if("data:"!==i.protocol){const e=0|(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate);i.searchParams.set("_HLS_pathway",this.pathwayId),i.searchParams.set("_HLS_throughput",""+e)}const s={responseType:"json",url:i.href},n=t.steeringManifestLoadPolicy.default,a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(e,t,r,s)=>{this.log(`Loaded steering manifest: "${i}"`);const n=e.data;if(1!==(null==n?void 0:n.VERSION))return void this.log(`Steering VERSION ${n.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=n.TTL;const{"RELOAD-URI":a,"PATHWAY-CLONES":o,"PATHWAY-PRIORITY":l}=n;if(a)try{this.uri=new self.URL(a,i).href}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${a}`)}this.scheduleRefresh(this.uri||r.url),o&&this.clonePathways(o);const c={steeringManifest:n,url:i.toString()};this.hls.trigger(Ou.STEERING_MANIFEST_LOADED,c),l&&this.updatePathwayPriority(l)},onError:(e,t,r,i)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)return this.enabled=!1,void this.log(`Steering manifest ${t.url} no longer available`);let s=1e3*this.timeToLoad;if(429===e.code){const e=this.loader;if("function"==typeof(null==e?void 0:e.getResponseHeader)){const t=e.getResponseHeader("Retry-After");t&&(s=1e3*parseFloat(t))}return void this.log(`Steering manifest ${t.url} rate limited`)}this.scheduleRefresh(this.uri||t.url,s)},onTimeout:(e,t,r)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log(`Requesting steering manifest: ${i}`),this.loader.load(s,o,l)}scheduleRefresh(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var t;const r=null==(t=this.hls)?void 0:t.media;!r||r.ended?this.scheduleRefresh(e,1e3*this.timeToLoad):this.loadSteeringManifest(e)},t)}},interstitialsController:class extends Ku{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const e=this.currentTime;if(void 0===e||this.playbackDisabled||!this.schedule)return;const t=e-this.timelinePos;if(Math.abs(t)<1/7056e5)return;const r=t<=-.01;this.timelinePos=e,this.bufferedPos=e;const i=this.playingItem;if(!i)return void this.checkBuffer();if(r){this.schedule.resetErrorsInRange(e,e-t)&&this.updateSchedule(!0)}if(this.checkBuffer(),r&&e<i.start||e>=i.end){var s;const t=this.findItemIndex(i);let n=this.schedule.findItemIndexAtTime(e);if(-1===n&&(n=t+(r?-1:1),this.log(`seeked ${r?"back ":""}to position not covered by schedule ${e} (resolving from ${t} to ${n})`)),!this.isInterstitial(i)&&null!=(s=this.media)&&s.paused&&(this.shouldPlay=!1),!r&&n>t){const e=this.schedule.findJumpRestrictedIndex(t+1,n);if(e>t)return void this.setSchedulePosition(e)}return void this.setSchedulePosition(n)}const n=this.playingAsset;if(!n){if(this.playingLastItem&&this.isInterstitial(i)){const t=i.event.assetList[0];t&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(e,t))}return}const a=n.timelineStart,o=n.duration||0;var l;(r&&e<a||e>=a+o)&&(null!=(l=i.event)&&l.appendInPlace&&(this.clearAssetPlayers(i.event,i),this.flushFrontBuffer(e)),this.setScheduleToAssetAtTime(e,n))},this.onTimeupdate=()=>{const e=this.currentTime;if(void 0===e||this.playbackDisabled)return;if(!(e>this.timelinePos))return;this.timelinePos=e,e>this.bufferedPos&&this.checkBuffer();const t=this.playingItem;if(!t||this.playingLastItem)return;if(e>=t.end){this.timelinePos=t.end;const e=this.findItemIndex(t);this.setSchedulePosition(e+1)}const r=this.playingAsset;if(!r)return;e>=r.timelineStart+(r.duration||0)&&this.setScheduleToAssetAtTime(e,r)},this.onScheduleUpdate=(e,t)=>{const r=this.schedule;if(!r)return;const i=this.playingItem,s=r.events||[],n=r.items||[],a=r.durations,o=e.map(e=>e.identifier),l=!(!s.length&&!o.length);(l||t)&&this.log(`INTERSTITIALS_UPDATED (${s.length}): ${s}\nSchedule: ${n.map(e=>hb(e))} pos: ${this.timelinePos}`),o.length&&this.log(`Removed events ${o}`);let c=null,d=null;i&&(c=this.updateItem(i,this.timelinePos),this.itemsMatch(i,c)?this.playingItem=c:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const u=this.bufferingItem;if(u&&(d=this.updateItem(u,this.bufferedPos),this.itemsMatch(u,d)?this.bufferingItem=d:u.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(u.event,null))),e.forEach(e=>{e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,null)})}),this.playerQueue.forEach(e=>{if(e.interstitial.appendInPlace){const t=e.assetItem.timelineStart,r=e.timelineOffset-t;if(r)try{e.timelineOffset=t}catch(i){Math.abs(r)>rb&&this.warn(`${i} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),l||t){if(this.hls.trigger(Ou.INTERSTITIALS_UPDATED,{events:s.slice(0),schedule:n.slice(0),durations:a,removedIds:o}),this.isInterstitial(i)&&o.includes(i.event.identifier))return this.warn(`Interstitial "${i.event.identifier}" removed while playing`),void this.primaryFallback(i.event);i&&this.trimInPlace(c,i),u&&d!==c&&this.trimInPlace(d,u),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new fb(e),this.schedule=new ub(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Ou.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Ou.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(Ou.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Ou.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(Ou.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(Ou.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(Ou.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Ou.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Ou.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(Ou.MEDIA_ENDED,this.onMediaEnded,this),e.on(Ou.ERROR,this.onError,this),e.on(Ou.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Ou.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Ou.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(Ou.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Ou.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(Ou.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(Ou.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(Ou.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Ou.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Ou.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Ou.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(Ou.MEDIA_ENDED,this.onMediaEnded,this),e.off(Ou.ERROR,this.onError,this),e.off(Ou.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;null==(e=this.getBufferingPlayer())||e.resumeBuffering()}pauseBuffering(){var e;null==(e=this.getBufferingPlayer())||e.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){Ym(e,"play",this.onPlay),Ym(e,"pause",this.onPause),Ym(e,"seeking",this.onSeeking),Ym(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const r=this.media=t.media;Wm(r,"seeking",this.onSeeking),Wm(r,"timeupdate",this.onTimeupdate),Wm(r,"play",this.onPlay),Wm(r,"pause",this.onPause)}onMediaAttached(e,t){const r=this.effectivePlayingItem,i=this.detachedData;if(this.detachedData=null,null===r)this.checkStart();else if(!i){this.clearScheduleState();const e=this.findItemIndex(r);this.setSchedulePosition(e)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){const r=!!t.transferMedia,i=this.media;if(this.media=null,!r&&(i&&this.removeMediaListeners(i),this.detachedData)){const e=this.getBufferingPlayer();e&&(this.log(`Removing schedule state for detachedData and ${e}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,e.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const e=this,t=()=>e.bufferingItem||e.waitingItem,r=t=>t?e.getAssetPlayer(t.identifier):t,i=(t,i,n,a,o)=>{if(t){let l=t[i].start;const c=t.event;if(c){if("playout"===i||c.timelineOccupancy!==ib.Point){const e=r(n);(null==e?void 0:e.interstitial)===c&&(l+=e.assetItem.startOffset+e[o])}}else{l+=("bufferedPos"===a?s():e[a])-t.start}return l}return 0},s=()=>{const t=e.bufferedPos;return t===Number.MAX_VALUE?n("primary"):Math.max(t,0)},n=t=>{var r,i;return null!=(r=e.primaryDetails)&&r.live?e.primaryDetails.edge:(null==(i=e.schedule)?void 0:i.durations[t])||0},a=(t,s)=>{var n,a;const o=e.effectivePlayingItem;if(null!=o&&null!=(n=o.event)&&n.restrictions.skip||!e.schedule)return;e.log(`seek to ${t} "${s}"`);const l=e.effectivePlayingItem,c=e.schedule.findItemIndexAtTime(t,s),d=null==(a=e.schedule.items)?void 0:a[c],u=e.getBufferingPlayer(),h=null==u?void 0:u.interstitial,f=null==h?void 0:h.appendInPlace,p=l&&e.itemsMatch(l,d);if(l&&(f||p)){const n=r(e.playingAsset),a=(null==n?void 0:n.media)||e.primaryMedia;if(a){const r="primary"===s?a.currentTime:i(l,s,e.playingAsset,"timelinePos","currentTime"),o=t-r,c=(f?r:a.currentTime)+o;if(c>=0&&(!n||f||c<=n.duration))return void(a.currentTime=c)}}if(d){let r=t;if("primary"!==s){const e=t-d[s].start;r=d.start+e}const i=!e.isInterstitial(d);if(e.isInterstitial(l)&&!l.event.appendInPlace||!i&&!d.event.appendInPlace){if(l){const n=e.findItemIndex(l);if(c>n){const t=e.schedule.findJumpRestrictedIndex(n+1,c);if(t>n)return void e.setSchedulePosition(t)}let a=0;if(i)e.timelinePos=r,e.checkBuffer();else{const e=d.event.assetList,r=t-(d[s]||d).start;for(let t=e.length;t--;){const i=e[t];if(i.duration&&r>=i.startOffset&&r<i.startOffset+i.duration){a=t;break}}}e.setSchedulePosition(c,a)}}else{const t=e.media||(f?null==u?void 0:u.media:null);t&&(t.currentTime=r)}}},o=()=>{const r=e.effectivePlayingItem;if(e.isInterstitial(r))return r;const i=t();return e.isInterstitial(i)?i:null},l={get bufferedEnd(){const r=t(),s=e.bufferingItem;var n;return s&&s===r&&(i(s,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-s.playout.start||(null==(n=e.bufferingAsset)?void 0:n.startOffset))||0},get currentTime(){const t=o(),r=e.effectivePlayingItem;return r&&r===t?i(r,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-r.playout.start:0},set currentTime(t){const r=o(),i=e.effectivePlayingItem;i&&i===r&&a(t+i.playout.start,"playout")},get duration(){const e=o();return e?e.playout.end-e.playout.start:0},get assetPlayers(){var t;const r=null==(t=o())?void 0:t.event.assetList;return r?r.map(t=>e.getAssetPlayer(t.identifier)):[]},get playingIndex(){var t;const r=null==(t=o())?void 0:t.event;return r&&e.effectivePlayingAsset?r.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return o()}};return this.manager={get events(){var t;return(null==(t=e.schedule)||null==(t=t.events)?void 0:t.slice(0))||[]},get schedule(){var t;return(null==(t=e.schedule)||null==(t=t.items)?void 0:t.slice(0))||[]},get interstitialPlayer(){return o()?l:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const r=t();return e.findItemIndex(r)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const t=e.effectivePlayingItem;return e.findItemIndex(t)},primary:{get bufferedEnd(){return s()},get currentTime(){const t=e.timelinePos;return t>0?t:0},set currentTime(e){a(e,"primary")},get duration(){return n("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0}},integrated:{get bufferedEnd(){return i(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return i(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(e){a(e,"integrated")},get duration(){return n("integrated")},get seekableStart(){var t;return((t,r)=>{var i;if(0!==t&&"primary"!==r&&null!=(i=e.schedule)&&i.length){var s;const i=e.schedule.findItemIndexAtTime(t),n=null==(s=e.schedule.items)?void 0:s[i];if(n)return t+(n[r].start-n.start)}return t})((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")}},skip:()=>{const t=e.effectivePlayingItem,r=null==t?void 0:t.event;if(r&&!r.restrictions.skip){const i=e.findItemIndex(t);if(r.appendInPlace){const e=t.playout.start+t.event.duration;a(e+.001,"playout")}else e.advanceAfterAssetEnded(r,i,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;const t=this.playingItem,r=null==(e=this.schedule)?void 0:e.items;return!!(this.playbackStarted&&t&&r)&&this.findItemIndex(t)===r.length-1}get playbackStarted(){return null!==this.effectivePlayingItem}get currentTime(){var e,t;if(null===this.mediaSelection)return;const r=this.waitingItem||this.playingItem;if(this.isInterstitial(r)&&!r.event.appendInPlace)return;let i=this.media;!i&&null!=(e=this.bufferingItem)&&null!=(e=e.event)&&e.appendInPlace&&(i=this.primaryMedia);const s=null==(t=i)?void 0:t.currentTime;return void 0!==s&&Ru(s)?s:void 0}get primaryMedia(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}isInterstitial(e){return!(null==e||!e.event)}retreiveMediaSource(e,t){const r=this.getAssetPlayer(e);r&&this.transferMediaFromPlayer(r,t)}transferMediaFromPlayer(e,t){const r=e.interstitial.appendInPlace,i=e.media;if(r&&i===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&i)return void(this.detachedData={media:i});const r=e.transferMedia();this.log(`transfer MediaSource from ${e} ${Pf(r)}`),this.detachedData=r}else t&&i&&(this.shouldPlay||(this.shouldPlay=!i.paused))}transferMediaTo(e,t){var r,i;if(e.media===t)return;let s=null;const n=this.hls,a=e!==n,o=a&&e.interstitial.appendInPlace,l=null==(r=this.detachedData)?void 0:r.mediaSource;let c;if(n.media)o&&(s=n.transferMedia(),this.detachedData=s),c="Primary";else if(l){const e=this.getBufferingPlayer();e?(s=e.transferMedia(),c=`${e}`):c="detached MediaSource"}else c="detached media";if(!s)if(l)s=this.detachedData,this.log(`using detachedData: MediaSource ${Pf(s)}`);else if(!this.detachedData||n.media===t){const e=this.playerQueue;e.length>1&&e.forEach(e=>{if(a&&e.interstitial.appendInPlace!==o){const t=e.interstitial;this.clearInterstitial(e.interstitial,null),t.appendInPlace=!1,t.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${t}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}const d=s&&"mediaSource"in s&&"closed"!==(null==(i=s.mediaSource)?void 0:i.readyState),u=d&&s?s:t;this.log(`${d?"transfering MediaSource":"attaching media"} to ${a?e:"Primary"} from ${c} (media.currentTime: ${t.currentTime})`);const h=this.schedule;if(u===s&&h){const t=a&&e.assetId===h.assetIdAtEnd;u.overrides={duration:h.duration,endOfStream:!a||t,cueRemoval:!a}}e.attachMedia(u)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=null==e?void 0:e.events;if(!t||this.playbackDisabled||!this.media)return;-1===this.bufferedPos&&(this.bufferedPos=0);const r=this.timelinePos,i=this.effectivePlayingItem;if(-1===r){const r=this.hls.startPosition;if(this.log(mb("checkStart",r)),this.timelinePos=r,t.length&&t[0].cue.pre){const r=e.findEventIndex(t[0].identifier);this.setSchedulePosition(r)}else if(r>=0||!this.primaryLive){const t=this.timelinePos=r>0?r:0,i=e.findItemIndexAtTime(t);this.setSchedulePosition(i)}}else if(i&&!this.playingItem){const t=e.findItemIndex(i);this.setSchedulePosition(t)}}advanceAssetBuffering(e,t){const r=e.event,i=r.findAssetIndex(t),s=lb(r,i);if(r.isAssetPastPlayoutLimit(s)){if(this.schedule){var n;const t=null==(n=this.schedule.items)?void 0:n[this.findItemIndex(e)+1];t&&this.bufferedToItem(t)}}else this.bufferedToEvent(e,s)}advanceAfterAssetEnded(e,t,r){const i=lb(e,r);if(e.isAssetPastPlayoutLimit(i)){if(this.schedule){const r=this.schedule.items;if(r){const i=t+1;if(i>=r.length)return void this.setSchedulePosition(-1);const s=e.resumeTime;this.timelinePos<s&&(this.log(mb("advanceAfterAssetEnded",s)),this.timelinePos=s,e.appendInPlace&&this.advanceInPlace(s),this.checkBuffer(this.bufferedPos<s)),this.setSchedulePosition(i)}}}else{if(e.appendInPlace){const t=e.assetList[i];t&&this.advanceInPlace(t.timelineStart)}this.setSchedulePosition(t,i)}}setScheduleToAssetAtTime(e,t){const r=this.schedule;if(!r)return;const i=t.parentIdentifier,s=r.getEvent(i);if(s){const t=r.findEventIndex(i),n=r.findAssetIndex(s,e);this.advanceAfterAssetEnded(s,t,n-1)}}setSchedulePosition(e,t){var r;const i=null==(r=this.schedule)?void 0:r.items;if(!i||this.playbackDisabled)return;const s=e>=0?i[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${s?hb(s):s}) pos: ${this.timelinePos}`);const n=this.waitingItem||this.playingItem,a=this.playingLastItem;if(this.isInterstitial(n)){const r=n.event,c=this.playingAsset,d=null==c?void 0:c.identifier,u=d?this.getAssetPlayer(d):null;if(u&&d&&(!this.eventItemsMatch(n,s)||void 0!==t&&d!==r.assetList[t].identifier)){var o;const t=r.findAssetIndex(c);if(this.log(`INTERSTITIAL_ASSET_ENDED ${t+1}/${r.assetList.length} ${cb(c)}`),this.endedAsset=c,this.playingAsset=null,this.hls.trigger(Ou.INTERSTITIAL_ASSET_ENDED,{asset:c,assetListIndex:t,event:r,schedule:i.slice(0),scheduleIndex:e,player:u}),n!==this.playingItem)return void(this.itemsMatch(n,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(r,this.findItemIndex(this.playingItem),t));this.retreiveMediaSource(d,s),!u.media||null!=(o=this.detachedData)&&o.mediaSource||u.detachMedia()}if(!this.eventItemsMatch(n,s)&&(this.endedItem=n,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${r} ${hb(n)}`),r.hasPlayed=!0,this.hls.trigger(Ou.INTERSTITIAL_ENDED,{event:r,schedule:i.slice(0),scheduleIndex:e}),r.cue.once)){var l;this.updateSchedule();const e=null==(l=this.schedule)?void 0:l.items;if(s&&e){const r=this.findItemIndex(s);this.advanceSchedule(r,e,t,n,a)}return}}this.advanceSchedule(e,i,t,n,a)}advanceSchedule(e,t,r,i,s){const n=this.schedule;if(!n)return;const a=t[e]||null,o=this.primaryMedia,l=this.playerQueue;if(l.length&&l.forEach(t=>{const r=t.interstitial,i=n.findEventIndex(r.identifier);(i<e||i>e+1)&&this.clearInterstitial(r,a)}),this.isInterstitial(a)){this.timelinePos=Math.min(Math.max(this.timelinePos,a.start),a.end);const s=a.event;if(void 0===r){const t=lb(s,(r=n.findAssetIndex(s,this.timelinePos))-1);if(s.isAssetPastPlayoutLimit(t)||s.appendInPlace&&this.timelinePos===a.end)return void this.advanceAfterAssetEnded(s,e,r);r=t}const l=this.waitingItem;this.assetsBuffered(a,o)||this.setBufferingItem(a);let c=this.preloadAssets(s,r);if(this.eventItemsMatch(a,l||i)||(this.waitingItem=a,this.log(`INTERSTITIAL_STARTED ${hb(a)} ${s.appendInPlace?"append in place":""}`),this.hls.trigger(Ou.INTERSTITIAL_STARTED,{event:s,schedule:t.slice(0),scheduleIndex:e})),!s.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${s}`);if(s.assetListLoader&&(s.assetListLoader.destroy(),s.assetListLoader=void 0),!o)return void this.log(`Waiting for attachMedia to start Interstitial ${s}`);this.waitingItem=this.endedItem=null,this.playingItem=a;const d=s.assetList[r];if(!d)return void this.advanceAfterAssetEnded(s,e,r||0);if(c||(c=this.getAssetPlayer(d.identifier)),null===c||c.destroyed){const e=s.assetList.length;this.warn(`asset ${r+1}/${e} player destroyed ${s}`),c=this.createAssetPlayer(s,d,r),c.loadSource()}if(!this.eventItemsMatch(a,this.bufferingItem)&&s.appendInPlace&&this.isAssetBuffered(d))return;this.startAssetPlayer(c,r,t,e,o),this.shouldPlay&&pb(c.media)}else a?(this.resumePrimary(a,e,i),this.shouldPlay&&pb(this.hls.media)):s&&this.isInterstitial(i)&&(this.endedItem=null,this.playingItem=i,i.event.appendInPlace||this.attachPrimary(n.durations.primary,null))}get playbackDisabled(){return!1===this.hls.config.enableInterstitialPlayback}get primaryDetails(){var e;return null==(e=this.mediaSelection)?void 0:e.main.details}get primaryLive(){var e;return!(null==(e=this.primaryDetails)||!e.live)}resumePrimary(e,t,r){var i,s;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${hb(e)}`),null==(i=this.detachedData)||!i.mediaSource){let r=this.timelinePos;(r<e.start||r>=e.end)&&(r=this.getPrimaryResumption(e,t),this.log(mb("resumePrimary",r)),this.timelinePos=r),this.attachPrimary(r,e)}if(!r)return;const n=null==(s=this.schedule)?void 0:s.items;n&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${hb(e)}`),this.hls.trigger(Ou.INTERSTITIALS_PRIMARY_RESUMED,{schedule:n.slice(0),scheduleIndex:t}),this.checkBuffer())}getPrimaryResumption(e,t){const r=e.start;if(this.primaryLive){const e=this.primaryDetails;if(0===t)return this.hls.startPosition;if(e&&(r<e.fragmentStart||r>e.edge))return this.hls.liveSyncPosition||-1}return r}isAssetBuffered(e){const t=this.getAssetPlayer(e.identifier);if(null!=t&&t.hls)return t.hls.bufferedToEnd;return Rp.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,r){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const i=this.primaryMedia;if(!i)return;const s=this.hls;s.media?this.checkBuffer():(this.transferMediaTo(s,i),r&&this.startLoadingPrimaryAt(e,r)),r||(this.log(mb("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,r))}startLoadingPrimaryAt(e,t){var r;const i=this.hls;!i.loadingEnabled||!i.media||Math.abs(((null==(r=i.mainForwardBufferInfo)?void 0:r.start)||i.media.currentTime)-e)>.5?i.startLoad(e,t):i.bufferingEnabled||i.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),null==(e=this.schedule)||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(Ou.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(Ou.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(-1===t.level||!this.schedule)return;const r=this.hls.levels[t.level];if(!r.details)return;const i=Yu(Yu({},this.mediaSelection||this.altSelection),{},{main:r});this.mediaSelection=i,this.schedule.parseInterstitialDateRanges(i,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(e,t){const r=this.hls.audioTracks[t.id],i=this.mediaSelection;if(!i)return void(this.altSelection=Yu(Yu({},this.altSelection),{},{audio:r}));const s=Yu(Yu({},i),{},{audio:r});this.mediaSelection=s}onSubtitleTrackUpdated(e,t){const r=this.hls.subtitleTracks[t.id],i=this.mediaSelection;if(!i)return void(this.altSelection=Yu(Yu({},this.altSelection),{},{subtitles:r}));const s=Yu(Yu({},i),{},{subtitles:r});this.mediaSelection=s}onAudioTrackSwitching(e,t){const r=_f(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(r)))}onSubtitleTrackSwitch(e,t){const r=_f(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setSubtitleOption(t)||-1!==t.id&&e.setSubtitleOption(r)))}onBufferCodecs(e,t){const r=t.tracks;r&&(this.requiredTracks=r)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){const r=this.playingItem;if(r&&!this.itemsMatch(r,this.bufferingItem)&&!this.isInterstitial(r)){const e=this.timelinePos;this.bufferedPos=e,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;const t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let e=0;e<t.length;e++){const i=t[e];if(i.cue.post){var r;const e=this.schedule.findEventIndex(i.identifier),t=null==(r=this.schedule.items)?void 0:r[e];this.isInterstitial(t)&&this.eventItemsMatch(t,this.bufferingItem)&&this.bufferedToItem(t,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){const t=this.playingItem;if(!this.playingLastItem&&t){const e=this.findItemIndex(t);this.setSchedulePosition(e+1)}else this.shouldPlay=!1}updateItem(e,t){var r;const i=null==(r=this.schedule)?void 0:r.items;if(e&&i){return i[this.findItemIndex(e,t)]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((t,r)=>{e.event.isAssetPastPlayoutLimit(r)&&this.clearAssetPlayer(t.identifier,null)});const r=e.end+.25,i=Rp.bufferInfo(this.primaryMedia,r,0);if(i.end>r||(i.nextStart||0)>r){this.log(`trim buffered interstitial ${hb(e)} (was ${hb(t)})`);const i=!0;this.attachPrimary(r,null,i),this.flushFrontBuffer(r)}}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var r;return!!t&&(e===t||e.event.identifier===(null==(r=t.event)?void 0:r.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t;const r=this.mediaSelection;r&&(null==(t=this.schedule)||t.updateSchedule(r,[],e))}checkBuffer(e){var t;const r=null==(t=this.schedule)?void 0:t.items;if(!r)return;const i=Rp.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=i.len<1),this.updateBufferedPos(i.end,r,e)}updateBufferedPos(e,t,r){const i=this.schedule,s=this.bufferingItem;if(this.bufferedPos>e||!i)return;if(1===t.length&&this.itemsMatch(t[0],s))return void(this.bufferedPos=e);const n=this.playingItem,a=this.findItemIndex(n);let o=i.findItemIndexAtTime(e);if(this.bufferedPos<e){var l;const r=this.findItemIndex(s),i=Math.min(r+1,t.length-1),n=t[i];if((-1===o&&s&&e>=s.end||null!=(l=n.event)&&l.appendInPlace&&e+.01>=n.start)&&(o=i),this.isInterstitial(s)){const e=s.event;if(i-a>1&&!1===e.appendInPlace)return;if(0===e.assetList.length&&e.assetListLoader)return}if(this.bufferedPos=e,o>r&&o>a)this.bufferedToItem(n);else{const t=this.primaryDetails;this.primaryLive&&t&&e>t.edge-t.targetduration&&n.start<t.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(n)&&this.preloadAssets(n.event,0)}}else r&&n&&!this.itemsMatch(n,s)&&(o===a?this.bufferedToItem(n):o===a+1&&this.bufferedToItem(t[o]))}assetsBuffered(e,t){return 0!==e.event.assetList.length&&!e.event.assetList.some(e=>{const r=this.getAssetPlayer(e.identifier);return!(null!=r&&r.bufferedInPlaceToEnd(t))})}setBufferingItem(e){const t=this.bufferingItem,r=this.schedule;if(!this.itemsMatch(e,t)&&r){const{items:i,events:s}=r;if(!i||!s)return t;const n=this.isInterstitial(e),a=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const o=a?a.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${hb(e)}`+(t?` (${o.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(n){const t=r.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((e,r)=>{const i=this.getAssetPlayer(e.identifier);i&&(r===t&&i.loadSource(),i.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(e=>e.pauseBuffering());this.hls.trigger(Ou.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:s.slice(0),schedule:i.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){const r=this.setBufferingItem(e);if(!this.playbackDisabled)if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==r){this.bufferingAsset=null;const t=this.detachedData;if(t)if(t.mediaSource){const t=!0;this.attachPrimary(e.start,e,t)}else this.preloadPrimary(e);else this.preloadPrimary(e)}}preloadPrimary(e){const t=this.findItemIndex(e),r=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(r)}bufferedToEvent(e,t){const r=e.event,i=0===r.assetList.length&&!r.assetListLoader,s=r.cue.once;if(i||!s){const e=this.preloadAssets(r,t);if(null!=e&&e.interstitial.appendInPlace){const t=this.primaryMedia;t&&this.bufferAssetPlayer(e,t)}}}preloadAssets(e,t){const r=e.assetUrl,i=e.assetList.length,s=0===i&&!e.assetListLoader,n=e.cue.once;if(s){const s=e.timelineStart;if(e.appendInPlace){var a;const t=this.playingItem;this.isInterstitial(t)||(null==t||null==(a=t.nextEvent)?void 0:a.identifier)!==e.identifier||this.flushFrontBuffer(s+.25)}let n,o=0;if(!this.playingItem&&this.primaryLive&&(o=this.hls.startPosition,-1===o&&(o=this.hls.liveSyncPosition||0)),o&&!e.cue.pre&&!e.cue.post){const e=o-s;e>0&&(n=Math.round(1e3*e)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${r?1:i} ${e}${n?` live-start: ${o} start-offset: ${n}`:""}`),r)return this.createAsset(e,0,0,s,e.duration,r);const l=this.assetListLoader.loadAssetList(e,n);l&&(e.assetListLoader=l)}else if(!n&&i){for(let r=t;r<i;r++){const t=e.assetList[r],i=this.getAssetPlayerQueueIndex(t.identifier);-1!==i&&!this.playerQueue[i].destroyed||t.error||this.createAssetPlayer(e,t,r)}const r=e.assetList[t];if(r){const e=this.getAssetPlayer(r.identifier);return e&&e.loadSource(),e}}return null}flushFrontBuffer(e){const t=this.requiredTracks;if(!t)return;this.log(`Removing front buffer starting at ${e}`);Object.keys(t).forEach(t=>{this.hls.trigger(Ou.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:t})})}getAssetPlayerQueueIndex(e){const t=this.playerQueue;for(let r=0;r<t.length;r++)if(e===t[r].assetId)return r;return-1}getAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){const{playerQueue:e,primaryMedia:t}=this;if(t)for(let r=0;r<e.length;r++)if(e[r].media===t)return e[r];return null}createAsset(e,t,r,i,s,n){const a={parentIdentifier:e.identifier,identifier:sb(e,n,t),duration:s,startOffset:r,timelineStart:i,uri:n};return this.createAssetPlayer(e,a,t)}createAssetPlayer(e,t,r){const i=this.hls,s=i.userConfig;let n=s.videoPreference;const a=i.loadLevelObj||i.levels[i.currentLevel];(n||a)&&(n=Vu({},n),a.videoCodec&&(n.videoCodec=a.videoCodec),a.videoRange&&(n.allowedVideoRanges=[a.videoRange]));const o=i.audioTracks[i.audioTrack],l=i.subtitleTracks[i.subtitleTrack];let c=0;if(this.primaryLive||e.appendInPlace){const e=this.timelinePos-t.timelineStart;if(e>1){const r=t.duration;r&&e<r&&(c=e)}}const d=t.identifier,u=Yu(Yu({},s),{},{maxMaxBufferLength:Math.min(180,i.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:i.sessionId,assetPlayerId:d,abrEwmaDefaultEstimate:i.bandwidthEstimate,interstitialsController:void 0,startPosition:c,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:n,audioPreference:o||s.audioPreference,subtitlePreference:l||s.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(u.timelineOffset=t.timelineStart));const h=u.cmcd;null!=h&&h.sessionId&&h.contentId&&(u.cmcd=Vu({},h,{contentId:tb(t.uri)})),this.getAssetPlayer(d)&&this.warn(`Duplicate date range identifier ${e} and asset ${d}`);const f=new db(this.HlsPlayerClass,u,e,t);this.playerQueue.push(f),e.assetList[r]=t;let p=!0;const m=i=>{if(i.live){var s;const t=new Error(`Interstitials MUST be VOD assets ${e}`),i={fatal:!0,type:Du.OTHER_ERROR,details:_u.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},n=(null==(s=this.schedule)?void 0:s.findEventIndex(e.identifier))||-1;return void this.handleAssetItemError(i,e,n,r,t.message)}const n=i.edge-i.fragmentStart,a=t.duration;(p||null===a||n>a)&&(p=!1,this.log(`Interstitial asset "${d}" duration change ${a} > ${n}`),t.duration=n,this.updateSchedule())};f.on(Ou.LEVEL_UPDATED,(e,{details:t})=>m(t)),f.on(Ou.LEVEL_PTS_UPDATED,(e,{details:t})=>m(t)),f.on(Ou.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const g=(e,t)=>{const r=this.getAssetPlayer(d);if(r&&t.tracks){r.off(Ou.BUFFER_CODECS,g),r.tracks=t.tracks;const e=this.primaryMedia;this.bufferingAsset===r.assetItem&&e&&!r.media&&this.bufferAssetPlayer(r,e)}};f.on(Ou.BUFFER_CODECS,g);f.on(Ou.BUFFERED_TO_END,()=>{var r;const i=this.getAssetPlayer(d);if(this.log(`buffered to end of asset ${i}`),!i||!this.schedule)return;const s=this.schedule.findEventIndex(e.identifier),n=null==(r=this.schedule.items)?void 0:r[s];this.isInterstitial(n)&&this.advanceAssetBuffering(n,t)});const v=t=>()=>{if(!this.getAssetPlayer(d)||!this.schedule)return;this.shouldPlay=!0;const r=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,r,t)};return f.once(Ou.MEDIA_ENDED,v(r)),f.once(Ou.PLAYOUT_LIMIT_REACHED,v(1/0)),f.on(Ou.ERROR,(t,i)=>{if(!this.schedule)return;const s=this.getAssetPlayer(d);if(i.details===_u.BUFFER_STALLED_ERROR)return null!=s&&s.appendInPlace?void this.handleInPlaceStall(e):(this.onTimeupdate(),void this.checkBuffer(!0));this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),r,`Asset player error ${i.error} ${e}`)}),f.on(Ou.DESTROYING,()=>{if(!this.getAssetPlayer(d)||!this.schedule)return;const t=new Error(`Asset player destroyed unexpectedly ${d}`),i={fatal:!0,type:Du.OTHER_ERROR,details:_u.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),r,t.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${cb(t)}`),this.hls.trigger(Ou.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:r,event:e,player:f}),f}clearInterstitial(e,t){this.clearAssetPlayers(e,t),e.reset()}clearAssetPlayers(e,t){e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,t)})}resetAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);if(-1!==t){this.log(`reset asset player "${e}" after error`);const r=this.playerQueue[t];this.transferMediaFromPlayer(r,null),r.resetDetails()}}clearAssetPlayer(e,t){const r=this.getAssetPlayerQueueIndex(e);if(-1!==r){const e=this.playerQueue[r];this.log(`clear ${e} toSegment: ${t?hb(t):t}`),this.transferMediaFromPlayer(e,t),this.playerQueue.splice(r,1),e.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,r,i,s){const{interstitial:n,assetItem:a,assetId:o}=e,l=n.assetList.length,c=this.playingAsset;this.endedAsset=null,this.playingAsset=a,c&&c.identifier===o||(c&&(this.clearAssetPlayer(c.identifier,r[i]),delete c.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${l} ${cb(a)}`),this.hls.trigger(Ou.INTERSTITIAL_ASSET_STARTED,{asset:a,assetListIndex:t,event:n,schedule:r.slice(0),scheduleIndex:i,player:e})),this.bufferAssetPlayer(e,s)}bufferAssetPlayer(e,t){var r,i;if(!this.schedule)return;const{interstitial:s,assetItem:n}=e,a=this.schedule.findEventIndex(s.identifier),o=null==(r=this.schedule.items)?void 0:r[a];if(!o)return;e.loadSource(),this.setBufferingItem(o),this.bufferingAsset=n;const l=this.getBufferingPlayer();if(l===e)return;const c=s.appendInPlace;if(c&&!1===(null==l?void 0:l.interstitial.appendInPlace))return;const d=(null==l?void 0:l.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(c&&n!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(d&&!rh(d,e.tracks)){const t=new Error(`Asset ${cb(n)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(d)}')`),r={fatal:!0,type:Du.OTHER_ERROR,details:_u.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},i=s.findAssetIndex(n);return void this.handleAssetItemError(r,s,a,i,t.message)}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,r=this.primaryMedia;if(!t||!r)return;const i=r.currentTime,s=t.findAssetIndex(e,i),n=e.assetList[s];if(n){const a=this.getAssetPlayer(n.identifier);if(a){const o=a.currentTime||i-n.timelineStart,l=a.duration-o;if(this.warn(`Stalled at ${o} of ${o+l} in ${a} ${e} (media.currentTime: ${i})`),o&&(l/r.playbackRate<.5||a.bufferedInPlaceToEnd(r))&&a.hls){const r=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,r,s)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,r,i,s){if(e.details===_u.BUFFER_STALLED_ERROR)return;const n=t.assetList[i]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${n?cb(n):n} ${e.error}`),!this.schedule)return;const a=(null==n?void 0:n.identifier)||"",o=this.getAssetPlayerQueueIndex(a),l=this.playerQueue[o]||null,c=this.schedule.items,d=Vu({},e,{fatal:!1,errorAction:ap(!0),asset:n,assetListIndex:i,event:t,schedule:c,scheduleIndex:r,player:l});if(this.hls.trigger(Ou.INTERSTITIAL_ASSET_ERROR,d),!e.fatal)return;const u=this.playingAsset,h=this.bufferingAsset,f=new Error(s);if(n&&(this.clearAssetPlayer(a,null),n.error=f),t.assetList.some(e=>!e.error))for(let e=i;e<t.assetList.length;e++)this.resetAssetPlayer(t.assetList[e].identifier);else t.error=f;this.updateSchedule(!0),t.error?this.primaryFallback(t):u&&u.identifier===a?this.advanceAfterAssetEnded(t,r,i):h&&h.identifier===a&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,h)}primaryFallback(e){const t=e.timelineStart,r=this.effectivePlayingItem;let i=this.timelinePos;if(r){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${i} playing: ${hb(r)} error: ${e.error}`),-1===i&&(i=this.hls.startPosition);const s=this.updateItem(r,i);this.itemsMatch(r,s)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(-1===i)return void this.checkStart();if(!this.schedule)return;const s=this.schedule.findItemIndexAtTime(i);this.setSchedulePosition(s)}onAssetListLoaded(e,t){var r,i;const s=t.event,n=s.identifier,a=t.assetListResponse.ASSETS;if(null==(r=this.schedule)||!r.hasEvent(n))return;const o=s.timelineStart,l=s.duration;let c=0;a.forEach((e,t)=>{const r=parseFloat(e.DURATION);this.createAsset(s,t,c,o+c,r,e.URI),c+=r}),s.duration=c,this.log(`Loaded asset-list with duration: ${c} (was: ${l}) ${s}`);const d=this.waitingItem,u=(null==d?void 0:d.event.identifier)===n;this.updateSchedule();const h=null==(i=this.bufferingItem)?void 0:i.event;if(u){var f;const e=this.schedule.findEventIndex(n),t=null==(f=this.schedule.items)?void 0:f[e];if(t){if(!this.playingItem&&this.timelinePos>t.end){if(this.schedule.findItemIndexAtTime(this.timelinePos)!==e)return s.error=new Error(`Interstitial ${a.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${s}`),this.log(s.error.message),this.updateSchedule(!0),void this.primaryFallback(s)}this.setBufferingItem(t)}this.setSchedulePosition(e)}else if((null==h?void 0:h.identifier)===n){const e=s.assetList[0];if(e){const t=this.getAssetPlayer(e.identifier);if(h.appendInPlace){const e=this.primaryMedia;t&&e&&this.bufferAssetPlayer(t,e)}else t&&t.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case _u.ASSET_LIST_PARSING_ERROR:case _u.ASSET_LIST_LOAD_ERROR:case _u.ASSET_LIST_LOAD_TIMEOUT:{const e=t.interstitial;e&&(this.updateSchedule(!0),this.primaryFallback(e));break}case _u.BUFFER_STALLED_ERROR:{const e=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(e)&&e.event.appendInPlace)return void this.handleInPlaceStall(e.event);this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}});function EE(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(EE):Object.keys(e).reduce((t,r)=>(t[r]=EE(e[r]),t),{}):e}function wE(e,t){const r=e.loader;if(r!==pE&&r!==yE)t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1;else{(function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1})()&&(e.loader=pE,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}}class SE extends kp{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var e;null!=(e=this.media)&&e.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{var e;this.hls&&(this.ended=(null==(e=this.media)?void 0:e.currentTime)||1,this.hls.trigger(Ou.MEDIA_ENDED,{stalled:!1}))},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;const r=this.media=t.media;Wm(r,"playing",this.onMediaPlaying),Wm(r,"waiting",this.onMediaWaiting),Wm(r,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:r}=this;r&&(Ym(r,"playing",this.onMediaPlaying),Ym(r,"waiting",this.onMediaWaiting),Ym(r,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(null==(e=this.media)||!e.readyState||!this.hasBuffered)return;const t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}poll(e,t){var r,i;const s=null==(r=this.hls)?void 0:r.config;if(!s)return;const n=this.media;if(!n)return;const{seeking:a}=n,o=this.seeking&&!a,l=!this.seeking&&a,c=n.paused&&!a||n.ended||0===n.playbackRate;if(this.seeking=a,e!==t)return t&&(this.ended=0),this.moved=!0,a||(this.nudgeRetry=0,s.nudgeOnVideoHole&&!c&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(l||o)return void(o&&this.stallResolved(e));if(c)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&n.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(Ou.MEDIA_ENDED,{stalled:!1})));if(!Rp.getBuffered(n).length)return void(this.nudgeRetry=0);const d=Rp.bufferInfo(n,e,0),u=d.nextStart||0,h=this.fragmentTracker;if(a&&h&&this.hls){const t=TE(this.hls.inFlightFragments,e),r=d.len>2,i=!u||t||u-e>2&&!h.getPartialFragment(e);if(r||i)return;this.moved=!1}const f=null==(i=this.hls)?void 0:i.latestLevelDetails;if(!this.moved&&null!==this.stalled&&h){if(!(d.len>0)&&!u)return;const t=Math.max(u,d.start||0)-e,r=!(null==f||!f.live)?2*f.targetduration:2,i=AE(e,h);if(t>0&&(t<=r||i))return void(n.paused||this._trySkipBufferHole(i))}const p=s.detectStallWithCurrentTimeMs,m=self.performance.now(),g=this.waiting;let v=this.stalled;if(null===v){if(!(g>0&&m-g<p))return void(this.stalled=m);v=this.stalled=g}const y=m-v;if(!a&&(y>=p||g)&&this.hls){var b;if("ended"===(null==(b=this.mediaSource)?void 0:b.readyState)&&(null==f||!f.live)&&Math.abs(e-((null==f?void 0:f.edge)||0))<1){if(this.ended)return;return this.ended=e||1,void this.hls.trigger(Ou.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media||!this.hls)return}const E=Rp.bufferInfo(n,e,s.maxBufferHole);this._tryFixBufferStall(E,y,e)}stallResolved(e){const t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){const r=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(r)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(Ou.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var r;const i=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(r=this.buffered.audio)&&r.length&&i&&i.length>1&&e>i.end(0)){const r=Rp.bufferedInfo(Rp.timeRangesToArray(this.buffered.audio),e,0);if(r.len>1&&t>=r.start){const r=Rp.timeRangesToArray(i),s=Rp.bufferedInfo(r,t,0).bufferedIndex;if(s>-1&&s<r.length-1){const t=Rp.bufferedInfo(r,e,0).bufferedIndex,i=r[s].end,n=r[s+1].start;if((-1===t||t>s)&&n-i<1&&e-i<2){const r=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${i} -> ${n} buffered index: ${t}`);this.warn(r.message),this.media.currentTime+=1e-6;let s=AE(e,this.fragmentTracker);s&&"fragment"in s?s=s.fragment:s||(s=void 0);const a=Rp.bufferInfo(this.media,e,0);this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:r,reason:r.message,frag:s,buffer:a.len,bufferInfo:a})}}}}}_tryFixBufferStall(e,t,r){var i,s;const{fragmentTracker:n,media:a}=this,o=null==(i=this.hls)?void 0:i.config;if(!a||!n||!o)return;const l=null==(s=this.hls)?void 0:s.latestLevelDetails,c=AE(r,n);if(c||null!=l&&l.live&&r<l.fragmentStart){if(this._trySkipBufferHole(c)||!this.media)return}const d=e.buffered,u=this.adjacentTraversal(e,r);(d&&d.length>1&&e.len>o.maxBufferHole||e.nextStart&&(e.nextStart-r<o.maxBufferHole||u))&&(t>1e3*o.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){const r=this.fragmentTracker,i=e.nextStart;if(r&&i){const e=r.getFragAtPos(t,Bu),s=r.getFragAtPos(i,Bu);if(e&&s)return s.sn-e.sn<2}return!1}_reportStall(e){const{hls:t,media:r,stallReported:i,stalled:s}=this;if(!i&&null!==s&&r&&t){this.stallReported=!0;const i=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${Pf(e)})`);this.warn(i.message),t.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len,bufferInfo:e,stalled:{start:s}})}}_trySkipBufferHole(e){var t;const{fragmentTracker:r,media:i}=this,s=null==(t=this.hls)?void 0:t.config;if(!i||!r||!s)return 0;const n=i.currentTime,a=Rp.bufferInfo(i,n,0),o=n<a.start?a.start:a.nextStart;if(o&&this.hls){const t=a.len<=s.maxBufferHole,c=a.len>0&&a.len<1&&i.readyState<3,d=o-n;if(d>0&&(t||c)){if(d>s.maxBufferHole){let t=!1;if(0===n){const e=r.getAppendedFrag(0,Bu);e&&o<e.end&&(t=!0)}if(!t&&e){var l;if(null==(l=this.hls.loadLevelObj)||!l.details)return 0;if(TE(this.hls.inFlightFragments,o))return 0;let t=!1,i=e.end;for(;i<o;){const e=AE(i,r);if(!e){t=!0;break}i+=e.duration}if(t)return 0}}const t=Math.max(o+.05,n+.1);if(this.warn(`skipping hole, adjusting currentTime from ${n} to ${t}`),this.moved=!0,i.currentTime=t,null==e||!e.gap){const r=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${t}`),i={type:Du.MEDIA_ERROR,details:_u.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:r,reason:r.message,buffer:a.len,bufferInfo:a};e&&("fragment"in e?i.part=e:i.frag=e),this.hls.trigger(Ou.ERROR,i)}return t}}return 0}_tryNudgeBuffer(e){const{hls:t,media:r,nudgeRetry:i}=this,s=null==t?void 0:t.config;if(!r||!s)return 0;const n=r.currentTime;if(this.nudgeRetry++,i<s.nudgeMaxRetry){const a=n+(i+1)*s.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);this.warn(o.message),r.currentTime=a,t.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1,buffer:e.len,bufferInfo:e})}else{const r=new Error(`Playhead still not moving while enough data buffered @${n} after ${s.nudgeMaxRetry} nudges`);this.error(r.message),t.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.BUFFER_STALLED_ERROR,error:r,fatal:!0,buffer:e.len,bufferInfo:e})}}}function TE(e,t){const r=xE(e.main);if(r&&r.start<=t)return r;const i=xE(e.audio);return i&&i.start<=t?i:null}function xE(e){if(!e)return null;switch(e.state){case Xm:case qm:case ig:case sg:return null}return e.frag}function AE(e,t){return t.getAppendedFrag(e,Bu)||t.getPartialFragment(e)}function kE(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function LE(e,t,r,i,s){let n=new e(t,r,"");try{n.value=i,s&&(n.type=s)}catch(a){n=new e(t,r,Pf(s?Yu({type:s},i):i))}return n}const IE=(()=>{const e=kE();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class RE{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(Ou.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Ou.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(Ou.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(Ou.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Ou.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){var r;this.media=t.media,!1===(null==(r=t.overrides)?void 0:r.cueRemoval)&&(this.removeCues=!1)}onMediaAttached(){var e;const t=null==(e=this.hls)?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null;!!t.transferMedia||(this.id3Track&&(this.removeCues&&Zy(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const r=e[t];if("metadata"===r.kind&&"id3"===r.label)return Xy(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:r,enableID3MetadataCues:i}=this.hls.config;if(!r&&!i)return;const{samples:s}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const n=kE();if(n)for(let e=0;e<s.length;e++){const t=s[e].type;if(t===Fg.emsg&&!r||!i)continue;const a=_g(s[e].data),o=s[e].pts;let l=o+s[e].duration;l>IE&&(l=IE);l-o<=0&&(l=o+.25);for(let e=0;e<a.length;e++){const r=a[e];if(!Og(r)){this.updateId3CueEnds(o,t);const e=LE(n,o,l,r,t);e&&this.id3Track.addCue(e)}}}}updateId3CueEnds(e,t){var r;const i=null==(r=this.id3Track)?void 0:r.cues;if(i)for(let r=i.length;r--;){const s=i[r];s.type===t&&s.startTime<e&&s.endTime===IE&&(s.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:i}){const{id3Track:s,hls:n}=this;if(!n)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:o}}=n;if(s&&(a||o)){let e;e="audio"===i?e=>e.type===Fg.audioId3&&o:"video"===i?e=>e.type===Fg.emsg&&a:e=>e.type===Fg.audioId3&&o||e.type===Fg.emsg&&a,Jy(s,t,r,e)}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;const{assetPlayerId:r,timelineOffset:i,enableDateRangeMetadataCues:s,interstitialsController:n}=this.hls.config;if(!s)return;const a=kE();if(r&&i&&!n){const{fragmentStart:t,fragmentEnd:i}=e;let s=this.assetCue;s?(s.startTime=t,s.endTime=i):a&&(s=this.assetCue=LE(a,t,i,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),s&&(s.id=r,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(s),s.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:o}=this,{dateRanges:l}=e,c=Object.keys(l);let d=this.dateRangeCuesAppended;var u;if(o&&t)if(null!=(u=o.cues)&&u.length){const e=Object.keys(d).filter(e=>!c.includes(e));for(let t=e.length;t--;){var h;const r=e[t],i=null==(h=d[r])?void 0:h.cues;delete d[r],i&&Object.keys(i).forEach(e=>{const t=i[e];if(t){t.removeEventListener("enter",this.onEventCueEnter);try{o.removeCue(t)}catch(e){}}})}}else d=this.dateRangeCuesAppended={};const f=e.fragments[e.fragments.length-1];if(0!==c.length&&Ru(null==f?void 0:f.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let e=0;e<c.length;e++){const t=c[e],r=l[t],i=r.startTime,s=d[t],o=(null==s?void 0:s.cues)||{};let u=(null==s?void 0:s.durationKnown)||!1,h=IE;const{duration:f,endDate:p}=r;if(p&&null!==f)h=i+f,u=!0;else if(r.endOnNext&&!u){const e=c.reduce((e,t)=>{if(t!==r.id){const i=l[t];if(i.class===r.class&&i.startDate>r.startDate&&(!e||r.startDate<e.startDate))return i}return e},null);e&&(h=e.startTime,u=!0)}const m=Object.keys(r.attr);for(let e=0;e<m.length;e++){const l=m[e];if(!$p(l))continue;const c=o[l];if(c)!u||null!=s&&s.durationKnown?Math.abs(c.startTime-i)>.01&&(c.startTime=i,c.endTime=h):c.endTime=h;else if(a){let e=r.attr[l];Bp(l)&&(e=nh(e));const s=LE(a,i,h,{key:l,data:e},Fg.dateRange);s&&(s.id=t,this.id3Track.addCue(s),o[l]=s,n&&("X-ASSET-LIST"!==l&&"X-ASSET-URL"!==l||s.addEventListener("enter",this.onEventCueEnter)))}}d[t]={cues:o,dateRange:r,durationKnown:u}}}}}class PE{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:e}=this,t=this.levelDetails;if(!e||!t)return;this.currentTime=e.currentTime;const r=this.computeLatency();if(null===r)return;this._latency=r;const{lowLatencyMode:i,maxLiveSyncPlaybackRate:s}=this.config;if(!i||1===s||!t.live)return;const n=this.targetLatency;if(null===n)return;const a=r-n;if(a<Math.min(this.maxLatency,n+t.targetduration)&&a>.05&&this.forwardBufferLength>1){const t=Math.min(2,Math.max(1,s)),r=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20,i=Math.min(t,Math.max(1,r));this.changeMediaPlaybackRate(e,i)}else 1!==e.playbackRate&&0!==e.playbackRate&&this.changeMediaPlaybackRate(e,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(void 0!==e.liveMaxLatencyDuration)return e.liveMaxLatencyDuration;const t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const e=this.levelDetails;if(null===e||null===this.hls)return null;const{holdBack:t,partHoldBack:r,targetduration:i}=e,{liveSyncDuration:s,liveSyncDurationCount:n,lowLatencyMode:a}=this.config,o=this.hls.userConfig;let l=a&&r||t;(this._targetLatencyUpdated||o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==s?s:n*i);const c=i;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;const r=this.levelDetails;if(null===r)return null;const i=r.edge,s=e-t-this.edgeStalled,n=i-r.totalduration,a=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(n,s),a)}get drift(){const e=this.levelDetails;return null===e?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(null===e)return 0;const t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;const r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Ou.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(Ou.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Ou.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Ou.ERROR,this.onError,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,t){var r;t.details===_u.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(r=this.levelDetails)&&r.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var r,i;e.playbackRate!==t&&(null==(r=this.hls)||r.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${null==(i=this.targetLatency)?void 0:i.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){const e=this.levelDetails;return null===e?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}class CE extends Bv{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Ou.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Ou.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Ou.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Ou.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const r=this.hls.config.preferManagedMediaSource,i=[],s={},n={};let a=!1,o=!1,l=!1;t.levels.forEach(e=>{const t=e.attrs;let{audioCodec:c,videoCodec:d}=e;c&&(e.audioCodec=c=of(c,r)||void 0),d&&(d=e.videoCodec=function(e){const t=e.split(",");for(let e=0;e<t.length;e++){const r=t[e].split(".");r.length>2&&"avc1"===r[0]&&(t[e]=`avc1.${parseInt(r[1]).toString(16)}${("000"+parseInt(r[2]).toString(16)).slice(-4)}`)}return t.join(",")}(d));const{width:u,height:h,unknownCodecs:f}=e,p=(null==f?void 0:f.length)||0;if(a||(a=!(!u||!h)),o||(o=!!d),l||(l=!!c),p||c&&!this.isAudioSupported(c)||d&&!this.isVideoSupported(d))return void this.log(`Some or all CODECS not supported "${t.CODECS}"`);const{CODECS:m,"FRAME-RATE":g,"HDCP-LEVEL":v,"PATHWAY-ID":y,RESOLUTION:b,"VIDEO-RANGE":E}=t,w=`${`${y||"."}-`}${e.bitrate}-${b}-${g}-${m}-${E}-${v}`;if(s[w])if(s[w].uri===e.url||e.attrs["PATHWAY-ID"])s[w].addGroupId("audio",t.AUDIO),s[w].addGroupId("text",t.SUBTITLES);else{const t=n[w]+=1;e.attrs["PATHWAY-ID"]=new Array(t+1).join(".");const r=this.createLevel(e);s[w]=r,i.push(r)}else{const t=this.createLevel(e);s[w]=t,n[w]=1,i.push(t)}}),this.filterAndSortMediaOptions(i,t,a,o,l)}createLevel(e){const t=new Lf(e),r=e.supplemental;if(null!=r&&r.videoCodec&&!this.isVideoSupported(r.videoCodec)){const e=new Error(`SUPPLEMENTAL-CODECS not supported "${r.videoCodec}"`);this.log(e.message),t.supportedResult=mf(e,[])}return t}isAudioSupported(e){return Jh(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Jh(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,r,i,s){var n;let a=[],o=[],l=e;const c=(null==(n=t.stats)?void 0:n.parsing)||{};if((r||i)&&s&&(l=l.filter(({videoCodec:e,videoRange:t,width:r,height:i})=>{return(!!e||!(!r||!i))&&(!!(s=t)&&wf.indexOf(s)>-1);var s})),0===l.length)return Promise.resolve().then(()=>{if(this.hls){let e="no level with compatible codecs found in manifest",r=e;t.levels.length&&(r=`one or more CODECS in variant not supported: ${Pf(t.levels.map(e=>e.attrs.CODECS).filter((e,t,r)=>r.indexOf(e)===t))}`,this.warn(r),e+=` (${r})`);const i=new Error(e);this.hls.trigger(Ou.ERROR,{type:Du.MEDIA_ERROR,details:_u.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:i,reason:r})}}),void(c.end=performance.now());t.audioTracks&&(a=t.audioTracks.filter(e=>!e.audioCodec||this.isAudioSupported(e.audioCodec)),DE(a)),t.subtitles&&(o=t.subtitles,DE(o));const d=l.slice(0);l.sort((e,t)=>{if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return wf.indexOf(e.videoRange)-wf.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){const r=rf(e.videoCodec),i=rf(t.videoCodec);if(r!==i)return i-r}if(e.uri===t.uri&&e.codecSet!==t.codecSet){const r=sf(e.codecSet),i=sf(t.codecSet);if(r!==i)return i-r}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});let u=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length))for(let e=0;e<d.length;e++)if(d[e].pathwayId===l[0].pathwayId){u=d[e];break}this._levels=l;for(let e=0;e<l.length;e++)if(l[e]===u){var h;this._firstLevel=e;const t=u.bitrate,r=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${t}`),void 0===(null==(h=this.hls.userConfig)?void 0:h.abrEwmaDefaultEstimate)){const e=Math.min(t,this.hls.config.abrEwmaDefaultEstimateMax);e>r&&r===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=e)}break}const f=s&&!i,p=this.hls.config,m=!(!p.audioStreamController||!p.audioTrackController),g={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:s,video:i,altAudio:m&&!f&&a.some(e=>!!e.url)};c.end=performance.now(),this.hls.trigger(Ou.MANIFEST_PARSED,g)}get levels(){return 0===this._levels.length?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(0===t.length)return;if(e<0||e>=t.length){const r=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}const r=this.currentLevelIndex,i=this.currentLevel,s=i?i.attrs["PATHWAY-ID"]:void 0,n=t[e],a=n.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=n,r===e&&i&&s===a)return;this.log(`Switching to level ${e} (${n.height?n.height+"p ":""}${n.videoRange?n.videoRange+" ":""}${n.codecSet?n.codecSet+" ":""}@${n.bitrate})${a?" with Pathway "+a:""} from level ${r}${s?" with Pathway "+s:""}`);const o={level:e,attrs:n.attrs,details:n.details,bitrate:n.bitrate,averageBitrate:n.averageBitrate,maxBitrate:n.maxBitrate,realBitrate:n.realBitrate,width:n.width,height:n.height,codecSet:n.codecSet,audioCodec:n.audioCodec,videoCodec:n.videoCodec,audioGroups:n.audioGroups,subtitleGroups:n.subtitleGroups,loaded:n.loaded,loadError:n.loadError,fragmentError:n.fragmentError,name:n.name,id:n.id,uri:n.uri,url:n.url,urlId:0,audioGroupIds:n.audioGroupIds,textGroupIds:n.textGroupIds};this.hls.trigger(Ou.LEVEL_SWITCHING,o);const l=n.details;if(!l||l.live){const e=this.switchParams(n.uri,null==i?void 0:i.details,l);this.loadPlaylist(e)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(void 0===this._startLevel){const e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const t=this.steering.pathways(),r=e.filter(e=>-1!==t.indexOf(e));if(e.length<1)return void this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);this.steering.pathwayPriority=r}}onError(e,t){!t.fatal&&t.context&&t.context.type===Nu&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(void 0!==t&&t.type===Bu){const e=t.elementaryStreams;if(!Object.keys(e).some(t=>!!e[t]))return;const r=this._levels[t.level];null!=r&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(e,t){var r;const{level:i,details:s}=t,n=t.levelInfo;var a;if(!n)return this.warn(`Invalid level index ${i}`),void(null!=(a=t.deliveryDirectives)&&a.skip&&(s.deltaUpdateFailed=!0));if(n===this.currentLevel||t.withoutMultiVariant){0===n.fragmentError&&(n.loadError=0);let e=n.details;e===t.details&&e.advanced&&(e=void 0),this.playlistLoaded(i,t,e)}else null!=(r=t.deliveryDirectives)&&r.skip&&(s.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const r=this.getUrlWithDirectives(e.uri,t),i=this.currentLevelIndex,s=e.attrs["PATHWAY-ID"],n=e.details,a=null==n?void 0:n.age;this.log(`Loading level index ${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${s?" Pathway "+s:""}${a&&n.live?" age "+a.toFixed(1)+(n.type&&" "+n.type||""):""} ${r}`),this.hls.trigger(Ou.LEVEL_LOADING,{url:r,level:i,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(1===this._levels.length)return;const r=this._levels.filter((t,r)=>r!==e||(this.steering&&this.steering.removeLevel(t),t===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,t.details&&t.details.fragments.forEach(e=>e.level=-1)),!1));$m(r),this._levels=r,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const i=r.length-1;this._firstLevel=Math.min(this._firstLevel,i),this._startLevel&&(this._startLevel=Math.min(this._startLevel,i)),this.hls.trigger(Ou.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(Ou.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function DE(e){const t={};e.forEach(e=>{const r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++})}function _E(){return self.SourceBuffer||self.WebKitSourceBuffer}function OE(){if(!th())return!1;const e=_E();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}class ME extends og{constructor(e,t,r){super(e,t,r,"stream-controller",Bu),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const e=this.media,t=e?e.currentTime:null;if(null===t||!Ru(t))return;if(this.log(`Media seeked to ${t.toFixed(3)}`),!this.getBufferedFrag(t))return;const r=this.getFwdBufferInfoAtPos(e,t,Bu,0);null!==r&&0!==r.len?this.tick():this.warn(`Main forward buffer length at ${t} on "seeked" event ${r?r.len:"empty"})`)},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Ou.LEVEL_LOADING,this.onLevelLoading,this),e.on(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Ou.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(Ou.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(Ou.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(Ou.BUFFER_CREATED,this.onBufferCreated,this),e.on(Ou.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Ou.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(Ou.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Ou.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Ou.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(Ou.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(Ou.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(Ou.BUFFER_CREATED,this.onBufferCreated,this),e.off(Ou.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Ou.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){const{lastCurrentTime:r,hls:i}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let e=i.startLevel;-1===e&&(i.config.testBandwidth&&this.levels.length>1?(e=0,this.bitrateTest=!0):e=i.firstAutoLevel),i.nextLoadLevel=e,this.level=i.loadLevel,this._hasEnoughToStart=!!t}r>0&&-1===e&&!t&&(this.log(`Override startPosition with lastCurrentTime @${r.toFixed(3)}`),e=r),this.state=Xm,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=qm}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case ag:{const{levels:e,level:t}=this,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r&&!this.waitForLive(r))){if(this.waitForCdnTuneIn(i))break;this.state=Xm;break}if(this.hls.nextLoadLevel!==this.level){this.state=Xm;break}break}case Jm:this.checkRetryDate()}this.state===Xm&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),null!=(e=this.media)&&e.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:r,media:i}=this;if(null===t||!i&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;const s=this.buffering?e.nextLoadLevel:e.loadLevel;if(null==r||!r[s])return;const n=r[s],a=this.getMainFwdBufferInfo();if(null===a)return;const o=this.getLevelDetails();if(o&&this._streamEnded(a,o)){const e={};return 2===this.altAudio&&(e.type="video"),this.hls.trigger(Ou.BUFFER_EOS,e),void(this.state=ig)}if(!this.buffering)return;e.loadLevel!==s&&-1===e.manualLevel&&this.log(`Adapting to level ${s} from level ${this.level}`),this.level=e.nextLoadLevel=s;const l=n.details;if(!l||this.state===ag||this.waitForLive(n))return this.level=s,this.state=ag,void(this.startFragRequested=!1);const c=a.len,d=this.getMaxBufferLength(n.maxBitrate);if(c>=d)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const u=this.backtrackFragment?this.backtrackFragment.start:a.end;let h=this.getNextFragment(u,l);if(this.couldBacktrack&&!this.fragPrevious&&h&&Eh(h)&&this.fragmentTracker.getState(h)!==dp){var f;const e=(null!=(f=this.backtrackFragment)?f:h).sn-l.startSN,t=l.fragments[e-1];t&&h.cc===t.cc&&(h=t,this.fragmentTracker.removeFragment(t))}else this.backtrackFragment&&a.len&&(this.backtrackFragment=null);if(h&&this.isLoopLoading(h,u)){if(!h.gap){const e=this.audioOnly&&!this.altAudio?gh:vh,t=(e===vh?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,Bu)}h=this.getNextFragmentLoopLoading(h,l,a,Bu,d)}h&&(!h.initSegment||h.initSegment.data||this.bitrateTest||(h=h.initSegment),this.loadFragment(h,n,u))}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);i===op||i===cp?Eh(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,r):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,Bu)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(null!=t&&t.readyState){let r;const i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);const s=this.getLevelDetails();if(null!=s&&s.live){const e=this.getMainFwdBufferInfo();if(!e||e.len<2*s.targetduration)return}if(!t.paused&&e){const t=e[this.hls.nextLoadLevel],i=this.fragLastKbps;r=i&&this.fragCurrent?this.fragCurrent.duration*t.maxBitrate/(1e3*i)+1:0}else r=0;const n=this.getBufferedFrag(t.currentTime+r);if(n){const e=this.followingBufferedFrag(n);if(e){this.abortCurrentFrag();const t=e.maxStartPTS?e.maxStartPTS:e.start,r=e.duration,i=Math.max(n.end,t+Math.min(Math.max(r-this.config.maxFragLookUpTolerance,r*(this.couldBacktrack?.5:.125)),r*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(i,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case Qm:case Zm:case Jm:case tg:case rg:this.state=Xm}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,2===this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const r=t.media;Wm(r,"playing",this.onMediaPlaying),Wm(r,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:r}=this;r&&(Ym(r,"playing",this.onMediaPlaying),Ym(r,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t);!!t.transferMedia||(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(Ou.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,t){let r=!1,i=!1;for(let e=0;e<t.levels.length;e++){const s=t.levels[e].audioCodec;s&&(r=r||-1!==s.indexOf("mp4a.40.2"),i=i||-1!==s.indexOf("mp4a.40.5"))}this.audioCodecSwitch=r&&i&&!function(){var e;const t=_E();return"function"==typeof(null==t||null==(e=t.prototype)?void 0:e.changeType)}(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:r}=this;if(!r||this.state!==Xm)return;const i=t.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=ag)}onLevelLoaded(e,t){var r;const{levels:i,startFragRequested:s}=this,n=t.level,a=t.details,o=a.totalduration;if(!i)return void this.warn(`Levels were reset while loading level ${n}`);this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const l=t.levelInfo,c=this.fragCurrent;!c||this.state!==Zm&&this.state!==Jm||c.level!==t.level&&c.loader&&this.abortCurrentFrag();let d=0;if(a.live||null!=(r=l.details)&&r.live){var u;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;d=this.alignPlaylists(a,l.details,null==(u=this.levelLastLoaded)?void 0:u.details)}if(l.details=a,this.levelLastLoaded=l,s||this.setStartPosition(a,d),this.hls.trigger(Ou.LEVEL_UPDATED,{details:a,level:n}),this.state===ag){if(this.waitForCdnTuneIn(a))return;this.state=Xm}s&&a.live&&this.synchronizeToLiveEdge(a),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:r}=this;if(!r)return;const i=this.hls.liveSyncPosition,s=this.getLoadPosition(),n=e.fragmentStart,a=e.edge,o=s>=n-t.maxFragLookUpTolerance&&s<=a;if(null!==i&&r.duration>i&&(s<i||!o)){const n=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!o&&r.readyState<4||s<a-n)&&(this._hasEnoughToStart||(this.nextLoadPosition=i),r.readyState))if(this.warn(`Playback: ${s.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : ${i.toFixed(3)}`),"buffered"===this.config.liveSyncMode){var l;const e=Rp.bufferInfo(r,i,0);if(null==(l=e.buffered)||!l.length)return void(r.currentTime=i);if(e.start<=s)return void(r.currentTime=i);const{nextStart:t}=Rp.bufferedInfo(e.buffered,s,0);t&&(r.currentTime=t)}else r.currentTime=i}}_handleFragmentLoadProgress(e){var t;const r=e.frag,{part:i,payload:s}=e,{levels:n}=this;if(!n)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);const a=n[r.level];if(!a)return void this.warn(`Level ${r.level} not found on progress`);const o=a.details;if(!o)return this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),void this.fragmentTracker.removeFragment(r);const l=a.videoCodec,c=o.PTSKnown||!o.live,d=null==(t=r.initSegment)?void 0:t.data,u=this._getAudioCodec(a),h=this.transmuxer=this.transmuxer||new $v(this.hls,Bu,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,p=-1!==f,m=new Lp(r.level,r.sn,r.stats.chunkCount,s.byteLength,f,p),g=this.initPTS[r.cc];h.push(s,d,u,l,r,i,o.totalduration,c,m,g)}onAudioTrackSwitching(e,t){const r=this.hls,i=0!==this.altAudio;if($f(t.url,r))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const e=this.fragCurrent;e&&(this.log("Switching to main audio track, cancel main fragment load"),e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(i)return this.altAudio=0,this.fragmentTracker.removeAllFragments(),r.once(Ou.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(Ou.AUDIO_TRACK_SWITCHED,t)}),void r.trigger(Ou.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});r.trigger(Ou.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const r=$f(t.url,this.hls);if(r){const e=this.videoBuffer;e&&this.mediaBuffer!==e&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=e)}this.altAudio=r?2:0,this.tick()}onBufferCreated(e,t){const r=t.tracks;let i,s,n=!1;for(const e in r){const t=r[e];if("main"===t.id){if(s=e,i=t,"video"===e){const t=r[e];t&&(this.videoBuffer=t.buffer)}}else n=!0}n&&i?(this.log(`Alternate track found, use ${s}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:r,part:i}=t,s=r.type===Bu;if(s){if(this.fragContextChanged(r))return this.warn(`Fragment ${r.sn}${i?" p: "+i.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===rg&&(this.state=Xm));const e=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*e.total/(e.buffering.end-e.loading.first)),Eh(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}const n=this.media;n&&(!this._hasEnoughToStart&&Rp.getBuffered(n).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),s&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var r;if(t.fatal)this.state=sg;else switch(t.details){case _u.FRAG_GAP:case _u.FRAG_PARSING_ERROR:case _u.FRAG_DECRYPT_ERROR:case _u.FRAG_LOAD_ERROR:case _u.FRAG_LOAD_TIMEOUT:case _u.KEY_LOAD_ERROR:case _u.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Bu,t);break;case _u.LEVEL_LOAD_ERROR:case _u.LEVEL_LOAD_TIMEOUT:case _u.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==ag||(null==(r=t.context)?void 0:r.type)!==Nu||(this.state=Xm);break;case _u.BUFFER_ADD_CODEC_ERROR:case _u.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case _u.BUFFER_FULL_ERROR:if("main"!==t.parent)return;if(this.reduceLengthAndFlushBuffer(t)){!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}break;case _u.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onFragLoadEmergencyAborted(){this.state=Xm,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==gh||!this.altAudio){const e=(t===vh?this.videoBuffer:this.mediaBuffer)||this.media;e&&(this.afterBufferFlushed(e,t,Bu),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void this.log(`could not seek to ${r}, already seeking at ${t}`);const i=this.timelineOffset;i&&r&&(r+=i);const s=this.getLevelDetails(),n=Rp.getBuffered(e),a=n.length?n.start(0):0,o=a-r,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||o>0&&(o<l||this.loadingParts&&o<2*((null==s?void 0:s.partTarget)||0)))&&(this.log(`adjusting start position by ${o} to match buffer start`),r+=o,this.startPosition=r),t<r&&(this.log(`seek to target start position ${r} from current time ${t} buffer start ${a}`),e.currentTime=r)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(e=>{const{hls:r}=this,i=null==e?void 0:e.frag;if(!i||this.fragContextChanged(i))return;t.fragmentError=0,this.state=Xm,this.startFragRequested=!1,this.bitrateTest=!1;const s=i.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now(),r.trigger(Ou.FRAG_LOADED,e),i.bitrateTest=!1}).catch(t=>{this.state!==qm&&this.state!==sg&&(this.warn(t),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:r}=this,{remuxResult:i,chunkMeta:s}=e,n=this.getCurrentContext(s);if(!n)return void this.resetWhenMissingContext(s);const{frag:a,part:o,level:l}=n,{video:c,text:d,id3:u,initSegment:h}=i,{details:f}=l,p=this.altAudio?void 0:i.audio;if(this.fragContextChanged(a))this.fragmentTracker.removeFragment(a);else{if(this.state=tg,h){const e=h.tracks;if(e){const i=a.initSegment||a;if(this.unhandledEncryptionError(h,a))return;this._bufferInitSegment(l,e,i,s),r.trigger(Ou.FRAG_PARSING_INIT_SEGMENT,{frag:i,id:t,tracks:e})}const i=h.initPTS,n=h.timescale,o=this.initPTS[a.cc];if(Ru(i)&&(!o||o.baseTime!==i||o.timescale!==n)){const e=h.trackId;this.initPTS[a.cc]={baseTime:i,timescale:n,trackId:e},r.trigger(Ou.INIT_PTS_FOUND,{frag:a,id:t,initPTS:i,timescale:n,trackId:e})}}if(c&&f){p&&"audiovideo"===c.type&&this.logMuxedErr(a);const e=f.fragments[a.sn-1-f.startSN],t=a.sn===f.startSN,r=!e||a.cc>e.cc;if(!1!==i.independent){const{startPTS:e,endPTS:i,startDTS:n,endDTS:l}=c;if(o)o.elementaryStreams[c.type]={startPTS:e,endPTS:i,startDTS:n,endDTS:l};else if(c.firstKeyFrame&&c.independent&&1===s.id&&!r&&(this.couldBacktrack=!0),c.dropped&&c.independent){const s=this.getMainFwdBufferInfo(),n=(s?s.end:this.getLoadPosition())+this.config.maxBufferHole,o=c.firstKeyFramePTS?c.firstKeyFramePTS:e;if(!t&&n<o-this.config.maxBufferHole&&!r)return void this.backtrack(a);r&&(a.gap=!0),a.setElementaryStreamInfo(c.type,a.start,i,a.start,l,!0)}else t&&e-(f.appliedTimelineOffset||0)>2&&(a.gap=!0);a.setElementaryStreamInfo(c.type,e,i,n,l),this.backtrackFragment&&(this.backtrackFragment=a),this.bufferFragmentData(c,a,o,s,t||r)}else{if(!t&&!r)return void this.backtrack(a);a.gap=!0}}if(p){const{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=p;o&&(o.elementaryStreams[gh]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),a.setElementaryStreamInfo(gh,e,t,r,i),this.bufferFragmentData(p,a,o,s)}if(f&&null!=u&&u.samples.length){const e={id:t,frag:a,details:f,samples:u.samples};r.trigger(Ou.FRAG_PARSING_METADATA,e)}if(f&&d){const e={id:t,frag:a,details:f,samples:d.samples};r.trigger(Ou.FRAG_PARSING_USERDATA,e)}}}logMuxedErr(e){this.warn(`${Eh(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,r,i){if(this.state!==tg)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(r));const{audio:s,video:n,audiovideo:a}=t;if(s){const r=e.audioCodec;let i=lf(s.codec,r);"mp4a"===i&&(i="mp4a.40.5");const n=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){i&&(i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");const e=s.metadata;e&&"channelCount"in e&&1!==(e.channelCount||1)&&-1===n.indexOf("firefox")&&(i="mp4a.40.5")}i&&-1!==i.indexOf("mp4a.40.5")&&-1!==n.indexOf("android")&&"audio/mpeg"!==s.container&&(i="mp4a.40.2",this.log(`Android: force audio codec to ${i}`)),r&&r!==i&&this.log(`Swapping manifest audio codec "${r}" for "${i}"`),s.levelCodec=i,s.id=Bu,this.log(`Init audio buffer, container:${s.container}, codecs[selected/level/parsed]=[${i||""}/${r||""}/${s.codec}]`),delete t.audiovideo}if(n){n.levelCodec=e.videoCodec,n.id=Bu;const r=n.codec;if(4===(null==r?void 0:r.length))switch(r){case"hvc1":case"hev1":n.codec="hvc1.1.6.L120.90";break;case"av01":n.codec="av01.0.04M.08";break;case"avc1":n.codec="avc1.42e01e"}this.log(`Init video buffer, container:${n.container}, codecs[level/parsed]=[${e.videoCodec||""}/${r}]${n.codec!==r?" parsed-corrected="+n.codec:""}${n.supplemental?" supplemental="+n.supplemental:""}`),delete t.audiovideo}a&&(this.log(`Init audiovideo buffer, container:${a.container}, codecs[level/parsed]=[${e.codecs}/${a.codec}]`),delete t.video,delete t.audio);const o=Object.keys(t);if(o.length){if(this.hls.trigger(Ou.BUFFER_CODECS,t),!this.hls)return;o.forEach(e=>{const s=t[e].initSegment;null!=s&&s.byteLength&&this.hls.trigger(Ou.BUFFER_APPENDING,{type:e,data:s,frag:r,part:null,chunkMeta:i,parent:r.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,Bu)}get maxBufferLength(){const{levels:e,level:t}=this,r=null==e?void 0:e[t];return r?this.getMaxBufferLength(r.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=Xm}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&!1===e.seeking){const r=e.currentTime;if(Rp.isBuffered(e,r)?t=this.getAppendedFrag(r):Rp.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;const e=this.fragPlaying,r=t.level;e&&t.sn===e.sn&&e.level===r||(this.fragPlaying=t,this.hls.trigger(Ou.FRAG_CHANGED,{frag:t}),e&&e.level===r||this.hls.trigger(Ou.LEVEL_SWITCHED,{level:r}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return Ru(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(Ru(t)){const e=this.getLevelDetails(),r=this.currentFrag||(e?Uf(null,e.fragments,t):null);if(r){const e=r.programDateTime;if(null!==e){const i=e+1e3*(t-r.start);return new Date(i)}}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class NE extends Ku{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const r in this.keyIdToKeyInfo){const i=this.keyIdToKeyInfo[r].loader;if(i){var t;if(e&&e!==(null==(t=i.context)?void 0:t.frag.type))return;i.abort()}}}detach(){for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,t=_u.KEY_LOAD_ERROR,r,i,s){return new Ap({type:Du.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:s,error:r,networkDetails:i})}loadClear(e,t,r){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let i=0,s=t.length;i<s;i++){const n=t[i];if(e.cc<=n.cc&&(!Eh(e)||!Eh(n)||e.sn<n.sn)||!r&&i==s-1)return this.emeController.selectKeySystemFormat(n).then(e=>{if(!this.emeController)return;n.setKeyFormat(e);const t=rm(e);return t?this.emeController.getKeySystemAccess([t]):void 0})}if(this.config.requireKeySystemAccessOnStart){const e=sm(this.config);if(e.length)return this.emeController.getKeySystemAccess(e)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,i;t&&e.setKeyFormat(t);const s=e.decryptdata;if(!s){const r=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,_u.KEY_LOAD_ERROR,r))}const n=s.uri;if(!n)return Promise.reject(this.createKeyLoadError(e,_u.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${n}"`)));const a=FE(s);let o=this.keyIdToKeyInfo[a];if(null!=(r=o)&&r.decryptdata.key)return s.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if(this.emeController&&null!=(i=o)&&i.keyLoadPromise){switch(this.emeController.getKeyStatus(o.decryptdata)){case"usable":case"usable-in-future":return o.keyLoadPromise.then(t=>{const{keyInfo:r}=t;return s.key=r.decryptdata.key,{frag:e,keyInfo:r}})}}switch(this.log(`${this.keyIdToKeyInfo[a]?"Rel":"L"}oading${s.keyId?" keyId: "+sh(s.keyId):""} URI: ${s.uri} from ${e.type} ${e.level}`),o=this.keyIdToKeyInfo[a]={decryptdata:s,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},s.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===s.keyFormat?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,_u.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${s.method}"`)))}}loadKeyEME(e,t){const r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i;if(!e.decryptdata.keyId&&null!=(i=t.initSegment)&&i.data){const r=function(e){const t=[];return Uh(e,e=>t.push(e.subarray(8,24))),t}(t.initSegment.data);if(r.length){let t=r[0];t.some(e=>0!==e)?(this.log(`Using keyId found in init segment ${sh(t)}`),cm.setKeyIdForUri(e.decryptdata.uri,t)):(t=cm.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${sh(t)}`)),e.decryptdata.keyId=t}}if(!e.decryptdata.keyId&&!Eh(t))return Promise.resolve(r);const s=this.emeController.loadKey(r);return(e.keyLoadPromise=s.then(t=>(e.mediaKeySessionContext=t,r))).catch(r=>{throw e.keyLoadPromise=null,"data"in r&&(r.data.frag=t),r})}return Promise.resolve(r)}loadKeyHTTP(e,t){const r=this.config,i=new(0,r.loader)(r);return t.keyLoader=e.loader=i,e.keyLoadPromise=new Promise((s,n)=>{const a={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},o=r.keyLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(e,t,r,i)=>{const{frag:a,keyInfo:o}=r,l=FE(o.decryptdata);if(!a.decryptdata||o!==this.keyIdToKeyInfo[l])return n(this.createKeyLoadError(a,_u.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),i));o.decryptdata.key=a.decryptdata.key=new Uint8Array(e.data),a.keyLoader=null,o.loader=null,s({frag:a,keyInfo:o})},onError:(e,r,i,s)=>{this.resetLoader(r),n(this.createKeyLoadError(t,_u.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),i,Yu({url:a.url,data:void 0},e)))},onTimeout:(e,r,i)=>{this.resetLoader(r),n(this.createKeyLoadError(t,_u.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(e,r,i)=>{this.resetLoader(r),n(this.createKeyLoadError(t,_u.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};i.load(a,l,c)})}resetLoader(e){const{frag:t,keyInfo:r,url:i}=e,s=r.loader;t.keyLoader===s&&(t.keyLoader=null,r.loader=null);const n=FE(r.decryptdata)||i;delete this.keyIdToKeyInfo[n],s&&s.destroy()}}function FE(e){if(e.keyFormat!==Jp){const t=e.keyId;if(t)return sh(t)}return e.uri}function $E(e){const{type:t}=e;switch(t){case Fu:return Uu;case $u:return zu;default:return Bu}}function BE(e,t){let r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}class UE{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Ou.LEVEL_LOADING,this.onLevelLoading,this),e.on(Ou.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(Ou.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(Ou.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Ou.LEVEL_LOADING,this.onLevelLoading,this),e.off(Ou.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(Ou.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(Ou.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,r=t.pLoader,i=t.loader,s=new(r||i)(t);return this.loaders[e.type]=s,s}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Mu,url:r,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:r,level:i,pathwayId:s,url:n,deliveryDirectives:a,levelInfo:o}=t;this.load({id:r,level:i,pathwayId:s,responseType:"text",type:Nu,url:n,deliveryDirectives:a,levelOrTrack:o})}onAudioTrackLoading(e,t){const{id:r,groupId:i,url:s,deliveryDirectives:n,track:a}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:Fu,url:s,deliveryDirectives:n,levelOrTrack:a})}onSubtitleTrackLoading(e,t){const{id:r,groupId:i,url:s,deliveryDirectives:n,track:a}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:$u,url:s,deliveryDirectives:n,levelOrTrack:a})}onLevelsUpdated(e,t){const r=this.loaders[Nu];if(r){const e=r.context;e&&!t.levels.some(t=>t===e.levelOrTrack)&&(r.abort(),delete this.loaders[Nu])}}load(e){var t;const r=this.hls.config;let i,s=this.getInternalLoader(e);if(s){const t=this.hls.logger,r=s.context;if(r&&r.levelOrTrack===e.levelOrTrack&&(r.url===e.url||r.deliveryDirectives&&!e.deliveryDirectives))return void(r.url===e.url?t.log(`[playlist-loader]: ignore ${e.url} ongoing request`):t.log(`[playlist-loader]: ignore ${e.url} in favor of ${r.url}`));t.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}if(i=e.type===Mu?r.manifestLoadPolicy.default:Vu({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),Ru(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===Nu&&null!==e.level?t=this.hls.levels[e.level].details:e.type===Fu&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===$u&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){const e=t.partTarget,r=t.targetduration;if(e&&r){const t=1e3*Math.max(3*e,.8*r);i=Vu({},i,{maxTimeToFirstByteMs:Math.min(t,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,i.maxTimeToFirstByteMs)})}}}const n=i.errorRetry||i.timeoutRetry||{},a={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0},o={onSuccess:(e,t,r,i)=>{const s=this.getInternalLoader(r);this.resetInternalLoader(r.type);const n=e.data;t.parsing.start=performance.now(),gm.isMediaPlaylist(n)||r.type!==Mu?this.handleTrackOrLevelPlaylist(e,t,r,i||null,s):this.handleMasterPlaylist(e,t,r,i)},onError:(e,t,r,i)=>{this.handleNetworkError(t,r,!1,e,i)},onTimeout:(e,t,r)=>{this.handleNetworkError(t,r,!0,void 0,e)}};s.load(e,a,o)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:t},forceStartLoad:r}=this.hls;(e||r)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,r,i){const s=this.hls,n=e.data,a=BE(e,r),o=gm.parseMasterPlaylist(n,a);if(o.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);const{contentSteering:l,levels:c,sessionData:d,sessionKeys:u,startTimeOffset:h,variableList:f}=o;this.variableList=f,c.forEach(e=>{const{unknownCodecs:t}=e;if(t){const{preferManagedMediaSource:r}=this.hls.config;let{audioCodec:i,videoCodec:s}=e;for(let n=t.length;n--;){const a=t[n];Jh(a,"audio",r)?(e.audioCodec=i=i?`${i},${a}`:a,Qh.audio[i.substring(0,4)]=2,t.splice(n,1)):Jh(a,"video",r)&&(e.videoCodec=s=s?`${s},${a}`:a,Qh.video[s.substring(0,4)]=2,t.splice(n,1))}}});const{AUDIO:p=[],SUBTITLES:m,"CLOSED-CAPTIONS":g}=gm.parseMasterPlaylistMedia(n,a,o);if(p.length){p.some(e=>!e.url)||!c[0].audioCodec||c[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Fp({}),bitrate:0,url:""}))}s.trigger(Ou.MANIFEST_LOADED,{levels:c,audioTracks:p,subtitles:m,captions:g,contentSteering:l,url:a,stats:t,networkDetails:i,sessionData:d,sessionKeys:u,startTimeOffset:h,variableList:f})}handleTrackOrLevelPlaylist(e,t,r,i,s){const n=this.hls,{id:a,level:o,type:l}=r,c=BE(e,r),d=Ru(o)?o:Ru(a)?a:0,u=$E(r),h=gm.parseLevelPlaylist(e.data,c,d,u,0,this.variableList);if(l===Mu){const e={attrs:new Fp({}),bitrate:0,details:h,name:"",url:c};h.requestScheduled=t.loading.start+Om(h,0),n.trigger(Ou.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:c,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=h,this.handlePlaylistLoaded(h,e,t,r,i,s)}handleManifestParsingError(e,t,r,i,s){this.hls.trigger(Ou.ERROR,{type:Du.NETWORK_ERROR,details:_u.MANIFEST_PARSING_ERROR,fatal:t.type===Mu,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:s})}handleNetworkError(e,t,r=!1,i,s){let n=`A network ${r?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading ${e.type}`;e.type===Nu?n+=`: ${e.level} id: ${e.id}`:e.type!==Fu&&e.type!==$u||(n+=` id: ${e.id} group-id: "${e.groupId}"`);const a=new Error(n);this.hls.logger.warn(`[playlist-loader]: ${n}`);let o=_u.UNKNOWN,l=!1;const c=this.getInternalLoader(e);switch(e.type){case Mu:o=r?_u.MANIFEST_LOAD_TIMEOUT:_u.MANIFEST_LOAD_ERROR,l=!0;break;case Nu:o=r?_u.LEVEL_LOAD_TIMEOUT:_u.LEVEL_LOAD_ERROR,l=!1;break;case Fu:o=r?_u.AUDIO_TRACK_LOAD_TIMEOUT:_u.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case $u:o=r?_u.SUBTITLE_TRACK_LOAD_TIMEOUT:_u.SUBTITLE_LOAD_ERROR,l=!1}c&&this.resetInternalLoader(e.type);const d={type:Du.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:c,context:e,error:a,networkDetails:t,stats:s};if(i){const r=(null==t?void 0:t.url)||e.url;d.response=Yu({url:r,data:void 0},i)}this.hls.trigger(Ou.ERROR,d)}handlePlaylistLoaded(e,t,r,i,s,n){const a=this.hls,{type:o,level:l,levelOrTrack:c,id:d,groupId:u,deliveryDirectives:h}=i,f=BE(t,i),p=$E(i);let m="number"==typeof i.level&&p===Bu?l:void 0;const g=e.playlistParsingError;if(g){if(this.hls.logger.warn(`${g} ${e.url}`),!a.config.ignorePlaylistParsingErrors)return void a.trigger(Ou.ERROR,{type:Du.NETWORK_ERROR,details:_u.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:i,level:m,parent:p,networkDetails:s,stats:r});e.playlistParsingError=null}if(!e.fragments.length){const n=e.playlistParsingError=new Error("No Segments found in Playlist");return void a.trigger(Ou.ERROR,{type:Du.NETWORK_ERROR,details:_u.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:n,reason:n.message,response:t,context:i,level:m,parent:p,networkDetails:s,stats:r})}switch(e.live&&n&&(n.getCacheAge&&(e.ageHeader=n.getCacheAge()||0),n.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case Mu:case Nu:if(m)if(c){if(c!==a.levels[m]){const e=a.levels.indexOf(c);e>-1&&(m=e)}}else m=0;a.trigger(Ou.LEVEL_LOADED,{details:e,levelInfo:c||a.levels[0],level:m||0,id:d||0,stats:r,networkDetails:s,deliveryDirectives:h,withoutMultiVariant:o===Mu});break;case Fu:a.trigger(Ou.AUDIO_TRACK_LOADED,{details:e,track:c,id:d||0,groupId:u||"",stats:r,networkDetails:s,deliveryDirectives:h});break;case $u:a.trigger(Ou.SUBTITLE_TRACK_LOADED,{details:e,track:c,id:d||0,groupId:u||"",stats:r,networkDetails:s,deliveryDirectives:h})}}}class zE{static get version(){return pg}static isMSESupported(){return OE()}static isSupported(){return function(){if(!OE())return!1;const e=th();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(t=>e.isTypeSupported(tf(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(tf(t,"audio"))))}()}static getMediaSource(){return th()}static get Events(){return Ou}static get MetadataSchema(){return Fg}static get ErrorTypes(){return Du}static get ErrorDetails(){return _u}static get DefaultConfig(){return zE.defaultConfig?zE.defaultConfig:bE}static set DefaultConfig(e){zE.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new fg,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const t=this.logger=function(e,t,r){const i=Qu();if("object"==typeof console&&!0===e||"object"==typeof e){const s=["debug","log","info","warn","error"];s.forEach(t=>{i[t]=Zu(t,e,r)});try{i.log(`Debug logs enabled for "${t}" in hls.js version 1.6.15`)}catch(e){return Qu()}s.forEach(t=>{Ju[t]=Zu(t,e)})}else Vu(Ju,i);return i}(e.debug||!1,"Hls instance",e.assetPlayerId),r=this.config=function(e,t,r){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const i=EE(e),s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{const n=`${"level"===e?"playlist":e}LoadPolicy`,a=void 0===t[n],o=[];s.forEach(r=>{const s=`${e}Loading${r}`,l=t[s];if(void 0!==l&&a){o.push(s);const e=i[n].default;switch(t[n]={default:e},r){case"TimeOut":e.maxLoadTimeMs=l,e.maxTimeToFirstByteMs=l;break;case"MaxRetry":e.errorRetry.maxNumRetry=l,e.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":e.errorRetry.retryDelayMs=l,e.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":e.errorRetry.maxRetryDelayMs=l,e.timeoutRetry.maxRetryDelayMs=l}}}),o.length&&r.warn(`hls.js config: "${o.join('", "')}" setting(s) are deprecated, use "${n}": ${Pf(t[n])}`)}),Yu(Yu({},i),t)}(zE.DefaultConfig,e,t);this.userConfig=e,r.progressive&&wE(r,t);const{abrController:i,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=r,l=new a(this),c=this.abrController=new i(this),d=new up(this),u=r.interstitialsController,h=u?this.interstitialsController=new u(this,zE):null,f=this.bufferController=new s(this,d),p=this.capLevelController=new n(this),m=new o(this),g=new UE(this),v=r.contentSteeringController,y=v?new v(this):null,b=this.levelController=new CE(this,y),E=new RE(this),w=new NE(this.config,this.logger),S=this.streamController=new ME(this,d,w),T=this.gapController=new SE(this,d);p.setStreamController(S),m.setStreamController(S);const x=[g,b,S];h&&x.splice(1,0,h),y&&x.splice(1,0,y),this.networkControllers=x;const A=[c,f,T,p,m,E,d];this.audioTrackController=this.createController(r.audioTrackController,x);const k=r.audioStreamController;k&&x.push(this.audioStreamController=new k(this,d,w)),this.subtitleTrackController=this.createController(r.subtitleTrackController,x);const L=r.subtitleStreamController;L&&x.push(this.subtititleStreamController=new L(this,d,w)),this.createController(r.timelineController,A),w.emeController=this.emeController=this.createController(r.emeController,A),this.cmcdController=this.createController(r.cmcdController,A),this.latencyController=this.createController(PE,A),this.coreComponents=A,x.push(l);const I=l.onErrorOut;"function"==typeof I&&this.on(Ou.ERROR,I,l),this.on(Ou.MANIFEST_LOADED,g.onManifestLoaded,g)}createController(e,t){if(e){const r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,i){this._emitter.off(e,t,r,i)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;const r=e===Ou.ERROR;this.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.INTERNAL_EXCEPTION,fatal:r,event:e,error:t}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(Ou.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){const t=new Error(`attachMedia failed: invalid argument (${e})`);return void this.trigger(Ou.ERROR,{type:Du.OTHER_ERROR,details:_u.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const t="media"in e,r=t?e.media:e,i=t?e:{media:r};this._media=r,this.trigger(Ou.MEDIA_ATTACHING,i)}detachMedia(){this.logger.log("detachMedia"),this.trigger(Ou.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(Ou.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,r=this._url,i=this._url=ph.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${i}`),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(Ou.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(e,t),this.started&&this.networkControllers);r++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){const e={[Bu]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[Uu]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[zu]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(e){try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){let t=(new Date).getTime();const r="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?r:3&r|8).toString(16)});return r}}}()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){(function(e){return Ef.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const r=e.length;for(let i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this;let i;if(i=-1===t&&null!=e&&e.length?e.length-1:t,r)for(let t=i;t--;){const i=e[t].attrs["HDCP-LEVEL"];if(i&&i<=r)return t}return i}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}get interstitialsManager(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){return vf(e,Df(t),navigator.mediaCapabilities)}}zE.defaultConfig=void 0;const GE=({file:e,startTime:s,poster:n,autoplay:o=!0,active:l=!0,visible:c=!0,muted:h=!0})=>{const f=r(null),{isReady:p,prewarm:m,setLowestResolution:g,startBufferBasedUpshift:v}=(({file:e,videoRef:t,autoplay:s=!0,startTime:n,enabled:o=!0,onReady:l,onError:c})=>{const h=r(null),f=r(null),p=r(0),m=r(0),g=r(!1),v=r(!1),[y,b]=a("idle"),[E,w]=a(0),[S,T]=a(!1),[A,k]=a([]),[L,I]=a("auto"),R=()=>{null!=f.current&&(clearTimeout(f.current),f.current=null)},P=(e=1e3)=>{if(null!=f.current)return;const t=p.current;if(t>=5)return b("error"),R(),void(null==c||c(new Error("Max retry reached")));const r=Math.min(15e3,e*Math.pow(2,Math.min(t,4)));b("loading"),console.log(`[HLS] schedule retry #${t+1} in ${r}ms`),f.current=window.setTimeout(()=>{f.current=null,p.current+=1,console.log(`[HLS] retryCount => ${p.current}`),w(e=>e+1)},r)};i(()=>{p.current=0,m.current=0,v.current=!1,T(!1),w(0),b(e?"loading":"idle"),R()},[e]);const C=u(()=>x(void 0,void 0,void 0,function*(){if(e)try{yield fetch(e,{method:"HEAD",mode:"cors",credentials:"omit"})}catch(e){}}),[e]);i(()=>{var r;const i=t.current;if(!i||!e||!o)return void(e&&!o&&(v.current=!1,T(!1),b("idle")));let n=()=>{};try{null===(r=h.current)||void 0===r||r.destroy()}catch(e){}if(h.current=null,v.current=!1,T(!1),b("loading"),zE.isSupported()){g.current=!1;const t=new zE({lowLatencyMode:!1,backBufferLength:0,maxBufferLength:2,maxMaxBufferLength:4,maxBufferSize:2e6,maxBufferHole:.5,startFragPrefetch:!0,capLevelToPlayerSize:!0});h.current=t;const r=()=>{const e=(t.levels||[]).map((e,t)=>{const r=e.height,i=e.width,s=e.bitrate,n=e.name;return{id:t,height:r,width:i,bitrate:s,name:n,label:n||(r?`${r}p`:`Level ${t}`)}});k(e);const r=t.currentLevel;I(null==r||r<0?"auto":r)},a=()=>{v.current||(v.current=!0,T(!0),b("ready"),p.current=0,R(),null==l||l(),s&&i.play().catch(()=>{}))};t.on(zE.Events.MANIFEST_PARSED,()=>{r(),s||_()}),t.on(zE.Events.FRAG_BUFFERED,a),t.on(zE.Events.BUFFER_APPENDED,a),t.on(zE.Events.LEVEL_SWITCHED,(e,t)=>{const r=null==t?void 0:t.level;I(null==r||r<0?"auto":r)}),t.on(zE.Events.ERROR,(e,r)=>{var i,s,n,a,o;const l=500===(null!==(a=null!==(s=null===(i=null==r?void 0:r.response)||void 0===i?void 0:i.code)&&void 0!==s?s:null===(n=null==r?void 0:r.response)||void 0===n?void 0:n.status)&&void 0!==a?a:null===(o=null==r?void 0:r.response)||void 0===o?void 0:o.statusCode);if(r.type!==zE.ErrorTypes.NETWORK_ERROR||r.fatal){if(r.fatal){if(r.type===zE.ErrorTypes.MEDIA_ERROR){if(m.current+=1,m.current<=2){try{t.recoverMediaError()}catch(e){}return void b("loading")}try{t.destroy()}catch(e){}return h.current=null,v.current=!1,T(!1),void P()}if(l){console.warn("[HLS] fatal 500 response - no retry");try{t.destroy()}catch(e){}return h.current=null,v.current=!1,T(!1),R(),b("error"),void(null==c||c(new Error("HTTP 500")))}try{t.destroy()}catch(e){}return h.current=null,v.current=!1,T(!1),void P()}}else{if(l){console.warn("[HLS] 500 response detected - no retry"),b("error");try{t.destroy()}catch(e){}return h.current=null,R(),void(null==c||c(new Error("HTTP 500")))}try{if(p.current>=5){b("error");try{t.destroy()}catch(e){}return h.current=null,void(null==c||c(new Error("Max retry reached")))}p.current+=1,console.log(`[HLS] non-fatal network retry => ${p.current}`),t.startLoad()}catch(e){}}}),t.attachMedia(i),t.loadSource(e),n=()=>{try{t.destroy()}catch(e){}h.current=null}}else if(i.canPlayType("application/vnd.apple.mpegURL")){g.current=!0,i.src!==e&&(i.src=e);const t=()=>{v.current||(v.current=!0,T(!0),b("ready"),p.current=0,R(),null==l||l(),s&&i.play().catch(()=>{}))},r=()=>{if(v.current=!1,T(!1),p.current>=5)return b("error"),void(null==c||c(new Error("Max retry reached")));P()};i.addEventListener("loadedmetadata",t),i.addEventListener("error",r),s&&i.play().catch(()=>{}),n=()=>{i.removeEventListener("loadedmetadata",t),i.removeEventListener("error",r)}}else b("error"),null==c||c(new Error("HLS not supported"));return()=>{n(),R()}},[e,E,s,l,c,t,o]),i(()=>{if(!S)return;if(null==n||n<=0)return;const e=t.current;if(e)try{Math.abs(e.currentTime-n)>.5&&(e.currentTime=n)}catch(e){}},[S,n,t]),i(()=>{const e=t.current;if(!e)return;const r=()=>b("ready"),i=()=>b("ready"),s=()=>{"error"!==y&&b("loading")},n=()=>b("loading"),a=()=>{b("error"),null==c||c()};return e.addEventListener("playing",r),e.addEventListener("canplay",i),e.addEventListener("waiting",s),e.addEventListener("stalled",n),e.addEventListener("error",a),()=>{e.removeEventListener("playing",r),e.removeEventListener("canplay",i),e.removeEventListener("waiting",s),e.removeEventListener("stalled",n),e.removeEventListener("error",a)}},[y,c,t]);const D=u(()=>{const e=h.current;e&&!g.current&&(console.log("Set auto resolution"),e.nextLevel=-1,I("auto"))},[]),_=u(()=>{var e,t;const r=h.current;if(!r)return;const i=r.levels||[];if(i.length){let s=0;for(let r=1;r<i.length;r++)(null!==(e=i[r].height)&&void 0!==e?e:99999)<(null!==(t=i[s].height)&&void 0!==t?t:99999)&&(s=r);r.currentLevel=s}},[]),O=u((e=2)=>{const r=h.current,i=t.current;if(!r||!i||g.current)return()=>{};let s=!1;const n=()=>{if(!s)if(r.autoLevelEnabled)s=!0;else try{i.buffered.length>0&&i.buffered.end(0)-i.currentTime>=e&&(r.nextLevel=-1,I("auto"),s=!0)}catch(e){}};return r.on(zE.Events.FRAG_BUFFERED,n),()=>{r.off(zE.Events.FRAG_BUFFERED,n)}},[t]);return{playbackStatus:y,isReady:S,qualities:A,currentLevel:L,isAutoQuality:d(()=>"auto"===L,[L]),canSetResolution:!g.current&&zE.isSupported(),setResolution:e=>{const t=h.current;if(!t||g.current)return;if("string"==typeof e&&"auto"===e.toLowerCase())return t.currentLevel=-1,void I("auto");const r="number"==typeof e?e:parseInt(e,10);if(!Number.isFinite(r)){const r=A.find(t=>t.label.toLowerCase()===String(e).toLowerCase());return void(r&&(t.currentLevel=r.id,I(r.id)))}const i=[...A].filter(e=>e.height).sort((e,t)=>(t.height||0)-(e.height||0)),s=i.find(e=>(e.height||0)<=r)||i[i.length-1];s&&(t.currentLevel=s.id,I(s.id))},setAutoResolution:D,prewarm:C,setLowestResolution:_,startBufferBasedUpshift:O}})({file:e,videoRef:f,autoplay:o,startTime:s,enabled:o||l});return i(()=>{m()},[m]),t.useEffect(()=>{var e,t;const r=f.current;if(r)if(l)null===(e=r.play)||void 0===e||e.call(r).catch(()=>{});else try{null===(t=r.pause)||void 0===t||t.call(r)}catch(e){}},[l,p]),i(()=>{if(!l)return;g();return v(2)},[l,g,v]),t.createElement("video",{ref:f,playsInline:!0,autoPlay:o,muted:h,poster:Ct(n||""),preload:"metadata",className:"w-full h-full object-cover object-center bg-black",style:{opacity:c&&p?1:0,transition:"opacity 200ms ease-in-out"}})},jE=({view:e})=>t.createElement("div",{className:"absolute",style:{top:8,left:8,borderRadius:"4px",color:"white",overflow:"hidden",fontSize:11}},t.createElement("span",{style:{backgroundColor:"rgba(62,213,69,0.71)",color:"white",padding:4,paddingLeft:9,paddingRight:9,display:"inline-block",lineHeight:1}},"다시보기"),t.createElement("span",{style:{backgroundColor:"rgba(58,58,58,0.52)",color:"white",padding:4,paddingLeft:9,paddingRight:9,display:"inline-block",lineHeight:1}},e," 시청")),HE=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:s,playback:n="hover"})=>{var a,o,l,c,d;const u=t.useRef(null),[h,f]=t.useState(!1),p=t.useRef(null),[m,g]=t.useState(!1),[v,y]=t.useState(!0),[b,E]=t.useState(!1),{boxSize:w}=Lu(r,u),S=e.thumbPath||(null===(o=null===(a=null==e?void 0:e.designInfo)||void 0===a?void 0:a.thumbPath)||void 0===o?void 0:o.preview),T=3===e.status,{API_BASE_URL:x,PLAYER_BASE_URL:A}=gt(),k=`${x}/hls/${null===(l=e.replay)||void 0===l?void 0:l.objectId}`;t.useEffect(()=>{const e=u.current;if(!e)return;const t=new IntersectionObserver(e=>{const t=e[0];E(t.isIntersecting&&t.intersectionRatio>=.5)},{root:null,threshold:[0,.5,1]});return t.observe(e),()=>t.disconnect()},[n]),t.useEffect(()=>{var e;if("undefined"!=typeof window&&window.matchMedia)try{const t=window.matchMedia("(pointer: fine)"),r=()=>y(t.matches);return r(),null===(e=t.addEventListener)||void 0===e||e.call(t,"change",r),()=>{var e;return null===(e=t.removeEventListener)||void 0===e?void 0:e.call(t,"change",r)}}catch(e){}},[n]);const L=()=>{null!=p.current&&(clearTimeout(p.current),p.current=null)},I=()=>{g(!0),L(),f(!1)};t.useEffect(()=>{const e=()=>g(!1);return window.addEventListener("mouseup",e),window.addEventListener("touchend",e),window.addEventListener("pointerup",e),()=>{window.removeEventListener("mouseup",e),window.removeEventListener("touchend",e),window.removeEventListener("pointerup",e)}},[n]);const R="hover"===n&&v,P=Boolean(k&&("autoplay"===n&&b||R&&h));return t.createElement("div",{className:"w-full h-full flex flex-col items-center justify-center",ref:u,onMouseEnter:()=>{"hover"===n&&v&&(m||(L(),p.current=window.setTimeout(()=>{f(!0)},150)))},onMouseLeave:()=>{L(),f(!1)},onMouseDown:I,onTouchStart:I},t.createElement("div",{className:"relative rounded overflow-hidden",style:{width:w.width?`${w.width}px`:"100%",height:w.height?`${w.height}px`:"100%",borderRadius:`${null!=s?s:10}px`,backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",aspectRatio:w.height?void 0:r,backgroundImage:S?`url(${Ct(S)})`:void 0,backgroundColor:S?void 0:"black"}},T?t.createElement("iframe",{src:`${A}/live/${e.eventId}`,className:"w-full h-full"}):t.createElement(t.Fragment,null,t.createElement("div",{className:"absolute inset-0 w-full h-full object-cover",style:{pointerEvents:"none"}},t.createElement(GE,{file:k,poster:S,autoplay:"autoplay"===n,active:"autoplay"===n&&b||R&&h,visible:P,muted:!0})),!P&&t.createElement(Au,null),t.createElement(jE,{view:null!==(d=null===(c=e.statistics)||void 0===c?void 0:c.pageView)&&void 0!==d?d:0}))))},VE=e=>{var r,i,s,n;const{content:a,title:o,aspectRatio:l="9/16",card:c,titleFontSize:u}=e,h=null!==(r=null==c?void 0:c.layout)&&void 0!==r?r:"slider",f=null!==(i=null==c?void 0:c.sliderPerView)&&void 0!==i?i:3,p=null!==(s=null==c?void 0:c.gridColumns)&&void 0!==s?s:3,m=null!==(n=null==c?void 0:c.gap)&&void 0!==n?n:12,g=null==c?void 0:c.width,v=g?"auto":f,y=d(()=>({fontSize:u?`${u}px`:void 0,fontWeight:600}),[u]),{PLAYER_BASE_URL:b}=gt();return a&&0!==a.length?t.createElement("div",{className:"flex flex-col w-full",style:{gap:m}},t.createElement("p",{className:"truncate",style:Object.assign(Object.assign({},y),{userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",cursor:"default"})},o||("past"===e.liveType?"지난 라이브":"예정된 라이브")),"slider"===h?t.createElement("div",null,t.createElement(Jn,{key:`${v}-${null!=g?g:""}-${m}`,slidesPerView:v,spaceBetween:m},a.map(r=>{var i,s;return t.createElement(ea,{key:r.eventId,style:g?{width:`${g}px`}:void 0},t.createElement("a",{href:`${b}/live/${r.eventId}`,target:"_blank",rel:"noopener noreferrer",className:"flex flex-col",style:{gap:6,textDecoration:"none",cursor:"pointer"}},"past"===e.liveType&&r.eventStatus!==xu.READY?t.createElement(HE,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius,playback:e.playback}):t.createElement(Iu,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius}),t.createElement("p",{className:"truncate",style:{color:null!==(s=null===(i=e.theme)||void 0===i?void 0:i.textColor)&&void 0!==s?s:"black",fontSize:14,userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"}},r.eventName)))}))):t.createElement("div",{style:{overflowY:"auto"}},t.createElement("div",{style:{display:"grid",gridTemplateColumns:g?`repeat(auto-fill, ${g}px)`:`repeat(${p}, minmax(0, 1fr))`,gap:m}},a.map(r=>{var i,s;return t.createElement("a",{key:r.eventId,href:`${b}/live/${r.eventId}`,target:"_blank",rel:"noopener noreferrer",className:"flex flex-col",style:{gap:6,textDecoration:"none",cursor:"pointer"}},"past"===e.liveType&&r.eventStatus!==xu.READY?t.createElement(HE,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius,playback:e.playback}):t.createElement(Iu,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==c?void 0:c.borderRadius}),t.createElement("p",{className:"truncate",style:{color:null!==(s=null===(i=e.theme)||void 0===i?void 0:i.textColor)&&void 0!==s?s:"black",fontSize:14,userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"}},r.eventName))})))):null},WE=({content:e})=>{const r=t.useMemo(()=>qe(e.start).tz("Asia/Seoul").format("M월 D일 A HH:mm"),[e.start]),i=e.eventStatus!==xu.READY;return t.createElement("div",{className:"flex-1 flex flex-col gap-5 items-center justify-center"},t.createElement("p",{style:{fontWeight:"bold",fontSize:"24px"}},e.eventName),!i&&t.createElement("p",null,r),t.createElement("button",{onClick:()=>{window.open(`https://player.midibus.im/live/${e.eventId}`,"_blank")},className:"rounded bg-black text-white cursor-pointer",style:{width:"70%",padding:"10px"}},"라이브 입장하기"))},YE=e=>{var r,i;const{content:s,aspectRatio:n="9/16",videoAlign:a}=e,o=null===(r=e.card)||void 0===r?void 0:r.borderRadius,l=null===(i=e.card)||void 0===i?void 0:i.width,{PLAYER_BASE_URL:c}=gt();return t.createElement("div",{className:"flex w-full h-full items-center justify-center"},"only"===a?t.createElement("a",{className:"w-full h-full",href:`${c}/live/${s.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(Iu,{content:s,aspectRatio:n,borderRadius:o,cursor:"pointer"})):"left"===a?t.createElement(t.Fragment,null,t.createElement("div",{className:"flex-1"},t.createElement("a",{href:`${c}/live/${s.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(Iu,{content:s,aspectRatio:n,borderRadius:o,cursor:"pointer"}))),t.createElement(WE,{content:s})):t.createElement(t.Fragment,null,t.createElement(WE,{content:s}),t.createElement("div",{className:"flex-1"},t.createElement("a",{href:`${c}/live/${s.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(Iu,{content:s,aspectRatio:n,borderRadius:o,cursor:"pointer"})))))},KE=e=>{var r;const{theme:i,titleFontSize:s,title:n}=e;return t.createElement("div",{className:"w-full h-full flex flex-col",style:{color:null!==(r=null==i?void 0:i.textColor)&&void 0!==r?r:"#252525"}},t.createElement("p",{style:Object.assign(Object.assign({},s&&{fontSize:s}),{fontWeight:"bold",color:null==i?void 0:i.textColor,paddingTop:"10px",paddingBottom:"10px",marginBottom:"30px"})},n||("past"===e.liveType?"지난 라이브":"예정된 라이브")),t.createElement("div",{className:"self-center text-center h-full flex flex-col items-center justify-center",style:{minHeight:"200px"}},t.createElement("p",{style:{fontSize:"20px",marginBottom:"10px"}},"past"===e.liveType?"지난 라이브가 없어요.":"예정된 라이브가 없어요."),t.createElement("span",{style:{fontWeight:"lighter"}},"past"===e.liveType?"다른 콘텐츠도 확인해 보세요.":"곧 혜택 가득한 라이브로 찾아올게요!")))};function qE(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({className:St("animate-pulse rounded-md bg-gray-200",r)},i))}const XE=e=>{var r,i,s,n,a,o,l,c,d;const{card:u,aspectRatio:h="9/16",widgetType:f,layout:p,theme:m}=e,g=null!==(r=null==u?void 0:u.layout)&&void 0!==r?r:"slider",v=null!==(i=null==u?void 0:u.sliderPerView)&&void 0!==i?i:3,y=null!==(s=null==u?void 0:u.gridColumns)&&void 0!==s?s:3,b=null!==(n=null==u?void 0:u.gap)&&void 0!==n?n:12,E=null!==(a=null==u?void 0:u.borderRadius)&&void 0!==a?a:8,w=null!==(o=null==p?void 0:p.paddingTop)&&void 0!==o?o:0,S=null!==(l=null==p?void 0:p.paddingBottom)&&void 0!==l?l:0,T=null!==(c=null==p?void 0:p.paddingLeft)&&void 0!==c?c:0,x=null!==(d=null==p?void 0:p.paddingRight)&&void 0!==d?d:0,A="ONE"===f&&"past"!==e.liveType,k=A?1:(null==u?void 0:u.visibleCount)||6,L=A?1:"slider"===g?v:k;return t.createElement("div",{className:"w-full flex flex-col",style:{gap:b,paddingTop:w,paddingBottom:S,paddingLeft:T,paddingRight:x,backgroundColor:null==m?void 0:m.backgroundColor}},t.createElement(qE,{className:"h-5 w-36"}),t.createElement("div",{style:A||"scroll"!==g?{display:"flex",gap:b,overflow:"hidden"}:{display:"grid",gridTemplateColumns:`repeat(${y}, minmax(0, 1fr))`,gap:b}},Array.from({length:L}).map((e,r)=>t.createElement("div",{key:r,className:"flex flex-col flex-shrink-0",style:{flex:A||"slider"!==g?void 0:`0 0 calc((100% - ${b*(v-1)}px) / ${v})`,gap:6}},t.createElement(qE,{style:{aspectRatio:h,borderRadius:E,width:"100%"}}),t.createElement(qE,{className:"h-3.5 w-4/5"})))))},QE=e=>{var r,i,s,n;const{widgetType:a,theme:o,layout:l}=e,c=Tu(e=>e.liveWidget),d=null!==(r=null==l?void 0:l.paddingTop)&&void 0!==r?r:0,u=null!==(i=null==l?void 0:l.paddingBottom)&&void 0!==i?i:0,h=null!==(s=null==l?void 0:l.paddingLeft)&&void 0!==s?s:0,f=null!==(n=null==l?void 0:l.paddingRight)&&void 0!==n?n:0;return null===c?t.createElement(XE,Object.assign({},e)):0===c.length?t.createElement(KE,Object.assign({},e)):t.createElement("div",{className:"w-full h-full",style:{backgroundColor:null==o?void 0:o.backgroundColor,color:null==o?void 0:o.textColor,paddingTop:d,paddingBottom:u,paddingLeft:h,paddingRight:f}},"ONE"===a&&"past"!==e.liveType?t.createElement(YE,Object.assign({content:c[0]},e)):t.createElement(VE,Object.assign({content:c},e)))},ZE=e=>{const r=Tu(e=>e.liveWidget),s=Tu(e=>e.setLiveWidget),{userId:n,card:a,includeRepresentative:o=!1,liveType:l}=e;return i(()=>{if(!n)return;if(r&&(null==a?void 0:a.visibleCount)&&r.length>Number(a.visibleCount))return void s(r.slice(0,null==a?void 0:a.visibleCount));const t=new AbortController;return x(void 0,void 0,void 0,function*(){const r=yield _a(n,"past"===l?"FINISHED":"UPCOMING",(null==a?void 0:a.visibleCount)||6,o,e.sorting);if(!r||t.signal.aborted)return;s(r);const i=yield Promise.allSettled(r.map(e=>x(void 0,void 0,void 0,function*(){const t=yield((e,t)=>x(void 0,void 0,void 0,function*(){const{STATISTICS_BASE_URL:r}=gt(),i=`${r}/replay/${e}/${t}/summary`,s=yield fetch(i);if(404!==s.status){if(!s.ok){const e=yield s.text().catch(()=>"");return console.error(`[ReplayStatistics] ${s.status} ${s.statusText} ${e}`),{pageView:0,like:0}}return s.json()}}))(n,e.eventId);return Object.assign(Object.assign({},e),{statistics:t})})));t.signal.aborted||s(i.map((e,t)=>"fulfilled"===e.status?e.value:r[t]))}),()=>t.abort()},[n,null==a?void 0:a.visibleCount,l,e.sorting,o]),t.createElement(Sr.div,{className:"w-full h-full"},t.createElement(fo,null),t.createElement(QE,Object.assign({},e)))},JE=e=>t.createElement(Su,null,t.createElement(ZE,Object.assign({},e))),ew=({eventId:e})=>{const[r,i]=a(!1),{PLAYER_BASE_URL:s}=gt();if(r)return null;const{w:n,h:o,left:l,top:c}=(()=>{const e=window.visualViewport;return e?{w:e.width,h:e.height,left:e.offsetLeft,top:e.offsetTop}:{w:window.innerWidth,h:window.innerHeight,left:0,top:0}})();return t.createElement(vu,{minWidth:240,lockAspectRatio:9/17.05,style:{zIndex:99999},default:{width:240,height:455,x:l+n-240-50,y:c+o-427-28-50},bounds:"window",dragHandleClassName:"live-floating-drag-handle"},t.createElement("div",{className:"flex flex-col w-full h-full",style:{borderRadius:8,overflow:"hidden",boxShadow:"0 4px 24px rgba(0,0,0,0.4)"}},t.createElement("div",{className:"live-floating-drag-handle flex items-center justify-between",style:{height:28,minHeight:28,background:"#111",cursor:"grab",padding:"0 8px",userSelect:"none"}},t.createElement(Or,{size:16,color:"#888"}),t.createElement("button",{className:"cursor-pointer",style:{color:"#ccc",lineHeight:0},onClick:()=>i(!0),"aria-label":"Close"},t.createElement(zr,{size:16}))),t.createElement("iframe",{src:`${s}/live/${e}`,style:{flex:1,border:0,display:"block",minHeight:0},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade"})))},tw=({eventId:e})=>e?t.createElement(Sr.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:99999}},t.createElement(fo,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(ew,{eventId:e}))):null;export{Ed as CollectionShowcase,Eu as FloatingPlayer,tw as LiveFloatingPlayer,JE as LiveWidget,bo as PreviewPlayer,yo as ShoppingPlayer,Ot as ViewPlayer,vd as WidgetPlayer,mt as configure};
|