@kinxcdn/commerce-player 1.6.4-alpha.4 → 1.6.4

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/esm/index.js CHANGED
@@ -24,7 +24,7 @@ var Ft={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24
24
24
  *
25
25
  * This source code is licensed under the ISC license.
26
26
  * See the LICENSE file in the root directory of this source tree.
27
- */function or(t,r=[]){let i=[];const n=()=>{const r=i.map(t=>e.createContext(t));return function(i){const n=i?.[t]||r;return e.useMemo(()=>({[`__scope${t}`]:{...i,[t]:n}}),[i,n])}};return n.scopeName=t,[function(r,n){const s=e.createContext(n),a=i.length;i=[...i,n];const o=r=>{const{scope:i,children:n,...o}=r,l=i?.[t]?.[a]||s,d=e.useMemo(()=>o,Object.values(o));return p(l.Provider,{value:d,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,d=e.useContext(l);if(d)return d;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},lr(n,...r)]}function lr(...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 n=i.reduce((e,{useScope:r,scopeName:i})=>({...e,...r(t)[`__scope${i}`]}),{});return e.useMemo(()=>({[`__scope${r.scopeName}`]:n}),[n])}};return i.scopeName=r.scopeName,i}function dr(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function cr(...e){return t=>{let r=!1;const i=e.map(e=>{const i=dr(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():dr(e[t],null)}}}}function ur(...t){return e.useCallback(cr(...t),t)}var hr=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(mr);if(a){const t=a.props.children,i=s.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return p(fr,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return p(fr,{...n,ref:r,children:i})});hr.displayName="Slot";var fr=e.forwardRef((t,r)=>{const{children:i,...n}=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),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{s(...e),n(...e)}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?cr(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});fr.displayName="SlotClone";var pr=({children:e})=>p(m,{children:e});function mr(t){return e.isValidElement(t)&&t.type===pr}function gr(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function vr(...e){return t=>{let r=!1;const i=e.map(e=>{const i=gr(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():gr(e[t],null)}}}}function yr(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function br(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}function Er({prop:t,defaultProp:r,onChange:i=()=>{}}){const[n,s]=function({defaultProp:t,onChange:r}){const i=e.useState(t),[n]=i,s=e.useRef(n),a=br(r);return e.useEffect(()=>{s.current!==n&&(a(n),s.current=n)},[n,s,a]),i}({defaultProp:r,onChange:i}),a=void 0!==t,o=a?t:n,l=br(i);return[o,e.useCallback(e=>{if(a){const r="function"==typeof e?e(t):e;r!==t&&l(r)}else s(e)},[a,t,s,l])]}var wr=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(xr);if(a){const t=a.props.children,i=s.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return p(Sr,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return p(Sr,{...n,ref:r,children:i})});wr.displayName="Slot";var Sr=e.forwardRef((t,r)=>{const{children:i,...n}=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),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{s(...e),n(...e)}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?vr(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});Sr.displayName="SlotClone";var Tr=({children:e})=>p(m,{children:e});function xr(t){return e.isValidElement(t)&&t.type===Tr}var Ar=["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,...n}=e,s=i?wr:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),p(s,{...n,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{}),kr=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{};function Lr(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ir(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Lr(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():Lr(e[t],null)}}}}function Rr(...t){return e.useCallback(Ir(...t),t)}var Pr=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(_r);if(a){const t=a.props.children,i=s.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return p(Dr,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return p(Dr,{...n,ref:r,children:i})});Pr.displayName="Slot";var Dr=e.forwardRef((t,r)=>{const{children:i,...n}=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),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{s(...e),n(...e)}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?Ir(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});Dr.displayName="SlotClone";var Cr=({children:e})=>p(m,{children:e});function _r(t){return e.isValidElement(t)&&t.type===Cr}var Or=["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,...n}=e,s=i?Pr:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),p(s,{...n,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{});var Mr=t=>{const{present:r,children:i}=t,n=function(t){const[r,i]=e.useState(),n=e.useRef({}),s=e.useRef(t),a=e.useRef("none"),o=t?"mounted":"unmounted",[l,d]=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=Nr(n.current);a.current="mounted"===l?e:"none"},[l]),kr(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=Nr(e);if(t)d("MOUNT");else if("none"===n||"none"===e?.display)d("UNMOUNT");else{d(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,d]),kr(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=Nr(n.current).includes(i.animationName);if(i.target===r&&a&&(d("ANIMATION_END"),!s.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=Nr(n.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)}}d("ANIMATION_END")},[r,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{e&&(n.current=getComputedStyle(e)),i(e)},[])}}(r),s="function"==typeof i?i({present:n.isPresent}):e.Children.only(i),a=Rr(n.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}(s));return"function"==typeof i||n.isPresent?e.cloneElement(s,{ref:a}):null};function Nr(e){return e?.animationName||"none"}Mr.displayName="Presence";var Fr=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{},$r=e["useId".toString()]||(()=>{}),Br=0;function Ur(t){const[r,i]=e.useState($r());return Fr(()=>{i(e=>e??String(Br++))},[t]),r?`radix-${r}`:""}var zr="Collapsible",[Gr,jr]=or(zr),[Hr,Vr]=Gr(zr),Wr=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,open:n,defaultOpen:s,disabled:a,onOpenChange:o,...l}=t,[d=!1,c]=Er({prop:n,defaultProp:s,onChange:o});return p(Hr,{scope:i,disabled:a,contentId:Ur(),open:d,onOpenToggle:e.useCallback(()=>c(e=>!e),[c]),children:p(Or.div,{"data-state":Zr(d),"data-disabled":a?"":void 0,...l,ref:r})})});Wr.displayName=zr;var Yr="CollapsibleTrigger",Kr=e.forwardRef((e,t)=>{const{__scopeCollapsible:r,...i}=e,n=Vr(Yr,r);return p(Or.button,{type:"button","aria-controls":n.contentId,"aria-expanded":n.open||!1,"data-state":Zr(n.open),"data-disabled":n.disabled?"":void 0,disabled:n.disabled,...i,ref:t,onClick:yr(e.onClick,n.onOpenToggle)})});Kr.displayName=Yr;var qr="CollapsibleContent",Xr=e.forwardRef((e,t)=>{const{forceMount:r,...i}=e,n=Vr(qr,e.__scopeCollapsible);return p(Mr,{present:r||n.open,children:({present:e})=>p(Qr,{...i,ref:t,present:e})})});Xr.displayName=qr;var Qr=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,present:n,children:s,...a}=t,o=Vr(qr,i),[l,d]=e.useState(n),c=e.useRef(null),u=Rr(r,c),h=e.useRef(0),f=h.current,m=e.useRef(0),g=m.current,v=o.open||l,y=e.useRef(v),b=e.useRef(void 0);return e.useEffect(()=>{const e=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(e)},[]),kr(()=>{const e=c.current;if(e){b.current=b.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,m.current=t.width,y.current||(e.style.transitionDuration=b.current.transitionDuration,e.style.animationName=b.current.animationName),d(n)}},[o.open,n]),p(Or.div,{"data-state":Zr(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!v,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...t.style},children:v&&s})});function Zr(e){return e?"open":"closed"}var Jr=Wr,ei=Kr,ti=Xr,ri=e.createContext(void 0);var ii="Accordion",ni=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[si,ai,oi]=function(e){const r=e+"CollectionProvider",[i,n]=or(r),[s,a]=i(r,{collectionRef:{current:null},itemMap:new Map}),o=e=>{const{scope:r,children:i}=e,n=t.useRef(null),a=t.useRef(new Map).current;return p(s,{scope:r,itemMap:a,collectionRef:n,children:i})};o.displayName=r;const l=e+"CollectionSlot",d=t.forwardRef((e,t)=>{const{scope:r,children:i}=e,n=ur(t,a(l,r).collectionRef);return p(hr,{ref:n,children:i})});d.displayName=l;const c=e+"CollectionItemSlot",u="data-radix-collection-item",h=t.forwardRef((e,r)=>{const{scope:i,children:n,...s}=e,o=t.useRef(null),l=ur(r,o),d=a(c,i);return t.useEffect(()=>(d.itemMap.set(o,{ref:o,...s}),()=>{d.itemMap.delete(o)})),p(hr,{[u]:"",ref:l,children:n})});return h.displayName=c,[{Provider:o,Slot:d,ItemSlot:h},function(r){const i=a(e+"CollectionConsumer",r),n=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 n},n]}(ii),[li,di]=or(ii,[oi,jr]),ci=jr(),ui=t.forwardRef((e,t)=>{const{type:r,...i}=e,n=i,s=i;return p(si.Provider,{scope:e.__scopeAccordion,children:"multiple"===r?p(vi,{...s,ref:t}):p(gi,{...n,ref:t})})});ui.displayName=ii;var[hi,fi]=li(ii),[pi,mi]=li(ii,{collapsible:!1}),gi=t.forwardRef((e,r)=>{const{value:i,defaultValue:n,onValueChange:s=()=>{},collapsible:a=!1,...o}=e,[l,d]=Er({prop:i,defaultProp:n,onChange:s});return p(hi,{scope:e.__scopeAccordion,value:l?[l]:[],onItemOpen:d,onItemClose:t.useCallback(()=>a&&d(""),[a,d]),children:p(pi,{scope:e.__scopeAccordion,collapsible:a,children:p(Ei,{...o,ref:r})})})}),vi=t.forwardRef((e,r)=>{const{value:i,defaultValue:n,onValueChange:s=()=>{},...a}=e,[o=[],l]=Er({prop:i,defaultProp:n,onChange:s}),d=t.useCallback(e=>l((t=[])=>[...t,e]),[l]),c=t.useCallback(e=>l((t=[])=>t.filter(t=>t!==e)),[l]);return p(hi,{scope:e.__scopeAccordion,value:o,onItemOpen:d,onItemClose:c,children:p(pi,{scope:e.__scopeAccordion,collapsible:!0,children:p(Ei,{...a,ref:r})})})}),[yi,bi]=li(ii),Ei=t.forwardRef((r,i)=>{const{__scopeAccordion:n,disabled:s,dir:a,orientation:o="vertical",...l}=r,d=function(...t){return e.useCallback(vr(...t),t)}(t.useRef(null),i),c=ai(n),u="ltr"===function(t){const r=e.useContext(ri);return t||r||"ltr"}(a),h=yr(r.onKeyDown,e=>{if(!ni.includes(e.key))return;const t=e.target,r=c().filter(e=>!e.ref.current?.disabled),i=r.findIndex(e=>e.ref.current===t),n=r.length;if(-1===i)return;e.preventDefault();let s=i;const a=n-1,l=()=>{s=i+1,s>a&&(s=0)},d=()=>{s=i-1,s<0&&(s=a)};switch(e.key){case"Home":s=0;break;case"End":s=a;break;case"ArrowRight":"horizontal"===o&&(u?l():d());break;case"ArrowDown":"vertical"===o&&l();break;case"ArrowLeft":"horizontal"===o&&(u?d():l());break;case"ArrowUp":"vertical"===o&&d()}const h=s%n;r[h].ref.current?.focus()});return p(yi,{scope:n,disabled:s,direction:a,orientation:o,children:p(si.Slot,{scope:n,children:p(Ar.div,{...l,"data-orientation":o,ref:d,onKeyDown:s?void 0:h})})})}),wi="AccordionItem",[Si,Ti]=li(wi),xi=t.forwardRef((e,t)=>{const{__scopeAccordion:r,value:i,...n}=e,s=bi(wi,r),a=fi(wi,r),o=ci(r),l=Ur(),d=i&&a.value.includes(i)||!1,c=s.disabled||e.disabled;return p(Si,{scope:r,open:d,disabled:c,triggerId:l,children:p(Jr,{"data-orientation":s.orientation,"data-state":Di(d),...o,...n,ref:t,disabled:c,open:d,onOpenChange:e=>{e?a.onItemOpen(i):a.onItemClose(i)}})})});xi.displayName=wi;var Ai="AccordionHeader",ki=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=bi(ii,r),s=Ti(Ai,r);return p(Ar.h3,{"data-orientation":n.orientation,"data-state":Di(s.open),"data-disabled":s.disabled?"":void 0,...i,ref:t})});ki.displayName=Ai;var Li="AccordionTrigger",Ii=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=bi(ii,r),s=Ti(Li,r),a=mi(Li,r),o=ci(r);return p(si.ItemSlot,{scope:r,children:p(ei,{"aria-disabled":s.open&&!a.collapsible||void 0,"data-orientation":n.orientation,id:s.triggerId,...o,...i,ref:t})})});Ii.displayName=Li;var Ri="AccordionContent",Pi=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=bi(ii,r),s=Ti(Ri,r),a=ci(r);return p(ti,{role:"region","aria-labelledby":s.triggerId,"data-orientation":n.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 Di(e){return e?"open":"closed"}Pi.displayName=Ri;var Ci=ui,_i=xi,Oi=ki,Mi=Ii,Ni=Pi;function Fi(t){var r=T(t,[]);return e.createElement(Ci,Object.assign({"data-slot":"accordion"},r))}function $i(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(_i,Object.assign({"data-slot":"accordion-item",className:wt("border-b last:border-b-0",r)},i))}function Bi(t){var{className:r,children:i}=t,n=T(t,["className","children"]);return e.createElement(Oi,{className:"flex"},e.createElement(Mi,Object.assign({"data-slot":"accordion-trigger",className:wt("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)},n),i,e.createElement(Ut,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"})))}function Ui(t){var{className:r,children:i}=t,n=T(t,["className","children"]);return e.createElement(Ni,Object.assign({"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"},n),e.createElement("div",{className:wt("pt-0 pb-4",r)},i))}const zi=({title:e,content:r})=>t.createElement(Fi,{style:{borderRadius:"0.625rem"},type:"single",collapsible:!0,className:"bg-white px-4",defaultValue:"item"},t.createElement($i,{value:"item"},t.createElement(Bi,{className:""},e),t.createElement(Ui,{className:"text-gray-700"},r))),Gi=({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"},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(Qt,null)))),ji=e=>{const{playerSettings:r,shortform:{description:i,productsInfo:n,logo:s,brand:a,title:o},player:l}=e;return t.createElement("div",{className:"w-full h-full bg-[#f4f4f4] overflow-scroll"},t.createElement(Gi,{logo:s}),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(Zt,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(nr,{rounded:!0}),t.createElement(sr,{rounded:!0}),t.createElement(ar,{rounded:!0})))),t.createElement("div",{className:"flex flex-col gap-4 max-w-[40%]"},i&&t.createElement(zi,{title:"숏클립 안내",content:t.createElement("p",{className:"font-medium"},i)}),t.createElement(zi,{title:"상품 목록",content:t.createElement(t.Fragment,null,t.createElement("div",{className:"max-h-[300px] overflow-y-auto font-medium"},n.map((e,r)=>t.createElement(t.Fragment,null,t.createElement(tr,{product:e}),r!==n.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==n?void 0:n.length)},"상품 전체 보기"))}),r.comment&&t.createElement(zi,{title:"댓글",content:t.createElement(rr,null)}))))};function Hi(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function Vi(e,t){void 0===e&&(e={}),void 0===t&&(t={}),Object.keys(t).forEach(r=>{void 0===e[r]?e[r]=t[r]:Hi(t[r])&&Hi(e[r])&&Object.keys(t[r]).length>0&&Vi(e[r],t[r])})}const Wi={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 Yi(){const e="undefined"!=typeof document?document:{};return Vi(e,Wi),e}const Ki={document:Wi,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 qi(){const e="undefined"!=typeof window?window:{};return Vi(e,Ki),e}function Xi(e,t){return void 0===t&&(t=0),setTimeout(e,t)}function Qi(){return Date.now()}function Zi(e,t){void 0===t&&(t="x");const r=qi();let i,n,s;const a=function(e){const t=qi();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?(n=a.transform||a.webkitTransform,n.split(",").length>6&&(n=n.split(", ").map(e=>e.replace(",",".")).join(", ")),s=new r.WebKitCSSMatrix("none"===n?"":n)):(s=a.MozTransform||a.OTransform||a.MsTransform||a.msTransform||a.transform||a.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),i=s.toString().split(",")),"x"===t&&(n=r.WebKitCSSMatrix?s.m41:16===i.length?parseFloat(i[12]):parseFloat(i[4])),"y"===t&&(n=r.WebKitCSSMatrix?s.m42:16===i.length?parseFloat(i[13]):parseFloat(i[5])),n||0}function Ji(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function en(e){return"undefined"!=typeof window&&void 0!==window.HTMLElement?e instanceof HTMLElement:e&&(1===e.nodeType||11===e.nodeType)}function tn(){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&&!en(i)){const r=Object.keys(Object(i)).filter(e=>t.indexOf(e)<0);for(let t=0,n=r.length;t<n;t+=1){const n=r[t],s=Object.getOwnPropertyDescriptor(i,n);void 0!==s&&s.enumerable&&(Ji(e[n])&&Ji(i[n])?i[n].__swiper__?e[n]=i[n]:tn(e[n],i[n]):!Ji(e[n])&&Ji(i[n])?(e[n]={},i[n].__swiper__?e[n]=i[n]:tn(e[n],i[n])):e[n]=i[n])}}}return e}function rn(e,t,r){e.style.setProperty(t,r)}function nn(e){let{swiper:t,targetPosition:r,side:i}=e;const n=qi(),s=-t.translate;let a,o=null;const l=t.params.speed;t.wrapperEl.style.scrollSnapType="none",n.cancelAnimationFrame(t.cssModeFrameID);const d=r>s?"next":"prev",c=(e,t)=>"next"===d&&e>=t||"prev"===d&&e<=t,u=()=>{a=(new Date).getTime(),null===o&&(o=a);const e=Math.max(Math.min((a-o)/l,1),0),d=.5-Math.cos(e*Math.PI)/2;let h=s+d*(r-s);if(c(h,r)&&(h=r),t.wrapperEl.scrollTo({[i]:h}),c(h,r))return t.wrapperEl.style.overflow="hidden",t.wrapperEl.style.scrollSnapType="",setTimeout(()=>{t.wrapperEl.style.overflow="",t.wrapperEl.scrollTo({[i]:h})}),void n.cancelAnimationFrame(t.cssModeFrameID);t.cssModeFrameID=n.requestAnimationFrame(u)};u()}function sn(e){return e.querySelector(".swiper-slide-transform")||e.shadowRoot&&e.shadowRoot.querySelector(".swiper-slide-transform")||e}function an(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 on(e){try{return void console.warn(e)}catch(e){}}function ln(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 dn(e,t){return qi().getComputedStyle(e,null).getPropertyValue(t)}function cn(e){let t,r=e;if(r){for(t=0;null!==(r=r.previousSibling);)1===r.nodeType&&(t+=1);return t}}function un(e,t,r){const i=qi();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 hn(e){return(Array.isArray(e)?e:[e]).filter(e=>!!e)}let fn,pn,mn;function gn(){return fn||(fn=function(){const e=qi(),t=Yi();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}()),fn}function vn(e){return void 0===e&&(e={}),pn||(pn=function(e){let{userAgent:t}=void 0===e?{}:e;const r=gn(),i=qi(),n=i.navigator.platform,s=t||i.navigator.userAgent,a={ios:!1,android:!1},o=i.screen.width,l=i.screen.height,d=s.match(/(Android);?[\s\/]+([\d.]+)?/);let c=s.match(/(iPad).*OS\s([\d_]+)/);const u=s.match(/(iPod)(.*OS\s([\d_]+))?/),h=!c&&s.match(/(iPhone\sOS|iOS)\s([\d_]+)/),f="Win32"===n;let p="MacIntel"===n;return!c&&p&&r.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${o}x${l}`)>=0&&(c=s.match(/(Version)\/([\d.]+)/),c||(c=[0,1,"13_0_0"]),p=!1),d&&!f&&(a.os="android",a.android=!0),(c||h||u)&&(a.os="ios",a.ios=!0),a}(e)),pn}function yn(){return mn||(mn=function(){const e=qi(),t=vn();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 n=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),s=i();return{isSafari:r||s,needPerspectiveFix:r,need3dFix:s||n&&t.ios,isWebView:n}}()),mn}var bn={on(e,t,r){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;const n=r?"unshift":"push";return e.split(" ").forEach(e=>{i.eventsListeners[e]||(i.eventsListeners[e]=[]),i.eventsListeners[e][n](t)}),i},once(e,t,r){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;function n(){i.off(e,n),n.__emitterProxy&&delete n.__emitterProxy;for(var r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];t.apply(i,s)}return n.__emitterProxy=t,i.on(e,n,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,n)=>{(i===t||i.__emitterProxy&&i.__emitterProxy===t)&&r.eventsListeners[e].splice(n,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 n=arguments.length,s=new Array(n),a=0;a<n;a++)s[a]=arguments[a];"string"==typeof s[0]||Array.isArray(s[0])?(t=s[0],r=s.slice(1,s.length),i=e):(t=s[0].events,r=s[0].data,i=s[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 En=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const wn=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const Sn=(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()}},Tn=(e,t)=>{if(!e.slides[t])return;const r=e.slides[t].querySelector('[loading="lazy"]');r&&r.removeAttribute("loading")},xn=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),n=e.activeIndex;if(e.params.grid&&e.params.grid.rows>1){const r=n,s=[r-t];return s.push(...Array.from({length:t}).map((e,t)=>r+i+t)),void e.slides.forEach((t,r)=>{s.includes(t.column)&&Tn(e,r)})}const s=n+i-1;if(e.params.rewind||e.params.loop)for(let i=n-t;i<=s+t;i+=1){const t=(i%r+r)%r;(t<n||t>s)&&Tn(e,t)}else for(let i=Math.max(n-t,0);i<=Math.min(s+t,r-1);i+=1)i!==n&&(i>s||i<n)&&Tn(e,i)};var An={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(dn(i,"padding-left")||0,10)-parseInt(dn(i,"padding-right")||0,10),r=r-parseInt(dn(i,"padding-top")||0,10)-parseInt(dn(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:n,size:s,rtlTranslate:a,wrongRTL:o}=e,l=e.virtual&&r.virtual.enabled,d=l?e.virtual.slides.length:e.slides.length,c=an(n,`.${e.params.slideClass}, swiper-slide`),u=l?e.virtual.slides.length:c.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===s)return;"string"==typeof b&&b.indexOf("%")>=0?b=parseFloat(b.replace("%",""))/100*s:"string"==typeof b&&(b=parseFloat(b)),e.virtualSize=-b,c.forEach(e=>{a?e.style.marginLeft="":e.style.marginRight="",e.style.marginBottom="",e.style.marginTop=""}),r.centeredSlides&&r.cssMode&&(rn(i,"--swiper-centered-offset-before",""),rn(i,"--swiper-centered-offset-after",""));const T=r.grid&&r.grid.rows>1&&e.grid;let x;T?e.grid.initSlides(c):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 n;if(x=0,c[i]&&(n=c[i]),T&&e.grid.updateSlide(i,n,c),!c[i]||"none"!==dn(n,"display")){if("auto"===r.slidesPerView){A&&(c[i].style[e.getDirectionLabel("width")]="");const s=getComputedStyle(n),a=n.style.transform,o=n.style.webkitTransform;if(a&&(n.style.transform="none"),o&&(n.style.webkitTransform="none"),r.roundLengths)x=e.isHorizontal()?un(n,"width"):un(n,"height");else{const e=t(s,"width"),r=t(s,"padding-left"),i=t(s,"padding-right"),a=t(s,"margin-left"),o=t(s,"margin-right"),l=s.getPropertyValue("box-sizing");if(l&&"border-box"===l)x=e+a+o;else{const{clientWidth:t,offsetWidth:s}=n;x=e+r+i+a+o+(s-t)}}a&&(n.style.transform=a),o&&(n.style.webkitTransform=o),r.roundLengths&&(x=Math.floor(x))}else x=(s-(r.slidesPerView-1)*b)/r.slidesPerView,r.roundLengths&&(x=Math.floor(x)),c[i]&&(c[i].style[e.getDirectionLabel("width")]=`${x}px`);c[i]&&(c[i].swiperSlideSize=x),p.push(x),r.centeredSlides?(E=E+x/2+w/2+b,0===w&&0!==i&&(E=E-s/2-b),0===i&&(E=E-s/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,s)+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 n=h[i];r.roundLengths&&(n=Math.floor(n)),h[i]<=e.virtualSize-s&&t.push(n)}h=t,Math.floor(e.virtualSize-s)-Math.floor(h[h.length-1])>1&&h.push(e.virtualSize-s)}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),n=t*r.slidesPerGroup;for(let e=0;e<i;e+=1)h.push(h[h.length-1]+n)}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");c.filter((e,t)=>!(r.cssMode&&!r.loop)||t!==c.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>s?e-s: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<s){const r=(s-e-t)/2;h.forEach((e,t)=>{h[t]=e-r}),f.forEach((e,t)=>{f[t]=e+r})}}if(Object.assign(e,{slides:c,snapGrid:h,slidesGrid:f,slidesSizesGrid:p}),r.centeredSlides&&r.cssMode&&!r.centeredSlidesBounds){rn(i,"--swiper-centered-offset-before",-h[0]+"px"),rn(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!==d&&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 n,s=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(n=0;n<Math.ceil(t.params.slidesPerView);n+=1){const e=t.activeIndex+n;if(e>t.slides.length&&!i)break;r.push(a(e))}else r.push(a(t.activeIndex));for(n=0;n<r.length;n+=1)if(void 0!==r[n]){const e=r[n].offsetHeight;s=e>s?e:s}(s||0===s)&&(t.wrapperEl.style.height=`${s}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:n,snapGrid:s}=t;if(0===i.length)return;void 0===i[0].swiperSlideOffset&&t.updateSlidesOffset();let a=-e;n&&(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 d=l.swiperSlideOffset;r.cssMode&&r.centeredSlides&&(d-=i[0].swiperSlideOffset);const c=(a+(r.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+o),u=(a-s[0]+(r.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+o),h=-(a-d),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)),En(l,m,r.slideVisibleClass),En(l,p,r.slideFullyVisibleClass),l.progress=n?-c:c,l.originalProgress=n?-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:n,isBeginning:s,isEnd:a,progressLoop:o}=t;const l=s,d=a;if(0===i)n=0,s=!0,a=!0;else{n=(e-t.minTranslate())/i;const r=Math.abs(e-t.minTranslate())<1,o=Math.abs(e-t.maxTranslate())<1;s=r||n<=0,a=o||n>=1,r&&(n=0),o&&(n=1)}if(r.loop){const r=t.getSlideIndexByData(0),i=t.getSlideIndexByData(t.slides.length-1),n=t.slidesGrid[r],s=t.slidesGrid[i],a=t.slidesGrid[t.slidesGrid.length-1],l=Math.abs(e);o=l>=n?(l-n)/a:(l+a-s)/a,o>1&&(o-=1)}Object.assign(t,{progress:n,progressLoop:o,isBeginning:s,isEnd:a}),(r.watchSlidesProgress||r.centeredSlides&&r.autoHeight)&&t.updateSlidesProgress(e),s&&!l&&t.emit("reachBeginning toEdge"),a&&!d&&t.emit("reachEnd toEdge"),(l&&!s||d&&!a)&&t.emit("fromEdge"),t.emit("progress",n)},updateSlidesClasses:function(){const e=this,{slides:t,params:r,slidesEl:i,activeIndex:n}=e,s=e.virtual&&r.virtual.enabled,a=e.grid&&r.grid&&r.grid.rows>1,o=e=>an(i,`.${r.slideClass}${e}, swiper-slide${e}`)[0];let l,d,c;if(s)if(r.loop){let t=n-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="${n}"]`);else a?(l=t.filter(e=>e.column===n)[0],c=t.filter(e=>e.column===n+1)[0],d=t.filter(e=>e.column===n-1)[0]):l=t[n];l&&(a||(c=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&&!c&&(c=t[0]),d=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===!d&&(d=t[t.length-1]))),t.forEach(e=>{wn(e,e===l,r.slideActiveClass),wn(e,e===c,r.slideNextClass),wn(e,e===d,r.slidePrevClass)}),e.emitSlidesClasses()},updateActiveIndex:function(e){const t=this,r=t.rtlTranslate?t.translate:-t.translate,{snapGrid:i,params:n,activeIndex:s,realIndex:a,snapIndex:o}=t;let l,d=e;const c=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===d&&(d=function(e){const{slidesGrid:t,params:r}=e,i=e.rtlTranslate?e.translate:-e.translate;let n;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?n=e:i>=t[e]&&i<t[e+1]&&(n=e+1):i>=t[e]&&(n=e);return r.normalizeSlideIndex&&(n<0||void 0===n)&&(n=0),n}(t)),i.indexOf(r)>=0)l=i.indexOf(r);else{const e=Math.min(n.slidesPerGroupSkip,d);l=e+Math.floor((d-e)/n.slidesPerGroup)}if(l>=i.length&&(l=i.length-1),d===s&&!t.params.loop)return void(l!==o&&(t.snapIndex=l,t.emit("snapIndexChange")));if(d===s&&t.params.loop&&t.virtual&&t.params.virtual.enabled)return void(t.realIndex=c(d));const u=t.grid&&n.grid&&n.grid.rows>1;let h;if(t.virtual&&n.virtual.enabled&&n.loop)h=c(d);else if(u){const e=t.slides.filter(e=>e.column===d)[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/n.grid.rows)}else if(t.slides[d]){const e=t.slides[d].getAttribute("data-swiper-slide-index");h=e?parseInt(e,10):d}else h=d;Object.assign(t,{previousSnapIndex:o,snapIndex:l,previousRealIndex:a,realIndex:h,previousIndex:s,activeIndex:d}),t.initialized&&xn(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 n=e.closest(`.${i.slideClass}, swiper-slide`);!n&&r.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach(e=>{!n&&e.matches&&e.matches(`.${i.slideClass}, swiper-slide`)&&(n=e)});let s,a=!1;if(n)for(let e=0;e<r.slides.length;e+=1)if(r.slides[e]===n){a=!0,s=e;break}if(!n||!a)return r.clickedSlide=void 0,void(r.clickedIndex=void 0);r.clickedSlide=n,r.virtual&&r.params.virtual.enabled?r.clickedIndex=parseInt(n.getAttribute("data-swiper-slide-index"),10):r.clickedIndex=s,i.slideToClickedSlide&&void 0!==r.clickedIndex&&r.clickedIndex!==r.activeIndex&&r.slideToClickedSlide()}};var kn={getTranslate:function(e){void 0===e&&(e=this.isHorizontal()?"x":"y");const{params:t,rtlTranslate:r,translate:i,wrapperEl:n}=this;if(t.virtualTranslate)return r?-i:i;if(t.cssMode)return i;let s=Zi(n,e);return s+=this.cssOverflowAdjustment(),r&&(s=-s),s||0},setTranslate:function(e,t){const r=this,{rtlTranslate:i,params:n,wrapperEl:s,progress:a}=r;let o,l=0,d=0;r.isHorizontal()?l=i?-e:e:d=e,n.roundLengths&&(l=Math.floor(l),d=Math.floor(d)),r.previousTranslate=r.translate,r.translate=r.isHorizontal()?l:d,n.cssMode?s[r.isHorizontal()?"scrollLeft":"scrollTop"]=r.isHorizontal()?-l:-d:n.virtualTranslate||(r.isHorizontal()?l-=r.cssOverflowAdjustment():d-=r.cssOverflowAdjustment(),s.style.transform=`translate3d(${l}px, ${d}px, 0px)`);const c=r.maxTranslate()-r.minTranslate();o=0===c?0:(e-r.minTranslate())/c,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,n){void 0===e&&(e=0),void 0===t&&(t=this.params.speed),void 0===r&&(r=!0),void 0===i&&(i=!0);const s=this,{params:a,wrapperEl:o}=s;if(s.animating&&a.preventInteractionOnTransition)return!1;const l=s.minTranslate(),d=s.maxTranslate();let c;if(c=i&&e>l?l:i&&e<d?d:e,s.updateProgress(c),a.cssMode){const e=s.isHorizontal();if(0===t)o[e?"scrollLeft":"scrollTop"]=-c;else{if(!s.support.smoothScroll)return nn({swiper:s,targetPosition:-c,side:e?"left":"top"}),!0;o.scrollTo({[e?"left":"top"]:-c,behavior:"smooth"})}return!0}return 0===t?(s.setTransition(0),s.setTranslate(c),r&&(s.emit("beforeTransitionStart",t,n),s.emit("transitionEnd"))):(s.setTransition(t),s.setTranslate(c),r&&(s.emit("beforeTransitionStart",t,n),s.emit("transitionStart")),s.animating||(s.animating=!0,s.onTranslateToWrapperTransitionEnd||(s.onTranslateToWrapperTransitionEnd=function(e){s&&!s.destroyed&&e.target===this&&(s.wrapperEl.removeEventListener("transitionend",s.onTranslateToWrapperTransitionEnd),s.onTranslateToWrapperTransitionEnd=null,delete s.onTranslateToWrapperTransitionEnd,s.animating=!1,r&&s.emit("transitionEnd"))}),s.wrapperEl.addEventListener("transitionend",s.onTranslateToWrapperTransitionEnd))),!0}};function Ln(e){let{swiper:t,runCallbacks:r,direction:i,step:n}=e;const{activeIndex:s,previousIndex:a}=t;let o=i;if(o||(o=s>a?"next":s<a?"prev":"reset"),t.emit(`transition${n}`),r&&s!==a){if("reset"===o)return void t.emit(`slideResetTransition${n}`);t.emit(`slideChangeTransition${n}`),"next"===o?t.emit(`slideNextTransition${n}`):t.emit(`slidePrevTransition${n}`)}}var In={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(),Ln({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),Ln({swiper:r,runCallbacks:e,direction:t,step:"End"}))}};var Rn={slideTo:function(e,t,r,i,n){void 0===e&&(e=0),void 0===r&&(r=!0),"string"==typeof e&&(e=parseInt(e,10));const s=this;let a=e;a<0&&(a=0);const{params:o,snapGrid:l,slidesGrid:d,previousIndex:c,activeIndex:u,rtlTranslate:h,wrapperEl:f,enabled:p}=s;if(!p&&!i&&!n||s.destroyed||s.animating&&o.preventInteractionOnTransition)return!1;void 0===t&&(t=s.params.speed);const m=Math.min(s.params.slidesPerGroupSkip,a);let g=m+Math.floor((a-m)/s.params.slidesPerGroup);g>=l.length&&(g=l.length-1);const v=-l[g];if(o.normalizeSlideIndex)for(let e=0;e<d.length;e+=1){const t=-Math.floor(100*v),r=Math.floor(100*d[e]),i=Math.floor(100*d[e+1]);void 0!==d[e+1]?t>=r&&t<i-(i-r)/2?a=e:t>=r&&t<i&&(a=e+1):t>=r&&(a=e)}if(s.initialized&&a!==u){if(!s.allowSlideNext&&(h?v>s.translate&&v>s.minTranslate():v<s.translate&&v<s.minTranslate()))return!1;if(!s.allowSlidePrev&&v>s.translate&&v>s.maxTranslate()&&(u||0)!==a)return!1}let y;a!==(c||0)&&r&&s.emit("beforeSlideChangeStart"),s.updateProgress(v),y=a>u?"next":a<u?"prev":"reset";const b=s.virtual&&s.params.virtual.enabled;if(!(b&&n)&&(h&&-v===s.translate||!h&&v===s.translate))return s.updateActiveIndex(a),o.autoHeight&&s.updateAutoHeight(),s.updateSlidesClasses(),"slide"!==o.effect&&s.setTranslate(v),"reset"!==y&&(s.transitionStart(r,y),s.transitionEnd(r,y)),!1;if(o.cssMode){const e=s.isHorizontal(),r=h?v:-v;if(0===t)b&&(s.wrapperEl.style.scrollSnapType="none",s._immediateVirtual=!0),b&&!s._cssModeVirtualInitialSet&&s.params.initialSlide>0?(s._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{f[e?"scrollLeft":"scrollTop"]=r})):f[e?"scrollLeft":"scrollTop"]=r,b&&requestAnimationFrame(()=>{s.wrapperEl.style.scrollSnapType="",s._immediateVirtual=!1});else{if(!s.support.smoothScroll)return nn({swiper:s,targetPosition:r,side:e?"left":"top"}),!0;f.scrollTo({[e?"left":"top"]:r,behavior:"smooth"})}return!0}return s.setTransition(t),s.setTranslate(v),s.updateActiveIndex(a),s.updateSlidesClasses(),s.emit("beforeTransitionStart",t,i),s.transitionStart(r,y),0===t?s.transitionEnd(r,y):s.animating||(s.animating=!0,s.onSlideToWrapperTransitionEnd||(s.onSlideToWrapperTransitionEnd=function(e){s&&!s.destroyed&&e.target===this&&(s.wrapperEl.removeEventListener("transitionend",s.onSlideToWrapperTransitionEnd),s.onSlideToWrapperTransitionEnd=null,delete s.onSlideToWrapperTransitionEnd,s.transitionEnd(r,y))}),s.wrapperEl.addEventListener("transitionend",s.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 n=this;if(n.destroyed)return;void 0===t&&(t=n.params.speed);const s=n.grid&&n.params.grid&&n.params.grid.rows>1;let a=e;if(n.params.loop)if(n.virtual&&n.params.virtual.enabled)a+=n.virtual.slidesBefore;else{let e;if(s){const t=a*n.params.grid.rows;e=n.slides.filter(e=>1*e.getAttribute("data-swiper-slide-index")===t)[0].column}else e=n.getSlideIndexByData(a);const t=s?Math.ceil(n.slides.length/n.params.grid.rows):n.slides.length,{centeredSlides:r}=n.params;let o=n.params.slidesPerView;"auto"===o?o=n.slidesPerViewDynamic():(o=Math.ceil(parseFloat(n.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"!==n.params.slidesPerView&&!s&&(l=!1),l){const i=r?e<n.activeIndex?"prev":"next":e-n.activeIndex-1<n.params.slidesPerView?"next":"prev";n.loopFix({direction:i,slideTo:!0,activeSlideIndex:"next"===i?e+1:e-t+1,slideRealIndex:"next"===i?n.realIndex:void 0})}if(s){const e=a*n.params.grid.rows;a=n.slides.filter(t=>1*t.getAttribute("data-swiper-slide-index")===e)[0].column}else a=n.getSlideIndexByData(a)}return requestAnimationFrame(()=>{n.slideTo(a,t,r,i)}),n},slideNext:function(e,t,r){void 0===t&&(t=!0);const i=this,{enabled:n,params:s,animating:a}=i;if(!n||i.destroyed)return i;void 0===e&&(e=i.params.speed);let o=s.slidesPerGroup;"auto"===s.slidesPerView&&1===s.slidesPerGroup&&s.slidesPerGroupAuto&&(o=Math.max(i.slidesPerViewDynamic("current",!0),1));const l=i.activeIndex<s.slidesPerGroupSkip?1:o,d=i.virtual&&s.virtual.enabled;if(s.loop){if(a&&!d&&s.loopPreventsSliding)return!1;if(i.loopFix({direction:"next"}),i._clientLeft=i.wrapperEl.clientLeft,i.activeIndex===i.slides.length-1&&s.cssMode)return requestAnimationFrame(()=>{i.slideTo(i.activeIndex+l,e,t,r)}),!0}return s.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:n,snapGrid:s,slidesGrid:a,rtlTranslate:o,enabled:l,animating:d}=i;if(!l||i.destroyed)return i;void 0===e&&(e=i.params.speed);const c=i.virtual&&n.virtual.enabled;if(n.loop){if(d&&!c&&n.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=s.map(e=>u(e));let p=s[f.indexOf(h)-1];if(void 0===p&&n.cssMode){let e;s.forEach((t,r)=>{h>=t&&(e=r)}),void 0!==e&&(p=s[e>0?e-1:e])}let m=0;if(void 0!==p&&(m=a.indexOf(p),m<0&&(m=i.activeIndex-1),"auto"===n.slidesPerView&&1===n.slidesPerGroup&&n.slidesPerGroupAuto&&(m=m-i.slidesPerViewDynamic("previous",!0)+1,m=Math.max(m,0))),n.rewind&&i.isBeginning){const n=i.params.virtual&&i.params.virtual.enabled&&i.virtual?i.virtual.slides.length-1:i.slides.length-1;return i.slideTo(n,e,t,r)}return n.loop&&0===i.activeIndex&&n.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 n=this;if(n.destroyed)return;void 0===e&&(e=n.params.speed);let s=n.activeIndex;const a=Math.min(n.params.slidesPerGroupSkip,s),o=a+Math.floor((s-a)/n.params.slidesPerGroup),l=n.rtlTranslate?n.translate:-n.translate;if(l>=n.snapGrid[o]){const e=n.snapGrid[o];l-e>(n.snapGrid[o+1]-e)*i&&(s+=n.params.slidesPerGroup)}else{const e=n.snapGrid[o-1];l-e<=(n.snapGrid[o]-e)*i&&(s-=n.params.slidesPerGroup)}return s=Math.max(s,0),s=Math.min(s,n.slidesGrid.length-1),n.slideTo(s,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 n,s=e.clickedIndex;const a=e.isElement?"swiper-slide":`.${t.slideClass}`;if(t.loop){if(e.animating)return;n=parseInt(e.clickedSlide.getAttribute("data-swiper-slide-index"),10),t.centeredSlides?s<e.loopedSlides-i/2||s>e.slides.length-e.loopedSlides+i/2?(e.loopFix(),s=e.getSlideIndex(an(r,`${a}[data-swiper-slide-index="${n}"]`)[0]),Xi(()=>{e.slideTo(s)})):e.slideTo(s):s>e.slides.length-i?(e.loopFix(),s=e.getSlideIndex(an(r,`${a}[data-swiper-slide-index="${n}"]`)[0]),Xi(()=>{e.slideTo(s)})):e.slideTo(s)}else e.slideTo(s)}};var Pn={loopCreate:function(e){const t=this,{params:r,slidesEl:i}=t;if(!r.loop||t.virtual&&t.params.virtual.enabled)return;const n=()=>{an(i,`.${r.slideClass}, swiper-slide`).forEach((e,t)=>{e.setAttribute("data-swiper-slide-index",t)})},s=t.grid&&r.grid&&r.grid.rows>1,a=r.slidesPerGroup*(s?r.grid.rows:1),o=t.slides.length%a!==0,l=s&&t.slides.length%r.grid.rows!==0,d=e=>{for(let i=0;i<e;i+=1){const e=t.isElement?ln("swiper-slide",[r.slideBlankClass]):ln("div",[r.slideClass,r.slideBlankClass]);t.slidesEl.append(e)}};if(o){if(r.loopAddBlankSlides){d(a-t.slides.length%a),t.recalcSlides(),t.updateSlides()}else on("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)");n()}else if(l){if(r.loopAddBlankSlides){d(r.grid.rows-t.slides.length%r.grid.rows),t.recalcSlides(),t.updateSlides()}else on("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)");n()}else n();t.loopFix({slideRealIndex:e,direction:r.centeredSlides?void 0:"next"})},loopFix:function(e){let{slideRealIndex:t,slideTo:r=!0,direction:i,setTranslate:n,activeSlideIndex:s,byController:a,byMousewheel:o}=void 0===e?{}:e;const l=this;if(!l.params.loop)return;l.emit("beforeLoopFix");const{slides:d,allowSlidePrev:c,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=c,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;d.length<m+v?on("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&&on("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");const b=[],E=[];let w=l.activeIndex;void 0===s?s=l.getSlideIndex(d.filter(e=>e.classList.contains(f.slideActiveClass))[0]):w=s;const S="next"===i||!i,T="prev"===i||!i;let x=0,A=0;const k=y?Math.ceil(d.length/f.grid.rows):d.length,L=(y?d[s].column:s)+(p&&void 0===n?-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=d.length-1;t>=0;t-=1)d[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?d.forEach((e,r)=>{e.column===t&&E.push(r)}):E.push(t)}}if(l.__preventObserver__=!0,requestAnimationFrame(()=>{l.__preventObserver__=!1}),T&&b.forEach(e=>{d[e].swiperLoopMoveDOM=!0,h.prepend(d[e]),d[e].swiperLoopMoveDOM=!1}),S&&E.forEach(e=>{d[e].swiperLoopMoveDOM=!0,h.append(d[e]),d[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),n&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-t,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-t))}else if(n){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),n&&(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=c,l.allowSlideNext=u,l.controller&&l.controller.control&&!a){const e={slideRealIndex:t,direction:i,setTranslate:n,activeSlideIndex:s,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 Dn(e,t,r){const i=qi(),{params:n}=e,s=n.edgeSwipeDetection,a=n.edgeSwipeThreshold;return!s||!(r<=a||r>=i.innerWidth-a)||"prevent"===s&&(t.preventDefault(),!0)}function Cn(e){const t=this,r=Yi();let i=e;i.originalEvent&&(i=i.originalEvent);const n=t.touchEventsData;if("pointerdown"===i.type){if(null!==n.pointerId&&n.pointerId!==i.pointerId)return;n.pointerId=i.pointerId}else"touchstart"===i.type&&1===i.targetTouches.length&&(n.touchId=i.targetTouches[0].identifier);if("touchstart"===i.type)return void Dn(t,i,i.targetTouches[0].pageX);const{params:s,touches:a,enabled:o}=t;if(!o)return;if(!s.simulateTouch&&"mouse"===i.pointerType)return;if(t.animating&&s.preventInteractionOnTransition)return;!t.animating&&s.cssMode&&s.loop&&t.loopFix();let l=i.target;if("wrapper"===s.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(n.isTouched&&n.isMoved)return;const d=!!s.noSwipingClass&&""!==s.noSwipingClass,c=i.composedPath?i.composedPath():i.path;d&&i.target&&i.target.shadowRoot&&c&&(l=c[0]);const u=s.noSwipingSelector?s.noSwipingSelector:`.${s.noSwipingClass}`,h=!(!i.target||!i.target.shadowRoot);if(s.noSwiping&&(h?function(e,t){return void 0===t&&(t=this),function t(r){if(!r||r===Yi()||r===qi())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(s.swipeHandler&&!l.closest(s.swipeHandler))return;a.currentX=i.pageX,a.currentY=i.pageY;const f=a.currentX,p=a.currentY;if(!Dn(t,i,f))return;Object.assign(n,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),a.startX=f,a.startY=p,n.touchStartTime=Qi(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,s.threshold>0&&(n.allowThresholdMove=!1);let m=!0;l.matches(n.focusableElements)&&(m=!1,"SELECT"===l.nodeName&&(n.isTouched=!1)),r.activeElement&&r.activeElement.matches(n.focusableElements)&&r.activeElement!==l&&("mouse"===i.pointerType||"mouse"!==i.pointerType&&!l.matches(n.focusableElements))&&r.activeElement.blur();const g=m&&t.allowTouchMove&&s.touchStartPreventDefault;!s.touchStartForcePreventDefault&&!g||l.isContentEditable||i.preventDefault(),s.freeMode&&s.freeMode.enabled&&t.freeMode&&t.animating&&!s.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",i)}function _n(e){const t=Yi(),r=this,i=r.touchEventsData,{params:n,touches:s,rtlTranslate:a,enabled:o}=r;if(!o)return;if(!n.simulateTouch&&"mouse"===e.pointerType)return;let l,d=e;if(d.originalEvent&&(d=d.originalEvent),"pointermove"===d.type){if(null!==i.touchId)return;if(d.pointerId!==i.pointerId)return}if("touchmove"===d.type){if(l=[...d.changedTouches].filter(e=>e.identifier===i.touchId)[0],!l||l.identifier!==i.touchId)return}else l=d;if(!i.isTouched)return void(i.startMoving&&i.isScrolling&&r.emit("touchMoveOpposite",d));const c=l.pageX,u=l.pageY;if(d.preventedByNestedSwiper)return s.startX=c,void(s.startY=u);if(!r.allowTouchMove)return d.target.matches(i.focusableElements)||(r.allowClick=!1),void(i.isTouched&&(Object.assign(s,{startX:c,startY:u,currentX:c,currentY:u}),i.touchStartTime=Qi()));if(n.touchReleaseOnEdges&&!n.loop)if(r.isVertical()){if(u<s.startY&&r.translate<=r.maxTranslate()||u>s.startY&&r.translate>=r.minTranslate())return i.isTouched=!1,void(i.isMoved=!1)}else if(c<s.startX&&r.translate<=r.maxTranslate()||c>s.startX&&r.translate>=r.minTranslate())return;if(t.activeElement&&t.activeElement.matches(i.focusableElements)&&t.activeElement!==d.target&&"mouse"!==d.pointerType&&t.activeElement.blur(),t.activeElement&&d.target===t.activeElement&&d.target.matches(i.focusableElements))return i.isMoved=!0,void(r.allowClick=!1);i.allowTouchCallbacks&&r.emit("touchMove",d),s.previousX=s.currentX,s.previousY=s.currentY,s.currentX=c,s.currentY=u;const h=s.currentX-s.startX,f=s.currentY-s.startY;if(r.params.threshold&&Math.sqrt(h**2+f**2)<r.params.threshold)return;if(void 0===i.isScrolling){let e;r.isHorizontal()&&s.currentY===s.startY||r.isVertical()&&s.currentX===s.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>n.touchAngle:90-e>n.touchAngle)}if(i.isScrolling&&r.emit("touchMoveOpposite",d),void 0===i.startMoving&&(s.currentX===s.startX&&s.currentY===s.startY||(i.startMoving=!0)),i.isScrolling||"touchmove"===d.type&&i.preventTouchMoveFromPointerMove)return void(i.isTouched=!1);if(!i.startMoving)return;r.allowClick=!1,!n.cssMode&&d.cancelable&&d.preventDefault(),n.touchMoveStopPropagation&&!n.nested&&d.stopPropagation();let p=r.isHorizontal()?h:f,m=r.isHorizontal()?s.currentX-s.previousX:s.currentY-s.previousY;n.oneWayMovement&&(p=Math.abs(p)*(a?1:-1),m=Math.abs(m)*(a?1:-1)),s.diff=p,p*=n.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&&!n.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,!n.grabCursor||!0!==r.allowSlideNext&&!0!==r.allowSlidePrev||r.setGrabCursor(!0),r.emit("sliderFirstMove",d)}if((new Date).getTime(),i.isMoved&&i.allowThresholdMove&&g!==r.touchesDirection&&v&&y&&Math.abs(p)>=1)return Object.assign(s,{startX:c,startY:u,currentX:c,currentY:u,startTranslate:i.currentTranslate}),i.loopSwapReset=!0,void(i.startTranslate=i.currentTranslate);r.emit("sliderMove",d),i.isMoved=!0,i.currentTranslate=p+i.startTranslate;let b=!0,E=n.resistanceRatio;if(n.touchReleaseOnEdges&&(E=0),p>0?(v&&y&&i.allowThresholdMove&&i.currentTranslate>(n.centeredSlides?r.minTranslate()-r.slidesSizesGrid[r.activeIndex+1]-("auto"!==n.slidesPerView&&r.slides.length-n.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,n.resistance&&(i.currentTranslate=r.minTranslate()-1+(-r.minTranslate()+i.startTranslate+p)**E))):p<0&&(v&&y&&i.allowThresholdMove&&i.currentTranslate<(n.centeredSlides?r.maxTranslate()+r.slidesSizesGrid[r.slidesSizesGrid.length-1]+r.params.spaceBetween+("auto"!==n.slidesPerView&&r.slides.length-n.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"===n.slidesPerView?r.slidesPerViewDynamic():Math.ceil(parseFloat(n.slidesPerView,10)))}),i.currentTranslate<r.maxTranslate()&&(b=!1,n.resistance&&(i.currentTranslate=r.maxTranslate()+1-(r.maxTranslate()-i.startTranslate-p)**E))),b&&(d.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),n.threshold>0){if(!(Math.abs(p)>n.threshold||i.allowThresholdMove))return void(i.currentTranslate=i.startTranslate);if(!i.allowThresholdMove)return i.allowThresholdMove=!0,s.startX=s.currentX,s.startY=s.currentY,i.currentTranslate=i.startTranslate,void(s.diff=r.isHorizontal()?s.currentX-s.startX:s.currentY-s.startY)}n.followFinger&&!n.cssMode&&((n.freeMode&&n.freeMode.enabled&&r.freeMode||n.watchSlidesProgress)&&(r.updateActiveIndex(),r.updateSlidesClasses()),n.freeMode&&n.freeMode.enabled&&r.freeMode&&r.freeMode.onTouchMove(),r.updateProgress(i.currentTranslate),r.setTranslate(i.currentTranslate))}function On(e){const t=this,r=t.touchEventsData;let i,n=e;n.originalEvent&&(n=n.originalEvent);if("touchend"===n.type||"touchcancel"===n.type){if(i=[...n.changedTouches].filter(e=>e.identifier===r.touchId)[0],!i||i.identifier!==r.touchId)return}else{if(null!==r.touchId)return;if(n.pointerId!==r.pointerId)return;i=n}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(n.type)){if(!(["pointercancel","contextmenu"].includes(n.type)&&(t.browser.isSafari||t.browser.isWebView)))return}r.pointerId=null,r.touchId=null;const{params:s,touches:a,rtlTranslate:o,slidesGrid:l,enabled:d}=t;if(!d)return;if(!s.simulateTouch&&"mouse"===n.pointerType)return;if(r.allowTouchCallbacks&&t.emit("touchEnd",n),r.allowTouchCallbacks=!1,!r.isTouched)return r.isMoved&&s.grabCursor&&t.setGrabCursor(!1),r.isMoved=!1,void(r.startMoving=!1);s.grabCursor&&r.isMoved&&r.isTouched&&(!0===t.allowSlideNext||!0===t.allowSlidePrev)&&t.setGrabCursor(!1);const c=Qi(),u=c-r.touchStartTime;if(t.allowClick){const e=n.path||n.composedPath&&n.composedPath();t.updateClickedSlide(e&&e[0]||n.target,e),t.emit("tap click",n),u<300&&c-r.lastClickTime<300&&t.emit("doubleTap doubleClick",n)}if(r.lastClickTime=Qi(),Xi(()=>{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=s.followFinger?o?t.translate:-t.translate:-r.currentTranslate,s.cssMode)return;if(s.freeMode&&s.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<s.slidesPerGroupSkip?1:s.slidesPerGroup){const t=e<s.slidesPerGroupSkip-1?1:s.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;s.rewind&&(t.isBeginning?v=s.virtual&&s.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<s.slidesPerGroupSkip-1?1:s.slidesPerGroup;if(u>s.longSwipesMs){if(!s.longSwipes)return void t.slideTo(t.activeIndex);"next"===t.swipeDirection&&(y>=s.longSwipesRatio?t.slideTo(s.rewind&&t.isEnd?g:p+b):t.slideTo(p)),"prev"===t.swipeDirection&&(y>1-s.longSwipesRatio?t.slideTo(p+b):null!==v&&y<0&&Math.abs(y)>s.longSwipesRatio?t.slideTo(v):t.slideTo(p))}else{if(!s.shortSwipes)return void t.slideTo(t.activeIndex);t.navigation&&(n.target===t.navigation.nextEl||n.target===t.navigation.prevEl)?n.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 Mn(){const e=this,{params:t,el:r}=e;if(r&&0===r.offsetWidth)return;t.breakpoints&&e.setBreakpoint();const{allowSlideNext:i,allowSlidePrev:n,snapGrid:s}=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=n,e.allowSlideNext=i,e.params.watchOverflow&&s!==e.snapGrid&&e.checkOverflow()}function Nn(e){const t=this;t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function Fn(){const e=this,{wrapperEl:t,rtlTranslate:r,enabled:i}=e;if(!i)return;let n;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 s=e.maxTranslate()-e.minTranslate();n=0===s?0:(e.translate-e.minTranslate())/s,n!==e.progress&&e.updateProgress(r?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}function $n(e){const t=this;Sn(t,e.target),t.params.cssMode||"auto"!==t.params.slidesPerView&&!t.params.autoHeight||t.update()}function Bn(){const e=this;e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}const Un=(e,t)=>{const r=Yi(),{params:i,el:n,wrapperEl:s,device:a}=e,o=!!i.nested,l="on"===t?"addEventListener":"removeEventListener",d=t;n&&"string"!=typeof n&&(r[l]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:o}),n[l]("touchstart",e.onTouchStart,{passive:!1}),n[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)&&n[l]("click",e.onClick,!0),i.cssMode&&s[l]("scroll",e.onScroll),i.updateOnWindowResize?e[d](a.ios||a.android?"resize orientationchange observerUpdate":"resize observerUpdate",Mn,!0):e[d]("observerUpdate",Mn,!0),n[l]("load",e.onLoad,{capture:!0}))};const zn=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var Gn={setBreakpoint:function(){const e=this,{realIndex:t,initialized:r,params:i,el:n}=e,s=i.breakpoints;if(!s||s&&0===Object.keys(s).length)return;const a=e.getBreakpoint(s,e.params.breakpointsBase,e.el);if(!a||e.currentBreakpoint===a)return;const o=(a in s?s[a]:void 0)||e.originalParams,l=zn(e,i),d=zn(e,o),c=e.params.grabCursor,u=o.grabCursor,h=i.enabled;l&&!d?(n.classList.remove(`${i.containerModifierClass}grid`,`${i.containerModifierClass}grid-column`),e.emitContainerClasses()):!l&&d&&(n.classList.add(`${i.containerModifierClass}grid`),(o.grid.fill&&"column"===o.grid.fill||!o.grid.fill&&"column"===i.grid.fill)&&n.classList.add(`${i.containerModifierClass}grid-column`),e.emitContainerClasses()),c&&!u?e.unsetGrabCursor():!c&&u&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(t=>{if(void 0===o[t])return;const r=i[t]&&i[t].enabled,n=o[t]&&o[t].enabled;r&&!n&&e[t].disable(),!r&&n&&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(),tn(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 n=qi(),s="window"===t?n.innerHeight:r.clientHeight,a=Object.keys(e).map(e=>{if("string"==typeof e&&0===e.indexOf("@")){const t=parseFloat(e.substr(1));return{value:s*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:s,value:o}=a[e];"window"===t?n.matchMedia(`(min-width: ${o}px)`).matches&&(i=s):o<=r.clientWidth&&(i=s)}return i||"max"}};var jn={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 Hn(e,t){return function(r){void 0===r&&(r={});const i=Object.keys(r)[0],n=r[i];"object"==typeof n&&null!==n?(!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 n?("object"!=typeof e[i]||"enabled"in e[i]||(e[i].enabled=!0),e[i]||(e[i]={enabled:!1}),tn(t,r)):tn(t,r)):tn(t,r)}}const Vn={eventsEmitter:bn,update:An,translate:kn,transition:In,slide:Rn,loop:Pn,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=Cn.bind(e),e.onTouchMove=_n.bind(e),e.onTouchEnd=On.bind(e),e.onDocumentTouchStart=Bn.bind(e),t.cssMode&&(e.onScroll=Fn.bind(e)),e.onClick=Nn.bind(e),e.onLoad=$n.bind(e),Un(e,"on")},detachEvents:function(){Un(this,"off")}},breakpoints:Gn,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:n,device:s}=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:s.android},{ios:s.ios},{"css-mode":r.cssMode},{centered:r.cssMode&&r.centeredSlides},{"watch-progress":r.watchSlidesProgress}],r.containerModifierClass);t.push(...a),n.classList.add(...t),e.emitContainerClasses()},removeClasses:function(){const{el:e,classNames:t}=this;e&&"string"!=typeof e&&(e.classList.remove(...t),this.emitContainerClasses())}}},Wn={};let Yn=class e{constructor(){let t,r;for(var i=arguments.length,n=new Array(i),s=0;s<i;s++)n[s]=arguments[s];1===n.length&&n[0].constructor&&"Object"===Object.prototype.toString.call(n[0]).slice(8,-1)?r=n[0]:[t,r]=n,r||(r={}),r=tn({},r),t&&!r.el&&(r.el=t);const a=Yi();if(r.el&&"string"==typeof r.el&&a.querySelectorAll(r.el).length>1){const t=[];return a.querySelectorAll(r.el).forEach(i=>{const n=tn({},r,{el:i});t.push(new e(n))}),t}const o=this;o.__swiper__=!0,o.support=gn(),o.device=vn({userAgent:r.userAgent}),o.browser=yn(),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:Hn(r,l),on:o.on.bind(o),once:o.once.bind(o),off:o.off.bind(o),emit:o.emit.bind(o)})});const d=tn({},jn,l);return o.params=tn({},d,Wn,r),o.originalParams=tn({},o.params),o.passedParams=tn({},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=cn(an(t,`.${r.slideClass}, swiper-slide`)[0]);return cn(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=an(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(),n=(r.maxTranslate()-i)*e+i;r.translateTo(n,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:n,slidesSizesGrid:s,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?n[e]+s[e]-n[o]<a:n[e]-n[o]<a)&&(l+=1)}else for(let e=o-1;e>=0;e-=1){n[o]-n[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 n;if(r.breakpoints&&e.setBreakpoint(),[...e.el.querySelectorAll('[loading="lazy"]')].forEach(t=>{t.complete&&Sn(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;n=e.slideTo(t.length-1,0,!1,!0)}else n=e.slideTo(e.activeIndex,0,!1,!0);n||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 n=(()=>{if(r&&r.shadowRoot&&r.shadowRoot.querySelector){return r.shadowRoot.querySelector(i())}return an(r,i())[0]})();return!n&&t.params.createElements&&(n=ln("div",t.params.wrapperClass),r.append(n),an(r,`.${t.params.slideClass}`).forEach(e=>{n.append(e)})),Object.assign(t,{el:r,wrapperEl:n,slidesEl:t.isElement&&!r.parentNode.host.slideSlots?r.parentNode.host:n,hostEl:t.isElement?r.parentNode.host:r,mounted:!0,rtl:"rtl"===r.dir.toLowerCase()||"rtl"===dn(r,"direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===r.dir.toLowerCase()||"rtl"===dn(r,"direction")),wrongRTL:"-webkit-box"===dn(n,"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?Sn(t,e):e.addEventListener("load",e=>{Sn(t,e.target)})}),xn(t),t.initialized=!0,xn(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:n,wrapperEl:s,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(),n&&"string"!=typeof n&&n.removeAttribute("style"),s&&s.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){tn(Wn,e)}static get extendedDefaults(){return Wn}static get defaults(){return jn}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(Vn).forEach(e=>{Object.keys(Vn[e]).forEach(t=>{Yn.prototype[t]=Vn[e][t]})}),Yn.use([function(e){let{swiper:t,on:r,emit:i}=e;const n=qi();let s=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!==n.ResizeObserver?t&&!t.destroyed&&t.initialized&&(s=new ResizeObserver(e=>{a=n.requestAnimationFrame(()=>{const{width:r,height:i}=t;let n=r,s=i;e.forEach(e=>{let{contentBoxSize:r,contentRect:i,target:a}=e;a&&a!==t.el||(n=i?i.width:(r[0]||r).inlineSize,s=i?i.height:(r[0]||r).blockSize)}),n===r&&s===i||o()})}),s.observe(t.el)):(n.addEventListener("resize",o),n.addEventListener("orientationchange",l))}),r("destroy",()=>{a&&n.cancelAnimationFrame(a),s&&s.unobserve&&t.el&&(s.unobserve(t.el),s=null),n.removeEventListener("resize",o),n.removeEventListener("orientationchange",l)})},function(e){let{swiper:t,extendParams:r,on:i,emit:n}=e;const s=[],a=qi(),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 n("observerUpdate",e[0]);const r=function(){n("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}),s.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",()=>{s.forEach(e=>{e.disconnect()}),s.splice(0,s.length)})}]);const Kn=["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 qn(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)&&!e.__swiper__}function Xn(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]:qn(t[r])&&qn(e[r])&&Object.keys(t[r]).length>0?t[r].__swiper__?e[r]=t[r]:Xn(e[r],t[r]):e[r]=t[r]})}function Qn(e){return void 0===e&&(e={}),e.navigation&&void 0===e.navigation.nextEl&&void 0===e.navigation.prevEl}function Zn(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 es(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 ts(e){return void 0===e&&(e=""),e?e.includes("swiper-wrapper")?e:`swiper-wrapper ${e}`:"swiper-wrapper"}function rs(){return rs=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},rs.apply(this,arguments)}function is(e){return e.type&&e.type.displayName&&e.type.displayName.includes("SwiperSlide")}function ns(e){const r=[];return t.Children.toArray(e).forEach(e=>{is(e)?r.push(e):e.props&&e.props.children&&ns(e.props.children).forEach(e=>r.push(e))}),r}function ss(e){const r=[],i={"container-start":[],"container-end":[],"wrapper-start":[],"wrapper-end":[]};return t.Children.toArray(e).forEach(e=>{if(is(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=ns(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 as(e,t){return"undefined"==typeof window?i(e,t):o(e,t)}const os=l(null),ls=l(null),ds=n(function(e,n){let{className:s,tag:o="div",wrapperTag:l="div",children:d,onSwiper:c,...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:D}=function(e,t){void 0===e&&(e={}),void 0===t&&(t=!0);const r={on:{}},i={},n={};Xn(r,jn),r._emitClasses=!0,r.init=!1;const s={},a=Kn.map(e=>e.replace(/_/,"")),o=Object.assign({},e);return Object.keys(o).forEach(o=>{void 0!==e[o]&&(a.indexOf(o)>=0?qn(e[o])?(r[o]={},n[o]={},Xn(r[o],e[o]),Xn(n[o],e[o])):(r[o]=e[o],n[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]:s[o]=e[o])}),["navigation","pagination","scrollbar"].forEach(e=>{!0===r[e]&&(r[e]={}),!1===r[e]&&delete r[e]}),{params:r,passedParams:n,rest:s,events:i}}(u),{slides:C,slots:_}=ss(d),O=()=>{y(!v)};Object.assign(I.on,{_containerClasses(e,t){p(t)}});const M=()=>{Object.assign(I.on,D),h=!0;const e={...I};if(delete e.wrapperClass,w.current=new Yn(e),w.current.virtual&&w.current.params.virtual.enabled){w.current.virtual.slides=C;const e={cache:!1,slides:C,renderExternal:g,renderExternalUpdate:!1};Xn(w.current.params.virtual,e),Xn(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)}),as(()=>{if(n&&(n.current=E.current),E.current)return w.current.destroyed&&M(),function(e,t){let{el:r,nextEl:i,prevEl:n,paginationEl:s,scrollbarEl:a,swiper:o}=e;Qn(t)&&i&&n&&(o.params.navigation.nextEl=i,o.originalParams.navigation.nextEl=i,o.params.navigation.prevEl=n,o.originalParams.navigation.prevEl=n),Zn(t)&&s&&(o.params.pagination.el=s,o.originalParams.pagination.el=s),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),c&&!w.current.destroyed&&c(w.current),()=>{w.current&&!w.current.destroyed&&w.current.destroy(!0,!1)}},[]),as(()=>{!h&&D&&w.current&&Object.keys(D).forEach(e=>{w.current.on(e,D[e])});const e=function(e,t,r,i,n){const s=[];if(!t)return s;const a=e=>{s.indexOf(e)<0&&s.push(e)};if(r&&i){const e=i.map(n),t=r.map(n);e.join("")!==t.join("")&&a("children"),i.length!==r.length&&a("children")}return Kn.filter(e=>"_"===e[0]).map(e=>e.replace(/_/,"")).forEach(r=>{if(r in e&&r in t)if(qn(e[r])&&qn(t[r])){const i=Object.keys(e[r]),n=Object.keys(t[r]);i.length!==n.length?a(r):(i.forEach(i=>{e[r][i]!==t[r][i]&&a(r)}),n.forEach(i=>{e[r][i]!==t[r][i]&&a(r)}))}else e[r]!==t[r]&&a(r)}),s}(R,S.current,C,T.current,e=>e.key);return S.current=R,T.current=C,e.length&&w.current&&!w.current.destroyed&&function(e){let{swiper:t,slides:r,passedParams:i,changedParams:n,nextEl:s,prevEl:a,scrollbarEl:o,paginationEl:l}=e;const d=n.filter(e=>"children"!==e&&"direction"!==e&&"wrapperClass"!==e),{params:c,pagination:u,navigation:h,scrollbar:f,virtual:p,thumbs:m}=t;let g,v,y,b,E,w,S,T;n.includes("thumbs")&&i.thumbs&&i.thumbs.swiper&&!i.thumbs.swiper.destroyed&&c.thumbs&&(!c.thumbs.swiper||c.thumbs.swiper.destroyed)&&(g=!0),n.includes("controller")&&i.controller&&i.controller.control&&c.controller&&!c.controller.control&&(v=!0),n.includes("pagination")&&i.pagination&&(i.pagination.el||l)&&(c.pagination||!1===c.pagination)&&u&&!u.el&&(y=!0),n.includes("scrollbar")&&i.scrollbar&&(i.scrollbar.el||o)&&(c.scrollbar||!1===c.scrollbar)&&f&&!f.el&&(b=!0),n.includes("navigation")&&i.navigation&&(i.navigation.prevEl||a)&&(i.navigation.nextEl||s)&&(c.navigation||!1===c.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()),c[e].prevEl=void 0,c[e].nextEl=void 0,t[e].prevEl=void 0,t[e].nextEl=void 0):(t.isElement&&t[e].el.remove(),c[e].el=void 0,t[e].el=void 0))};n.includes("loop")&&t.isElement&&(c.loop&&!i.loop?w=!0:!c.loop&&i.loop?S=!0:T=!0),d.forEach(e=>{if(qn(c[e])&&qn(i[e]))Object.assign(c[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?c[e]=i[e]:!1===t&&x(e)}}),d.includes("controller")&&!v&&t.controller&&t.controller.control&&c.controller&&c.controller.control&&(t.controller.control=c.controller.control),n.includes("children")&&r&&p&&c.virtual.enabled?(p.slides=r,p.update(!0)):n.includes("virtual")&&p&&c.virtual.enabled&&(r&&(p.slides=r),p.update(!0)),n.includes("children")&&r&&c.loop&&(T=!0),g&&m.init()&&m.update(!0);v&&(t.controller.control=c.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&&(c.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&&(c.scrollbar.el=o),f.init(),f.updateSize(),f.setTranslate()),E&&(t.isElement&&(s&&"string"!=typeof s||(s=document.createElement("div"),s.classList.add("swiper-button-next"),s.innerHTML=t.hostEl.constructor.nextButtonSvg,s.part.add("button-next"),t.el.appendChild(s)),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))),s&&(c.navigation.nextEl=s),a&&(c.navigation.prevEl=a),h.init(),h.update()),n.includes("allowSlideNext")&&(t.allowSlideNext=i.allowSlideNext),n.includes("allowSlidePrev")&&(t.allowSlidePrev=i.allowSlidePrev),n.includes("direction")&&t.changeDirection(i.direction,!1),(w||T)&&t.loopDestroy(),(S||T)&&t.loopCreate(),t.update()}({swiper:w.current,slides:C,passedParams:R,changedParams:e,nextEl:x.current,prevEl:A.current,scrollbarEl:L.current,paginationEl:k.current}),()=>{D&&w.current&&Object.keys(D).forEach(e=>{w.current.off(e,D[e])})}}),as(()=>{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,rs({ref:E,className:es(`${f}${s?` ${s}`:""}`)},P),t.createElement(ls.Provider,{value:w.current},_["container-start"],t.createElement(l,{className:ts(I.wrapperClass)},_["wrapper-start"],I.virtual?function(e,r,i){if(!i)return null;const n=e=>{let t=e;return e<0?t=r.length+e:t>=r.length&&(t-=r.length),t},s=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,d=e.params.loop?2*r.length:r.length,c=[];for(let e=l;e<d;e+=1)e>=a&&e<=o&&c.push(r[n(e)]);return c.map((r,i)=>t.cloneElement(r,{swiper:e,style:s,key:r.props.virtualIndex||r.key||`slide-${i}`}))}(w.current,C,m):C.map((e,r)=>t.cloneElement(e,{swiper:w.current,swiperSlideIndex:r})),_["wrapper-end"]),Qn(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"}),Zn(I)&&t.createElement("div",{ref:k,className:"swiper-pagination"}),_["container-end"]))});ds.displayName="Swiper";const cs=n(function(e,i){let{tag:n="div",children:s,className:o="",swiper:l,zoom:d,lazy:c,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)}as(()=>{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")}}),as(()=>{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 s?s(E):s;return t.createElement(n,rs({ref:p,className:es(`${m}${o?` ${o}`:""}`),"data-swiper-slide-index":u,onLoad:()=>{y(!0)}},f),d&&t.createElement(os.Provider,{value:E},t.createElement("div",{className:"swiper-zoom-container","data-swiper-zoom":"number"==typeof d?d:void 0},w(),c&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"}))),!d&&t.createElement(os.Provider,{value:E},w(),c&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"})))});function us(e){let{swiper:t,extendParams:r,on:i,emit:n}=e;const s=qi();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=Qi();const d=[];function c(){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&&Qi()-l<t.params.mousewheel.thresholdTime)&&(e.delta>=6&&Qi()-l<60||(e.direction<0?t.isEnd&&!t.params.loop||t.animating||(t.slideNext(),n("scroll",e.raw)):t.isBeginning&&!t.params.loop||t.animating||(t.slidePrev(),n("scroll",e.raw)),l=(new s.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 s=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 c=l&&l.contains(r.target);if(!t.mouseEntered&&!c&&!s.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,n=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,n=10*r,"deltaY"in e&&(n=e.deltaY),"deltaX"in e&&(i=e.deltaX),e.shiftKey&&!i&&(i=n,n=0),(i||n)&&e.deltaMode&&(1===e.deltaMode?(i*=40,n*=40):(i*=800,n*=800)),i&&!t&&(t=i<1?-1:1),n&&!r&&(r=n<1?-1:1),{spinX:t,spinY:r,pixelX:i,pixelY:n}}(r);if(s.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;s.invert&&(u=-u);let m=t.getTranslate()+u*s.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:Qi(),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*s.sensitivity;const c=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(),(!c&&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,d.length>=15&&d.shift();const r=d.length?d[d.length-1]:void 0,i=d[0];if(d.push(e),r&&(e.delta>r.delta||e.direction!==r.direction))d.splice(0);else if(d.length>=15&&e.time-i.time<500&&i.delta-e.delta>=1&&e.delta<=6){const r=u>0?.8:.2;o=e,d.splice(0),a=Xi(()=>{!t.destroyed&&t.params&&t.slideToClosest(t.params.speed,!0,void 0,r)},0)}a||(a=Xi(()=>{if(t.destroyed||!t.params)return;o=e,d.splice(0),t.slideToClosest(t.params.speed,!0,void 0,.5)},500))}if(i||n("scroll",r),t.params.autoplay&&t.params.autoplayDisableOnInteraction&&t.autoplay.stop(),s.releaseOnEdges&&(l===t.minTranslate()||l===t.maxTranslate()))return!0}}else{const r={time:Qi(),delta:Math.abs(u),direction:Math.sign(u),raw:e};d.length>=2&&d.shift();const i=d.length?d[d.length-1]:void 0;if(d.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",c),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 hs(e){let{swiper:t,extendParams:r,on:i,emit:n}=e;function s(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=hn(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(),n("navigationPrev"))}function d(e){e.preventDefault(),(!t.isEnd||t.params.loop||t.params.rewind)&&(t.slideNext(),n("navigationNext"))}function c(){const e=t.params.navigation;if(t.params.navigation=function(e,t,r,i){return e.params.createElements&&Object.keys(i).forEach(n=>{if(!r[n]&&!0===r.auto){let s=an(e.el,`.${i[n]}`)[0];s||(s=ln("div",i[n]),s.className=i[n],e.el.append(s)),r[n]=s,t[n]=s}}),r}(t,t.originalParams.navigation,t.params.navigation,{nextEl:"swiper-button-next",prevEl:"swiper-button-prev"}),!e.nextEl&&!e.prevEl)return;let r=s(e.nextEl),i=s(e.prevEl);Object.assign(t.navigation,{nextEl:r,prevEl:i}),r=hn(r),i=hn(i);const n=(r,i)=>{r&&r.addEventListener("click","next"===i?d:l),!t.enabled&&r&&r.classList.add(...e.lockClass.split(" "))};r.forEach(e=>n(e,"next")),i.forEach(e=>n(e,"prev"))}function u(){let{nextEl:e,prevEl:r}=t.navigation;e=hn(e),r=hn(r);const i=(e,r)=>{e.removeEventListener("click","next"===r?d: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():(c(),o())}),i("toEdge fromEdge lock unlock",()=>{o()}),i("destroy",()=>{u()}),i("enable disable",()=>{let{nextEl:e,prevEl:r}=t.navigation;e=hn(e),r=hn(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:s}=t.navigation;i=hn(i),s=hn(s);const a=r.target;let o=s.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)||s.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):s.length&&(e=s[0].classList.contains(t.params.navigation.hiddenClass)),n(!0===e?"navigationShow":"navigationHide"),[...i,...s].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(" ")),c(),o()},disable:h,update:o,init:c,destroy:u})}function fs(e){let t,r,{swiper:i,extendParams:n,on:s,emit:a,params:o}=e;i.autoplay={running:!1,paused:!1,timeLeft:0},n({autoplay:{enabled:!1,delay:3e3,waitForTransition:!0,disableOnInteraction:!1,stopOnLastSlide:!1,reverseDirection:!1,pauseOnMouseEnter:!1}});let l,d,c,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?d=!0:d&&(v=l,d=!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 n=void 0===e?i.params.autoplay.delay:e;g=i.params.autoplay.delay,v=i.params.autoplay.delay;const s=(()=>{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(s)&&s>0&&void 0===e&&(n=s,g=s,v=s),l=n;const o=i.params.speed,d=()=>{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 n>0?(clearTimeout(t),t=setTimeout(()=>{d()},n)):requestAnimationFrame(()=>{d()}),n},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 n=()=>{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 n();const s=l||i.params.autoplay.delay;l=s-((new Date).getTime()-y),i.isEnd&&l<0&&!i.params.loop||(l<0&&(l=0),n())},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=Yi();"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())};s("init",()=>{i.params.autoplay.enabled&&(i.params.autoplay.pauseOnMouseEnter&&(i.el.addEventListener("pointerenter",L),i.el.addEventListener("pointerleave",I)),Yi().addEventListener("visibilitychange",k),S())}),s("destroy",()=>{i.el&&"string"!=typeof i.el&&(i.el.removeEventListener("pointerenter",L),i.el.removeEventListener("pointerleave",I)),Yi().removeEventListener("visibilitychange",k),i.autoplay.running&&T()}),s("_freeModeStaticRelease",()=>{(u||p)&&A()}),s("_freeModeNoMomentumRelease",()=>{i.params.autoplay.disableOnInteraction?T():x(!0,!0)}),s("beforeTransitionStart",(e,t,r)=>{!i.destroyed&&i.autoplay.running&&(r||!i.params.autoplay.disableOnInteraction?x(!0,!0):T())}),s("sliderFirstMove",()=>{!i.destroyed&&i.autoplay.running&&(i.params.autoplay.disableOnInteraction?T():(c=!0,u=!1,p=!1,h=setTimeout(()=>{p=!0,u=!0,x(!0)},200)))}),s("touchEnd",()=>{if(!i.destroyed&&i.autoplay.running&&c){if(clearTimeout(h),clearTimeout(t),i.params.autoplay.disableOnInteraction)return u=!1,void(c=!1);u&&i.params.cssMode&&A(),u=!1,c=!1}}),s("slideChange",()=>{!i.destroyed&&i.autoplay.running&&(f=!0)}),Object.assign(i.autoplay,{start:S,stop:T,pause:x,resume:A})}function ps(e){let t,r,i,n,{swiper:s,extendParams:a,on:o}=e;a({grid:{rows:1,fill:"column"}});const l=()=>{let e=s.params.spaceBetween;return"string"==typeof e&&e.indexOf("%")>=0?e=parseFloat(e.replace("%",""))/100*s.size:"string"==typeof e&&(e=parseFloat(e)),e};o("init",()=>{n=s.params.grid&&s.params.grid.rows>1}),o("update",()=>{const{params:e,el:t}=s,r=e.grid&&e.grid.rows>1;n&&!r?(t.classList.remove(`${e.containerModifierClass}grid`,`${e.containerModifierClass}grid-column`),i=1,s.emitContainerClasses()):!n&&r&&(t.classList.add(`${e.containerModifierClass}grid`),"column"===e.grid.fill&&t.classList.add(`${e.containerModifierClass}grid-column`),s.emitContainerClasses()),n=r}),s.grid={initSlides:e=>{const{slidesPerView:n}=s.params,{rows:a,fill:o}=s.params.grid,l=s.virtual&&s.params.virtual.enabled?s.virtual.slides.length:e.length;i=Math.floor(l/a),t=Math.floor(l/a)===l/a?l:Math.ceil(l/a)*a,"auto"!==n&&"row"===o&&(t=Math.max(t,n*a)),r=t/a},unsetSlides:()=>{s.slides&&s.slides.forEach(e=>{e.swiperSlideGridSet&&(e.style.height="",e.style[s.getDirectionLabel("margin-top")]="")})},updateSlide:(e,n,a)=>{const{slidesPerGroup:o}=s.params,d=l(),{rows:c,fill:u}=s.params.grid,h=s.virtual&&s.params.virtual.enabled?s.virtual.slides.length:a.length;let f,p,m;if("row"===u&&o>1){const r=Math.floor(e/(o*c)),i=e-c*o*r,s=0===r?o:Math.min(Math.ceil((h-r*c*o)/c),o);m=Math.floor(i/s),p=i-m*s+r*o,f=p+m*t/c,n.style.order=f}else"column"===u?(p=Math.floor(e/c),m=e-p*c,(p>i||p===i&&m===c-1)&&(m+=1,m>=c&&(m=0,p+=1))):(m=Math.floor(e/r),p=e-m*r);n.row=m,n.column=p,n.style.height=`calc((100% - ${(c-1)*d}px) / ${c})`,n.style[s.getDirectionLabel("margin-top")]=0!==m?d&&`${d}px`:"",n.swiperSlideGridSet=!0},updateWrapperSize:(e,r)=>{const{centeredSlides:i,roundLengths:n}=s.params,a=l(),{rows:o}=s.params.grid;if(s.virtualSize=(e+a)*t,s.virtualSize=Math.ceil(s.virtualSize/o)-a,s.params.cssMode||(s.wrapperEl.style[s.getDirectionLabel("width")]=`${s.virtualSize+a}px`),i){const e=[];for(let t=0;t<r.length;t+=1){let i=r[t];n&&(i=Math.floor(i)),r[t]<s.virtualSize+r[0]&&e.push(i)}r.splice(0,r.length),r.push(...e)}}}}function ms(e){const t=this,{params:r,slidesEl:i}=t;r.loop&&t.loopDestroy();const n=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]&&n(e[t]);else n(e);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update()}function gs(e){const t=this,{params:r,activeIndex:i,slidesEl:n}=t;r.loop&&t.loopDestroy();let s=i+1;const a=e=>{if("string"==typeof e){const t=document.createElement("div");t.innerHTML=e,n.prepend(t.children[0]),t.innerHTML=""}else n.prepend(e)};if("object"==typeof e&&"length"in e){for(let t=0;t<e.length;t+=1)e[t]&&a(e[t]);s=i+e.length}else a(e);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update(),t.slideTo(s,0,!1)}function vs(e,t){const r=this,{params:i,activeIndex:n,slidesEl:s}=r;let a=n;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 d=[];for(let t=o-1;t>=e;t-=1){const e=r.slides[t];e.remove(),d.unshift(e)}if("object"==typeof t&&"length"in t){for(let e=0;e<t.length;e+=1)t[e]&&s.append(t[e]);l=a>e?a+t.length:a}else s.append(t);for(let e=0;e<d.length;e+=1)s.append(d[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 ys(e){const t=this,{params:r,activeIndex:i}=t;let n=i;r.loop&&(n-=t.loopedSlides,t.loopDestroy());let s,a=n;if("object"==typeof e&&"length"in e){for(let r=0;r<e.length;r+=1)s=e[r],t.slides[s]&&t.slides[s].remove(),s<a&&(a-=1);a=Math.max(a,0)}else s=e,t.slides[s]&&t.slides[s].remove(),s<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 bs(){const e=this,t=[];for(let r=0;r<e.slides.length;r+=1)t.push(r);e.removeSlide(t)}function Es(e){let{swiper:t}=e;Object.assign(t,{appendSlide:ms.bind(t),prependSlide:gs.bind(t),addSlide:vs.bind(t),removeSlide:ys.bind(t),removeAllSlides:bs.bind(t)})}function ws(e,t){const r=sn(t);return r!==t&&(r.style.backfaceVisibility="hidden",r.style["-webkit-backface-visibility"]="hidden"),r}function Ss(e){let{swiper:t,duration:r,transformElements:i,allSlides:n}=e;const{activeIndex:s}=t;if(t.params.virtualTranslate&&0!==r){let e,r=!1;e=n?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)===s}),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 Ts(e,t,r){const i=`swiper-slide-shadow swiper-slide-shadow-${e}`,n=sn(t);let s=n.querySelector(`.${i.split(" ").join(".")}`);return s||(s=ln("div",i.split(" ")),n.append(s)),s}function xs(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:n,setTransition:s,overwriteParams:a,perspective:o,recreateShadows:l,getEffectParams:d}=e;let c;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&&n()}),i("setTransition",(e,i)=>{r.params.effect===t&&s(i)}),i("transitionEnd",()=>{if(r.params.effect===t&&l){if(!d||!d().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||(c=!0),requestAnimationFrame(()=>{c&&r.slides&&r.slides.length&&(n(),c=!1)}))})}({effect:"cards",swiper:t,on:i,setTranslate:()=>{const{slides:e,activeIndex:r,rtlTranslate:i}=t,n=t.params.cardsEffect,{startTranslate:s,isTouched:a}=t.touchEventsData,o=i?-t.translate:t.translate;for(let l=0;l<e.length;l+=1){const d=e[l],c=d.progress,u=Math.min(Math.max(c,-4),4);let h=d.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=-n.perSlideRotate*u,y=n.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<s,w=(b===r||b===r+1)&&u<0&&u>-1&&(a||t.params.cssMode)&&o>s;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(${n.rotate?i?-v:v:0}deg)\n scale(${S})\n `;if(n.slideShadows){let e=d.querySelector(".swiper-slide-shadow");e||(e=Ts("cards",d)),e&&(e.style.opacity=Math.min(Math.max((Math.abs(u)-.5)/.5,0),1))}d.style.zIndex=-Math.abs(Math.round(c))+e.length;ws(0,d).style.transform=T}},setTransition:e=>{const r=t.slides.map(e=>sn(e));r.forEach(t=>{t.style.transitionDuration=`${e}ms`,t.querySelectorAll(".swiper-slide-shadow").forEach(t=>{t.style.transitionDuration=`${e}ms`})}),Ss({swiper:t,duration:e,transformElements:r})},perspective:()=>!0,overwriteParams:()=>({watchSlidesProgress:!0,virtualTranslate:!t.params.cssMode})})}cs.displayName="SwiperSlide";const As=({product:e})=>{const[r,i]=a(!1);return t.createElement("a",{href:e.linkPath,target:"_blank"},t.createElement("div",{className:"w-full h-full flex gap-2 flex-col"},t.createElement("div",{className:"w-full max-h-fit aspect-square border mb-2 flex justify-center items-center"},e.thumbPath&&!r?t.createElement(er,{product:e,onError:()=>i(!0)}):t.createElement(Jt,null)),t.createElement("div",{className:"justify-center flex flex-col"},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",null,e.productName),t.createElement("div",null,t.createElement("span",{className:"font-semibold text-red-500"},e.discount,"%"," "),t.createElement("span",{className:"font-semibold"},xt(e.sellingPrice),"원")))))},ks=({products:e})=>{const n=r(null),[s,o]=a(0),l=r(null);i(()=>{u(),window.addEventListener("resize",()=>{clearInterval(d),d=setTimeout(u,c)})},[]);let d=null;const c=100,u=()=>{l.current&&o(l.current.offsetWidth)};return e&&t.createElement("div",{className:"flex items-center h-full justify-center w-full",ref:l},e.length>3?t.createElement(zt,{size:50,className:"cursor-pointer slide__prev",onClick:()=>{var e;null===(e=n.current)||void 0===e||e.slidePrev()}}):t.createElement("div",{className:"w-[50px]"}),t.createElement(ds,{modules:[hs],onSwiper:e=>{n.current=e},style:{width:s},slidesPerView:3,navigation:{prevEl:".slide__prev",nextEl:".slide__next"},spaceBetween:20},e.map(e=>t.createElement(cs,{key:e.productId},t.createElement(As,{product:e})))),e.length>3?t.createElement(Gt,{onClick:()=>{var e;null===(e=n.current)||void 0===e||e.slideNext()},size:50,className:"cursor-pointer slide__next"}):t.createElement("div",{className:"w-[50px]"}))},Ls=e=>{const{player:r,shortform:i}=e;return t.createElement("div",{className:"flex h-full gap-5"},t.createElement("div",{className:"h-full aspect-[9/16]"},r),t.createElement("div",{className:"w-full min-w-44 max-w-[800px] overflow-hidden text-sm"},t.createElement(ks,{products:i.productsInfo})))},Is=({products:e})=>{const i=r(null);return t.createElement("div",{className:"flex items-center flex-col h-full"},e.length>4&&t.createElement(jt,{size:50,className:"cursor-pointer slide__prev"}),t.createElement(ds,{modules:[us,hs],mousewheel:!0,onSwiper:e=>{i.current=e},spaceBetween:10,className:"max-w-full h-[80%]",slidesPerView:4,direction:"vertical",navigation:{prevEl:".slide__prev",nextEl:".slide__next"}},e.map(e=>t.createElement(cs,{key:e.productId},t.createElement(tr,{product:e})))),e.length>4&&t.createElement(Ut,{size:50,className:"cursor-pointer slide__next"}))},Rs=e=>{const{playerSettings:r,shortform:{productsInfo:i},player:n}=e;return t.createElement("div",{className:"flex h-full w-full gap-5"},t.createElement("div",{className:" h-full "},n),t.createElement("div",{className:"max-w-[800px] overflow-hidden"},t.createElement(Is,{products:i})))},Ps=({products:e})=>{const i=r(null),n=e.length>6;return t.createElement("div",{className:"flex items-center my-10 h-full text-sm w-full"},n?t.createElement(zt,{onClick:()=>{var e;null===(e=i.current)||void 0===e||e.slidePrev()},size:50,className:"cursor-pointer"}):t.createElement("div",{className:"w-[50px]"}),t.createElement(ds,{onSwiper:e=>{i.current=e},className:"w-[80%] h-[80%]",slidesPerView:3,spaceBetween:20,modules:[ps],grid:{rows:2,fill:"row"}},e.map(e=>t.createElement(cs,{key:e.productId},t.createElement(As,{product:e})))),n?t.createElement(Gt,{onClick:()=>{var e;null===(e=i.current)||void 0===e||e.slideNext()},size:50,className:"cursor-pointer"}):t.createElement("div",{className:"w-[50px]"}))},Ds=e=>{const{player:r,shortform:{productsInfo:i}}=e;return t.createElement("div",{className:"flex gap-4 w-full h-full min-w-[768px]"},t.createElement("div",{className:"flex-1 w-full"},t.createElement("div",{className:"h-full aspect-[9/16]"},r)),t.createElement("div",{className:"flex-[2] w-full h-full overflow-hidden"},t.createElement(Ps,{products:i})))},Cs=e=>(document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}),_s=()=>document.visibilityState,Os=()=>{throw Error("useVisibilityChange is a client-only hook")};function Ms(){return"visible"===e.useSyncExternalStore(Cs,_s,Os)}var Ns=(e,t,n=!0)=>{const s=r(e),a=r(null),o=()=>{a.current&&(clearInterval(a.current),a.current=null)},l=c(()=>{a.current||(a.current=setInterval(()=>s.current(),t))},[t]);return i(()=>{s.current=e},[e]),i(()=>(n&&l(),()=>o()),[l,n]),{clear:o,run:l}};const Fs=()=>{const[e,t]=a(0);Ns(()=>{t(e=>e+1)},1e3);return{playtime:e,resetPlaytime:()=>t(0)}};var $s;!function(e){e.latest="",e.views="pageView",e.likes="like"}($s||($s={}));let Bs=0;const Us=e=>x(void 0,void 0,void 0,function*(){const{PLAYER_BACK_BASE_URL:t}=gt(),{contentId:r,uuid:i,type:n,userId:s}=e;try{if(3===Bs)return;const e=`${t}/statistics/play`,a=Object.assign({contentId:r,uuid:i,type:n,date:At(),userId:+s,playtime:0,isLive:!1},"shorts"===n&&{isFinished:!1,playedOver5Sec:!1});yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}catch(e){console.error(`Error in statisticsApi.join - contentId: ${r}`),Pt(e),Bs++}}),zs=e=>{const{PLAYER_BACK_BASE_URL:t}=gt(),{contentId:r,uuid:i,type:n,isFinished:s,playtime:a,userId:o}=e,l=Object.assign({contentId:r,uuid:i,playtime:a,type:n,date:At(),userId:+o,isLive:!1},"shorts"===n&&{isFinished:s,playedOver5Sec:Number(a)>5});fetch(`${t}/statistics/play`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l),keepalive:!0})},Gs=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:At()},e))})}catch(e){console.error(`Error in statisticsApi.productClick - contentProductId: ${r}`),Pt(e)}}),js=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}`),Pt(t),0}}),Hs=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}`),Pt(t)}}),Vs=e=>x(void 0,[e],void 0,function*({collectionId:e,nextKey:t,size:r=5}){const{PLAYER_BACK_BASE_URL:i}=gt();try{const n=new URLSearchParams;-1!==r&&n.set("size",String(r)),t&&n.set("nextKey",t);const s=yield fetch(`${i}/commerce/collection/${e}?${n.toString()}`);return s.ok?yield s.json():null}catch(e){return Pt(e),null}}),Ws=(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:n}}}=t;return Object.assign(Object.assign(Object.assign(Object.assign({layout:t.player.layout},t.player.shoppingPlayer),{aspectRatio:Dt(i,n)}),t),{uuid:kt()})}catch(e){return Pt(e),null}try{const t=yield fetch(`${i}/commerce/short-form/${e}`),r=yield t.json();return r.shortsId?r:null}catch(e){return Pt(e),null}}),Ys=(e,t,r,i,n)=>x(void 0,void 0,void 0,function*(){const{API_BASE_URL:s}=gt();try{const a=yield fetch(`${s}/live/${e}/list?size=${r||6}&status=${t}&includeMainLive=${i}${n&&$s[n]?`&sortBy=${$s[n]}`:""}`);if(!a.ok)return console.error("Error in getLiveWidgetContents "),null;const{content:o,mainLive:l}=(yield a.json()).result;return[...l?[l]:[],...o]}catch(e){return console.error("Error in getLiveWidgetContents: ",e),null}}),Ks=e=>{let t;const r=new Set,i=(e,i)=>{const n="function"==typeof e?e(t):e;if(!Object.is(n,t)){const e=t;t=(null!=i?i:"object"!=typeof n||null===n)?n:Object.assign({},t,n),r.forEach(r=>r(t,e))}},n=()=>t,s={setState:i,getState:n,getInitialState:()=>a,subscribe:e=>(r.add(e),()=>r.delete(e))},a=t=e(i,n,s);return s},qs=e=>e?Ks(e):Ks,Xs=e=>e;function Qs(e,r=Xs){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 Zs=e=>{const t=qs(e),r=e=>Qs(t,e);return Object.assign(r,t),r},Js=e=>e?Zs(e):Zs,ea=Js(e=>({priceText:"",isPreview:!1,setPriceText:t=>e({priceText:t}),setIsPreview:t=>e({isPreview:t})})),ta=t.createContext(null),ra=({children:e})=>{const r=t.useRef(null);return r.current||(r.current=qs(e=>({collection:null,setCollection:t=>e({collection:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})}))),t.createElement(ta.Provider,{value:r.current},e)},ia=()=>(e=>{const r=t.useContext(ta);if(!r)throw new Error("Missing CollectionProvider");return Qs(r,e)})(e=>e),na=(e,t)=>{const{collection:r,setCollection:n,isFetching:s,setIsFetching:a,nextKey:o,setNextKey:l}=ia(),{isPreview:d}=ea(),c=(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}=Fs(),{playtime:f,resetPlaytime:p}=Fs(),m=Ms(),g=()=>{if(!r)return;const{colId:t,uuid:i,userId:n}=r,s=Ge,a=Math.floor((new Date).getTime()/1e3);localStorage.setItem(s,a.toString()),d||(zs({contentId:t,uuid:i,type:Et.COLLECTION,userId:n,playtime:f}),e&&zs({contentId:e.shortsId,uuid:e.uuid,type:Et.SHORTS,userId:n,playtime:h,isFinished:h>=c}),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:d,count:c}=r;if((null!=c?c:Number.MAX_SAFE_INTEGER)>d.length&&e>=d.length-5&&!s){a(!0);try{const e=yield Vs({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 s=new Set(r.contents.map(e=>e.shortsId)),a=e.contents.filter(e=>!s.has(e.shortsId));if(!a.length)return;const d=r.contents.concat(a);n(Object.assign(Object.assign({},r),{contents:d}))}catch(e){console.error(e)}finally{a(!1)}}}))(i),!d)){const{shortsId:n,uuid:s,userId:a}=e;zs({contentId:n,uuid:s,type:Et.SHORTS,playtime:h,isFinished:h>=c,userId:a}),u();const o=kt(),l=r.contents[i];t(Object.assign(Object.assign({},l),{uuid:o})),yield Us({contentId:l.shortsId,uuid:o,type:Et.SHORTS,userId:l.userId,isFirstPlay:!Lt(l.shortsId)})}}),onCollectionClose:g}},sa=e=>{const{collection:i,playerSettings:n,shortform:s,setShortform:a}=e,o=r(null),{onSlideChange:l}=na(i,s);return t.createElement(t.Fragment,null,t.createElement("div",{className:"self-center flex gap-4 flex-col"},t.createElement(jt,{size:44,onClick:()=>{var e;null===(e=o.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(Ut,{size:44,onClick:()=>{var e;null===(e=o.current)||void 0===e||e.swiper.slideNext()}})),t.createElement("div",{className:"h-full aspect-[9/16] my-10"},t.createElement(ds,{modules:[us,Es],mousewheel:!0,loop:!0,direction:"vertical",touchEventsTarget:"container",slidesPerView:1,ref:o,className:"h-full",onSlideChangeTransitionEnd:e=>x(void 0,void 0,void 0,function*(){yield l(e.realIndex)})},i.contents.map(e=>t.createElement(cs,{key:e.shortsId},s.shortsId===e.shortsId&&t.createElement("div",{className:"h-full rounded-xl absolute z-[999] aspect-[9/16] overflow-hidden"},t.createElement(L,{file:Tt(s.media.objectId)})),t.createElement("img",{src:Rt(e.thumbPath),alt:e.title,className:"rounded-xl overflow-hidden h-full bg-black aspect-[9/16] "+(e.media.width>e.media.height?"object-contain":"object-cover")}))))))},aa=e=>{const{collection:i,shortform:n,setShortform:s,playerSettings:a}=e,o=r(null);na(i,n);return t.createElement("div",{className:"mx-10 flex h-full gap-4"},t.createElement("div",{className:"self-center flex gap-4 flex-col"},t.createElement(jt,{size:44,onClick:()=>{var e;null===(e=o.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(Ut,{size:44,onClick:()=>{var e;null===(e=o.current)||void 0===e||e.swiper.slideNext()}})),t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(ds,{modules:[us,Es],mousewheel:!0,direction:"vertical",slidesPerView:1,ref:o,className:"h-full",preventClicksPropagation:!1,preventClicks:!1,noSwiping:!0,allowTouchMove:!1,loop:!0},i.contents.map(e=>t.createElement(cs,{key:e.shortsId},t.createElement("div",{className:"flex justify-center gap-3 h-full w-full"},n.shortsId===e.shortsId&&t.createElement("div",{className:"h-full absolute z-[999] w-full"},t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(L,{file:Tt(n.media.objectId)}))),t.createElement("div",{className:"h-full aspec[9/16]"},t.createElement("img",{src:"https://"+e.thumbPath,alt:e.title,className:"w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")}))))))))},oa=()=>t.createElement("div",{className:"inline-block absolute pointer-events-none top-0 z-10 animate-float w-[24px] h-[24px]"},t.createElement(Vt,{className:"fill-red-500 text-transparent w-[24px] h-[24px]"})),la=({shortsId:e})=>{const{isPreview:r}=ea(),[n,s]=a(r?123:0),[o,l]=a([]);i(()=>{r||x(void 0,void 0,void 0,function*(){try{const t=yield js(e);s(t)}catch(e){return console.error(`Error in statistics getLikeInLive: ${e.toString()}`),0}})},[]);return t.createElement("div",{className:"flex justify-center flex-col items-center relative w-[24px] h-[24px]"},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)})(),s(e=>e+1),r||(yield x(void 0,void 0,void 0,function*(){yield Hs(e)}))}),className:"z-[5] cursor-pointer"},t.createElement(Vt,{className:"text-xl fill-white w-[24px] h-[24px]"})),o.map(e=>t.createElement(oa,{key:e})),t.createElement("span",{className:"break-keep text-[10px]"},xt(n)))};var da,ca,ua={},ha={exports:{}},fa=ha.exports;function pa(){return da||(da=1,e=ha,t=ha.exports,function(r,i){var n="function",s="undefined",a="object",o="string",l="major",d="model",c="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",D="Microsoft",C="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===s?e:e.substring(0,500)},Y=function(e,t){for(var r,s,o,l,d,c,u=0;u<t.length&&!d;){var h=t[u],f=t[u+1];for(r=s=0;r<h.length&&!d&&h[r];)if(d=h[r++].exec(e))for(o=0;o<f.length;o++)c=d[++s],typeof(l=f[o])===a&&l.length>0?2===l.length?typeof l[1]==n?this[l[0]]=l[1].call(this,c):this[l[0]]=l[1]:3===l.length?typeof l[1]!==n||l[1].exec&&l[1].test?this[l[0]]=c?c.replace(l[1],l[2]):i:this[l[0]]=c?l[1].call(this,c,l[2]):i:4===l.length&&(this[l[0]]=c?l[3].call(this,c.replace(l[1],l[2])):i):this[l]=c||i;u+=2}},K=function(e,t){for(var r in t)if(typeof t[r]===a&&t[r].length>0){for(var n=0;n<t[r].length;n++)if(H(t[r][n],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,[c,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[f,[c,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[c,f],[/opios[\/ ]+([\w\.]+)/i],[f,[c,_+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[f,[c,_+" GX"]],[/\bopr\/([\w\.]+)/i],[f,[c,_]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[f,[c,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[f,[c,"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],[c,f],[/quark(?:pc)?\/([-\w\.]+)/i],[f,[c,"Quark"]],[/\bddg\/([\w\.]+)/i],[f,[c,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[f,[c,"UC"+A]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[f,[c,"WeChat"]],[/konqueror\/([\w\.]+)/i],[f,[c,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[f,[c,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[f,[c,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[f,[c,"Smart Lenovo "+A]],[/(avast|avg)\/([\w\.]+)/i],[[c,/(.+)/,"$1 Secure "+A],f],[/\bfocus\/([\w\.]+)/i],[f,[c,L+" Focus"]],[/\bopt\/([\w\.]+)/i],[f,[c,_+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[f,[c,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[f,[c,"Dolphin"]],[/coast\/([\w\.]+)/i],[f,[c,_+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[f,[c,"MIUI"+G]],[/fxios\/([\w\.-]+)/i],[f,[c,L]],[/\bqihoobrowser\/?([\w\.]*)/i],[f,[c,"360"]],[/\b(qq)\/([\w\.]+)/i],[[c,/(.+)/,"$1Browser"],f],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[c,/(.+)/,"$1"+G],f],[/samsungbrowser\/([\w\.]+)/i],[f,[c,O+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[f,[c,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[c,"Sogou Mobile"],f],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[c,f],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[c],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[f,c],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[c,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],[c,f],[/\bgsa\/([\w\.]+) .*safari\//i],[f,[c,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[f,[c,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[f,[c,k+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[c,k+" WebView"],f],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[f,[c,"Android "+A]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[c,f],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[f,[c,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[f,c],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[c,[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],[c,f],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[c,"Netscape"],f],[/(wolvic|librewolf)\/([\w\.]+)/i],[c,f],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[f,[c,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],[c,[f,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[c,[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],[d,[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],[d,[h,O],[u,g]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[d,[h,S],[u,g]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[d,[h,S],[u,v]],[/(macintosh);/i],[d,[h,S]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[d,[h,M],[u,g]],[/(?:honor)([-\w ]+)[;\)]/i],[d,[h,"Honor"],[u,g]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[d,[h,R],[u,v]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[d,[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],[[d,/_/g," "],[h,F],[u,g]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[d,/_/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],[d,[h,"OPPO"],[u,g]],[/\b(opd2\d{3}a?) bui/i],[d,[h,"OPPO"],[u,v]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[d,[h,"Vivo"],[u,g]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[d,[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],[d,[h,C],[u,g]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[d,[h,C],[u,v]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[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],[d,[h,P],[u,g]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[d,[h,"Lenovo"],[u,v]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[d,/_/g," "],[h,"Nokia"],[u,g]],[/(pixel c)\b/i],[d,[h,I],[u,v]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[d,[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],[d,[h,N],[u,g]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[d,"Xperia Tablet"],[h,N],[u,v]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[d,[h,"OnePlus"],[u,g]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[d,[h,w],[u,v]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[d,/(.+)/g,"Fire Phone $1"],[h,w],[u,g]],[/(playbook);[-\w\),; ]+(rim)/i],[d,h,[u,v]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[d,[h,x],[u,g]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[d,[h,T],[u,v]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[d,[h,T],[u,g]],[/(nexus 9)/i],[d,[h,"HTC"],[u,v]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[d,/_/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],[d,[h,"TCL"],[u,v]],[/(itel) ((\w+))/i],[[h,V],d,[u,K,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[d,[h,"Acer"],[u,v]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[d,[h,"Meizu"],[u,g]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[d,[h,"Ulefone"],[u,g]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[d,[h,"Energizer"],[u,g]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[d,[h,"Cat"],[u,g]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[d,[h,"Smartfren"],[u,g]],[/droid.+; (a(?:015|06[35]|142p?))/i],[d,[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,d,[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,d,[u,v]],[/(surface duo)/i],[d,[h,D],[u,v]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[d,[h,"Fairphone"],[u,g]],[/(u304aa)/i],[d,[h,"AT&T"],[u,g]],[/\bsie-(\w*)/i],[d,[h,"Siemens"],[u,g]],[/\b(rct\w+) b/i],[d,[h,"RCA"],[u,v]],[/\b(venue[\d ]{2,7}) b/i],[d,[h,"Dell"],[u,v]],[/\b(q(?:mv|ta)\w+) b/i],[d,[h,"Verizon"],[u,v]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[d,[h,"Barnes & Noble"],[u,v]],[/\b(tm\d{3}\w+) b/i],[d,[h,"NuVision"],[u,v]],[/\b(k88) b/i],[d,[h,"ZTE"],[u,v]],[/\b(nx\d{3}j) b/i],[d,[h,"ZTE"],[u,g]],[/\b(gen\d{3}) b.+49h/i],[d,[h,"Swiss"],[u,g]],[/\b(zur\d{3}) b/i],[d,[h,"Swiss"],[u,v]],[/\b((zeki)?tb.*\b) b/i],[d,[h,"Zeki"],[u,v]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,"Dragon Touch"],d,[u,v]],[/\b(ns-?\w{0,9}) b/i],[d,[h,"Insignia"],[u,v]],[/\b((nxa|next)-?\w{0,9}) b/i],[d,[h,"NextBook"],[u,v]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,"Voice"],d,[u,g]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,"LvTel"],d,[u,g]],[/\b(ph-1) /i],[d,[h,"Essential"],[u,g]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[d,[h,"Envizen"],[u,v]],[/\b(trio[-\w\. ]+) b/i],[d,[h,"MachSpeed"],[u,v]],[/\btu_(1491) b/i],[d,[h,"Rotor"],[u,v]],[/(shield[\w ]+) b/i],[d,[h,"Nvidia"],[u,v]],[/(sprint) (\w+)/i],[h,d,[u,g]],[/(kin\.[onetw]{3})/i],[[d,/\./g," "],[h,D],[u,g]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[d,[h,$],[u,v]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[d,[h,$],[u,g]],[/smart-tv.+(samsung)/i],[h,[u,y]],[/hbbtv.+maple;(\d+)/i],[[d,/^/,"SmartTV"],[h,O],[u,y]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,P],[u,y]],[/(apple) ?tv/i],[h,[d,S+" TV"],[u,y]],[/crkey/i],[[d,k+"cast"],[h,I],[u,y]],[/droid.+aft(\w+)( bui|\))/i],[d,[h,w],[u,y]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[d,[h,M],[u,y]],[/(bravia[\w ]+)( bui|\))/i],[d,[h,N],[u,y]],[/(mitv-\w{5}) bui/i],[d,[h,F],[u,y]],[/Hbbtv.*(technisat) (.*);/i],[h,d,[u,y]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,W],[d,W],[u,y]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[u,y]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,d,[u,m]],[/droid.+; (shield) bui/i],[d,[h,"Nvidia"],[u,m]],[/(playstation [345portablevi]+)/i],[d,[h,N],[u,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[d,[h,D],[u,m]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[d,[h,O],[u,b]],[/((pebble))app/i],[h,d,[u,b]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[d,[h,S],[u,b]],[/droid.+; (glass) \d/i],[d,[h,I],[u,b]],[/droid.+; (wt63?0{2,3})\)/i],[d,[h,$],[u,b]],[/droid.+; (glass) \d/i],[d,[h,I],[u,b]],[/(pico) (4|neo3(?: link|pro)?)/i],[h,d,[u,b]],[/; (quest( \d| pro)?)/i],[d,[h,B],[u,b]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[u,E]],[/(aeobc)\b/i],[d,[h,w],[u,E]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[d,[u,g]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[d,[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],[d,[h,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[f,[c,"EdgeHTML"]],[/(arkweb)\/([\w\.]+)/i],[c,f],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[f,[c,"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],[c,f],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[f,c]],os:[[/microsoft (windows) (vista|xp)/i],[c,f],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[c,[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],[c,"Windows"]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[f,/_/g,"."],[c,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[c,z],[f,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[f,c],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[c,f],[/\(bb(10);/i],[f,[c,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[f,[c,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[f,[c,L+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[f,[c,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[f,[c,"watchOS"]],[/crkey\/([\d\.]+)/i],[f,[c,k+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[c,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],[c,f],[/(sunos) ?([\w\.\d]*)/i],[[c,"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],[c,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!==s&&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[c]=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==n&&(e[c]="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[d]=i,e[u]=i,Y.call(e,y,E.device),w&&!e[u]&&b&&b.mobile&&(e[u]=g),w&&"Macintosh"==e[d]&&m&&typeof m.standalone!==s&&m.maxTouchPoints&&m.maxTouchPoints>2&&(e[d]="iPad",e[u]=v),e},this.getEngine=function(){var e={};return e[c]=i,e[f]=i,Y.call(e,y,E.engine),e},this.getOS=function(){var e={};return e[c]=i,e[f]=i,Y.call(e,y,E.os),w&&!e[c]&&b&&b.platform&&"Unknown"!=b.platform&&(e[c]=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([c,f,l]),Q.CPU=j([p]),Q.DEVICE=j([d,h,u,m,g,y,v,b,E]),Q.ENGINE=Q.OS=j([c,f]),e.exports&&(t=e.exports=Q),t.UAParser=Q;var Z=typeof r!==s&&(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:fa)),ha.exports;var e,t}var ma=function(){if(ca)return ua;ca=1,Object.defineProperty(ua,"__esModule",{value:!0});var e,r=t,i=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,n=pa(),s=new n,a=s.getBrowser(),o=s.getCPU(),l=s.getDevice(),d=s.getEngine(),c=s.getOS(),u=s.getUA(),h=function(e){return s.setUA(e)},f=function(e){if(e){var t=new n(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:s,browser:a,cpu:o,device:l,engine:d,os:c,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,n=function(e,t){if(null==e)return{};var r,i,n={},s=Object.keys(e);for(i=0;i<s.length;i++)r=s[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}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,n,s=[],a=!0,o=!1;try{for(r=r.call(e);!(a=(i=r.next()).done)&&(s.push(i.value),!t||s.length!==t);a=!0);}catch(e){o=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(o)throw n}}return s}(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",D="embedded",C=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===C},V=function(e){return e.type===P},W=function(e){return e.type===R},Y=function(e){return e.type===D},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)},ne=function(e){return e.name===_.Chrome},se=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},de=function(e){var t=e.name;return t===_.Safari||t===_.MobileSafari},ce=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,n=t.os,s=t.engine,a=t.ua;return{isSmartTV:j(r),isConsole:W(r),isWearable:V(r),isEmbedded:Y(r),isMobileSafari:ce(i)||Te(),isChromium:ae(i),isMobile:G(r)||Te(),isMobileOnly:U(r),isTablet:z(r)||Te(),isBrowser:H(r),isDesktop:H(r),isAndroid:Q(n),isWinPhone:ee(n),isIOS:te(n)||Te(),isChrome:ne(i),isFirefox:se(i),isSafari:de(i),isOpera:ue(i),isIE:he(i),osVersion:re(n),osName:ie(n),fullBrowserVersion:me(i),browserVersion:ge(i),browserName:ve(i),mobileVendor:K(r),mobileModel:q(r),engineName:ye(s),engineVersion:be(s),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(n),isMacOs:J(n),isMIUI:fe(i),isSamsungBrowser:pe(i)}}var Ie=j(l),Re=W(l),Pe=V(l),De=Y(l),Ce=ce(a)||Te(),_e=ae(a),Oe=G(l)||Te(),Me=U(l),Ne=z(l)||Te(),Fe=H(l),$e=H(l),Be=Q(c),Ue=ee(c),ze=te(c)||Te(),Ge=ne(a),je=se(a),He=de(a),Ve=ue(a),We=he(a),Ye=re(c),Ke=ie(c),qe=me(a),Xe=ge(a),Qe=ve(a),Ze=K(l),Je=q(l),et=ye(d),tt=be(d),rt=ke(u),it=oe(a)||we(u),nt=le(a),st=X(l),at=Se(),ot=Te(),lt=xe(),dt=Ae(),ct=Ee(),ut=we(u),ht=oe(a)&&!we(u),ft=Z(c),pt=J(c),mt=fe(a),gt=pe(a);function vt(e){var t=e||window.navigator.userAgent;return f(t)}return ua.AndroidView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Be?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.BrowserTypes=_,ua.BrowserView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Fe?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.ConsoleView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Re?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.CustomView=function(e){var t=e.renderWithFragment,n=e.children;e.viewClassName,e.style;var s=e.condition,a=S(e,["renderWithFragment","children","viewClassName","style","condition"]);return s?t?i.createElement(r.Fragment,null,n):i.createElement("div",a,n):null},ua.IEView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return We?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.IOSView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return ze?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.MobileOnlyView=function(e){var t=e.renderWithFragment,n=e.children;e.viewClassName,e.style;var s=S(e,["renderWithFragment","children","viewClassName","style"]);return Me?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.MobileView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Oe?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.OsTypes=O,ua.SmartTVView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Ie?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.TabletView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Ne?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.WearableView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Pe?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.WinPhoneView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Ue?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.browserName=Qe,ua.browserVersion=Xe,ua.deviceDetect=function(e){var t=e?f(e):p,r=t.device,i=t.browser,n=t.engine,s=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 C:return{isBrowser:!0};case D:return{isEmbedded:!0};default:return M}}(r.type),l=o.isBrowser,d=o.isMobile,c=o.isTablet,u=o.isSmartTV,h=o.isConsole,m=o.isWearable,g=o.isEmbedded;return l?function(e,t,r,i,n){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(n)}}(l,i,n,s,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,n,s,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,n,s,a):d||c?B(o,r,s,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,n,s,a):g?function(e,t,r,i,n){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(n)}}(g,r,n,s,a):void 0},ua.deviceType=st,ua.engineName=et,ua.engineVersion=tt,ua.fullBrowserVersion=qe,ua.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")},ua.getUA=rt,ua.isAndroid=Be,ua.isBrowser=Fe,ua.isChrome=Ge,ua.isChromium=_e,ua.isConsole=Re,ua.isDesktop=$e,ua.isEdge=it,ua.isEdgeChromium=ut,ua.isElectron=ct,ua.isEmbedded=De,ua.isFirefox=je,ua.isIE=We,ua.isIOS=ze,ua.isIOS13=at,ua.isIPad13=ot,ua.isIPhone13=lt,ua.isIPod13=dt,ua.isLegacyEdge=ht,ua.isMIUI=mt,ua.isMacOs=pt,ua.isMobile=Oe,ua.isMobileOnly=Me,ua.isMobileSafari=Ce,ua.isOpera=Ve,ua.isSafari=He,ua.isSamsungBrowser=gt,ua.isSmartTV=Ie,ua.isTablet=Ne,ua.isWearable=Pe,ua.isWinPhone=Ue,ua.isWindows=ft,ua.isYandex=nt,ua.mobileModel=Je,ua.mobileVendor=Ze,ua.osName=Ke,ua.osVersion=Ye,ua.parseUserAgent=f,ua.setUserAgent=function(e){return h(e)},ua.useDeviceData=vt,ua.useDeviceSelectors=function(e){var t=vt(e||window.navigator.userAgent);return[Le(t),t]},ua.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],n=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&&(n(),window.addEventListener("load",n,!1),window.addEventListener("resize",n,!1)),function(){window.removeEventListener("resize",n,!1),window.removeEventListener("load",n,!1)}},[n]),t},ua.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)},ua}();function ga({message:e,duration:r=3e3,visible:n,setVisible:s}){return i(()=>{const e=setTimeout(()=>s(!1),r);return()=>clearTimeout(e)},[n]),n?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 va=({shortForm:e,shareUrl:r})=>{const i=null!=r?r:window.location.href,[n,s]=a(!1);return t.createElement(t.Fragment,null,t.createElement("button",{onClick:()=>x(void 0,void 0,void 0,function*(){try{s(!0),ma.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(Kt,{size:22}),t.createElement(ga,{message:"공유 링크 복사 완료",setVisible:s,visible:n})))},ya=({product:e,hideMoreBtn:r,contentId:i})=>{const{isPreview:n,priceText:s}=ea(),[o,l]=a(!1);return t.createElement("div",{style:{height:"80px"},className:"flex gap-2 items-center w-full",onClick:()=>x(void 0,void 0,void 0,function*(){r&&(window.open(e.linkPath,"_blank"),n||(yield Gs({contentProductId:e.eventProductId,contentId:i,productId:e.productId})))})},e.thumbPath&&!o?t.createElement(er,{product:e,onError:()=>l(!0)}):t.createElement(Jt,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"}},s?s+" ":"할인가 ",t.createElement("span",{className:"font-semibold break-keep"},xt(e.sellingPrice),"원"))))};function ba(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function Ea(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function wa(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Ea(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():Ea(e[t],null)}}}}function Sa(...t){return e.useCallback(wa(...t),t)}function Ta(...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 n=i.reduce((e,{useScope:r,scopeName:i})=>({...e,...r(t)[`__scope${i}`]}),{});return e.useMemo(()=>({[`__scope${r.scopeName}`]:n}),[n])}};return i.scopeName=r.scopeName,i}var xa=globalThis?.document?e.useLayoutEffect:()=>{},Aa=e[" useId ".trim().toString()]||(()=>{}),ka=0;function La(t){const[r,i]=e.useState(Aa());return xa(()=>{t||i(e=>e??String(ka++))},[t]),t||(r?`radix-${r}`:"")}var Ia=e[" useInsertionEffect ".trim().toString()]||xa;function Ra({prop:t,defaultProp:r,onChange:i=()=>{},caller:n}){const[s,a,o]=function({defaultProp:t,onChange:r}){const[i,n]=e.useState(t),s=e.useRef(i),a=e.useRef(r);return Ia(()=>{a.current=r},[r]),e.useEffect(()=>{s.current!==i&&(a.current?.(i),s.current=i)},[i,s]),[i,n,a]}({defaultProp:r,onChange:i}),l=void 0!==t,d=l?t:s;{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(`${n} 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,n])}const c=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[d,c]}function Pa(t){const r=Da(t),i=e.forwardRef((t,i)=>{const{children:n,...s}=t,a=e.Children.toArray(n),o=a.find(_a);if(o){const t=o.props.children,n=a.map(r=>r===o?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return p(r,{...s,ref:i,children:e.isValidElement(t)?e.cloneElement(t,void 0,n):null})}return p(r,{...s,ref:i,children:n})});return i.displayName=`${t}.Slot`,i}function Da(t){const r=e.forwardRef((t,r)=>{const{children:i,...n}=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),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{const t=s(...e);return n(...e),t}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?wa(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}var Ca=Symbol("radix.slottable");function _a(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===Ca}var Oa=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=Pa(`Primitive.${r}`),n=e.forwardRef((e,t)=>{const{asChild:n,...s}=e,a=n?i:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),p(a,{...s,ref:t})});return n.displayName=`Primitive.${r}`,{...t,[r]:n}},{});function Ma(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}function Na(t,r=globalThis?.document){const i=Ma(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])}var Fa,$a="dismissableLayer.update",Ba="dismissableLayer.pointerDownOutside",Ua="dismissableLayer.focusOutside",za=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ga=e.forwardRef((t,r)=>{const{disableOutsidePointerEvents:i=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:o,onDismiss:l,...d}=t,c=e.useContext(za),[u,h]=e.useState(null),f=u?.ownerDocument??globalThis?.document,[,m]=e.useState({}),g=Sa(r,e=>h(e)),v=Array.from(c.layers),[y]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),b=v.indexOf(y),E=u?v.indexOf(u):-1,w=c.layersWithOutsidePointerEventsDisabled.size>0,S=E>=b,T=function(t,r=globalThis?.document){const i=Ma(t),n=e.useRef(!1),s=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){let t=function(){Ha(Ba,i,n,{discrete:!0})};const n={originalEvent:e};"touch"===e.pointerType?(r.removeEventListener("click",s.current),s.current=t,r.addEventListener("click",s.current,{once:!0})):t()}else r.removeEventListener("click",s.current);n.current=!1},t=window.setTimeout(()=>{r.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),r.removeEventListener("pointerdown",e),r.removeEventListener("click",s.current)}},[r,i]),{onPointerDownCapture:()=>n.current=!0}}(e=>{const t=e.target,r=[...c.branches].some(e=>e.contains(t));S&&!r&&(s?.(e),o?.(e),e.defaultPrevented||l?.())},f),x=function(t,r=globalThis?.document){const i=Ma(t),n=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){Ha(Ua,i,{originalEvent:e},{discrete:!1})}};return r.addEventListener("focusin",e),()=>r.removeEventListener("focusin",e)},[r,i]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}(e=>{const t=e.target;[...c.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||l?.())},f);return Na(e=>{E===c.layers.size-1&&(n?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),e.useEffect(()=>{if(u)return i&&(0===c.layersWithOutsidePointerEventsDisabled.size&&(Fa=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),ja(),()=>{i&&1===c.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=Fa)}},[u,f,i,c]),e.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),ja())},[u,c]),e.useEffect(()=>{const e=()=>m({});return document.addEventListener($a,e),()=>document.removeEventListener($a,e)},[]),p(Oa.div,{...d,ref:g,style:{pointerEvents:w?S?"auto":"none":void 0,...t.style},onFocusCapture:ba(t.onFocusCapture,x.onFocusCapture),onBlurCapture:ba(t.onBlurCapture,x.onBlurCapture),onPointerDownCapture:ba(t.onPointerDownCapture,T.onPointerDownCapture)})});Ga.displayName="DismissableLayer";function ja(){const e=new CustomEvent($a);document.dispatchEvent(e)}function Ha(e,t,r,{discrete:i}){const n=r.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),i?function(e,t){e&&v.flushSync(()=>e.dispatchEvent(t))}(n,s):n.dispatchEvent(s)}e.forwardRef((t,r)=>{const i=e.useContext(za),n=e.useRef(null),s=Sa(r,n);return e.useEffect(()=>{const e=n.current;if(e)return i.branches.add(e),()=>{i.branches.delete(e)}},[i.branches]),p(Oa.div,{...t,ref:s})}).displayName="DismissableLayerBranch";var Va="focusScope.autoFocusOnMount",Wa="focusScope.autoFocusOnUnmount",Ya={bubbles:!1,cancelable:!0},Ka=e.forwardRef((t,r)=>{const{loop:i=!1,trapped:n=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...o}=t,[l,d]=e.useState(null),c=Ma(s),u=Ma(a),h=e.useRef(null),f=Sa(r,e=>d(e)),m=e.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;e.useEffect(()=>{if(n){let e=function(e){if(m.paused||!l)return;const t=e.target;l.contains(t)?h.current=t:Za(h.current,{select:!0})},t=function(e){if(m.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||Za(h.current,{select:!0}))},r=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&Za(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()}}},[n,l,m.paused]),e.useEffect(()=>{if(l){Ja.add(m);const t=document.activeElement;if(!l.contains(t)){const r=new CustomEvent(Va,Ya);l.addEventListener(Va,c),l.dispatchEvent(r),r.defaultPrevented||(!function(e,{select:t=!1}={}){const r=document.activeElement;for(const i of e)if(Za(i,{select:t}),document.activeElement!==r)return}((e=qa(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&Za(l))}return()=>{l.removeEventListener(Va,c),setTimeout(()=>{const e=new CustomEvent(Wa,Ya);l.addEventListener(Wa,u),l.dispatchEvent(e),e.defaultPrevented||Za(t??document.body,{select:!0}),l.removeEventListener(Wa,u),Ja.remove(m)},0)}}var e},[l,c,u,m]);const g=e.useCallback(e=>{if(!i&&!n)return;if(m.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,r=document.activeElement;if(t&&r){const t=e.currentTarget,[n,s]=function(e){const t=qa(e),r=Xa(t,e),i=Xa(t.reverse(),e);return[r,i]}(t);n&&s?e.shiftKey||r!==s?e.shiftKey&&r===n&&(e.preventDefault(),i&&Za(s,{select:!0})):(e.preventDefault(),i&&Za(n,{select:!0})):r===t&&e.preventDefault()}},[i,n,m.paused]);return p(Oa.div,{tabIndex:-1,...o,ref:f,onKeyDown:g})});function qa(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 Xa(e,t){for(const r of e)if(!Qa(r,{upTo:t}))return r}function Qa(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 Za(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()}}Ka.displayName="FocusScope";var Ja=function(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=eo(e,t),e.unshift(t)},remove(t){e=eo(e,t),e[0]?.resume()}}}();function eo(e,t){const r=[...e],i=r.indexOf(t);return-1!==i&&r.splice(i,1),r}var to=e.forwardRef((t,r)=>{const{container:i,...n}=t,[s,a]=e.useState(!1);xa(()=>a(!0),[]);const o=i||s&&globalThis?.document?.body;return o?y.createPortal(p(Oa.div,{...n,ref:r}),o):null});to.displayName="Portal";var ro=t=>{const{present:r,children:i}=t,n=function(t){const[r,i]=e.useState(),n=e.useRef(null),s=e.useRef(t),a=e.useRef("none"),o=t?"mounted":"unmounted",[l,d]=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=io(n.current);a.current="mounted"===l?e:"none"},[l]),xa(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=io(e);if(t)d("MOUNT");else if("none"===n||"none"===e?.display)d("UNMOUNT");else{d(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,d]),xa(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=io(n.current).includes(i.animationName);if(i.target===r&&a&&(d("ANIMATION_END"),!s.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=io(n.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)}}d("ANIMATION_END")},[r,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{n.current=e?getComputedStyle(e):null,i(e)},[])}}(r),s="function"==typeof i?i({present:n.isPresent}):e.Children.only(i),a=Sa(n.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}(s));return"function"==typeof i||n.isPresent?e.cloneElement(s,{ref:a}):null};function io(e){return e?.animationName||"none"}ro.displayName="Presence";var no=0;function so(){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 ao="right-scroll-bar-position",oo="width-before-scroll-bar";function lo(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var co="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,uo=new WeakMap;function ho(e,t){var r,i,n,s=(r=null,i=function(t){return e.forEach(function(e){return lo(e,t)})},(n=a(function(){return{value:r,callback:i,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0]).callback=i,n.facade);return co(function(){var t=uo.get(s);if(t){var r=new Set(t),i=new Set(e),n=s.current;r.forEach(function(e){i.has(e)||lo(e,null)}),i.forEach(function(e){r.has(e)||lo(e,n)})}uo.set(s,e)},[e]),s}function fo(e){return e}var po=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 n=r.read();if(!n)throw new Error("Sidecar medium not found");return e.createElement(n,S({},i))};po.isSideCarExport=!0;var mo=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=fo);var r=[],i=!1,n={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 n=t(e,i);return r.push(n),function(){r=r.filter(function(e){return e!==n})}},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 n=r;r=[],n.forEach(e),t=r}var s=function(){var r=t;t=[],r.forEach(e)},a=function(){return Promise.resolve().then(s)};a(),r={push:function(e){t.push(e),a()},filter:function(e){return t=t.filter(e),r}}}};return n}(null);return t.options=S({async:!0,ssr:!1},e),t}(),go=function(){},vo=e.forwardRef(function(t,r){var i=e.useRef(null),n=e.useState({onScrollCapture:go,onWheelCapture:go,onTouchMoveCapture:go}),s=n[0],a=n[1],o=t.forwardProps,l=t.children,d=t.className,c=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=ho([i,r]),k=S(S({},w),s);return e.createElement(e.Fragment,null,u&&e.createElement(x,{sideCar:mo,removeScrollBar:c,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:d,ref:A}),l))});vo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},vo.classNames={fullWidth:oo,zeroRight:ao};function yo(){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 bo=function(){var e=0,t=null;return{add:function(r){var i,n;0==e&&(t=yo())&&(n=r,(i=t).styleSheet?i.styleSheet.cssText=n:i.appendChild(document.createTextNode(n)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Eo=function(){var t,r=(t=bo(),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}},wo={left:0,top:0,right:0,gap:0},So=function(e){return parseInt(e||"",10)||0},To=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return wo;var t=function(e){var t=window.getComputedStyle(document.body),r=t["padding"===e?"paddingLeft":"marginLeft"],i=t["padding"===e?"paddingTop":"marginTop"],n=t["padding"===e?"paddingRight":"marginRight"];return[So(r),So(i),So(n)]}(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])}},xo=Eo(),Ao="data-scroll-locked",ko=function(e,t,r,i){var n=e.left,s=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(Ao,"] {\n overflow: hidden ").concat(i,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(i,";"),"margin"===r&&"\n padding-left: ".concat(n,"px;\n padding-top: ").concat(s,"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(ao," {\n right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat(oo," {\n margin-right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat(ao," .").concat(ao," {\n right: 0 ").concat(i,";\n }\n \n .").concat(oo," .").concat(oo," {\n margin-right: 0 ").concat(i,";\n }\n \n body[").concat(Ao,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(o,"px;\n }\n")},Lo=function(){var e=parseInt(document.body.getAttribute(Ao)||"0",10);return isFinite(e)?e:0},Io=function(t){var r=t.noRelative,i=t.noImportant,n=t.gapMode,s=void 0===n?"margin":n;e.useEffect(function(){return document.body.setAttribute(Ao,(Lo()+1).toString()),function(){var e=Lo()-1;e<=0?document.body.removeAttribute(Ao):document.body.setAttribute(Ao,e.toString())}},[]);var a=e.useMemo(function(){return To(s)},[s]);return e.createElement(xo,{styles:ko(a,!r,s,i?"":"!important")})},Ro=!1;if("undefined"!=typeof window)try{var Po=Object.defineProperty({},"passive",{get:function(){return Ro=!0,!0}});window.addEventListener("test",Po,Po),window.removeEventListener("test",Po,Po)}catch(e){Ro=!1}var Do=!!Ro&&{passive:!1},Co=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])},_o=function(e,t){var r=t.ownerDocument,i=t;do{if("undefined"!=typeof ShadowRoot&&i instanceof ShadowRoot&&(i=i.host),Oo(e,i)){var n=Mo(e,i);if(n[1]>n[2])return!0}i=i.parentNode}while(i&&i!==r.body);return!1},Oo=function(e,t){return"v"===e?function(e){return Co(e,"overflowY")}(t):function(e){return Co(e,"overflowX")}(t)},Mo=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},No=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Fo=function(e){return[e.deltaX,e.deltaY]},$o=function(e){return e&&"current"in e?e.current:e},Bo=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},Uo=0,zo=[];function Go(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var jo,Ho=(jo=function(t){var r=e.useRef([]),i=e.useRef([0,0]),n=e.useRef(),s=e.useState(Uo++)[0],a=e.useState(Eo)[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(s));var e=function(e,t,r){if(r||2===arguments.length)for(var i,n=0,s=t.length;n<s;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}([t.lockRef.current],(t.shards||[]).map($o),!0).filter(Boolean);return e.forEach(function(e){return e.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),e.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(s))})}}},[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,s=No(e),a=i.current,l="deltaX"in e?e.deltaX:a[0]-s[0],d="deltaY"in e?e.deltaY:a[1]-s[1],c=e.target,u=Math.abs(l)>Math.abs(d)?"h":"v";if("touches"in e&&"h"===u&&"range"===c.type)return!1;var h=_o(u,c);if(!h)return!0;if(h?r=u:(r="v"===u?"h":"v",h=_o(u,c)),!h)return!1;if(!n.current&&"changedTouches"in e&&(l||d)&&(n.current=r),!r)return!0;var f=n.current||r;return function(e,t,r,i,n){var s=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),a=s*i,o=r.target,l=t.contains(o),d=!1,c=a>0,u=0,h=0;do{if(!o)break;var f=Mo(e,o),p=f[0],m=f[1]-f[2]-s*p;(p||m)&&Oo(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 c&&(Math.abs(u)<1||!n)?d=!0:c||!(Math.abs(h)<1)&&n||(d=!0),d}(f,t,e,"h"===f?l:d,!0)},[]),d=e.useCallback(function(e){var t=e;if(zo.length&&zo[zo.length-1]===a){var i="deltaY"in t?Fo(t):No(t),n=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(n&&n.should)t.cancelable&&t.preventDefault();else if(!n){var s=(o.current.shards||[]).map($o).filter(Boolean).filter(function(e){return e.contains(t.target)});(s.length>0?l(t,s[0]):!o.current.noIsolation)&&t.cancelable&&t.preventDefault()}}},[]),c=e.useCallback(function(e,t,i,n){var s={name:e,delta:t,target:i,should:n,shadowParent:Go(i)};r.current.push(s),setTimeout(function(){r.current=r.current.filter(function(e){return e!==s})},1)},[]),u=e.useCallback(function(e){i.current=No(e),n.current=void 0},[]),h=e.useCallback(function(e){c(e.type,Fo(e),e.target,l(e,t.lockRef.current))},[]),f=e.useCallback(function(e){c(e.type,No(e),e.target,l(e,t.lockRef.current))},[]);e.useEffect(function(){return zo.push(a),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",d,Do),document.addEventListener("touchmove",d,Do),document.addEventListener("touchstart",u,Do),function(){zo=zo.filter(function(e){return e!==a}),document.removeEventListener("wheel",d,Do),document.removeEventListener("touchmove",d,Do),document.removeEventListener("touchstart",u,Do)}},[]);var p=t.removeScrollBar,m=t.inert;return e.createElement(e.Fragment,null,m?e.createElement(a,{styles:Bo(s)}):null,p?e.createElement(Io,{noRelative:t.noRelative,gapMode:t.gapMode}):null)},mo.useMedium(jo),po),Vo=e.forwardRef(function(t,r){return e.createElement(vo,S({},t,{ref:r,sideCar:Ho}))});Vo.classNames=vo.classNames;var Wo=new WeakMap,Yo=new WeakMap,Ko={},qo=0,Xo=function(e){return e&&(e.host||Xo(e.parentNode))},Qo=function(e,t,r,i){var n=function(e,t){return t.map(function(t){if(e.contains(t))return t;var r=Xo(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]);Ko[r]||(Ko[r]=new WeakMap);var s=Ko[r],a=[],o=new Set,l=new Set(n),d=function(e){e&&!o.has(e)&&(o.add(e),d(e.parentNode))};n.forEach(d);var c=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(o.has(e))c(e);else try{var t=e.getAttribute(i),n=null!==t&&"false"!==t,l=(Wo.get(e)||0)+1,d=(s.get(e)||0)+1;Wo.set(e,l),s.set(e,d),a.push(e),1===l&&n&&Yo.set(e,!0),1===d&&e.setAttribute(r,"true"),n||e.setAttribute(i,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return c(t),o.clear(),qo++,function(){a.forEach(function(e){var t=Wo.get(e)-1,n=s.get(e)-1;Wo.set(e,t),s.set(e,n),t||(Yo.has(e)||e.removeAttribute(i),Yo.delete(e)),n||e.removeAttribute(r)}),--qo||(Wo=new WeakMap,Wo=new WeakMap,Yo=new WeakMap,Ko={})}},Zo=function(e,t,r){void 0===r&&(r="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),n=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return n?(i.push.apply(i,Array.from(n.querySelectorAll("[aria-live], script"))),Qo(i,n,r,"aria-hidden")):function(){return null}},Jo="Dialog",[el,tl]=function(t,r=[]){let i=[];const n=()=>{const r=i.map(t=>e.createContext(t));return function(i){const n=i?.[t]||r;return e.useMemo(()=>({[`__scope${t}`]:{...i,[t]:n}}),[i,n])}};return n.scopeName=t,[function(r,n){const s=e.createContext(n),a=i.length;i=[...i,n];const o=r=>{const{scope:i,children:n,...o}=r,l=i?.[t]?.[a]||s,d=e.useMemo(()=>o,Object.values(o));return p(l.Provider,{value:d,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,d=e.useContext(l);if(d)return d;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},Ta(n,...r)]}(Jo),[rl,il]=el(Jo),nl=t=>{const{__scopeDialog:r,children:i,open:n,defaultOpen:s,onOpenChange:a,modal:o=!0}=t,l=e.useRef(null),d=e.useRef(null),[c,u]=Ra({prop:n,defaultProp:s??!1,onChange:a,caller:Jo});return p(rl,{scope:r,triggerRef:l,contentRef:d,contentId:La(),titleId:La(),descriptionId:La(),open:c,onOpenChange:u,onOpenToggle:e.useCallback(()=>u(e=>!e),[u]),modal:o,children:i})};nl.displayName=Jo;var sl="DialogTrigger",al=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=il(sl,r),s=Sa(t,n.triggerRef);return p(Oa.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":kl(n.open),...i,ref:s,onClick:ba(e.onClick,n.onOpenToggle)})});al.displayName=sl;var ol="DialogPortal",[ll,dl]=el(ol,{forceMount:void 0}),cl=t=>{const{__scopeDialog:r,forceMount:i,children:n,container:s}=t,a=il(ol,r);return p(ll,{scope:r,forceMount:i,children:e.Children.map(n,e=>p(ro,{present:i||a.open,children:p(to,{asChild:!0,container:s,children:e})}))})};cl.displayName=ol;var ul="DialogOverlay",hl=e.forwardRef((e,t)=>{const r=dl(ul,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=il(ul,e.__scopeDialog);return s.modal?p(ro,{present:i||s.open,children:p(pl,{...n,ref:t})}):null});hl.displayName=ul;var fl=Pa("DialogOverlay.RemoveScroll"),pl=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=il(ul,r);return p(Vo,{as:fl,allowPinchZoom:!0,shards:[n.contentRef],children:p(Oa.div,{"data-state":kl(n.open),...i,ref:t,style:{pointerEvents:"auto",...i.style}})})}),ml="DialogContent",gl=e.forwardRef((e,t)=>{const r=dl(ml,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=il(ml,e.__scopeDialog);return p(ro,{present:i||s.open,children:s.modal?p(vl,{...n,ref:t}):p(yl,{...n,ref:t})})});gl.displayName=ml;var vl=e.forwardRef((t,r)=>{const i=il(ml,t.__scopeDialog),n=e.useRef(null),s=Sa(r,i.contentRef,n);return e.useEffect(()=>{const e=n.current;if(e)return Zo(e)},[]),p(bl,{...t,ref:s,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ba(t.onCloseAutoFocus,e=>{e.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:ba(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;(2===t.button||r)&&e.preventDefault()}),onFocusOutside:ba(t.onFocusOutside,e=>e.preventDefault())})}),yl=e.forwardRef((t,r)=>{const i=il(ml,t.__scopeDialog),n=e.useRef(!1),s=e.useRef(!1);return p(bl,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),e.defaultPrevented||(n.current||i.triggerRef.current?.focus(),e.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:e=>{t.onInteractOutside?.(e),e.defaultPrevented||(n.current=!0,"pointerdown"===e.detail.originalEvent.type&&(s.current=!0));const r=e.target,a=i.triggerRef.current?.contains(r);a&&e.preventDefault(),"focusin"===e.detail.originalEvent.type&&s.current&&e.preventDefault()}})}),bl=e.forwardRef((t,r)=>{const{__scopeDialog:i,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:a,...o}=t,l=il(ml,i),d=e.useRef(null),c=Sa(r,d);return e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??so()),document.body.insertAdjacentElement("beforeend",e[1]??so()),no++,()=>{1===no&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),no--}},[]),g(m,{children:[p(Ka,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:a,children:p(Ga,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":kl(l.open),...o,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),g(m,{children:[p(Pl,{titleId:l.titleId}),p(Dl,{contentRef:d,descriptionId:l.descriptionId})]})]})}),El="DialogTitle",wl=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=il(El,r);return p(Oa.h2,{id:n.titleId,...i,ref:t})});wl.displayName=El;var Sl="DialogDescription",Tl=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=il(Sl,r);return p(Oa.p,{id:n.descriptionId,...i,ref:t})});Tl.displayName=Sl;var xl="DialogClose",Al=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=il(xl,r);return p(Oa.button,{type:"button",...i,ref:t,onClick:ba(e.onClick,()=>n.onOpenChange(!1))})});function kl(e){return e?"open":"closed"}Al.displayName=xl;var Ll="DialogTitleWarning",[Il,Rl]=function(t,r){const i=e.createContext(r),n=t=>{const{children:r,...n}=t,s=e.useMemo(()=>n,Object.values(n));return p(i.Provider,{value:s,children:r})};return n.displayName=t+"Provider",[n,function(n){const s=e.useContext(i);if(s)return s;if(void 0!==r)return r;throw new Error(`\`${n}\` must be used within \`${t}\``)}]}(Ll,{contentName:ml,titleName:El,docsSlug:"dialog"}),Pl=({titleId:t})=>{const r=Rl(Ll),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},Dl=({contentRef:t,descriptionId:r})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Rl("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},Cl=nl,_l=al,Ol=cl,Ml=hl,Nl=gl,Fl=wl,$l=Tl,Bl=Al;const Ul=t.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),zl=()=>{const e=t.useContext(Ul);if(!e)throw new Error("useDrawerContext must be used within a Drawer.Root");return e};function Gl(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function jl(){return Vl(/^iPad/)||Vl(/^Mac/)&&navigator.maxTouchPoints>1}function Hl(){return Vl(/^iPhone/)||jl()}function Vl(e){return"undefined"!=typeof window&&null!=window.navigator?e.test(window.navigator.platform):void 0}!function(e){if("undefined"==typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}("[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(\n[data-state=closed]\n){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}");const Wl="undefined"!=typeof window?o:i;function Yl(...e){return(...t)=>{for(let r of e)"function"==typeof r&&r(...t)}}const Kl="undefined"!=typeof document&&window.visualViewport;function ql(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function Xl(e){for(ql(e)&&(e=e.parentElement);e&&!ql(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}const Ql=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let Zl,Jl=0;function ed(e={}){let{isDisabled:t}=e;Wl(()=>{if(!t)return Jl++,1===Jl&&Hl()&&(Zl=function(){let e,t=0,r=r=>{e=Xl(r.target),e===document.documentElement&&e===document.body||(t=r.changedTouches[0].pageY)},i=r=>{if(!e||e===document.documentElement||e===document.body)return void r.preventDefault();let i=r.changedTouches[0].pageY,n=e.scrollTop,s=e.scrollHeight-e.clientHeight;0!==s&&((n<=0&&i>t||n>=s&&i<t)&&r.preventDefault(),t=i)},n=e=>{let t=e.target;id(t)&&t!==document.activeElement&&(e.preventDefault(),t.style.transform="translateY(-2000px)",t.focus(),requestAnimationFrame(()=>{t.style.transform=""}))},s=e=>{let t=e.target;id(t)&&(t.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{t.style.transform="",Kl&&(Kl.height<window.innerHeight?requestAnimationFrame(()=>{rd(t)}):Kl.addEventListener("resize",()=>rd(t),{once:!0}))}))},a=()=>{window.scrollTo(0,0)},o=window.pageXOffset,l=window.pageYOffset,d=Yl(function(e,t,r){let i=e.style[t];return e.style[t]=r,()=>{e.style[t]=i}}(document.documentElement,"paddingRight",window.innerWidth-document.documentElement.clientWidth+"px"));window.scrollTo(0,0);let c=Yl(td(document,"touchstart",r,{passive:!1,capture:!0}),td(document,"touchmove",i,{passive:!1,capture:!0}),td(document,"touchend",n,{passive:!1,capture:!0}),td(document,"focus",s,!0),td(window,"scroll",a));return()=>{d(),c(),window.scrollTo(o,l)}}()),()=>{Jl--,0===Jl&&(null==Zl||Zl())}},[t])}function td(e,t,r,i){return e.addEventListener(t,r,i),()=>{e.removeEventListener(t,r,i)}}function rd(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let t=Xl(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let r=t.getBoundingClientRect().top,i=e.getBoundingClientRect().top;e.getBoundingClientRect().bottom>t.getBoundingClientRect().bottom+24&&(t.scrollTop+=i-r)}e=t.parentElement}}function id(e){return e instanceof HTMLInputElement&&!Ql.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function nd(...t){return e.useCallback(function(...e){return t=>e.forEach(e=>function(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}(e,t))}(...t),t)}const sd=new WeakMap;function ad(e,t,r=!1){if(!(e&&e instanceof HTMLElement))return;let i={};Object.entries(t).forEach(([t,r])=>{t.startsWith("--")?e.style.setProperty(t,r):(i[t]=e.style[t],e.style[t]=r)}),r||sd.set(e,i)}const od=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function ld(e,t){if(!e)return null;const r=window.getComputedStyle(e),i=r.transform||r.webkitTransform||r.mozTransform;let n=i.match(/^matrix3d\((.+)\)$/);return n?parseFloat(n[1].split(", ")[od(t)?13:12]):(n=i.match(/^matrix\((.+)\)$/),n?parseFloat(n[1].split(", ")[od(t)?5:4]):null)}function dd(e,t){if(!e)return()=>{};const r=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=r}}const cd={DURATION:.5,EASE:[.32,.72,0,1]},ud=16,hd="vaul-dragging";function fd(e){const r=t.useRef(e);return t.useEffect(()=>{r.current=e}),t.useMemo(()=>(...e)=>null==r.current?void 0:r.current.call(r,...e),[])}function pd({prop:e,defaultProp:r,onChange:i=()=>{}}){const[n,s]=function({defaultProp:e,onChange:r}){const i=t.useState(e),[n]=i,s=t.useRef(n),a=fd(r);return t.useEffect(()=>{s.current!==n&&(a(n),s.current=n)},[n,s,a]),i}({defaultProp:r,onChange:i}),a=void 0!==e,o=a?e:n,l=fd(i),d=t.useCallback(t=>{if(a){const r="function"==typeof t?t(e):t;r!==e&&l(r)}else s(t)},[a,e,s,l]);return[o,d]}let md=null;function gd({open:e,onOpenChange:r,children:i,onDrag:n,onRelease:s,snapPoints:a,shouldScaleBackground:o=!1,setBackgroundColorOnScale:l=!0,closeThreshold:d=.25,scrollLockTimeout:c=100,dismissible:u=!0,handleOnly:h=!1,fadeFromIndex:f=a&&a.length-1,activeSnapPoint:p,setActiveSnapPoint:m,fixed:g,modal:v=!0,onClose:y,nested:b,noBodyStyles:E=!1,direction:w="bottom",defaultOpen:S=!1,disablePreventScroll:T=!0,snapToSequentialPoint:x=!1,preventScrollRestoration:A=!1,repositionInputs:k=!0,onAnimationEnd:L,container:I,autoFocus:R=!1}){var P,D;const[C=!1,_]=pd({defaultProp:S,prop:e,onChange:e=>{null==r||r(e),e||b||ce(),setTimeout(()=>{null==L||L(e)},1e3*cd.DURATION),e&&!v&&"undefined"!=typeof window&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),e||(document.body.style.pointerEvents="auto")}}),[O,M]=t.useState(!1),[N,F]=t.useState(!1),[$,B]=t.useState(!1),U=t.useRef(null),z=t.useRef(null),G=t.useRef(null),j=t.useRef(null),H=t.useRef(null),V=t.useRef(!1),W=t.useRef(null),Y=t.useRef(0),K=t.useRef(!1),q=t.useRef(!S),X=t.useRef(0),Q=t.useRef(null),Z=t.useRef((null==(P=Q.current)?void 0:P.getBoundingClientRect().height)||0),J=t.useRef((null==(D=Q.current)?void 0:D.getBoundingClientRect().width)||0),ee=t.useRef(0),te=t.useCallback(e=>{a&&e===ae.length-1&&(z.current=new Date)},[]),{activeSnapPoint:re,activeSnapPointIndex:ie,setActiveSnapPoint:ne,onRelease:se,snapPointsOffset:ae,onDrag:oe,shouldFade:le,getPercentageDragged:de}=function({activeSnapPointProp:e,setActiveSnapPointProp:r,snapPoints:i,drawerRef:n,overlayRef:s,fadeFromIndex:a,onSnapPointChange:o,direction:l="bottom",container:d,snapToSequentialPoint:c}){const[u,h]=pd({prop:e,defaultProp:null==i?void 0:i[0],onChange:r}),[f,p]=t.useState("undefined"!=typeof window?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);t.useEffect(()=>{function e(){p({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const m=t.useMemo(()=>u===(null==i?void 0:i[i.length-1])||null,[i,u]),g=t.useMemo(()=>{var e;return null!=(e=null==i?void 0:i.findIndex(e=>e===u))?e:null},[i,u]),v=i&&i.length>0&&(a||0===a)&&!Number.isNaN(a)&&i[a]===u||!i,y=t.useMemo(()=>{const e=d?{width:d.getBoundingClientRect().width,height:d.getBoundingClientRect().height}:"undefined"!=typeof window?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var t;return null!=(t=null==i?void 0:i.map(t=>{const r="string"==typeof t;let i=0;if(r&&(i=parseInt(t,10)),od(l)){const n=r?i:f?t*e.height:0;return f?"bottom"===l?e.height-n:-e.height+n:n}const n=r?i:f?t*e.width:0;return f?"right"===l?e.width-n:-e.width+n:n}))?t:[]},[i,f,d]),b=t.useMemo(()=>null!==g?null==y?void 0:y[g]:null,[y,g]),E=t.useCallback(e=>{var t;const r=null!=(t=null==y?void 0:y.findIndex(t=>t===e))?t:null;o(r),ad(n.current,{transition:`transform ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`,transform:od(l)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`}),y&&r!==y.length-1&&void 0!==a&&r!==a&&r<a?ad(s.current,{transition:`opacity ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`,opacity:"0"}):ad(s.current,{transition:`opacity ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`,opacity:"1"}),h(null==i?void 0:i[Math.max(r,0)])},[n.current,i,y,a,s,h]);return t.useEffect(()=>{if(u||e){var t;const r=null!=(t=null==i?void 0:i.findIndex(t=>t===e||t===u))?t:-1;y&&-1!==r&&"number"==typeof y[r]&&E(y[r])}},[u,e,i,y,E]),{isLastSnapPoint:m,activeSnapPoint:u,shouldFade:v,getPercentageDragged:function(e,t){if(!i||"number"!=typeof g||!y||void 0===a)return null;const r=g===a-1;if(g>=a&&t)return 0;if(r&&!t)return 1;if(!v&&!r)return null;const n=r?g+1:g-1,s=r?y[n]-y[n-1]:y[n+1]-y[n],o=e/Math.abs(s);return r?1-o:o},setActiveSnapPoint:h,activeSnapPointIndex:g,onRelease:function({draggedDistance:e,closeDrawer:t,velocity:r,dismissible:n}){if(void 0===a)return;const o="bottom"===l||"right"===l?(null!=b?b:0)-e:(null!=b?b:0)+e,d=0===g,u=e>0;if(g===a-1&&ad(s.current,{transition:`opacity ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`}),!c&&r>2&&!u)return void(n?t():E(y[0]));if(!c&&r>2&&u&&y&&i)return void E(y[i.length-1]);const h=null==y?void 0:y.reduce((e,t)=>"number"!=typeof e||"number"!=typeof t?e:Math.abs(t-o)<Math.abs(e-o)?t:e),f=od(l)?window.innerHeight:window.innerWidth;if(r>.4&&Math.abs(e)<.4*f){const e=u?1:-1;if(e>0&&m&&i)return void E(y[i.length-1]);if(d&&e<0&&n&&t(),null===g)return;return void E(y[g+e])}E(h)},onDrag:function({draggedDistance:e}){if(null===b)return;const t="bottom"===l||"right"===l?b-e:b+e;("bottom"===l||"right"===l)&&t<y[y.length-1]||("top"===l||"left"===l)&&t>y[y.length-1]||ad(n.current,{transform:od(l)?`translate3d(0, ${t}px, 0)`:`translate3d(${t}px, 0, 0)`})},snapPointsOffset:y}}({snapPoints:a,activeSnapPointProp:p,setActiveSnapPointProp:m,drawerRef:Q,fadeFromIndex:f,overlayRef:U,onSnapPointChange:te,direction:w,container:I,snapToSequentialPoint:x});ed({isDisabled:!C||N||!v||$||!O||!k||!T});const{restorePositionSetting:ce}=function({isOpen:e,modal:r,nested:i,hasBeenOpened:n,preventScrollRestoration:s,noBodyStyles:a}){const[o,l]=t.useState(()=>"undefined"!=typeof window?window.location.href:""),d=t.useRef(0),c=t.useCallback(()=>{if(Gl()&&null===md&&e&&!a){md={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:e,innerHeight:t}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:-d.current+"px",left:-e+"px",right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const e=t-window.innerHeight;e&&d.current>=t&&(document.body.style.top=-(d.current+e)+"px")}),300)}},[e]),u=t.useCallback(()=>{if(Gl()&&null!==md&&!a){const e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);Object.assign(document.body.style,md),window.requestAnimationFrame(()=>{s&&o!==window.location.href?l(window.location.href):window.scrollTo(t,e)}),md=null}},[o]);return t.useEffect(()=>{function e(){d.current=window.scrollY}return e(),window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}},[]),t.useEffect(()=>{if(r)return()=>{"undefined"!=typeof document&&(document.querySelector("[data-vaul-drawer]")||u())}},[r,u]),t.useEffect(()=>{!i&&n&&(e?(!window.matchMedia("(display-mode: standalone)").matches&&c(),r||window.setTimeout(()=>{u()},500)):u())},[e,n,o,r,i,c,u]),{restorePositionSetting:u}}({isOpen:C,modal:v,nested:null!=b&&b,hasBeenOpened:O,preventScrollRestoration:A,noBodyStyles:E});function ue(){return(window.innerWidth-26)/window.innerWidth}function he(e,t){var r;let i=e;const n=null==(r=window.getSelection())?void 0:r.toString(),s=Q.current?ld(Q.current,w):null,a=new Date;if("SELECT"===i.tagName)return!1;if(i.hasAttribute("data-vaul-no-drag")||i.closest("[data-vaul-no-drag]"))return!1;if("right"===w||"left"===w)return!0;if(z.current&&a.getTime()-z.current.getTime()<500)return!1;if(null!==s&&("bottom"===w?s>0:s<0))return!0;if(n&&n.length>0)return!1;if(H.current&&a.getTime()-H.current.getTime()<c&&0===s)return H.current=a,!1;if(t)return H.current=a,!1;for(;i;){if(i.scrollHeight>i.clientHeight){if(0!==i.scrollTop)return H.current=new Date,!1;if("dialog"===i.getAttribute("role"))return!0}i=i.parentNode}return!0}function fe(e){!function(){if(!N||!Q.current)return;Q.current.classList.remove(hd),V.current=!1,F(!1),j.current=new Date}(),null==y||y(),e||_(!1),setTimeout(()=>{a&&ne(a[0])},1e3*cd.DURATION)}function pe(){if(!Q.current)return;const e=document.querySelector("[data-vaul-drawer-wrapper]"),t=ld(Q.current,w);ad(Q.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`}),ad(U.current,{transition:`opacity ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`,opacity:"1"}),o&&t&&t>0&&C&&ad(e,{borderRadius:"8px",overflow:"hidden",...od(w)?{transform:`scale(${ue()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${ue()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${cd.DURATION}s`,transitionTimingFunction:`cubic-bezier(${cd.EASE.join(",")})`},!0)}return t.useEffect(()=>{window.requestAnimationFrame(()=>{q.current=!0})},[]),t.useEffect(()=>{var e;function t(){if(!Q.current||!k)return;if(id(document.activeElement)||K.current){var e;const t=(null==(e=window.visualViewport)?void 0:e.height)||0,r=window.innerHeight;let i=r-t;const n=Q.current.getBoundingClientRect().height||0,s=n>.8*r;ee.current||(ee.current=n);const o=Q.current.getBoundingClientRect().top;if(Math.abs(X.current-i)>60&&(K.current=!K.current),a&&a.length>0&&ae&&ie){i+=ae[ie]||0}if(X.current=i,n>t||K.current){const e=Q.current.getBoundingClientRect().height;let r=e;e>t&&(r=t-(s?o:26)),Q.current.style.height=g?e-Math.max(i,0)+"px":`${Math.max(r,t-o)}px`}else(function(){const e=navigator.userAgent;return"undefined"!=typeof window&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))})()||(Q.current.style.height=`${ee.current}px`);a&&a.length>0&&!K.current?Q.current.style.bottom="0px":Q.current.style.bottom=`${Math.max(i,0)}px`}}return null==(e=window.visualViewport)||e.addEventListener("resize",t),()=>{var e;return null==(e=window.visualViewport)?void 0:e.removeEventListener("resize",t)}},[ie,a,ae]),t.useEffect(()=>(C&&(ad(document.documentElement,{scrollBehavior:"auto"}),z.current=new Date),()=>{!function(e,t){if(!(e&&e instanceof HTMLElement))return;let r=sd.get(e);r&&(e.style[t]=r[t])}(document.documentElement,"scrollBehavior")}),[C]),t.useEffect(()=>{v||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[v]),t.createElement(Cl,{defaultOpen:S,onOpenChange:e=>{(u||e)&&(e?M(!0):fe(!0),_(e))},open:C},t.createElement(Ul.Provider,{value:{activeSnapPoint:re,snapPoints:a,setActiveSnapPoint:ne,drawerRef:Q,overlayRef:U,onOpenChange:r,onPress:function(e){var t,r;(u||a)&&(Q.current&&!Q.current.contains(e.target)||(Z.current=(null==(t=Q.current)?void 0:t.getBoundingClientRect().height)||0,J.current=(null==(r=Q.current)?void 0:r.getBoundingClientRect().width)||0,F(!0),G.current=new Date,Hl()&&window.addEventListener("touchend",()=>V.current=!1,{once:!0}),e.target.setPointerCapture(e.pointerId),Y.current=od(w)?e.pageY:e.pageX))},onRelease:function(e){if(!N||!Q.current)return;Q.current.classList.remove(hd),V.current=!1,F(!1),j.current=new Date;const t=ld(Q.current,w);if(!e||!he(e.target,!1)||!t||Number.isNaN(t))return;if(null===G.current)return;const r=j.current.getTime()-G.current.getTime(),i=Y.current-(od(w)?e.pageY:e.pageX),n=Math.abs(i)/r;if(n>.05&&(B(!0),setTimeout(()=>{B(!1)},200)),a){return se({draggedDistance:i*("bottom"===w||"right"===w?1:-1),closeDrawer:fe,velocity:n,dismissible:u}),void(null==s||s(e,!0))}if("bottom"===w||"right"===w?i>0:i<0)return pe(),void(null==s||s(e,!0));if(n>.4)return fe(),void(null==s||s(e,!1));var o;const l=Math.min(null!=(o=Q.current.getBoundingClientRect().height)?o:0,window.innerHeight);var c;const h=Math.min(null!=(c=Q.current.getBoundingClientRect().width)?c:0,window.innerWidth),f="left"===w||"right"===w;if(Math.abs(t)>=(f?h:l)*d)return fe(),void(null==s||s(e,!1));null==s||s(e,!0),pe()},onDrag:function(e){if(Q.current&&N){const t="bottom"===w||"right"===w?1:-1,r=(Y.current-(od(w)?e.pageY:e.pageX))*t,i=r>0,s=a&&!u&&!i;if(s&&0===ie)return;const l=Math.abs(r),d=document.querySelector("[data-vaul-drawer-wrapper]");let c=l/("bottom"===w||"top"===w?Z.current:J.current);const h=de(l,i);if(null!==h&&(c=h),s&&c>=1)return;if(!V.current&&!he(e.target,i))return;if(Q.current.classList.add(hd),V.current=!0,ad(Q.current,{transition:"none"}),ad(U.current,{transition:"none"}),a&&oe({draggedDistance:r}),i&&!a){const e=function(e){return 8*(Math.log(e+1)-2)}(r),i=Math.min(-1*e,0)*t;return void ad(Q.current,{transform:od(w)?`translate3d(0, ${i}px, 0)`:`translate3d(${i}px, 0, 0)`})}const p=1-c;if((le||f&&ie===f-1)&&(null==n||n(e,c),ad(U.current,{opacity:`${p}`,transition:"none"},!0)),d&&U.current&&o){const e=Math.min(ue()+c*(1-ue()),1),t=8-8*c,r=Math.max(0,14-14*c);ad(d,{borderRadius:`${t}px`,transform:od(w)?`scale(${e}) translate3d(0, ${r}px, 0)`:`scale(${e}) translate3d(${r}px, 0, 0)`,transition:"none"},!0)}if(!a){const e=l*t;ad(Q.current,{transform:od(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})}}},dismissible:u,shouldAnimate:q,handleOnly:h,isOpen:C,isDragging:N,shouldFade:le,closeDrawer:fe,onNestedDrag:function(e,t){if(t<0)return;const r=(window.innerWidth-ud)/window.innerWidth,i=r+t*(1-r),n=t*ud-16;ad(Q.current,{transform:od(w)?`scale(${i}) translate3d(0, ${n}px, 0)`:`scale(${i}) translate3d(${n}px, 0, 0)`,transition:"none"})},onNestedOpenChange:function(e){const t=e?(window.innerWidth-ud)/window.innerWidth:1,r=e?-16:0;W.current&&window.clearTimeout(W.current),ad(Q.current,{transition:`transform ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`,transform:od(w)?`scale(${t}) translate3d(0, ${r}px, 0)`:`scale(${t}) translate3d(${r}px, 0, 0)`}),!e&&Q.current&&(W.current=setTimeout(()=>{const e=ld(Q.current,w);ad(Q.current,{transition:"none",transform:od(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})},500))},onNestedRelease:function(e,t){const r=od(w)?window.innerHeight:window.innerWidth,i=t?(r-ud)/r:1,n=t?-16:0;t&&ad(Q.current,{transition:`transform ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`,transform:od(w)?`scale(${i}) translate3d(0, ${n}px, 0)`:`scale(${i}) translate3d(${n}px, 0, 0)`})},keyboardIsOpen:K,modal:v,snapPointsOffset:ae,activeSnapPointIndex:ie,direction:w,shouldScaleBackground:o,setBackgroundColorOnScale:l,noBodyStyles:E,container:I,autoFocus:R}},i))}const vd=t.forwardRef(function({...e},r){const{overlayRef:i,snapPoints:n,onRelease:s,shouldFade:a,isOpen:o,modal:l,shouldAnimate:d}=zl(),c=nd(r,i),u=n&&n.length>0;if(!l)return null;const h=t.useCallback(e=>s(e),[s]);return t.createElement(Ml,{onMouseUp:h,ref:c,"data-vaul-overlay":"","data-vaul-snap-points":o&&u?"true":"false","data-vaul-snap-points-overlay":o&&a?"true":"false","data-vaul-animate":(null==d?void 0:d.current)?"true":"false",...e})});vd.displayName="Drawer.Overlay";const yd=t.forwardRef(function({onPointerDownOutside:e,style:r,onOpenAutoFocus:i,...n},s){const{drawerRef:a,onPress:o,onRelease:l,onDrag:d,keyboardIsOpen:c,snapPointsOffset:h,activeSnapPointIndex:f,modal:p,isOpen:m,direction:g,snapPoints:v,container:y,handleOnly:b,shouldAnimate:E,autoFocus:w}=zl(),[S,T]=t.useState(!1),x=nd(s,a),A=t.useRef(null),k=t.useRef(null),L=t.useRef(!1),I=v&&v.length>0;!function(){const{direction:e,isOpen:r,shouldScaleBackground:i,setBackgroundColorOnScale:n,noBodyStyles:s}=zl(),a=t.useRef(null),o=u(()=>document.body.style.backgroundColor,[]);function l(){return(window.innerWidth-26)/window.innerWidth}t.useEffect(()=>{if(r&&i){a.current&&clearTimeout(a.current);const t=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!t)return;n&&!s&&dd(document.body,{background:"black"}),dd(t,{transformOrigin:od(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${cd.DURATION}s`,transitionTimingFunction:`cubic-bezier(${cd.EASE.join(",")})`});const r=dd(t,{borderRadius:"8px",overflow:"hidden",...od(e)?{transform:`scale(${l()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${l()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{r(),a.current=window.setTimeout(()=>{o?document.body.style.background=o:document.body.style.removeProperty("background")},1e3*cd.DURATION)}}},[r,i,o])}();function R(e){A.current=null,L.current=!1,l(e)}return t.useEffect(()=>{I&&window.requestAnimationFrame(()=>{T(!0)})},[]),t.createElement(Nl,{"data-vaul-drawer-direction":g,"data-vaul-drawer":"","data-vaul-delayed-snap-points":S?"true":"false","data-vaul-snap-points":m&&I?"true":"false","data-vaul-custom-container":y?"true":"false","data-vaul-animate":(null==E?void 0:E.current)?"true":"false",...n,ref:x,style:h&&h.length>0?{"--snap-point-height":`${h[null!=f?f:0]}px`,...r}:r,onPointerDown:e=>{b||(null==n.onPointerDown||n.onPointerDown.call(n,e),A.current={x:e.pageX,y:e.pageY},o(e))},onOpenAutoFocus:e=>{null==i||i(e),w||e.preventDefault()},onPointerDownOutside:t=>{null==e||e(t),p&&!t.defaultPrevented?c.current&&(c.current=!1):t.preventDefault()},onFocusOutside:e=>{p||e.preventDefault()},onPointerMove:e=>{if(k.current=e,b)return;if(null==n.onPointerMove||n.onPointerMove.call(n,e),!A.current)return;const t=e.pageY-A.current.y,r=e.pageX-A.current.x,i="touch"===e.pointerType?10:2,s=((e,t,r=0)=>{if(L.current)return!0;const i=Math.abs(e.y),n=Math.abs(e.x),s=n>i,a=["bottom","right"].includes(t)?1:-1;if("left"===t||"right"===t){if(!(e.x*a<0)&&n>=0&&n<=r)return s}else if(!(e.y*a<0)&&i>=0&&i<=r)return!s;return L.current=!0,!0})({x:r,y:t},g,i);s?d(e):(Math.abs(r)>i||Math.abs(t)>i)&&(A.current=null)},onPointerUp:e=>{null==n.onPointerUp||n.onPointerUp.call(n,e),A.current=null,L.current=!1,l(e)},onPointerOut:e=>{null==n.onPointerOut||n.onPointerOut.call(n,e),R(k.current)},onContextMenu:e=>{null==n.onContextMenu||n.onContextMenu.call(n,e),k.current&&R(k.current)}})});yd.displayName="Drawer.Content";const bd=t.forwardRef(function({preventCycle:e=!1,children:r,...i},n){const{closeDrawer:s,isDragging:a,snapPoints:o,activeSnapPoint:l,setActiveSnapPoint:d,dismissible:c,handleOnly:u,isOpen:h,onPress:f,onDrag:p}=zl(),m=t.useRef(null),g=t.useRef(!1);function v(){m.current&&window.clearTimeout(m.current),g.current=!1}return t.createElement("div",{onClick:function(){g.current?v():window.setTimeout(()=>{!function(){if(a||e||g.current)return void v();if(v(),!o||0===o.length)return void(c||s());if(l===o[o.length-1]&&c)return void s();const t=o.findIndex(e=>e===l);if(-1===t)return;const r=o[t+1];d(r)}()},120)},onPointerCancel:v,onPointerDown:e=>{u&&f(e),m.current=window.setTimeout(()=>{g.current=!0},250)},onPointerMove:e=>{u&&p(e)},ref:n,"data-vaul-drawer-visible":h?"true":"false","data-vaul-handle":"","aria-hidden":"true",...i},t.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},r))});bd.displayName="Drawer.Handle";const Ed={Root:gd,NestedRoot:function({onDrag:e,onOpenChange:r,open:i,...n}){const{onNestedDrag:s,onNestedOpenChange:a,onNestedRelease:o}=zl();if(!s)throw new Error("Drawer.NestedRoot must be placed in another drawer");return t.createElement(gd,{nested:!0,open:i,onClose:()=>{a(!1)},onDrag:(t,r)=>{s(t,r),null==e||e(t,r)},onOpenChange:e=>{e&&a(e),null==r||r(e)},onRelease:o,...n})},Content:yd,Overlay:vd,Trigger:_l,Portal:function(e){const r=zl(),{container:i=r.container,...n}=e;return t.createElement(Ol,{container:i,...n})},Handle:bd,Close:Bl,Title:Fl,Description:$l};function wd(t){var r=T(t,[]);return e.createElement(Ed.Root,Object.assign({"data-slot":"drawer"},r))}function Sd(t){var r=T(t,[]);return e.createElement(Ed.Trigger,Object.assign({"data-slot":"drawer-trigger"},r))}function Td(t){var r=T(t,[]);return e.createElement(Ed.Portal,Object.assign({"data-slot":"drawer-portal"},r))}function xd(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(Ed.Overlay,Object.assign({"data-slot":"drawer-overlay",className:wt("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[999999] bg-black/50",r)},i))}function Ad(t){var{className:r,children:i}=t,n=T(t,["className","children"]);return e.createElement(Td,{"data-slot":"drawer-portal"},e.createElement(xd,null),e.createElement(Ed.Content,Object.assign({"data-slot":"drawer-content",className:wt("group/drawer-content bg-background fixed z-[999999] flex h-auto flex-col","data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b","data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t","data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm","data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=left]:sm:max-w-sm",r)},n),e.createElement("div",{className:"bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full group-data-[vaul-drawer-direction=bottom]/drawer-content:block"}),i))}function kd(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({"data-slot":"drawer-header",className:wt("flex flex-col gap-1.5 p-4",r)},i))}function Ld(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(Ed.Title,Object.assign({"data-slot":"drawer-title",className:wt("text-foreground font-semibold",r)},i))}const Id=({children:e,products:r,contentId:i})=>{const{isPreview:n}=ea();return t.createElement(wd,{direction:"right",fadeFromIndex:0,snapPoints:[1]},t.createElement(Sd,{className:"w-full"},e),t.createElement(Ad,null,t.createElement(kd,null,t.createElement(Ld,null,"상품 목록")),t.createElement("div",{className:"overflow-y-scroll grid-cols-2 grid items-baseline justify-items-center scrollbar-hide"},r.map(e=>e.linkPath?t.createElement("a",{key:e.productId,className:"p-2 text-gray-800 w-full h-full flex flex-col items-center justify-center no-underline",href:e.linkPath,target:"_blank",onClick:()=>x(void 0,void 0,void 0,function*(){n||(yield Gs({contentId:i,contentProductId:e.eventProductId,productId:e.productId}))})},t.createElement(Rd,{product:e})):t.createElement(Rd,{key:e.productId,product:e})))))},Rd=({product:e})=>t.createElement("div",{className:"text-gray-800 w-32"},t.createElement("div",{className:"w-full aspect-square mb-2 border border-[#f4f3f6] rounded "},t.createElement("img",{src:e.thumbPath,alt:e.productName,className:"w-full h-full"})),e.brand&&t.createElement("p",{className:"text-xs text-gray-400 mb-1"},e.brand.brandName),t.createElement("p",{className:"w-full text-[12px] md:text-[15px] mb-1"},e.productName),t.createElement("div",{className:"w-full "},t.createElement("div",{className:"flex"},t.createElement("span",{className:"text-sm text-red-500 mr-2 font-semibold"},e.discount,"%"),t.createElement("span",{className:"font-semibold"},St(e.sellingPrice),"원")))),Pd=({products:e,useDrawer:r,contentId:i})=>{const n=u(()=>(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"}},r?t.createElement(Id,{products:e,contentId:i},t.createElement(ya,{product:e[0],productsLength:e.length,contentId:i})):t.createElement(ya,{product:e[0],productsLength:e.length,hideMoreBtn:!0,contentId:i})):t.createElement(ds,{nested:!0,modules:[xs,fs],slidesPerView:1.1,effect:"cards",autoplay:!0,loop:!0,grabCursor:!0,cardsEffect:{rotate:!1},className:"w-full",style:{height:"80px"}},n.map((n,s)=>t.createElement(cs,{key:s+n.productId,className:"bg-white overflow-hidden rounded-xl",style:{borderRadius:"10px",height:"80px"}},r?t.createElement(Id,{products:e,contentId:i},t.createElement(ya,{product:n,productsLength:e.length,contentId:i})):t.createElement(ya,{product:n,productsLength:e.length,hideMoreBtn:!0,contentId:i}))))):null},Dd=({shortForm:e,useDrawer:r,isPopup:i,shareUrl:n,handleClose:s})=>{const[o,l]=a(!Boolean(i)),[d,c]=a(!0),{logo:u,productsInfo:h,thumbPath:f,title:p,media:m,brand:g,shortsId:v}=e;return t.createElement("div",{className:"h-full w-full text-sm overflow-hidden text-white relative"},t.createElement("div",{style:{backgroundImage:"linear-gradient(to bottom, rgba(0,0,0,0.4) 0%, transparent 50%, rgba(0,0,0,0.4) 100%)",padding:"15px"},className:"absolute h-full flex flex-col w-full z-[1] justify-between inset-0 bg-gradient-to-b from-black/40 via-transparent to-black/40"},t.createElement("div",{className:"flex gap-2 justify-between "},t.createElement("div",{className:"max-w-16"},(null==u?void 0:u.thumbPath)?t.createElement("img",{className:"mb-1",src:u.thumbPath,alt:u.logoName,width:100,height:100}):null),t.createElement("div",{className:"justify-self-end flex gap-2"},t.createElement("div",{className:"cursor-pointer text-white ",onClick:()=>{c(e=>!e)}},d?t.createElement(Wt,{size:20}):t.createElement(Yt,{size:20})),t.createElement("div",{className:"cursor-pointer text-white ",onClick:()=>{l(e=>!e)}},o?t.createElement(Xt,{size:20}):t.createElement(qt,{size:20})),t.createElement("div",{className:"cursor-pointer text-white ",onClick:s},t.createElement(Qt,{size:20})))),t.createElement("div",null,t.createElement("div",{className:"flex justify-between items-end mb-3 gap-3"},t.createElement("div",{className:"w-full"},g&&t.createElement("div",{className:"items-center flex gap-3 mb-2"},t.createElement("div",{className:"w-12 h-12 bg-white rounded-full border overflow-hidden"},t.createElement("img",{src:g.thumbPath,alt:g.brandName,width:100,height:100,className:"object-contain w-full h-full"})),t.createElement("p",{style:{fontSize:"14px",textAlign:"start"}},null==g?void 0:g.brandName)),t.createElement("p",{style:{fontSize:"14px",textAlign:"start"}},p)),t.createElement("div",{className:"flex flex-col items-center",style:{gap:"15px"}},t.createElement(la,{shortsId:v}),t.createElement("div",{className:"w-[24px] h-[24px] flex items-center justify-center"},t.createElement(va,{shortForm:e,shareUrl:n})))),h&&t.createElement(Pd,{products:h,useDrawer:r,contentId:e.shortsId}))),t.createElement(L,{file:Tt(null==m?void 0:m.objectId),thumbnail:`${Rt(f)}`,mute:o,isVertical:(null==m?void 0:m.height)>(null==m?void 0:m.width),play:d}))},Cd=({collection:e,playerSettings:r})=>{const[i,n]=a(e.contents[0]);return t.createElement("div",{className:"w-full h-full aspect-[9/16]"},t.createElement(ds,{modules:[us,Es],loop:!0,mousewheel:!0,direction:"vertical",touchEventsTarget:"container",slidesPerView:1,onSlideChangeTransitionEnd:t=>{const r=e.contents[t.realIndex];n(Object.assign({},r))},className:"h-full"},e.contents.map(e=>t.createElement(cs,{key:e.shortsId,className:"rounded-xl overflow-hidden"},i.shortsId===e.shortsId&&t.createElement("div",{className:"h-full rounded-xl absolute z-[999] w-full"},t.createElement(Dd,{shortForm:i,isPopup:!0})),t.createElement("img",{src:Rt(e.thumbPath),alt:e.title,className:"rounded-xl w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")})))))},_d=e=>{const{isMobile:r}=e,[i,n]=a("collection"in e?e.collection.contents[0]:null);if(r){if("shortform"in e)return t.createElement(Dd,{shortForm:e.shortform});if(e.collection)return t.createElement(Cd,{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 _t.PLATFORM:return t.createElement(ji,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"aspect-[9/16] h-full rounded-xl border overflow-hidden"},t.createElement(L,{file:Tt(e.shortform.media.objectId)}))});case _t.HORIZONTAL:return t.createElement(Ls,{shortform:e.shortform,playerSettings:i,player:t.createElement(L,{file:Tt(e.shortform.media.objectId)})});case _t.VERTICAL:return t.createElement(Rs,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"aspect-[9/16] h-full"},t.createElement(L,{file:Tt(e.shortform.media.objectId)}))});case _t.GRID:return t.createElement(Ds,{shortform:e.shortform,playerSettings:i,player:t.createElement(L,{file:Tt(e.shortform.media.objectId)})})}}else{if(!e.collection||!i)return null;{const{layout:r}=e.collection.player,s=e.collection.player.shoppingPlayer;switch(r){case _t.PLATFORM:return t.createElement(ji,{shortform:i,playerSettings:s,player:t.createElement("div",{className:"w-full flex items-center justify-center gap-4",style:{height:"calc(-220px + 100vh)"}},t.createElement(sa,{collection:e.collection,playerSettings:s,shortform:i,setShortform:n}))});case _t.HORIZONTAL:return t.createElement(Ls,{shortform:i,playerSettings:Object.assign({},s),player:t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(aa,{collection:e.collection,playerSettings:s,shortform:i,setShortform:n}))});case _t.VERTICAL:return t.createElement(Rs,{playerSettings:Object.assign({},s),shortform:i,player:t.createElement(aa,{collection:e.collection,playerSettings:s,shortform:i,setShortform:n})});case _t.GRID:return t.createElement(Ds,{shortform:i,playerSettings:Object.assign({},s),player:t.createElement(aa,{collection:e.collection,playerSettings:s,shortform:i,setShortform:n})})}}}},Od=e=>t.createElement(Dd,Object.assign({},e));function Md(){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 Nd=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(${Rt(e.thumbPath)})`}},t.createElement(Dd,{handleClose:i,shortForm:e,useDrawer:!1,isPopup:!0,shareUrl:r})))),Fd=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}`})`}})),$d=({shortform:e,shareUrl:r,handleClose:i})=>{const{isActive:n}=d(os),s=d(ls),a=Md().width<430||ma.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(${n?1:.8})`,transition:"transform 180ms ease"}},n?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(),s.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(zt,{size:28})),t.createElement(Nd,{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(),s.slideNext()}},t.createElement(Gt,{size:28}))):t.createElement(Fd,{shortform:e})))},{PLAYER_BACK_BASE_URL:Bd}=gt(),Ud=({collection:e,initialShortsId:i,onSlideChange:n,onClosePlayer:s})=>{var a;const o=u(()=>Math.max(e.contents.findIndex(e=>e.shortsId===i),0),[e.contents,i]),l=e.contents.length,d=Math.max(l,10),c=null!==(a=Md().width)&&void 0!==a?a:0,h=c<430||ma.isMobile,f=h?1:c>=1200?4:c>=900?3:2,p=u(()=>(e=>{const t=[...e];for(;t.length<d;)t.push(...e);return t})(e.contents),[e.contents]),m=r(null);return t.createElement("div",{style:{minHeight:100,minWidth:300},className:"w-full"},t.createElement(ds,{style:{minHeight:100,overflow:"visible"},initialSlide:o,ref:m,lazyPreloadPrevNext:2,className:"w-full",spaceBetween:h?8:c>=1200?24:c>=900?25:16,slidesPerView:f,grabCursor:!0,centeredSlides:1!==f,onSlideChangeTransitionEnd:t=>{const r=t.realIndex%l;null==n||n(r);const i=e.contents[(r+1)%l];var s;s=Tt(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!==s&&(A.src=s,A.load(),k=s)},loop:!0,slideToClickedSlide:!0},p.map((r,i)=>t.createElement(cs,{key:i},t.createElement($d,{handleClose:s,shortform:r,shareUrl:`${Bd}/collection/${e.colId}?start=${r.shortsId}&layout=5`})))))},zd=({shortform:e,onThumbnailClick:r,iconSize:i,exposeTitle:n,borderLine:s})=>{const a=u(()=>It(s),[s])?{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:Rt(e.thumbPath),alt:"thumbnail",className:"w-full h-full object-cover block rounded-full"})),n&&t.createElement("span",{style:{width:i},className:"text-black overflow-hidden text-[12px] whitespace-nowrap text-center text-clip cursor-default"},e.title))},Gd=Js(e=>({open:!1,setOpen:t=>e({open:t})})),jd=({product:e,productLength:r,hideMoreBadge:i=!1,contentId:n,lineClamp:s,showMoreBtn:a=!1,openProductPopup:o})=>{const{isPreview:l}=ea();return t.createElement(t.Fragment,null,t.createElement("div",{className:"product-banner border mbus-border",onClick:()=>x(void 0,void 0,void 0,function*(){i&&(window.open(e.linkPath,"_blank"),l||(yield Gs({contentProductId:e.eventProductId,contentId:n,productId:e.productId})))})},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:Rt(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:s||2,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word",fontWeight:600,color:"#494949"}},e.productName)),t.createElement("span",{className:"product-banner__arrow","aria-hidden":!0},"›")),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,")"))},Hd=({products:e,iconSize:r,contentId:i,setSelectedProducts:n,showMoreBtn:s,hideMoreBadge:a})=>{const{setOpen:o}=Gd(),l=()=>{n({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||s||l()}),className:"flex flex-col gap-2 mt-4 text-gray-800",style:{maxWidth:r||"100%",fontSize:13}},t.createElement(jd,{showMoreBtn:s,lineClamp:2,product:e[0],contentId:i,productLength:e.length,hideMoreBadge:null!=a?a:1===e.length,openProductPopup:l})))},Vd=({product:e,maxWidth:r="100%",height:i,cardWidth:n})=>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:Rt(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}},"number"==typeof e.sellingPrice&&e.sellingPrice<e.price?"number"==typeof n&&n>=190?t.createElement(t.Fragment,null,t.createElement("span",{style:{color:"#dc2626",fontWeight:600,marginRight:4}},St(e.sellingPrice),"원"),t.createElement("span",{style:{color:"#9ca3af",textDecoration:"line-through"}},St(e.price),"원")):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},St(e.sellingPrice),"원"):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},St(e.price),"원")))),Wd=({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"})),Yd=({shortform:e,onThumbnailClick:r,iconSize:i,exposeTitle:n,rounded:s,borderLine:o,titlePosition:l,exposeProductBanner:d,setSelectedProducts:c,iconRatio:h,hoverPlay:f,exposeProductBadge:p})=>{var m;const g=u(()=>It(o),[o]),[v,y]=a(!1),{API_BASE_URL:b}=gt();return t.createElement("div",{className:"relative"},t.createElement("div",{onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),onClick:()=>r(e.shortsId),style:Object.assign({width:i,aspectRatio:h},s&&{borderRadius:"10px"}),className:`cursor-pointer p-[3px] ${s&&"rounded-xl"} ${g&&"bg-insta"} relative overflow-hidden`},v&&f&&t.createElement(Wd,{playUrl:`${b}/direct/${e.media.objectId}`,poster:Rt(e.thumbPath)}),t.createElement("img",{style:Object.assign({},s&&{borderRadius:"10px"}),src:Rt(e.thumbPath),alt:"thumbnail",className:`w-full h-full object-cover ${s&&"rounded-xl"}`}),p&&(null===(m=e.productsInfo)||void 0===m?void 0:m.length)>0&&!(f&&v)&&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(Vd,{product:e.productsInfo[0],maxWidth:"100%",height:"100%",cardWidth:i})))),n&&!(f&&v&&l===Be.INNER)&&t.createElement("p",{style:Object.assign({width:i,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},l===Be.INNER&&p?{bottom:"22%"}:{}),className:`my-2 ${l===Be.INNER?"absolute bottom-0 left-0 text-white px-2 z-10":""} text-[12px] cursor-default truncate`},e.title),d&&t.createElement(Hd,{setSelectedProducts:c,products:e.productsInfo,iconSize:i,contentId:e.shortsId}))},Kd=e=>{const{iconShape:r,collection:i}=e;return r===Ne.MANY?t.createElement(qd,Object.assign({},e)):t.createElement(Xd,Object.assign({},e,{shortform:i.contents[0]}))},qd=e=>{const{collection:r}=e,{thumbnailAutoPlay:i}=e,{setCollection:n,nextKey:s,setNextKey:a,isFetching:o,setIsFetching:l}=ia();return t.createElement(ds,{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 Vs({collectionId:r.colId,nextKey:s});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;n(Object.assign(Object.assign({},r),{contents:[...r.contents,...l]}))}catch(e){console.error(e)}finally{l(!1)}}}),modules:i?[fs]:[],autoplay:!!i&&{delay:3e3,disableOnInteraction:!1,pauseOnMouseEnter:!0},loop:i||void 0},null==r?void 0:r.contents.map(r=>t.createElement(cs,{key:r.shortsId,className:"!w-auto"},t.createElement(Xd,Object.assign({},e,{shortform:r})))))},Xd=e=>{const{iconForm:r}=e;return r===Me.INSTA?t.createElement(zd,Object.assign({},e)):t.createElement(Yd,Object.assign({},e))};function Qd(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function Zd(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Jd(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Zd(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():Zd(e[t],null)}}}}function ec(...t){return e.useCallback(Jd(...t),t)}function tc(...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 n=i.reduce((e,{useScope:r,scopeName:i})=>({...e,...r(t)[`__scope${i}`]}),{});return e.useMemo(()=>({[`__scope${r.scopeName}`]:n}),[n])}};return i.scopeName=r.scopeName,i}var rc=globalThis?.document?e.useLayoutEffect:()=>{},ic=e[" useId ".trim().toString()]||(()=>{}),nc=0;function sc(t){const[r,i]=e.useState(ic());return rc(()=>{t||i(e=>e??String(nc++))},[t]),t||(r?`radix-${r}`:"")}var ac=e[" useInsertionEffect ".trim().toString()]||rc;function oc({prop:t,defaultProp:r,onChange:i=()=>{},caller:n}){const[s,a,o]=function({defaultProp:t,onChange:r}){const[i,n]=e.useState(t),s=e.useRef(i),a=e.useRef(r);return ac(()=>{a.current=r},[r]),e.useEffect(()=>{s.current!==i&&(a.current?.(i),s.current=i)},[i,s]),[i,n,a]}({defaultProp:r,onChange:i}),l=void 0!==t,d=l?t:s;{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(`${n} 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,n])}const c=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[d,c]}function lc(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function dc(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function cc(...e){return t=>{let r=!1;const i=e.map(e=>{const i=dc(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():dc(e[t],null)}}}}function uc(...t){return e.useCallback(cc(...t),t)}function hc(t){const r=e.forwardRef((t,r)=>{const{children:i,...n}=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),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{const t=s(...e);return n(...e),t}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?cc(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}var fc=Symbol("radix.slottable");function pc(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===fc}var mc=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=function(t){const r=hc(t),i=e.forwardRef((t,i)=>{const{children:n,...s}=t,a=e.Children.toArray(n),o=a.find(pc);if(o){const t=o.props.children,n=a.map(r=>r===o?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return p(r,{...s,ref:i,children:e.isValidElement(t)?e.cloneElement(t,void 0,n):null})}return p(r,{...s,ref:i,children:n})});return i.displayName=`${t}.Slot`,i}(`Primitive.${r}`),n=e.forwardRef((e,t)=>{const{asChild:n,...s}=e,a=n?i:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),p(a,{...s,ref:t})});return n.displayName=`Primitive.${r}`,{...t,[r]:n}},{});var gc,vc="dismissableLayer.update",yc="dismissableLayer.pointerDownOutside",bc="dismissableLayer.focusOutside",Ec=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),wc=e.forwardRef((t,r)=>{const{disableOutsidePointerEvents:i=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:o,onDismiss:l,...d}=t,c=e.useContext(Ec),[u,h]=e.useState(null),f=u?.ownerDocument??globalThis?.document,[,m]=e.useState({}),g=uc(r,e=>h(e)),v=Array.from(c.layers),[y]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),b=v.indexOf(y),E=u?v.indexOf(u):-1,w=c.layersWithOutsidePointerEventsDisabled.size>0,S=E>=b,T=function(t,r=globalThis?.document){const i=Ma(t),n=e.useRef(!1),s=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){let t=function(){Tc(yc,i,n,{discrete:!0})};const n={originalEvent:e};"touch"===e.pointerType?(r.removeEventListener("click",s.current),s.current=t,r.addEventListener("click",s.current,{once:!0})):t()}else r.removeEventListener("click",s.current);n.current=!1},t=window.setTimeout(()=>{r.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),r.removeEventListener("pointerdown",e),r.removeEventListener("click",s.current)}},[r,i]),{onPointerDownCapture:()=>n.current=!0}}(e=>{const t=e.target,r=[...c.branches].some(e=>e.contains(t));S&&!r&&(s?.(e),o?.(e),e.defaultPrevented||l?.())},f),x=function(t,r=globalThis?.document){const i=Ma(t),n=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){Tc(bc,i,{originalEvent:e},{discrete:!1})}};return r.addEventListener("focusin",e),()=>r.removeEventListener("focusin",e)},[r,i]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}(e=>{const t=e.target;[...c.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||l?.())},f);return Na(e=>{E===c.layers.size-1&&(n?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),e.useEffect(()=>{if(u)return i&&(0===c.layersWithOutsidePointerEventsDisabled.size&&(gc=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),Sc(),()=>{i&&1===c.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=gc)}},[u,f,i,c]),e.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),Sc())},[u,c]),e.useEffect(()=>{const e=()=>m({});return document.addEventListener(vc,e),()=>document.removeEventListener(vc,e)},[]),p(mc.div,{...d,ref:g,style:{pointerEvents:w?S?"auto":"none":void 0,...t.style},onFocusCapture:lc(t.onFocusCapture,x.onFocusCapture),onBlurCapture:lc(t.onBlurCapture,x.onBlurCapture),onPointerDownCapture:lc(t.onPointerDownCapture,T.onPointerDownCapture)})});wc.displayName="DismissableLayer";function Sc(){const e=new CustomEvent(vc);document.dispatchEvent(e)}function Tc(e,t,r,{discrete:i}){const n=r.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),i?function(e,t){e&&v.flushSync(()=>e.dispatchEvent(t))}(n,s):n.dispatchEvent(s)}e.forwardRef((t,r)=>{const i=e.useContext(Ec),n=e.useRef(null),s=uc(r,n);return e.useEffect(()=>{const e=n.current;if(e)return i.branches.add(e),()=>{i.branches.delete(e)}},[i.branches]),p(mc.div,{...t,ref:s})}).displayName="DismissableLayerBranch";var xc=t=>{const{present:r,children:i}=t,n=function(t){const[r,i]=e.useState(),n=e.useRef(null),s=e.useRef(t),a=e.useRef("none"),o=t?"mounted":"unmounted",[l,d]=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=Ac(n.current);a.current="mounted"===l?e:"none"},[l]),rc(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=Ac(e);if(t)d("MOUNT");else if("none"===n||"none"===e?.display)d("UNMOUNT");else{d(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,d]),rc(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=Ac(n.current).includes(i.animationName);if(i.target===r&&a&&(d("ANIMATION_END"),!s.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=Ac(n.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)}}d("ANIMATION_END")},[r,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{n.current=e?getComputedStyle(e):null,i(e)},[])}}(r),s="function"==typeof i?i({present:n.isPresent}):e.Children.only(i),a=ec(n.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}(s));return"function"==typeof i||n.isPresent?e.cloneElement(s,{ref:a}):null};function Ac(e){return e?.animationName||"none"}function kc(t){const r=Lc(t),i=e.forwardRef((t,i)=>{const{children:n,...s}=t,a=e.Children.toArray(n),o=a.find(Rc);if(o){const t=o.props.children,n=a.map(r=>r===o?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return p(r,{...s,ref:i,children:e.isValidElement(t)?e.cloneElement(t,void 0,n):null})}return p(r,{...s,ref:i,children:n})});return i.displayName=`${t}.Slot`,i}function Lc(t){const r=e.forwardRef((t,r)=>{const{children:i,...n}=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),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{const t=s(...e);return n(...e),t}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?Jd(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}xc.displayName="Presence";var Ic=Symbol("radix.slottable");function Rc(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===Ic}var Pc=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=kc(`Primitive.${r}`),n=e.forwardRef((e,t)=>{const{asChild:n,...s}=e,a=n?i:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),p(a,{...s,ref:t})});return n.displayName=`Primitive.${r}`,{...t,[r]:n}},{}),Dc=0;function Cc(){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 _c="Dialog",[Oc,Mc]=function(t,r=[]){let i=[];const n=()=>{const r=i.map(t=>e.createContext(t));return function(i){const n=i?.[t]||r;return e.useMemo(()=>({[`__scope${t}`]:{...i,[t]:n}}),[i,n])}};return n.scopeName=t,[function(r,n){const s=e.createContext(n),a=i.length;i=[...i,n];const o=r=>{const{scope:i,children:n,...o}=r,l=i?.[t]?.[a]||s,d=e.useMemo(()=>o,Object.values(o));return p(l.Provider,{value:d,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,d=e.useContext(l);if(d)return d;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},tc(n,...r)]}(_c),[Nc,Fc]=Oc(_c),$c=t=>{const{__scopeDialog:r,children:i,open:n,defaultOpen:s,onOpenChange:a,modal:o=!0}=t,l=e.useRef(null),d=e.useRef(null),[c,u]=oc({prop:n,defaultProp:s??!1,onChange:a,caller:_c});return p(Nc,{scope:r,triggerRef:l,contentRef:d,contentId:sc(),titleId:sc(),descriptionId:sc(),open:c,onOpenChange:u,onOpenToggle:e.useCallback(()=>u(e=>!e),[u]),modal:o,children:i})};$c.displayName=_c;var Bc="DialogTrigger";e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Fc(Bc,r),s=ec(t,n.triggerRef);return p(Pc.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":su(n.open),...i,ref:s,onClick:Qd(e.onClick,n.onOpenToggle)})}).displayName=Bc;var Uc="DialogPortal",[zc,Gc]=Oc(Uc,{forceMount:void 0}),jc=t=>{const{__scopeDialog:r,forceMount:i,children:n,container:s}=t,a=Fc(Uc,r);return p(zc,{scope:r,forceMount:i,children:e.Children.map(n,e=>p(xc,{present:i||a.open,children:p(to,{asChild:!0,container:s,children:e})}))})};jc.displayName=Uc;var Hc="DialogOverlay",Vc=e.forwardRef((e,t)=>{const r=Gc(Hc,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=Fc(Hc,e.__scopeDialog);return s.modal?p(xc,{present:i||s.open,children:p(Yc,{...n,ref:t})}):null});Vc.displayName=Hc;var Wc=kc("DialogOverlay.RemoveScroll"),Yc=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Fc(Hc,r);return p(Vo,{as:Wc,allowPinchZoom:!0,shards:[n.contentRef],children:p(Pc.div,{"data-state":su(n.open),...i,ref:t,style:{pointerEvents:"auto",...i.style}})})}),Kc="DialogContent",qc=e.forwardRef((e,t)=>{const r=Gc(Kc,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=Fc(Kc,e.__scopeDialog);return p(xc,{present:i||s.open,children:s.modal?p(Xc,{...n,ref:t}):p(Qc,{...n,ref:t})})});qc.displayName=Kc;var Xc=e.forwardRef((t,r)=>{const i=Fc(Kc,t.__scopeDialog),n=e.useRef(null),s=ec(r,i.contentRef,n);return e.useEffect(()=>{const e=n.current;if(e)return Zo(e)},[]),p(Zc,{...t,ref:s,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Qd(t.onCloseAutoFocus,e=>{e.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:Qd(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;(2===t.button||r)&&e.preventDefault()}),onFocusOutside:Qd(t.onFocusOutside,e=>e.preventDefault())})}),Qc=e.forwardRef((t,r)=>{const i=Fc(Kc,t.__scopeDialog),n=e.useRef(!1),s=e.useRef(!1);return p(Zc,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),e.defaultPrevented||(n.current||i.triggerRef.current?.focus(),e.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:e=>{t.onInteractOutside?.(e),e.defaultPrevented||(n.current=!0,"pointerdown"===e.detail.originalEvent.type&&(s.current=!0));const r=e.target,a=i.triggerRef.current?.contains(r);a&&e.preventDefault(),"focusin"===e.detail.originalEvent.type&&s.current&&e.preventDefault()}})}),Zc=e.forwardRef((t,r)=>{const{__scopeDialog:i,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:a,...o}=t,l=Fc(Kc,i),d=e.useRef(null),c=ec(r,d);return e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Cc()),document.body.insertAdjacentElement("beforeend",e[1]??Cc()),Dc++,()=>{1===Dc&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Dc--}},[]),g(m,{children:[p(Ka,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:a,children:p(wc,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":su(l.open),...o,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),g(m,{children:[p(du,{titleId:l.titleId}),p(cu,{contentRef:d,descriptionId:l.descriptionId})]})]})}),Jc="DialogTitle",eu=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Fc(Jc,r);return p(Pc.h2,{id:n.titleId,...i,ref:t})});eu.displayName=Jc;var tu="DialogDescription",ru=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Fc(tu,r);return p(Pc.p,{id:n.descriptionId,...i,ref:t})});ru.displayName=tu;var iu="DialogClose",nu=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Fc(iu,r);return p(Pc.button,{type:"button",...i,ref:t,onClick:Qd(e.onClick,()=>n.onOpenChange(!1))})});function su(e){return e?"open":"closed"}nu.displayName=iu;var au="DialogTitleWarning",[ou,lu]=function(t,r){const i=e.createContext(r),n=t=>{const{children:r,...n}=t,s=e.useMemo(()=>n,Object.values(n));return p(i.Provider,{value:s,children:r})};return n.displayName=t+"Provider",[n,function(n){const s=e.useContext(i);if(s)return s;if(void 0!==r)return r;throw new Error(`\`${n}\` must be used within \`${t}\``)}]}(au,{contentName:Kc,titleName:Jc,docsSlug:"dialog"}),du=({titleId:t})=>{const r=lu(au),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},cu=({contentRef:t,descriptionId:r})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${lu("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},uu=$c,hu=jc,fu=Vc,pu=qc,mu=eu,gu=nu;function vu(t){return e.createElement(uu,Object.assign({"data-slot":"dialog"},t))}function yu(t){var r=T(t,[]);return e.createElement(hu,Object.assign({"data-slot":"dialog-portal"},r))}function bu(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(fu,Object.assign({"data-slot":"dialog-overlay",className:wt("fixed inset-0 z-50 bg-black/50",r)},i))}function Eu(t){var{className:r,children:i,showCloseButton:n=!0,container:s}=t,a=T(t,["className","children","showCloseButton","container"]);return e.createElement(yu,{"data-slot":"dialog-portal",container:s},e.createElement(bu,null),e.createElement(pu,Object.assign({"data-slot":"dialog-content",style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",outline:"none"},className:wt("fixed","z-50 grid w-full max-w-lg sm:mx-0 gap-4 p-6",r)},a),i,n&&e.createElement(gu,{"data-slot":"dialog-close",style:{right:"calc(var(--spacing) * 4)",top:"calc(var(--spacing) * 4)",outline:"none"},className:wt("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(Qt,{className:"h-4 w-4 pointer-events-none shrink-0",style:{height:"calc(var(--spacing) * 4)",width:"calc(var(--spacing) * 4)"}}))))}function wu(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({"data-slot":"dialog-header",className:wt("flex flex-col gap-2 text-left",r)},i))}function Su(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(mu,Object.assign({"data-slot":"dialog-title",className:wt("text-lg leading-none font-semibold",r)},i))}function Tu({title:e,children:r,contentClassName:i,hideCloseButton:n=!1,portalContainer:s,description:a}){const{open:o,setOpen:l}=Gd();return t.createElement(vu,{open:o,onOpenChange:l},t.createElement(Eu,{container:s,className:i,showCloseButton:!n},e&&t.createElement(wu,null,t.createElement(Su,{style:{color:"#494949"}},e||""),t.createElement(ru,{style:{color:"#5e5e5e",fontSize:"12.5px"}},a||"")),r))}const xu=({products:e,contentId:r})=>{const i=Md().width<430||ma.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(jd,{key:i.productId,product:i,hideMoreBadge:!0,productLength:e.length,contentId:r})))},{PLAYER_BACK_BASE_URL:Au}=gt(),ku=({widgetPlayerOption:e,setCollectionUuid:r,portalContainer:n})=>{const{player:s}=e,[o,l]=a(null),{collection:d}=ia(),{isPreview:c}=ea(),{onSlideChange:u,onCollectionClose:h}=na(o,l),{setOpen:f,open:p}=Gd();i(()=>{p||(o&&(h(),l(null)),m&&g(null))},[p]);const[m,g]=a();return t.createElement(t.Fragment,null,d&&t.createElement(Kd,Object.assign({collection:d},e,{onThumbnailClick:e=>x(void 0,void 0,void 0,function*(){if(s===$e.POPUP){const t=kt(),i=kt();if(r(i),l(Object.assign(Object.assign({},d.contents.find(t=>t.shortsId===e)),{uuid:t})),f(!0),c)return;yield Promise.all([Us({contentId:d.colId,uuid:i,type:Et.COLLECTION,userId:d.userId,isFirstPlay:!Lt(d.colId)}),Us({contentId:e,uuid:t,type:Et.SHORTS,userId:d.userId,isFirstPlay:!Lt(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}})(s),r=null==d?void 0:d.contents.findIndex(t=>t.shortsId===e);let i="";r&&r>1&&(i=(null==d?void 0:d.contents[r-1].shortsId)||""),open(`${Au}/collection/${d.colId}?nextKey=${i}&layout=${t}`)}}),setSelectedProducts:g})),m&&t.createElement(Tu,{portalContainer:n,title:"상품 목록",contentClassName:"bg-white rounded p-4 product-dialog-container",description:"상품 정보를 확인해 보세요"},t.createElement(xu,{products:m.productsInfo,contentId:m.shortsId})),d&&o&&t.createElement(Tu,{portalContainer:n,hideCloseButton:!0,contentClassName:"w-full max-w-none p-0 mx-0"},t.createElement(Ud,{collection:d,initialShortsId:o.shortsId,onClosePlayer:()=>x(void 0,void 0,void 0,function*(){h(),f(!1)}),onSlideChange:u})))};var Lu,Iu={exports:{}},Ru={exports:{}},Pu={};var Du,Cu,_u,Ou,Mu,Nu,Fu,$u,Bu,Uu,zu,Gu,ju,Hu,Vu,Wu={};
27
+ */function or(t,r=[]){let i=[];const n=()=>{const r=i.map(t=>e.createContext(t));return function(i){const n=i?.[t]||r;return e.useMemo(()=>({[`__scope${t}`]:{...i,[t]:n}}),[i,n])}};return n.scopeName=t,[function(r,n){const s=e.createContext(n),a=i.length;i=[...i,n];const o=r=>{const{scope:i,children:n,...o}=r,l=i?.[t]?.[a]||s,d=e.useMemo(()=>o,Object.values(o));return p(l.Provider,{value:d,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,d=e.useContext(l);if(d)return d;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},lr(n,...r)]}function lr(...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 n=i.reduce((e,{useScope:r,scopeName:i})=>({...e,...r(t)[`__scope${i}`]}),{});return e.useMemo(()=>({[`__scope${r.scopeName}`]:n}),[n])}};return i.scopeName=r.scopeName,i}function dr(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function cr(...e){return t=>{let r=!1;const i=e.map(e=>{const i=dr(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():dr(e[t],null)}}}}function ur(...t){return e.useCallback(cr(...t),t)}var hr=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(mr);if(a){const t=a.props.children,i=s.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return p(fr,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return p(fr,{...n,ref:r,children:i})});hr.displayName="Slot";var fr=e.forwardRef((t,r)=>{const{children:i,...n}=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),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{s(...e),n(...e)}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?cr(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});fr.displayName="SlotClone";var pr=({children:e})=>p(m,{children:e});function mr(t){return e.isValidElement(t)&&t.type===pr}function gr(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function vr(...e){return t=>{let r=!1;const i=e.map(e=>{const i=gr(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():gr(e[t],null)}}}}function yr(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function br(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}function Er({prop:t,defaultProp:r,onChange:i=()=>{}}){const[n,s]=function({defaultProp:t,onChange:r}){const i=e.useState(t),[n]=i,s=e.useRef(n),a=br(r);return e.useEffect(()=>{s.current!==n&&(a(n),s.current=n)},[n,s,a]),i}({defaultProp:r,onChange:i}),a=void 0!==t,o=a?t:n,l=br(i);return[o,e.useCallback(e=>{if(a){const r="function"==typeof e?e(t):e;r!==t&&l(r)}else s(e)},[a,t,s,l])]}var wr=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(xr);if(a){const t=a.props.children,i=s.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return p(Sr,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return p(Sr,{...n,ref:r,children:i})});wr.displayName="Slot";var Sr=e.forwardRef((t,r)=>{const{children:i,...n}=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),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{s(...e),n(...e)}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?vr(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});Sr.displayName="SlotClone";var Tr=({children:e})=>p(m,{children:e});function xr(t){return e.isValidElement(t)&&t.type===Tr}var Ar=["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,...n}=e,s=i?wr:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),p(s,{...n,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{}),kr=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{};function Lr(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ir(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Lr(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():Lr(e[t],null)}}}}function Rr(...t){return e.useCallback(Ir(...t),t)}var Pr=e.forwardRef((t,r)=>{const{children:i,...n}=t,s=e.Children.toArray(i),a=s.find(_r);if(a){const t=a.props.children,i=s.map(r=>r===a?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return p(Dr,{...n,ref:r,children:e.isValidElement(t)?e.cloneElement(t,void 0,i):null})}return p(Dr,{...n,ref:r,children:i})});Pr.displayName="Slot";var Dr=e.forwardRef((t,r)=>{const{children:i,...n}=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),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{s(...e),n(...e)}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?Ir(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});Dr.displayName="SlotClone";var Cr=({children:e})=>p(m,{children:e});function _r(t){return e.isValidElement(t)&&t.type===Cr}var Or=["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,...n}=e,s=i?Pr:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),p(s,{...n,ref:t})});return i.displayName=`Primitive.${r}`,{...t,[r]:i}},{});var Mr=t=>{const{present:r,children:i}=t,n=function(t){const[r,i]=e.useState(),n=e.useRef({}),s=e.useRef(t),a=e.useRef("none"),o=t?"mounted":"unmounted",[l,d]=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=Nr(n.current);a.current="mounted"===l?e:"none"},[l]),kr(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=Nr(e);if(t)d("MOUNT");else if("none"===n||"none"===e?.display)d("UNMOUNT");else{d(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,d]),kr(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=Nr(n.current).includes(i.animationName);if(i.target===r&&a&&(d("ANIMATION_END"),!s.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=Nr(n.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)}}d("ANIMATION_END")},[r,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{e&&(n.current=getComputedStyle(e)),i(e)},[])}}(r),s="function"==typeof i?i({present:n.isPresent}):e.Children.only(i),a=Rr(n.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}(s));return"function"==typeof i||n.isPresent?e.cloneElement(s,{ref:a}):null};function Nr(e){return e?.animationName||"none"}Mr.displayName="Presence";var Fr=Boolean(globalThis?.document)?e.useLayoutEffect:()=>{},$r=e["useId".toString()]||(()=>{}),Br=0;function Ur(t){const[r,i]=e.useState($r());return Fr(()=>{i(e=>e??String(Br++))},[t]),r?`radix-${r}`:""}var zr="Collapsible",[Gr,jr]=or(zr),[Hr,Vr]=Gr(zr),Wr=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,open:n,defaultOpen:s,disabled:a,onOpenChange:o,...l}=t,[d=!1,c]=Er({prop:n,defaultProp:s,onChange:o});return p(Hr,{scope:i,disabled:a,contentId:Ur(),open:d,onOpenToggle:e.useCallback(()=>c(e=>!e),[c]),children:p(Or.div,{"data-state":Zr(d),"data-disabled":a?"":void 0,...l,ref:r})})});Wr.displayName=zr;var Yr="CollapsibleTrigger",Kr=e.forwardRef((e,t)=>{const{__scopeCollapsible:r,...i}=e,n=Vr(Yr,r);return p(Or.button,{type:"button","aria-controls":n.contentId,"aria-expanded":n.open||!1,"data-state":Zr(n.open),"data-disabled":n.disabled?"":void 0,disabled:n.disabled,...i,ref:t,onClick:yr(e.onClick,n.onOpenToggle)})});Kr.displayName=Yr;var qr="CollapsibleContent",Xr=e.forwardRef((e,t)=>{const{forceMount:r,...i}=e,n=Vr(qr,e.__scopeCollapsible);return p(Mr,{present:r||n.open,children:({present:e})=>p(Qr,{...i,ref:t,present:e})})});Xr.displayName=qr;var Qr=e.forwardRef((t,r)=>{const{__scopeCollapsible:i,present:n,children:s,...a}=t,o=Vr(qr,i),[l,d]=e.useState(n),c=e.useRef(null),u=Rr(r,c),h=e.useRef(0),f=h.current,m=e.useRef(0),g=m.current,v=o.open||l,y=e.useRef(v),b=e.useRef(void 0);return e.useEffect(()=>{const e=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(e)},[]),kr(()=>{const e=c.current;if(e){b.current=b.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,m.current=t.width,y.current||(e.style.transitionDuration=b.current.transitionDuration,e.style.animationName=b.current.animationName),d(n)}},[o.open,n]),p(Or.div,{"data-state":Zr(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!v,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...t.style},children:v&&s})});function Zr(e){return e?"open":"closed"}var Jr=Wr,ei=Kr,ti=Xr,ri=e.createContext(void 0);var ii="Accordion",ni=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[si,ai,oi]=function(e){const r=e+"CollectionProvider",[i,n]=or(r),[s,a]=i(r,{collectionRef:{current:null},itemMap:new Map}),o=e=>{const{scope:r,children:i}=e,n=t.useRef(null),a=t.useRef(new Map).current;return p(s,{scope:r,itemMap:a,collectionRef:n,children:i})};o.displayName=r;const l=e+"CollectionSlot",d=t.forwardRef((e,t)=>{const{scope:r,children:i}=e,n=ur(t,a(l,r).collectionRef);return p(hr,{ref:n,children:i})});d.displayName=l;const c=e+"CollectionItemSlot",u="data-radix-collection-item",h=t.forwardRef((e,r)=>{const{scope:i,children:n,...s}=e,o=t.useRef(null),l=ur(r,o),d=a(c,i);return t.useEffect(()=>(d.itemMap.set(o,{ref:o,...s}),()=>{d.itemMap.delete(o)})),p(hr,{[u]:"",ref:l,children:n})});return h.displayName=c,[{Provider:o,Slot:d,ItemSlot:h},function(r){const i=a(e+"CollectionConsumer",r),n=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 n},n]}(ii),[li,di]=or(ii,[oi,jr]),ci=jr(),ui=t.forwardRef((e,t)=>{const{type:r,...i}=e,n=i,s=i;return p(si.Provider,{scope:e.__scopeAccordion,children:"multiple"===r?p(vi,{...s,ref:t}):p(gi,{...n,ref:t})})});ui.displayName=ii;var[hi,fi]=li(ii),[pi,mi]=li(ii,{collapsible:!1}),gi=t.forwardRef((e,r)=>{const{value:i,defaultValue:n,onValueChange:s=()=>{},collapsible:a=!1,...o}=e,[l,d]=Er({prop:i,defaultProp:n,onChange:s});return p(hi,{scope:e.__scopeAccordion,value:l?[l]:[],onItemOpen:d,onItemClose:t.useCallback(()=>a&&d(""),[a,d]),children:p(pi,{scope:e.__scopeAccordion,collapsible:a,children:p(Ei,{...o,ref:r})})})}),vi=t.forwardRef((e,r)=>{const{value:i,defaultValue:n,onValueChange:s=()=>{},...a}=e,[o=[],l]=Er({prop:i,defaultProp:n,onChange:s}),d=t.useCallback(e=>l((t=[])=>[...t,e]),[l]),c=t.useCallback(e=>l((t=[])=>t.filter(t=>t!==e)),[l]);return p(hi,{scope:e.__scopeAccordion,value:o,onItemOpen:d,onItemClose:c,children:p(pi,{scope:e.__scopeAccordion,collapsible:!0,children:p(Ei,{...a,ref:r})})})}),[yi,bi]=li(ii),Ei=t.forwardRef((r,i)=>{const{__scopeAccordion:n,disabled:s,dir:a,orientation:o="vertical",...l}=r,d=function(...t){return e.useCallback(vr(...t),t)}(t.useRef(null),i),c=ai(n),u="ltr"===function(t){const r=e.useContext(ri);return t||r||"ltr"}(a),h=yr(r.onKeyDown,e=>{if(!ni.includes(e.key))return;const t=e.target,r=c().filter(e=>!e.ref.current?.disabled),i=r.findIndex(e=>e.ref.current===t),n=r.length;if(-1===i)return;e.preventDefault();let s=i;const a=n-1,l=()=>{s=i+1,s>a&&(s=0)},d=()=>{s=i-1,s<0&&(s=a)};switch(e.key){case"Home":s=0;break;case"End":s=a;break;case"ArrowRight":"horizontal"===o&&(u?l():d());break;case"ArrowDown":"vertical"===o&&l();break;case"ArrowLeft":"horizontal"===o&&(u?d():l());break;case"ArrowUp":"vertical"===o&&d()}const h=s%n;r[h].ref.current?.focus()});return p(yi,{scope:n,disabled:s,direction:a,orientation:o,children:p(si.Slot,{scope:n,children:p(Ar.div,{...l,"data-orientation":o,ref:d,onKeyDown:s?void 0:h})})})}),wi="AccordionItem",[Si,Ti]=li(wi),xi=t.forwardRef((e,t)=>{const{__scopeAccordion:r,value:i,...n}=e,s=bi(wi,r),a=fi(wi,r),o=ci(r),l=Ur(),d=i&&a.value.includes(i)||!1,c=s.disabled||e.disabled;return p(Si,{scope:r,open:d,disabled:c,triggerId:l,children:p(Jr,{"data-orientation":s.orientation,"data-state":Di(d),...o,...n,ref:t,disabled:c,open:d,onOpenChange:e=>{e?a.onItemOpen(i):a.onItemClose(i)}})})});xi.displayName=wi;var Ai="AccordionHeader",ki=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=bi(ii,r),s=Ti(Ai,r);return p(Ar.h3,{"data-orientation":n.orientation,"data-state":Di(s.open),"data-disabled":s.disabled?"":void 0,...i,ref:t})});ki.displayName=Ai;var Li="AccordionTrigger",Ii=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=bi(ii,r),s=Ti(Li,r),a=mi(Li,r),o=ci(r);return p(si.ItemSlot,{scope:r,children:p(ei,{"aria-disabled":s.open&&!a.collapsible||void 0,"data-orientation":n.orientation,id:s.triggerId,...o,...i,ref:t})})});Ii.displayName=Li;var Ri="AccordionContent",Pi=t.forwardRef((e,t)=>{const{__scopeAccordion:r,...i}=e,n=bi(ii,r),s=Ti(Ri,r),a=ci(r);return p(ti,{role:"region","aria-labelledby":s.triggerId,"data-orientation":n.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 Di(e){return e?"open":"closed"}Pi.displayName=Ri;var Ci=ui,_i=xi,Oi=ki,Mi=Ii,Ni=Pi;function Fi(t){var r=T(t,[]);return e.createElement(Ci,Object.assign({"data-slot":"accordion"},r))}function $i(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(_i,Object.assign({"data-slot":"accordion-item",className:wt("border-b last:border-b-0",r)},i))}function Bi(t){var{className:r,children:i}=t,n=T(t,["className","children"]);return e.createElement(Oi,{className:"flex"},e.createElement(Mi,Object.assign({"data-slot":"accordion-trigger",className:wt("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)},n),i,e.createElement(Ut,{className:"text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"})))}function Ui(t){var{className:r,children:i}=t,n=T(t,["className","children"]);return e.createElement(Ni,Object.assign({"data-slot":"accordion-content",className:"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"},n),e.createElement("div",{className:wt("pt-0 pb-4",r)},i))}const zi=({title:e,content:r})=>t.createElement(Fi,{style:{borderRadius:"0.625rem"},type:"single",collapsible:!0,className:"bg-white px-4",defaultValue:"item"},t.createElement($i,{value:"item"},t.createElement(Bi,{className:""},e),t.createElement(Ui,{className:"text-gray-700"},r))),Gi=({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"},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(Qt,null)))),ji=e=>{const{playerSettings:r,shortform:{description:i,productsInfo:n,logo:s,brand:a,title:o},player:l}=e;return t.createElement("div",{className:"w-full h-full bg-[#f4f4f4] overflow-scroll"},t.createElement(Gi,{logo:s}),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(Zt,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(nr,{rounded:!0}),t.createElement(sr,{rounded:!0}),t.createElement(ar,{rounded:!0})))),t.createElement("div",{className:"flex flex-col gap-4 max-w-[40%]"},i&&t.createElement(zi,{title:"숏클립 안내",content:t.createElement("p",{className:"font-medium"},i)}),t.createElement(zi,{title:"상품 목록",content:t.createElement(t.Fragment,null,t.createElement("div",{className:"max-h-[300px] overflow-y-auto font-medium"},n.map((e,r)=>t.createElement(t.Fragment,null,t.createElement(tr,{product:e}),r!==n.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==n?void 0:n.length)},"상품 전체 보기"))}),r.comment&&t.createElement(zi,{title:"댓글",content:t.createElement(rr,null)}))))};function Hi(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function Vi(e,t){void 0===e&&(e={}),void 0===t&&(t={}),Object.keys(t).forEach(r=>{void 0===e[r]?e[r]=t[r]:Hi(t[r])&&Hi(e[r])&&Object.keys(t[r]).length>0&&Vi(e[r],t[r])})}const Wi={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 Yi(){const e="undefined"!=typeof document?document:{};return Vi(e,Wi),e}const Ki={document:Wi,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 qi(){const e="undefined"!=typeof window?window:{};return Vi(e,Ki),e}function Xi(e,t){return void 0===t&&(t=0),setTimeout(e,t)}function Qi(){return Date.now()}function Zi(e,t){void 0===t&&(t="x");const r=qi();let i,n,s;const a=function(e){const t=qi();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?(n=a.transform||a.webkitTransform,n.split(",").length>6&&(n=n.split(", ").map(e=>e.replace(",",".")).join(", ")),s=new r.WebKitCSSMatrix("none"===n?"":n)):(s=a.MozTransform||a.OTransform||a.MsTransform||a.msTransform||a.transform||a.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),i=s.toString().split(",")),"x"===t&&(n=r.WebKitCSSMatrix?s.m41:16===i.length?parseFloat(i[12]):parseFloat(i[4])),"y"===t&&(n=r.WebKitCSSMatrix?s.m42:16===i.length?parseFloat(i[13]):parseFloat(i[5])),n||0}function Ji(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function en(e){return"undefined"!=typeof window&&void 0!==window.HTMLElement?e instanceof HTMLElement:e&&(1===e.nodeType||11===e.nodeType)}function tn(){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&&!en(i)){const r=Object.keys(Object(i)).filter(e=>t.indexOf(e)<0);for(let t=0,n=r.length;t<n;t+=1){const n=r[t],s=Object.getOwnPropertyDescriptor(i,n);void 0!==s&&s.enumerable&&(Ji(e[n])&&Ji(i[n])?i[n].__swiper__?e[n]=i[n]:tn(e[n],i[n]):!Ji(e[n])&&Ji(i[n])?(e[n]={},i[n].__swiper__?e[n]=i[n]:tn(e[n],i[n])):e[n]=i[n])}}}return e}function rn(e,t,r){e.style.setProperty(t,r)}function nn(e){let{swiper:t,targetPosition:r,side:i}=e;const n=qi(),s=-t.translate;let a,o=null;const l=t.params.speed;t.wrapperEl.style.scrollSnapType="none",n.cancelAnimationFrame(t.cssModeFrameID);const d=r>s?"next":"prev",c=(e,t)=>"next"===d&&e>=t||"prev"===d&&e<=t,u=()=>{a=(new Date).getTime(),null===o&&(o=a);const e=Math.max(Math.min((a-o)/l,1),0),d=.5-Math.cos(e*Math.PI)/2;let h=s+d*(r-s);if(c(h,r)&&(h=r),t.wrapperEl.scrollTo({[i]:h}),c(h,r))return t.wrapperEl.style.overflow="hidden",t.wrapperEl.style.scrollSnapType="",setTimeout(()=>{t.wrapperEl.style.overflow="",t.wrapperEl.scrollTo({[i]:h})}),void n.cancelAnimationFrame(t.cssModeFrameID);t.cssModeFrameID=n.requestAnimationFrame(u)};u()}function sn(e){return e.querySelector(".swiper-slide-transform")||e.shadowRoot&&e.shadowRoot.querySelector(".swiper-slide-transform")||e}function an(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 on(e){try{return void console.warn(e)}catch(e){}}function ln(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 dn(e,t){return qi().getComputedStyle(e,null).getPropertyValue(t)}function cn(e){let t,r=e;if(r){for(t=0;null!==(r=r.previousSibling);)1===r.nodeType&&(t+=1);return t}}function un(e,t,r){const i=qi();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 hn(e){return(Array.isArray(e)?e:[e]).filter(e=>!!e)}let fn,pn,mn;function gn(){return fn||(fn=function(){const e=qi(),t=Yi();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}()),fn}function vn(e){return void 0===e&&(e={}),pn||(pn=function(e){let{userAgent:t}=void 0===e?{}:e;const r=gn(),i=qi(),n=i.navigator.platform,s=t||i.navigator.userAgent,a={ios:!1,android:!1},o=i.screen.width,l=i.screen.height,d=s.match(/(Android);?[\s\/]+([\d.]+)?/);let c=s.match(/(iPad).*OS\s([\d_]+)/);const u=s.match(/(iPod)(.*OS\s([\d_]+))?/),h=!c&&s.match(/(iPhone\sOS|iOS)\s([\d_]+)/),f="Win32"===n;let p="MacIntel"===n;return!c&&p&&r.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${o}x${l}`)>=0&&(c=s.match(/(Version)\/([\d.]+)/),c||(c=[0,1,"13_0_0"]),p=!1),d&&!f&&(a.os="android",a.android=!0),(c||h||u)&&(a.os="ios",a.ios=!0),a}(e)),pn}function yn(){return mn||(mn=function(){const e=qi(),t=vn();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 n=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),s=i();return{isSafari:r||s,needPerspectiveFix:r,need3dFix:s||n&&t.ios,isWebView:n}}()),mn}var bn={on(e,t,r){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;const n=r?"unshift":"push";return e.split(" ").forEach(e=>{i.eventsListeners[e]||(i.eventsListeners[e]=[]),i.eventsListeners[e][n](t)}),i},once(e,t,r){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;function n(){i.off(e,n),n.__emitterProxy&&delete n.__emitterProxy;for(var r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];t.apply(i,s)}return n.__emitterProxy=t,i.on(e,n,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,n)=>{(i===t||i.__emitterProxy&&i.__emitterProxy===t)&&r.eventsListeners[e].splice(n,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 n=arguments.length,s=new Array(n),a=0;a<n;a++)s[a]=arguments[a];"string"==typeof s[0]||Array.isArray(s[0])?(t=s[0],r=s.slice(1,s.length),i=e):(t=s[0].events,r=s[0].data,i=s[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 En=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const wn=(e,t,r)=>{t&&!e.classList.contains(r)?e.classList.add(r):!t&&e.classList.contains(r)&&e.classList.remove(r)};const Sn=(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()}},Tn=(e,t)=>{if(!e.slides[t])return;const r=e.slides[t].querySelector('[loading="lazy"]');r&&r.removeAttribute("loading")},xn=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),n=e.activeIndex;if(e.params.grid&&e.params.grid.rows>1){const r=n,s=[r-t];return s.push(...Array.from({length:t}).map((e,t)=>r+i+t)),void e.slides.forEach((t,r)=>{s.includes(t.column)&&Tn(e,r)})}const s=n+i-1;if(e.params.rewind||e.params.loop)for(let i=n-t;i<=s+t;i+=1){const t=(i%r+r)%r;(t<n||t>s)&&Tn(e,t)}else for(let i=Math.max(n-t,0);i<=Math.min(s+t,r-1);i+=1)i!==n&&(i>s||i<n)&&Tn(e,i)};var An={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(dn(i,"padding-left")||0,10)-parseInt(dn(i,"padding-right")||0,10),r=r-parseInt(dn(i,"padding-top")||0,10)-parseInt(dn(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:n,size:s,rtlTranslate:a,wrongRTL:o}=e,l=e.virtual&&r.virtual.enabled,d=l?e.virtual.slides.length:e.slides.length,c=an(n,`.${e.params.slideClass}, swiper-slide`),u=l?e.virtual.slides.length:c.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===s)return;"string"==typeof b&&b.indexOf("%")>=0?b=parseFloat(b.replace("%",""))/100*s:"string"==typeof b&&(b=parseFloat(b)),e.virtualSize=-b,c.forEach(e=>{a?e.style.marginLeft="":e.style.marginRight="",e.style.marginBottom="",e.style.marginTop=""}),r.centeredSlides&&r.cssMode&&(rn(i,"--swiper-centered-offset-before",""),rn(i,"--swiper-centered-offset-after",""));const T=r.grid&&r.grid.rows>1&&e.grid;let x;T?e.grid.initSlides(c):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 n;if(x=0,c[i]&&(n=c[i]),T&&e.grid.updateSlide(i,n,c),!c[i]||"none"!==dn(n,"display")){if("auto"===r.slidesPerView){A&&(c[i].style[e.getDirectionLabel("width")]="");const s=getComputedStyle(n),a=n.style.transform,o=n.style.webkitTransform;if(a&&(n.style.transform="none"),o&&(n.style.webkitTransform="none"),r.roundLengths)x=e.isHorizontal()?un(n,"width"):un(n,"height");else{const e=t(s,"width"),r=t(s,"padding-left"),i=t(s,"padding-right"),a=t(s,"margin-left"),o=t(s,"margin-right"),l=s.getPropertyValue("box-sizing");if(l&&"border-box"===l)x=e+a+o;else{const{clientWidth:t,offsetWidth:s}=n;x=e+r+i+a+o+(s-t)}}a&&(n.style.transform=a),o&&(n.style.webkitTransform=o),r.roundLengths&&(x=Math.floor(x))}else x=(s-(r.slidesPerView-1)*b)/r.slidesPerView,r.roundLengths&&(x=Math.floor(x)),c[i]&&(c[i].style[e.getDirectionLabel("width")]=`${x}px`);c[i]&&(c[i].swiperSlideSize=x),p.push(x),r.centeredSlides?(E=E+x/2+w/2+b,0===w&&0!==i&&(E=E-s/2-b),0===i&&(E=E-s/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,s)+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 n=h[i];r.roundLengths&&(n=Math.floor(n)),h[i]<=e.virtualSize-s&&t.push(n)}h=t,Math.floor(e.virtualSize-s)-Math.floor(h[h.length-1])>1&&h.push(e.virtualSize-s)}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),n=t*r.slidesPerGroup;for(let e=0;e<i;e+=1)h.push(h[h.length-1]+n)}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");c.filter((e,t)=>!(r.cssMode&&!r.loop)||t!==c.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>s?e-s: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<s){const r=(s-e-t)/2;h.forEach((e,t)=>{h[t]=e-r}),f.forEach((e,t)=>{f[t]=e+r})}}if(Object.assign(e,{slides:c,snapGrid:h,slidesGrid:f,slidesSizesGrid:p}),r.centeredSlides&&r.cssMode&&!r.centeredSlidesBounds){rn(i,"--swiper-centered-offset-before",-h[0]+"px"),rn(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!==d&&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 n,s=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(n=0;n<Math.ceil(t.params.slidesPerView);n+=1){const e=t.activeIndex+n;if(e>t.slides.length&&!i)break;r.push(a(e))}else r.push(a(t.activeIndex));for(n=0;n<r.length;n+=1)if(void 0!==r[n]){const e=r[n].offsetHeight;s=e>s?e:s}(s||0===s)&&(t.wrapperEl.style.height=`${s}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:n,snapGrid:s}=t;if(0===i.length)return;void 0===i[0].swiperSlideOffset&&t.updateSlidesOffset();let a=-e;n&&(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 d=l.swiperSlideOffset;r.cssMode&&r.centeredSlides&&(d-=i[0].swiperSlideOffset);const c=(a+(r.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+o),u=(a-s[0]+(r.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+o),h=-(a-d),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)),En(l,m,r.slideVisibleClass),En(l,p,r.slideFullyVisibleClass),l.progress=n?-c:c,l.originalProgress=n?-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:n,isBeginning:s,isEnd:a,progressLoop:o}=t;const l=s,d=a;if(0===i)n=0,s=!0,a=!0;else{n=(e-t.minTranslate())/i;const r=Math.abs(e-t.minTranslate())<1,o=Math.abs(e-t.maxTranslate())<1;s=r||n<=0,a=o||n>=1,r&&(n=0),o&&(n=1)}if(r.loop){const r=t.getSlideIndexByData(0),i=t.getSlideIndexByData(t.slides.length-1),n=t.slidesGrid[r],s=t.slidesGrid[i],a=t.slidesGrid[t.slidesGrid.length-1],l=Math.abs(e);o=l>=n?(l-n)/a:(l+a-s)/a,o>1&&(o-=1)}Object.assign(t,{progress:n,progressLoop:o,isBeginning:s,isEnd:a}),(r.watchSlidesProgress||r.centeredSlides&&r.autoHeight)&&t.updateSlidesProgress(e),s&&!l&&t.emit("reachBeginning toEdge"),a&&!d&&t.emit("reachEnd toEdge"),(l&&!s||d&&!a)&&t.emit("fromEdge"),t.emit("progress",n)},updateSlidesClasses:function(){const e=this,{slides:t,params:r,slidesEl:i,activeIndex:n}=e,s=e.virtual&&r.virtual.enabled,a=e.grid&&r.grid&&r.grid.rows>1,o=e=>an(i,`.${r.slideClass}${e}, swiper-slide${e}`)[0];let l,d,c;if(s)if(r.loop){let t=n-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="${n}"]`);else a?(l=t.filter(e=>e.column===n)[0],c=t.filter(e=>e.column===n+1)[0],d=t.filter(e=>e.column===n-1)[0]):l=t[n];l&&(a||(c=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&&!c&&(c=t[0]),d=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===!d&&(d=t[t.length-1]))),t.forEach(e=>{wn(e,e===l,r.slideActiveClass),wn(e,e===c,r.slideNextClass),wn(e,e===d,r.slidePrevClass)}),e.emitSlidesClasses()},updateActiveIndex:function(e){const t=this,r=t.rtlTranslate?t.translate:-t.translate,{snapGrid:i,params:n,activeIndex:s,realIndex:a,snapIndex:o}=t;let l,d=e;const c=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===d&&(d=function(e){const{slidesGrid:t,params:r}=e,i=e.rtlTranslate?e.translate:-e.translate;let n;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?n=e:i>=t[e]&&i<t[e+1]&&(n=e+1):i>=t[e]&&(n=e);return r.normalizeSlideIndex&&(n<0||void 0===n)&&(n=0),n}(t)),i.indexOf(r)>=0)l=i.indexOf(r);else{const e=Math.min(n.slidesPerGroupSkip,d);l=e+Math.floor((d-e)/n.slidesPerGroup)}if(l>=i.length&&(l=i.length-1),d===s&&!t.params.loop)return void(l!==o&&(t.snapIndex=l,t.emit("snapIndexChange")));if(d===s&&t.params.loop&&t.virtual&&t.params.virtual.enabled)return void(t.realIndex=c(d));const u=t.grid&&n.grid&&n.grid.rows>1;let h;if(t.virtual&&n.virtual.enabled&&n.loop)h=c(d);else if(u){const e=t.slides.filter(e=>e.column===d)[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/n.grid.rows)}else if(t.slides[d]){const e=t.slides[d].getAttribute("data-swiper-slide-index");h=e?parseInt(e,10):d}else h=d;Object.assign(t,{previousSnapIndex:o,snapIndex:l,previousRealIndex:a,realIndex:h,previousIndex:s,activeIndex:d}),t.initialized&&xn(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 n=e.closest(`.${i.slideClass}, swiper-slide`);!n&&r.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach(e=>{!n&&e.matches&&e.matches(`.${i.slideClass}, swiper-slide`)&&(n=e)});let s,a=!1;if(n)for(let e=0;e<r.slides.length;e+=1)if(r.slides[e]===n){a=!0,s=e;break}if(!n||!a)return r.clickedSlide=void 0,void(r.clickedIndex=void 0);r.clickedSlide=n,r.virtual&&r.params.virtual.enabled?r.clickedIndex=parseInt(n.getAttribute("data-swiper-slide-index"),10):r.clickedIndex=s,i.slideToClickedSlide&&void 0!==r.clickedIndex&&r.clickedIndex!==r.activeIndex&&r.slideToClickedSlide()}};var kn={getTranslate:function(e){void 0===e&&(e=this.isHorizontal()?"x":"y");const{params:t,rtlTranslate:r,translate:i,wrapperEl:n}=this;if(t.virtualTranslate)return r?-i:i;if(t.cssMode)return i;let s=Zi(n,e);return s+=this.cssOverflowAdjustment(),r&&(s=-s),s||0},setTranslate:function(e,t){const r=this,{rtlTranslate:i,params:n,wrapperEl:s,progress:a}=r;let o,l=0,d=0;r.isHorizontal()?l=i?-e:e:d=e,n.roundLengths&&(l=Math.floor(l),d=Math.floor(d)),r.previousTranslate=r.translate,r.translate=r.isHorizontal()?l:d,n.cssMode?s[r.isHorizontal()?"scrollLeft":"scrollTop"]=r.isHorizontal()?-l:-d:n.virtualTranslate||(r.isHorizontal()?l-=r.cssOverflowAdjustment():d-=r.cssOverflowAdjustment(),s.style.transform=`translate3d(${l}px, ${d}px, 0px)`);const c=r.maxTranslate()-r.minTranslate();o=0===c?0:(e-r.minTranslate())/c,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,n){void 0===e&&(e=0),void 0===t&&(t=this.params.speed),void 0===r&&(r=!0),void 0===i&&(i=!0);const s=this,{params:a,wrapperEl:o}=s;if(s.animating&&a.preventInteractionOnTransition)return!1;const l=s.minTranslate(),d=s.maxTranslate();let c;if(c=i&&e>l?l:i&&e<d?d:e,s.updateProgress(c),a.cssMode){const e=s.isHorizontal();if(0===t)o[e?"scrollLeft":"scrollTop"]=-c;else{if(!s.support.smoothScroll)return nn({swiper:s,targetPosition:-c,side:e?"left":"top"}),!0;o.scrollTo({[e?"left":"top"]:-c,behavior:"smooth"})}return!0}return 0===t?(s.setTransition(0),s.setTranslate(c),r&&(s.emit("beforeTransitionStart",t,n),s.emit("transitionEnd"))):(s.setTransition(t),s.setTranslate(c),r&&(s.emit("beforeTransitionStart",t,n),s.emit("transitionStart")),s.animating||(s.animating=!0,s.onTranslateToWrapperTransitionEnd||(s.onTranslateToWrapperTransitionEnd=function(e){s&&!s.destroyed&&e.target===this&&(s.wrapperEl.removeEventListener("transitionend",s.onTranslateToWrapperTransitionEnd),s.onTranslateToWrapperTransitionEnd=null,delete s.onTranslateToWrapperTransitionEnd,s.animating=!1,r&&s.emit("transitionEnd"))}),s.wrapperEl.addEventListener("transitionend",s.onTranslateToWrapperTransitionEnd))),!0}};function Ln(e){let{swiper:t,runCallbacks:r,direction:i,step:n}=e;const{activeIndex:s,previousIndex:a}=t;let o=i;if(o||(o=s>a?"next":s<a?"prev":"reset"),t.emit(`transition${n}`),r&&s!==a){if("reset"===o)return void t.emit(`slideResetTransition${n}`);t.emit(`slideChangeTransition${n}`),"next"===o?t.emit(`slideNextTransition${n}`):t.emit(`slidePrevTransition${n}`)}}var In={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(),Ln({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),Ln({swiper:r,runCallbacks:e,direction:t,step:"End"}))}};var Rn={slideTo:function(e,t,r,i,n){void 0===e&&(e=0),void 0===r&&(r=!0),"string"==typeof e&&(e=parseInt(e,10));const s=this;let a=e;a<0&&(a=0);const{params:o,snapGrid:l,slidesGrid:d,previousIndex:c,activeIndex:u,rtlTranslate:h,wrapperEl:f,enabled:p}=s;if(!p&&!i&&!n||s.destroyed||s.animating&&o.preventInteractionOnTransition)return!1;void 0===t&&(t=s.params.speed);const m=Math.min(s.params.slidesPerGroupSkip,a);let g=m+Math.floor((a-m)/s.params.slidesPerGroup);g>=l.length&&(g=l.length-1);const v=-l[g];if(o.normalizeSlideIndex)for(let e=0;e<d.length;e+=1){const t=-Math.floor(100*v),r=Math.floor(100*d[e]),i=Math.floor(100*d[e+1]);void 0!==d[e+1]?t>=r&&t<i-(i-r)/2?a=e:t>=r&&t<i&&(a=e+1):t>=r&&(a=e)}if(s.initialized&&a!==u){if(!s.allowSlideNext&&(h?v>s.translate&&v>s.minTranslate():v<s.translate&&v<s.minTranslate()))return!1;if(!s.allowSlidePrev&&v>s.translate&&v>s.maxTranslate()&&(u||0)!==a)return!1}let y;a!==(c||0)&&r&&s.emit("beforeSlideChangeStart"),s.updateProgress(v),y=a>u?"next":a<u?"prev":"reset";const b=s.virtual&&s.params.virtual.enabled;if(!(b&&n)&&(h&&-v===s.translate||!h&&v===s.translate))return s.updateActiveIndex(a),o.autoHeight&&s.updateAutoHeight(),s.updateSlidesClasses(),"slide"!==o.effect&&s.setTranslate(v),"reset"!==y&&(s.transitionStart(r,y),s.transitionEnd(r,y)),!1;if(o.cssMode){const e=s.isHorizontal(),r=h?v:-v;if(0===t)b&&(s.wrapperEl.style.scrollSnapType="none",s._immediateVirtual=!0),b&&!s._cssModeVirtualInitialSet&&s.params.initialSlide>0?(s._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{f[e?"scrollLeft":"scrollTop"]=r})):f[e?"scrollLeft":"scrollTop"]=r,b&&requestAnimationFrame(()=>{s.wrapperEl.style.scrollSnapType="",s._immediateVirtual=!1});else{if(!s.support.smoothScroll)return nn({swiper:s,targetPosition:r,side:e?"left":"top"}),!0;f.scrollTo({[e?"left":"top"]:r,behavior:"smooth"})}return!0}return s.setTransition(t),s.setTranslate(v),s.updateActiveIndex(a),s.updateSlidesClasses(),s.emit("beforeTransitionStart",t,i),s.transitionStart(r,y),0===t?s.transitionEnd(r,y):s.animating||(s.animating=!0,s.onSlideToWrapperTransitionEnd||(s.onSlideToWrapperTransitionEnd=function(e){s&&!s.destroyed&&e.target===this&&(s.wrapperEl.removeEventListener("transitionend",s.onSlideToWrapperTransitionEnd),s.onSlideToWrapperTransitionEnd=null,delete s.onSlideToWrapperTransitionEnd,s.transitionEnd(r,y))}),s.wrapperEl.addEventListener("transitionend",s.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 n=this;if(n.destroyed)return;void 0===t&&(t=n.params.speed);const s=n.grid&&n.params.grid&&n.params.grid.rows>1;let a=e;if(n.params.loop)if(n.virtual&&n.params.virtual.enabled)a+=n.virtual.slidesBefore;else{let e;if(s){const t=a*n.params.grid.rows;e=n.slides.filter(e=>1*e.getAttribute("data-swiper-slide-index")===t)[0].column}else e=n.getSlideIndexByData(a);const t=s?Math.ceil(n.slides.length/n.params.grid.rows):n.slides.length,{centeredSlides:r}=n.params;let o=n.params.slidesPerView;"auto"===o?o=n.slidesPerViewDynamic():(o=Math.ceil(parseFloat(n.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"!==n.params.slidesPerView&&!s&&(l=!1),l){const i=r?e<n.activeIndex?"prev":"next":e-n.activeIndex-1<n.params.slidesPerView?"next":"prev";n.loopFix({direction:i,slideTo:!0,activeSlideIndex:"next"===i?e+1:e-t+1,slideRealIndex:"next"===i?n.realIndex:void 0})}if(s){const e=a*n.params.grid.rows;a=n.slides.filter(t=>1*t.getAttribute("data-swiper-slide-index")===e)[0].column}else a=n.getSlideIndexByData(a)}return requestAnimationFrame(()=>{n.slideTo(a,t,r,i)}),n},slideNext:function(e,t,r){void 0===t&&(t=!0);const i=this,{enabled:n,params:s,animating:a}=i;if(!n||i.destroyed)return i;void 0===e&&(e=i.params.speed);let o=s.slidesPerGroup;"auto"===s.slidesPerView&&1===s.slidesPerGroup&&s.slidesPerGroupAuto&&(o=Math.max(i.slidesPerViewDynamic("current",!0),1));const l=i.activeIndex<s.slidesPerGroupSkip?1:o,d=i.virtual&&s.virtual.enabled;if(s.loop){if(a&&!d&&s.loopPreventsSliding)return!1;if(i.loopFix({direction:"next"}),i._clientLeft=i.wrapperEl.clientLeft,i.activeIndex===i.slides.length-1&&s.cssMode)return requestAnimationFrame(()=>{i.slideTo(i.activeIndex+l,e,t,r)}),!0}return s.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:n,snapGrid:s,slidesGrid:a,rtlTranslate:o,enabled:l,animating:d}=i;if(!l||i.destroyed)return i;void 0===e&&(e=i.params.speed);const c=i.virtual&&n.virtual.enabled;if(n.loop){if(d&&!c&&n.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=s.map(e=>u(e));let p=s[f.indexOf(h)-1];if(void 0===p&&n.cssMode){let e;s.forEach((t,r)=>{h>=t&&(e=r)}),void 0!==e&&(p=s[e>0?e-1:e])}let m=0;if(void 0!==p&&(m=a.indexOf(p),m<0&&(m=i.activeIndex-1),"auto"===n.slidesPerView&&1===n.slidesPerGroup&&n.slidesPerGroupAuto&&(m=m-i.slidesPerViewDynamic("previous",!0)+1,m=Math.max(m,0))),n.rewind&&i.isBeginning){const n=i.params.virtual&&i.params.virtual.enabled&&i.virtual?i.virtual.slides.length-1:i.slides.length-1;return i.slideTo(n,e,t,r)}return n.loop&&0===i.activeIndex&&n.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 n=this;if(n.destroyed)return;void 0===e&&(e=n.params.speed);let s=n.activeIndex;const a=Math.min(n.params.slidesPerGroupSkip,s),o=a+Math.floor((s-a)/n.params.slidesPerGroup),l=n.rtlTranslate?n.translate:-n.translate;if(l>=n.snapGrid[o]){const e=n.snapGrid[o];l-e>(n.snapGrid[o+1]-e)*i&&(s+=n.params.slidesPerGroup)}else{const e=n.snapGrid[o-1];l-e<=(n.snapGrid[o]-e)*i&&(s-=n.params.slidesPerGroup)}return s=Math.max(s,0),s=Math.min(s,n.slidesGrid.length-1),n.slideTo(s,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 n,s=e.clickedIndex;const a=e.isElement?"swiper-slide":`.${t.slideClass}`;if(t.loop){if(e.animating)return;n=parseInt(e.clickedSlide.getAttribute("data-swiper-slide-index"),10),t.centeredSlides?s<e.loopedSlides-i/2||s>e.slides.length-e.loopedSlides+i/2?(e.loopFix(),s=e.getSlideIndex(an(r,`${a}[data-swiper-slide-index="${n}"]`)[0]),Xi(()=>{e.slideTo(s)})):e.slideTo(s):s>e.slides.length-i?(e.loopFix(),s=e.getSlideIndex(an(r,`${a}[data-swiper-slide-index="${n}"]`)[0]),Xi(()=>{e.slideTo(s)})):e.slideTo(s)}else e.slideTo(s)}};var Pn={loopCreate:function(e){const t=this,{params:r,slidesEl:i}=t;if(!r.loop||t.virtual&&t.params.virtual.enabled)return;const n=()=>{an(i,`.${r.slideClass}, swiper-slide`).forEach((e,t)=>{e.setAttribute("data-swiper-slide-index",t)})},s=t.grid&&r.grid&&r.grid.rows>1,a=r.slidesPerGroup*(s?r.grid.rows:1),o=t.slides.length%a!==0,l=s&&t.slides.length%r.grid.rows!==0,d=e=>{for(let i=0;i<e;i+=1){const e=t.isElement?ln("swiper-slide",[r.slideBlankClass]):ln("div",[r.slideClass,r.slideBlankClass]);t.slidesEl.append(e)}};if(o){if(r.loopAddBlankSlides){d(a-t.slides.length%a),t.recalcSlides(),t.updateSlides()}else on("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)");n()}else if(l){if(r.loopAddBlankSlides){d(r.grid.rows-t.slides.length%r.grid.rows),t.recalcSlides(),t.updateSlides()}else on("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)");n()}else n();t.loopFix({slideRealIndex:e,direction:r.centeredSlides?void 0:"next"})},loopFix:function(e){let{slideRealIndex:t,slideTo:r=!0,direction:i,setTranslate:n,activeSlideIndex:s,byController:a,byMousewheel:o}=void 0===e?{}:e;const l=this;if(!l.params.loop)return;l.emit("beforeLoopFix");const{slides:d,allowSlidePrev:c,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=c,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;d.length<m+v?on("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&&on("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");const b=[],E=[];let w=l.activeIndex;void 0===s?s=l.getSlideIndex(d.filter(e=>e.classList.contains(f.slideActiveClass))[0]):w=s;const S="next"===i||!i,T="prev"===i||!i;let x=0,A=0;const k=y?Math.ceil(d.length/f.grid.rows):d.length,L=(y?d[s].column:s)+(p&&void 0===n?-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=d.length-1;t>=0;t-=1)d[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?d.forEach((e,r)=>{e.column===t&&E.push(r)}):E.push(t)}}if(l.__preventObserver__=!0,requestAnimationFrame(()=>{l.__preventObserver__=!1}),T&&b.forEach(e=>{d[e].swiperLoopMoveDOM=!0,h.prepend(d[e]),d[e].swiperLoopMoveDOM=!1}),S&&E.forEach(e=>{d[e].swiperLoopMoveDOM=!0,h.append(d[e]),d[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),n&&(l.touchEventsData.startTranslate=l.touchEventsData.startTranslate-t,l.touchEventsData.currentTranslate=l.touchEventsData.currentTranslate-t))}else if(n){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),n&&(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=c,l.allowSlideNext=u,l.controller&&l.controller.control&&!a){const e={slideRealIndex:t,direction:i,setTranslate:n,activeSlideIndex:s,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 Dn(e,t,r){const i=qi(),{params:n}=e,s=n.edgeSwipeDetection,a=n.edgeSwipeThreshold;return!s||!(r<=a||r>=i.innerWidth-a)||"prevent"===s&&(t.preventDefault(),!0)}function Cn(e){const t=this,r=Yi();let i=e;i.originalEvent&&(i=i.originalEvent);const n=t.touchEventsData;if("pointerdown"===i.type){if(null!==n.pointerId&&n.pointerId!==i.pointerId)return;n.pointerId=i.pointerId}else"touchstart"===i.type&&1===i.targetTouches.length&&(n.touchId=i.targetTouches[0].identifier);if("touchstart"===i.type)return void Dn(t,i,i.targetTouches[0].pageX);const{params:s,touches:a,enabled:o}=t;if(!o)return;if(!s.simulateTouch&&"mouse"===i.pointerType)return;if(t.animating&&s.preventInteractionOnTransition)return;!t.animating&&s.cssMode&&s.loop&&t.loopFix();let l=i.target;if("wrapper"===s.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(n.isTouched&&n.isMoved)return;const d=!!s.noSwipingClass&&""!==s.noSwipingClass,c=i.composedPath?i.composedPath():i.path;d&&i.target&&i.target.shadowRoot&&c&&(l=c[0]);const u=s.noSwipingSelector?s.noSwipingSelector:`.${s.noSwipingClass}`,h=!(!i.target||!i.target.shadowRoot);if(s.noSwiping&&(h?function(e,t){return void 0===t&&(t=this),function t(r){if(!r||r===Yi()||r===qi())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(s.swipeHandler&&!l.closest(s.swipeHandler))return;a.currentX=i.pageX,a.currentY=i.pageY;const f=a.currentX,p=a.currentY;if(!Dn(t,i,f))return;Object.assign(n,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),a.startX=f,a.startY=p,n.touchStartTime=Qi(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,s.threshold>0&&(n.allowThresholdMove=!1);let m=!0;l.matches(n.focusableElements)&&(m=!1,"SELECT"===l.nodeName&&(n.isTouched=!1)),r.activeElement&&r.activeElement.matches(n.focusableElements)&&r.activeElement!==l&&("mouse"===i.pointerType||"mouse"!==i.pointerType&&!l.matches(n.focusableElements))&&r.activeElement.blur();const g=m&&t.allowTouchMove&&s.touchStartPreventDefault;!s.touchStartForcePreventDefault&&!g||l.isContentEditable||i.preventDefault(),s.freeMode&&s.freeMode.enabled&&t.freeMode&&t.animating&&!s.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",i)}function _n(e){const t=Yi(),r=this,i=r.touchEventsData,{params:n,touches:s,rtlTranslate:a,enabled:o}=r;if(!o)return;if(!n.simulateTouch&&"mouse"===e.pointerType)return;let l,d=e;if(d.originalEvent&&(d=d.originalEvent),"pointermove"===d.type){if(null!==i.touchId)return;if(d.pointerId!==i.pointerId)return}if("touchmove"===d.type){if(l=[...d.changedTouches].filter(e=>e.identifier===i.touchId)[0],!l||l.identifier!==i.touchId)return}else l=d;if(!i.isTouched)return void(i.startMoving&&i.isScrolling&&r.emit("touchMoveOpposite",d));const c=l.pageX,u=l.pageY;if(d.preventedByNestedSwiper)return s.startX=c,void(s.startY=u);if(!r.allowTouchMove)return d.target.matches(i.focusableElements)||(r.allowClick=!1),void(i.isTouched&&(Object.assign(s,{startX:c,startY:u,currentX:c,currentY:u}),i.touchStartTime=Qi()));if(n.touchReleaseOnEdges&&!n.loop)if(r.isVertical()){if(u<s.startY&&r.translate<=r.maxTranslate()||u>s.startY&&r.translate>=r.minTranslate())return i.isTouched=!1,void(i.isMoved=!1)}else if(c<s.startX&&r.translate<=r.maxTranslate()||c>s.startX&&r.translate>=r.minTranslate())return;if(t.activeElement&&t.activeElement.matches(i.focusableElements)&&t.activeElement!==d.target&&"mouse"!==d.pointerType&&t.activeElement.blur(),t.activeElement&&d.target===t.activeElement&&d.target.matches(i.focusableElements))return i.isMoved=!0,void(r.allowClick=!1);i.allowTouchCallbacks&&r.emit("touchMove",d),s.previousX=s.currentX,s.previousY=s.currentY,s.currentX=c,s.currentY=u;const h=s.currentX-s.startX,f=s.currentY-s.startY;if(r.params.threshold&&Math.sqrt(h**2+f**2)<r.params.threshold)return;if(void 0===i.isScrolling){let e;r.isHorizontal()&&s.currentY===s.startY||r.isVertical()&&s.currentX===s.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>n.touchAngle:90-e>n.touchAngle)}if(i.isScrolling&&r.emit("touchMoveOpposite",d),void 0===i.startMoving&&(s.currentX===s.startX&&s.currentY===s.startY||(i.startMoving=!0)),i.isScrolling||"touchmove"===d.type&&i.preventTouchMoveFromPointerMove)return void(i.isTouched=!1);if(!i.startMoving)return;r.allowClick=!1,!n.cssMode&&d.cancelable&&d.preventDefault(),n.touchMoveStopPropagation&&!n.nested&&d.stopPropagation();let p=r.isHorizontal()?h:f,m=r.isHorizontal()?s.currentX-s.previousX:s.currentY-s.previousY;n.oneWayMovement&&(p=Math.abs(p)*(a?1:-1),m=Math.abs(m)*(a?1:-1)),s.diff=p,p*=n.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&&!n.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,!n.grabCursor||!0!==r.allowSlideNext&&!0!==r.allowSlidePrev||r.setGrabCursor(!0),r.emit("sliderFirstMove",d)}if((new Date).getTime(),i.isMoved&&i.allowThresholdMove&&g!==r.touchesDirection&&v&&y&&Math.abs(p)>=1)return Object.assign(s,{startX:c,startY:u,currentX:c,currentY:u,startTranslate:i.currentTranslate}),i.loopSwapReset=!0,void(i.startTranslate=i.currentTranslate);r.emit("sliderMove",d),i.isMoved=!0,i.currentTranslate=p+i.startTranslate;let b=!0,E=n.resistanceRatio;if(n.touchReleaseOnEdges&&(E=0),p>0?(v&&y&&i.allowThresholdMove&&i.currentTranslate>(n.centeredSlides?r.minTranslate()-r.slidesSizesGrid[r.activeIndex+1]-("auto"!==n.slidesPerView&&r.slides.length-n.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,n.resistance&&(i.currentTranslate=r.minTranslate()-1+(-r.minTranslate()+i.startTranslate+p)**E))):p<0&&(v&&y&&i.allowThresholdMove&&i.currentTranslate<(n.centeredSlides?r.maxTranslate()+r.slidesSizesGrid[r.slidesSizesGrid.length-1]+r.params.spaceBetween+("auto"!==n.slidesPerView&&r.slides.length-n.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"===n.slidesPerView?r.slidesPerViewDynamic():Math.ceil(parseFloat(n.slidesPerView,10)))}),i.currentTranslate<r.maxTranslate()&&(b=!1,n.resistance&&(i.currentTranslate=r.maxTranslate()+1-(r.maxTranslate()-i.startTranslate-p)**E))),b&&(d.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),n.threshold>0){if(!(Math.abs(p)>n.threshold||i.allowThresholdMove))return void(i.currentTranslate=i.startTranslate);if(!i.allowThresholdMove)return i.allowThresholdMove=!0,s.startX=s.currentX,s.startY=s.currentY,i.currentTranslate=i.startTranslate,void(s.diff=r.isHorizontal()?s.currentX-s.startX:s.currentY-s.startY)}n.followFinger&&!n.cssMode&&((n.freeMode&&n.freeMode.enabled&&r.freeMode||n.watchSlidesProgress)&&(r.updateActiveIndex(),r.updateSlidesClasses()),n.freeMode&&n.freeMode.enabled&&r.freeMode&&r.freeMode.onTouchMove(),r.updateProgress(i.currentTranslate),r.setTranslate(i.currentTranslate))}function On(e){const t=this,r=t.touchEventsData;let i,n=e;n.originalEvent&&(n=n.originalEvent);if("touchend"===n.type||"touchcancel"===n.type){if(i=[...n.changedTouches].filter(e=>e.identifier===r.touchId)[0],!i||i.identifier!==r.touchId)return}else{if(null!==r.touchId)return;if(n.pointerId!==r.pointerId)return;i=n}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(n.type)){if(!(["pointercancel","contextmenu"].includes(n.type)&&(t.browser.isSafari||t.browser.isWebView)))return}r.pointerId=null,r.touchId=null;const{params:s,touches:a,rtlTranslate:o,slidesGrid:l,enabled:d}=t;if(!d)return;if(!s.simulateTouch&&"mouse"===n.pointerType)return;if(r.allowTouchCallbacks&&t.emit("touchEnd",n),r.allowTouchCallbacks=!1,!r.isTouched)return r.isMoved&&s.grabCursor&&t.setGrabCursor(!1),r.isMoved=!1,void(r.startMoving=!1);s.grabCursor&&r.isMoved&&r.isTouched&&(!0===t.allowSlideNext||!0===t.allowSlidePrev)&&t.setGrabCursor(!1);const c=Qi(),u=c-r.touchStartTime;if(t.allowClick){const e=n.path||n.composedPath&&n.composedPath();t.updateClickedSlide(e&&e[0]||n.target,e),t.emit("tap click",n),u<300&&c-r.lastClickTime<300&&t.emit("doubleTap doubleClick",n)}if(r.lastClickTime=Qi(),Xi(()=>{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=s.followFinger?o?t.translate:-t.translate:-r.currentTranslate,s.cssMode)return;if(s.freeMode&&s.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<s.slidesPerGroupSkip?1:s.slidesPerGroup){const t=e<s.slidesPerGroupSkip-1?1:s.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;s.rewind&&(t.isBeginning?v=s.virtual&&s.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<s.slidesPerGroupSkip-1?1:s.slidesPerGroup;if(u>s.longSwipesMs){if(!s.longSwipes)return void t.slideTo(t.activeIndex);"next"===t.swipeDirection&&(y>=s.longSwipesRatio?t.slideTo(s.rewind&&t.isEnd?g:p+b):t.slideTo(p)),"prev"===t.swipeDirection&&(y>1-s.longSwipesRatio?t.slideTo(p+b):null!==v&&y<0&&Math.abs(y)>s.longSwipesRatio?t.slideTo(v):t.slideTo(p))}else{if(!s.shortSwipes)return void t.slideTo(t.activeIndex);t.navigation&&(n.target===t.navigation.nextEl||n.target===t.navigation.prevEl)?n.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 Mn(){const e=this,{params:t,el:r}=e;if(r&&0===r.offsetWidth)return;t.breakpoints&&e.setBreakpoint();const{allowSlideNext:i,allowSlidePrev:n,snapGrid:s}=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=n,e.allowSlideNext=i,e.params.watchOverflow&&s!==e.snapGrid&&e.checkOverflow()}function Nn(e){const t=this;t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function Fn(){const e=this,{wrapperEl:t,rtlTranslate:r,enabled:i}=e;if(!i)return;let n;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 s=e.maxTranslate()-e.minTranslate();n=0===s?0:(e.translate-e.minTranslate())/s,n!==e.progress&&e.updateProgress(r?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}function $n(e){const t=this;Sn(t,e.target),t.params.cssMode||"auto"!==t.params.slidesPerView&&!t.params.autoHeight||t.update()}function Bn(){const e=this;e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}const Un=(e,t)=>{const r=Yi(),{params:i,el:n,wrapperEl:s,device:a}=e,o=!!i.nested,l="on"===t?"addEventListener":"removeEventListener",d=t;n&&"string"!=typeof n&&(r[l]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:o}),n[l]("touchstart",e.onTouchStart,{passive:!1}),n[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)&&n[l]("click",e.onClick,!0),i.cssMode&&s[l]("scroll",e.onScroll),i.updateOnWindowResize?e[d](a.ios||a.android?"resize orientationchange observerUpdate":"resize observerUpdate",Mn,!0):e[d]("observerUpdate",Mn,!0),n[l]("load",e.onLoad,{capture:!0}))};const zn=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var Gn={setBreakpoint:function(){const e=this,{realIndex:t,initialized:r,params:i,el:n}=e,s=i.breakpoints;if(!s||s&&0===Object.keys(s).length)return;const a=e.getBreakpoint(s,e.params.breakpointsBase,e.el);if(!a||e.currentBreakpoint===a)return;const o=(a in s?s[a]:void 0)||e.originalParams,l=zn(e,i),d=zn(e,o),c=e.params.grabCursor,u=o.grabCursor,h=i.enabled;l&&!d?(n.classList.remove(`${i.containerModifierClass}grid`,`${i.containerModifierClass}grid-column`),e.emitContainerClasses()):!l&&d&&(n.classList.add(`${i.containerModifierClass}grid`),(o.grid.fill&&"column"===o.grid.fill||!o.grid.fill&&"column"===i.grid.fill)&&n.classList.add(`${i.containerModifierClass}grid-column`),e.emitContainerClasses()),c&&!u?e.unsetGrabCursor():!c&&u&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(t=>{if(void 0===o[t])return;const r=i[t]&&i[t].enabled,n=o[t]&&o[t].enabled;r&&!n&&e[t].disable(),!r&&n&&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(),tn(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 n=qi(),s="window"===t?n.innerHeight:r.clientHeight,a=Object.keys(e).map(e=>{if("string"==typeof e&&0===e.indexOf("@")){const t=parseFloat(e.substr(1));return{value:s*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:s,value:o}=a[e];"window"===t?n.matchMedia(`(min-width: ${o}px)`).matches&&(i=s):o<=r.clientWidth&&(i=s)}return i||"max"}};var jn={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 Hn(e,t){return function(r){void 0===r&&(r={});const i=Object.keys(r)[0],n=r[i];"object"==typeof n&&null!==n?(!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 n?("object"!=typeof e[i]||"enabled"in e[i]||(e[i].enabled=!0),e[i]||(e[i]={enabled:!1}),tn(t,r)):tn(t,r)):tn(t,r)}}const Vn={eventsEmitter:bn,update:An,translate:kn,transition:In,slide:Rn,loop:Pn,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=Cn.bind(e),e.onTouchMove=_n.bind(e),e.onTouchEnd=On.bind(e),e.onDocumentTouchStart=Bn.bind(e),t.cssMode&&(e.onScroll=Fn.bind(e)),e.onClick=Nn.bind(e),e.onLoad=$n.bind(e),Un(e,"on")},detachEvents:function(){Un(this,"off")}},breakpoints:Gn,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:n,device:s}=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:s.android},{ios:s.ios},{"css-mode":r.cssMode},{centered:r.cssMode&&r.centeredSlides},{"watch-progress":r.watchSlidesProgress}],r.containerModifierClass);t.push(...a),n.classList.add(...t),e.emitContainerClasses()},removeClasses:function(){const{el:e,classNames:t}=this;e&&"string"!=typeof e&&(e.classList.remove(...t),this.emitContainerClasses())}}},Wn={};let Yn=class e{constructor(){let t,r;for(var i=arguments.length,n=new Array(i),s=0;s<i;s++)n[s]=arguments[s];1===n.length&&n[0].constructor&&"Object"===Object.prototype.toString.call(n[0]).slice(8,-1)?r=n[0]:[t,r]=n,r||(r={}),r=tn({},r),t&&!r.el&&(r.el=t);const a=Yi();if(r.el&&"string"==typeof r.el&&a.querySelectorAll(r.el).length>1){const t=[];return a.querySelectorAll(r.el).forEach(i=>{const n=tn({},r,{el:i});t.push(new e(n))}),t}const o=this;o.__swiper__=!0,o.support=gn(),o.device=vn({userAgent:r.userAgent}),o.browser=yn(),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:Hn(r,l),on:o.on.bind(o),once:o.once.bind(o),off:o.off.bind(o),emit:o.emit.bind(o)})});const d=tn({},jn,l);return o.params=tn({},d,Wn,r),o.originalParams=tn({},o.params),o.passedParams=tn({},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=cn(an(t,`.${r.slideClass}, swiper-slide`)[0]);return cn(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=an(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(),n=(r.maxTranslate()-i)*e+i;r.translateTo(n,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:n,slidesSizesGrid:s,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?n[e]+s[e]-n[o]<a:n[e]-n[o]<a)&&(l+=1)}else for(let e=o-1;e>=0;e-=1){n[o]-n[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 n;if(r.breakpoints&&e.setBreakpoint(),[...e.el.querySelectorAll('[loading="lazy"]')].forEach(t=>{t.complete&&Sn(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;n=e.slideTo(t.length-1,0,!1,!0)}else n=e.slideTo(e.activeIndex,0,!1,!0);n||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 n=(()=>{if(r&&r.shadowRoot&&r.shadowRoot.querySelector){return r.shadowRoot.querySelector(i())}return an(r,i())[0]})();return!n&&t.params.createElements&&(n=ln("div",t.params.wrapperClass),r.append(n),an(r,`.${t.params.slideClass}`).forEach(e=>{n.append(e)})),Object.assign(t,{el:r,wrapperEl:n,slidesEl:t.isElement&&!r.parentNode.host.slideSlots?r.parentNode.host:n,hostEl:t.isElement?r.parentNode.host:r,mounted:!0,rtl:"rtl"===r.dir.toLowerCase()||"rtl"===dn(r,"direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===r.dir.toLowerCase()||"rtl"===dn(r,"direction")),wrongRTL:"-webkit-box"===dn(n,"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?Sn(t,e):e.addEventListener("load",e=>{Sn(t,e.target)})}),xn(t),t.initialized=!0,xn(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:n,wrapperEl:s,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(),n&&"string"!=typeof n&&n.removeAttribute("style"),s&&s.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){tn(Wn,e)}static get extendedDefaults(){return Wn}static get defaults(){return jn}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(Vn).forEach(e=>{Object.keys(Vn[e]).forEach(t=>{Yn.prototype[t]=Vn[e][t]})}),Yn.use([function(e){let{swiper:t,on:r,emit:i}=e;const n=qi();let s=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!==n.ResizeObserver?t&&!t.destroyed&&t.initialized&&(s=new ResizeObserver(e=>{a=n.requestAnimationFrame(()=>{const{width:r,height:i}=t;let n=r,s=i;e.forEach(e=>{let{contentBoxSize:r,contentRect:i,target:a}=e;a&&a!==t.el||(n=i?i.width:(r[0]||r).inlineSize,s=i?i.height:(r[0]||r).blockSize)}),n===r&&s===i||o()})}),s.observe(t.el)):(n.addEventListener("resize",o),n.addEventListener("orientationchange",l))}),r("destroy",()=>{a&&n.cancelAnimationFrame(a),s&&s.unobserve&&t.el&&(s.unobserve(t.el),s=null),n.removeEventListener("resize",o),n.removeEventListener("orientationchange",l)})},function(e){let{swiper:t,extendParams:r,on:i,emit:n}=e;const s=[],a=qi(),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 n("observerUpdate",e[0]);const r=function(){n("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}),s.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",()=>{s.forEach(e=>{e.disconnect()}),s.splice(0,s.length)})}]);const Kn=["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 qn(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)&&!e.__swiper__}function Xn(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]:qn(t[r])&&qn(e[r])&&Object.keys(t[r]).length>0?t[r].__swiper__?e[r]=t[r]:Xn(e[r],t[r]):e[r]=t[r]})}function Qn(e){return void 0===e&&(e={}),e.navigation&&void 0===e.navigation.nextEl&&void 0===e.navigation.prevEl}function Zn(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 es(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 ts(e){return void 0===e&&(e=""),e?e.includes("swiper-wrapper")?e:`swiper-wrapper ${e}`:"swiper-wrapper"}function rs(){return rs=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},rs.apply(this,arguments)}function is(e){return e.type&&e.type.displayName&&e.type.displayName.includes("SwiperSlide")}function ns(e){const r=[];return t.Children.toArray(e).forEach(e=>{is(e)?r.push(e):e.props&&e.props.children&&ns(e.props.children).forEach(e=>r.push(e))}),r}function ss(e){const r=[],i={"container-start":[],"container-end":[],"wrapper-start":[],"wrapper-end":[]};return t.Children.toArray(e).forEach(e=>{if(is(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=ns(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 as(e,t){return"undefined"==typeof window?i(e,t):o(e,t)}const os=l(null),ls=l(null),ds=n(function(e,n){let{className:s,tag:o="div",wrapperTag:l="div",children:d,onSwiper:c,...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:D}=function(e,t){void 0===e&&(e={}),void 0===t&&(t=!0);const r={on:{}},i={},n={};Xn(r,jn),r._emitClasses=!0,r.init=!1;const s={},a=Kn.map(e=>e.replace(/_/,"")),o=Object.assign({},e);return Object.keys(o).forEach(o=>{void 0!==e[o]&&(a.indexOf(o)>=0?qn(e[o])?(r[o]={},n[o]={},Xn(r[o],e[o]),Xn(n[o],e[o])):(r[o]=e[o],n[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]:s[o]=e[o])}),["navigation","pagination","scrollbar"].forEach(e=>{!0===r[e]&&(r[e]={}),!1===r[e]&&delete r[e]}),{params:r,passedParams:n,rest:s,events:i}}(u),{slides:C,slots:_}=ss(d),O=()=>{y(!v)};Object.assign(I.on,{_containerClasses(e,t){p(t)}});const M=()=>{Object.assign(I.on,D),h=!0;const e={...I};if(delete e.wrapperClass,w.current=new Yn(e),w.current.virtual&&w.current.params.virtual.enabled){w.current.virtual.slides=C;const e={cache:!1,slides:C,renderExternal:g,renderExternalUpdate:!1};Xn(w.current.params.virtual,e),Xn(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)}),as(()=>{if(n&&(n.current=E.current),E.current)return w.current.destroyed&&M(),function(e,t){let{el:r,nextEl:i,prevEl:n,paginationEl:s,scrollbarEl:a,swiper:o}=e;Qn(t)&&i&&n&&(o.params.navigation.nextEl=i,o.originalParams.navigation.nextEl=i,o.params.navigation.prevEl=n,o.originalParams.navigation.prevEl=n),Zn(t)&&s&&(o.params.pagination.el=s,o.originalParams.pagination.el=s),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),c&&!w.current.destroyed&&c(w.current),()=>{w.current&&!w.current.destroyed&&w.current.destroy(!0,!1)}},[]),as(()=>{!h&&D&&w.current&&Object.keys(D).forEach(e=>{w.current.on(e,D[e])});const e=function(e,t,r,i,n){const s=[];if(!t)return s;const a=e=>{s.indexOf(e)<0&&s.push(e)};if(r&&i){const e=i.map(n),t=r.map(n);e.join("")!==t.join("")&&a("children"),i.length!==r.length&&a("children")}return Kn.filter(e=>"_"===e[0]).map(e=>e.replace(/_/,"")).forEach(r=>{if(r in e&&r in t)if(qn(e[r])&&qn(t[r])){const i=Object.keys(e[r]),n=Object.keys(t[r]);i.length!==n.length?a(r):(i.forEach(i=>{e[r][i]!==t[r][i]&&a(r)}),n.forEach(i=>{e[r][i]!==t[r][i]&&a(r)}))}else e[r]!==t[r]&&a(r)}),s}(R,S.current,C,T.current,e=>e.key);return S.current=R,T.current=C,e.length&&w.current&&!w.current.destroyed&&function(e){let{swiper:t,slides:r,passedParams:i,changedParams:n,nextEl:s,prevEl:a,scrollbarEl:o,paginationEl:l}=e;const d=n.filter(e=>"children"!==e&&"direction"!==e&&"wrapperClass"!==e),{params:c,pagination:u,navigation:h,scrollbar:f,virtual:p,thumbs:m}=t;let g,v,y,b,E,w,S,T;n.includes("thumbs")&&i.thumbs&&i.thumbs.swiper&&!i.thumbs.swiper.destroyed&&c.thumbs&&(!c.thumbs.swiper||c.thumbs.swiper.destroyed)&&(g=!0),n.includes("controller")&&i.controller&&i.controller.control&&c.controller&&!c.controller.control&&(v=!0),n.includes("pagination")&&i.pagination&&(i.pagination.el||l)&&(c.pagination||!1===c.pagination)&&u&&!u.el&&(y=!0),n.includes("scrollbar")&&i.scrollbar&&(i.scrollbar.el||o)&&(c.scrollbar||!1===c.scrollbar)&&f&&!f.el&&(b=!0),n.includes("navigation")&&i.navigation&&(i.navigation.prevEl||a)&&(i.navigation.nextEl||s)&&(c.navigation||!1===c.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()),c[e].prevEl=void 0,c[e].nextEl=void 0,t[e].prevEl=void 0,t[e].nextEl=void 0):(t.isElement&&t[e].el.remove(),c[e].el=void 0,t[e].el=void 0))};n.includes("loop")&&t.isElement&&(c.loop&&!i.loop?w=!0:!c.loop&&i.loop?S=!0:T=!0),d.forEach(e=>{if(qn(c[e])&&qn(i[e]))Object.assign(c[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?c[e]=i[e]:!1===t&&x(e)}}),d.includes("controller")&&!v&&t.controller&&t.controller.control&&c.controller&&c.controller.control&&(t.controller.control=c.controller.control),n.includes("children")&&r&&p&&c.virtual.enabled?(p.slides=r,p.update(!0)):n.includes("virtual")&&p&&c.virtual.enabled&&(r&&(p.slides=r),p.update(!0)),n.includes("children")&&r&&c.loop&&(T=!0),g&&m.init()&&m.update(!0);v&&(t.controller.control=c.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&&(c.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&&(c.scrollbar.el=o),f.init(),f.updateSize(),f.setTranslate()),E&&(t.isElement&&(s&&"string"!=typeof s||(s=document.createElement("div"),s.classList.add("swiper-button-next"),s.innerHTML=t.hostEl.constructor.nextButtonSvg,s.part.add("button-next"),t.el.appendChild(s)),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))),s&&(c.navigation.nextEl=s),a&&(c.navigation.prevEl=a),h.init(),h.update()),n.includes("allowSlideNext")&&(t.allowSlideNext=i.allowSlideNext),n.includes("allowSlidePrev")&&(t.allowSlidePrev=i.allowSlidePrev),n.includes("direction")&&t.changeDirection(i.direction,!1),(w||T)&&t.loopDestroy(),(S||T)&&t.loopCreate(),t.update()}({swiper:w.current,slides:C,passedParams:R,changedParams:e,nextEl:x.current,prevEl:A.current,scrollbarEl:L.current,paginationEl:k.current}),()=>{D&&w.current&&Object.keys(D).forEach(e=>{w.current.off(e,D[e])})}}),as(()=>{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,rs({ref:E,className:es(`${f}${s?` ${s}`:""}`)},P),t.createElement(ls.Provider,{value:w.current},_["container-start"],t.createElement(l,{className:ts(I.wrapperClass)},_["wrapper-start"],I.virtual?function(e,r,i){if(!i)return null;const n=e=>{let t=e;return e<0?t=r.length+e:t>=r.length&&(t-=r.length),t},s=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,d=e.params.loop?2*r.length:r.length,c=[];for(let e=l;e<d;e+=1)e>=a&&e<=o&&c.push(r[n(e)]);return c.map((r,i)=>t.cloneElement(r,{swiper:e,style:s,key:r.props.virtualIndex||r.key||`slide-${i}`}))}(w.current,C,m):C.map((e,r)=>t.cloneElement(e,{swiper:w.current,swiperSlideIndex:r})),_["wrapper-end"]),Qn(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"}),Zn(I)&&t.createElement("div",{ref:k,className:"swiper-pagination"}),_["container-end"]))});ds.displayName="Swiper";const cs=n(function(e,i){let{tag:n="div",children:s,className:o="",swiper:l,zoom:d,lazy:c,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)}as(()=>{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")}}),as(()=>{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 s?s(E):s;return t.createElement(n,rs({ref:p,className:es(`${m}${o?` ${o}`:""}`),"data-swiper-slide-index":u,onLoad:()=>{y(!0)}},f),d&&t.createElement(os.Provider,{value:E},t.createElement("div",{className:"swiper-zoom-container","data-swiper-zoom":"number"==typeof d?d:void 0},w(),c&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"}))),!d&&t.createElement(os.Provider,{value:E},w(),c&&!v&&t.createElement("div",{className:"swiper-lazy-preloader"})))});function us(e){let{swiper:t,extendParams:r,on:i,emit:n}=e;const s=qi();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=Qi();const d=[];function c(){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&&Qi()-l<t.params.mousewheel.thresholdTime)&&(e.delta>=6&&Qi()-l<60||(e.direction<0?t.isEnd&&!t.params.loop||t.animating||(t.slideNext(),n("scroll",e.raw)):t.isBeginning&&!t.params.loop||t.animating||(t.slidePrev(),n("scroll",e.raw)),l=(new s.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 s=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 c=l&&l.contains(r.target);if(!t.mouseEntered&&!c&&!s.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,n=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,n=10*r,"deltaY"in e&&(n=e.deltaY),"deltaX"in e&&(i=e.deltaX),e.shiftKey&&!i&&(i=n,n=0),(i||n)&&e.deltaMode&&(1===e.deltaMode?(i*=40,n*=40):(i*=800,n*=800)),i&&!t&&(t=i<1?-1:1),n&&!r&&(r=n<1?-1:1),{spinX:t,spinY:r,pixelX:i,pixelY:n}}(r);if(s.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;s.invert&&(u=-u);let m=t.getTranslate()+u*s.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:Qi(),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*s.sensitivity;const c=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(),(!c&&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,d.length>=15&&d.shift();const r=d.length?d[d.length-1]:void 0,i=d[0];if(d.push(e),r&&(e.delta>r.delta||e.direction!==r.direction))d.splice(0);else if(d.length>=15&&e.time-i.time<500&&i.delta-e.delta>=1&&e.delta<=6){const r=u>0?.8:.2;o=e,d.splice(0),a=Xi(()=>{!t.destroyed&&t.params&&t.slideToClosest(t.params.speed,!0,void 0,r)},0)}a||(a=Xi(()=>{if(t.destroyed||!t.params)return;o=e,d.splice(0),t.slideToClosest(t.params.speed,!0,void 0,.5)},500))}if(i||n("scroll",r),t.params.autoplay&&t.params.autoplayDisableOnInteraction&&t.autoplay.stop(),s.releaseOnEdges&&(l===t.minTranslate()||l===t.maxTranslate()))return!0}}else{const r={time:Qi(),delta:Math.abs(u),direction:Math.sign(u),raw:e};d.length>=2&&d.shift();const i=d.length?d[d.length-1]:void 0;if(d.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",c),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 hs(e){let{swiper:t,extendParams:r,on:i,emit:n}=e;function s(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=hn(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(),n("navigationPrev"))}function d(e){e.preventDefault(),(!t.isEnd||t.params.loop||t.params.rewind)&&(t.slideNext(),n("navigationNext"))}function c(){const e=t.params.navigation;if(t.params.navigation=function(e,t,r,i){return e.params.createElements&&Object.keys(i).forEach(n=>{if(!r[n]&&!0===r.auto){let s=an(e.el,`.${i[n]}`)[0];s||(s=ln("div",i[n]),s.className=i[n],e.el.append(s)),r[n]=s,t[n]=s}}),r}(t,t.originalParams.navigation,t.params.navigation,{nextEl:"swiper-button-next",prevEl:"swiper-button-prev"}),!e.nextEl&&!e.prevEl)return;let r=s(e.nextEl),i=s(e.prevEl);Object.assign(t.navigation,{nextEl:r,prevEl:i}),r=hn(r),i=hn(i);const n=(r,i)=>{r&&r.addEventListener("click","next"===i?d:l),!t.enabled&&r&&r.classList.add(...e.lockClass.split(" "))};r.forEach(e=>n(e,"next")),i.forEach(e=>n(e,"prev"))}function u(){let{nextEl:e,prevEl:r}=t.navigation;e=hn(e),r=hn(r);const i=(e,r)=>{e.removeEventListener("click","next"===r?d: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():(c(),o())}),i("toEdge fromEdge lock unlock",()=>{o()}),i("destroy",()=>{u()}),i("enable disable",()=>{let{nextEl:e,prevEl:r}=t.navigation;e=hn(e),r=hn(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:s}=t.navigation;i=hn(i),s=hn(s);const a=r.target;let o=s.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)||s.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):s.length&&(e=s[0].classList.contains(t.params.navigation.hiddenClass)),n(!0===e?"navigationShow":"navigationHide"),[...i,...s].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(" ")),c(),o()},disable:h,update:o,init:c,destroy:u})}function fs(e){let t,r,{swiper:i,extendParams:n,on:s,emit:a,params:o}=e;i.autoplay={running:!1,paused:!1,timeLeft:0},n({autoplay:{enabled:!1,delay:3e3,waitForTransition:!0,disableOnInteraction:!1,stopOnLastSlide:!1,reverseDirection:!1,pauseOnMouseEnter:!1}});let l,d,c,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?d=!0:d&&(v=l,d=!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 n=void 0===e?i.params.autoplay.delay:e;g=i.params.autoplay.delay,v=i.params.autoplay.delay;const s=(()=>{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(s)&&s>0&&void 0===e&&(n=s,g=s,v=s),l=n;const o=i.params.speed,d=()=>{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 n>0?(clearTimeout(t),t=setTimeout(()=>{d()},n)):requestAnimationFrame(()=>{d()}),n},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 n=()=>{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 n();const s=l||i.params.autoplay.delay;l=s-((new Date).getTime()-y),i.isEnd&&l<0&&!i.params.loop||(l<0&&(l=0),n())},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=Yi();"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())};s("init",()=>{i.params.autoplay.enabled&&(i.params.autoplay.pauseOnMouseEnter&&(i.el.addEventListener("pointerenter",L),i.el.addEventListener("pointerleave",I)),Yi().addEventListener("visibilitychange",k),S())}),s("destroy",()=>{i.el&&"string"!=typeof i.el&&(i.el.removeEventListener("pointerenter",L),i.el.removeEventListener("pointerleave",I)),Yi().removeEventListener("visibilitychange",k),i.autoplay.running&&T()}),s("_freeModeStaticRelease",()=>{(u||p)&&A()}),s("_freeModeNoMomentumRelease",()=>{i.params.autoplay.disableOnInteraction?T():x(!0,!0)}),s("beforeTransitionStart",(e,t,r)=>{!i.destroyed&&i.autoplay.running&&(r||!i.params.autoplay.disableOnInteraction?x(!0,!0):T())}),s("sliderFirstMove",()=>{!i.destroyed&&i.autoplay.running&&(i.params.autoplay.disableOnInteraction?T():(c=!0,u=!1,p=!1,h=setTimeout(()=>{p=!0,u=!0,x(!0)},200)))}),s("touchEnd",()=>{if(!i.destroyed&&i.autoplay.running&&c){if(clearTimeout(h),clearTimeout(t),i.params.autoplay.disableOnInteraction)return u=!1,void(c=!1);u&&i.params.cssMode&&A(),u=!1,c=!1}}),s("slideChange",()=>{!i.destroyed&&i.autoplay.running&&(f=!0)}),Object.assign(i.autoplay,{start:S,stop:T,pause:x,resume:A})}function ps(e){let t,r,i,n,{swiper:s,extendParams:a,on:o}=e;a({grid:{rows:1,fill:"column"}});const l=()=>{let e=s.params.spaceBetween;return"string"==typeof e&&e.indexOf("%")>=0?e=parseFloat(e.replace("%",""))/100*s.size:"string"==typeof e&&(e=parseFloat(e)),e};o("init",()=>{n=s.params.grid&&s.params.grid.rows>1}),o("update",()=>{const{params:e,el:t}=s,r=e.grid&&e.grid.rows>1;n&&!r?(t.classList.remove(`${e.containerModifierClass}grid`,`${e.containerModifierClass}grid-column`),i=1,s.emitContainerClasses()):!n&&r&&(t.classList.add(`${e.containerModifierClass}grid`),"column"===e.grid.fill&&t.classList.add(`${e.containerModifierClass}grid-column`),s.emitContainerClasses()),n=r}),s.grid={initSlides:e=>{const{slidesPerView:n}=s.params,{rows:a,fill:o}=s.params.grid,l=s.virtual&&s.params.virtual.enabled?s.virtual.slides.length:e.length;i=Math.floor(l/a),t=Math.floor(l/a)===l/a?l:Math.ceil(l/a)*a,"auto"!==n&&"row"===o&&(t=Math.max(t,n*a)),r=t/a},unsetSlides:()=>{s.slides&&s.slides.forEach(e=>{e.swiperSlideGridSet&&(e.style.height="",e.style[s.getDirectionLabel("margin-top")]="")})},updateSlide:(e,n,a)=>{const{slidesPerGroup:o}=s.params,d=l(),{rows:c,fill:u}=s.params.grid,h=s.virtual&&s.params.virtual.enabled?s.virtual.slides.length:a.length;let f,p,m;if("row"===u&&o>1){const r=Math.floor(e/(o*c)),i=e-c*o*r,s=0===r?o:Math.min(Math.ceil((h-r*c*o)/c),o);m=Math.floor(i/s),p=i-m*s+r*o,f=p+m*t/c,n.style.order=f}else"column"===u?(p=Math.floor(e/c),m=e-p*c,(p>i||p===i&&m===c-1)&&(m+=1,m>=c&&(m=0,p+=1))):(m=Math.floor(e/r),p=e-m*r);n.row=m,n.column=p,n.style.height=`calc((100% - ${(c-1)*d}px) / ${c})`,n.style[s.getDirectionLabel("margin-top")]=0!==m?d&&`${d}px`:"",n.swiperSlideGridSet=!0},updateWrapperSize:(e,r)=>{const{centeredSlides:i,roundLengths:n}=s.params,a=l(),{rows:o}=s.params.grid;if(s.virtualSize=(e+a)*t,s.virtualSize=Math.ceil(s.virtualSize/o)-a,s.params.cssMode||(s.wrapperEl.style[s.getDirectionLabel("width")]=`${s.virtualSize+a}px`),i){const e=[];for(let t=0;t<r.length;t+=1){let i=r[t];n&&(i=Math.floor(i)),r[t]<s.virtualSize+r[0]&&e.push(i)}r.splice(0,r.length),r.push(...e)}}}}function ms(e){const t=this,{params:r,slidesEl:i}=t;r.loop&&t.loopDestroy();const n=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]&&n(e[t]);else n(e);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update()}function gs(e){const t=this,{params:r,activeIndex:i,slidesEl:n}=t;r.loop&&t.loopDestroy();let s=i+1;const a=e=>{if("string"==typeof e){const t=document.createElement("div");t.innerHTML=e,n.prepend(t.children[0]),t.innerHTML=""}else n.prepend(e)};if("object"==typeof e&&"length"in e){for(let t=0;t<e.length;t+=1)e[t]&&a(e[t]);s=i+e.length}else a(e);t.recalcSlides(),r.loop&&t.loopCreate(),r.observer&&!t.isElement||t.update(),t.slideTo(s,0,!1)}function vs(e,t){const r=this,{params:i,activeIndex:n,slidesEl:s}=r;let a=n;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 d=[];for(let t=o-1;t>=e;t-=1){const e=r.slides[t];e.remove(),d.unshift(e)}if("object"==typeof t&&"length"in t){for(let e=0;e<t.length;e+=1)t[e]&&s.append(t[e]);l=a>e?a+t.length:a}else s.append(t);for(let e=0;e<d.length;e+=1)s.append(d[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 ys(e){const t=this,{params:r,activeIndex:i}=t;let n=i;r.loop&&(n-=t.loopedSlides,t.loopDestroy());let s,a=n;if("object"==typeof e&&"length"in e){for(let r=0;r<e.length;r+=1)s=e[r],t.slides[s]&&t.slides[s].remove(),s<a&&(a-=1);a=Math.max(a,0)}else s=e,t.slides[s]&&t.slides[s].remove(),s<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 bs(){const e=this,t=[];for(let r=0;r<e.slides.length;r+=1)t.push(r);e.removeSlide(t)}function Es(e){let{swiper:t}=e;Object.assign(t,{appendSlide:ms.bind(t),prependSlide:gs.bind(t),addSlide:vs.bind(t),removeSlide:ys.bind(t),removeAllSlides:bs.bind(t)})}function ws(e,t){const r=sn(t);return r!==t&&(r.style.backfaceVisibility="hidden",r.style["-webkit-backface-visibility"]="hidden"),r}function Ss(e){let{swiper:t,duration:r,transformElements:i,allSlides:n}=e;const{activeIndex:s}=t;if(t.params.virtualTranslate&&0!==r){let e,r=!1;e=n?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)===s}),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 Ts(e,t,r){const i=`swiper-slide-shadow swiper-slide-shadow-${e}`,n=sn(t);let s=n.querySelector(`.${i.split(" ").join(".")}`);return s||(s=ln("div",i.split(" ")),n.append(s)),s}function xs(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:n,setTransition:s,overwriteParams:a,perspective:o,recreateShadows:l,getEffectParams:d}=e;let c;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&&n()}),i("setTransition",(e,i)=>{r.params.effect===t&&s(i)}),i("transitionEnd",()=>{if(r.params.effect===t&&l){if(!d||!d().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||(c=!0),requestAnimationFrame(()=>{c&&r.slides&&r.slides.length&&(n(),c=!1)}))})}({effect:"cards",swiper:t,on:i,setTranslate:()=>{const{slides:e,activeIndex:r,rtlTranslate:i}=t,n=t.params.cardsEffect,{startTranslate:s,isTouched:a}=t.touchEventsData,o=i?-t.translate:t.translate;for(let l=0;l<e.length;l+=1){const d=e[l],c=d.progress,u=Math.min(Math.max(c,-4),4);let h=d.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=-n.perSlideRotate*u,y=n.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<s,w=(b===r||b===r+1)&&u<0&&u>-1&&(a||t.params.cssMode)&&o>s;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(${n.rotate?i?-v:v:0}deg)\n scale(${S})\n `;if(n.slideShadows){let e=d.querySelector(".swiper-slide-shadow");e||(e=Ts("cards",d)),e&&(e.style.opacity=Math.min(Math.max((Math.abs(u)-.5)/.5,0),1))}d.style.zIndex=-Math.abs(Math.round(c))+e.length;ws(0,d).style.transform=T}},setTransition:e=>{const r=t.slides.map(e=>sn(e));r.forEach(t=>{t.style.transitionDuration=`${e}ms`,t.querySelectorAll(".swiper-slide-shadow").forEach(t=>{t.style.transitionDuration=`${e}ms`})}),Ss({swiper:t,duration:e,transformElements:r})},perspective:()=>!0,overwriteParams:()=>({watchSlidesProgress:!0,virtualTranslate:!t.params.cssMode})})}cs.displayName="SwiperSlide";const As=({product:e})=>{const[r,i]=a(!1);return t.createElement("a",{href:e.linkPath,target:"_blank"},t.createElement("div",{className:"w-full h-full flex gap-2 flex-col"},t.createElement("div",{className:"w-full max-h-fit aspect-square border mb-2 flex justify-center items-center"},e.thumbPath&&!r?t.createElement(er,{product:e,onError:()=>i(!0)}):t.createElement(Jt,null)),t.createElement("div",{className:"justify-center flex flex-col"},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",null,e.productName),t.createElement("div",null,t.createElement("span",{className:"font-semibold text-red-500"},e.discount,"%"," "),t.createElement("span",{className:"font-semibold"},xt(e.sellingPrice),"원")))))},ks=({products:e})=>{const n=r(null),[s,o]=a(0),l=r(null);i(()=>{u(),window.addEventListener("resize",()=>{clearInterval(d),d=setTimeout(u,c)})},[]);let d=null;const c=100,u=()=>{l.current&&o(l.current.offsetWidth)};return e&&t.createElement("div",{className:"flex items-center h-full justify-center w-full",ref:l},e.length>3?t.createElement(zt,{size:50,className:"cursor-pointer slide__prev",onClick:()=>{var e;null===(e=n.current)||void 0===e||e.slidePrev()}}):t.createElement("div",{className:"w-[50px]"}),t.createElement(ds,{modules:[hs],onSwiper:e=>{n.current=e},style:{width:s},slidesPerView:3,navigation:{prevEl:".slide__prev",nextEl:".slide__next"},spaceBetween:20},e.map(e=>t.createElement(cs,{key:e.productId},t.createElement(As,{product:e})))),e.length>3?t.createElement(Gt,{onClick:()=>{var e;null===(e=n.current)||void 0===e||e.slideNext()},size:50,className:"cursor-pointer slide__next"}):t.createElement("div",{className:"w-[50px]"}))},Ls=e=>{const{player:r,shortform:i}=e;return t.createElement("div",{className:"flex h-full gap-5"},t.createElement("div",{className:"h-full aspect-[9/16]"},r),t.createElement("div",{className:"w-full min-w-44 max-w-[800px] overflow-hidden text-sm"},t.createElement(ks,{products:i.productsInfo})))},Is=({products:e})=>{const i=r(null);return t.createElement("div",{className:"flex items-center flex-col h-full"},e.length>4&&t.createElement(jt,{size:50,className:"cursor-pointer slide__prev"}),t.createElement(ds,{modules:[us,hs],mousewheel:!0,onSwiper:e=>{i.current=e},spaceBetween:10,className:"max-w-full h-[80%]",slidesPerView:4,direction:"vertical",navigation:{prevEl:".slide__prev",nextEl:".slide__next"}},e.map(e=>t.createElement(cs,{key:e.productId},t.createElement(tr,{product:e})))),e.length>4&&t.createElement(Ut,{size:50,className:"cursor-pointer slide__next"}))},Rs=e=>{const{playerSettings:r,shortform:{productsInfo:i},player:n}=e;return t.createElement("div",{className:"flex h-full w-full gap-5"},t.createElement("div",{className:" h-full "},n),t.createElement("div",{className:"max-w-[800px] overflow-hidden"},t.createElement(Is,{products:i})))},Ps=({products:e})=>{const i=r(null),n=e.length>6;return t.createElement("div",{className:"flex items-center my-10 h-full text-sm w-full"},n?t.createElement(zt,{onClick:()=>{var e;null===(e=i.current)||void 0===e||e.slidePrev()},size:50,className:"cursor-pointer"}):t.createElement("div",{className:"w-[50px]"}),t.createElement(ds,{onSwiper:e=>{i.current=e},className:"w-[80%] h-[80%]",slidesPerView:3,spaceBetween:20,modules:[ps],grid:{rows:2,fill:"row"}},e.map(e=>t.createElement(cs,{key:e.productId},t.createElement(As,{product:e})))),n?t.createElement(Gt,{onClick:()=>{var e;null===(e=i.current)||void 0===e||e.slideNext()},size:50,className:"cursor-pointer"}):t.createElement("div",{className:"w-[50px]"}))},Ds=e=>{const{player:r,shortform:{productsInfo:i}}=e;return t.createElement("div",{className:"flex gap-4 w-full h-full min-w-[768px]"},t.createElement("div",{className:"flex-1 w-full"},t.createElement("div",{className:"h-full aspect-[9/16]"},r)),t.createElement("div",{className:"flex-[2] w-full h-full overflow-hidden"},t.createElement(Ps,{products:i})))},Cs=e=>(document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}),_s=()=>document.visibilityState,Os=()=>{throw Error("useVisibilityChange is a client-only hook")};function Ms(){return"visible"===e.useSyncExternalStore(Cs,_s,Os)}var Ns=(e,t,n=!0)=>{const s=r(e),a=r(null),o=()=>{a.current&&(clearInterval(a.current),a.current=null)},l=c(()=>{a.current||(a.current=setInterval(()=>s.current(),t))},[t]);return i(()=>{s.current=e},[e]),i(()=>(n&&l(),()=>o()),[l,n]),{clear:o,run:l}};const Fs=()=>{const[e,t]=a(0);Ns(()=>{t(e=>e+1)},1e3);return{playtime:e,resetPlaytime:()=>t(0)}};var $s;!function(e){e.latest="",e.views="pageView",e.likes="like"}($s||($s={}));let Bs=0;const Us=e=>x(void 0,void 0,void 0,function*(){const{PLAYER_BACK_BASE_URL:t}=gt(),{contentId:r,uuid:i,type:n,userId:s}=e;try{if(3===Bs)return;const e=`${t}/statistics/play`,a=Object.assign({contentId:r,uuid:i,type:n,date:At(),userId:+s,playtime:0,isLive:!1},"shorts"===n&&{isFinished:!1,playedOver5Sec:!1});yield fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})}catch(e){console.error(`Error in statisticsApi.join - contentId: ${r}`),Pt(e),Bs++}}),zs=e=>{const{PLAYER_BACK_BASE_URL:t}=gt(),{contentId:r,uuid:i,type:n,isFinished:s,playtime:a,userId:o}=e,l=Object.assign({contentId:r,uuid:i,playtime:a,type:n,date:At(),userId:+o,isLive:!1},"shorts"===n&&{isFinished:s,playedOver5Sec:Number(a)>5});fetch(`${t}/statistics/play`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l),keepalive:!0})},Gs=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:At()},e))})}catch(e){console.error(`Error in statisticsApi.productClick - contentProductId: ${r}`),Pt(e)}}),js=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}`),Pt(t),0}}),Hs=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}`),Pt(t)}}),Vs=e=>x(void 0,[e],void 0,function*({collectionId:e,nextKey:t,size:r=5}){const{PLAYER_BACK_BASE_URL:i}=gt();try{const n=new URLSearchParams;-1!==r&&n.set("size",String(r)),t&&n.set("nextKey",t);const s=yield fetch(`${i}/commerce/collection/${e}?${n.toString()}`);return s.ok?yield s.json():null}catch(e){return Pt(e),null}}),Ws=(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:n}}}=t;return Object.assign(Object.assign(Object.assign(Object.assign({layout:t.player.layout},t.player.shoppingPlayer),{aspectRatio:Dt(i,n)}),t),{uuid:kt()})}catch(e){return Pt(e),null}try{const t=yield fetch(`${i}/commerce/short-form/${e}`),r=yield t.json();return r.shortsId?r:null}catch(e){return Pt(e),null}}),Ys=(e,t,r,i,n)=>x(void 0,void 0,void 0,function*(){const{API_BASE_URL:s}=gt();try{const a=yield fetch(`${s}/live/${e}/list?size=${r||6}&status=${t}&includeMainLive=${i}${n&&$s[n]?`&sortBy=${$s[n]}`:""}`);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}}),Ks=e=>{let t;const r=new Set,i=(e,i)=>{const n="function"==typeof e?e(t):e;if(!Object.is(n,t)){const e=t;t=(null!=i?i:"object"!=typeof n||null===n)?n:Object.assign({},t,n),r.forEach(r=>r(t,e))}},n=()=>t,s={setState:i,getState:n,getInitialState:()=>a,subscribe:e=>(r.add(e),()=>r.delete(e))},a=t=e(i,n,s);return s},qs=e=>e?Ks(e):Ks,Xs=e=>e;function Qs(e,r=Xs){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 Zs=e=>{const t=qs(e),r=e=>Qs(t,e);return Object.assign(r,t),r},Js=e=>e?Zs(e):Zs,ea=Js(e=>({priceText:"",isPreview:!1,setPriceText:t=>e({priceText:t}),setIsPreview:t=>e({isPreview:t})})),ta=t.createContext(null),ra=({children:e})=>{const r=t.useRef(null);return r.current||(r.current=qs(e=>({collection:null,setCollection:t=>e({collection:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})}))),t.createElement(ta.Provider,{value:r.current},e)},ia=()=>(e=>{const r=t.useContext(ta);if(!r)throw new Error("Missing CollectionProvider");return Qs(r,e)})(e=>e),na=(e,t)=>{const{collection:r,setCollection:n,isFetching:s,setIsFetching:a,nextKey:o,setNextKey:l}=ia(),{isPreview:d}=ea(),c=(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}=Fs(),{playtime:f,resetPlaytime:p}=Fs(),m=Ms(),g=()=>{if(!r)return;const{colId:t,uuid:i,userId:n}=r,s=Ge,a=Math.floor((new Date).getTime()/1e3);localStorage.setItem(s,a.toString()),d||(zs({contentId:t,uuid:i,type:Et.COLLECTION,userId:n,playtime:f}),e&&zs({contentId:e.shortsId,uuid:e.uuid,type:Et.SHORTS,userId:n,playtime:h,isFinished:h>=c}),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:d,count:c}=r;if((null!=c?c:Number.MAX_SAFE_INTEGER)>d.length&&e>=d.length-5&&!s){a(!0);try{const e=yield Vs({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 s=new Set(r.contents.map(e=>e.shortsId)),a=e.contents.filter(e=>!s.has(e.shortsId));if(!a.length)return;const d=r.contents.concat(a);n(Object.assign(Object.assign({},r),{contents:d}))}catch(e){console.error(e)}finally{a(!1)}}}))(i),!d)){const{shortsId:n,uuid:s,userId:a}=e;zs({contentId:n,uuid:s,type:Et.SHORTS,playtime:h,isFinished:h>=c,userId:a}),u();const o=kt(),l=r.contents[i];t(Object.assign(Object.assign({},l),{uuid:o})),yield Us({contentId:l.shortsId,uuid:o,type:Et.SHORTS,userId:l.userId,isFirstPlay:!Lt(l.shortsId)})}}),onCollectionClose:g}},sa=e=>{const{collection:i,playerSettings:n,shortform:s,setShortform:a}=e,o=r(null),{onSlideChange:l}=na(i,s);return t.createElement(t.Fragment,null,t.createElement("div",{className:"self-center flex gap-4 flex-col"},t.createElement(jt,{size:44,onClick:()=>{var e;null===(e=o.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(Ut,{size:44,onClick:()=>{var e;null===(e=o.current)||void 0===e||e.swiper.slideNext()}})),t.createElement("div",{className:"h-full aspect-[9/16] my-10"},t.createElement(ds,{modules:[us,Es],mousewheel:!0,loop:!0,direction:"vertical",touchEventsTarget:"container",slidesPerView:1,ref:o,className:"h-full",onSlideChangeTransitionEnd:e=>x(void 0,void 0,void 0,function*(){yield l(e.realIndex)})},i.contents.map(e=>t.createElement(cs,{key:e.shortsId},s.shortsId===e.shortsId&&t.createElement("div",{className:"h-full rounded-xl absolute z-[999] aspect-[9/16] overflow-hidden"},t.createElement(L,{file:Tt(s.media.objectId)})),t.createElement("img",{src:Rt(e.thumbPath),alt:e.title,className:"rounded-xl overflow-hidden h-full bg-black aspect-[9/16] "+(e.media.width>e.media.height?"object-contain":"object-cover")}))))))},aa=e=>{const{collection:i,shortform:n,setShortform:s,playerSettings:a}=e,o=r(null);na(i,n);return t.createElement("div",{className:"mx-10 flex h-full gap-4"},t.createElement("div",{className:"self-center flex gap-4 flex-col"},t.createElement(jt,{size:44,onClick:()=>{var e;null===(e=o.current)||void 0===e||e.swiper.slidePrev()}}),t.createElement(Ut,{size:44,onClick:()=>{var e;null===(e=o.current)||void 0===e||e.swiper.slideNext()}})),t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(ds,{modules:[us,Es],mousewheel:!0,direction:"vertical",slidesPerView:1,ref:o,className:"h-full",preventClicksPropagation:!1,preventClicks:!1,noSwiping:!0,allowTouchMove:!1,loop:!0},i.contents.map(e=>t.createElement(cs,{key:e.shortsId},t.createElement("div",{className:"flex justify-center gap-3 h-full w-full"},n.shortsId===e.shortsId&&t.createElement("div",{className:"h-full absolute z-[999] w-full"},t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(L,{file:Tt(n.media.objectId)}))),t.createElement("div",{className:"h-full aspec[9/16]"},t.createElement("img",{src:"https://"+e.thumbPath,alt:e.title,className:"w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")}))))))))},oa=()=>t.createElement("div",{className:"inline-block absolute pointer-events-none top-0 z-10 animate-float w-[24px] h-[24px]"},t.createElement(Vt,{className:"fill-red-500 text-transparent w-[24px] h-[24px]"})),la=({shortsId:e})=>{const{isPreview:r}=ea(),[n,s]=a(r?123:0),[o,l]=a([]);i(()=>{r||x(void 0,void 0,void 0,function*(){try{const t=yield js(e);s(t)}catch(e){return console.error(`Error in statistics getLikeInLive: ${e.toString()}`),0}})},[]);return t.createElement("div",{className:"flex justify-center flex-col items-center relative w-[24px] h-[24px]"},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)})(),s(e=>e+1),r||(yield x(void 0,void 0,void 0,function*(){yield Hs(e)}))}),className:"z-[5] cursor-pointer"},t.createElement(Vt,{className:"text-xl fill-white w-[24px] h-[24px]"})),o.map(e=>t.createElement(oa,{key:e})),t.createElement("span",{className:"break-keep text-[10px]"},xt(n)))};var da,ca,ua={},ha={exports:{}},fa=ha.exports;function pa(){return da||(da=1,e=ha,t=ha.exports,function(r,i){var n="function",s="undefined",a="object",o="string",l="major",d="model",c="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",D="Microsoft",C="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===s?e:e.substring(0,500)},Y=function(e,t){for(var r,s,o,l,d,c,u=0;u<t.length&&!d;){var h=t[u],f=t[u+1];for(r=s=0;r<h.length&&!d&&h[r];)if(d=h[r++].exec(e))for(o=0;o<f.length;o++)c=d[++s],typeof(l=f[o])===a&&l.length>0?2===l.length?typeof l[1]==n?this[l[0]]=l[1].call(this,c):this[l[0]]=l[1]:3===l.length?typeof l[1]!==n||l[1].exec&&l[1].test?this[l[0]]=c?c.replace(l[1],l[2]):i:this[l[0]]=c?l[1].call(this,c,l[2]):i:4===l.length&&(this[l[0]]=c?l[3].call(this,c.replace(l[1],l[2])):i):this[l]=c||i;u+=2}},K=function(e,t){for(var r in t)if(typeof t[r]===a&&t[r].length>0){for(var n=0;n<t[r].length;n++)if(H(t[r][n],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,[c,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[f,[c,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[c,f],[/opios[\/ ]+([\w\.]+)/i],[f,[c,_+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[f,[c,_+" GX"]],[/\bopr\/([\w\.]+)/i],[f,[c,_]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[f,[c,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[f,[c,"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],[c,f],[/quark(?:pc)?\/([-\w\.]+)/i],[f,[c,"Quark"]],[/\bddg\/([\w\.]+)/i],[f,[c,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[f,[c,"UC"+A]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[f,[c,"WeChat"]],[/konqueror\/([\w\.]+)/i],[f,[c,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[f,[c,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[f,[c,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[f,[c,"Smart Lenovo "+A]],[/(avast|avg)\/([\w\.]+)/i],[[c,/(.+)/,"$1 Secure "+A],f],[/\bfocus\/([\w\.]+)/i],[f,[c,L+" Focus"]],[/\bopt\/([\w\.]+)/i],[f,[c,_+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[f,[c,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[f,[c,"Dolphin"]],[/coast\/([\w\.]+)/i],[f,[c,_+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[f,[c,"MIUI"+G]],[/fxios\/([\w\.-]+)/i],[f,[c,L]],[/\bqihoobrowser\/?([\w\.]*)/i],[f,[c,"360"]],[/\b(qq)\/([\w\.]+)/i],[[c,/(.+)/,"$1Browser"],f],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[c,/(.+)/,"$1"+G],f],[/samsungbrowser\/([\w\.]+)/i],[f,[c,O+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[f,[c,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[c,"Sogou Mobile"],f],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[c,f],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[c],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[f,c],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[c,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],[c,f],[/\bgsa\/([\w\.]+) .*safari\//i],[f,[c,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[f,[c,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[f,[c,k+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[c,k+" WebView"],f],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[f,[c,"Android "+A]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[c,f],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[f,[c,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[f,c],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[c,[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],[c,f],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[c,"Netscape"],f],[/(wolvic|librewolf)\/([\w\.]+)/i],[c,f],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[f,[c,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],[c,[f,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[c,[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],[d,[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],[d,[h,O],[u,g]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[d,[h,S],[u,g]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[d,[h,S],[u,v]],[/(macintosh);/i],[d,[h,S]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[d,[h,M],[u,g]],[/(?:honor)([-\w ]+)[;\)]/i],[d,[h,"Honor"],[u,g]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[d,[h,R],[u,v]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[d,[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],[[d,/_/g," "],[h,F],[u,g]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[d,/_/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],[d,[h,"OPPO"],[u,g]],[/\b(opd2\d{3}a?) bui/i],[d,[h,"OPPO"],[u,v]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[d,[h,"Vivo"],[u,g]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[d,[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],[d,[h,C],[u,g]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[d,[h,C],[u,v]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[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],[d,[h,P],[u,g]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[d,[h,"Lenovo"],[u,v]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[d,/_/g," "],[h,"Nokia"],[u,g]],[/(pixel c)\b/i],[d,[h,I],[u,v]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[d,[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],[d,[h,N],[u,g]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[d,"Xperia Tablet"],[h,N],[u,v]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[d,[h,"OnePlus"],[u,g]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[d,[h,w],[u,v]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[d,/(.+)/g,"Fire Phone $1"],[h,w],[u,g]],[/(playbook);[-\w\),; ]+(rim)/i],[d,h,[u,v]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[d,[h,x],[u,g]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[d,[h,T],[u,v]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[d,[h,T],[u,g]],[/(nexus 9)/i],[d,[h,"HTC"],[u,v]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[d,/_/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],[d,[h,"TCL"],[u,v]],[/(itel) ((\w+))/i],[[h,V],d,[u,K,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[d,[h,"Acer"],[u,v]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[d,[h,"Meizu"],[u,g]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[d,[h,"Ulefone"],[u,g]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[d,[h,"Energizer"],[u,g]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[d,[h,"Cat"],[u,g]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[d,[h,"Smartfren"],[u,g]],[/droid.+; (a(?:015|06[35]|142p?))/i],[d,[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,d,[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,d,[u,v]],[/(surface duo)/i],[d,[h,D],[u,v]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[d,[h,"Fairphone"],[u,g]],[/(u304aa)/i],[d,[h,"AT&T"],[u,g]],[/\bsie-(\w*)/i],[d,[h,"Siemens"],[u,g]],[/\b(rct\w+) b/i],[d,[h,"RCA"],[u,v]],[/\b(venue[\d ]{2,7}) b/i],[d,[h,"Dell"],[u,v]],[/\b(q(?:mv|ta)\w+) b/i],[d,[h,"Verizon"],[u,v]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[d,[h,"Barnes & Noble"],[u,v]],[/\b(tm\d{3}\w+) b/i],[d,[h,"NuVision"],[u,v]],[/\b(k88) b/i],[d,[h,"ZTE"],[u,v]],[/\b(nx\d{3}j) b/i],[d,[h,"ZTE"],[u,g]],[/\b(gen\d{3}) b.+49h/i],[d,[h,"Swiss"],[u,g]],[/\b(zur\d{3}) b/i],[d,[h,"Swiss"],[u,v]],[/\b((zeki)?tb.*\b) b/i],[d,[h,"Zeki"],[u,v]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,"Dragon Touch"],d,[u,v]],[/\b(ns-?\w{0,9}) b/i],[d,[h,"Insignia"],[u,v]],[/\b((nxa|next)-?\w{0,9}) b/i],[d,[h,"NextBook"],[u,v]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,"Voice"],d,[u,g]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,"LvTel"],d,[u,g]],[/\b(ph-1) /i],[d,[h,"Essential"],[u,g]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[d,[h,"Envizen"],[u,v]],[/\b(trio[-\w\. ]+) b/i],[d,[h,"MachSpeed"],[u,v]],[/\btu_(1491) b/i],[d,[h,"Rotor"],[u,v]],[/(shield[\w ]+) b/i],[d,[h,"Nvidia"],[u,v]],[/(sprint) (\w+)/i],[h,d,[u,g]],[/(kin\.[onetw]{3})/i],[[d,/\./g," "],[h,D],[u,g]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[d,[h,$],[u,v]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[d,[h,$],[u,g]],[/smart-tv.+(samsung)/i],[h,[u,y]],[/hbbtv.+maple;(\d+)/i],[[d,/^/,"SmartTV"],[h,O],[u,y]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,P],[u,y]],[/(apple) ?tv/i],[h,[d,S+" TV"],[u,y]],[/crkey/i],[[d,k+"cast"],[h,I],[u,y]],[/droid.+aft(\w+)( bui|\))/i],[d,[h,w],[u,y]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[d,[h,M],[u,y]],[/(bravia[\w ]+)( bui|\))/i],[d,[h,N],[u,y]],[/(mitv-\w{5}) bui/i],[d,[h,F],[u,y]],[/Hbbtv.*(technisat) (.*);/i],[h,d,[u,y]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,W],[d,W],[u,y]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[u,y]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,d,[u,m]],[/droid.+; (shield) bui/i],[d,[h,"Nvidia"],[u,m]],[/(playstation [345portablevi]+)/i],[d,[h,N],[u,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[d,[h,D],[u,m]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[d,[h,O],[u,b]],[/((pebble))app/i],[h,d,[u,b]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[d,[h,S],[u,b]],[/droid.+; (glass) \d/i],[d,[h,I],[u,b]],[/droid.+; (wt63?0{2,3})\)/i],[d,[h,$],[u,b]],[/droid.+; (glass) \d/i],[d,[h,I],[u,b]],[/(pico) (4|neo3(?: link|pro)?)/i],[h,d,[u,b]],[/; (quest( \d| pro)?)/i],[d,[h,B],[u,b]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[u,E]],[/(aeobc)\b/i],[d,[h,w],[u,E]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[d,[u,g]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[d,[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],[d,[h,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[f,[c,"EdgeHTML"]],[/(arkweb)\/([\w\.]+)/i],[c,f],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[f,[c,"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],[c,f],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[f,c]],os:[[/microsoft (windows) (vista|xp)/i],[c,f],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[c,[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],[c,"Windows"]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[f,/_/g,"."],[c,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[c,z],[f,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[f,c],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[c,f],[/\(bb(10);/i],[f,[c,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[f,[c,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[f,[c,L+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[f,[c,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[f,[c,"watchOS"]],[/crkey\/([\d\.]+)/i],[f,[c,k+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[c,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],[c,f],[/(sunos) ?([\w\.\d]*)/i],[[c,"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],[c,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!==s&&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[c]=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==n&&(e[c]="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[d]=i,e[u]=i,Y.call(e,y,E.device),w&&!e[u]&&b&&b.mobile&&(e[u]=g),w&&"Macintosh"==e[d]&&m&&typeof m.standalone!==s&&m.maxTouchPoints&&m.maxTouchPoints>2&&(e[d]="iPad",e[u]=v),e},this.getEngine=function(){var e={};return e[c]=i,e[f]=i,Y.call(e,y,E.engine),e},this.getOS=function(){var e={};return e[c]=i,e[f]=i,Y.call(e,y,E.os),w&&!e[c]&&b&&b.platform&&"Unknown"!=b.platform&&(e[c]=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([c,f,l]),Q.CPU=j([p]),Q.DEVICE=j([d,h,u,m,g,y,v,b,E]),Q.ENGINE=Q.OS=j([c,f]),e.exports&&(t=e.exports=Q),t.UAParser=Q;var Z=typeof r!==s&&(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:fa)),ha.exports;var e,t}var ma=function(){if(ca)return ua;ca=1,Object.defineProperty(ua,"__esModule",{value:!0});var e,r=t,i=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,n=pa(),s=new n,a=s.getBrowser(),o=s.getCPU(),l=s.getDevice(),d=s.getEngine(),c=s.getOS(),u=s.getUA(),h=function(e){return s.setUA(e)},f=function(e){if(e){var t=new n(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:s,browser:a,cpu:o,device:l,engine:d,os:c,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,n=function(e,t){if(null==e)return{};var r,i,n={},s=Object.keys(e);for(i=0;i<s.length;i++)r=s[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}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,n,s=[],a=!0,o=!1;try{for(r=r.call(e);!(a=(i=r.next()).done)&&(s.push(i.value),!t||s.length!==t);a=!0);}catch(e){o=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(o)throw n}}return s}(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",D="embedded",C=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===C},V=function(e){return e.type===P},W=function(e){return e.type===R},Y=function(e){return e.type===D},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)},ne=function(e){return e.name===_.Chrome},se=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},de=function(e){var t=e.name;return t===_.Safari||t===_.MobileSafari},ce=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,n=t.os,s=t.engine,a=t.ua;return{isSmartTV:j(r),isConsole:W(r),isWearable:V(r),isEmbedded:Y(r),isMobileSafari:ce(i)||Te(),isChromium:ae(i),isMobile:G(r)||Te(),isMobileOnly:U(r),isTablet:z(r)||Te(),isBrowser:H(r),isDesktop:H(r),isAndroid:Q(n),isWinPhone:ee(n),isIOS:te(n)||Te(),isChrome:ne(i),isFirefox:se(i),isSafari:de(i),isOpera:ue(i),isIE:he(i),osVersion:re(n),osName:ie(n),fullBrowserVersion:me(i),browserVersion:ge(i),browserName:ve(i),mobileVendor:K(r),mobileModel:q(r),engineName:ye(s),engineVersion:be(s),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(n),isMacOs:J(n),isMIUI:fe(i),isSamsungBrowser:pe(i)}}var Ie=j(l),Re=W(l),Pe=V(l),De=Y(l),Ce=ce(a)||Te(),_e=ae(a),Oe=G(l)||Te(),Me=U(l),Ne=z(l)||Te(),Fe=H(l),$e=H(l),Be=Q(c),Ue=ee(c),ze=te(c)||Te(),Ge=ne(a),je=se(a),He=de(a),Ve=ue(a),We=he(a),Ye=re(c),Ke=ie(c),qe=me(a),Xe=ge(a),Qe=ve(a),Ze=K(l),Je=q(l),et=ye(d),tt=be(d),rt=ke(u),it=oe(a)||we(u),nt=le(a),st=X(l),at=Se(),ot=Te(),lt=xe(),dt=Ae(),ct=Ee(),ut=we(u),ht=oe(a)&&!we(u),ft=Z(c),pt=J(c),mt=fe(a),gt=pe(a);function vt(e){var t=e||window.navigator.userAgent;return f(t)}return ua.AndroidView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Be?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.BrowserTypes=_,ua.BrowserView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Fe?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.ConsoleView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Re?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.CustomView=function(e){var t=e.renderWithFragment,n=e.children;e.viewClassName,e.style;var s=e.condition,a=S(e,["renderWithFragment","children","viewClassName","style","condition"]);return s?t?i.createElement(r.Fragment,null,n):i.createElement("div",a,n):null},ua.IEView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return We?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.IOSView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return ze?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.MobileOnlyView=function(e){var t=e.renderWithFragment,n=e.children;e.viewClassName,e.style;var s=S(e,["renderWithFragment","children","viewClassName","style"]);return Me?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.MobileView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Oe?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.OsTypes=O,ua.SmartTVView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Ie?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.TabletView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Ne?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.WearableView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Pe?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.WinPhoneView=function(e){var t=e.renderWithFragment,n=e.children,s=S(e,["renderWithFragment","children"]);return Ue?t?i.createElement(r.Fragment,null,n):i.createElement("div",s,n):null},ua.browserName=Qe,ua.browserVersion=Xe,ua.deviceDetect=function(e){var t=e?f(e):p,r=t.device,i=t.browser,n=t.engine,s=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 C:return{isBrowser:!0};case D:return{isEmbedded:!0};default:return M}}(r.type),l=o.isBrowser,d=o.isMobile,c=o.isTablet,u=o.isSmartTV,h=o.isConsole,m=o.isWearable,g=o.isEmbedded;return l?function(e,t,r,i,n){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(n)}}(l,i,n,s,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,n,s,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,n,s,a):d||c?B(o,r,s,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,n,s,a):g?function(e,t,r,i,n){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(n)}}(g,r,n,s,a):void 0},ua.deviceType=st,ua.engineName=et,ua.engineVersion=tt,ua.fullBrowserVersion=qe,ua.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")},ua.getUA=rt,ua.isAndroid=Be,ua.isBrowser=Fe,ua.isChrome=Ge,ua.isChromium=_e,ua.isConsole=Re,ua.isDesktop=$e,ua.isEdge=it,ua.isEdgeChromium=ut,ua.isElectron=ct,ua.isEmbedded=De,ua.isFirefox=je,ua.isIE=We,ua.isIOS=ze,ua.isIOS13=at,ua.isIPad13=ot,ua.isIPhone13=lt,ua.isIPod13=dt,ua.isLegacyEdge=ht,ua.isMIUI=mt,ua.isMacOs=pt,ua.isMobile=Oe,ua.isMobileOnly=Me,ua.isMobileSafari=Ce,ua.isOpera=Ve,ua.isSafari=He,ua.isSamsungBrowser=gt,ua.isSmartTV=Ie,ua.isTablet=Ne,ua.isWearable=Pe,ua.isWinPhone=Ue,ua.isWindows=ft,ua.isYandex=nt,ua.mobileModel=Je,ua.mobileVendor=Ze,ua.osName=Ke,ua.osVersion=Ye,ua.parseUserAgent=f,ua.setUserAgent=function(e){return h(e)},ua.useDeviceData=vt,ua.useDeviceSelectors=function(e){var t=vt(e||window.navigator.userAgent);return[Le(t),t]},ua.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],n=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&&(n(),window.addEventListener("load",n,!1),window.addEventListener("resize",n,!1)),function(){window.removeEventListener("resize",n,!1),window.removeEventListener("load",n,!1)}},[n]),t},ua.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)},ua}();function ga({message:e,duration:r=3e3,visible:n,setVisible:s}){return i(()=>{const e=setTimeout(()=>s(!1),r);return()=>clearTimeout(e)},[n]),n?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 va=({shortForm:e,shareUrl:r})=>{const i=null!=r?r:window.location.href,[n,s]=a(!1);return t.createElement(t.Fragment,null,t.createElement("button",{onClick:()=>x(void 0,void 0,void 0,function*(){try{s(!0),ma.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(Kt,{size:22}),t.createElement(ga,{message:"공유 링크 복사 완료",setVisible:s,visible:n})))},ya=({product:e,hideMoreBtn:r,contentId:i})=>{const{isPreview:n,priceText:s}=ea(),[o,l]=a(!1);return t.createElement("div",{style:{height:"80px"},className:"flex gap-2 items-center w-full",onClick:()=>x(void 0,void 0,void 0,function*(){r&&(window.open(e.linkPath,"_blank"),n||(yield Gs({contentProductId:e.eventProductId,contentId:i,productId:e.productId})))})},e.thumbPath&&!o?t.createElement(er,{product:e,onError:()=>l(!0)}):t.createElement(Jt,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"}},s?s+" ":"할인가 ",t.createElement("span",{className:"font-semibold break-keep"},xt(e.sellingPrice),"원"))))};function ba(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function Ea(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function wa(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Ea(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():Ea(e[t],null)}}}}function Sa(...t){return e.useCallback(wa(...t),t)}function Ta(...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 n=i.reduce((e,{useScope:r,scopeName:i})=>({...e,...r(t)[`__scope${i}`]}),{});return e.useMemo(()=>({[`__scope${r.scopeName}`]:n}),[n])}};return i.scopeName=r.scopeName,i}var xa=globalThis?.document?e.useLayoutEffect:()=>{},Aa=e[" useId ".trim().toString()]||(()=>{}),ka=0;function La(t){const[r,i]=e.useState(Aa());return xa(()=>{t||i(e=>e??String(ka++))},[t]),t||(r?`radix-${r}`:"")}var Ia=e[" useInsertionEffect ".trim().toString()]||xa;function Ra({prop:t,defaultProp:r,onChange:i=()=>{},caller:n}){const[s,a,o]=function({defaultProp:t,onChange:r}){const[i,n]=e.useState(t),s=e.useRef(i),a=e.useRef(r);return Ia(()=>{a.current=r},[r]),e.useEffect(()=>{s.current!==i&&(a.current?.(i),s.current=i)},[i,s]),[i,n,a]}({defaultProp:r,onChange:i}),l=void 0!==t,d=l?t:s;{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(`${n} 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,n])}const c=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[d,c]}function Pa(t){const r=Da(t),i=e.forwardRef((t,i)=>{const{children:n,...s}=t,a=e.Children.toArray(n),o=a.find(_a);if(o){const t=o.props.children,n=a.map(r=>r===o?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return p(r,{...s,ref:i,children:e.isValidElement(t)?e.cloneElement(t,void 0,n):null})}return p(r,{...s,ref:i,children:n})});return i.displayName=`${t}.Slot`,i}function Da(t){const r=e.forwardRef((t,r)=>{const{children:i,...n}=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),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{const t=s(...e);return n(...e),t}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?wa(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}var Ca=Symbol("radix.slottable");function _a(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===Ca}var Oa=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=Pa(`Primitive.${r}`),n=e.forwardRef((e,t)=>{const{asChild:n,...s}=e,a=n?i:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),p(a,{...s,ref:t})});return n.displayName=`Primitive.${r}`,{...t,[r]:n}},{});function Ma(t){const r=e.useRef(t);return e.useEffect(()=>{r.current=t}),e.useMemo(()=>(...e)=>r.current?.(...e),[])}function Na(t,r=globalThis?.document){const i=Ma(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])}var Fa,$a="dismissableLayer.update",Ba="dismissableLayer.pointerDownOutside",Ua="dismissableLayer.focusOutside",za=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ga=e.forwardRef((t,r)=>{const{disableOutsidePointerEvents:i=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:o,onDismiss:l,...d}=t,c=e.useContext(za),[u,h]=e.useState(null),f=u?.ownerDocument??globalThis?.document,[,m]=e.useState({}),g=Sa(r,e=>h(e)),v=Array.from(c.layers),[y]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),b=v.indexOf(y),E=u?v.indexOf(u):-1,w=c.layersWithOutsidePointerEventsDisabled.size>0,S=E>=b,T=function(t,r=globalThis?.document){const i=Ma(t),n=e.useRef(!1),s=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){let t=function(){Ha(Ba,i,n,{discrete:!0})};const n={originalEvent:e};"touch"===e.pointerType?(r.removeEventListener("click",s.current),s.current=t,r.addEventListener("click",s.current,{once:!0})):t()}else r.removeEventListener("click",s.current);n.current=!1},t=window.setTimeout(()=>{r.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),r.removeEventListener("pointerdown",e),r.removeEventListener("click",s.current)}},[r,i]),{onPointerDownCapture:()=>n.current=!0}}(e=>{const t=e.target,r=[...c.branches].some(e=>e.contains(t));S&&!r&&(s?.(e),o?.(e),e.defaultPrevented||l?.())},f),x=function(t,r=globalThis?.document){const i=Ma(t),n=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){Ha(Ua,i,{originalEvent:e},{discrete:!1})}};return r.addEventListener("focusin",e),()=>r.removeEventListener("focusin",e)},[r,i]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}(e=>{const t=e.target;[...c.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||l?.())},f);return Na(e=>{E===c.layers.size-1&&(n?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),e.useEffect(()=>{if(u)return i&&(0===c.layersWithOutsidePointerEventsDisabled.size&&(Fa=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),ja(),()=>{i&&1===c.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=Fa)}},[u,f,i,c]),e.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),ja())},[u,c]),e.useEffect(()=>{const e=()=>m({});return document.addEventListener($a,e),()=>document.removeEventListener($a,e)},[]),p(Oa.div,{...d,ref:g,style:{pointerEvents:w?S?"auto":"none":void 0,...t.style},onFocusCapture:ba(t.onFocusCapture,x.onFocusCapture),onBlurCapture:ba(t.onBlurCapture,x.onBlurCapture),onPointerDownCapture:ba(t.onPointerDownCapture,T.onPointerDownCapture)})});Ga.displayName="DismissableLayer";function ja(){const e=new CustomEvent($a);document.dispatchEvent(e)}function Ha(e,t,r,{discrete:i}){const n=r.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),i?function(e,t){e&&v.flushSync(()=>e.dispatchEvent(t))}(n,s):n.dispatchEvent(s)}e.forwardRef((t,r)=>{const i=e.useContext(za),n=e.useRef(null),s=Sa(r,n);return e.useEffect(()=>{const e=n.current;if(e)return i.branches.add(e),()=>{i.branches.delete(e)}},[i.branches]),p(Oa.div,{...t,ref:s})}).displayName="DismissableLayerBranch";var Va="focusScope.autoFocusOnMount",Wa="focusScope.autoFocusOnUnmount",Ya={bubbles:!1,cancelable:!0},Ka=e.forwardRef((t,r)=>{const{loop:i=!1,trapped:n=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...o}=t,[l,d]=e.useState(null),c=Ma(s),u=Ma(a),h=e.useRef(null),f=Sa(r,e=>d(e)),m=e.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;e.useEffect(()=>{if(n){let e=function(e){if(m.paused||!l)return;const t=e.target;l.contains(t)?h.current=t:Za(h.current,{select:!0})},t=function(e){if(m.paused||!l)return;const t=e.relatedTarget;null!==t&&(l.contains(t)||Za(h.current,{select:!0}))},r=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&Za(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()}}},[n,l,m.paused]),e.useEffect(()=>{if(l){Ja.add(m);const t=document.activeElement;if(!l.contains(t)){const r=new CustomEvent(Va,Ya);l.addEventListener(Va,c),l.dispatchEvent(r),r.defaultPrevented||(!function(e,{select:t=!1}={}){const r=document.activeElement;for(const i of e)if(Za(i,{select:t}),document.activeElement!==r)return}((e=qa(l),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&Za(l))}return()=>{l.removeEventListener(Va,c),setTimeout(()=>{const e=new CustomEvent(Wa,Ya);l.addEventListener(Wa,u),l.dispatchEvent(e),e.defaultPrevented||Za(t??document.body,{select:!0}),l.removeEventListener(Wa,u),Ja.remove(m)},0)}}var e},[l,c,u,m]);const g=e.useCallback(e=>{if(!i&&!n)return;if(m.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,r=document.activeElement;if(t&&r){const t=e.currentTarget,[n,s]=function(e){const t=qa(e),r=Xa(t,e),i=Xa(t.reverse(),e);return[r,i]}(t);n&&s?e.shiftKey||r!==s?e.shiftKey&&r===n&&(e.preventDefault(),i&&Za(s,{select:!0})):(e.preventDefault(),i&&Za(n,{select:!0})):r===t&&e.preventDefault()}},[i,n,m.paused]);return p(Oa.div,{tabIndex:-1,...o,ref:f,onKeyDown:g})});function qa(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 Xa(e,t){for(const r of e)if(!Qa(r,{upTo:t}))return r}function Qa(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 Za(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()}}Ka.displayName="FocusScope";var Ja=function(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=eo(e,t),e.unshift(t)},remove(t){e=eo(e,t),e[0]?.resume()}}}();function eo(e,t){const r=[...e],i=r.indexOf(t);return-1!==i&&r.splice(i,1),r}var to=e.forwardRef((t,r)=>{const{container:i,...n}=t,[s,a]=e.useState(!1);xa(()=>a(!0),[]);const o=i||s&&globalThis?.document?.body;return o?y.createPortal(p(Oa.div,{...n,ref:r}),o):null});to.displayName="Portal";var ro=t=>{const{present:r,children:i}=t,n=function(t){const[r,i]=e.useState(),n=e.useRef(null),s=e.useRef(t),a=e.useRef("none"),o=t?"mounted":"unmounted",[l,d]=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=io(n.current);a.current="mounted"===l?e:"none"},[l]),xa(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=io(e);if(t)d("MOUNT");else if("none"===n||"none"===e?.display)d("UNMOUNT");else{d(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,d]),xa(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=io(n.current).includes(i.animationName);if(i.target===r&&a&&(d("ANIMATION_END"),!s.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=io(n.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)}}d("ANIMATION_END")},[r,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{n.current=e?getComputedStyle(e):null,i(e)},[])}}(r),s="function"==typeof i?i({present:n.isPresent}):e.Children.only(i),a=Sa(n.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}(s));return"function"==typeof i||n.isPresent?e.cloneElement(s,{ref:a}):null};function io(e){return e?.animationName||"none"}ro.displayName="Presence";var no=0;function so(){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 ao="right-scroll-bar-position",oo="width-before-scroll-bar";function lo(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var co="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,uo=new WeakMap;function ho(e,t){var r,i,n,s=(r=null,i=function(t){return e.forEach(function(e){return lo(e,t)})},(n=a(function(){return{value:r,callback:i,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0]).callback=i,n.facade);return co(function(){var t=uo.get(s);if(t){var r=new Set(t),i=new Set(e),n=s.current;r.forEach(function(e){i.has(e)||lo(e,null)}),i.forEach(function(e){r.has(e)||lo(e,n)})}uo.set(s,e)},[e]),s}function fo(e){return e}var po=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 n=r.read();if(!n)throw new Error("Sidecar medium not found");return e.createElement(n,S({},i))};po.isSideCarExport=!0;var mo=function(e){void 0===e&&(e={});var t=function(e,t){void 0===t&&(t=fo);var r=[],i=!1,n={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 n=t(e,i);return r.push(n),function(){r=r.filter(function(e){return e!==n})}},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 n=r;r=[],n.forEach(e),t=r}var s=function(){var r=t;t=[],r.forEach(e)},a=function(){return Promise.resolve().then(s)};a(),r={push:function(e){t.push(e),a()},filter:function(e){return t=t.filter(e),r}}}};return n}(null);return t.options=S({async:!0,ssr:!1},e),t}(),go=function(){},vo=e.forwardRef(function(t,r){var i=e.useRef(null),n=e.useState({onScrollCapture:go,onWheelCapture:go,onTouchMoveCapture:go}),s=n[0],a=n[1],o=t.forwardProps,l=t.children,d=t.className,c=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=ho([i,r]),k=S(S({},w),s);return e.createElement(e.Fragment,null,u&&e.createElement(x,{sideCar:mo,removeScrollBar:c,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:d,ref:A}),l))});vo.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},vo.classNames={fullWidth:oo,zeroRight:ao};function yo(){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 bo=function(){var e=0,t=null;return{add:function(r){var i,n;0==e&&(t=yo())&&(n=r,(i=t).styleSheet?i.styleSheet.cssText=n:i.appendChild(document.createTextNode(n)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){! --e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Eo=function(){var t,r=(t=bo(),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}},wo={left:0,top:0,right:0,gap:0},So=function(e){return parseInt(e||"",10)||0},To=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return wo;var t=function(e){var t=window.getComputedStyle(document.body),r=t["padding"===e?"paddingLeft":"marginLeft"],i=t["padding"===e?"paddingTop":"marginTop"],n=t["padding"===e?"paddingRight":"marginRight"];return[So(r),So(i),So(n)]}(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])}},xo=Eo(),Ao="data-scroll-locked",ko=function(e,t,r,i){var n=e.left,s=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(Ao,"] {\n overflow: hidden ").concat(i,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(i,";"),"margin"===r&&"\n padding-left: ".concat(n,"px;\n padding-top: ").concat(s,"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(ao," {\n right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat(oo," {\n margin-right: ").concat(o,"px ").concat(i,";\n }\n \n .").concat(ao," .").concat(ao," {\n right: 0 ").concat(i,";\n }\n \n .").concat(oo," .").concat(oo," {\n margin-right: 0 ").concat(i,";\n }\n \n body[").concat(Ao,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(o,"px;\n }\n")},Lo=function(){var e=parseInt(document.body.getAttribute(Ao)||"0",10);return isFinite(e)?e:0},Io=function(t){var r=t.noRelative,i=t.noImportant,n=t.gapMode,s=void 0===n?"margin":n;e.useEffect(function(){return document.body.setAttribute(Ao,(Lo()+1).toString()),function(){var e=Lo()-1;e<=0?document.body.removeAttribute(Ao):document.body.setAttribute(Ao,e.toString())}},[]);var a=e.useMemo(function(){return To(s)},[s]);return e.createElement(xo,{styles:ko(a,!r,s,i?"":"!important")})},Ro=!1;if("undefined"!=typeof window)try{var Po=Object.defineProperty({},"passive",{get:function(){return Ro=!0,!0}});window.addEventListener("test",Po,Po),window.removeEventListener("test",Po,Po)}catch(e){Ro=!1}var Do=!!Ro&&{passive:!1},Co=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])},_o=function(e,t){var r=t.ownerDocument,i=t;do{if("undefined"!=typeof ShadowRoot&&i instanceof ShadowRoot&&(i=i.host),Oo(e,i)){var n=Mo(e,i);if(n[1]>n[2])return!0}i=i.parentNode}while(i&&i!==r.body);return!1},Oo=function(e,t){return"v"===e?function(e){return Co(e,"overflowY")}(t):function(e){return Co(e,"overflowX")}(t)},Mo=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},No=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Fo=function(e){return[e.deltaX,e.deltaY]},$o=function(e){return e&&"current"in e?e.current:e},Bo=function(e){return"\n .block-interactivity-".concat(e," {pointer-events: none;}\n .allow-interactivity-").concat(e," {pointer-events: all;}\n")},Uo=0,zo=[];function Go(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var jo,Ho=(jo=function(t){var r=e.useRef([]),i=e.useRef([0,0]),n=e.useRef(),s=e.useState(Uo++)[0],a=e.useState(Eo)[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(s));var e=function(e,t,r){if(r||2===arguments.length)for(var i,n=0,s=t.length;n<s;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}([t.lockRef.current],(t.shards||[]).map($o),!0).filter(Boolean);return e.forEach(function(e){return e.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),e.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(s))})}}},[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,s=No(e),a=i.current,l="deltaX"in e?e.deltaX:a[0]-s[0],d="deltaY"in e?e.deltaY:a[1]-s[1],c=e.target,u=Math.abs(l)>Math.abs(d)?"h":"v";if("touches"in e&&"h"===u&&"range"===c.type)return!1;var h=_o(u,c);if(!h)return!0;if(h?r=u:(r="v"===u?"h":"v",h=_o(u,c)),!h)return!1;if(!n.current&&"changedTouches"in e&&(l||d)&&(n.current=r),!r)return!0;var f=n.current||r;return function(e,t,r,i,n){var s=function(e,t){return"h"===e&&"rtl"===t?-1:1}(e,window.getComputedStyle(t).direction),a=s*i,o=r.target,l=t.contains(o),d=!1,c=a>0,u=0,h=0;do{if(!o)break;var f=Mo(e,o),p=f[0],m=f[1]-f[2]-s*p;(p||m)&&Oo(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 c&&(Math.abs(u)<1||!n)?d=!0:c||!(Math.abs(h)<1)&&n||(d=!0),d}(f,t,e,"h"===f?l:d,!0)},[]),d=e.useCallback(function(e){var t=e;if(zo.length&&zo[zo.length-1]===a){var i="deltaY"in t?Fo(t):No(t),n=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(n&&n.should)t.cancelable&&t.preventDefault();else if(!n){var s=(o.current.shards||[]).map($o).filter(Boolean).filter(function(e){return e.contains(t.target)});(s.length>0?l(t,s[0]):!o.current.noIsolation)&&t.cancelable&&t.preventDefault()}}},[]),c=e.useCallback(function(e,t,i,n){var s={name:e,delta:t,target:i,should:n,shadowParent:Go(i)};r.current.push(s),setTimeout(function(){r.current=r.current.filter(function(e){return e!==s})},1)},[]),u=e.useCallback(function(e){i.current=No(e),n.current=void 0},[]),h=e.useCallback(function(e){c(e.type,Fo(e),e.target,l(e,t.lockRef.current))},[]),f=e.useCallback(function(e){c(e.type,No(e),e.target,l(e,t.lockRef.current))},[]);e.useEffect(function(){return zo.push(a),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",d,Do),document.addEventListener("touchmove",d,Do),document.addEventListener("touchstart",u,Do),function(){zo=zo.filter(function(e){return e!==a}),document.removeEventListener("wheel",d,Do),document.removeEventListener("touchmove",d,Do),document.removeEventListener("touchstart",u,Do)}},[]);var p=t.removeScrollBar,m=t.inert;return e.createElement(e.Fragment,null,m?e.createElement(a,{styles:Bo(s)}):null,p?e.createElement(Io,{noRelative:t.noRelative,gapMode:t.gapMode}):null)},mo.useMedium(jo),po),Vo=e.forwardRef(function(t,r){return e.createElement(vo,S({},t,{ref:r,sideCar:Ho}))});Vo.classNames=vo.classNames;var Wo=new WeakMap,Yo=new WeakMap,Ko={},qo=0,Xo=function(e){return e&&(e.host||Xo(e.parentNode))},Qo=function(e,t,r,i){var n=function(e,t){return t.map(function(t){if(e.contains(t))return t;var r=Xo(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]);Ko[r]||(Ko[r]=new WeakMap);var s=Ko[r],a=[],o=new Set,l=new Set(n),d=function(e){e&&!o.has(e)&&(o.add(e),d(e.parentNode))};n.forEach(d);var c=function(e){e&&!l.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(o.has(e))c(e);else try{var t=e.getAttribute(i),n=null!==t&&"false"!==t,l=(Wo.get(e)||0)+1,d=(s.get(e)||0)+1;Wo.set(e,l),s.set(e,d),a.push(e),1===l&&n&&Yo.set(e,!0),1===d&&e.setAttribute(r,"true"),n||e.setAttribute(i,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return c(t),o.clear(),qo++,function(){a.forEach(function(e){var t=Wo.get(e)-1,n=s.get(e)-1;Wo.set(e,t),s.set(e,n),t||(Yo.has(e)||e.removeAttribute(i),Yo.delete(e)),n||e.removeAttribute(r)}),--qo||(Wo=new WeakMap,Wo=new WeakMap,Yo=new WeakMap,Ko={})}},Zo=function(e,t,r){void 0===r&&(r="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),n=function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return n?(i.push.apply(i,Array.from(n.querySelectorAll("[aria-live], script"))),Qo(i,n,r,"aria-hidden")):function(){return null}},Jo="Dialog",[el,tl]=function(t,r=[]){let i=[];const n=()=>{const r=i.map(t=>e.createContext(t));return function(i){const n=i?.[t]||r;return e.useMemo(()=>({[`__scope${t}`]:{...i,[t]:n}}),[i,n])}};return n.scopeName=t,[function(r,n){const s=e.createContext(n),a=i.length;i=[...i,n];const o=r=>{const{scope:i,children:n,...o}=r,l=i?.[t]?.[a]||s,d=e.useMemo(()=>o,Object.values(o));return p(l.Provider,{value:d,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,d=e.useContext(l);if(d)return d;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},Ta(n,...r)]}(Jo),[rl,il]=el(Jo),nl=t=>{const{__scopeDialog:r,children:i,open:n,defaultOpen:s,onOpenChange:a,modal:o=!0}=t,l=e.useRef(null),d=e.useRef(null),[c,u]=Ra({prop:n,defaultProp:s??!1,onChange:a,caller:Jo});return p(rl,{scope:r,triggerRef:l,contentRef:d,contentId:La(),titleId:La(),descriptionId:La(),open:c,onOpenChange:u,onOpenToggle:e.useCallback(()=>u(e=>!e),[u]),modal:o,children:i})};nl.displayName=Jo;var sl="DialogTrigger",al=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=il(sl,r),s=Sa(t,n.triggerRef);return p(Oa.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":kl(n.open),...i,ref:s,onClick:ba(e.onClick,n.onOpenToggle)})});al.displayName=sl;var ol="DialogPortal",[ll,dl]=el(ol,{forceMount:void 0}),cl=t=>{const{__scopeDialog:r,forceMount:i,children:n,container:s}=t,a=il(ol,r);return p(ll,{scope:r,forceMount:i,children:e.Children.map(n,e=>p(ro,{present:i||a.open,children:p(to,{asChild:!0,container:s,children:e})}))})};cl.displayName=ol;var ul="DialogOverlay",hl=e.forwardRef((e,t)=>{const r=dl(ul,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=il(ul,e.__scopeDialog);return s.modal?p(ro,{present:i||s.open,children:p(pl,{...n,ref:t})}):null});hl.displayName=ul;var fl=Pa("DialogOverlay.RemoveScroll"),pl=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=il(ul,r);return p(Vo,{as:fl,allowPinchZoom:!0,shards:[n.contentRef],children:p(Oa.div,{"data-state":kl(n.open),...i,ref:t,style:{pointerEvents:"auto",...i.style}})})}),ml="DialogContent",gl=e.forwardRef((e,t)=>{const r=dl(ml,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=il(ml,e.__scopeDialog);return p(ro,{present:i||s.open,children:s.modal?p(vl,{...n,ref:t}):p(yl,{...n,ref:t})})});gl.displayName=ml;var vl=e.forwardRef((t,r)=>{const i=il(ml,t.__scopeDialog),n=e.useRef(null),s=Sa(r,i.contentRef,n);return e.useEffect(()=>{const e=n.current;if(e)return Zo(e)},[]),p(bl,{...t,ref:s,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ba(t.onCloseAutoFocus,e=>{e.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:ba(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;(2===t.button||r)&&e.preventDefault()}),onFocusOutside:ba(t.onFocusOutside,e=>e.preventDefault())})}),yl=e.forwardRef((t,r)=>{const i=il(ml,t.__scopeDialog),n=e.useRef(!1),s=e.useRef(!1);return p(bl,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),e.defaultPrevented||(n.current||i.triggerRef.current?.focus(),e.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:e=>{t.onInteractOutside?.(e),e.defaultPrevented||(n.current=!0,"pointerdown"===e.detail.originalEvent.type&&(s.current=!0));const r=e.target,a=i.triggerRef.current?.contains(r);a&&e.preventDefault(),"focusin"===e.detail.originalEvent.type&&s.current&&e.preventDefault()}})}),bl=e.forwardRef((t,r)=>{const{__scopeDialog:i,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:a,...o}=t,l=il(ml,i),d=e.useRef(null),c=Sa(r,d);return e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??so()),document.body.insertAdjacentElement("beforeend",e[1]??so()),no++,()=>{1===no&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),no--}},[]),g(m,{children:[p(Ka,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:a,children:p(Ga,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":kl(l.open),...o,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),g(m,{children:[p(Pl,{titleId:l.titleId}),p(Dl,{contentRef:d,descriptionId:l.descriptionId})]})]})}),El="DialogTitle",wl=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=il(El,r);return p(Oa.h2,{id:n.titleId,...i,ref:t})});wl.displayName=El;var Sl="DialogDescription",Tl=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=il(Sl,r);return p(Oa.p,{id:n.descriptionId,...i,ref:t})});Tl.displayName=Sl;var xl="DialogClose",Al=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=il(xl,r);return p(Oa.button,{type:"button",...i,ref:t,onClick:ba(e.onClick,()=>n.onOpenChange(!1))})});function kl(e){return e?"open":"closed"}Al.displayName=xl;var Ll="DialogTitleWarning",[Il,Rl]=function(t,r){const i=e.createContext(r),n=t=>{const{children:r,...n}=t,s=e.useMemo(()=>n,Object.values(n));return p(i.Provider,{value:s,children:r})};return n.displayName=t+"Provider",[n,function(n){const s=e.useContext(i);if(s)return s;if(void 0!==r)return r;throw new Error(`\`${n}\` must be used within \`${t}\``)}]}(Ll,{contentName:ml,titleName:El,docsSlug:"dialog"}),Pl=({titleId:t})=>{const r=Rl(Ll),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},Dl=({contentRef:t,descriptionId:r})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Rl("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},Cl=nl,_l=al,Ol=cl,Ml=hl,Nl=gl,Fl=wl,$l=Tl,Bl=Al;const Ul=t.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),zl=()=>{const e=t.useContext(Ul);if(!e)throw new Error("useDrawerContext must be used within a Drawer.Root");return e};function Gl(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function jl(){return Vl(/^iPad/)||Vl(/^Mac/)&&navigator.maxTouchPoints>1}function Hl(){return Vl(/^iPhone/)||jl()}function Vl(e){return"undefined"!=typeof window&&null!=window.navigator?e.test(window.navigator.platform):void 0}!function(e){if("undefined"==typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}("[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(\n[data-state=closed]\n){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}");const Wl="undefined"!=typeof window?o:i;function Yl(...e){return(...t)=>{for(let r of e)"function"==typeof r&&r(...t)}}const Kl="undefined"!=typeof document&&window.visualViewport;function ql(e){let t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function Xl(e){for(ql(e)&&(e=e.parentElement);e&&!ql(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}const Ql=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let Zl,Jl=0;function ed(e={}){let{isDisabled:t}=e;Wl(()=>{if(!t)return Jl++,1===Jl&&Hl()&&(Zl=function(){let e,t=0,r=r=>{e=Xl(r.target),e===document.documentElement&&e===document.body||(t=r.changedTouches[0].pageY)},i=r=>{if(!e||e===document.documentElement||e===document.body)return void r.preventDefault();let i=r.changedTouches[0].pageY,n=e.scrollTop,s=e.scrollHeight-e.clientHeight;0!==s&&((n<=0&&i>t||n>=s&&i<t)&&r.preventDefault(),t=i)},n=e=>{let t=e.target;id(t)&&t!==document.activeElement&&(e.preventDefault(),t.style.transform="translateY(-2000px)",t.focus(),requestAnimationFrame(()=>{t.style.transform=""}))},s=e=>{let t=e.target;id(t)&&(t.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{t.style.transform="",Kl&&(Kl.height<window.innerHeight?requestAnimationFrame(()=>{rd(t)}):Kl.addEventListener("resize",()=>rd(t),{once:!0}))}))},a=()=>{window.scrollTo(0,0)},o=window.pageXOffset,l=window.pageYOffset,d=Yl(function(e,t,r){let i=e.style[t];return e.style[t]=r,()=>{e.style[t]=i}}(document.documentElement,"paddingRight",window.innerWidth-document.documentElement.clientWidth+"px"));window.scrollTo(0,0);let c=Yl(td(document,"touchstart",r,{passive:!1,capture:!0}),td(document,"touchmove",i,{passive:!1,capture:!0}),td(document,"touchend",n,{passive:!1,capture:!0}),td(document,"focus",s,!0),td(window,"scroll",a));return()=>{d(),c(),window.scrollTo(o,l)}}()),()=>{Jl--,0===Jl&&(null==Zl||Zl())}},[t])}function td(e,t,r,i){return e.addEventListener(t,r,i),()=>{e.removeEventListener(t,r,i)}}function rd(e){let t=document.scrollingElement||document.documentElement;for(;e&&e!==t;){let t=Xl(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let r=t.getBoundingClientRect().top,i=e.getBoundingClientRect().top;e.getBoundingClientRect().bottom>t.getBoundingClientRect().bottom+24&&(t.scrollTop+=i-r)}e=t.parentElement}}function id(e){return e instanceof HTMLInputElement&&!Ql.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function nd(...t){return e.useCallback(function(...e){return t=>e.forEach(e=>function(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}(e,t))}(...t),t)}const sd=new WeakMap;function ad(e,t,r=!1){if(!(e&&e instanceof HTMLElement))return;let i={};Object.entries(t).forEach(([t,r])=>{t.startsWith("--")?e.style.setProperty(t,r):(i[t]=e.style[t],e.style[t]=r)}),r||sd.set(e,i)}const od=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function ld(e,t){if(!e)return null;const r=window.getComputedStyle(e),i=r.transform||r.webkitTransform||r.mozTransform;let n=i.match(/^matrix3d\((.+)\)$/);return n?parseFloat(n[1].split(", ")[od(t)?13:12]):(n=i.match(/^matrix\((.+)\)$/),n?parseFloat(n[1].split(", ")[od(t)?5:4]):null)}function dd(e,t){if(!e)return()=>{};const r=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=r}}const cd={DURATION:.5,EASE:[.32,.72,0,1]},ud=16,hd="vaul-dragging";function fd(e){const r=t.useRef(e);return t.useEffect(()=>{r.current=e}),t.useMemo(()=>(...e)=>null==r.current?void 0:r.current.call(r,...e),[])}function pd({prop:e,defaultProp:r,onChange:i=()=>{}}){const[n,s]=function({defaultProp:e,onChange:r}){const i=t.useState(e),[n]=i,s=t.useRef(n),a=fd(r);return t.useEffect(()=>{s.current!==n&&(a(n),s.current=n)},[n,s,a]),i}({defaultProp:r,onChange:i}),a=void 0!==e,o=a?e:n,l=fd(i),d=t.useCallback(t=>{if(a){const r="function"==typeof t?t(e):t;r!==e&&l(r)}else s(t)},[a,e,s,l]);return[o,d]}let md=null;function gd({open:e,onOpenChange:r,children:i,onDrag:n,onRelease:s,snapPoints:a,shouldScaleBackground:o=!1,setBackgroundColorOnScale:l=!0,closeThreshold:d=.25,scrollLockTimeout:c=100,dismissible:u=!0,handleOnly:h=!1,fadeFromIndex:f=a&&a.length-1,activeSnapPoint:p,setActiveSnapPoint:m,fixed:g,modal:v=!0,onClose:y,nested:b,noBodyStyles:E=!1,direction:w="bottom",defaultOpen:S=!1,disablePreventScroll:T=!0,snapToSequentialPoint:x=!1,preventScrollRestoration:A=!1,repositionInputs:k=!0,onAnimationEnd:L,container:I,autoFocus:R=!1}){var P,D;const[C=!1,_]=pd({defaultProp:S,prop:e,onChange:e=>{null==r||r(e),e||b||ce(),setTimeout(()=>{null==L||L(e)},1e3*cd.DURATION),e&&!v&&"undefined"!=typeof window&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),e||(document.body.style.pointerEvents="auto")}}),[O,M]=t.useState(!1),[N,F]=t.useState(!1),[$,B]=t.useState(!1),U=t.useRef(null),z=t.useRef(null),G=t.useRef(null),j=t.useRef(null),H=t.useRef(null),V=t.useRef(!1),W=t.useRef(null),Y=t.useRef(0),K=t.useRef(!1),q=t.useRef(!S),X=t.useRef(0),Q=t.useRef(null),Z=t.useRef((null==(P=Q.current)?void 0:P.getBoundingClientRect().height)||0),J=t.useRef((null==(D=Q.current)?void 0:D.getBoundingClientRect().width)||0),ee=t.useRef(0),te=t.useCallback(e=>{a&&e===ae.length-1&&(z.current=new Date)},[]),{activeSnapPoint:re,activeSnapPointIndex:ie,setActiveSnapPoint:ne,onRelease:se,snapPointsOffset:ae,onDrag:oe,shouldFade:le,getPercentageDragged:de}=function({activeSnapPointProp:e,setActiveSnapPointProp:r,snapPoints:i,drawerRef:n,overlayRef:s,fadeFromIndex:a,onSnapPointChange:o,direction:l="bottom",container:d,snapToSequentialPoint:c}){const[u,h]=pd({prop:e,defaultProp:null==i?void 0:i[0],onChange:r}),[f,p]=t.useState("undefined"!=typeof window?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);t.useEffect(()=>{function e(){p({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const m=t.useMemo(()=>u===(null==i?void 0:i[i.length-1])||null,[i,u]),g=t.useMemo(()=>{var e;return null!=(e=null==i?void 0:i.findIndex(e=>e===u))?e:null},[i,u]),v=i&&i.length>0&&(a||0===a)&&!Number.isNaN(a)&&i[a]===u||!i,y=t.useMemo(()=>{const e=d?{width:d.getBoundingClientRect().width,height:d.getBoundingClientRect().height}:"undefined"!=typeof window?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var t;return null!=(t=null==i?void 0:i.map(t=>{const r="string"==typeof t;let i=0;if(r&&(i=parseInt(t,10)),od(l)){const n=r?i:f?t*e.height:0;return f?"bottom"===l?e.height-n:-e.height+n:n}const n=r?i:f?t*e.width:0;return f?"right"===l?e.width-n:-e.width+n:n}))?t:[]},[i,f,d]),b=t.useMemo(()=>null!==g?null==y?void 0:y[g]:null,[y,g]),E=t.useCallback(e=>{var t;const r=null!=(t=null==y?void 0:y.findIndex(t=>t===e))?t:null;o(r),ad(n.current,{transition:`transform ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`,transform:od(l)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`}),y&&r!==y.length-1&&void 0!==a&&r!==a&&r<a?ad(s.current,{transition:`opacity ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`,opacity:"0"}):ad(s.current,{transition:`opacity ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`,opacity:"1"}),h(null==i?void 0:i[Math.max(r,0)])},[n.current,i,y,a,s,h]);return t.useEffect(()=>{if(u||e){var t;const r=null!=(t=null==i?void 0:i.findIndex(t=>t===e||t===u))?t:-1;y&&-1!==r&&"number"==typeof y[r]&&E(y[r])}},[u,e,i,y,E]),{isLastSnapPoint:m,activeSnapPoint:u,shouldFade:v,getPercentageDragged:function(e,t){if(!i||"number"!=typeof g||!y||void 0===a)return null;const r=g===a-1;if(g>=a&&t)return 0;if(r&&!t)return 1;if(!v&&!r)return null;const n=r?g+1:g-1,s=r?y[n]-y[n-1]:y[n+1]-y[n],o=e/Math.abs(s);return r?1-o:o},setActiveSnapPoint:h,activeSnapPointIndex:g,onRelease:function({draggedDistance:e,closeDrawer:t,velocity:r,dismissible:n}){if(void 0===a)return;const o="bottom"===l||"right"===l?(null!=b?b:0)-e:(null!=b?b:0)+e,d=0===g,u=e>0;if(g===a-1&&ad(s.current,{transition:`opacity ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`}),!c&&r>2&&!u)return void(n?t():E(y[0]));if(!c&&r>2&&u&&y&&i)return void E(y[i.length-1]);const h=null==y?void 0:y.reduce((e,t)=>"number"!=typeof e||"number"!=typeof t?e:Math.abs(t-o)<Math.abs(e-o)?t:e),f=od(l)?window.innerHeight:window.innerWidth;if(r>.4&&Math.abs(e)<.4*f){const e=u?1:-1;if(e>0&&m&&i)return void E(y[i.length-1]);if(d&&e<0&&n&&t(),null===g)return;return void E(y[g+e])}E(h)},onDrag:function({draggedDistance:e}){if(null===b)return;const t="bottom"===l||"right"===l?b-e:b+e;("bottom"===l||"right"===l)&&t<y[y.length-1]||("top"===l||"left"===l)&&t>y[y.length-1]||ad(n.current,{transform:od(l)?`translate3d(0, ${t}px, 0)`:`translate3d(${t}px, 0, 0)`})},snapPointsOffset:y}}({snapPoints:a,activeSnapPointProp:p,setActiveSnapPointProp:m,drawerRef:Q,fadeFromIndex:f,overlayRef:U,onSnapPointChange:te,direction:w,container:I,snapToSequentialPoint:x});ed({isDisabled:!C||N||!v||$||!O||!k||!T});const{restorePositionSetting:ce}=function({isOpen:e,modal:r,nested:i,hasBeenOpened:n,preventScrollRestoration:s,noBodyStyles:a}){const[o,l]=t.useState(()=>"undefined"!=typeof window?window.location.href:""),d=t.useRef(0),c=t.useCallback(()=>{if(Gl()&&null===md&&e&&!a){md={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:e,innerHeight:t}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:-d.current+"px",left:-e+"px",right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const e=t-window.innerHeight;e&&d.current>=t&&(document.body.style.top=-(d.current+e)+"px")}),300)}},[e]),u=t.useCallback(()=>{if(Gl()&&null!==md&&!a){const e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);Object.assign(document.body.style,md),window.requestAnimationFrame(()=>{s&&o!==window.location.href?l(window.location.href):window.scrollTo(t,e)}),md=null}},[o]);return t.useEffect(()=>{function e(){d.current=window.scrollY}return e(),window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}},[]),t.useEffect(()=>{if(r)return()=>{"undefined"!=typeof document&&(document.querySelector("[data-vaul-drawer]")||u())}},[r,u]),t.useEffect(()=>{!i&&n&&(e?(!window.matchMedia("(display-mode: standalone)").matches&&c(),r||window.setTimeout(()=>{u()},500)):u())},[e,n,o,r,i,c,u]),{restorePositionSetting:u}}({isOpen:C,modal:v,nested:null!=b&&b,hasBeenOpened:O,preventScrollRestoration:A,noBodyStyles:E});function ue(){return(window.innerWidth-26)/window.innerWidth}function he(e,t){var r;let i=e;const n=null==(r=window.getSelection())?void 0:r.toString(),s=Q.current?ld(Q.current,w):null,a=new Date;if("SELECT"===i.tagName)return!1;if(i.hasAttribute("data-vaul-no-drag")||i.closest("[data-vaul-no-drag]"))return!1;if("right"===w||"left"===w)return!0;if(z.current&&a.getTime()-z.current.getTime()<500)return!1;if(null!==s&&("bottom"===w?s>0:s<0))return!0;if(n&&n.length>0)return!1;if(H.current&&a.getTime()-H.current.getTime()<c&&0===s)return H.current=a,!1;if(t)return H.current=a,!1;for(;i;){if(i.scrollHeight>i.clientHeight){if(0!==i.scrollTop)return H.current=new Date,!1;if("dialog"===i.getAttribute("role"))return!0}i=i.parentNode}return!0}function fe(e){!function(){if(!N||!Q.current)return;Q.current.classList.remove(hd),V.current=!1,F(!1),j.current=new Date}(),null==y||y(),e||_(!1),setTimeout(()=>{a&&ne(a[0])},1e3*cd.DURATION)}function pe(){if(!Q.current)return;const e=document.querySelector("[data-vaul-drawer-wrapper]"),t=ld(Q.current,w);ad(Q.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`}),ad(U.current,{transition:`opacity ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`,opacity:"1"}),o&&t&&t>0&&C&&ad(e,{borderRadius:"8px",overflow:"hidden",...od(w)?{transform:`scale(${ue()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${ue()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${cd.DURATION}s`,transitionTimingFunction:`cubic-bezier(${cd.EASE.join(",")})`},!0)}return t.useEffect(()=>{window.requestAnimationFrame(()=>{q.current=!0})},[]),t.useEffect(()=>{var e;function t(){if(!Q.current||!k)return;if(id(document.activeElement)||K.current){var e;const t=(null==(e=window.visualViewport)?void 0:e.height)||0,r=window.innerHeight;let i=r-t;const n=Q.current.getBoundingClientRect().height||0,s=n>.8*r;ee.current||(ee.current=n);const o=Q.current.getBoundingClientRect().top;if(Math.abs(X.current-i)>60&&(K.current=!K.current),a&&a.length>0&&ae&&ie){i+=ae[ie]||0}if(X.current=i,n>t||K.current){const e=Q.current.getBoundingClientRect().height;let r=e;e>t&&(r=t-(s?o:26)),Q.current.style.height=g?e-Math.max(i,0)+"px":`${Math.max(r,t-o)}px`}else(function(){const e=navigator.userAgent;return"undefined"!=typeof window&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))})()||(Q.current.style.height=`${ee.current}px`);a&&a.length>0&&!K.current?Q.current.style.bottom="0px":Q.current.style.bottom=`${Math.max(i,0)}px`}}return null==(e=window.visualViewport)||e.addEventListener("resize",t),()=>{var e;return null==(e=window.visualViewport)?void 0:e.removeEventListener("resize",t)}},[ie,a,ae]),t.useEffect(()=>(C&&(ad(document.documentElement,{scrollBehavior:"auto"}),z.current=new Date),()=>{!function(e,t){if(!(e&&e instanceof HTMLElement))return;let r=sd.get(e);r&&(e.style[t]=r[t])}(document.documentElement,"scrollBehavior")}),[C]),t.useEffect(()=>{v||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[v]),t.createElement(Cl,{defaultOpen:S,onOpenChange:e=>{(u||e)&&(e?M(!0):fe(!0),_(e))},open:C},t.createElement(Ul.Provider,{value:{activeSnapPoint:re,snapPoints:a,setActiveSnapPoint:ne,drawerRef:Q,overlayRef:U,onOpenChange:r,onPress:function(e){var t,r;(u||a)&&(Q.current&&!Q.current.contains(e.target)||(Z.current=(null==(t=Q.current)?void 0:t.getBoundingClientRect().height)||0,J.current=(null==(r=Q.current)?void 0:r.getBoundingClientRect().width)||0,F(!0),G.current=new Date,Hl()&&window.addEventListener("touchend",()=>V.current=!1,{once:!0}),e.target.setPointerCapture(e.pointerId),Y.current=od(w)?e.pageY:e.pageX))},onRelease:function(e){if(!N||!Q.current)return;Q.current.classList.remove(hd),V.current=!1,F(!1),j.current=new Date;const t=ld(Q.current,w);if(!e||!he(e.target,!1)||!t||Number.isNaN(t))return;if(null===G.current)return;const r=j.current.getTime()-G.current.getTime(),i=Y.current-(od(w)?e.pageY:e.pageX),n=Math.abs(i)/r;if(n>.05&&(B(!0),setTimeout(()=>{B(!1)},200)),a){return se({draggedDistance:i*("bottom"===w||"right"===w?1:-1),closeDrawer:fe,velocity:n,dismissible:u}),void(null==s||s(e,!0))}if("bottom"===w||"right"===w?i>0:i<0)return pe(),void(null==s||s(e,!0));if(n>.4)return fe(),void(null==s||s(e,!1));var o;const l=Math.min(null!=(o=Q.current.getBoundingClientRect().height)?o:0,window.innerHeight);var c;const h=Math.min(null!=(c=Q.current.getBoundingClientRect().width)?c:0,window.innerWidth),f="left"===w||"right"===w;if(Math.abs(t)>=(f?h:l)*d)return fe(),void(null==s||s(e,!1));null==s||s(e,!0),pe()},onDrag:function(e){if(Q.current&&N){const t="bottom"===w||"right"===w?1:-1,r=(Y.current-(od(w)?e.pageY:e.pageX))*t,i=r>0,s=a&&!u&&!i;if(s&&0===ie)return;const l=Math.abs(r),d=document.querySelector("[data-vaul-drawer-wrapper]");let c=l/("bottom"===w||"top"===w?Z.current:J.current);const h=de(l,i);if(null!==h&&(c=h),s&&c>=1)return;if(!V.current&&!he(e.target,i))return;if(Q.current.classList.add(hd),V.current=!0,ad(Q.current,{transition:"none"}),ad(U.current,{transition:"none"}),a&&oe({draggedDistance:r}),i&&!a){const e=function(e){return 8*(Math.log(e+1)-2)}(r),i=Math.min(-1*e,0)*t;return void ad(Q.current,{transform:od(w)?`translate3d(0, ${i}px, 0)`:`translate3d(${i}px, 0, 0)`})}const p=1-c;if((le||f&&ie===f-1)&&(null==n||n(e,c),ad(U.current,{opacity:`${p}`,transition:"none"},!0)),d&&U.current&&o){const e=Math.min(ue()+c*(1-ue()),1),t=8-8*c,r=Math.max(0,14-14*c);ad(d,{borderRadius:`${t}px`,transform:od(w)?`scale(${e}) translate3d(0, ${r}px, 0)`:`scale(${e}) translate3d(${r}px, 0, 0)`,transition:"none"},!0)}if(!a){const e=l*t;ad(Q.current,{transform:od(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})}}},dismissible:u,shouldAnimate:q,handleOnly:h,isOpen:C,isDragging:N,shouldFade:le,closeDrawer:fe,onNestedDrag:function(e,t){if(t<0)return;const r=(window.innerWidth-ud)/window.innerWidth,i=r+t*(1-r),n=t*ud-16;ad(Q.current,{transform:od(w)?`scale(${i}) translate3d(0, ${n}px, 0)`:`scale(${i}) translate3d(${n}px, 0, 0)`,transition:"none"})},onNestedOpenChange:function(e){const t=e?(window.innerWidth-ud)/window.innerWidth:1,r=e?-16:0;W.current&&window.clearTimeout(W.current),ad(Q.current,{transition:`transform ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`,transform:od(w)?`scale(${t}) translate3d(0, ${r}px, 0)`:`scale(${t}) translate3d(${r}px, 0, 0)`}),!e&&Q.current&&(W.current=setTimeout(()=>{const e=ld(Q.current,w);ad(Q.current,{transition:"none",transform:od(w)?`translate3d(0, ${e}px, 0)`:`translate3d(${e}px, 0, 0)`})},500))},onNestedRelease:function(e,t){const r=od(w)?window.innerHeight:window.innerWidth,i=t?(r-ud)/r:1,n=t?-16:0;t&&ad(Q.current,{transition:`transform ${cd.DURATION}s cubic-bezier(${cd.EASE.join(",")})`,transform:od(w)?`scale(${i}) translate3d(0, ${n}px, 0)`:`scale(${i}) translate3d(${n}px, 0, 0)`})},keyboardIsOpen:K,modal:v,snapPointsOffset:ae,activeSnapPointIndex:ie,direction:w,shouldScaleBackground:o,setBackgroundColorOnScale:l,noBodyStyles:E,container:I,autoFocus:R}},i))}const vd=t.forwardRef(function({...e},r){const{overlayRef:i,snapPoints:n,onRelease:s,shouldFade:a,isOpen:o,modal:l,shouldAnimate:d}=zl(),c=nd(r,i),u=n&&n.length>0;if(!l)return null;const h=t.useCallback(e=>s(e),[s]);return t.createElement(Ml,{onMouseUp:h,ref:c,"data-vaul-overlay":"","data-vaul-snap-points":o&&u?"true":"false","data-vaul-snap-points-overlay":o&&a?"true":"false","data-vaul-animate":(null==d?void 0:d.current)?"true":"false",...e})});vd.displayName="Drawer.Overlay";const yd=t.forwardRef(function({onPointerDownOutside:e,style:r,onOpenAutoFocus:i,...n},s){const{drawerRef:a,onPress:o,onRelease:l,onDrag:d,keyboardIsOpen:c,snapPointsOffset:h,activeSnapPointIndex:f,modal:p,isOpen:m,direction:g,snapPoints:v,container:y,handleOnly:b,shouldAnimate:E,autoFocus:w}=zl(),[S,T]=t.useState(!1),x=nd(s,a),A=t.useRef(null),k=t.useRef(null),L=t.useRef(!1),I=v&&v.length>0;!function(){const{direction:e,isOpen:r,shouldScaleBackground:i,setBackgroundColorOnScale:n,noBodyStyles:s}=zl(),a=t.useRef(null),o=u(()=>document.body.style.backgroundColor,[]);function l(){return(window.innerWidth-26)/window.innerWidth}t.useEffect(()=>{if(r&&i){a.current&&clearTimeout(a.current);const t=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!t)return;n&&!s&&dd(document.body,{background:"black"}),dd(t,{transformOrigin:od(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${cd.DURATION}s`,transitionTimingFunction:`cubic-bezier(${cd.EASE.join(",")})`});const r=dd(t,{borderRadius:"8px",overflow:"hidden",...od(e)?{transform:`scale(${l()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${l()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{r(),a.current=window.setTimeout(()=>{o?document.body.style.background=o:document.body.style.removeProperty("background")},1e3*cd.DURATION)}}},[r,i,o])}();function R(e){A.current=null,L.current=!1,l(e)}return t.useEffect(()=>{I&&window.requestAnimationFrame(()=>{T(!0)})},[]),t.createElement(Nl,{"data-vaul-drawer-direction":g,"data-vaul-drawer":"","data-vaul-delayed-snap-points":S?"true":"false","data-vaul-snap-points":m&&I?"true":"false","data-vaul-custom-container":y?"true":"false","data-vaul-animate":(null==E?void 0:E.current)?"true":"false",...n,ref:x,style:h&&h.length>0?{"--snap-point-height":`${h[null!=f?f:0]}px`,...r}:r,onPointerDown:e=>{b||(null==n.onPointerDown||n.onPointerDown.call(n,e),A.current={x:e.pageX,y:e.pageY},o(e))},onOpenAutoFocus:e=>{null==i||i(e),w||e.preventDefault()},onPointerDownOutside:t=>{null==e||e(t),p&&!t.defaultPrevented?c.current&&(c.current=!1):t.preventDefault()},onFocusOutside:e=>{p||e.preventDefault()},onPointerMove:e=>{if(k.current=e,b)return;if(null==n.onPointerMove||n.onPointerMove.call(n,e),!A.current)return;const t=e.pageY-A.current.y,r=e.pageX-A.current.x,i="touch"===e.pointerType?10:2,s=((e,t,r=0)=>{if(L.current)return!0;const i=Math.abs(e.y),n=Math.abs(e.x),s=n>i,a=["bottom","right"].includes(t)?1:-1;if("left"===t||"right"===t){if(!(e.x*a<0)&&n>=0&&n<=r)return s}else if(!(e.y*a<0)&&i>=0&&i<=r)return!s;return L.current=!0,!0})({x:r,y:t},g,i);s?d(e):(Math.abs(r)>i||Math.abs(t)>i)&&(A.current=null)},onPointerUp:e=>{null==n.onPointerUp||n.onPointerUp.call(n,e),A.current=null,L.current=!1,l(e)},onPointerOut:e=>{null==n.onPointerOut||n.onPointerOut.call(n,e),R(k.current)},onContextMenu:e=>{null==n.onContextMenu||n.onContextMenu.call(n,e),k.current&&R(k.current)}})});yd.displayName="Drawer.Content";const bd=t.forwardRef(function({preventCycle:e=!1,children:r,...i},n){const{closeDrawer:s,isDragging:a,snapPoints:o,activeSnapPoint:l,setActiveSnapPoint:d,dismissible:c,handleOnly:u,isOpen:h,onPress:f,onDrag:p}=zl(),m=t.useRef(null),g=t.useRef(!1);function v(){m.current&&window.clearTimeout(m.current),g.current=!1}return t.createElement("div",{onClick:function(){g.current?v():window.setTimeout(()=>{!function(){if(a||e||g.current)return void v();if(v(),!o||0===o.length)return void(c||s());if(l===o[o.length-1]&&c)return void s();const t=o.findIndex(e=>e===l);if(-1===t)return;const r=o[t+1];d(r)}()},120)},onPointerCancel:v,onPointerDown:e=>{u&&f(e),m.current=window.setTimeout(()=>{g.current=!0},250)},onPointerMove:e=>{u&&p(e)},ref:n,"data-vaul-drawer-visible":h?"true":"false","data-vaul-handle":"","aria-hidden":"true",...i},t.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},r))});bd.displayName="Drawer.Handle";const Ed={Root:gd,NestedRoot:function({onDrag:e,onOpenChange:r,open:i,...n}){const{onNestedDrag:s,onNestedOpenChange:a,onNestedRelease:o}=zl();if(!s)throw new Error("Drawer.NestedRoot must be placed in another drawer");return t.createElement(gd,{nested:!0,open:i,onClose:()=>{a(!1)},onDrag:(t,r)=>{s(t,r),null==e||e(t,r)},onOpenChange:e=>{e&&a(e),null==r||r(e)},onRelease:o,...n})},Content:yd,Overlay:vd,Trigger:_l,Portal:function(e){const r=zl(),{container:i=r.container,...n}=e;return t.createElement(Ol,{container:i,...n})},Handle:bd,Close:Bl,Title:Fl,Description:$l};function wd(t){var r=T(t,[]);return e.createElement(Ed.Root,Object.assign({"data-slot":"drawer"},r))}function Sd(t){var r=T(t,[]);return e.createElement(Ed.Trigger,Object.assign({"data-slot":"drawer-trigger"},r))}function Td(t){var r=T(t,[]);return e.createElement(Ed.Portal,Object.assign({"data-slot":"drawer-portal"},r))}function xd(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(Ed.Overlay,Object.assign({"data-slot":"drawer-overlay",className:wt("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[999999] bg-black/50",r)},i))}function Ad(t){var{className:r,children:i}=t,n=T(t,["className","children"]);return e.createElement(Td,{"data-slot":"drawer-portal"},e.createElement(xd,null),e.createElement(Ed.Content,Object.assign({"data-slot":"drawer-content",className:wt("group/drawer-content bg-background fixed z-[999999] flex h-auto flex-col","data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b","data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t","data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm","data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=left]:sm:max-w-sm",r)},n),e.createElement("div",{className:"bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full group-data-[vaul-drawer-direction=bottom]/drawer-content:block"}),i))}function kd(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({"data-slot":"drawer-header",className:wt("flex flex-col gap-1.5 p-4",r)},i))}function Ld(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(Ed.Title,Object.assign({"data-slot":"drawer-title",className:wt("text-foreground font-semibold",r)},i))}const Id=({children:e,products:r,contentId:i})=>{const{isPreview:n}=ea();return t.createElement(wd,{direction:"right",fadeFromIndex:0,snapPoints:[1]},t.createElement(Sd,{className:"w-full"},e),t.createElement(Ad,null,t.createElement(kd,null,t.createElement(Ld,null,"상품 목록")),t.createElement("div",{className:"overflow-y-scroll grid-cols-2 grid items-baseline justify-items-center scrollbar-hide"},r.map(e=>e.linkPath?t.createElement("a",{key:e.productId,className:"p-2 text-gray-800 w-full h-full flex flex-col items-center justify-center no-underline",href:e.linkPath,target:"_blank",onClick:()=>x(void 0,void 0,void 0,function*(){n||(yield Gs({contentId:i,contentProductId:e.eventProductId,productId:e.productId}))})},t.createElement(Rd,{product:e})):t.createElement(Rd,{key:e.productId,product:e})))))},Rd=({product:e})=>t.createElement("div",{className:"text-gray-800 w-32"},t.createElement("div",{className:"w-full aspect-square mb-2 border border-[#f4f3f6] rounded "},t.createElement("img",{src:e.thumbPath,alt:e.productName,className:"w-full h-full"})),e.brand&&t.createElement("p",{className:"text-xs text-gray-400 mb-1"},e.brand.brandName),t.createElement("p",{className:"w-full text-[12px] md:text-[15px] mb-1"},e.productName),t.createElement("div",{className:"w-full "},t.createElement("div",{className:"flex"},t.createElement("span",{className:"text-sm text-red-500 mr-2 font-semibold"},e.discount,"%"),t.createElement("span",{className:"font-semibold"},St(e.sellingPrice),"원")))),Pd=({products:e,useDrawer:r,contentId:i})=>{const n=u(()=>(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"}},r?t.createElement(Id,{products:e,contentId:i},t.createElement(ya,{product:e[0],productsLength:e.length,contentId:i})):t.createElement(ya,{product:e[0],productsLength:e.length,hideMoreBtn:!0,contentId:i})):t.createElement(ds,{nested:!0,modules:[xs,fs],slidesPerView:1.1,effect:"cards",autoplay:!0,loop:!0,grabCursor:!0,cardsEffect:{rotate:!1},className:"w-full",style:{height:"80px"}},n.map((n,s)=>t.createElement(cs,{key:s+n.productId,className:"bg-white overflow-hidden rounded-xl",style:{borderRadius:"10px",height:"80px"}},r?t.createElement(Id,{products:e,contentId:i},t.createElement(ya,{product:n,productsLength:e.length,contentId:i})):t.createElement(ya,{product:n,productsLength:e.length,hideMoreBtn:!0,contentId:i}))))):null},Dd=({shortForm:e,useDrawer:r,isPopup:i,shareUrl:n,handleClose:s})=>{const[o,l]=a(!Boolean(i)),[d,c]=a(!0),{logo:u,productsInfo:h,thumbPath:f,title:p,media:m,brand:g,shortsId:v}=e;return t.createElement("div",{className:"h-full w-full text-sm overflow-hidden text-white relative"},t.createElement("div",{style:{backgroundImage:"linear-gradient(to bottom, rgba(0,0,0,0.4) 0%, transparent 50%, rgba(0,0,0,0.4) 100%)",padding:"15px"},className:"absolute h-full flex flex-col w-full z-[1] justify-between inset-0 bg-gradient-to-b from-black/40 via-transparent to-black/40"},t.createElement("div",{className:"flex gap-2 justify-between "},t.createElement("div",{className:"max-w-16"},(null==u?void 0:u.thumbPath)?t.createElement("img",{className:"mb-1",src:u.thumbPath,alt:u.logoName,width:100,height:100}):null),t.createElement("div",{className:"justify-self-end flex gap-2"},t.createElement("div",{className:"cursor-pointer text-white ",onClick:()=>{c(e=>!e)}},d?t.createElement(Wt,{size:20}):t.createElement(Yt,{size:20})),t.createElement("div",{className:"cursor-pointer text-white ",onClick:()=>{l(e=>!e)}},o?t.createElement(Xt,{size:20}):t.createElement(qt,{size:20})),t.createElement("div",{className:"cursor-pointer text-white ",onClick:s},t.createElement(Qt,{size:20})))),t.createElement("div",null,t.createElement("div",{className:"flex justify-between items-end mb-3 gap-3"},t.createElement("div",{className:"w-full"},g&&t.createElement("div",{className:"items-center flex gap-3 mb-2"},t.createElement("div",{className:"w-12 h-12 bg-white rounded-full border overflow-hidden"},t.createElement("img",{src:g.thumbPath,alt:g.brandName,width:100,height:100,className:"object-contain w-full h-full"})),t.createElement("p",{style:{fontSize:"14px",textAlign:"start"}},null==g?void 0:g.brandName)),t.createElement("p",{style:{fontSize:"14px",textAlign:"start"}},p)),t.createElement("div",{className:"flex flex-col items-center",style:{gap:"15px"}},t.createElement(la,{shortsId:v}),t.createElement("div",{className:"w-[24px] h-[24px] flex items-center justify-center"},t.createElement(va,{shortForm:e,shareUrl:n})))),h&&t.createElement(Pd,{products:h,useDrawer:r,contentId:e.shortsId}))),t.createElement(L,{file:Tt(null==m?void 0:m.objectId),thumbnail:`${Rt(f)}`,mute:o,isVertical:(null==m?void 0:m.height)>(null==m?void 0:m.width),play:d}))},Cd=({collection:e,playerSettings:r})=>{const[i,n]=a(e.contents[0]);return t.createElement("div",{className:"w-full h-full aspect-[9/16]"},t.createElement(ds,{modules:[us,Es],loop:!0,mousewheel:!0,direction:"vertical",touchEventsTarget:"container",slidesPerView:1,onSlideChangeTransitionEnd:t=>{const r=e.contents[t.realIndex];n(Object.assign({},r))},className:"h-full"},e.contents.map(e=>t.createElement(cs,{key:e.shortsId,className:"rounded-xl overflow-hidden"},i.shortsId===e.shortsId&&t.createElement("div",{className:"h-full rounded-xl absolute z-[999] w-full"},t.createElement(Dd,{shortForm:i,isPopup:!0})),t.createElement("img",{src:Rt(e.thumbPath),alt:e.title,className:"rounded-xl w-full h-full bg-black "+(e.media.width>e.media.height?"object-contain":"object-cover")})))))},_d=e=>{const{isMobile:r}=e,[i,n]=a("collection"in e?e.collection.contents[0]:null);if(r){if("shortform"in e)return t.createElement(Dd,{shortForm:e.shortform});if(e.collection)return t.createElement(Cd,{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 _t.PLATFORM:return t.createElement(ji,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"aspect-[9/16] h-full rounded-xl border overflow-hidden"},t.createElement(L,{file:Tt(e.shortform.media.objectId)}))});case _t.HORIZONTAL:return t.createElement(Ls,{shortform:e.shortform,playerSettings:i,player:t.createElement(L,{file:Tt(e.shortform.media.objectId)})});case _t.VERTICAL:return t.createElement(Rs,{shortform:e.shortform,playerSettings:i,player:t.createElement("div",{className:"aspect-[9/16] h-full"},t.createElement(L,{file:Tt(e.shortform.media.objectId)}))});case _t.GRID:return t.createElement(Ds,{shortform:e.shortform,playerSettings:i,player:t.createElement(L,{file:Tt(e.shortform.media.objectId)})})}}else{if(!e.collection||!i)return null;{const{layout:r}=e.collection.player,s=e.collection.player.shoppingPlayer;switch(r){case _t.PLATFORM:return t.createElement(ji,{shortform:i,playerSettings:s,player:t.createElement("div",{className:"w-full flex items-center justify-center gap-4",style:{height:"calc(-220px + 100vh)"}},t.createElement(sa,{collection:e.collection,playerSettings:s,shortform:i,setShortform:n}))});case _t.HORIZONTAL:return t.createElement(Ls,{shortform:i,playerSettings:Object.assign({},s),player:t.createElement("div",{className:"h-full aspect-[9/16]"},t.createElement(aa,{collection:e.collection,playerSettings:s,shortform:i,setShortform:n}))});case _t.VERTICAL:return t.createElement(Rs,{playerSettings:Object.assign({},s),shortform:i,player:t.createElement(aa,{collection:e.collection,playerSettings:s,shortform:i,setShortform:n})});case _t.GRID:return t.createElement(Ds,{shortform:i,playerSettings:Object.assign({},s),player:t.createElement(aa,{collection:e.collection,playerSettings:s,shortform:i,setShortform:n})})}}}},Od=e=>t.createElement(Dd,Object.assign({},e));function Md(){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 Nd=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(${Rt(e.thumbPath)})`}},t.createElement(Dd,{handleClose:i,shortForm:e,useDrawer:!1,isPopup:!0,shareUrl:r})))),Fd=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}`})`}})),$d=({shortform:e,shareUrl:r,handleClose:i})=>{const{isActive:n}=d(os),s=d(ls),a=Md().width<430||ma.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(${n?1:.8})`,transition:"transform 180ms ease"}},n?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(),s.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(zt,{size:28})),t.createElement(Nd,{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(),s.slideNext()}},t.createElement(Gt,{size:28}))):t.createElement(Fd,{shortform:e})))},{PLAYER_BACK_BASE_URL:Bd}=gt(),Ud=({collection:e,initialShortsId:i,onSlideChange:n,onClosePlayer:s})=>{var a;const o=u(()=>Math.max(e.contents.findIndex(e=>e.shortsId===i),0),[e.contents,i]),l=e.contents.length,d=Math.max(l,10),c=null!==(a=Md().width)&&void 0!==a?a:0,h=c<430||ma.isMobile,f=h?1:c>=1200?4:c>=900?3:2,p=u(()=>(e=>{const t=[...e];for(;t.length<d;)t.push(...e);return t})(e.contents),[e.contents]),m=r(null);return t.createElement("div",{style:{minHeight:100,minWidth:300},className:"w-full"},t.createElement(ds,{style:{minHeight:100,overflow:"visible"},initialSlide:o,ref:m,lazyPreloadPrevNext:2,className:"w-full",spaceBetween:h?8:c>=1200?24:c>=900?25:16,slidesPerView:f,grabCursor:!0,centeredSlides:1!==f,onSlideChangeTransitionEnd:t=>{const r=t.realIndex%l;null==n||n(r);const i=e.contents[(r+1)%l];var s;s=Tt(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!==s&&(A.src=s,A.load(),k=s)},loop:!0,slideToClickedSlide:!0},p.map((r,i)=>t.createElement(cs,{key:i},t.createElement($d,{handleClose:s,shortform:r,shareUrl:`${Bd}/collection/${e.colId}?start=${r.shortsId}&layout=5`})))))},zd=({shortform:e,onThumbnailClick:r,iconSize:i,exposeTitle:n,borderLine:s})=>{const a=u(()=>It(s),[s])?{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:Rt(e.thumbPath),alt:"thumbnail",className:"w-full h-full object-cover block rounded-full"})),n&&t.createElement("span",{style:{width:i},className:"text-black overflow-hidden text-[12px] whitespace-nowrap text-center text-clip cursor-default"},e.title))},Gd=Js(e=>({open:!1,setOpen:t=>e({open:t})})),jd=({product:e,productLength:r,hideMoreBadge:i=!1,contentId:n,lineClamp:s,showMoreBtn:a=!1,openProductPopup:o})=>{const{isPreview:l}=ea();return t.createElement(t.Fragment,null,t.createElement("div",{className:"product-banner border mbus-border",onClick:()=>x(void 0,void 0,void 0,function*(){i&&(window.open(e.linkPath,"_blank"),l||(yield Gs({contentProductId:e.eventProductId,contentId:n,productId:e.productId})))})},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:Rt(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:s||2,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word",fontWeight:600,color:"#494949"}},e.productName)),t.createElement("span",{className:"product-banner__arrow","aria-hidden":!0},"›")),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,")"))},Hd=({products:e,iconSize:r,contentId:i,setSelectedProducts:n,showMoreBtn:s,hideMoreBadge:a})=>{const{setOpen:o}=Gd(),l=()=>{n({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||s||l()}),className:"flex flex-col gap-2 mt-4 text-gray-800",style:{maxWidth:r||"100%",fontSize:13}},t.createElement(jd,{showMoreBtn:s,lineClamp:2,product:e[0],contentId:i,productLength:e.length,hideMoreBadge:null!=a?a:1===e.length,openProductPopup:l})))},Vd=({product:e,maxWidth:r="100%",height:i,cardWidth:n})=>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:Rt(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}},"number"==typeof e.sellingPrice&&e.sellingPrice<e.price?"number"==typeof n&&n>=190?t.createElement(t.Fragment,null,t.createElement("span",{style:{color:"#dc2626",fontWeight:600,marginRight:4}},St(e.sellingPrice),"원"),t.createElement("span",{style:{color:"#9ca3af",textDecoration:"line-through"}},St(e.price),"원")):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},St(e.sellingPrice),"원"):t.createElement("span",{style:{color:"#dc2626",fontWeight:600}},St(e.price),"원")))),Wd=({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"})),Yd=({shortform:e,onThumbnailClick:r,iconSize:i,exposeTitle:n,rounded:s,borderLine:o,titlePosition:l,exposeProductBanner:d,setSelectedProducts:c,iconRatio:h,hoverPlay:f,exposeProductBadge:p})=>{var m;const g=u(()=>It(o),[o]),[v,y]=a(!1),{API_BASE_URL:b}=gt();return t.createElement("div",{className:"relative"},t.createElement("div",{onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),onClick:()=>r(e.shortsId),style:Object.assign({width:i,aspectRatio:h},s&&{borderRadius:"10px"}),className:`cursor-pointer p-[3px] ${s&&"rounded-xl"} ${g&&"bg-insta"} relative overflow-hidden`},v&&f&&t.createElement(Wd,{playUrl:`${b}/direct/${e.media.objectId}`,poster:Rt(e.thumbPath)}),t.createElement("img",{style:Object.assign({},s&&{borderRadius:"10px"}),src:Rt(e.thumbPath),alt:"thumbnail",className:`w-full h-full object-cover ${s&&"rounded-xl"}`}),p&&(null===(m=e.productsInfo)||void 0===m?void 0:m.length)>0&&!(f&&v)&&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(Vd,{product:e.productsInfo[0],maxWidth:"100%",height:"100%",cardWidth:i})))),n&&!(f&&v&&l===Be.INNER)&&t.createElement("p",{style:Object.assign({width:i,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},l===Be.INNER&&p?{bottom:"22%"}:{}),className:`my-2 ${l===Be.INNER?"absolute bottom-0 left-0 text-white px-2 z-10":""} text-[12px] cursor-default truncate`},e.title),d&&t.createElement(Hd,{setSelectedProducts:c,products:e.productsInfo,iconSize:i,contentId:e.shortsId}))},Kd=e=>{const{iconShape:r,collection:i}=e;return r===Ne.MANY?t.createElement(qd,Object.assign({},e)):t.createElement(Xd,Object.assign({},e,{shortform:i.contents[0]}))},qd=e=>{const{collection:r}=e,{thumbnailAutoPlay:i}=e,{setCollection:n,nextKey:s,setNextKey:a,isFetching:o,setIsFetching:l}=ia();return t.createElement(ds,{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 Vs({collectionId:r.colId,nextKey:s});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;n(Object.assign(Object.assign({},r),{contents:[...r.contents,...l]}))}catch(e){console.error(e)}finally{l(!1)}}}),modules:i?[fs]:[],autoplay:!!i&&{delay:3e3,disableOnInteraction:!1,pauseOnMouseEnter:!0},loop:i||void 0},null==r?void 0:r.contents.map(r=>t.createElement(cs,{key:r.shortsId,className:"!w-auto"},t.createElement(Xd,Object.assign({},e,{shortform:r})))))},Xd=e=>{const{iconForm:r}=e;return r===Me.INSTA?t.createElement(zd,Object.assign({},e)):t.createElement(Yd,Object.assign({},e))};function Qd(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function Zd(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Jd(...e){return t=>{let r=!1;const i=e.map(e=>{const i=Zd(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():Zd(e[t],null)}}}}function ec(...t){return e.useCallback(Jd(...t),t)}function tc(...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 n=i.reduce((e,{useScope:r,scopeName:i})=>({...e,...r(t)[`__scope${i}`]}),{});return e.useMemo(()=>({[`__scope${r.scopeName}`]:n}),[n])}};return i.scopeName=r.scopeName,i}var rc=globalThis?.document?e.useLayoutEffect:()=>{},ic=e[" useId ".trim().toString()]||(()=>{}),nc=0;function sc(t){const[r,i]=e.useState(ic());return rc(()=>{t||i(e=>e??String(nc++))},[t]),t||(r?`radix-${r}`:"")}var ac=e[" useInsertionEffect ".trim().toString()]||rc;function oc({prop:t,defaultProp:r,onChange:i=()=>{},caller:n}){const[s,a,o]=function({defaultProp:t,onChange:r}){const[i,n]=e.useState(t),s=e.useRef(i),a=e.useRef(r);return ac(()=>{a.current=r},[r]),e.useEffect(()=>{s.current!==i&&(a.current?.(i),s.current=i)},[i,s]),[i,n,a]}({defaultProp:r,onChange:i}),l=void 0!==t,d=l?t:s;{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(`${n} 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,n])}const c=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[d,c]}function lc(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e?.(i),!1===r||!i.defaultPrevented)return t?.(i)}}function dc(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function cc(...e){return t=>{let r=!1;const i=e.map(e=>{const i=dc(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():dc(e[t],null)}}}}function uc(...t){return e.useCallback(cc(...t),t)}function hc(t){const r=e.forwardRef((t,r)=>{const{children:i,...n}=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),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{const t=s(...e);return n(...e),t}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?cc(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}var fc=Symbol("radix.slottable");function pc(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===fc}var mc=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=function(t){const r=hc(t),i=e.forwardRef((t,i)=>{const{children:n,...s}=t,a=e.Children.toArray(n),o=a.find(pc);if(o){const t=o.props.children,n=a.map(r=>r===o?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return p(r,{...s,ref:i,children:e.isValidElement(t)?e.cloneElement(t,void 0,n):null})}return p(r,{...s,ref:i,children:n})});return i.displayName=`${t}.Slot`,i}(`Primitive.${r}`),n=e.forwardRef((e,t)=>{const{asChild:n,...s}=e,a=n?i:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),p(a,{...s,ref:t})});return n.displayName=`Primitive.${r}`,{...t,[r]:n}},{});var gc,vc="dismissableLayer.update",yc="dismissableLayer.pointerDownOutside",bc="dismissableLayer.focusOutside",Ec=e.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),wc=e.forwardRef((t,r)=>{const{disableOutsidePointerEvents:i=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:o,onDismiss:l,...d}=t,c=e.useContext(Ec),[u,h]=e.useState(null),f=u?.ownerDocument??globalThis?.document,[,m]=e.useState({}),g=uc(r,e=>h(e)),v=Array.from(c.layers),[y]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),b=v.indexOf(y),E=u?v.indexOf(u):-1,w=c.layersWithOutsidePointerEventsDisabled.size>0,S=E>=b,T=function(t,r=globalThis?.document){const i=Ma(t),n=e.useRef(!1),s=e.useRef(()=>{});return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){let t=function(){Tc(yc,i,n,{discrete:!0})};const n={originalEvent:e};"touch"===e.pointerType?(r.removeEventListener("click",s.current),s.current=t,r.addEventListener("click",s.current,{once:!0})):t()}else r.removeEventListener("click",s.current);n.current=!1},t=window.setTimeout(()=>{r.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),r.removeEventListener("pointerdown",e),r.removeEventListener("click",s.current)}},[r,i]),{onPointerDownCapture:()=>n.current=!0}}(e=>{const t=e.target,r=[...c.branches].some(e=>e.contains(t));S&&!r&&(s?.(e),o?.(e),e.defaultPrevented||l?.())},f),x=function(t,r=globalThis?.document){const i=Ma(t),n=e.useRef(!1);return e.useEffect(()=>{const e=e=>{if(e.target&&!n.current){Tc(bc,i,{originalEvent:e},{discrete:!1})}};return r.addEventListener("focusin",e),()=>r.removeEventListener("focusin",e)},[r,i]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}(e=>{const t=e.target;[...c.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||l?.())},f);return Na(e=>{E===c.layers.size-1&&(n?.(e),!e.defaultPrevented&&l&&(e.preventDefault(),l()))},f),e.useEffect(()=>{if(u)return i&&(0===c.layersWithOutsidePointerEventsDisabled.size&&(gc=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),Sc(),()=>{i&&1===c.layersWithOutsidePointerEventsDisabled.size&&(f.body.style.pointerEvents=gc)}},[u,f,i,c]),e.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),Sc())},[u,c]),e.useEffect(()=>{const e=()=>m({});return document.addEventListener(vc,e),()=>document.removeEventListener(vc,e)},[]),p(mc.div,{...d,ref:g,style:{pointerEvents:w?S?"auto":"none":void 0,...t.style},onFocusCapture:lc(t.onFocusCapture,x.onFocusCapture),onBlurCapture:lc(t.onBlurCapture,x.onBlurCapture),onPointerDownCapture:lc(t.onPointerDownCapture,T.onPointerDownCapture)})});wc.displayName="DismissableLayer";function Sc(){const e=new CustomEvent(vc);document.dispatchEvent(e)}function Tc(e,t,r,{discrete:i}){const n=r.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),i?function(e,t){e&&v.flushSync(()=>e.dispatchEvent(t))}(n,s):n.dispatchEvent(s)}e.forwardRef((t,r)=>{const i=e.useContext(Ec),n=e.useRef(null),s=uc(r,n);return e.useEffect(()=>{const e=n.current;if(e)return i.branches.add(e),()=>{i.branches.delete(e)}},[i.branches]),p(mc.div,{...t,ref:s})}).displayName="DismissableLayerBranch";var xc=t=>{const{present:r,children:i}=t,n=function(t){const[r,i]=e.useState(),n=e.useRef(null),s=e.useRef(t),a=e.useRef("none"),o=t?"mounted":"unmounted",[l,d]=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=Ac(n.current);a.current="mounted"===l?e:"none"},[l]),rc(()=>{const e=n.current,r=s.current;if(r!==t){const i=a.current,n=Ac(e);if(t)d("MOUNT");else if("none"===n||"none"===e?.display)d("UNMOUNT");else{d(r&&i!==n?"ANIMATION_OUT":"UNMOUNT")}s.current=t}},[t,d]),rc(()=>{if(r){let e;const t=r.ownerDocument.defaultView??window,i=i=>{const a=Ac(n.current).includes(i.animationName);if(i.target===r&&a&&(d("ANIMATION_END"),!s.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=Ac(n.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)}}d("ANIMATION_END")},[r,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:e.useCallback(e=>{n.current=e?getComputedStyle(e):null,i(e)},[])}}(r),s="function"==typeof i?i({present:n.isPresent}):e.Children.only(i),a=ec(n.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}(s));return"function"==typeof i||n.isPresent?e.cloneElement(s,{ref:a}):null};function Ac(e){return e?.animationName||"none"}function kc(t){const r=Lc(t),i=e.forwardRef((t,i)=>{const{children:n,...s}=t,a=e.Children.toArray(n),o=a.find(Rc);if(o){const t=o.props.children,n=a.map(r=>r===o?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:r);return p(r,{...s,ref:i,children:e.isValidElement(t)?e.cloneElement(t,void 0,n):null})}return p(r,{...s,ref:i,children:n})});return i.displayName=`${t}.Slot`,i}function Lc(t){const r=e.forwardRef((t,r)=>{const{children:i,...n}=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),s=function(e,t){const r={...t};for(const i in t){const n=e[i],s=t[i];/^on[A-Z]/.test(i)?n&&s?r[i]=(...e)=>{const t=s(...e);return n(...e),t}:n&&(r[i]=n):"style"===i?r[i]={...n,...s}:"className"===i&&(r[i]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}(n,i.props);return i.type!==e.Fragment&&(s.ref=r?Jd(r,t):t),e.cloneElement(i,s)}return e.Children.count(i)>1?e.Children.only(null):null});return r.displayName=`${t}.SlotClone`,r}xc.displayName="Presence";var Ic=Symbol("radix.slottable");function Rc(t){return e.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===Ic}var Pc=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,r)=>{const i=kc(`Primitive.${r}`),n=e.forwardRef((e,t)=>{const{asChild:n,...s}=e,a=n?i:r;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),p(a,{...s,ref:t})});return n.displayName=`Primitive.${r}`,{...t,[r]:n}},{}),Dc=0;function Cc(){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 _c="Dialog",[Oc,Mc]=function(t,r=[]){let i=[];const n=()=>{const r=i.map(t=>e.createContext(t));return function(i){const n=i?.[t]||r;return e.useMemo(()=>({[`__scope${t}`]:{...i,[t]:n}}),[i,n])}};return n.scopeName=t,[function(r,n){const s=e.createContext(n),a=i.length;i=[...i,n];const o=r=>{const{scope:i,children:n,...o}=r,l=i?.[t]?.[a]||s,d=e.useMemo(()=>o,Object.values(o));return p(l.Provider,{value:d,children:n})};return o.displayName=r+"Provider",[o,function(i,o){const l=o?.[t]?.[a]||s,d=e.useContext(l);if(d)return d;if(void 0!==n)return n;throw new Error(`\`${i}\` must be used within \`${r}\``)}]},tc(n,...r)]}(_c),[Nc,Fc]=Oc(_c),$c=t=>{const{__scopeDialog:r,children:i,open:n,defaultOpen:s,onOpenChange:a,modal:o=!0}=t,l=e.useRef(null),d=e.useRef(null),[c,u]=oc({prop:n,defaultProp:s??!1,onChange:a,caller:_c});return p(Nc,{scope:r,triggerRef:l,contentRef:d,contentId:sc(),titleId:sc(),descriptionId:sc(),open:c,onOpenChange:u,onOpenToggle:e.useCallback(()=>u(e=>!e),[u]),modal:o,children:i})};$c.displayName=_c;var Bc="DialogTrigger";e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Fc(Bc,r),s=ec(t,n.triggerRef);return p(Pc.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":su(n.open),...i,ref:s,onClick:Qd(e.onClick,n.onOpenToggle)})}).displayName=Bc;var Uc="DialogPortal",[zc,Gc]=Oc(Uc,{forceMount:void 0}),jc=t=>{const{__scopeDialog:r,forceMount:i,children:n,container:s}=t,a=Fc(Uc,r);return p(zc,{scope:r,forceMount:i,children:e.Children.map(n,e=>p(xc,{present:i||a.open,children:p(to,{asChild:!0,container:s,children:e})}))})};jc.displayName=Uc;var Hc="DialogOverlay",Vc=e.forwardRef((e,t)=>{const r=Gc(Hc,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=Fc(Hc,e.__scopeDialog);return s.modal?p(xc,{present:i||s.open,children:p(Yc,{...n,ref:t})}):null});Vc.displayName=Hc;var Wc=kc("DialogOverlay.RemoveScroll"),Yc=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Fc(Hc,r);return p(Vo,{as:Wc,allowPinchZoom:!0,shards:[n.contentRef],children:p(Pc.div,{"data-state":su(n.open),...i,ref:t,style:{pointerEvents:"auto",...i.style}})})}),Kc="DialogContent",qc=e.forwardRef((e,t)=>{const r=Gc(Kc,e.__scopeDialog),{forceMount:i=r.forceMount,...n}=e,s=Fc(Kc,e.__scopeDialog);return p(xc,{present:i||s.open,children:s.modal?p(Xc,{...n,ref:t}):p(Qc,{...n,ref:t})})});qc.displayName=Kc;var Xc=e.forwardRef((t,r)=>{const i=Fc(Kc,t.__scopeDialog),n=e.useRef(null),s=ec(r,i.contentRef,n);return e.useEffect(()=>{const e=n.current;if(e)return Zo(e)},[]),p(Zc,{...t,ref:s,trapFocus:i.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Qd(t.onCloseAutoFocus,e=>{e.preventDefault(),i.triggerRef.current?.focus()}),onPointerDownOutside:Qd(t.onPointerDownOutside,e=>{const t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;(2===t.button||r)&&e.preventDefault()}),onFocusOutside:Qd(t.onFocusOutside,e=>e.preventDefault())})}),Qc=e.forwardRef((t,r)=>{const i=Fc(Kc,t.__scopeDialog),n=e.useRef(!1),s=e.useRef(!1);return p(Zc,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:e=>{t.onCloseAutoFocus?.(e),e.defaultPrevented||(n.current||i.triggerRef.current?.focus(),e.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:e=>{t.onInteractOutside?.(e),e.defaultPrevented||(n.current=!0,"pointerdown"===e.detail.originalEvent.type&&(s.current=!0));const r=e.target,a=i.triggerRef.current?.contains(r);a&&e.preventDefault(),"focusin"===e.detail.originalEvent.type&&s.current&&e.preventDefault()}})}),Zc=e.forwardRef((t,r)=>{const{__scopeDialog:i,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:a,...o}=t,l=Fc(Kc,i),d=e.useRef(null),c=ec(r,d);return e.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Cc()),document.body.insertAdjacentElement("beforeend",e[1]??Cc()),Dc++,()=>{1===Dc&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Dc--}},[]),g(m,{children:[p(Ka,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:a,children:p(wc,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":su(l.open),...o,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),g(m,{children:[p(du,{titleId:l.titleId}),p(cu,{contentRef:d,descriptionId:l.descriptionId})]})]})}),Jc="DialogTitle",eu=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Fc(Jc,r);return p(Pc.h2,{id:n.titleId,...i,ref:t})});eu.displayName=Jc;var tu="DialogDescription",ru=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Fc(tu,r);return p(Pc.p,{id:n.descriptionId,...i,ref:t})});ru.displayName=tu;var iu="DialogClose",nu=e.forwardRef((e,t)=>{const{__scopeDialog:r,...i}=e,n=Fc(iu,r);return p(Pc.button,{type:"button",...i,ref:t,onClick:Qd(e.onClick,()=>n.onOpenChange(!1))})});function su(e){return e?"open":"closed"}nu.displayName=iu;var au="DialogTitleWarning",[ou,lu]=function(t,r){const i=e.createContext(r),n=t=>{const{children:r,...n}=t,s=e.useMemo(()=>n,Object.values(n));return p(i.Provider,{value:s,children:r})};return n.displayName=t+"Provider",[n,function(n){const s=e.useContext(i);if(s)return s;if(void 0!==r)return r;throw new Error(`\`${n}\` must be used within \`${t}\``)}]}(au,{contentName:Kc,titleName:Jc,docsSlug:"dialog"}),du=({titleId:t})=>{const r=lu(au),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},cu=({contentRef:t,descriptionId:r})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${lu("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},uu=$c,hu=jc,fu=Vc,pu=qc,mu=eu,gu=nu;function vu(t){return e.createElement(uu,Object.assign({"data-slot":"dialog"},t))}function yu(t){var r=T(t,[]);return e.createElement(hu,Object.assign({"data-slot":"dialog-portal"},r))}function bu(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(fu,Object.assign({"data-slot":"dialog-overlay",className:wt("fixed inset-0 z-50 bg-black/50",r)},i))}function Eu(t){var{className:r,children:i,showCloseButton:n=!0,container:s}=t,a=T(t,["className","children","showCloseButton","container"]);return e.createElement(yu,{"data-slot":"dialog-portal",container:s},e.createElement(bu,null),e.createElement(pu,Object.assign({"data-slot":"dialog-content",style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",outline:"none"},className:wt("fixed","z-50 grid w-full max-w-lg sm:mx-0 gap-4 p-6",r)},a),i,n&&e.createElement(gu,{"data-slot":"dialog-close",style:{right:"calc(var(--spacing) * 4)",top:"calc(var(--spacing) * 4)",outline:"none"},className:wt("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(Qt,{className:"h-4 w-4 pointer-events-none shrink-0",style:{height:"calc(var(--spacing) * 4)",width:"calc(var(--spacing) * 4)"}}))))}function wu(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({"data-slot":"dialog-header",className:wt("flex flex-col gap-2 text-left",r)},i))}function Su(t){var{className:r}=t,i=T(t,["className"]);return e.createElement(mu,Object.assign({"data-slot":"dialog-title",className:wt("text-lg leading-none font-semibold",r)},i))}function Tu({title:e,children:r,contentClassName:i,hideCloseButton:n=!1,portalContainer:s,description:a}){const{open:o,setOpen:l}=Gd();return t.createElement(vu,{open:o,onOpenChange:l},t.createElement(Eu,{container:s,className:i,showCloseButton:!n},e&&t.createElement(wu,null,t.createElement(Su,{style:{color:"#494949"}},e||""),t.createElement(ru,{style:{color:"#5e5e5e",fontSize:"12.5px"}},a||"")),r))}const xu=({products:e,contentId:r})=>{const i=Md().width<430||ma.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(jd,{key:i.productId,product:i,hideMoreBadge:!0,productLength:e.length,contentId:r})))},{PLAYER_BACK_BASE_URL:Au}=gt(),ku=({widgetPlayerOption:e,setCollectionUuid:r,portalContainer:n})=>{const{player:s}=e,[o,l]=a(null),{collection:d}=ia(),{isPreview:c}=ea(),{onSlideChange:u,onCollectionClose:h}=na(o,l),{setOpen:f,open:p}=Gd();i(()=>{p||(o&&(h(),l(null)),m&&g(null))},[p]);const[m,g]=a();return t.createElement(t.Fragment,null,d&&t.createElement(Kd,Object.assign({collection:d},e,{onThumbnailClick:e=>x(void 0,void 0,void 0,function*(){if(s===$e.POPUP){const t=kt(),i=kt();if(r(i),l(Object.assign(Object.assign({},d.contents.find(t=>t.shortsId===e)),{uuid:t})),f(!0),c)return;yield Promise.all([Us({contentId:d.colId,uuid:i,type:Et.COLLECTION,userId:d.userId,isFirstPlay:!Lt(d.colId)}),Us({contentId:e,uuid:t,type:Et.SHORTS,userId:d.userId,isFirstPlay:!Lt(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}})(s),r=null==d?void 0:d.contents.findIndex(t=>t.shortsId===e);let i="";r&&r>1&&(i=(null==d?void 0:d.contents[r-1].shortsId)||""),open(`${Au}/collection/${d.colId}?nextKey=${i}&layout=${t}`)}}),setSelectedProducts:g})),m&&t.createElement(Tu,{portalContainer:n,title:"상품 목록",contentClassName:"bg-white rounded p-4 product-dialog-container",description:"상품 정보를 확인해 보세요"},t.createElement(xu,{products:m.productsInfo,contentId:m.shortsId})),d&&o&&t.createElement(Tu,{portalContainer:n,hideCloseButton:!0,contentClassName:"w-full max-w-none p-0 mx-0"},t.createElement(Ud,{collection:d,initialShortsId:o.shortsId,onClosePlayer:()=>x(void 0,void 0,void 0,function*(){h(),f(!1)}),onSlideChange:u})))};var Lu,Iu={exports:{}},Ru={exports:{}},Pu={};var Du,Cu,_u,Ou,Mu,Nu,Fu,$u,Bu,Uu,zu,Gu,ju,Hu,Vu,Wu={};
28
28
  /** @license React v16.13.1
29
29
  * react-is.development.js
30
30
  *
@@ -37,4 +37,4 @@ var Ft={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24
37
37
  object-assign
38
38
  (c) Sindre Sorhus
39
39
  @license MIT
40
- */function Ku(){if(Ou)return _u;Ou=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;return _u=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach(function(e){i[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(e){return!1}}()?Object.assign:function(i,n){for(var s,a,o=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(i),l=1;l<arguments.length;l++){for(var d in s=Object(arguments[l]))t.call(s,d)&&(o[d]=s[d]);if(e){a=e(s);for(var c=0;c<a.length;c++)r.call(s,a[c])&&(o[a[c]]=s[a[c]])}}return o},_u}function qu(){if(Nu)return Mu;Nu=1;return Mu="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}function Xu(){return $u?Fu:($u=1,Fu=Function.call.bind(Object.prototype.hasOwnProperty))}function Qu(){if(Uu)return Bu;Uu=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=qu(),r={},i=Xu();e=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function n(n,s,a,o,l){if("production"!==process.env.NODE_ENV)for(var d in n)if(i(n,d)){var c;try{if("function"!=typeof n[d]){var u=Error((o||"React class")+": "+a+" type `"+d+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[d]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw u.name="Invariant Violation",u}c=n[d](s,d,o,a,null,t)}catch(e){c=e}if(!c||c instanceof Error||e((o||"React class")+": type specification of "+a+" `"+d+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof c+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),c instanceof Error&&!(c.message in r)){r[c.message]=!0;var h=l?l():"";e("Failed "+a+" type: "+c.message+(null!=h?h:""))}}}return n.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(r={})},Bu=n}function Zu(){if(Gu)return zu;Gu=1;var e=Yu(),t=Ku(),r=qu(),i=Xu(),n=Qu(),s=function(){};function a(){return null}return"production"!==process.env.NODE_ENV&&(s=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),zu=function(o,l){var d="function"==typeof Symbol&&Symbol.iterator;var c="<<anonymous>>",u={array:m("array"),bigint:m("bigint"),bool:m("boolean"),func:m("function"),number:m("number"),object:m("object"),string:m("string"),symbol:m("symbol"),any:p(a),arrayOf:function(e){return p(function(t,i,n,s,a){if("function"!=typeof e)return new f("Property `"+a+"` of component `"+n+"` has invalid PropType notation inside arrayOf.");var o=t[i];if(!Array.isArray(o))return new f("Invalid "+s+" `"+a+"` of type `"+y(o)+"` supplied to `"+n+"`, expected an array.");for(var l=0;l<o.length;l++){var d=e(o,l,n,s,a+"["+l+"]",r);if(d instanceof Error)return d}return null})},element:p(function(e,t,r,i,n){var s=e[t];return o(s)?null:new f("Invalid "+i+" `"+n+"` of type `"+y(s)+"` supplied to `"+r+"`, expected a single ReactElement.")}),elementType:p(function(t,r,i,n,s){var a=t[r];return e.isValidElementType(a)?null:new f("Invalid "+n+" `"+s+"` of type `"+y(a)+"` supplied to `"+i+"`, expected a single ReactElement type.")}),instanceOf:function(e){return p(function(t,r,i,n,s){if(!(t[r]instanceof e)){var a=e.name||c;return new f("Invalid "+n+" `"+s+"` of type `"+(((o=t[r]).constructor&&o.constructor.name?o.constructor.name:c)+"` supplied to `")+i+"`, expected instance of `"+a+"`.")}var o;return null})},node:p(function(e,t,r,i,n){return v(e[t])?null:new f("Invalid "+i+" `"+n+"` supplied to `"+r+"`, expected a ReactNode.")}),objectOf:function(e){return p(function(t,n,s,a,o){if("function"!=typeof e)return new f("Property `"+o+"` of component `"+s+"` has invalid PropType notation inside objectOf.");var l=t[n],d=y(l);if("object"!==d)return new f("Invalid "+a+" `"+o+"` of type `"+d+"` supplied to `"+s+"`, expected an object.");for(var c in l)if(i(l,c)){var u=e(l,c,s,a,o+"."+c,r);if(u instanceof Error)return u}return null})},oneOf:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&s(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),a;return p(function(t,r,i,n,s){for(var a=t[r],o=0;o<e.length;o++)if(h(a,e[o]))return null;var l=JSON.stringify(e,function(e,t){return"symbol"===b(t)?String(t):t});return new f("Invalid "+n+" `"+s+"` of value `"+String(a)+"` supplied to `"+i+"`, expected one of "+l+".")})},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&s("Invalid argument supplied to oneOfType, expected an instance of array."),a;for(var t=0;t<e.length;t++){var n=e[t];if("function"!=typeof n)return s("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+E(n)+" at index "+t+"."),a}return p(function(t,n,s,a,o){for(var l=[],d=0;d<e.length;d++){var c=(0,e[d])(t,n,s,a,o,r);if(null==c)return null;c.data&&i(c.data,"expectedType")&&l.push(c.data.expectedType)}return new f("Invalid "+a+" `"+o+"` supplied to `"+s+"`"+(l.length>0?", expected one of type ["+l.join(", ")+"]":"")+".")})},shape:function(e){return p(function(t,i,n,s,a){var o=t[i],l=y(o);if("object"!==l)return new f("Invalid "+s+" `"+a+"` of type `"+l+"` supplied to `"+n+"`, expected `object`.");for(var d in e){var c=e[d];if("function"!=typeof c)return g(n,s,a,d,b(c));var u=c(o,d,n,s,a+"."+d,r);if(u)return u}return null})},exact:function(e){return p(function(n,s,a,o,l){var d=n[s],c=y(d);if("object"!==c)return new f("Invalid "+o+" `"+l+"` of type `"+c+"` supplied to `"+a+"`, expected `object`.");var u=t({},n[s],e);for(var h in u){var p=e[h];if(i(e,h)&&"function"!=typeof p)return g(a,o,l,h,b(p));if(!p)return new f("Invalid "+o+" `"+l+"` key `"+h+"` supplied to `"+a+"`.\nBad object: "+JSON.stringify(n[s],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var m=p(d,h,a,o,l+"."+h,r);if(m)return m}return null})}};function h(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function f(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function p(e){if("production"!==process.env.NODE_ENV)var t={},i=0;function n(n,a,o,d,u,h,p){if(d=d||c,h=h||o,p!==r){if(l){var m=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw m.name="Invariant Violation",m}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var g=d+":"+o;!t[g]&&i<3&&(s("You are manually calling a React.PropTypes validation function for the `"+h+"` prop on `"+d+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),t[g]=!0,i++)}}return null==a[o]?n?null===a[o]?new f("The "+u+" `"+h+"` is marked as required in `"+d+"`, but its value is `null`."):new f("The "+u+" `"+h+"` is marked as required in `"+d+"`, but its value is `undefined`."):null:e(a,o,d,u,h)}var a=n.bind(null,!1);return a.isRequired=n.bind(null,!0),a}function m(e){return p(function(t,r,i,n,s,a){var o=t[r];return y(o)!==e?new f("Invalid "+n+" `"+s+"` of type `"+b(o)+"` supplied to `"+i+"`, expected `"+e+"`.",{expectedType:e}):null})}function g(e,t,r,i,n){return new f((e||"React class")+": "+t+" type `"+r+"."+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+n+"`.")}function v(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(v);if(null===e||o(e))return!0;var t=function(e){var t=e&&(d&&e[d]||e["@@iterator"]);if("function"==typeof t)return t}(e);if(!t)return!1;var r,i=t.call(e);if(t!==e.entries){for(;!(r=i.next()).done;)if(!v(r.value))return!1}else for(;!(r=i.next()).done;){var n=r.value;if(n&&!v(n[1]))return!1}return!0;default:return!1}}function y(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function b(e){if(null==e)return""+e;var t=y(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function E(e){var t=b(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return f.prototype=Error.prototype,u.checkPropTypes=n,u.resetWarningCache=n.resetWarningCache,u.PropTypes=u,u},zu}function Ju(){if(Hu)return ju;Hu=1;var e=qu();function t(){}function r(){}return r.resetWarningCache=t,ju=function(){function i(t,r,i,n,s,a){if(a!==e){var o=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw o.name="Invariant Violation",o}}function n(){return i}i.isRequired=i;var s={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:n,element:i,elementType:i,instanceOf:n,node:i,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:r,resetWarningCache:t};return s.PropTypes=s,s}}function eh(){if(Vu)return Iu.exports;if(Vu=1,"production"!==process.env.NODE_ENV){var e=Yu();Iu.exports=Zu()(e.isElement,true)}else Iu.exports=Ju()();return Iu.exports}var th=je(eh()),rh="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ih(e,t){return e(t={exports:{}},t.exports),t.exports}var nh=ih(function(e){!function(t){var r=function(e,t,i){if(!l(t)||c(t)||u(t)||h(t)||o(t))return t;var n,s=0,a=0;if(d(t))for(n=[],a=t.length;s<a;s++)n.push(r(e,t[s],i));else for(var f in n={},t)Object.prototype.hasOwnProperty.call(t,f)&&(n[e(f,i)]=r(e,t[f],i));return n},i=function(e){return f(e)?e:(e=e.replace(/[\-_\s]+(.)?/g,function(e,t){return t?t.toUpperCase():""})).substr(0,1).toLowerCase()+e.substr(1)},n=function(e){var t=i(e);return t.substr(0,1).toUpperCase()+t.substr(1)},s=function(e,t){return function(e,t){var r=(t=t||{}).separator||"_",i=t.split||/(?=[A-Z])/;return e.split(i).join(r)}(e,t).toLowerCase()},a=Object.prototype.toString,o=function(e){return"function"==typeof e},l=function(e){return e===Object(e)},d=function(e){return"[object Array]"==a.call(e)},c=function(e){return"[object Date]"==a.call(e)},u=function(e){return"[object RegExp]"==a.call(e)},h=function(e){return"[object Boolean]"==a.call(e)},f=function(e){return(e-=0)==e},p=function(e,t){var r=t&&"process"in t?t.process:t;return"function"!=typeof r?e:function(t,i){return r(t,e,i)}},m={camelize:i,decamelize:s,pascalize:n,depascalize:s,camelizeKeys:function(e,t){return r(p(i,t),e)},decamelizeKeys:function(e,t){return r(p(s,t),e,t)},pascalizeKeys:function(e,t){return r(p(n,t),e)},depascalizeKeys:function(){return this.decamelizeKeys.apply(this,arguments)}};e.exports?e.exports=m:t.humps=m}(rh)}).decamelize,sh=function(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},ah=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],i=!0,n=!1,s=void 0;try{for(var a,o=e[Symbol.iterator]();!(i=(a=o.next()).done)&&(r.push(a.value),!t||r.length!==t);i=!0);}catch(e){n=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(n)throw s}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return sh(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?sh(e,t):void 0}}(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.")}()},oh=ih(function(e){function t(){return e.exports=t=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},t.apply(this,arguments)}e.exports=t}),lh=function(e,t){if(null==e)return{};var r,i,n=function(e,t){if(null==e)return{};var r,i,n={},s=Object.keys(e);for(i=0;i<s.length;i++)r=s[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n},dh=l(null);function ch(e){var r=e.children,i=void 0===r?"":r,n=lh(e,["children"]);return"string"!=typeof i&&(i=w(i)),t.createElement("template",oh({},n,{dangerouslySetInnerHTML:{__html:i}}))}function uh(e){var t=e.root,r=e.children;return b(void 0===r?null:r,t)}ch.propTypes={children:th.oneOfType([th.string,th.node])},uh.propTypes={root:th.object.isRequired,children:th.node};var hh=new Map;var fh=function(){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"core",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){return e.children};return new Proxy(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{get:function(l,d){var c=nh(d,{separator:"-"}),u="".concat(e,"-").concat(c);return hh.has(u)||hh.set(u,function(e){var s=n(function(n,s){var l,d,c=n.mode,u=void 0===c?"open":c,h=n.delegatesFocus,f=void 0!==h&&h,p=n.styleSheets,m=void 0===p?[]:p,g=n.ssr,v=void 0!==g&&g,y=n.children,b=lh(n,["mode","delegatesFocus","styleSheets","ssr","children"]),E=(d=r((l=s)&&l.current),i(function(){l&&(l.current=d.current)},[l]),d),w=a(null),S=ah(w,2),T=S[0],x=S[1],A="node_".concat(u).concat(f);return o(function(){if(E.current)try{if("function"==typeof s&&s(E.current),v){var e=E.current.shadowRoot;return void x(e)}var t=E.current.attachShadow({mode:u,delegatesFocus:f});m.length>0&&(t.adoptedStyleSheets=m),x(t)}catch(e){!function(e){var t=e.error,r=e.styleSheets,i=e.root;if("NotSupportedError"!==t.name)throw t;r.length>0&&(i.adoptedStyleSheets=r)}({error:e,styleSheets:m,root:T})}},[s,E,m]),t.createElement(t.Fragment,null,t.createElement(e.tag,oh({key:A,ref:E},b),(T||v)&&t.createElement(dh.Provider,{value:T},v?t.createElement(ch,{shadowroot:u,shadowrootmode:u},e.render({root:T,ssr:v,children:y})):t.createElement(uh,{root:T},e.render({root:T,ssr:v,children:y})))))});return s.propTypes={mode:th.oneOf(["open","closed"]),delegatesFocus:th.bool,styleSheets:th.arrayOf(th.instanceOf(globalThis.CSSStyleSheet)),ssr:th.bool,children:th.node},s}({tag:c,render:s})),hh.get(u)}})}();const ph='/*! 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-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-700:oklch(0.37 0.013 285.805);--color-black:#000;--color-white:#fff;--spacing:0.25rem;--container-sm:24rem;--container-lg:32rem;--text-xs:0.75rem;--text-xs--line-height:1.33333;--text-sm:0.875rem;--text-sm--line-height:1.42857;--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);--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-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-4{top:calc(var(--spacing)*4)}.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}.z-\\[999999\\]{z-index:999999}.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-10{margin-inline:calc(var(--spacing)*10)}.mx-auto{margin-inline:auto}.my-0{margin-block:calc(var(--spacing)*0)}.my-2{margin-block:calc(var(--spacing)*2)}.my-10{margin-block:calc(var(--spacing)*10)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-auto{margin-top:auto}.mr-2{margin-right:calc(var(--spacing)*2)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.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-2{height:calc(var(--spacing)*2)}.h-4{height:calc(var(--spacing)*4)}.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-\\[100px\\]{height:100px}.h-\\[125px\\]{height:125px}.h-\\[500px\\]{height:500px}.h-\\[600px\\]{height:600px}.h-auto{height:auto}.h-full{height:100%}.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%}.\\!w-auto{width:auto!important}.w-4{width:calc(var(--spacing)*4)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-16{width:calc(var(--spacing)*16)}.w-32{width:calc(var(--spacing)*32)}.w-\\[24px\\]{width:24px}.w-\\[50px\\]{width:50px}.w-\\[80\\%\\]{width:80%}.w-\\[100px\\]{width:100px}.w-\\[400px\\]{width:400px}.w-\\[500px\\]{width:500px}.w-\\[1024px\\]{width:1024px}.w-full{width:100%}.max-w-16{max-width:calc(var(--spacing)*16)}.max-w-52{max-width:calc(var(--spacing)*52)}.max-w-\\[40\\%\\]{max-width:40%}.max-w-\\[800px\\]{max-width:800px}.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-none{flex:none}.flex-shrink-0,.shrink-0{flex-shrink:0}.grow{flex-grow:1}.border-collapse{border-collapse:collapse}.translate-y-0\\.5{--tw-translate-y:calc(var(--spacing)*0.5);translate:var(--tw-translate-x) var(--tw-translate-y)}.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)}.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-baseline{align-items:baseline}.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}.justify-items-center{justify-items:center}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\\.5{gap:calc(var(--spacing)*1.5)}.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-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}.overflow-y-scroll{overflow-y:scroll}.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}.border-\\[\\#f4f3f6\\]{border-color:#f4f3f6}.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-background{background-color:var(--background)}.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-muted{background-color:var(--muted)}.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-4{padding-inline:calc(var(--spacing)*4)}.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-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-foreground{color:var(--foreground)}.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)}.line-through{text-decoration-line:line-through}.no-underline{text-decoration-line:none}.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}.group-data-\\[vaul-drawer-direction\\=bottom\\]\\/drawer-content\\:block{&:is(:where(.group\\/drawer-content)[data-vaul-drawer-direction=bottom] *){display:block}}.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\\=closed\\]\\:animate-out{&[data-state=closed]{--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial;animation-duration:.15s;animation-name:exit}}.data-\\[state\\=closed\\]\\:fade-out-0{&[data-state=closed]{--tw-exit-opacity:0}}.data-\\[state\\=open\\]\\:animate-in{&[data-state=open]{--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial;animation-duration:.15s;animation-name:enter}}.data-\\[state\\=open\\]\\:fade-in-0{&[data-state=open]{--tw-enter-opacity:0}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:inset-x-0{&[data-vaul-drawer-direction=bottom]{inset-inline:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:bottom-0{&[data-vaul-drawer-direction=bottom]{bottom:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:mt-24{&[data-vaul-drawer-direction=bottom]{margin-top:calc(var(--spacing)*24)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:max-h-\\[80vh\\]{&[data-vaul-drawer-direction=bottom]{max-height:80vh}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:rounded-t-lg{&[data-vaul-drawer-direction=bottom]{border-top-left-radius:var(--radius);border-top-right-radius:var(--radius)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:border-t{&[data-vaul-drawer-direction=bottom]{border-top-style:var(--tw-border-style);border-top-width:1px}}.data-\\[vaul-drawer-direction\\=left\\]\\:inset-y-0{&[data-vaul-drawer-direction=left]{inset-block:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=left\\]\\:left-0{&[data-vaul-drawer-direction=left]{left:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=left\\]\\:w-3\\/4{&[data-vaul-drawer-direction=left]{width:75%}}.data-\\[vaul-drawer-direction\\=left\\]\\:border-r{&[data-vaul-drawer-direction=left]{border-right-style:var(--tw-border-style);border-right-width:1px}}.data-\\[vaul-drawer-direction\\=right\\]\\:inset-y-0{&[data-vaul-drawer-direction=right]{inset-block:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=right\\]\\:right-0{&[data-vaul-drawer-direction=right]{right:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=right\\]\\:w-3\\/4{&[data-vaul-drawer-direction=right]{width:75%}}.data-\\[vaul-drawer-direction\\=right\\]\\:border-l{&[data-vaul-drawer-direction=right]{border-left-style:var(--tw-border-style);border-left-width:1px}}.data-\\[vaul-drawer-direction\\=top\\]\\:inset-x-0{&[data-vaul-drawer-direction=top]{inset-inline:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=top\\]\\:top-0{&[data-vaul-drawer-direction=top]{top:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=top\\]\\:mb-24{&[data-vaul-drawer-direction=top]{margin-bottom:calc(var(--spacing)*24)}}.data-\\[vaul-drawer-direction\\=top\\]\\:max-h-\\[80vh\\]{&[data-vaul-drawer-direction=top]{max-height:80vh}}.data-\\[vaul-drawer-direction\\=top\\]\\:rounded-b-lg{&[data-vaul-drawer-direction=top]{border-bottom-left-radius:var(--radius);border-bottom-right-radius:var(--radius)}}.data-\\[vaul-drawer-direction\\=top\\]\\:border-b{&[data-vaul-drawer-direction=top]{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}}.data-\\[vaul-drawer-direction\\=left\\]\\:sm\\:max-w-sm,.sm\\:flex-row,.sm\\:justify-end,.sm\\:mx-0{&[data-vaul-drawer-direction=left]{@media (width >= 40rem){max-width:var(--container-sm)}}}.data-\\[vaul-drawer-direction\\=right\\]\\:sm\\:max-w-sm{&[data-vaul-drawer-direction=right]{@media (width >= 40rem){max-width:var(--container-sm)}}}.\\[\\&\\[data-state\\=open\\]\\>svg\\]\\:rotate-180,.md\\:text-\\[15px\\]{&[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)}.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 float{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-200px)}}',mh=ph.trim().length>0,gh="undefined"!=typeof window&&"adoptedStyleSheets"in Document.prototype&&"undefined"!=typeof CSSStyleSheet&&"replaceSync"in CSSStyleSheet.prototype;let vh=null;function yh(e){return vh||(vh=new CSSStyleSheet,vh.replaceSync(e)),vh}function bh(){return mh?ph: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 Eh=({extra:e})=>{const r=bh()+(e?"\n"+e:"");return t.createElement("style",null,r)};function wh(){const[e,n]=t.useState(null),s=r(null),{open:a,setOpen:o}=Gd();return i(()=>{s.current&&(s.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),s.current=e;const t=e.attachShadow({mode:"open"});!function(e){const t=bh();if(gh)e.adoptedStyleSheets=[yh(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),n(i),()=>e.remove()},[]),{container:e,setOpen:o}}const Sh=e=>{const{collectionId:r,isPreview:n,priceText:s,container:a}=e,{setIsPreview:o,setPriceText:l}=ea(),{setCollection:d,setNextKey:c,collection:u}=ia();i(()=>{s&&l(s);const e=Boolean(n);e&&o(e)},[]),i(()=>{x(void 0,void 0,void 0,function*(){var e;const t=yield Vs({collectionId:r,size:10});if(!t)return;const{contents:i,count:n}=t;(null==i?void 0:i.length)&&c(null===(e=i.at(-1))||void 0===e?void 0:e.shortsId),d(Object.assign(Object.assign({},t),{count:n}))})},[r]);const h=function(e){var t,r,i,n,s,a,o,l,d,c,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!==(n=e.borderLine)&&void 0!==n?n:Fe.DAY,exposeTitle:null===(s=e.exposeTitle)||void 0===s||s,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!==(d=e.exposeProductBanner)&&void 0!==d&&d,exposeProductBadge:null!==(c=e.exposeProductBadge)&&void 0!==c&&c,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:f}=function({collectionId:e,iconSize:r}){const{collection:i,setCollection:n,nextKey:s,setNextKey:a,isFetching:o,setIsFetching:l}=ia(),d=t.useRef(null),[c,u]=t.useState(0);return t.useEffect(()=>{if(!d.current)return;const e=new ResizeObserver(e=>{var t,r,i;const n=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(n)});return e.observe(d.current),()=>e.disconnect()},[]),t.useEffect(()=>{var e;if(!i||!i.contents)return;const t=Math.max(1,r+12),d=Math.ceil((c||0)/t)+4,u=null!==(e=i.count)&&void 0!==e?e:Number.MAX_SAFE_INTEGER,h=Math.min(u,d);if(i.contents.length>=h||o)return;let f=!1;return(()=>{x(this,void 0,void 0,function*(){var e,t,r,o,d;try{l(!0);let c=i,u=s||(null===(e=c.contents.at(-1))||void 0===e?void 0:e.shortsId)||void 0;const p=new Set(c.contents.map(e=>e.shortsId));for(;!f&&c.contents.length<h;){const e=Math.max(6,h-c.contents.length),i=yield Vs({collectionId:c.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 s=i.contents.filter(e=>!p.has(e.shortsId));if(!s.length)break;if(s.forEach(e=>p.add(e.shortsId)),c=Object.assign(Object.assign({},c),{contents:[...c.contents,...s]}),n(c),a(u||""),c.contents.length>=(null!==(d=c.count)&&void 0!==d?d: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,c,r,o,s,n,l,a]),{containerRef:d}}({collectionId:r,iconSize:h.iconSize});return t.createElement(fh.div,null,t.createElement(Eh,null),t.createElement("div",{ref:f},t.createElement(ku,{widgetPlayerOption:h,setCollectionUuid:e=>{d(Object.assign(Object.assign({},u),{uuid:e}))},portalContainer:a})))},Th=e=>{const{container:r}=wh();return r?t.createElement(ra,null,t.createElement(Sh,Object.assign({},e,{container:r}))):null},xh=({portalContainer:e,aspectRatio:r})=>{var n;const{collection:s,setNextKey:o}=ia(),[l,d]=a(),{setOpen:c,open:u}=Gd();i(()=>{u||l&&d(null)},[u]);const h=(null!==(n=Md().width)&&void 0!==n?n:0)<430||ma.isMobile;return t.createElement(t.Fragment,null,t.createElement("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${h?2:5}, 1fr)`}},null==s?void 0:s.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:Tt(e.media.objectId),poster:Rt(e.thumbPath)})),t.createElement(Hd,{hideMoreBadge:!0,showMoreBtn:!0,products:e.productsInfo,contentId:e.shortsId,setSelectedProducts:d})))),l&&t.createElement(Tu,{portalContainer:e,title:"상품 목록",contentClassName:"bg-white rounded p-4 product-dialog-container",description:"연결된 전체 상품 정보를 확인해 보세요"},t.createElement(xu,{products:l.productsInfo,contentId:l.shortsId})))},Ah=({collectionId:e,aspectRatio:r,container:n,isPreview:s})=>{const{setCollection:a,setNextKey:o}=ia();return i(()=>{x(void 0,void 0,void 0,function*(){var t;const r=yield Vs({collectionId:e,size:-1});if(!r)return;const{contents:i,count:n}=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:n}))})},[e]),t.createElement(fh.div,null,t.createElement(Eh,null),t.createElement(xh,{portalContainer:n,aspectRatio:r}))},kh=e=>{const{container:r}=wh();return r?t.createElement(ra,null,t.createElement(Ah,Object.assign({},e,{container:r}))):null},Lh=Js(e=>({shortform:null,setShortform:t=>e({shortform:t})}));var Ih={exports:{}},Rh={};function Ph(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=Ph(e[t]))&&(i&&(i+=" "),i+=r);else for(t in e)e[t]&&(i&&(i+=" "),i+=t);return i}function Dh(){for(var e,t,r=0,i="";r<arguments.length;)(e=arguments[r++])&&(t=Ph(e))&&(i&&(i+=" "),i+=t);return i}var Ch,_h=He(Object.freeze({__proto__:null,clsx:Dh,default:Dh})),Oh={},Mh={};function Nh(){if(Ch)return Mh;return Ch=1,Object.defineProperty(Mh,"__esModule",{value:!0}),Mh.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."))},Mh.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]},Mh.int=function(e){return parseInt(e,10)},Mh.isFunction=function(e){return"function"==typeof e||"[object Function]"===Object.prototype.toString.call(e)},Mh.isNum=function(e){return"number"==typeof e&&!isNaN(e)},Mh}var Fh,$h,Bh={};function Uh(){if($h)return Oh;$h=1,Object.defineProperty(Oh,"__esModule",{value:!0}),Oh.addClassName=a,Oh.addEvent=function(e,t,r,i){if(!e)return;const n={capture:!0,...i};e.addEventListener?e.addEventListener(t,r,n):e.attachEvent?e.attachEvent("on"+t,r):e["on"+t]=r},Oh.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")},Oh.createCSSTransform=function(e,r){const i=s(e,r,"px");return{[(0,t.browserPrefixToKey)("transform",t.default)]:i}},Oh.createSVGTransform=function(e,t){return s(e,t,"")},Oh.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)},Oh.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},Oh.getTranslation=s,Oh.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},Oh.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},Oh.matchesSelector=n,Oh.matchesSelectorAndParentsTo=function(e,t,r){let i=e;do{if(n(i,t))return!0;if(i===r)return!1;i=i.parentNode}while(i);return!1},Oh.offsetXYFromParent=function(e,t,r){const i=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect(),n=(e.clientX+t.scrollLeft-i.left)/r,s=(e.clientY+t.scrollTop-i.top)/r;return{x:n,y:s}},Oh.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},Oh.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},Oh.removeClassName=o,Oh.removeEvent=function(e,t,r,i){if(!e)return;const n={capture:!0,...i};e.removeEventListener?e.removeEventListener(t,r,n):e.detachEvent?e.detachEvent("on"+t,r):e["on"+t]=null},Oh.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=Nh(),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 n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var o=s?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(n,a,o):n[a]=e[a]}n.default=e,i&&i.set(e,n);return n}(function(){if(Fh)return Bh;Fh=1,Object.defineProperty(Bh,"__esModule",{value:!0}),Bh.browserPrefixToKey=r,Bh.browserPrefixToStyle=function(e,t){return t?"-".concat(t.toLowerCase(),"-").concat(e):e},Bh.default=void 0,Bh.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 n=null===(t=window.document)||void 0===t||null===(t=t.documentElement)||void 0===t?void 0:t.style;if(!n)return"";if(i in n)return"";for(let t=0;t<e.length;t++)if(r(i,e[t])in n)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 Bh.default=t(),Bh}());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 n(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 s(e,t,r){let{x:i,y:n}=e,s="translate(".concat(i).concat(r,",").concat(n).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);s="translate(".concat(e,", ").concat(i,")")+s}return s}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 Oh}var zh,Gh={};function jh(){if(zh)return Gh;zh=1,Object.defineProperty(Gh,"__esModule",{value:!0}),Gh.canDragX=function(e){return"both"===e.props.axis||"x"===e.props.axis},Gh.canDragY=function(e){return"both"===e.props.axis||"y"===e.props.axis},Gh.createCoreData=function(t,i,n){const s=!(0,e.isNum)(t.lastX),a=r(t);return s?{node:a,deltaX:0,deltaY:0,lastX:i,lastY:n,x:i,y:n}:{node:a,deltaX:i-t.lastX,deltaY:n-t.lastY,lastX:t.lastX,lastY:t.lastY,x:i,y:n}},Gh.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}},Gh.getBoundPosition=function(i,n,s){if(!i.props.bounds)return[n,s];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 n;if(n="parent"===a?o.parentNode:r.querySelector(a),!(n instanceof i.HTMLElement))throw new Error('Bounds selector "'+a+'" could not find an element.');const s=n,l=i.getComputedStyle(o),d=i.getComputedStyle(s);a={left:-o.offsetLeft+(0,e.int)(d.paddingLeft)+(0,e.int)(l.marginLeft),top:-o.offsetTop+(0,e.int)(d.paddingTop)+(0,e.int)(l.marginTop),right:(0,t.innerWidth)(s)-(0,t.outerWidth)(o)-o.offsetLeft+(0,e.int)(d.paddingRight)-(0,e.int)(l.marginRight),bottom:(0,t.innerHeight)(s)-(0,t.outerHeight)(o)-o.offsetTop+(0,e.int)(d.paddingBottom)-(0,e.int)(l.marginBottom)}}(0,e.isNum)(a.right)&&(n=Math.min(n,a.right));(0,e.isNum)(a.bottom)&&(s=Math.min(s,a.bottom));(0,e.isNum)(a.left)&&(n=Math.max(n,a.left));(0,e.isNum)(a.top)&&(s=Math.max(s,a.top));return[n,s]},Gh.getControlPosition=function(e,i,n){const s="number"==typeof i?(0,t.getTouch)(e,i):null;if("number"==typeof i&&!s)return null;const a=r(n),o=n.props.offsetParent||a.offsetParent||a.ownerDocument.body;return(0,t.offsetXYFromParent)(s||e,o,n.props.scale)},Gh.snapToGrid=function(e,t,r){const i=Math.round(t/e[0])*e[0],n=Math.round(r/e[1])*e[1];return[i,n]};var e=Nh(),t=Uh();function r(e){const t=e.findDOMNode();if(!t)throw new Error("<DraggableCore>: Unmounted during event!");return t}return Gh}var Hh,Vh,Wh,Yh,Kh={},qh={};function Xh(){if(Hh)return qh;return Hh=1,Object.defineProperty(qh,"__esModule",{value:!0}),qh.default=function(){},qh}function Qh(){if(Vh)return Kh;Vh=1,Object.defineProperty(Kh,"__esModule",{value:!0}),Kh.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=d(t);if(r&&r.has(e))return r.get(e);var i={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var a=n?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(i,s,a):i[s]=e[s]}i.default=e,r&&r.set(e,i);return i}(t),r=l(eh()),i=l(y),n=Uh(),s=jh(),a=Nh(),o=l(Xh());function l(e){return e&&e.__esModule?e:{default:e}}function d(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(d=function(e){return e?r:t})(e)}function c(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),c(this,"dragging",!1),c(this,"lastX",NaN),c(this,"lastY",NaN),c(this,"touchIdentifier",null),c(this,"mounted",!1),c(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,n.matchesSelectorAndParentsTo)(e.target,this.props.handle,t)||this.props.cancel&&(0,n.matchesSelectorAndParentsTo)(e.target,this.props.cancel,t))return;"touchstart"===e.type&&e.preventDefault();const i=(0,n.getTouchIdentifier)(e);this.touchIdentifier=i;const a=(0,s.getControlPosition)(e,i,this);if(null==a)return;const{x:l,y:d}=a,c=(0,s.createCoreData)(this,l,d);(0,o.default)("DraggableCore: handleDragStart: %j",c),(0,o.default)("calling",this.props.onStart);!1!==this.props.onStart(e,c)&&!1!==this.mounted&&(this.props.enableUserSelectHack&&(0,n.addUserSelectStyles)(r),this.dragging=!0,this.lastX=l,this.lastY=d,(0,n.addEvent)(r,f.move,this.handleDrag),(0,n.addEvent)(r,f.stop,this.handleDragStop))}),c(this,"handleDrag",e=>{const t=(0,s.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,s.snapToGrid)(this.props.grid,e,t),!e&&!t)return;r=this.lastX+e,i=this.lastY+t}const n=(0,s.createCoreData)(this,r,i);(0,o.default)("DraggableCore: handleDrag: %j",n);if(!1!==this.props.onDrag(e,n)&&!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)}}),c(this,"handleDragStop",e=>{if(!this.dragging)return;const t=(0,s.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,s.snapToGrid)(this.props.grid,e,t),r=this.lastX+e,i=this.lastY+t}const a=(0,s.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,n.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,n.removeEvent)(l.ownerDocument,f.move,this.handleDrag),(0,n.removeEvent)(l.ownerDocument,f.stop,this.handleDragStop))}),c(this,"onMouseDown",e=>(f=h,this.handleDragStart(e))),c(this,"onMouseUp",e=>(f=h,this.handleDragStop(e))),c(this,"onTouchStart",e=>(f=u,this.handleDragStart(e))),c(this,"onTouchEnd",e=>(f=u,this.handleDragStop(e)))}componentDidMount(){this.mounted=!0;const e=this.findDOMNode();e&&(0,n.addEvent)(e,u.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const e=this.findDOMNode();if(e){const{ownerDocument:t}=e;(0,n.removeEvent)(t,h.move,this.handleDrag),(0,n.removeEvent)(t,u.move,this.handleDrag),(0,n.removeEvent)(t,h.stop,this.handleDragStop),(0,n.removeEvent)(t,u.stop,this.handleDragStop),(0,n.removeEvent)(e,u.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,n.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 Kh.default=p,c(p,"displayName","DraggableCore"),c(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}),c(p,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1}),Kh}function Zh(){return Wh||(Wh=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return d.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={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var a=n?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(i,s,a):i[s]=e[s]}i.default=e,r&&r.set(e,i);return i}(t),i=u(eh()),n=u(y),s=u(_h),a=Uh(),o=jh(),l=Nh(),d=u(Qh()),c=u(Xh());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 m 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,c.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,c.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,c.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[n,s]=(0,o.getBoundPosition)(this,i.x,i.y);i.x=n,i.y=s,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,c.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:n.default.findDOMNode(this)}render(){const{axis:e,bounds:t,children:i,defaultPosition:n,defaultClassName:l,defaultClassNameDragging:c,defaultClassNameDragged:u,position:h,positionOffset:p,scale:m,...g}=this.props;let v={},y=null;const b=!Boolean(h)||this.state.dragging,E=h||n,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,s.default)(i.props.className||"",l,{[c]:this.state.dragging,[u]:this.state.dragged});return r.createElement(d.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=m,p(m,"displayName","Draggable"),p(m,"propTypes",{...d.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(m,"defaultProps",{...d.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})}(Rh)),Rh}var Jh=function(){if(Yh)return Ih.exports;Yh=1;const{default:e,DraggableCore:t}=Zh();return Ih.exports=e,Ih.exports.default=e,Ih.exports.DraggableCore=t,Ih.exports}(),ef=je(Jh),tf=function(){return tf=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},tf.apply(this,arguments)},rf={width:"100%",height:"10px",top:"0px",left:"0px",cursor:"row-resize"},nf={width:"10px",height:"100%",top:"0px",left:"0px",cursor:"col-resize"},sf={width:"20px",height:"20px",position:"absolute",zIndex:1},af={top:tf(tf({},rf),{top:"-5px"}),right:tf(tf({},nf),{left:void 0,right:"-5px"}),bottom:tf(tf({},rf),{top:void 0,bottom:"-5px"}),left:tf(tf({},nf),{left:"-5px"}),topRight:tf(tf({},sf),{right:"-10px",top:"-10px",cursor:"ne-resize"}),bottomRight:tf(tf({},sf),{right:"-10px",bottom:"-10px",cursor:"se-resize"}),bottomLeft:tf(tf({},sf),{left:"-10px",bottom:"-10px",cursor:"sw-resize"}),topLeft:tf(tf({},sf),{left:"-10px",top:"-10px",cursor:"nw-resize"})},of=h(function(e){var t=e.onResizeStart,r=e.direction,i=e.children,n=e.replaceStyles,s=e.className,a=c(function(e){t(e,r)},[t,r]),o=c(function(e){t(e,r)},[t,r]),l=u(function(){return tf(tf({position:"absolute",userSelect:"none"},af[r]),null!=n?n:{})},[n,r]);return p("div",{className:s||void 0,style:l,onMouseDown:a,onTouchStart:o,children:i})}),lf=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)}}(),df=function(){return df=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},df.apply(this,arguments)},cf={width:"auto",height:"auto"},uf=function(e,t,r){return Math.max(Math.min(e,r),t)},hf=function(e,t,r){var i=Math.round(e/t);return i*t+r*(i-1)},ff=function(e,t){return new RegExp(e,"i").test(t)},pf=function(e){return Boolean(e.touches&&e.touches.length)},mf=function(e,t,r){void 0===r&&(r=0);var i=t.reduce(function(r,i,n){return Math.abs(i-e)<Math.abs(t[r]-e)?n:r},0),n=Math.abs(t[i]-e);return 0===r||n<r?t[i]:e},gf=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")},vf=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},yf=["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"],bf="__resizable_base__",Ef=function(e){function t(t){var r,i,n,s,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(bf):t.className+=bf,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!==(s=null===(n=a.propsSize)||void 0===n?void 0:n.height)&&void 0!==s?s:"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 lf(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||cf},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,n=this.resizable.style.position;"relative"!==n&&(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=n}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(),n=Number(e.state[t].toString().replace("px",""))/i[t]*100;return"".concat(n,"%")}return gf(e.state[t])};return{width:t&&void 0!==t.width&&!this.state.isResizing?gf(t.width):r("width"),height:t&&void 0!==t.height&&!this.state.isResizing?gf(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,n=this.props.boundsByDirection,s=this.state.direction,a=n&&ff("left",s),o=n&&ff("top",s);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,n=(r=this.props.resizeRatio||1,Array.isArray(r)?r:[r,r]),s=n[0],a=n[1],o=this.state,l=o.direction,d=o.original,c=this.props,u=c.lockAspectRatio,h=c.lockAspectRatioExtraHeight,f=c.lockAspectRatioExtraWidth,p=d.width,m=d.height,g=h||0,v=f||0;return ff("right",l)&&(p=d.width+(e-d.x)*s/i,u&&(m=(p-v)/this.ratio+g)),ff("left",l)&&(p=d.width-(e-d.x)*s/i,u&&(m=(p-v)/this.ratio+g)),ff("bottom",l)&&(m=d.height+(t-d.y)*a/i,u&&(p=(m-g)*this.ratio+v)),ff("top",l)&&(m=d.height-(t-d.y)*a/i,u&&(p=(m-g)*this.ratio+v)),{newWidth:p,newHeight:m}},t.prototype.calculateNewSizeFromAspectRatio=function(e,t,r,i){var n=this.props,s=n.lockAspectRatio,a=n.lockAspectRatioExtraHeight,o=n.lockAspectRatioExtraWidth,l=void 0===i.width?10:i.width,d=void 0===r.width||r.width<0?e:r.width,c=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(s){var p=(c-h)*this.ratio+f,m=(u-h)*this.ratio+f,g=(l-f)/this.ratio+h,v=(d-f)/this.ratio+h,y=Math.max(l,p),b=Math.min(d,m),E=Math.max(c,g),w=Math.min(u,v);e=uf(e,y,b),t=uf(t,E,w)}else e=uf(e,l,d),t=uf(t,c,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 n=this.resizable.getBoundingClientRect(),s=n.left,a=n.top,o=n.right,l=n.bottom;this.resizableLeft=s*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,n=0;if(e.nativeEvent&&function(e){return Boolean((e.clientX||0===e.clientX)&&(e.clientY||0===e.clientY))}(e.nativeEvent)?(i=e.nativeEvent.clientX,n=e.nativeEvent.clientY):e.nativeEvent&&pf(e.nativeEvent)&&(i=e.nativeEvent.touches[0].clientX,n=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 s=this.window.getComputedStyle(this.resizable);if("auto"!==s.flexBasis){var a=this.parentNode;if(a){var o=this.window.getComputedStyle(a).flexDirection;this.flexDir=o.startsWith("row")?"row":"column",r=s.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var l={original:{x:i,y:n,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:df(df({},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&&pf(e))try{e.preventDefault(),e.stopPropagation()}catch(e){}var r=this.props,i=r.maxWidth,n=r.maxHeight,s=r.minWidth,a=r.minHeight,o=pf(e)?e.touches[0].clientX:e.clientX,l=pf(e)?e.touches[0].clientY:e.clientY,d=this.state,c=d.direction,u=d.original,h=d.width,f=d.height,p=this.getParentSize(),m=function(e,t,r,i,n,s,a){return i=vf(i,e.width,t,r),n=vf(n,e.height,t,r),s=vf(s,e.width,t,r),a=vf(a,e.height,t,r),{maxWidth:void 0===i?void 0:Number(i),maxHeight:void 0===n?void 0:Number(n),minWidth:void 0===s?void 0:Number(s),minHeight:void 0===a?void 0:Number(a)}}(p,this.window.innerWidth,this.window.innerHeight,i,n,s,a);i=m.maxWidth,n=m.maxHeight,s=m.minWidth,a=m.minHeight;var g=this.calculateNewSizeFromDirection(o,l),v=g.newHeight,y=g.newWidth,b=this.calculateNewMaxFromBoundary(i,n);this.props.snap&&this.props.snap.x&&(y=mf(y,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(v=mf(v,this.props.snap.y,this.props.snapGap));var w=this.calculateNewSizeFromAspectRatio(y,v,{width:b.maxWidth,height:b.maxHeight},{width:s,height:a});if(y=w.newWidth,v=w.newHeight,this.props.grid){var S=hf(y,this.props.grid[0],this.props.gridGap?this.props.gridGap[0]:0),T=hf(v,this.props.grid[1],this.props.gridGap?this.props.gridGap[1]:0),x=this.props.snapGap||0;y=0===x||Math.abs(S-y)<=x?S:y,v=0===x||Math.abs(T-v)<=x?T:v}var A={width:y-u.width,height:v-u.height};if(this.delta=A,h&&"string"==typeof h)if(h.endsWith("%")){var k=y/p.width*100;y="".concat(k,"%")}else if(h.endsWith("vw")){var L=y/this.window.innerWidth*100;y="".concat(L,"vw")}else if(h.endsWith("vh")){var I=y/this.window.innerHeight*100;y="".concat(I,"vh")}if(f&&"string"==typeof f)if(f.endsWith("%")){k=v/p.height*100;v="".concat(k,"%")}else if(f.endsWith("vw")){L=v/this.window.innerWidth*100;v="".concat(L,"vw")}else if(f.endsWith("vh")){I=v/this.window.innerHeight*100;v="".concat(I,"vh")}var R={width:this.createSizeForCssProperty(y,"width"),height:this.createSizeForCssProperty(v,"height")};"row"===this.flexDir?R.flexBasis=R.width:"column"===this.flexDir&&(R.flexBasis=R.height);var P=this.state.width!==R.width,D=this.state.height!==R.height,C=this.state.flexBasis!==R.flexBasis,_=P||D||C;_&&E(function(){t.setState(R)}),this.props.onResize&&_&&this.props.onResize(e,c,this.resizable,A)}},t.prototype.onMouseUp=function(e){var t,r,i=this.state,n=i.isResizing,s=i.direction;i.original,n&&this.resizable&&(this.props.onResizeStop&&this.props.onResizeStop(e,s,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:df(df({},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,n=t.handleClasses,s=t.handleWrapperStyle,a=t.handleWrapperClass,o=t.handleComponent;if(!r)return null;var l=Object.keys(r).map(function(t){return!1!==r[t]?p(of,{direction:t,onResizeStart:e.onResizeStart,replaceStyles:i&&i[t],className:n&&n[t],children:o&&o[t]?o[t]:null},t):null});return p("div",{className:a,style:s,children:l})},t.prototype.render=function(){var e=this,t=Object.keys(this.props).reduce(function(t,r){return-1!==yf.indexOf(r)||(t[r]=e.props[r]),t},{}),r=df(df(df({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 g(i,df({style:r,className:this.props.className},t,{ref:function(t){t&&(e.resizable=t)},children:[this.state.isResizing&&p("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),wf=function(e,t){return wf=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])},wf(e,t)};var Sf=function(){return Sf=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},Sf.apply(this,arguments)};var Tf={width:"auto",height:"auto",display:"inline-block",position:"absolute",top:0,left:0},xf=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}wf(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(),n=i.x,s=i.y;this.draggable.setState({x:n-t,y:s-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,n=this.getParent(),s=this.props.scale;if("parent"===this.props.bounds)i=n;else{if("body"===this.props.bounds){var a=n.getBoundingClientRect(),o=a.left,l=a.top,d=document.body.getBoundingClientRect(),c=-(o-n.offsetLeft*s-d.left)/s,u=-(l-n.offsetTop*s-d.top)/s,h=(document.body.offsetWidth-this.resizable.size.width*s)/s+c,f=(document.body.offsetHeight-this.resizable.size.height*s)/s+u;return this.setState({bounds:{top:u,right:h,bottom:f,left:c}})}if("window"===this.props.bounds){if(!this.resizable)return;var p=n.getBoundingClientRect(),m=p.left,g=p.top,v=-(m-n.offsetLeft*s)/s,y=-(g-n.offsetTop*s)/s;h=(window.innerWidth-this.resizable.size.width*s)/s+v,f=(window.innerHeight-this.resizable.size.height*s)/s+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&&n instanceof HTMLElement){var b=i.getBoundingClientRect(),E=b.left,w=b.top,S=n.getBoundingClientRect(),T=(E-S.left)/s,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/s,bottom:x+(i.offsetHeight-this.resizable.size.height)-A.top,left:T-A.left/s}})}}}},t.prototype.onDrag=function(e,t){if(this.props.onDrag){var r=this.offsetFromParent,i=r.left,n=r.top;return this.props.dragAxis&&"both"!==this.props.dragAxis?"x"===this.props.dragAxis?this.props.onDrag(e,Sf(Sf({},t),{x:t.x+i,y:this.originalPosition.y+n,deltaY:0})):"y"===this.props.dragAxis?this.props.onDrag(e,Sf(Sf({},t),{x:this.originalPosition.x+i,y:t.y+n,deltaX:0})):void 0:this.props.onDrag(e,Sf(Sf({},t),{x:t.x+i,y:t.y+n}))}},t.prototype.onDragStop=function(e,t){if(this.props.onDragStop){var r=this.offsetFromParent,i=r.left,n=r.top;return this.props.dragAxis&&"both"!==this.props.dragAxis?"x"===this.props.dragAxis?this.props.onDragStop(e,Sf(Sf({},t),{x:t.x+i,y:this.originalPosition.y+n,deltaY:0})):"y"===this.props.dragAxis?this.props.onDragStop(e,Sf(Sf({},t),{x:this.originalPosition.x+i,y:t.y+n,deltaX:0})):void 0:this.props.onDragStop(e,Sf(Sf({},t),{x:t.x+i,y:t.y+n}))}},t.prototype.onResizeStart=function(e,t,r){e.stopPropagation(),this.setState({resizing:!0});var i=this.props.scale,n=this.offsetFromParent,s=this.getDraggablePosition();if(this.resizingPosition={x:s.x+n.left,y:s.y+n.top},this.originalPosition=s,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 d=this.getMaxSizesFromProps(),c=d.maxWidth,u=d.maxHeight,h=this.getParentSize();if(c&&"string"==typeof c)if(c.endsWith("%")){var f=Number(c.replace("%",""))/100;c=h.width*f}else c.endsWith("px")&&(c=Number(c.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(c)?c:k})}if(T||this.props.lockAspectRatio&&!S&&!x){k=E+(y-m)/i;this.setState({maxWidth:k>Number(c)?c: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 n=this,s={x:this.originalPosition.x,y:this.originalPosition.y},a=-i.width,o=-i.height;["top","left","topLeft","bottomLeft","topRight"].includes(t)&&("bottomLeft"===t?s.x+=a:("topRight"===t||(s.x+=a),s.y+=o));var l=this.draggable.state;s.x===l.x&&s.y===l.y||E(function(){n.draggable.setState(s)}),this.updateOffsetFromParent();var d=this.offsetFromParent,c=this.getDraggablePosition().x+d.left,u=this.getDraggablePosition().y+d.top;this.resizingPosition={x:c,y:u},this.props.onResize&&this.props.onResize(e,t,r,i,{x:c,y:u})},t.prototype.onResizeStop=function(e,t,r,i){this.setState({resizing:!1});var n=this.getMaxSizesFromProps(),s=n.maxWidth,a=n.maxHeight;this.setState({maxWidth:s,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(),n=i.left,s=i.top,a=r.getBoundingClientRect(),o=this.getDraggablePosition(),l=t.scrollLeft,d=t.scrollTop;this.offsetFromParent={left:a.left-n+l-o.x*e,top:a.top-s+d-o.y*e}},t.prototype.render=function(){var e=this,t=this.props,r=t.disableDragging,i=t.style,n=t.dragHandleClassName,a=t.position,o=t.onMouseDown,l=t.onMouseUp,d=t.dragAxis,c=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 n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]])}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?Sf({},this.props.default):void 0;delete A.default;var L,I=r||n?{cursor:"auto"}:{cursor:"move"},R=Sf(Sf(Sf({},Tf),I),i),P=this.offsetFromParent,D=P.left,C=P.top;a&&(L={x:a.x-D,y:a.y-C});var _,O=this.state.resizing?void 0:L,M=this.state.resizing?"both":d;return s(ef,{ref:function(t){t&&(e.draggable=t)},handle:n?".".concat(n):void 0,defaultPosition:k,onMouseDown:o,onMouseUp:l,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop,axis:M,disabled:r,grid:c,bounds:u?this.state.bounds:void 0,position:O,enableUserSelectHack:h,cancel:f,scale:S,allowAnyClick:T,nodeRef:this.resizableElement,positionOffset:x},s(Ef,Sf({},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 Af=({shortform:e,setClose:r})=>{const[n,s]=t.useState(!0),[o,l]=a(!0),[d,c]=a(!1),u=t.useRef(null),h=()=>{u.current&&(window.clearTimeout(u.current),u.current=null)},f=(e=1500)=>{h(),u.current=window.setTimeout(()=>c(!1),e)};return i(()=>()=>h(),[]),t.createElement("div",{className:"relative w-full h-full",onClick:()=>{c(!0),f(2e3)},onMouseLeave:()=>f(800),onMouseEnter:()=>d&&f(1500)},t.createElement("div",{className:"absolute inset-0 bg-black",style:{zIndex:1,opacity:d?.4:0,transition:"opacity 300ms ease",pointerEvents:d?"auto":"none"}}),t.createElement("div",{className:"absolute inset-0",style:{zIndex:2,opacity:d?1:0,transition:"opacity 300ms ease",pointerEvents:d?"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(),s(e=>!e)},"aria-label":n?"Unmute":"Mute"},n?t.createElement(Xt,{size:20}):t.createElement(qt,{size:20})),t.createElement("button",{className:"cursor-pointer",onClick:e=>{null==e||e.stopPropagation(),r()},"aria-label":"Close"},t.createElement(Qt,{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(Wt,{size:28}):t.createElement(Yt,{size:28})))),t.createElement(Ct,{shortform:e,mute:n,play:o}))},kf=({shortsId:e,type:r})=>{const{shortform:n}=Lh(),[s,o]=a(!1),{playtime:l}=Fs(),d=()=>{if(!n)return;o(!0);const{shortsId:e,uuid:t,userId:r}=n;zs({contentId:e,uuid:t,type:Et.SHORTS,playtime:l,userId:r})};(({shorform:e,playtime:t})=>{i(()=>{if(!e)return;const{shortsId:t,shortsUuid:r,userId:i}=e;Us({contentId:t,uuid:r,type:Et.SHORTS,userId:i,isFirstPlay:!Lt(t)})},[]);const r=Ms();i(()=>{if(!e||r)return;const{shortsId:i,uuid:n,userId:s}=e;zs({contentId:i,uuid:n,type:Et.SHORTS,playtime:t,userId:s})},[r])})({shorform:n,playtime:l});const{w:c,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 n&&!s&&t.createElement(xf,{minWidth:240,lockAspectRatio:9/16,style:{zIndex:99999},default:{width:240,height:427,x:h+c-240-50,y:f+u-427-50},bounds:"window"},"shopping"===r&&n.productsInfo.length>0?t.createElement(Dd,{shortForm:n,handleClose:d}):t.createElement(Af,{shortform:n,setClose:d}))},Lf=({shortsId:e,type:r,isPreview:n})=>{const{setShortform:s,shortform:a}=Lh();return i(()=>{if(!e)return;e&&x(void 0,void 0,void 0,function*(){const t=yield Ws(e,n);t&&s(Object.assign(Object.assign({},t),{uuid:kt()}))})},[e]),a?t.createElement(fh.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:99999}},t.createElement(Eh,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(kf,{shortsId:e,type:r}))):null},If=Js(e=>({liveWidget:null,setLiveWidget:t=>e({liveWidget:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})})),Rf=({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"}})},Pf=({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"})},Df=(e,r)=>{const[i,n]=t.useState({}),[s,a]=t.useState({primary:20,secondary:12});return t.useEffect(()=>{const t=r.current;if(!t)return;const i=()=>{const r=t.getBoundingClientRect(),i=Math.max(0,Math.floor(r.width)),s=Math.max(0,Math.floor(r.height)),[o,l]=e.includes("/")?e.split("/").map(e=>parseFloat(e)):[1,1],d=l/o;let c,u;i>0&&s>0?(c=i,u=Math.round(c*d),u>s&&(u=s,c=Math.round(u/d)),n({width:c,height:u})):n({});const h="number"==typeof c?c: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:s,boxSize:i}},Cf=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:n})=>{var s,o;const{leftTime:l}=(e=>{const{start:t}=e,r=qe().tz("Asia/Seoul").unix(),[i,n]=a(t-r>0?t-r:0);return Ns(()=>{n(i<=0?0:e=>e-1)},1e3),{leftTime:i}})(e),d=null===(o=null===(s=null==e?void 0:e.designInfo)||void 0===s?void 0:s.thumbPath)||void 0===o?void 0:o.preview,c=t.useRef(null),{boxSize:u,fontSize:h}=Df(r,c),{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:c},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!=n?n:10}px`,backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",aspectRatio:u.height?void 0:r,backgroundImage:d?`url(${Rt(d)})`:void 0,backgroundColor:d?void 0:"black"}},1===e.openStatus?t.createElement(t.Fragment,null,t.createElement(Pf,{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(Rf,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(Rf,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`}},"곧 라이브가 시작됩니다!")))))},_f=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},Of=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=Mf},Mf=Number.MAX_SAFE_INTEGER||9007199254740991;let Nf=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}({}),Ff=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}({}),$f=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 Bf="manifest",Uf="level",zf="audioTrack",Gf="subtitleTrack",jf="main",Hf="audio",Vf="subtitle";class Wf{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 Yf{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 Wf(e),this.fast_=new Wf(t),this.defaultTTFB_=i,this.ttfb_=new Wf(e)}update(e,t){const{slow_:r,fast_:i,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new Wf(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new Wf(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Wf(e,n.getEstimate(),n.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 Kf(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 qf(){return qf=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},qf.apply(null,arguments)}function Xf(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 Qf(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Xf(Object(r),!0).forEach(function(t){Kf(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Xf(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class Zf{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=Jf,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 Jf=function(){},ep={trace:Jf,debug:Jf,log:Jf,warn:Jf,info:Jf,error:Jf};function tp(){return qf({},ep)}function rp(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}] >`):Jf}(e,r)}const ip=tp();const np=ip;function sp(e=!0){if("undefined"==typeof self)return;return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function ap(e,t){const r=Object.keys(e),i=Object.keys(t),n=r.length,s=i.length;return!n||!s||n===s&&!r.some(e=>-1===i.indexOf(e))}function op(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,n,s,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:n=e[o++],a+=String.fromCharCode((31&i)<<6|63&n);break;case 14:n=e[o++],s=e[o++],a+=String.fromCharCode((15&i)<<12|(63&n)<<6|63&s)}}return a}function lp(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 dp(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function cp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var up,hp={exports:{}};var fp,pp,mp,gp,vp,yp=up?hp.exports:(up=1,fp=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,pp=/^(?=([^\/?#]*))\1([^]*)$/,mp=/(?:\/|^)\.(?=\/)/g,gp=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,hp.exports=vp={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=vp.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=vp.normalizePath(i.path),vp.buildURLFromParts(i)}var n=vp.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=vp.normalizePath(n.path),vp.buildURLFromParts(n)):t;var s=vp.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var a=pp.exec(s.path);s.netLoc=a[1],s.path=a[2]}s.netLoc&&!s.path&&(s.path="/");var o={scheme:s.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(o.netLoc=s.netLoc,"/"!==n.path[0]))if(n.path){var l=s.path,d=l.substring(0,l.lastIndexOf("/")+1)+n.path;o.path=vp.normalizePath(d)}else o.path=s.path,n.params||(o.params=s.params,n.query||(o.query=s.query));return null===o.path&&(o.path=r.alwaysNormalize?vp.normalizePath(n.path):n.path),vp.buildURLFromParts(o)},parseURL:function(e){var t=fp.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(mp,"");e.length!==(e=e.replace(gp,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}});class bp{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 Ep="audio",wp="video",Sp="audiovideo";class Tp{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=Lp(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={[Ep]:null,[wp]:null,[Sp]: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 bp),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=yp.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[Ep]=null,e[wp]=null,e[Sp]=null}}function xp(e){return"initSegment"!==e.sn}class Ap extends Tp{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(_f(e)&&_f(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=_f(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){_f(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}get ref(){return xp(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,n,s=!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,n)):a[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:s}}}class kp extends Tp{constructor(e,t,r,i,n){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 s=e.enumeratedString("BYTERANGE");s&&this.setByteRange(s,n),n&&(this.fragOffset=n.fragOffset+n.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 Lp(e,t){const r=Object.getPrototypeOf(e);if(r){const e=Object.getOwnPropertyDescriptor(r,t);return e||Lp(r,t)}}const Ip=Math.pow(2,32)-1,Rp=[].push,Pp={video:1,audio:2,id3:3,text:4};function Dp(e){return String.fromCharCode.apply(null,e)}function Cp(e,t){const r=e[t]<<8|e[t+1];return r<0?65536+r:r}function _p(e,t){const r=Mp(e,t);return r<0?4294967296+r:r}function Op(e,t){let r=_p(e,t);return r*=Math.pow(2,32),r+=_p(e,t+4),r}function Mp(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function Np(e,t){const r=[];if(!t.length)return r;const i=e.byteLength;for(let n=0;n<i;){const s=_p(e,n),a=s>1?n+s:i;if(Dp(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,a));else{const i=Np(e.subarray(n+8,a),t.slice(1));i.length&&Rp.apply(r,i)}n=a}return r}function Fp(e){const t=[],r=e[0];let i=8;const n=_p(e,i);i+=4;let s=0,a=0;0===r?(s=_p(e,i),a=_p(e,i+4),i+=8):(s=Op(e,i),a=Op(e,i+8),i+=16),i+=2;let o=e.length+a;const l=Cp(e,i);i+=2;for(let r=0;r<l;r++){let r=i;const s=_p(e,r);r+=4;const a=2147483647&s;if(1===(2147483648&s)>>>31)return np.warn("SIDX has hierarchical references (not supported)"),null;const l=_p(e,r);r+=4,t.push({referenceSize:a,subsegmentDuration:l,info:{duration:l/n,start:o,end:o+a-1}}),o+=a,r+=4,i=r}return{earliestPresentationTime:s,timescale:n,version:r,referencesCount:l,references:t}}function $p(e){const t=[],r=Np(e,["moov","trak"]);for(let e=0;e<r.length;e++){const i=r[e],n=Np(i,["tkhd"])[0];if(n){let e=n[0];const r=_p(n,0===e?12:20),s=Np(i,["mdia","mdhd"])[0];if(s){e=s[0];const n=_p(s,0===e?12:20),a=Np(i,["mdia","hdlr"])[0];if(a){const e=Dp(a.subarray(8,12)),s={soun:Ep,vide:wp}[e],o=Bp(Np(i,["mdia","minf","stbl","stsd"])[0]);s?(t[r]={timescale:n,type:s,stsd:o},t[s]=Qf({timescale:n,id:r},o)):t[r]={timescale:n,type:e,stsd:o}}}}}return Np(e,["moov","mvex","trex"]).forEach(e=>{const r=_p(e,4),i=t[r];i&&(i.default={duration:_p(e,12),flags:_p(e,20)})}),t}function Bp(e){const t=e.subarray(8),r=t.subarray(86),i=Dp(t.subarray(4,8));let n,s=i;const a="enca"===i||"encv"===i;if(a){const e=Np(t,[i])[0];Np(e.subarray("enca"===i?28:78),["sinf"]).forEach(e=>{const t=Np(e,["schm"])[0];if(t){const r=Dp(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=Np(e,["frma"])[0];t&&(s=Dp(t))}}})}const o=s;switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const e=Np(r,["avcC"])[0];e&&e.length>3&&(s+="."+Gp(e[1])+Gp(e[2])+Gp(e[3]),n=Up("avc1"===o?"dva1":"dvav",r));break}case"mp4a":{const e=Np(t,[i])[0],r=Np(e.subarray(28),["esds"])[0];if(r&&r.length>7){let e=4;if(3!==r[e++])break;e=zp(r,e),e+=2;const t=r[e++];if(128&t&&(e+=2),64&t&&(e+=r[e++]),4!==r[e++])break;e=zp(r,e);const i=r[e++];if(64!==i)break;if(s+="."+Gp(i),e+=12,5!==r[e++])break;e=zp(r,e);const n=r[e++];let a=(248&n)>>3;31===a&&(a+=1+((7&n)<<3)+((224&r[e])>>5)),s+="."+a}break}case"hvc1":case"hev1":{const e=Np(r,["hvcC"])[0];if(e&&e.length>12){const t=e[1],r=["","A","B","C"][t>>6],i=31&t,n=_p(e,2),a=(32&t)>>5?"H":"L",o=e[12],l=e.subarray(6,12);s+="."+r+i,s+="."+function(e){let t=0;for(let r=0;r<32;r++)t|=(e>>r&1)<<31-r;return t>>>0}(n).toString(16).toUpperCase(),s+="."+a+o;let d="";for(let e=l.length;e--;){const t=l[e];if(t||d){d="."+t.toString(16).toUpperCase()+d}}s+=d}n=Up("hev1"==o?"dvhe":"dvh1",r);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":s=Up(s,r)||s;break;case"vp09":{const e=Np(r,["vpcC"])[0];if(e&&e.length>6){const t=e[4],r=e[5],i=e[6]>>4&15;s+="."+jp(t)+"."+jp(r)+"."+jp(i)}break}case"av01":{const e=Np(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,d=2===t&&o?l?12:10:o?10:8,c=(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;s+="."+t+"."+jp(i)+a+"."+jp(d)+"."+c+"."+u+h+f+"."+jp(p)+"."+jp(m)+"."+jp(g)+"."+v,n=Up("dav1",r)}break}}return{codec:s,encrypted:a,supplemental:n}}function Up(e,t){const r=Np(t,["dvvC"]),i=r.length?r[0]:Np(t,["dvcC"])[0];if(i){const t=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return e+"."+jp(t)+"."+jp(r)}}function zp(e,t){const r=t+5;for(;128&e[t++]&&t<r;);return t}function Gp(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function jp(e){return(e<10?"0":"")+e}function Hp(e,t){Np(e,["moov","trak"]).forEach(e=>{const r=Np(e,["mdia","minf","stbl","stsd"])[0];if(!r)return;const i=r.subarray(8);let n=Np(i,["enca"]);const s=n.length>0;s||(n=Np(i,["encv"])),n.forEach(e=>{Np(s?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{const r=Vp(e);r&&t(r,s)})})})}function Vp(e){const t=Np(e,["schm"])[0];if(t){const r=Dp(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=Np(e,["schi","tenc"])[0];if(t)return t}}}function Wp(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function Yp(e,t){const r=[],i=t.samples,n=t.timescale,s=t.id;let a=!1;return Np(i,["moof"]).map(o=>{const l=o.byteOffset-8;Np(o,["traf"]).map(o=>{const d=Np(o,["tfdt"]).map(e=>{const t=e[0];let r=_p(e,4);return 1===t&&(r*=Math.pow(2,32),r+=_p(e,8)),r/n})[0];return void 0!==d&&(e=d),Np(o,["tfhd"]).map(d=>{const c=_p(d,4),u=16777215&_p(d,0);let h=0;const f=!!(16&u);let p=0;const m=!!(32&u);let g=8;c===s&&(!!(1&u)&&(g+=8),!!(2&u)&&(g+=4),!!(8&u)&&(h=_p(d,g),g+=4),f&&(p=_p(d,g),g+=4),m&&(g+=4),"video"===t.type&&(a=Kp(t.codec)),Np(o,["trun"]).map(s=>{const o=s[0],d=16777215&_p(s,0),c=!!(1&d);let u=0;const f=!!(4&d),m=!!(256&d);let g=0;const v=!!(512&d);let y=0;const b=!!(1024&d),E=!!(2048&d);let w=0;const S=_p(s,4);let T=8;c&&(u=_p(s,T),T+=4),f&&(T+=4);let x=u+l;for(let l=0;l<S;l++){if(m?(g=_p(s,T),T+=4):g=h,v?(y=_p(s,T),T+=4):y=p,b&&(T+=4),E&&(w=0===o?_p(s,T):Mp(s,T),T+=4),t.type===wp){let t=0;for(;t<y;){const s=_p(i,x);if(x+=4,qp(a,i[x])){Xp(i.subarray(x,x+s),a?2:1,e+w/n,r)}x+=s,t+=s+4}}e+=g/n}}))})})}),r}function Kp(e){if(!e)return!1;const t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function qp(e,t){if(e){const e=t>>1&63;return 39===e||40===e}return 6===(31&t)}function Xp(e,t,r,i){const n=Qp(e);let s=0;s+=t;let a=0,o=0,l=0;for(;s<n.length;){a=0;do{if(s>=n.length)break;l=n[s++],a+=l}while(255===l);o=0;do{if(s>=n.length)break;l=n[s++],o+=l}while(255===l);const e=n.length-s;let t=s;if(o<e)s+=o;else if(o>e){np.error(`Malformed SEI payload. ${o} is too small, only ${e} bytes left to parse.`);break}if(4===a){if(181===n[t++]){const e=Cp(n,t);if(t+=2,49===e){const e=_p(n,t);if(t+=4,1195456820===e){const e=n[t++];if(3===e){const s=n[t++],o=64&s,l=o?2+3*(31&s):0,d=new Uint8Array(l);if(o){d[0]=s;for(let e=1;e<l;e++)d[e]=n[t++]}i.push({type:e,payloadType:a,pts:r,bytes:d})}}}}}else if(5===a&&o>16){const e=[];for(let r=0;r<16;r++){const i=n[t++].toString(16);e.push(1==i.length?"0"+i:i),3!==r&&5!==r&&7!==r&&9!==r||e.push("-")}const s=o-16,l=new Uint8Array(s);for(let e=0;e<s;e++)l[e]=n[t++];i.push({payloadType:a,pts:r,uuid:e.join(""),userData:op(l),userDataBytes:l})}}}function Qp(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 n=t-r.length,s=new Uint8Array(n);let a=0;for(i=0;i<n;a++,i++)a===r[0]&&(a++,r.shift()),s[i]=e[a];return s}function Zp(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");let i,n,s;i=0,n=new Uint8Array,s=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,n=r;for(;n--;)i+=t[n].byteLength;const s=new Uint8Array(i);for(s[0]=i>>24&255,s[1]=i>>16&255,s[2]=i>>8&255,s[3]=255&i,s.set(e,4),n=0,i=8;n<r;n++)s.set(t[n],i),i+=t[n].byteLength;return s}([112,115,115,104],new Uint8Array([0,0,0,0]),e,s,n,a,r)}function Jp(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 n=e.getUint32(8)>>>24;if(0!==n&&1!==n)return{offset:r,size:t};const s=e.buffer,a=lp(new Uint8Array(s,r+12,16));let o=null,l=null,d=0;if(0===n)d=28;else{const n=e.getUint32(28);if(!n||i<32+16*n)return{offset:r,size:t};o=[];for(let e=0;e<n;e++)o.push(new Uint8Array(s,r+32+16*e,16));d=32+16*n}if(!d)return{offset:r,size:t};const c=e.getUint32(d);return t-32<c?{offset:r,size:t}:(l=new Uint8Array(s,r+d+4,c),{version:n,systemId:a,kids:o,data:l,offset:r,size:t})}const em=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),tm={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 rm(e,t){const r=tm[t];return!!r&&!!r[e.slice(0,4)]}function im(e,t,r=!0){return!e.split(",").some(e=>!nm(e,t,r))}function nm(e,t,r=!0){var i;const n=sp(r);return null!=(i=null==n?void 0:n.isTypeSupported(sm(e,t)))&&i}function sm(e,t){return`${t}/mp4;codecs=${e}`}function am(e){if(e){const t=e.substring(0,4);return tm.video[t]}return 2}function om(e){const t=em();return e.split(",").reduce((e,r)=>{const i=t&&Kp(r)?9:tm.video[r];return i?(2*i+e)/(e?3:2):(tm.audio[r]+e)/(e?2:1)},0)}const lm={};const dm=/flac|opus|mp4a\.40\.34/i;function cm(e,t=!0){return e.replace(dm,e=>function(e,t=!0){if(lm[e])return lm[e];const r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e];for(let n=0;n<r.length;n++){var i;if(nm(r[n],"audio",t))return lm[e]=r[n],r[n];if("mp3"===r[n]&&null!=(i=sp(t))&&i.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t))}function um(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(hm(e,"audio")||hm(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 hm(e,t){return rm(e,t)&&nm(e,t)}function fm(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 pm(e){const t=sp(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 mm(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const gm={supported:!1,smooth:!1,powerEfficient:!1},vm={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function ym(e,t){return{supported:!1,configurations:t,decodingInfoResults:[gm],error:e}}function bm(e,t,r,i,n,s){const a=e.videoCodec,o=e.audioCodec?e.audioGroups:null,l=null==s?void 0:s.audioCodec,d=null==s?void 0:s.channels,c=d?parseInt(d):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=>Kp(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(n,8e6))||!!u&&_f(c)&&Object.keys(u).some(e=>parseInt(e)>c)}function Em(e,t,r,i={}){const n=e.videoCodec;if(!n&&!e.audioCodec||!r)return Promise.resolve(vm);const s=[],a=function(e){var t;const r=null==(t=e.videoCodec)?void 0:t.split(","),i=Sm(e),n=e.width||640,s=e.height||480,a=e.frameRate||30,o=e.videoRange.toLowerCase();return r?r.map(e=>{const t={contentType:sm(fm(e),"video"),width:n,height:s,bitrate:i,framerate:a};return"sdr"!==o&&(t.transferFunction=o),t}):[]}(e),o=a.length,l=function(e,t,r){var i;const n=null==(i=e.audioCodec)?void 0:i.split(","),s=Sm(e);if(n&&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||"");n.forEach(t=>{const n={contentType:sm(t,"audio"),bitrate:r?wm(t,s):s};i&&(n.channels=""+i),e.push(n)})}return e},e):e},[]);return[]}(e,t,o>0),d=l.length;for(let e=o||1*d||1;e--;){const t={type:"media-source"};if(o&&(t.video=a[e%o]),d){t.audio=l[e%d];const r=t.audio.bitrate;t.video&&r&&(t.video.bitrate-=r)}s.push(t)}if(n){const e=navigator.userAgent;if(n.split(",").some(e=>Kp(e))&&em())return Promise.resolve(ym(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${e})`),s))}return Promise.all(s.map(e=>{const t=function(e){let t="";const{audio:r,video:i}=e;if(i){t+=`${mm(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?"_":""}${mm(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:s,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:s,decodingInfoResults:[],error:e}))}function wm(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 Sm(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}const Tm=["NONE","TYPE-0","TYPE-1",null];const xm=["SDR","PQ","HLG"];var Am="",km="YES",Lm="v2";function Im(e){const{canSkipUntil:t,canSkipDateRanges:r,age:i}=e;return t&&i<t/2?r?Lm:km:Am}class Rm{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 Pm{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 Dm(this._audioGroups,e)}hasSubtitleGroup(e){return Dm(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 Dm(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function Cm(e,t){let r=!1,i=[];if(e&&(r="SDR"!==e,i=[e]),t){i=t.allowedVideoRanges||xm.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 _m=(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 Om(e,t){np.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function Mm(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 Nm(e){if(!e)return e;const{lang:t,assocLang:r,characteristics:i,channels:n,audioCodec:s}=e;return{lang:t,assocLang:r,characteristics:i,channels:n,audioCodec:s}}function Fm(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($m(e,t[i],r))return i}return-1}function $m(e,t,r){const{groupId:i,name:n,lang:s,assocLang:a,default:o}=e,l=e.forced;return(void 0===i||t.groupId===i)&&(void 0===n||t.name===n)&&(void 0===s||function(e,t="--"){if(e.length===t.length)return e===t;return e.startsWith(t)||t.startsWith(e)}(s,t.lang))&&(void 0===s||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 Bm(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 Um(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 zm(e,t){var r;return!!e&&e!==(null==(r=t.loadLevelObj)?void 0:r.uri)}const Gm=function(e,t){let r=0,i=e.length-1,n=null,s=null;for(;r<=i;){n=(r+i)/2|0,s=e[n];const a=t(s);if(a>0)r=n+1;else{if(!(a<0))return s;i=n-1}}return null};function jm(e,t,r=0,i=0,n=.005){let s=null;if(e){s=t[1+e.sn-t[0].sn]||null;const i=e.endDTS-r;i>0&&i<15e-7&&(r+=15e-7),s&&e.level!==s.level&&s.end<=e.end&&(s=t[2+e.sn-t[0].sn]||null)}else 0===r&&0===t[0].start&&(s=t[0]);if(s&&((!e||e.level===s.level)&&0===Hm(r,i,s)||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}(s,e,Math.min(n,i))))return s;const a=Gm(t,Hm.bind(null,r,i));return!a||a===e&&s?s:a}function Hm(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 Vm(e,t,r){const i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function Wm(e,t,r){if(e&&e.startCC<=t&&e.endCC>=t){let i=e.fragments;const{fragmentHint:n}=e;let s;return n&&(i=i.concat(n)),Gm(i,e=>e.cc<t?1:e.cc>t?-1:(s=e,e.end<=r?1:e.start>r?-1:0)),s||null}return null}function Ym(e){switch(e.details){case Ff.FRAG_LOAD_TIMEOUT:case Ff.KEY_LOAD_TIMEOUT:case Ff.LEVEL_LOAD_TIMEOUT:case Ff.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Km(e){return e.details.startsWith("key")}function qm(e){return Km(e)&&!!e.frag&&!e.frag.decryptdata}function Xm(e,t){const r=Ym(t);return e.default[(r?"timeout":"error")+"Retry"]}function Qm(e,t){const r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function Zm(e){return Qf(Qf({},e),{errorRetry:null,timeoutRetry:null})}function Jm(e,t,r,i){if(!e)return!1;const n=null==i?void 0:i.code,s=t<e.maxNumRetry&&(function(e){return eg(e)||!!e&&(e<400||e>499)}(n)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,s):s}function eg(e){return 0===e&&!1===navigator.onLine}var tg=0,rg=2,ig=3,ng=5,sg=0,ag=1,og=2,lg=4;function dg(e){const t={action:tg,flags:sg};return e&&(t.resolved=!0),t}var cg="NOT_LOADED",ug="APPENDING",hg="PARTIAL",fg="OK";class pg{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($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.BUFFER_APPENDED,this.onBufferAppended,this),e.on($f.FRAG_BUFFERED,this.onFragBuffered,this),e.on($f.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.BUFFER_APPENDED,this.onBufferAppended,this),e.off($f.FRAG_BUFFERED,this.onFragBuffered,this),e.off($f.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,n=Object.keys(i);for(let s=n.length;s--;){const a=i[n[s]];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,n){this.timeRanges&&(this.timeRanges[e]=t);const s=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach(i=>{const a=this.fragments[i];if(!a)return;if(s>=a.body.sn)return;if(!a.buffered&&(!a.loaded||n))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=gg(r),n=this.fragments[i];if(!n||n.buffered&&r.gap)return;const s=!r.relurl;Object.keys(t).forEach(i=>{const a=r.elementaryStreams[i];if(!a)return;const o=t[i],l=s||!0===a.partial;n.range[i]=this.getBufferedTimes(r,e.part,l,o)}),n.loaded=null,Object.keys(n.range).length?(this.bufferedEnd(n,r),mg(n)||this.removeParts(r.sn-1,r.type)):this.removeFragment(n.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]=vg(r,t=>t.fragment.sn>=e))}fragBuffered(e,t){const r=gg(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 n={time:[],partial:r},s=e.start,a=e.end,o=e.minEndPTS||a,l=e.maxStartPTS||s;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){n.time.push({startPTS:Math.max(s,i.start(e)),endPTS:Math.min(a,i.end(e))});break}if(s<r&&a>t){const t=Math.max(s,i.start(e)),r=Math.min(a,i.end(e));r>t&&(n.partial=!0,n.time.push({startPTS:t,endPTS:r}))}else if(a<=t)break}return n}getPartialFragment(e){let t,r,i,n=null,s=0;const{bufferPadding:a,fragments:o}=this;return Object.keys(o).forEach(l=>{const d=o[l];d&&mg(d)&&(r=d.body.start-a,i=d.body.end+a,e>=r&&e<=i&&(t=Math.min(e-r,i-e),s<=t&&(n=d.body,s=t)))}),n}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||mg(t))}getState(e){const t=gg(e),r=this.fragments[t];return r?r.buffered?mg(r)?hg:fg:ug:cg}isTimeBuffered(e,t,r){let i,n;for(let s=0;s<r.length;s++){if(i=r.start(s)-this.bufferPadding,n=r.end(s)+this.bufferPadding,e>=i&&t<=n)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,n=gg(r);this.fragments[n]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:r,part:i,timeRanges:n,type:s}=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=n;const o=n[s];this.detectEvictedFragments(s,o,a,i)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=gg(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 n=t[r[i]];if((null==n?void 0:n.body.type)===e)return!0}return!1}hasParts(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}removeFragmentsInRange(e,t,r,i,n){i&&!this.hasGaps||Object.keys(this.fragments).forEach(s=>{const a=this.fragments[s];if(!a)return;const o=a.body;o.type!==r||i&&!o.gap||o.start<t&&o.end>e&&(a.buffered||n)&&this.removeFragment(o)})}removeFragment(e){const t=gg(e);e.clearElementaryStreamInfo();const r=this.activePartLists[e.type];if(r){const t=e.sn;this.activePartLists[e.type]=vg(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 mg(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 gg(e){return`${e.type}_${e.level}_${e.sn}`}function vg(e,t){return e.filter(e=>{const r=t(e);return r||e.clearElementaryStreamInfo(),r})}var yg=0,bg=1;class Eg{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 yg:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case bg: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 wg{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],n=r[1],s=r[2],a=r[3],o=this.invSubMix,l=o[0],d=o[1],c=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,n[f]=v<<16|v>>>16,s[f]=v<<8|v>>>24,a[f]=v,v=16843009*g^65537*m^257*o^16843008*f,l[r]=v<<24|v>>>8,d[r]=v<<16|v>>>16,c[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 n=this.keySize=t.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);const s=this.ksRows=4*(n+6+1);let a,o;const l=this.keySchedule=new Uint32Array(s),d=this.invKeySchedule=new Uint32Array(s),c=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<s;a++)a<n?v=l[a]=t[a]:(y=v,a%n===0?(y=y<<8|y>>>24,y=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[255&y],y^=u[a/n|0]<<24):n>6&&a%n===4&&(y=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[255&y]),l[a]=v=(l[a-n]^y)>>>0);for(o=0;o<s;o++)a=s-o,y=3&o?l[a]:l[a-4],d[o]=o<4||a<=4?y:f[c[y>>>24]]^p[c[y>>>16&255]]^m[c[y>>>8&255]]^g[c[255&y]],d[o]=d[o]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,r){const i=this.keySize+6,n=this.invKeySchedule,s=this.invSBox,a=this.invSubMix,o=a[0],l=a[1],d=a[2],c=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,D;const C=this.networkToHostOrderSwap;for(;t<g.length;){for(k=C(g[t]),L=C(g[t+1]),I=C(g[t+2]),R=C(g[t+3]),S=k^n[0],T=R^n[1],x=I^n[2],A=L^n[3],P=4,D=1;D<i;D++)y=o[S>>>24]^l[T>>16&255]^d[x>>8&255]^c[255&A]^n[P],b=o[T>>>24]^l[x>>16&255]^d[A>>8&255]^c[255&S]^n[P+1],E=o[x>>>24]^l[A>>16&255]^d[S>>8&255]^c[255&T]^n[P+2],w=o[A>>>24]^l[S>>16&255]^d[T>>8&255]^c[255&x]^n[P+3],S=y,T=b,x=E,A=w,P+=4;y=s[S>>>24]<<24^s[T>>16&255]<<16^s[x>>8&255]<<8^s[255&A]^n[P],b=s[T>>>24]<<24^s[x>>16&255]<<16^s[A>>8&255]<<8^s[255&S]^n[P+1],E=s[x>>>24]<<24^s[A>>16&255]<<16^s[S>>8&255]<<8^s[255&T]^n[P+2],w=s[A>>>24]<<24^s[S>>16&255]<<16^s[T>>8&255]<<8^s[255&x]^n[P+3],v[t]=C(y^h),v[t+1]=C(w^f),v[t+2]=C(E^p),v[t+3]=C(b^m),h=k,f=L,p=I,m=R,t+=4}return v.buffer}}class Sg{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 yg:return"AES-CBC";case bg: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 Tg{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((n,s)=>{const a=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(a,t,r,i);const o=this.flush();o?n(o.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r,i)}softwareDecrypt(e,t,r,i){const{currentIV:n,currentResult:s,remainderData:a}=this;if(i!==yg||16!==t.byteLength)return np.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),a&&(e=Wp(a,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;n&&(r=n);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new wg),l.expandKey(t);const d=s;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=o.slice(-16).buffer,d||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 Sg(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 Eg(this.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)}).catch(n=>(np.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,r,i)))}onWebCryptoError(e,t,r,i){const n=this.enableSoftwareAES;if(n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,i);const n=this.flush();if(n)return n.buffer}throw new Error("WebCrypto"+(n?" 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&&(np.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const xg=Math.pow(2,17);class Ag{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 Ig({type:Nf.NETWORK_ERROR,details:Ff.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,n=i.fLoader,s=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(Lg(e));e.gap=!1}const l=this.loader=n?new n(i):new s(i),d=kg(e);e.loader=l;const c=Zm(i.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:xg};e.stats=l.stats;const h={onSuccess:(t,r,i,n)=>{this.resetLoader(e,l);let s=t.data;i.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),a({frag:e,part:null,payload:s,networkDetails:n})},onError:(t,i,n,s)=>{this.resetLoader(e,l),o(new Ig({type:Nf.NETWORK_ERROR,details:Ff.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Qf({url:r,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:n,stats:s}))},onAbort:(t,r,i)=>{this.resetLoader(e,l),o(new Ig({type:Nf.NETWORK_ERROR,details:Ff.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:(t,r,i)=>{this.resetLoader(e,l),o(new Ig({type:Nf.NETWORK_ERROR,details:Ff.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:i,stats:t}))}};t&&(h.onProgress=(r,i,n,s)=>t({frag:e,part:null,payload:n,networkDetails:s})),l.load(d,u,h)})}loadPart(e,t,r){this.abort();const i=this.config,n=i.fLoader,s=i.loader;return new Promise((a,o)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void o(Lg(e,t));const l=this.loader=n?new n(i):new s(i),d=kg(e,t);e.loader=l;const c=Zm(i.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:xg};t.stats=l.stats,l.load(d,u,{onSuccess:(i,n,s,o)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const d={frag:e,part:t,payload:i.data,networkDetails:o};r(d),a(d)},onError:(r,i,n,s)=>{this.resetLoader(e,l),o(new Ig({type:Nf.NETWORK_ERROR,details:Ff.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Qf({url:d.url,data:void 0},r),error:new Error(`HTTP Error ${r.code} ${r.text}`),networkDetails:n,stats:s}))},onAbort:(r,i,n)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),o(new Ig({type:Nf.NETWORK_ERROR,details:Ff.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:n,stats:r}))},onTimeout:(r,i,n)=>{this.resetLoader(e,l),o(new Ig({type:Nf.NETWORK_ERROR,details:Ff.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:n,stats:r}))}})})}updateStatsFromPart(e,t){const r=e.stats,i=t.stats,n=i.total;if(r.loaded+=i.loaded,n){const i=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/n),i),a=(i-s)*Math.round(r.loaded/s);r.total=r.loaded+a}else r.total=Math.max(r.loaded,r.total);const s=r.loading,a=i.loading;s.start?s.first+=a.first-a.start:(s.start=a.start,s.first=a.first),s.end=a.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function kg(e,t=null){const r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},n=r.byteRangeStartOffset,s=r.byteRangeEndOffset;if(_f(n)&&_f(s)){var a;let t=n,r=s;if("initSegment"===e.sn&&("AES-128"===(o=null==(a=e.decryptdata)?void 0:a.method)||"AES-256"===o)){const e=s-n;e%16&&(r=s+(16-e%16)),0!==n&&(i.resetIV=!0,t=n-16)}i.rangeStart=t,i.rangeEnd=r}var o;return i}function Lg(e,t){const r=new Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:Nf.MEDIA_ERROR,details:Ff.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new Ig(i)}class Ig extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Rg extends Zf{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 Pg{constructor(e,t,r,i=0,n=-1,s=!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=n,this.partial=s}}const Dg={length:0,start:()=>0,end:()=>0};class Cg{static isBuffered(e,t){if(e){const r=Cg.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=Cg.getBuffered(e);return Cg.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=Cg.bufferedRanges(e);if(i.length)return Cg.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,n=[];if(r)for(let s=0;s<e.length;s++){t>=e[s].start&&t<=e[s].end&&(i=s);const a=n.length;if(a){const t=n[a-1].end;e[s].start-t<r?e[s].end>t&&(n[a-1].end=e[s].end):n.push(e[s])}else n.push(e[s])}else n=e;let s,a=0,o=t,l=t;for(let e=0;e<n.length;e++){const d=n[e].start,c=n[e].end;if(-1===i&&t>=d&&t<=c&&(i=e),t+r>=d&&t<c)o=d,l=c,a=l-t;else if(t+r<d){s=d;break}}return{len:a,start:o||0,end:l||0,nextStart:s,buffered:e,bufferedIndex:i}}static getBuffered(e){try{return e.buffered||Dg}catch(e){return np.log("failed to get media.buffered",e),Dg}}}const _g=/\{\$([a-zA-Z0-9-_]+)\}/g;function Og(e){return _g.test(e)}function Mg(e,t){if(null!==e.variableList||e.hasVariableRefs){const r=e.variableList;return t.replace(_g,t=>{const i=t.substring(2,t.length-1),n=null==r?void 0:r[i];return void 0===n?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"`)),t):n})}return t}function Ng(e,t,r){let i,n,s=e.variableList;if(s||(e.variableList=s={}),"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}"`);n=e.get(i)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else i=t.NAME,n=t.VALUE;i in s?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):s[i]=n||""}function Fg(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 $g=/^(\d+)x(\d+)$/,Bg=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Ug{constructor(e,t){"string"==typeof e&&(e=Ug.parseAttrList(e,t)),qf(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=$g.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(Bg.lastIndex=0;null!==(r=Bg.exec(e));){const n=r[1].trim();let s=r[2];const a=0===s.indexOf('"')&&s.lastIndexOf('"')===s.length-1;let o=!1;if(a)s=s.slice(1,-1);else switch(n){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":o=!0}if(t&&(a||o))s=Mg(t,s);else if(!o&&!a)switch(n){case"CLOSED-CAPTIONS":if("NONE"===s)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":np.warn(`${e}: attribute ${n} is missing quotes`)}i[n]=s}return i}}function zg(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function Gg(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}class jg{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]){np.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=qf(new Ug({}),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"]);_f(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?(np.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(_f(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return"com.apple.hls.interstitial"===this.class}get isValid(){return!!this.id&&!this._badValueForSameId&&_f(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 Hg{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&&_f(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 Vg(e,t){return e.length===t.length&&!e.some((e,r)=>e!==t[r])}function Wg(e,t){return!e&&!t||!(!e||!t)&&Vg(e,t)}function Yg(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function Kg(e){switch(e){case"AES-128":case"AES-256":return yg;case"AES-256-CTR":return bg;default:throw new Error(`invalid full segment method ${e}`)}}function qg(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function Xg(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function Qg(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 Zg(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],n=i[1];t?(e.splice(-1,1),r=qg(n)):r=function(e){const t=Xg(e).subarray(0,16),r=new Uint8Array(16);return r.set(t,16-t.length),r}(n)}}return r}const Jg="undefined"!=typeof self?self:void 0;var ev={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},tv="org.w3.clearkey",rv="com.apple.streamingkeydelivery",iv="com.microsoft.playready",nv="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function sv(e){switch(e){case rv:return ev.FAIRPLAY;case iv:return ev.PLAYREADY;case nv:return ev.WIDEVINE;case tv:return ev.CLEARKEY}}function av(e){switch(e){case ev.FAIRPLAY:return rv;case ev.PLAYREADY:return iv;case ev.WIDEVINE:return nv;case ev.CLEARKEY:return tv}}function ov(e){const{drmSystems:t,widevineLicenseUrl:r}=e,i=t?[ev.FAIRPLAY,ev.WIDEVINE,ev.PLAYREADY,ev.CLEARKEY].filter(e=>!!t[e]):[];return!i[ev.WIDEVINE]&&r&&i.push(ev.WIDEVINE),i}const lv=null!=Jg&&null!=(dv=Jg.navigator)&&dv.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var dv;function cv(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),n=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(n){const e=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE");if(e){const t=qg(e).subarray(0,16);return Qg(t),t}}return null}let uv={};class hv{static clearKeyUriToKeyIdMap(){uv={}}static setKeyIdForUri(e,t){uv[e]=t}static addKeyIdForUri(e){const t=Object.keys(uv).length%Number.MAX_SAFE_INTEGER,r=new Uint8Array(16);return new DataView(r.buffer,12,4).setUint32(0,t),uv[e]=r,r}constructor(e,t,r,i=[1],n=null,s){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=n,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&!Yg(e),null!=s&&s.startsWith("0x")&&(this.keyId=new Uint8Array(dp(s)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&Vg(e.keyFormatVersions,this.keyFormatVersions)&&Wg(e.iv,this.iv)&&Wg(e.keyId,this.keyId)}isSupported(){if(this.method){if(Yg(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case rv:case nv:case iv:case tv: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(Yg(this.method)){let t=this.iv;t||("number"!=typeof e&&(np.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 hv(this.method,this.uri,"identity",this.keyFormatVersions,t)}if(this.keyId){const e=uv[this.uri];if(e&&!Vg(this.keyId,e)&&hv.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const r=Zg(this.uri);if(r)switch(this.keyFormat){case nv: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=Jp(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=fv(t));break;case iv:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Zp(e,0,r),this.keyId=cv(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[nv];if(t)return t.keyId;return null}(t),e||(e=fv(t),e||(e=uv[this.uri])),e&&(this.keyId=e,hv.setKeyIdForUri(this.uri,e))}return this}}function fv(e){const t=null==e?void 0:e[iv];if(t){const e=Zg(t.uri);if(e)return cv(e)}return null}const pv=/#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,mv=/#EXT-X-MEDIA:(.*)/g,gv=/^#EXT(?:INF|-X-TARGETDURATION):/m,vv=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),yv=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 bv{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 yp.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return gv.test(e)}static parseMasterPlaylist(e,t){const r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Og(e)},i=[];if(pv.lastIndex=0,!e.startsWith("#EXTM3U"))return r.playlistParsingError=new Error("no EXTM3U delimiter"),r;let n;for(;null!=(n=pv.exec(e));)if(n[1]){var s;const e=new Ug(n[1],r),a=Mg(r,n[2]),o={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:bv.resolve(a,t)},l=e.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),xv(e.CODECS,o);const d=e["SUPPLEMENTAL-CODECS"];d&&(o.supplemental={},xv(d,o.supplemental)),null!=(s=o.unknownCodecs)&&s.length||i.push(o),r.levels.push(o)}else if(n[3]){const e=n[3],i=n[4];switch(e){case"SESSION-DATA":{const e=new Ug(i,r),t=e["DATA-ID"];t&&(null===r.sessionData&&(r.sessionData={}),r.sessionData[t]=e);break}case"SESSION-KEY":{const e=Sv(i,t,r);e.encrypted&&e.isSupported()?(null===r.sessionKeys&&(r.sessionKeys=[]),r.sessionKeys.push(e)):np.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":Ng(r,new Ug(i,r),t);break;case"CONTENT-STEERING":{const e=new Ug(i,r);r.contentSteering={uri:bv.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":r.startTimeOffset=Tv(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 n={},s=r.levels,a={AUDIO:s.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:s.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]};let o=0;for(mv.lastIndex=0;null!==(i=mv.exec(e));){const e=new Ug(i[1],r),s=e.TYPE;if(s){const r=a[s],i=n[s]||[];n[s]=i;const l=e.LANGUAGE,d=e["ASSOC-LANGUAGE"],c=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:s,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:l,url:e.URI?bv.resolve(e.URI,t):""};if(d&&(f.assocLang=d),c&&(f.channels=c),u&&(f.characteristics=u),h&&(f.instreamId=h),null!=r&&r.length){const e=bv.findGroup(r,f.groupId)||r[0];Av(f,e,"audioCodec"),Av(f,e,"textCodec")}i.push(f)}}return n}static parseLevelPlaylist(e,t,r,i,n,s){var a;const o={url:t},l=new Hg(t),d=l.fragments,c=[];let u,h,f,p,m=null,g=0,v=0,y=0,b=0,E=0,w=null,S=new Ap(i,o),T=-1,x=!1,A=null;if(vv.lastIndex=0,l.m3u8=e,l.hasVariableRefs=Og(e),"#EXTM3U"!==(null==(a=vv.exec(e))?void 0:a[0]))return l.playlistParsingError=new Error("Missing format identifier #EXTM3U"),l;for(;null!==(u=vv.exec(e));){x&&(x=!1,S=new Ap(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(_f(S.duration)){S.playlistOffset=y,S.setStart(y),f&&Iv(S,f,l),S.sn=g,S.level=r,S.cc=b,d.push(S);const e=(" "+u[3]).slice(1);S.relurl=Mg(l,e),kv(S,w,c),w=S,y+=S.duration,g++,v=0,x=!0}}else{if(u=u[0].match(yv),!u){np.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),n=(" "+u[h+1]).slice(1),a=u[h+2]?(" "+u[h+2]).slice(1):null;switch(e){case"BYTERANGE":w?S.setByteRange(n,w):S.setByteRange(n);break;case"PROGRAM-DATE-TIME":S.rawProgramDateTime=n,S.tagList.push(["PROGRAM-DATE-TIME",n]),-1===T&&(T=d.length);break;case"PLAYLIST-TYPE":l.type&&Rv(l,e,u),l.type=n.toUpperCase();break;case"MEDIA-SEQUENCE":0!==l.startSN?Rv(l,e,u):d.length>0&&Pv(l,e,u),g=l.startSN=parseInt(n);break;case"SKIP":{l.skippedSegments&&Rv(l,e,u);const t=new Ug(n,l),r=t.decimalInteger("SKIPPED-SEGMENTS");if(_f(r)){l.skippedSegments+=r;for(let e=r;e--;)d.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&&Rv(l,e,u),l.targetduration=Math.max(parseInt(n),1);break;case"VERSION":null!==l.version&&Rv(l,e,u),l.version=parseInt(n);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":l.live||Rv(l,e,u),l.live=!1;break;case"#":(n||a)&&S.tagList.push(a?[n,a]:[n]);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,n]),E=1e3*parseInt(n),_f(E)?S.bitrate=E:E=0;break;case"DATERANGE":{const e=new Ug(n,l),t=new jg(e,l.dateRanges[e.ID],l.dateRangeTagCount);l.dateRangeTagCount++,t.isValid||l.skippedSegments?l.dateRanges[t.id]=t:np.warn(`Ignoring invalid DATERANGE tag: "${n}"`),S.tagList.push(["EXT-X-DATERANGE",n]);break}case"DEFINE":{const e=new Ug(n,l);"IMPORT"in e?Fg(l,e,s):Ng(l,e,t)}break;case"DISCONTINUITY-SEQUENCE":0!==l.startCC?Rv(l,e,u):d.length>0&&Pv(l,e,u),l.startCC=b=parseInt(n);break;case"KEY":{const e=Sv(n,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=qf({},f)),f[e.keyFormat]=e)}else np.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${n}"`);break}case"START":l.startTimeOffset=Tv(n);break;case"MAP":{const e=new Ug(n,l);if(S.duration){const t=new Ap(i,o);Lv(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;Lv(S,e,r,f),m=S,x=!0}m.cc=b;break}case"SERVER-CONTROL":p&&Rv(l,e,u),p=new Ug(n),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&&Rv(l,e,u);const t=new Ug(n);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 Ug(n,l),s=new kp(i,S,o,r,t);e.push(s),S.duration+=s.duration;break}case"PRELOAD-HINT":{const e=new Ug(n,l);l.preloadHint=e;break}case"RENDITION-REPORT":{const e=new Ug(n,l);l.renditionReports=l.renditionReports||[],l.renditionReports.push(e);break}default:np.warn(`line parsed but not handled: ${u}`)}}}w&&!w.relurl?(d.pop(),y-=w.duration,l.partList&&(l.fragmentHint=w)):l.partList&&(kv(S,w,c),S.cc=b,l.fragmentHint=S,f&&Iv(S,f,l)),l.targetduration||(l.playlistParsingError=new Error("Missing Target Duration"));const k=d.length,L=d[0],I=d[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}}(d,T),L&&c.unshift(L))}return l.fragmentHint&&(y+=l.fragmentHint.duration),l.totalduration=y,c.length&&l.dateRangeTagCount&&L&&Ev(c,l),l.endCC=b,l}}function Ev(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],n=t.live?1/0:t.totalduration,s=Object.keys(t.dateRanges);for(let o=s.length;o--;){const l=t.dateRanges[s[o]],d=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=wv(t,d,e,i,n);if(-1!==r){l.tagAnchor=t.fragments[r].ref;break}}}}function wv(e,t,r,i,n){const s=r[i];if(s){const o=s.programDateTime;if(t>=o||0===i){var a;if(t<=o+1e3*(((null==(a=r[i+1])?void 0:a.start)||n)-s.start)){const n=r[i].sn-e.startSN;if(n<0)return-1;const s=e.fragments;if(s.length>r.length){for(let a=(r[i+1]||s[s.length-1]).sn-e.startSN;a>n;a--){const e=s[a].programDateTime;if(t>=e&&t<e+1e3*s[a].duration)return a}}return n}}}return-1}function Sv(e,t,r){var i,n;const s=new Ug(e,r),a=null!=(i=s.METHOD)?i:"",o=s.URI,l=s.hexadecimalInteger("IV"),d=s.KEYFORMATVERSIONS,c=null!=(n=s.KEYFORMAT)?n:"identity";o&&s.IV&&!l&&np.error(`Invalid IV: ${s.IV}`);const u=o?bv.resolve(o,t):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new hv(a,u,c,h,l,s.KEYID)}function Tv(e){const t=new Ug(e).decimalFloatingPoint("TIME-OFFSET");return _f(t)?t:null}function xv(e,t){let r=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{const i=r.filter(t=>rm(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 Av(e,t,r){const i=t[r];i&&(e[r]=i)}function kv(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function Lv(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 Iv(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 Rv(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${r[0]})`)}function Pv(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${r[0]})`)}function Dv(e,t){const r=t.startPTS;if(_f(r)){let i,n=0;t.sn>e.sn?(n=r-e.start,i=e):(n=e.start-r,i=t),i.duration!==n&&i.setDuration(n)}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 Cv(e,t,r,i,n,s,a){i-r<=0&&(a.warn("Fragment should have a positive duration",t),i=r+t.duration,s=n+t.duration);let o=r,l=i;const d=t.startPTS,c=t.endPTS;if(_f(d)){const u=Math.abs(d-r);e&&u>e.totalduration?a.warn(`media timestamps and playlist times differ by ${u}s for level ${t.level} ${e.url}`):_f(t.deltaPTS)?t.deltaPTS=Math.max(u,t.deltaPTS):t.deltaPTS=u,o=Math.max(r,d),r=Math.min(r,d),n=void 0!==t.startDTS?Math.min(n,t.startDTS):n,l=Math.min(i,c),i=Math.max(i,c),s=void 0!==t.endDTS?Math.max(s,t.endDTS):s}const u=r-t.start;0!==t.start&&t.setStart(r),t.setDuration(i-t.start),t.startPTS=r,t.maxStartPTS=o,t.startDTS=n,t.endPTS=i,t.minEndPTS=l,t.endDTS=s;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--)Dv(m[f],m[f-1]);for(f=p;f<m.length-1;f++)Dv(m[f],m[f+1]);return e.fragmentHint&&Dv(m[m.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,u}function _v(e,t,r){if(e===t)return;let i=null;const n=e.fragments;for(let e=n.length-1;e>=0;e--){const t=n[e].initSegment;if(t){i=t;break}}let s;e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,r){const i=t.skippedSegments,n=Math.max(e.startSN,t.startSN)-t.startSN,s=(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 d=n;d<=s;d++){const n=l[a+d];let s=o[d];if(i&&!s&&n&&(s=t.fragments[d]=n),n&&s){r(n,s,d,o);const i=n.relurl,a=s.relurl;if(i&&Gv(i,a))return void(t.playlistParsingError=Ov(`media sequence mismatch ${s.sn}:`,e,t,n,s));if(n.cc!==s.cc)return void(t.playlistParsingError=Ov(`discontinuity sequence mismatch (${n.cc}!=${s.cc})`,e,t,n,s))}}}(e,t,(e,r,n,a)=>{if((!t.startCC||t.skippedSegments)&&r.cc!==e.cc){const i=e.cc-r.cc;for(let e=n;e<a.length;e++)a[e].cc+=i;t.endCC=a[a.length-1].cc}_f(e.startPTS)&&_f(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&&(s=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:n}=t,s=qf({},e);n&&n.forEach(e=>{delete s[e]});const a=Object.keys(s).length;if(!a)return i;return Object.keys(i).forEach(e=>{const t=s[e],n=new jg(i[e].attr,t);n.isValid?(s[e]=n,t||(n.tagOrder+=a)):r.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${_m(i[e].attr)}"`)}),s}(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&&kv(o[e],o[e-1],i);Ev(i,t)}t.endCC=a[a.length-1].cc}if(!t.startCC){var l;const r=$v(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 n=0,s=e.length;n<=s;n++){const s=e[n],a=t[n+i];s&&a&&s.index===a.index&&s.fragment.sn===a.fragment.sn?r(s,a):i--}}}(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),s?Cv(t,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS,r):Mv(e,t),a.length&&(t.totalduration=t.edge-a[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;const d=t.advancedDateTime;if(t.advanced&&d){const e=t.edge;t.driftStart||(t.driftStartTime=d,t.driftStart=e),t.driftEndTime=d,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}function Ov(e,t,r,i,n){return new Error(`${e} ${n.url}\nPlaylist starting @${t.startSN}\n${t.m3u8}\n\nPlaylist starting @${r.startSN}\n${r.m3u8}`)}function Mv(e,t,r=!0){const i=t.startSN+t.skippedSegments-e.startSN,n=e.fragments,s=i>=0;let a=0;if(s&&i<n.length)a=n[i].start;else if(s&&t.startSN===e.endSN+1)a=e.fragmentEnd;else if(s&&r)a=e.fragmentStart+i*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;a=e.fragmentStart}Nv(t,a)}function Nv(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 Fv(e,t=1/0){let r=1e3*e.targetduration;if(e.updated){const i=e.fragments,n=4;if(i.length&&r*n>t){const e=1e3*i[i.length-1].duration;e<r&&(r=e)}}else r/=2;return Math.round(r)}function $v(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 Bv(e,t,r){return e?Uv(e.partList,t,r):null}function Uv(e,t,r){if(e)for(let i=e.length;i--;){const n=e[i];if(n.index===r&&n.fragment.sn===t)return n}return null}function zv(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 Gv(e,t){return!(e===t||!t)&&jv(e)!==jv(t)}function jv(e){return e.replace(/\?[^?]*$/,"")}function Hv(e,t){for(let i=0,n=e.length;i<n;i++){var r;if((null==(r=e[i])?void 0:r.cc)===t)return e[i]}return null}function Vv(e,t){const r=e.start+t;e.startPTS=r,e.setStart(r),e.endPTS=r+e.duration}function Wv(e,t){const r=t.fragments;for(let t=0,i=r.length;t<i;t++)Vv(r[t],e);t.fragmentHint&&Vv(t.fragmentHint,e),t.alignedSliding=!0}function Yv(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=Hv(t.fragments,r),n=Hv(e.fragments,r);if(!i||!n)return;np.log(`Aligning playlist at start of dicontinuity sequence ${r}`);Wv(i.start-n.start,e)}function Kv(e,t){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;const r=e.fragments,i=t.fragments;if(!r.length||!i.length)return;let n,s;const a=Math.min(t.endCC,e.endCC);t.startCC<a&&e.startCC<a&&(n=Hv(i,a),s=Hv(r,a)),n&&s||(n=i[Math.floor(i.length/2)],s=Hv(r,n.cc)||r[Math.floor(r.length/2)]);const o=n.programDateTime,l=s.programDateTime;if(!o||!l)return;Wv((l-o)/1e3-(s.start-n.start),e)}function qv(e,t,r){Xv(e,t,r),e.addEventListener(t,r)}function Xv(e,t,r){e.removeEventListener(t,r)}const Qv=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},Zv="STOPPED",Jv="IDLE",ey="KEY_LOADING",ty="FRAG_LOADING",ry="FRAG_LOADING_WAITING_RETRY",iy="WAITING_TRACK",ny="PARSING",sy="PARSED",ay="ENDED",oy="ERROR",ly="WAITING_INIT_PTS",dy="WAITING_LEVEL";class cy extends Rg{constructor(e,t,r,i,n){super(i,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Zv,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:n}=this,s=r?r.currentTime:0,a=Cg.bufferInfo(i||r,s,e.maxBufferHole),o=!a.len;if(this.log(`Media seeking to ${_f(s)?s.toFixed(3):s}, state: ${n}, ${o?"out of":"in"} buffer`),this.state===ay)this.resetLoadingState();else if(t){const r=e.maxFragLookUpTolerance,i=t.start-r,n=t.start+t.duration+r;if(o||n<a.start||i>a.end){const e=s>n;(s<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(s,1/0,this.playlistType,!0);if(s>this.lastCurrentTime&&(this.lastCurrentTime=s),!this.loadingParts){const e=Math.max(a.end,s),t=this.shouldLoadParts(this.getLevelDetails(),e);t&&(this.log(`LL-Part loading ON after seeking to ${s.toFixed(2)} with buffer @${e.toFixed(2)}`),this.loadingParts=t)}}this.hls.hasEnoughToStart||(this.log(`Setting ${o?"startPosition":"nextLoadPosition"} to ${s} for seek without enough to start`),this.nextLoadPosition=s,o&&(this.startPosition=s)),o&&this.state===Jv&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=n,this.hls=e,this.fragmentLoader=new Ag(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Tg(e.config)}registerListeners(){const{hls:e}=this;e.on($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.on($f.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.off($f.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===Zv)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=Zv}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 n=e.buffered;this.config.maxBufferHole&&n&&n.length>1&&(e=Cg.bufferedInfo(n,e.start,0));const s=e.nextStart;if(s&&s>i&&s<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 Cg.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;qv(r,"seeking",this.onMediaSeeking),qv(r,"ended",this.onMediaEnded);const i=this.config;this.levels&&i.autoStartLoad&&this.state===Zv&&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),Xv(i,"seeking",this.onMediaSeeking),Xv(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=Zv,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===ty||!this.fragCurrent&&t===ny)&&(this.fragmentTracker.removeFragment(r),this.state=Jv):("payload"in e&&(this.log(`Loaded ${r.type} sn: ${r.sn} of ${this.playlistLabel()} ${r.level}`),this.hls.trigger($f.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))}).catch(t=>{this.state!==Zv&&this.state!==oy&&(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)===ug){const t=e.type,i=this.getFwdBufferInfo(this.mediaBuffer,t),n=Math.max(e.duration,i?i.len:this.config.maxBufferLength),s=this.backtrackFragment;(1===(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(n,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)===hg&&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($f.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,n=r.decryptdata;if(i&&i.byteLength>0&&null!=n&&n.key&&n.iv&&Yg(n.method)){const s=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,Kg(n.method)).catch(e=>{throw t.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e}).then(i=>{const n=self.performance.now();return t.trigger($f.FRAG_DECRYPTED,{frag:r,payload:i,stats:{tstart:s,tdecrypt:n}}),e.payload=i,this.completeInitSegmentLoad(e)})}return this.completeInitSegmentLoad(e)}).catch(t=>{this.state!==Zv&&this.state!==oy&&(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!==Zv&&(this.state=Jv),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 n=e.tracks;if(n&&!t.encrypted&&(null!=(r=n.audio)&&r.encrypted||null!=(i=n.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($f.ERROR,{type:Nf.KEY_SYSTEM_ERROR,details:Ff.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?Qv(Cg.getBuffered(r)):"(detached)"})`),xp(e)){var i;if(e.type!==Vf){const t=e.elementaryStreams;if(!Object.keys(t).some(e=>!!t[e]))return void(this.state=Jv)}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=Jv}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:r,part:i,partsLoaded:n}=e,s=!n||0===n.length||n.some(e=>!e),a=new Pg(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!s);t.flush(a)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,i){var n;this.fragCurrent=e;const s=t.details;if(!this.levels||!s)throw new Error(`frag load aborted, missing level${s?"":" detail"}s`);let a=null;if(!e.encrypted||null!=(n=e.decryptdata)&&n.key)e.encrypted||(a=this.keyLoader.loadClear(e,s.encryptedFragments,this.startFragRequested),a&&this.log("[eme] blocking frag load until media-keys acquired"));else if(this.log(`Loading key for ${e.sn} of [${s.startSN}-${s.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=ey,this.fragCurrent=e,a=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger($f.KEY_LOADED,e),this.state===ey&&(this.state=Jv),e}),this.hls.trigger($f.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);const o=this.fragPrevious;if(xp(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&&xp(e)){const n=s.partList;if(n&&i){r>s.fragmentEnd&&s.fragmentHint&&(e=s.fragmentHint);const o=this.getNextPart(n,e,r);if(o>-1){const l=n[o];let d;return e=this.fragCurrent=l.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${l.index} (${o}/${n.length-1}) of ${this.fragInfo(e,!1,l)}) cc: ${e.cc} [${s.startSN}-${s.endSN}], target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=ty,d=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($f.FRAG_LOADING,{frag:e,part:l,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):d}if(!e.url||this.loadedEndOfParts(n,r))return Promise.resolve(null)}}var l;if(xp(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=s.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} ${"["+s.startSN+"-"+s.endSN+"]"}, target: ${parseFloat(r.toFixed(3))}`),_f(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=ty;const d=this.config.progressive&&e.type!==Vf;let c;return c=d&&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,d?i:void 0),a]).then(([e])=>(!d&&i&&i(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger($f.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c}doFragPartsLoad(e,t,r,i){return new Promise((n,s)=>{var a;const o=[],l=null==(a=r.details)?void 0:a.partList,d=t=>{this.fragmentLoader.loadPart(e,t,i).then(i=>{o[t.index]=i;const s=i.part;this.hls.trigger($f.FRAG_LOADED,i);const a=Bv(r.details,e.sn,t.index+1)||Uv(l,e.sn,t.index+1);if(!a)return n({frag:e,part:s,partsLoaded:o});d(a)}).catch(s)};d(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===Ff.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===Nf.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger($f.ERROR,t)}else this.hls.trigger($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==ny)return void(this.fragCurrent||this.state===Zv||this.state===oy||(this.state=Jv));const{frag:r,part:i,level:n}=t,s=self.performance.now();r.stats.parsing.end=s,i&&(i.stats.parsing.end=s);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,n,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var r;const n=e.partList[0];if(n.fragment.type===Vf)return!1;if(t>=n.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())>n.start-n.fragment.duration)return!0}}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:r}=this,{level:i,sn:n,part:s}=e;if(null==t||!t[i])return this.warn(`Levels object was unset while buffering fragment ${n} of ${this.playlistLabel()} ${i}. The current chunk will not be buffered.`),null;const a=t[i],o=a.details,l=s>-1?Bv(o,n,s):null,d=l?l.fragment:$v(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:a}):null}bufferFragmentData(e,t,r,i,n){if(this.state!==ny)return;const{data1:s,data2:a}=e;let o=s;if(a&&(o=Wp(s,a)),!o.length)return;const l=this.initPTS[t.cc],d=l?-l.baseTime/l.timescale:void 0,c={type:e.type,frag:t,part:r,chunkMeta:i,offset:d,parent:t.type,data:o};if(this.hls.trigger($f.BUFFER_APPENDING,c),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Cg.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);const r=t.currentTime,i=Cg.bufferInfo(t,r,0),n=e.duration,s=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),a=Math.max(Math.min(e.start-s,i.end-s),r+s);e.start-a>s&&this.flushMainBuffer(a,e.start)}getFwdBufferInfo(e,t){var r;const i=this.getLoadPosition();if(!_f(i))return null;const n=this.lastCurrentTime>i||null!=(r=this.media)&&r.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,i,t,n)}getFwdBufferInfoAtPos(e,t,r,i){const n=Cg.bufferInfo(e,t,i);if(0===n.len&&void 0!==n.nextStart){const s=this.fragmentTracker.getBufferedFrag(t,r);if(s&&(n.nextStart<=s.end||s.gap)){const r=Math.max(Math.min(n.nextStart,s.end)-t,i);return Cg.bufferInfo(e,t,r)}}return n}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),n=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return n>=i&&(r.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),!0)}getAppendedFrag(e,t=jf){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:n}=this,s=r[0].start,a=n.lowLatencyMode&&!!t.partList;let o=null;if(t.live){const r=n.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<s){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,n=o?(-1!==r&&r>=s?r:i)||o.start:e;this.log(`Setting startPosition to ${n} to match start frag at live edge. mainStart: ${r} liveSyncPosition: ${i} frag.start: ${null==(l=o)?void 0:l.start}`),this.startPosition=this.nextLoadPosition=n}}else e<=s&&(o=r[0]);if(!o){const r=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,r,t)}let d=this.filterReplacedPrimary(o,t);if(!d&&o){const e=o.sn-t.startSN;d=this.filterReplacedPrimary(r[e+1]||null,t)}return this.mapToInitFragWhenRequired(d)}isLoopLoading(e,t){const r=this.fragmentTracker.getState(e);return(r===fg||r===hg&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,i,n){let s=null;if(e.gap&&(s=this.getNextFragment(this.nextLoadPosition,t),s&&!s.gap&&r.nextStart)){const e=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i,0);if(null!==e&&r.len+e.len>=n){const e=s.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,s}get primaryPrefetch(){if(uy(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(uy(this.config)&&e.type!==Vf){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 n=null==r?void 0:r.playerQueue;if(n)for(let t=n.length;t--;){const r=n[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,n=!1,s=!0;for(let a=0,o=e.length;a<o;a++){const o=e[a];if(s=s&&!o.independent,i>-1&&r<o.start)break;const l=o.loaded;l?i=-1:(n||(o.independent||s)&&o.fragment===t)&&(o.fragment!==t&&this.warn(`Need buffer at ${r} but next unloaded part starts at ${o.start}`),i=a),n=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||!_f(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 n=e[i];if(Vm(t,r,n))return n}return null}(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){const n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){const s=t[n-e.startSN];r.cc===s.cc&&(i=s,this.log(`Live playlist, switching playlist, load frag with next SN: ${i.sn}`))}i||(i=Wm(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:n}=this,{fragments:s,endSN:a}=r;const{fragmentHint:o}=r,{maxFragLookUpTolerance:l}=i,d=r.partList,c=!!(this.loadingParts&&null!=d&&d.length&&o);let u;if(c&&!this.bitrateTest&&d[d.length-1].fragment.sn===o.sn&&(s=s.concat(o),a=o.sn),e<t){var h;u=jm(n,s,e,e<this.lastCurrentTime||e>t-l||null!=(h=this.media)&&h.paused||!this.startFragRequested?0:l)}else u=s[s.length-1];if(u){const e=u.sn-r.startSN,t=this.fragmentTracker.getState(u);if((t===fg||t===hg&&u.gap)&&(n=u),n&&u.sn===n.sn&&(!c||d[0].fragment.sn>u.sn||!r.live)){if(u.level===n.level){const t=s[e+1];u=u.sn<a&&this.fragmentTracker.getState(t)!==fg?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 n=e.fragmentStart,s=!t,a=e.alignedSliding&&_f(n);if(s||!a&&!n){!function(e,t){e&&(Yv(t,e),t.alignedSliding||Kv(t,e),t.alignedSliding||t.skippedSegments||Mv(e,t,!1))}(r,e);const n=e.fragmentStart;return this.log(`Live playlist sliding: ${n.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${i}`),n}return n}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 n=null!==this.startTimeOffset,s=n?this.startTimeOffset:e.startTimeOffset;null!==s&&_f(s)?(r=t+s,s<0&&(r+=e.edge),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Setting startPosition to ${r} for start time offset ${s} found in ${n?"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&&xp(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===ry)||(this.state=Jv)}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 n;if(this.fragContextChanged(i))return void this.warn(`Frag load error must match current frag to retry ${i.url} > ${null==(n=this.fragCurrent)?void 0:n.url}`);const s=t.details===Ff.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(i,!0);const a=t.errorAction;if(!a)return void(this.state=oy);const{action:o,flags:l,retryCount:d=0,retryConfig:c}=a,u=!!c,h=u&&o===ng,f=u&&!a.resolved&&l===ag,p=null==(r=this.hls.latestLevelDetails)?void 0:r.live;if(!h&&f&&xp(i)&&!i.endList&&p&&!qm(t))this.resetFragmentErrors(e),this.treatAsGap(i),a.resolved=!0;else if((h||f)&&d<c.maxNumRetry){var m;const r=eg(null==(m=t.response)?void 0:m.code),n=Qm(c,d);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+n,this.state=ry,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 ${d+1}/${c.maxNumRetry} in ${n}ms`)}else if(c){if(this.resetFragmentErrors(e),!(d<c.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${d})`);s||o===ig||(a.resolved=!0)}else this.state=o===rg?dy:oy;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,r=t===1/0;(!t||e>=t||r&&!eg(0))&&(r&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=Jv)}reduceLengthAndFlushBuffer(e){if(this.state===ny||this.state===sy){const t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);const s=!n;return s&&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(),s}return!1}resetFragmentErrors(e){e===Hf&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==Zv&&(this.state=Jv)}afterBufferFlushed(e,t,r){if(!e)return;const i=Cg.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===ay&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==Zv&&(this.state=Jv)}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 n=r.details;if(!n)return void this.warn("level.details undefined");if(!Object.keys(e.elementaryStreams).reduce((t,s)=>{const a=e.elementaryStreams[s];if(a){const o=a.endPTS-a.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${e.sn} ${s} duration reliably (${o})`),t||!1;const l=i?0:Cv(n,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS,this);return this.hls.trigger($f.LEVEL_PTS_UPDATED,{details:n,level:r,drift:l,type:s,frag:e,start:a.startPTS,end:a.endPTS}),!0}return t},!1)){var s;const t=null===(null==(s=this.transmuxer)?void 0:s.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($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.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=sy,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger($f.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===jf?"level":"track"}fragInfo(e,t=!0,r){var i,n;return`${this.playlistLabel()} ${e.level} (${r?"part":"frag"}:[${(null!=(i=t&&!r?e.startPTS:(r||e).start)?i:NaN).toFixed(3)}-${(null!=(n=t&&!r?e.endPTS:(r||e).end)?n: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 uy(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}class hy{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 n=e[t];r.set(n,i),i+=n.length}return r}(e,t),this.reset(),r):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}var fy,py={exports:{}};var my=(fy||(fy=1,function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,i,s,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new n(i,s||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,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},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 n=0,s=i.length,a=new Array(s);n<s;n++)a[n]=i[n].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,n,s,a){var o=r?r+e:e;if(!this._events[o])return!1;var l,d,c=this._events[o],u=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,i),!0;case 4:return c.fn.call(c.context,t,i,n),!0;case 5:return c.fn.call(c.context,t,i,n,s),!0;case 6:return c.fn.call(c.context,t,i,n,s,a),!0}for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c.fn.apply(c.context,l)}else{var h,f=c.length;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),u){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,i);break;case 4:c[d].fn.call(c[d].context,t,i,n);break;default:if(!l)for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];c[d].fn.apply(c[d].context,l)}}return!0},o.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,n){var s=r?r+e:e;if(!this._events[s])return this;if(!t)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||a(this,s);else{for(var l=0,d=[],c=o.length;l<c;l++)(o[l].fn!==t||n&&!o[l].once||i&&o[l].context!==i)&&d.push(o[l]);d.length?this._events[s]=1===d.length?d[0]:d:a(this,s)}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}(py)),py.exports),gy=cp(my);const vy="1.6.15",yy={};function by(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 Ey(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 wy(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 Sy(e,t){const r=t;let i=0;for(;Ey(e,t);){i+=10;i+=wy(e,t+6),by(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(r,r+i)}function Ty(e,t){return 255===e[t]&&240==(246&e[t+1])}function xy(e,t){return 1&e[t+1]?7:9}function Ay(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function ky(e,t){return t+1<e.length&&Ty(e,t)}function Ly(e,t){if(ky(e,t)){const r=xy(e,t);if(t+r>=e.length)return!1;const i=Ay(e,t);if(i<=r)return!1;const n=t+i;return n===e.length||ky(e,n)}return!1}function Iy(e,t,r,i,n){if(!e.samplerate){const s=function(e,t,r,i){const n=t[r+2],s=n>>2&15;if(s>12){const t=new Error(`invalid ADTS sampling index:${s}`);return void e.emit($f.ERROR,$f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.FRAG_PARSING_ERROR,fatal:!0,error:t,reason:t.message})}const a=1+(n>>6&3),o=t[r+3]>>6&3|(1&n)<<2,l="mp4a.40."+a,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][s];let c=s;5!==a&&29!==a||(c-=3);const u=[a<<3|(14&c)>>1,(1&c)<<7|o<<3];return np.log(`manifest codec:${i}, parsed codec:${l}, channels:${o}, rate:${d} (ADTS object type:${a} sampling index:${s})`),{config:u,samplerate:d,channelCount:o,codec:l,parsedCodec:l,manifestCodec:i}}(t,r,i,n);if(!s)return;qf(e,s)}}function Ry(e){return 9216e4/e}function Py(e,t,r,i,n){const s=i+n*Ry(e.samplerate),a=function(e,t){const r=xy(e,t);if(t+r<=e.length){const i=Ay(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);let o;if(a){const{frameLength:i,headerLength:n}=a,l=n+i,d=Math.max(0,r+l-t.length);d?(o=new Uint8Array(l-n),o.set(t.subarray(r+n,t.length),0)):o=t.subarray(r+n,r+l);const c={unit:o,pts:s};return d||e.samples.push(c),{sample:c,length:l,missing:d}}const l=t.length-r;o=new Uint8Array(l),o.set(t.subarray(r,t.length),0);return{sample:{unit:o,pts:s},length:l,missing:-1}}function Dy(e,t){return Ey(e,t)&&wy(e,t+6)+10<=e.length-t}function Cy(e,t=0,r=1/0){return function(e,t,r,i){const n=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e);let s=1;"BYTES_PER_ELEMENT"in i&&(s=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)/s,l=(a+t)/s,d=Math.floor(Math.max(0,Math.min(l,o))),c=Math.floor(Math.min(d+Math.max(r,0),o));var u;return new i(n,d,c-d)}(e,t,r,Uint8Array)}function _y(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=op(Cy(e.data,1,r)),n=e.data[2+r],s=e.data.subarray(3+r).indexOf(0);if(-1===s)return;const a=op(Cy(e.data,3+r,s));let o;return o="--\x3e"===i?op(Cy(e.data,4+r+s)):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+s)),t.mimeType=i,t.pictureType=n,t.description=a,t.data=o,t}function Oy(e){return"PRIV"===e.type?function(e){if(e.size<2)return;const t=op(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=op(e.data.subarray(t),!0);t+=r.length+1;const i=op(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=op(e.data);return{key:e.type,info:"",data:t}}(e):"APIC"===e.type?_y(e):function(e){if(e.size<2)return;if("TXXX"===e.type){let t=1;const r=op(e.data.subarray(t),!0);t+=r.length+1;const i=op(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=op(e.data.subarray(1));return{key:e.type,info:"",data:t}}(e)}function My(e){const t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=wy(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}function Ny(e){let t=0;const r=[];for(;Ey(e,t);){const i=wy(e,t+6);e[t+5]>>6&1&&(t+=10),t+=10;const n=t+i;for(;t+10<n;){const i=My(e.subarray(t)),n=Oy(i);n&&r.push(n),t+=i.size+10}by(e,t)&&(t+=10)}return r}function Fy(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function $y(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 By(e){const t=Ny(e);for(let e=0;e<t.length;e++){const r=t[e];if(Fy(r))return $y(r)}}let Uy=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 zy(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class Gy{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=Wp(this.cachedData,e),this.cachedData=null);let r,i=Sy(e,0),n=i?i.length:0;const s=this._audioTrack,a=this._id3Track,o=i?By(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&_f(o))&&(this.basePTS=jy(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:Uy.audioId3,duration:Number.POSITIVE_INFINITY});n<l;){if(this.canParse(e,n)){const t=this.appendFrame(s,e,n);t?(this.frameIndex++,this.lastPTS=t.sample.pts,n+=t.length,r=n):n=l}else Dy(e,n)?(i=Sy(e,n),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Uy.audioId3,duration:Number.POSITIVE_INFINITY}),n+=i.length,r=n):n++;if(n===l&&r!==l){const t=e.slice(r);this.cachedData?this.cachedData=Wp(this.cachedData,t):this.cachedData=t}}return{audioTrack:s,videoTrack:zy(),id3Track:a,textTrack:zy()}}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:zy(),id3Track:this._id3Track,textTrack:zy()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const jy=(e,t,r)=>{if(_f(e))return 90*e;return 9e4*t+(r?9e4*r.baseTime/r.timescale:0)};let Hy=null;const Vy=[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],Wy=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Yy=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Ky=[0,1,1,4];function qy(e,t,r,i,n){if(r+24>t.length)return;const s=Xy(t,r);if(s&&r+s.frameLength<=t.length){const a=i+n*(9e4*s.samplesPerFrame/s.sampleRate),o={unit:t.subarray(r,r+s.frameLength),pts:a,dts:a};return e.config=[],e.channelCount=s.channelCount,e.samplerate=s.sampleRate,e.samples.push(o),{sample:o,length:s.frameLength,missing:0}}}function Xy(e,t){const r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,s=e[t+2]>>2&3;if(1!==r&&0!==n&&15!==n&&3!==s){const a=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*Vy[14*(3===r?3-i:3===i?3:4)+n-1],d=Wy[3*(3===r?0:2===r?1:2)+s],c=3===o?1:2,u=Yy[r][i],h=Ky[i],f=8*u*h,p=Math.floor(u*l/d+a)*h;if(null===Hy){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Hy=e?parseInt(e[1]):0}return!!Hy&&Hy<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:d,channelCount:c,frameLength:p,samplesPerFrame:f}}}function Qy(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function Zy(e,t){return t+1<e.length&&Qy(e,t)}function Jy(e,t){if(t+1<e.length&&Qy(e,t)){const r=4,i=Xy(e,t);let n=r;null!=i&&i.frameLength&&(n=i.frameLength);const s=t+n;return s===e.length||Zy(e,s)}return!1}const eb=(e,t)=>{let r=0,i=5;t+=i;const n=new Uint32Array(1),s=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=e[t];const o=Math.min(i,8),l=8-o;s[0]=4278190080>>>24+l<<l,n[0]=(a[0]&s[0])>>l,r=r?r<<o|n[0]:n[0],t+=1,i-=o}return r};class tb extends Gy{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=rb(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=Sy(e,0);if(!t)return!1;const r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==By(t)&&eb(e,r)<16}}function rb(e,t,r,i,n){if(r+8>t.length)return-1;if(11!==t[r]||119!==t[r+1])return-1;const s=t[r+4]>>6;if(s>=3)return-1;const a=[48e3,44100,32e3][s],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+s];if(r+l>t.length)return-1;const d=t[r+6]>>5;let c=0;2===d?c+=2:(1&d&&1!==d&&(c+=2),4&d&&(c+=2));const u=(t[r+6]<<8|t[r+7])>>12-c&1,h=[2,1,2,3,3,4,4,5][d]+u,f=t[r+5]>>3,p=7&t[r+5],m=new Uint8Array([s<<6|f<<1|p>>2,(3&p)<<6|d<<3|u<<2|o>>4,o<<4&224]),g=i+n*(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 ib=/\/emsg[-/]ID3/i;function nb(e,t){return _f(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}class sb{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Tg(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,yg)}decryptAacSample(e,t,r){const i=e[t].unit;if(i.length<=16)return;const n=i.subarray(16,i.length-i.length%16),s=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(s).then(n=>{const s=new Uint8Array(n);i.set(s,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,n){const s=Qp(n.data),a=this.getAvcEncryptedData(s);this.decryptBuffer(a.buffer).then(a=>{n.data=this.getAvcDecryptedUnit(s,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 n=e[t].units;for(;!(r>=n.length);r++){const s=n[r];if(!(s.data.length<=48||1!==s.type&&5!==s.type||(this.decryptAvcSample(e,t,r,i,s),this.decrypter.isSync())))return}}}}class ab{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 n=e.naluState||0;const s=n,a=[];let o,l,d,c=0,u=-1,h=0;for(-1===n&&(u=0,h=this.getNALuType(t,0),n=0,c=1);c<i;)if(o=t[c++],n)if(1!==n)if(o)if(1===o){if(l=c-n-1,u>=0){const e={data:t.subarray(u,l),type:h};a.push(e)}else{const r=this.getLastNalUnit(e.samples);r&&(s&&c<=4-s&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-s)),l>0&&(r.data=Wp(r.data,t.subarray(0,l)),r.state=0))}c<i?(d=this.getNALuType(t,c),u=c,h=d,n=0):n=-1}else n=0;else n=3;else n=o?0:2;else n=o?0:1;if(u>=0&&n>=0){const e={data:t.subarray(u,i),type:h,state:n};a.push(e)}if(0===a.length){const r=this.getLastNalUnit(e.samples);r&&(r.data=Wp(r.data,t))}return e.naluState=n,a}}class ob{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),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");i.set(e.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n}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&&np.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 lb extends ab{parsePES(e,t,r,i){const n=this.parseNALu(e,r.data,i);let s,a=this.VideoSample,o=!1;r.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),n.forEach(i=>{var n,l;switch(i.type){case 1:{let t=!1;s=!0;const n=i.data;if(o&&n.length>4){const e=this.readSliceType(n);2!==e&&4!==e&&7!==e&&9!==e||(t=!0)}var d;if(t)null!=(d=a)&&d.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:s=!0,null!=(n=a)&&n.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:s=!0,Xp(i.data,1,r.pts,t.samples);break;case 7:{var c,u;s=!0,o=!0;const t=i.data,r=this.readSPS(t);if(!e.sps||e.width!==r.width||e.height!==r.height||(null==(c=e.pixelRatio)?void 0:c[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 n="avc1.";for(let e=0;e<3;e++){let t=i[e].toString(16);t.length<2&&(t="0"+t),n+=t}e.codec=n}break}case 8:s=!0,e.pps=[i.data];break;case 9:s=!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:s=!0;break;default:s=!1}if(a&&s){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 ob(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let r,i=8,n=8;for(let s=0;s<e;s++)0!==n&&(r=t.readEG(),n=(i+r+256)%256),i=0===n?i:n}readSPS(e){const t=new ob(e);let r,i,n,s=0,a=0,o=0,l=0;const d=t.readUByte.bind(t),c=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);d();const v=d();if(c(5),f(3),d(),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,n=0;n<i;n++)h()&&g(n<6?16:64,t)}m();const y=u();if(0===y)u();else if(1===y)for(f(1),p(),p(),r=u(),n=0;n<r;n++)p();m(),f(1);const b=u(),E=u(),w=c(1);0===w&&f(1),f(1),h()&&(s=u(),a=u(),o=u(),l=u());let S=[1,1];if(h()&&h()){switch(d()){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=[d()<<8|d(),d()<<8|d()]}}return{width:Math.ceil(16*(b+1)-2*s-2*a),height:(2-w)*(E+1)*16-(w?2:4)*(o+l),pixelRatio:S}}}class db extends ab{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,r,i){const n=this.parseNALu(e,r.data,i);let s,a=this.VideoSample,o=!1;r.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),n.forEach(i=>{var n,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,s=!0;break;case 16:case 17:case 18:case 21:var d;if(s=!0,o)null!=(d=a)&&d.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:s=!0,null!=(n=a)&&n.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:s=!0,Xp(i.data,2,r.pts,t.samples);break;case 32:s=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=qf(e.params,this.readVPS(i.data)),this.initVPS=i.data),e.vps=[i.data];break;case 33:if(s=!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(s=!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:s=!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:s=!1}if(a&&s){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 ob(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 ob(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const r=t.readBits(3);t.readBoolean();const i=t.readBits(2),n=t.readBoolean(),s=t.readBits(5),a=t.readUByte(),o=t.readUByte(),l=t.readUByte(),d=t.readUByte(),c=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 D=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<=D;e++){const e=t.readBoolean();let i=!1;e||(i=t.readBoolean()),(e||i)&&r++}D=r}else{const e=t.readUEG(),r=t.readUEG();D=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 C=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 n=!1;(e||i)&&(n=t.readBoolean(),n&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),n&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let s=0;s<=r;s++){M=t.readBoolean();let r=!1;M||t.readBoolean()?t.readEG():r=t.readBoolean();const s=r?1:t.readUEG()+1;if(e)for(let e=0;e<s;e++)t.readUEG(),t.readUEG(),n&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(i)for(let e=0;e<s;e++)t.readUEG(),t.readUEG(),n&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),C=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|d;let j=0;for(let e=0;e<32;e++)j=(j|(G>>e&1)<<31-e)>>>0;let H=j.toString(16);1===s&&"2"===H&&(H="6");return{codecString:`hvc1.${z}${s}.${H}.${n?"H":"L"}${g}.B0`,params:{general_tier_flag:n,general_profile_idc:s,general_profile_space:i,general_profile_compatibility_flags:[a,o,l,d],general_constraint_indicator_flags:[c,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:C,chroma_format_idc:b,frame_rate:{fixed:M,fps:F/N}},width:B,height:U,pixelRatio:[_,O]}}readPPS(e){const t=new ob(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 n=1;return i&&r?n=0:i?n=3:r&&(n=2),{parallelismType:n}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const cb=188;class ub{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=ub.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-cb)+1,i=0;for(;i<r;){let n=!1,s=-1,a=0;for(let o=i;o<t;o+=cb){if(71!==e[o]||t-o!==cb&&71!==e[o+cb]){if(a)return-1;break}if(a++,-1===s&&(s=o,0!==s&&(r=Math.min(s+18612,e.length-cb)+1)),n||(n=0===hb(e,o)),n&&a>1&&(0===s&&a>2||o+cb>r))return s}i++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:Pp[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=ub.createTrack("video"),this._videoTrack.duration=i,this._audioTrack=ub.createTrack("audio",i),this._id3Track=ub.createTrack("id3"),this._txtTrack=ub.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 n;r||(this.sampleAes=null);const s=this._videoTrack,a=this._audioTrack,o=this._id3Track,l=this._txtTrack;let d=s.pid,c=s.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=Wp(this.remainderData,e)).length,this.remainderData=null),y<cb&&!i)return this.remainderData=e,{audioTrack:a,videoTrack:s,id3Track:o,textTrack:l};const b=Math.max(0,ub.syncOffset(e));y-=(y-b)%cb,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+=cb)if(71===e[t]){const i=!!(64&e[t+1]),y=hb(e,t);let E;if((48&e[t+3])>>4>1){if(E=t+5+e[t+4],E===t+cb)continue}else E=t+4;switch(y){case d:i&&(c&&(n=vb(c,this.logger))&&(this.readyVideoParser(s.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(s,l,n,!1)),c={data:[],size:0}),c&&(c.data.push(e.subarray(E,t+cb)),c.size+=t+cb-E);break;case u:if(i){if(f&&(n=vb(f,this.logger)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,n);break;case"mp3":this.parseMPEGPES(a,n);break;case"ac3":this.parseAC3PES(a,n)}f={data:[],size:0}}f&&(f.data.push(e.subarray(E,t+cb)),f.size+=t+cb-E);break;case h:i&&(p&&(n=vb(p,this.logger))&&this.parseID3PES(o,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(E,t+cb)),p.size+=t+cb-E);break;case 0:i&&(E+=e[E]+1),v=this._pmtId=fb(e,E);break;case v:{i&&(E+=e[E]+1);const n=pb(e,E,this.typeSupported,r,this.observer,this.logger);d=n.videoPid,d>0&&(s.pid=d,s.segmentCodec=n.segmentVideoCodec),u=n.audioPid,u>0&&(a.pid=u,a.segmentCodec=n.segmentAudioCodec),h=n.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&&mb(this.observer,new Error(`Found ${E} TS packet/s that do not start with 0x47`),void 0,this.logger),s.pesData=c,a.pesData=f,o.pesData=p;const w={audioTrack:a,videoTrack:s,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:n}=e,s=r.pesData,a=t.pesData,o=i.pesData;let l;if(s&&(l=vb(s,this.logger))?(this.readyVideoParser(r.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(r,n,l,!0),r.pesData=null)):r.pesData=s,a&&(l=vb(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=vb(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),n=this.sampleAes=new sb(this.observer,this.config,t);return this.decrypt(i,n)}readyVideoParser(e){null===this.videoParser&&("avc"===e?this.videoParser=new lb:"hevc"===e&&(this.videoParser=new db))}decrypt(e,t){return new Promise(r=>{const{audioTrack:i,videoTrack:n}=e;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.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 n,s,a,o=t.data;if(i){this.aacOverFlow=null;const t=i.missing,n=i.sample.unit.byteLength;if(-1===t)o=Wp(i.sample.unit,o);else{const s=n-t;i.sample.unit.set(o.subarray(0,t),s),e.samples.push(i.sample),r=i.missing}}for(n=r,s=o.length;n<s-1&&!ky(o,n);n++);if(n!==r){let e;const t=n<s-1;if(e=t?`AAC PES did not start with ADTS header,offset:${n}`:"No ADTS header found in AAC PES",mb(this.observer,new Error(e),t,this.logger),!t)return}if(Iy(e,this.observer,o,n,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!i)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");{const t=Ry(e.samplerate);a=i.sample.pts+t}}let l,d=0;for(;n<s;){if(l=Py(e,o,n,a,d),n+=l.length,l.missing){this.aacOverFlow=l;break}for(d++;n<s-1&&!ky(o,n);n++);}}parseMPEGPES(e,t){const r=t.data,i=r.length;let n=0,s=0;const a=t.pts;if(void 0!==a)for(;s<i;)if(Zy(r,s)){const t=qy(e,r,s,a,n);if(!t)break;s+=t.length,n++}else s++;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 n=r.length;let s,a=0,o=0;for(;o<n&&(s=rb(e,r,o,i,a++))>0;)o+=s}}parseID3PES(e,t){if(void 0===t.pts)return void this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");const r=qf({},t,{type:this._videoTrack?Uy.emsg:Uy.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}}function hb(e,t){return((31&e[t+1])<<8)+e[t+2]}function fb(e,t){return(31&e[t+10])<<8|e[t+11]}function pb(e,t,r,i,n,s){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=hb(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){gb("ADTS AAC",s);break}case 15:-1===a.audioPid&&(a.audioPid=o);break;case 21:-1===a.id3Pid&&(a.id3Pid=o);break;case 219:if(!i){gb("H.264",s);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"):s.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){gb("AC-3",s);break}case 129:r.ac3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="ac3"):s.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===a.audioPid&&l>0){let i=t+5,n=l;for(;n>2;){if(106===e[i])!0!==r.ac3?s.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,n-=t}}break;case 194:case 135:return mb(n,new Error("Unsupported EC-3 in M2TS found"),void 0,s),a;case 36:-1===a.videoPid&&(a.videoPid=o,a.segmentVideoCodec="hevc",s.log("HEVC in M2TS found"))}t+=l+5}return a}function mb(e,t,r,i){i.warn(`parsing error: ${t.message}`),e.emit($f.ERROR,$f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function gb(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function vb(e,t){let r,i,n,s,a,o=0;const l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=Wp(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 d=r[7];192&d&&(s=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&d?(a=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2,s-a>54e5&&(t.warn(`${Math.round((s-a)/9e4)}s delta between PTS and DTS, align them`),s=a)):a=s),n=r[8];let c=n+9;if(e.size<=c)return null;e.size-=c;const u=new Uint8Array(e.size);for(let e=0,t=l.length;e<t;e++){r=l[e];let t=r.byteLength;if(c){if(c>t){c-=t;continue}r=r.subarray(c),t-=c,c=0}u.set(r,o),o+=t}return i&&(i-=n+3),{data:u,pts:s,dts:a,len:i}}return null}class yb{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 bb=Math.pow(2,32)-1;class Eb{static init(){let e;for(e in Eb.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:[]},Eb.types)Eb.types.hasOwnProperty(e)&&(Eb.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]);Eb.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]),n=new Uint8Array([0,0,0,0,0,0,0,0]);Eb.STTS=Eb.STSC=Eb.STCO=n,Eb.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Eb.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Eb.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),Eb.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const s=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),o=new Uint8Array([0,0,0,1]);Eb.FTYP=Eb.box(Eb.types.ftyp,s,o,s,a),Eb.DINF=Eb.box(Eb.types.dinf,Eb.box(Eb.types.dref,i))}static box(e,...t){let r=8,i=t.length;const n=i;for(;i--;)r+=t[i].byteLength;const s=new Uint8Array(r);for(s[0]=r>>24&255,s[1]=r>>16&255,s[2]=r>>8&255,s[3]=255&r,s.set(e,4),i=0,r=8;i<n;i++)s.set(t[i],r),r+=t[i].byteLength;return s}static hdlr(e){return Eb.box(Eb.types.hdlr,Eb.HDLR_TYPES[e])}static mdat(e){return Eb.box(Eb.types.mdat,e)}static mdhd(e,t){t*=e;const r=Math.floor(t/(bb+1)),i=Math.floor(t%(bb+1));return Eb.box(Eb.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 Eb.box(Eb.types.mdia,Eb.mdhd(e.timescale||0,e.duration||0),Eb.hdlr(e.type),Eb.minf(e))}static mfhd(e){return Eb.box(Eb.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?Eb.box(Eb.types.minf,Eb.box(Eb.types.smhd,Eb.SMHD),Eb.DINF,Eb.stbl(e)):Eb.box(Eb.types.minf,Eb.box(Eb.types.vmhd,Eb.VMHD),Eb.DINF,Eb.stbl(e))}static moof(e,t,r){return Eb.box(Eb.types.moof,Eb.mfhd(e),Eb.traf(r,t))}static moov(e){let t=e.length;const r=[];for(;t--;)r[t]=Eb.trak(e[t]);return Eb.box.apply(null,[Eb.types.moov,Eb.mvhd(e[0].timescale||0,e[0].duration||0)].concat(r).concat(Eb.mvex(e)))}static mvex(e){let t=e.length;const r=[];for(;t--;)r[t]=Eb.trex(e[t]);return Eb.box.apply(null,[Eb.types.mvex,...r])}static mvhd(e,t){t*=e;const r=Math.floor(t/(bb+1)),i=Math.floor(t%(bb+1)),n=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 Eb.box(Eb.types.mvhd,n)}static sdtp(e){const t=e.samples||[],r=new Uint8Array(4+t.length);let i,n;for(i=0;i<t.length;i++)n=t[i].flags,r[i+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return Eb.box(Eb.types.sdtp,r)}static stbl(e){return Eb.box(Eb.types.stbl,Eb.stsd(e),Eb.box(Eb.types.stts,Eb.STTS),Eb.box(Eb.types.stsc,Eb.STSC),Eb.box(Eb.types.stsz,Eb.STSZ),Eb.box(Eb.types.stco,Eb.STCO))}static avc1(e){let t,r,i,n=[],s=[];for(t=0;t<e.sps.length;t++)r=e.sps[t],i=r.byteLength,n.push(i>>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(r));for(t=0;t<e.pps.length;t++)r=e.pps[t],i=r.byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(r));const a=Eb.box(Eb.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|e.sps.length].concat(n).concat([e.pps.length]).concat(s))),o=e.width,l=e.height,d=e.pixelRatio[0],c=e.pixelRatio[1];return Eb.box(Eb.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,Eb.box(Eb.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Eb.box(Eb.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,c>>24,c>>16&255,c>>8&255,255&c])))}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 Eb.box(Eb.types.mp4a,Eb.audioStsd(e),Eb.box(Eb.types.esds,Eb.esds(e)))}static mp3(e){return Eb.box(Eb.types[".mp3"],Eb.audioStsd(e))}static ac3(e){return Eb.box(Eb.types["ac-3"],Eb.audioStsd(e),Eb.box(Eb.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if("audio"===e.type){if("aac"===t)return Eb.box(Eb.types.stsd,Eb.STSD,Eb.mp4a(e));if("ac3"===t&&e.config)return Eb.box(Eb.types.stsd,Eb.STSD,Eb.ac3(e));if("mp3"===t&&"mp3"===e.codec)return Eb.box(Eb.types.stsd,Eb.STSD,Eb.mp3(e))}else{if(!e.pps||!e.sps)throw new Error("video track missing pps or sps");if("avc"===t)return Eb.box(Eb.types.stsd,Eb.STSD,Eb.avc1(e));if("hevc"===t&&e.vps)return Eb.box(Eb.types.stsd,Eb.STSD,Eb.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,n=e.height||0,s=Math.floor(r/(bb+1)),a=Math.floor(r%(bb+1));return Eb.box(Eb.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,s>>24,s>>16&255,s>>8&255,255&s,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,n>>8&255,255&n,0,0]))}static traf(e,t){const r=Eb.sdtp(e),i=e.id,n=Math.floor(t/(bb+1)),s=Math.floor(t%(bb+1));return Eb.box(Eb.types.traf,Eb.box(Eb.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),Eb.box(Eb.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s])),Eb.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,Eb.box(Eb.types.trak,Eb.tkhd(e),Eb.mdia(e))}static trex(e){const t=e.id;return Eb.box(Eb.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,n=12+16*i,s=new Uint8Array(n);let a,o,l,d,c,u;for(t+=8+n,s.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,d=o.size,c=o.flags,u=o.cts,s.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,d>>>24&255,d>>>16&255,d>>>8&255,255&d,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,61440&c.degradPrio,15&c.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*a);return Eb.box(Eb.types.trun,s)}static initSegment(e){Eb.types||Eb.init();const t=Eb.moov(e);return Wp(Eb.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 n=i.length;for(let e=0;e<r.length;e+=1){n+=3;for(let t=0;t<r[e].length;t+=1)n+=2+r[e][t].length}const s=new Uint8Array(n);s.set(i,0),n=i.length;const a=r.length-1;for(let e=0;e<r.length;e+=1){s.set(new Uint8Array([32+e|(e===a?128:0),0,r[e].length]),n),n+=3;for(let t=0;t<r[e].length;t+=1)s.set(new Uint8Array([r[e][t].length>>8,255&r[e][t].length]),n),n+=2,s.set(r[e][t],n),n+=r[e][t].length}const o=Eb.box(Eb.types.hvcC,s),l=e.width,d=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return Eb.box(Eb.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,d>>8&255,255&d,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,Eb.box(Eb.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Eb.box(Eb.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,u>>24,u>>16&255,u>>8&255,255&u])))}}Eb.types=void 0,Eb.HDLR_TYPES=void 0,Eb.STTS=void 0,Eb.STSC=void 0,Eb.STCO=void 0,Eb.STSZ=void 0,Eb.VMHD=void 0,Eb.SMHD=void 0,Eb.STSD=void 0,Eb.FTYP=void 0,Eb.DINF=void 0;function wb(e,t,r=1,i=!1){const n=e*t*r;return i?Math.round(n):n}function Sb(e,t=!1){return wb(e,1e3,1/9e4,t)}function Tb(e){const{baseTime:t,timescale:r,trackId:i}=e;return`${t/r} (${t}/${r}) trackId: ${i}`}let xb,Ab=null,kb=null;function Lb(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 Ib extends Zf{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===Ab){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ab=e?parseInt(e[1]):0}if(null===kb){const e=navigator.userAgent.match(/Safari\/(\d+)/i);kb=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?Tb(t):t} > ${e?Tb(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 n=i.pts,s=n-e;return s<-4294967296&&(t=!0,n=Rb(n,r),s=n-e),s>0?e:n},r);return t&&this.debug("PTS rollover detected"),i}remux(e,t,r,i,n,s,a,o){let l,d,c,u,h,f,p=n,m=n;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||(c=this.generateIS(e,t,n,s));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=(Rb(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"),c=this.generateIS(e,t,n,s)),d=this.remuxAudio(e,p,this.isAudioContiguous,s,v||E||o===Hf?m:void 0),E){const i=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),c=this.generateIS(e,t,n,s)),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=Pb(r,n,this._initPTS,this._initDTS)),i.samples.length&&(u=Db(i,n,this._initPTS))),{audio:d,video:l,initSegment:c,independent:f,text:u,id3:h}}computeInitPts(e,t,r,i){const n=Math.round(r*t);let s=Rb(e,n);if(s<n+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(n-s)/t} ${i}`);s<n+t;)s+=8589934592;return s-n}generateIS(e,t,r,i){const n=e.samples,s=t.samples,a=this.typeSupported,o={},l=this._initPTS;let d,c,u,h=!l||i,f="audio/mp4",p=-1;if(h&&(d=c=1/0),e.config&&n.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):Eb.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(p=e.id,u=e.inputTimeScale,l&&u===l.timescale?h=!1:d=c=this.computeInitPts(n[0].pts,u,r,"audio"))}if(t.sps&&t.pps&&s.length){if(t.timescale=t.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Eb.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(s),t=Rb(s[0].dts,e),i=this.computeInitPts(t,u,r,"video"),n=this.computeInitPts(e,u,r,"video");c=Math.min(c,i),d=Math.min(d,n)}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} ${d/u} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${r} offset: ${d/u} (${d}/${u}) trackId: ${p}`),this._initPTS={baseTime:d,timescale:u,trackId:p},this._initDTS={baseTime:c,timescale:u,trackId:p}):d=u=void 0,{tracks:o,initPTS:d,timescale:u,trackId:p}}remuxVideo(e,t,r,i){const n=e.inputTimeScale,s=e.samples,a=[],o=s.length,l=this._initPTS,d=l.baseTime*n/l.timescale;let c,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=d+t*n,i=s[0].pts-Rb(s[0].dts,s[0].pts);Ab&&null!==h&&Math.abs(e-i-(h+d))<15e3?r=!0:h=e-i-d}const y=h+d;for(let e=0;e<o;e++){const t=s[e];t.pts=Rb(t.pts,y),t.dts=Rb(t.dts,y),t.dts<s[e>0?e-1:e].dts&&(v=!0)}v&&s.sort(function(e,t){const r=e.dts-t.dts,i=e.pts-t.pts;return r||i}),c=s[0].dts,u=s[s.length-1].dts;const b=u-c,E=b?Math.round(b/(o-1)):p||e.inputTimeScale/30;if(r){const r=c-y,i=r>E,n=r<-1;if((i||n)&&(i?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Sb(r,!0)} ms (${r}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Sb(-r,!0)} ms (${r}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!n||y>=s[0].pts||Ab)){c=y;const e=s[0].pts-r;if(i)s[0].dts=c,s[0].pts=e;else{let t=!0;for(let i=0;i<s.length&&!(s[i].dts>e&&t);i++){const e=s[i].pts;if(s[i].dts-=r,s[i].pts-=r,i<s.length-1){const r=s[i+1].pts;t=r<=s[i].pts==r<=e}}}this.log(`Video: Initial PTS/DTS adjusted: ${Sb(e,!0)}/${Sb(c,!0)}, delta: ${Sb(r,!0)} ms`)}}c=Math.max(0,c);let w=0,S=0,T=c;for(let e=0;e<o;e++){const t=s[e],r=t.units,i=r.length;let n=0;for(let e=0;e<i;e++)n+=r[e].data.length;S+=n,w+=i,t.length=n,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=s[o-1].dts;const x=S+4*w+8;let A;try{A=new Uint8Array(x)}catch(e){return void this.observer.emit($f.ERROR,$f.ERROR,{type:Nf.MUX_ERROR,details:Ff.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(Eb.types.mdat,4);let L=!1,I=Number.POSITIVE_INFINITY,R=Number.POSITIVE_INFINITY,P=Number.NEGATIVE_INFINITY,D=Number.NEGATIVE_INFINITY;for(let e=0;e<o;e++){const t=s[e],r=t.units;let l,c=0;for(let e=0,t=r.length;e<t;e++){const t=r[e],i=t.data,n=t.data.byteLength;k.setUint32(f,n),f+=4,A.set(i,f),f+=n,c+=4+n}if(e<o-1)p=s[e+1].dts-t.dts,l=s[e+1].pts-t.pts;else{const r=this.config,a=e>0?t.dts-s[e-1].dts:E;if(l=e>0?t.pts-s[e-1].pts:E,r.stretchShortVideoTrack&&null!==this.nextAudioTs){const e=Math.floor(r.maxBufferHole*n),s=(i?m+i*n:this.nextAudioTs+d)-t.pts;s>e?(p=s-a,p<0?p=a:L=!0,this.log(`It is approximately ${s/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),D=Math.max(D,l),a.push(Lb(t.key,p,c,u))}if(a.length)if(Ab){if(Ab<70){const e=a[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(kb&&D-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=c;for(let t=0,r=a.length;t<r;t++){const i=e+a[t].duration,n=e+a[t].cts;if(t<r-1){const e=i+a[t+1].cts;a[t].duration=e-n}else a[t].duration=t?a[t-1].duration:E;a[t].cts=0,e=i}}p=L||!p?E:p;const C=u+p;this.nextVideoTs=h=C-d,this.videoSampleDuration=p,this.isVideoContiguous=!0;const _={data1:Eb.moof(e.sequenceNumber++,c,qf(e,{samples:a})),data2:A,startPTS:(m-d)/n,endPTS:(g+p-d)/n,startDTS:(c-d)/n,endDTS:h/n,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,n){const s=e.inputTimeScale,a=s/(e.samplerate?e.samplerate:s),o=this.getSamplesPerFrame(e),l=o*a,d=this._initPTS,c="mp3"===e.segmentCodec&&this.typeSupported.mpeg,u=[],h=void 0!==n;let f=e.samples,p=c?0:8,m=this.nextAudioTs||-1;const g=d.baseTime*s/d.timescale,v=g+t*s;if(this.isAudioContiguous=r=r||f.length&&m>0&&(i&&Math.abs(v-(m+g))<9e3||Math.abs(Rb(f[0].pts,v)-(m+g))<20*l),f.forEach(function(e){e.pts=Rb(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} / ${s})`),!f.length)return;m=0===n?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 n=f[r],a=n.pts,o=a-i,d=Math.abs(1e3*o/s);if(o<=-t*l&&h)0===r&&(this.warn(`Audio frame @ ${(a/s).toFixed(3)}s overlaps marker by ${Math.round(1e3*o/s)} ms.`),this.nextAudioTs=m=a-g,i=a);else if(o>=t*l&&d<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)/s).toFixed(3)}s due to ${Math.round(1e3*o/s)} ms gap.`);for(let s=0;s<t;s++){let t=yb.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=n.unit.subarray()),f.splice(r,0,{unit:t,pts:i}),i+=l,r++}}n.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],n=i.unit;let s=i.pts;if(null!==E){u[t-1].duration=Math.round((s-E)/a)}else{if(r&&"aac"===e.segmentCodec&&(s=m+g),b=s,!(w>0))return;w+=p;try{y=new Uint8Array(w)}catch(e){return void this.observer.emit($f.ERROR,$f.ERROR,{type:Nf.MUX_ERROR,details:Ff.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:w,reason:`fail allocating audio mdat ${w}`})}if(!c){new DataView(y.buffer).setUint32(0,w),y.set(Eb.types.mdat,4)}}y.set(n,p);const l=n.byteLength;p+=l,u.push(Lb(!0,o,l,0)),E=s}const T=u.length;if(!T)return;const x=u[u.length-1];m=E-g,this.nextAudioTs=m+a*x.duration;const A=c?new Uint8Array(0):Eb.moof(e.sequenceNumber++,b/a,qf({},e,{samples:u}));e.samples=[];const k=(b-g)/s,L=this.nextAudioTs/s,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 Rb(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 Pb(e,t,r,i){const n=e.samples.length;if(!n)return;const s=e.inputTimeScale;for(let a=0;a<n;a++){const n=e.samples[a];n.pts=Rb(n.pts-r.baseTime*s/r.timescale,t*s)/s,n.dts=Rb(n.dts-i.baseTime*s/i.timescale,t*s)/s}const a=e.samples;return e.samples=[],{samples:a}}function Db(e,t,r){const i=e.samples.length;if(!i)return;const n=e.inputTimeScale;for(let s=0;s<i;s++){const i=e.samples[s];i.pts=Rb(i.pts-r.baseTime*n/r.timescale,t*n)/n}e.samples.sort((e,t)=>e.pts-t.pts);const s=e.samples;return e.samples=[],{samples:s}}function Cb(e,t,r=!1){return void 0!==(null==e?void 0:e.start)?(e.start+(r?e.duration:0))/e.timescale:t}function _b(e,t,r){const i=e.codec;if(i&&i.length>4)return i;if(t===Ep){if("ec-3"===i||"ac-3"===i||"alac"===i)return i;if("fLaC"===i||"Opus"===i){return cm(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{xb=self.performance.now.bind(self.performance)}catch(e){xb=Date.now}const Ob=[{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 n=this.videoTrack=zy("video",1),s=this.audioTrack=zy("audio",1),a=this.txtTrack=zy("text",1);if(this.id3Track=zy("id3",1),this.timeOffset=0,null==e||!e.byteLength)return;const o=$p(e);if(o.video){const{id:e,timescale:t,codec:r,supplemental:i}=o.video;n.id=e,n.timescale=a.timescale=t,n.codec=r,n.supplemental=i}if(o.audio){const{id:e,timescale:t,codec:r}=o.audio;s.id=e,s.timescale=t,s.codec=r}a.id=Pp.text,n.sampleDuration=0,n.duration=s.duration=i}resetContiguity(){this.remainderData=null}static probe(e){return function(e){const t=e.byteLength;for(let r=0;r<t;){const i=_p(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,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Wp(this.remainderData,e));const t=function(e){const t={valid:null,remainder:null},r=Np(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 s=this.extractID3Track(i,t);return n.samples=Yp(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,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=Yp(e,t),{videoTrack:t,audioTrack:zy(),id3Track:i,textTrack:zy()}}extractID3Track(e,t){const r=this.id3Track;if(e.samples.length){const i=Np(e.samples,["emsg"]);i&&i.forEach(e=>{const i=function(e){const t=e[0];let r="",i="",n=0,s=0,a=0,o=0,l=0,d=0;if(0===t){for(;"\0"!==Dp(e.subarray(d,d+1));)r+=Dp(e.subarray(d,d+1)),d+=1;for(r+=Dp(e.subarray(d,d+1)),d+=1;"\0"!==Dp(e.subarray(d,d+1));)i+=Dp(e.subarray(d,d+1)),d+=1;i+=Dp(e.subarray(d,d+1)),d+=1,n=_p(e,12),s=_p(e,16),o=_p(e,20),l=_p(e,24),d=28}else if(1===t){d+=4,n=_p(e,d),d+=4;const t=_p(e,d);d+=4;const s=_p(e,d);for(d+=4,a=2**32*t+s,Of(a)||(a=Number.MAX_SAFE_INTEGER,np.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=_p(e,d),d+=4,l=_p(e,d),d+=4;"\0"!==Dp(e.subarray(d,d+1));)r+=Dp(e.subarray(d,d+1)),d+=1;for(r+=Dp(e.subarray(d,d+1)),d+=1;"\0"!==Dp(e.subarray(d,d+1));)i+=Dp(e.subarray(d,d+1)),d+=1;i+=Dp(e.subarray(d,d+1)),d+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:a,presentationTimeDelta:s,eventDuration:o,id:l,payload:e.subarray(d,e.byteLength)}}(e);if(ib.test(i.schemeIdUri)){const e=nb(i,t);let n=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;n<=.001&&(n=Number.POSITIVE_INFINITY);const s=i.payload;r.samples.push({data:s,len:s.byteLength,dts:e,pts:e,type:Uy.emsg,duration:n})}else if(this.config.enableEmsgKLVMetadata&&i.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const e=nb(i,t);r.samples.push({data:i.payload,len:i.payload.byteLength,dts:e,pts:e,type:Uy.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 Zf{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:n,video:s}=this.initData=$p(e);if(t)!function(e,t){if(!e||!t)return;const r=t.keyId;r&&t.isCommonEncryption&&Hp(e,(e,t)=>{const i=e.subarray(8,24);i.some(e=>0!==e)||(np.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${lp(i)} -> ${lp(r)}`),e.set(r,8))})}(e,t);else{const e=n||s;null!=e&&e.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${e.codec}")!`)}n&&(r=_b(n,Ep,this)),s&&(i=_b(s,wp,this));const a={};n&&s?a.audiovideo={container:"video/mp4",codec:r+","+i,supplemental:s.supplemental,encrypted:s.encrypted,initSegment:e,id:"main"}:n?a.audio={container:"audio/mp4",codec:r,encrypted:n.encrypted,initSegment:e,id:"audio"}:s?a.video={container:"video/mp4",codec:i,supplemental:s.supplemental,encrypted:s.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=a}remux(e,t,r,i,n,s){var a,o;let{initPTS:l,lastEndTime:d}=this;const c={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};_f(d)||(d=this.lastEndTime=n||0);const u=t.samples;if(!u.length)return c;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."),c;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1);const p=function(e,t,r){const i={},n=Np(e,["moof","traf"]);for(let e=0;e<n.length;e++){const s=n[e],a=Np(s,["tfhd"])[0],o=_p(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 d=i[o],c=Np(s,["tfdt"])[0];if(c){const e=c[0];let t=_p(c,4);1===e&&(t===Ip?r.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(t*=Ip+1,t+=_p(c,8))),_f(t)&&(!_f(d.start)||t<d.start)&&(d.start=t)}const u=l.default,h=_p(a,0)|(null==u?void 0:u.flags);let f=(null==u?void 0:u.duration)||0;8&h&&(f=_p(a,2&h?12:8));const p=Np(s,["trun"]);let m=d.start||0,g=0,v=f;for(let e=0;e<p.length;e++){const t=p[e],r=_p(t,4),i=d.sampleCount;d.sampleCount+=r;const n=1&t[3],s=4&t[3],a=1&t[2],o=2&t[2],l=4&t[2],c=8&t[2];let u=8,h=r;for(n&&(u+=4),s&&r&&(1&t[u+1]||void 0!==d.keyFrameIndex||(d.keyFrameIndex=i),u+=4,a?(v=_p(t,u),u+=4):v=f,o&&(u+=4),c&&(u+=4),m+=v,g+=v,h--);h--;)a?(v=_p(t,u),u+=4):v=f,o&&(u+=4),l&&(1&t[u+1]||void 0===d.keyFrameIndex&&(d.keyFrameIndex=d.sampleCount-(h+1),d.keyFrameStart=m),u+=4),c&&(u+=4),m+=v,g+=v;!g&&f&&(g+=f*r)}d.duration+=g}if(!Object.keys(i).some(e=>i[e].duration)){let t=1/0,r=0;const n=Np(e,["sidx"]);for(let e=0;e<n.length;e++){const i=Fp(n[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&&_f(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=Cb(g,1/0),y=Cb(m,1/0),b=Cb(g,0,!0),E=Cb(m,0,!0);let w=n,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-n*e,r=T?f.audio.id:f.video.id;w=x.start/e,S=T?E-y:b-v,!s&&l||!function(e,t,r,i){if(null===e)return!0;const n=Math.max(i,1),s=t-e.baseTime/e.timescale;return Math.abs(s-r)>n}(l,w,n,S)&&e===l.timescale||(l&&this.warn(`Timestamps at playlist time: ${s?"":"~"}${n} ${t/e} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${n} offset: ${w-n} (${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: ${n}`);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};c.audio=L&&!I?P:void 0,c.video=I?P:void 0;const D=null==g?void 0:g.sampleCount;if(D){const e=g.keyFrameIndex,t=-1!==e;P.nb=D,P.dropped=0===e||this.isVideoContiguous?0:t?e:D,P.independent=t,P.firstKeyFrame=e,t&&g.keyFrameStart&&(P.firstKeyFramePTS=(g.keyFrameStart-l.baseTime)/l.timescale),this.isVideoContiguous||(c.independent=t),this.isVideoContiguous||(this.isVideoContiguous=t),P.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${e}/${D} dropped: ${P.dropped} start: ${P.firstKeyFramePTS||"NA"}`)}return c.initSegment=h,c.id3=Pb(r,n,l,l),i.samples.length&&(c.text=Db(i,n,l)),c}}},{demux:ub,remux:Ib},{demux:class extends Gy{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=Sy(e,0);let i=(null==r?void 0:r.length)||0;if(Jy(e,i))return!1;for(let r=e.length;i<r;i++)if(Ly(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)&&Ty(e,t)&&Ay(e,t)<=e.length-t}(e,t)}appendFrame(e,t,r){Iy(e,this.observer,t,r,e.manifestCodec);const i=Py(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}},remux:Ib},{demux:class extends Gy{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=Sy(e,0);let r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==By(t)&&eb(e,r)<=16)return!1;for(let t=e.length;r<t;r++)if(Jy(e,r))return np.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return Qy(e,t)&&4<=e.length-t}(e,t)}appendFrame(e,t,r){if(null!==this.basePTS)return qy(e,t,r,this.basePTS,this.frameIndex)}},remux:Ib}];Ob.splice(2,0,{demux:tb,remux:Ib});class Mb{constructor(e,t,r,i,n,s){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=n,this.logger=s}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,i){const n=r.transmuxing;n.executeStart=xb();let s=new Uint8Array(e);const{currentTransmuxState:a,transmuxConfig:o}=this;i&&(this.currentTransmuxState=i);const{contiguous:l,discontinuity:d,trackSwitch:c,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}(s,t);if(b&&Yg(b.method)){const e=this.getDecrypter(),t=Kg(b.method);if(!e.isSync())return this.asyncResult=!0,this.decryptionPromise=e.webCryptoDecrypt(s,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(s,b.key.buffer,b.iv.buffer,t);if(r.part>-1){const t=e.flush();i=t?t.buffer:t}if(!i)return n.executeEnd=xb(),Nb(r);s=new Uint8Array(i)}}const E=this.needsProbing(d,c);if(E){const e=this.configureTransmuxer(s);if(e)return this.logger.warn(`[transmuxer] ${e.message}`),this.observer.emit($f.ERROR,$f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),n.executeEnd=xb(),Nb(r)}(d||c||f||E)&&this.resetInitSegment(y,p,m,v,t),(d||f||E)&&this.resetInitialTimestamp(g),l||this.resetContiguity();const w=this.transmux(s,b,h,u,r);this.asyncResult=Fb(w);const S=this.currentTransmuxState;return S.contiguous=!0,S.discontinuity=!1,S.trackSwitch=!1,n.executeEnd=xb(),w}flush(e){const t=e.transmuxing;t.executeStart=xb();const{decrypter:r,currentTransmuxState:i,decryptionPromise:n}=this;if(n)return this.asyncResult=!0,n.then(()=>this.flush(e));const s=[],{timeOffset:a}=i;if(r){const t=r.flush();t&&s.push(this.push(t.buffer,null,e))}const{demuxer:o,remuxer:l}=this;if(!o||!l){t.executeEnd=xb();const r=[Nb(e)];return this.asyncResult?Promise.resolve(r):r}const d=o.flush(a);return Fb(d)?(this.asyncResult=!0,d.then(t=>(this.flushRemux(s,t,e),s))):(this.flushRemux(s,d,e),this.asyncResult?Promise.resolve(s):s)}flushRemux(e,t,r){const{audioTrack:i,videoTrack:n,id3Track:s,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===jf?"level":"track"} ${r.level}`);const d=this.remuxer.remux(i,n,s,a,l,o,!0,this.id);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=xb()}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,n){const{demuxer:s,remuxer:a}=this;s&&a&&(s.resetInitSegment(e,t,r,i),a.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,i,n){let s;return s=t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,n):this.transmuxUnencrypted(e,r,i,n),s}transmuxUnencrypted(e,t,r,i){const{audioTrack:n,videoTrack:s,id3Track:a,textTrack:o}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,s,a,o,t,r,!1,this.id),chunkMeta:i}}transmuxSampleAes(e,t,r,i,n){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:n}))}configureTransmuxer(e){const{config:t,observer:r,typeSupported:i}=this;let n;for(let t=0,r=Ob.length;t<r;t++){var s;if(null!=(s=Ob[t].demux)&&s.probe(e,this.logger)){n=Ob[t];break}}if(!n)return new Error("Failed to find demuxer by probing fragment data");const a=this.demuxer,o=this.remuxer,l=n.remux,d=n.demux;o&&o instanceof l||(this.remuxer=new l(r,t,i,this.logger)),a&&a instanceof d||(this.demuxer=new d(r,t,i,this.logger),this.probe=d.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Tg(this.config)),e}}const Nb=e=>({remuxResult:{},chunkMeta:e});function Fb(e){return"then"in e&&e.then instanceof Function}class $b{constructor(e,t,r,i,n){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=n||null}}class Bb{constructor(e,t,r,i,n,s){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=n,this.initSegmentChange=s}}let Ub=0;class zb{constructor(e,t,r,i){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Ub++,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($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})};const n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;const s=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===$f.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new gy,this.observer.on($f.FRAG_DECRYPTED,s),this.observer.on($f.ERROR,s);const a=pm(n.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){const r=this.hls.logger;if(n.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{n.workerPath?(r.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=function(e){const t=yy[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 yy[e]=i,i}(n.workerPath)):(r.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){const e=yy[vy];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 yy[vy]=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:_m(n)})}catch(i){r.warn(`Error setting up "${t}" Web Worker, fallback to inline`,i),this.terminateWorker(),this.error=null,this.transmuxer=new Mb(this.observer,a,n,"",t,e.logger)}return}}this.transmuxer=new Mb(this.observer,a,n,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=Ub++;const t=this.hls.config,r=pm(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:_m(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=yy[e||vy];if(t&&1===t.clientCount--){const{worker:r,objectURL:i}=t;delete yy[e||vy],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,n,s,a,o,l,d){var c,u;l.transmuxing.start=self.performance.now();const{instanceNo:h,transmuxer:f}=this,p=s?s.start:n.start,m=n.decryptdata,g=this.frag,v=!(g&&n.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===n.stats.parsing.start)&&(n.stats.parsing.start=T),!s||!E&&S||(s.stats.parsing.start=T);const x=!(g&&(null==(c=n.initSegment)?void 0:c.url)===(null==(u=g.initSegment)?void 0:u.url)),A=new Bb(v,S,o,y,p,x);if(!S||v||x){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${n.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id===jf?"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 $b(r,i,t,a,d);this.configureTransmuxer(e)}if(this.frag=n,this.part=s,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);Fb(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);Fb(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($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.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 Gb extends Zf{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 n=-1;for(let r=0;r<i.length;r++){const s=i[r];let a;try{a=new self.URL(s.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),a=s.URI||""}if(a===e){n=r;break}a===e.substring(0,a.length)&&(n=r)}if(-1!==n){const e=i[n],s=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&&Im(r);return new Rm(s,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:n}=t,s=self.performance.now(),a=n.loading.first?Math.max(0,s-n.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){_v(r,i,this);const e=i.playlistParsingError;if(e){this.warn(e);const r=this.hls;if(!r.config.ignorePlaylistParsingErrors){var l;const{networkDetails:s}=t;return void r.trigger($f.ERROR,{type:Nf.NETWORK_ERROR,details:Ff.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:s,stats:n})}i.playlistParsingError=null}}-1===i.requestScheduled&&(i.requestScheduled=n.loading.start);const d=this.hls.mainForwardBufferInfo,c=d?d.end-d.len:0,u=Fv(i,1e3*(i.edge-c));if(i.requestScheduled+u<s?i.requestScheduled=s: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,n=i.lastPartSn,a=i.endSN,l=i.lastPartIndex,d=n===a;-1!==l?d?(f=a+1,p=e?0:l):(f=n,p=e?l+1:i.maxPartIndex):f=a+1;const c=i.age,u=c+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 ${c.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 ${c.toFixed(2)}s goal: ${m} skip sn ${e} to part ${p}`)}i.tuneInGoal=m}if(h=this.getDeliveryDirectives(i,t.deliveryDirectives,f,p),e||!d)return i.requestScheduled=s,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=n.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 n=self.performance.now(),s=i.requestScheduled;if(n>=s)return void this.loadingPlaylist(e,t);const a=s-n;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 n=Im(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=Am),new Rm(r,i,n)}checkRetry(e){const t=e.details,r=Ym(e),i=e.errorAction,{action:n,retryCount:s=0,retryConfig:a}=i||{},o=!!i&&!!a&&(n===ng||!i.resolved&&n===rg);if(o){var l;if(s>=a.maxNumRetry)return!1;if(r&&null!=(l=e.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const e=Qm(a,s);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),e),this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,i.resolved=!0}return o}}function jb(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Hb(e[r].attrs,t[r].attrs))return!1;return!0}function Hb(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 Vb(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}class Wb{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 n=null==(r=this.tracks[e])?void 0:r.buffer;null!=n&&n.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 Yb=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Kb="HlsJsTrackRemovedError";class qb extends Error{constructor(e){super(e),this.name=Kb}}function Xb(e){const t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function Qb(e){return"audio"===e?1:0}class Zb{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($f.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on($f.MANIFEST_PARSED,this.onManifestParsed,this),e.on($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on($f.BUFFER_CODECS,this.onBufferCodecs,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off($f.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off($f.MANIFEST_PARSED,this.onManifestParsed,this),e.off($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off($f.BUFFER_CODECS,this.onBufferCodecs,this),e.off($f.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&&_f(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,Zb.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 n=e.length-1;const s=Math.max(t,r);for(let t=0;t<e.length;t+=1){const r=e[t];if((r.width>=s||r.height>=s)&&i(r,e[t+1])){n=t;break}}return n}}const Jb={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},eE={HLS:"h"};class tE{constructor(e,t){Array.isArray(e)&&(e=e.map(e=>e instanceof tE?e:new tE(e))),this.value=e,this.params=t}}function rE(e,t,r,i){return new Error(`failed to ${e} "${n=t,Array.isArray(n)?JSON.stringify(n):n instanceof Map?"Map{}":n instanceof Set?"Set{}":"object"==typeof n?JSON.stringify(n):String(n)}" as ${r}`,{cause:i});var n}function iE(e,t,r){return rE("serialize",e,t,r)}class nE{constructor(e){this.description=e}}const sE="Bare Item";function aE(e){if(!1===ArrayBuffer.isView(e))throw iE(e,"Byte Sequence");return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function oE(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw iE(e,"Integer");return e.toString()}function lE(e,t){if(e<0)return-lE(-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 dE(e){const t=lE(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw iE(e,"Decimal");const r=t.toString();return r.includes(".")?r:`${r}.0`}const cE=/[\x00-\x1f\x7f]+/;function uE(e){const t=(r=e).description||r.toString().slice(7,-1);var r;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw iE(t,"Token");return t}function hE(e){switch(typeof e){case"number":if(!_f(e))throw iE(e,sE);return Number.isInteger(e)?oE(e):dE(e);case"string":return function(e){if(cE.test(e))throw iE(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return uE(e);case"boolean":return function(e){if("boolean"!=typeof e)throw iE(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${oE(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return aE(e);if(e instanceof nE)return uE(e);default:throw iE(e,sE)}}function fE(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw iE(e,"Key");return e}function pE(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${fE(e)}`:`;${fE(e)}=${hE(t)}`).join("")}function mE(e){return e instanceof tE?`${hE(e.value)}${pE(e.params)}`:hE(e)}function gE(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw iE(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 tE==!1&&(t=new tE(t));let r=fE(e);var i;return!0===t.value?r+=pE(t.params):(r+="=",Array.isArray(t.value)?r+=`(${(i=t).value.map(mE).join(" ")})${pE(i.params)}`:r+=mE(t)),r}).join(`,${i}`)}function vE(e,t){return gE(e,t)}const yE="CMCD-Object",bE="CMCD-Request",EE="CMCD-Session",wE="CMCD-Status",SE={br:yE,ab:yE,d:yE,ot:yE,tb:yE,tpb:yE,lb:yE,tab:yE,lab:yE,url:yE,pb:bE,bl:bE,tbl:bE,dl:bE,ltc:bE,mtp:bE,nor:bE,nrr:bE,rc:bE,sn:bE,sta:bE,su:bE,ttfb:bE,ttfbb:bE,ttlb:bE,cmsdd:bE,cmsds:bE,smrt:bE,df:bE,cs:bE,ts:bE,cid:EE,pr:EE,sf:EE,sid:EE,st:EE,v:EE,msd:EE,bs:wE,bsd:wE,cdn:wE,rtp:wE,bg:wE,pt:wE,ec:wE,e:wE},TE=bE;function xE(e,t){const r={};if(!e)return r;const i=Object.keys(e),n=t?(s=t,Object.keys(s).reduce((e,t)=>{var r;return null===(r=s[t])||void 0===r||r.forEach(r=>e[r]=t),e},{})):{};var s;return i.reduce((t,r)=>{var i;const s=SE[r]||n[r]||TE;return(null!==(i=t[s])&&void 0!==i?i:t[s]={})[r]=e[r],t},r)}const AE="event";const kE=e=>Math.round(e),LE=(e,t)=>Array.isArray(e)?e.map(e=>LE(e,t)):e instanceof tE&&"string"==typeof e.value?new tE(LE(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 n=r.pathname.split("/").slice(1),s=i.pathname.split("/").slice(1,-1);for(;n[0]===s[0];)n.shift(),s.shift();for(;s.length;)s.shift(),n.unshift("..");return n.join("/")+r.search+r.hash}(e,t.baseUrl)),1===t.version?encodeURIComponent(e):e),IE=e=>100*kE(e/100),RE={br:kE,d:kE,bl:IE,dl:IE,mtp:IE,nor:(e,t)=>{let r=e;return t.version>=2&&(e instanceof tE&&"string"==typeof e.value?r=new tE([e]):"string"==typeof e&&(r=[e])),LE(r,t)},rtp:IE,tb:kE},PE="request",DE="response",CE=["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"],_E=["e"],OE=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function ME(e){return OE.test(e)}const NE=["d","dl","nor","ot","rtp","su"];const FE=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];const $E=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function BE(e){return $E.includes(e)||ME(e)}const UE={[DE]:function(e){return CE.includes(e)||NE.includes(e)||FE.includes(e)||ME(e)},[AE]:function(e){return CE.includes(e)||_E.includes(e)||ME(e)},[PE]:function(e){return CE.includes(e)||NE.includes(e)||ME(e)}};function zE(e,t={}){const r={};if(null==e||"object"!=typeof e)return r;const i=t.version||e.v||1,n=t.reportingMode||PE,s=1===i?BE:UE[n];let a=Object.keys(e).filter(s);const o=t.filter;"function"==typeof o&&(a=a.filter(o));const l=n===DE||n===AE;l&&!a.includes("ts")&&a.push("ts"),i>1&&!a.includes("v")&&a.push("v");const d=qf({},RE,t.formatters),c={version:i,reportingMode:n,baseUrl:t.baseUrl};return a.sort().forEach(t=>{let n=e[t];const s=d[t];if("function"==typeof s&&(n=s(n,c)),"v"===t){if(1===i)return;n=i}"pr"==t&&1===n||(l&&"ts"===t&&!_f(n)&&(n=Date.now()),function(e){return"number"==typeof e?_f(e):null!=e&&""!==e&&!1!==e}(n)&&(function(e){return["ot","sf","st","e","sta"].includes(e)}(t)&&"string"==typeof n&&(n=new nE(n)),r[t]=n))}),r}function GE(e,t,r){return qf(e,function(e,t={}){const r={};if(!e)return r;const i=xE(zE(e,t),null==t?void 0:t.customHeaderMap);return Object.entries(i).reduce((e,[t,r])=>{const i=vE(r,{whitespace:!1});return i&&(e[t]=i),e},r)}(t,r))}function jE(e,t={}){if(!e)return"";const r=function(e,t={}){return e?vE(zE(e,t),{whitespace:!1}):""}(e,t);return encodeURIComponent(r)}const HE=/CMCD=[^&#]+/;function VE(e,t,r){const i=function(e,t={}){return e?`CMCD=${jE(e,t)}`:""}(t,r);if(!i)return e;if(HE.test(e))return e.replace(HE,i);const n=e.includes("?")?"&":"?";return`${e}${n}${i}`}function WE(e,t,r,i){e&&Object.keys(t).forEach(n=>{const s=e.filter(e=>e.groupId===n).map(e=>{const s=qf({},e);return s.details=void 0,s.attrs=new Ug(s.attrs),s.url=s.attrs.URI=YE(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),s.groupId=s.attrs["GROUP-ID"]=t[n],s.attrs["PATHWAY-ID"]=i,s});e.push(...s)})}function YE(e,t,r,i){const{HOST:n,PARAMS:s,[r]:a}=i;let o;t&&(o=null==a?void 0:a[t],o&&(e=o));const l=new self.URL(e);return n&&!o&&(l.host=n),s&&Object.keys(s).sort().forEach(e=>{e&&l.searchParams.set(e,s[e])}),l.href}class KE extends Zf{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=KE.CDMCleanupPromise?[KE.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=ov(this.config));const t=e.map(av).filter(e=>!!e);this.keyFormatPromise=this.getKeyFormatPromise(t)}this.keyFormatPromise.then(n=>{const s=sv(n);if("sinf"!==t||s!==ev.FAIRPLAY)return void this.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${s}`);let a;try{const e=Dp(new Uint8Array(r)),t=Vp(qg(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=lp(a),{keyIdToKeySessionPromise:l,mediaKeySessions:d}=this;let c=l[o];for(let e=0;e<d.length;e++){const i=d[e],n=i.decryptdata;if(!n.keyId)continue;const s=lp(n.keyId);if(Vg(a,n.keyId)||-1!==n.uri.replace(/-/g,"").indexOf(o)){if(c=l[s],!c)continue;if(n.pssh)break;delete l[s],n.pssh=new Uint8Array(r),n.keyId=a,c=l[o]=c.then(()=>this.generateRequestWithPreferredKeySession(i,t,r,"encrypted-event-key-match")),c.catch(e=>this.handleError(e));break}}c||this.handleError(new Error(`Key ID ${o} not encountered in playlist. Key-system sessions ${d.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($f.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on($f.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on($f.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on($f.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on($f.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off($f.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off($f.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off($f.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off($f.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===ev.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),n=t.map(e=>e.videoCodec).filter(r);return i.length+n.length===0&&n.push("avc1.42e01e"),new Promise((t,r)=>{const s=e=>{const a=e.shift();this.getMediaKeysPromise(a,i,n).then(e=>t({keySystem:a,mediaKeys:e})).catch(t=>{e.length?s(e):r(t instanceof QE?t:new QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};s(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:r}=this.config;if("function"!=typeof r){let e=`Configured requestMediaKeySystemAccess is not a function ${r}`;return null===lv&&"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 n=function(e,t,r,i){let n;switch(e){case ev.FAIRPLAY:n=["cenc","sinf"];break;case ev.WIDEVINE:case ev.PLAYREADY:n=["cenc"];break;case ev.CLEARKEY:n=["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}))}]}(n,t,r,i)}(e,t,r,this.config.drmSystemOptions||{});let s=this.keySystemAccessPromises[e],a=null==(i=s)?void 0:i.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${_m(n)}`),a=this.requestMediaKeySystemAccess(e,n);const t=s=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 n=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 n.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),n})}return a.then(()=>s.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${lp(e.keyId||[])} keyUri: ${e.uri}`);const i=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const r=this.createMediaKeySessionContext(e),i=qE(t),n="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,n,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 ${lp(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})=>av(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=av(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=ov(this.config),r=e.map(sv).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=XE(e,t[r]);if(i)return i}}loadKey(e){const t=e.keyInfo.decryptdata,r=qE(t),i=this.bannedKeyIds[r];if(i||"internal-error"===this.getKeyStatus(t)){const r=ZE(i||"internal-error",t);return this.handleError(r,e.frag),Promise.reject(r)}const n=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${n}`);const s=this.keyIdToKeySessionPromise[r];if(!s){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 ${n}`),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 s.catch(r=>{if(r instanceof QE){const i=Qf({},r.data);"internal-error"===this.getKeyStatus(t)&&(i.decryptdata=t);const n=new QE(i,r.message);this.handleError(n,e.frag)}}),s}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof QE){t&&(e.data.frag=t);const r=e.data.decryptdata;this.error(`${e.message}${r?` (${lp(r.keyId||[])})`:""}`),this.hls.trigger($f.ERROR,e.data)}else this.error(e.message),this.hls.trigger($f.ERROR,{type:Nf.KEY_SYSTEM_ERROR,details:Ff.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){const t=qE(e),r=this.keyIdToKeySessionPromise[t];if(!r){const t=sv(e.keyFormat),r=t?[t]:ov(this.config);return this.attemptKeySystemAccess(r)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=ov(this.config)),0===e.length)throw new QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${_m({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 n;const s=null==(n=this.config.drmSystems)||null==(n=n[e.keySystem])?void 0:n.generateRequest;if(s)try{const i=s.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=qE(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 gy,d=e._onmessage=t=>{const r=e.mediaKeysSession;if(!r)return void l.emit("error",new Error("invalid state"));const{messageType:i,message:n}=t;this.log(`"${i}" message event for session "${r.sessionId}" message size: ${n.byteLength}`),"license-request"===i||"license-renewal"===i?this.renewLicense(e,n).catch(e=>{l.eventNames().length?l.emit("error",e):this.handleError(e)}):"license-release"===i?e.keySystem===ev.FAIRPLAY&&this.updateKeySession(e,Xg("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${i}"`)},c=(e,t)=>{let r;t.keyStatus=e,e.startsWith("usable")?l.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?r=ZE(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 ${_m(r)} in key-session "${e.mediaKeysSession.sessionId}"`),void this.renewKeySession(e);let i=r[a];if(i)c(i,e);else{var n;const t=1e3;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(n=e.keyStatusTimeouts)[a]||(n[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.`),c(r,e);this.log(`key status for ${a} in key-session "${e.mediaKeysSession.sessionId}" timed out after ${t}ms`),i="internal-error",c(i,e)},t)),this.log(`No status for keyId ${a} (${_m(r)}).`)}};qv(e.mediaKeysSession,"message",d),qv(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 QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.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 n="buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i);if(e.keySystem===ev.PLAYREADY&&16===n.length){const e=lp(n);t[e]=r,Qg(n)}const s=lp(n);"internal-error"===r&&(this.bannedKeyIds[s]=r),this.log(`key status change "${r}" for keyStatuses keyId: ${s} key-session "${e.mediaKeysSession.sessionId}"`),t[s]=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((n,s)=>{const a={responseType:"arraybuffer",url:i},o=t.certLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(e,t,r,i)=>{n(e.data)},onError:(t,r,n,o)=>{s(new QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:Qf({url:a.url,data:void 0},t)},`"${e}" certificate request failed (${i}). Status: ${t.code} (${t.text})`))},onTimeout:(t,r,n)=>{s(new QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:{url:a.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(e,t,r)=>{s(new Error("aborted"))}};r.load(a,l,d)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((i,n)=>{e.setServerCertificate(r).then(n=>{this.log(`setServerCertificate ${n?"success":"not supported by CDM"} (${r.byteLength}) on "${t}"`),i(e)}).catch(e=>{n(new QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.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 QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.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"),n=i.querySelectorAll("HttpHeader");if(n.length>0){let t;for(let r=0,i=n.length;r<i;r++){var s,a;t=n[r];const i=null==(s=t.querySelector("name"))?void 0:s.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 Xg(atob(l))}setupLicenseXHR(e,t,r,i){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,i)}).catch(s=>{if(!r.decryptdata)throw s;return e.open("POST",t,!0),n.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,n)=>{const s=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${s}`);const a=new XMLHttpRequest;a.responseType="arraybuffer",a.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(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,s,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)n(new QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:a,response:{url:s,data:void 0,code:a.status,text:a.statusText}},`License Request XHR failed (${s}). 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,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=a,this.setupLicenseXHR(a,s,e,t).then(({xhr:t,licenseChallenge:r})=>{e.keySystem==ev.PLAYREADY&&(r=this.unpackPlayReadyKeyMessage(t,r)),t.send(r)}).catch(n)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const r=t.media;this.media=r,qv(r,"encrypted",this.onMediaEncrypted),qv(r,"waitingforkey",this.onWaitingForKey);const i=this.mediaResolved;i?i():this.mediaKeys=r.mediaKeys}onMediaDetached(){const e=this.media;e&&(Xv(e,"encrypted",this.onMediaEncrypted),Xv(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,hv.clearKeyUriToKeyIdMap();const n=i.length;KE.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($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.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($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${e}`)})}).then(()=>{n&&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: ${lp((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 n=this.mediaKeySessions.indexOf(e);n>-1&&this.mediaKeySessions.splice(n,1);const{keyStatusTimeouts:s}=e;s&&Object.keys(s).forEach(e=>self.clearTimeout(s[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($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.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($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}function qE(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return lp(e.keyId)}function XE(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}KE.CDMCleanupPromise=void 0;class QE 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 ZE(e,t){const r="output-restricted"===e,i=r?Ff.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:Ff.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new QE({type:Nf.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:t},r?"HDCP level output restricted":`key status changed to "${e}"`)}function JE(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 ew(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){np.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){np.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===r&&(e.mode=r)}function tw(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 rw(e,t,r,i){const n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0){const n=function(e,t,r){const i=[],n=function(e,t){if(t<=e[0].startTime)return 0;const r=e.length-1;if(t>e[r].endTime)return-1;let i,n=0,s=r;for(;n<=s;)if(i=Math.floor((s+n)/2),t<e[i].startTime)s=i-1;else{if(!(t>e[i].startTime&&n<r))return i;n=i+1}return e[n].startTime-t<t-e[s].startTime?n:s}(e,t);if(n>-1)for(let s=n,a=e.length;s<a;s++){const n=e[s];if(n.startTime>=t&&n.endTime<=r)i.push(n);else if(n.startTime>r)return i}return i}(e.cues,t,r);for(let t=0;t<n.length;t++)i&&!i(n[t])||e.removeCue(n[t])}"disabled"===n&&(e.mode=n)}function iw(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 nw(e){let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}const sw=.025;let aw=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function ow(e,t,r){return`${e.identifier}-${r+1}-${nw(t)}`}class lw{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 dw(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-dw(t,e)<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=_f(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 dw(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)<sw))}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"]?aw.Range:aw.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 dw(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<sw)?t.start:t.start+t.duration}function cw(e,t,r){const i=new self.URL(e,r);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function uw(e,t){for(;null!=(r=e.assetList[++t])&&r.error;)var r;return t}function hw(e){const t=e.timelineStart,r=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+r).toFixed(2)}]`}class fw{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($f.PLAYOUT_LIMIT_REACHED,{})};const n=this.hls=new e(t);this.interstitial=r,this.assetItem=i;const s=()=>{this.hasDetails=!0};n.once($f.LEVEL_LOADED,s),n.once($f.AUDIO_TRACK_LOADED,s),n.once($f.SUBTITLE_TRACK_LOADED,s),n.on($f.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t;this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&n.on($f.BUFFER_APPENDED,()=>{const e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,n.trigger($f.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=cw(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,n=Cg.bufferInfo(e,i,0);return this.getAssetTime(n.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=Cg.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: ${hw(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}class pw extends Zf{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!=(n=i[r])&&n.event;){var n;r--}return r}findItemIndexAtTime(e,t){const r=this.items;if(r)for(let i=0;i<r.length;i++){let n=r[i];if(t&&"primary"!==t&&(n=n[t]),e===n.start||e>n.start&&e<n.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 n=r[e];if(!n.error){const r=n.timelineStart;if(t===r||t>r&&(t<r+(n.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,n=this.events,s=this.parseDateRanges(i,{url:r.url},t),a=Object.keys(i),o=n?n.filter(e=>!a.includes(e.identifier)):[];s.length&&s.sort((e,t)=>{const r=e.cue.pre,i=e.cue.post,n=t.cue.pre,s=t.cue.post;if(r&&!n)return-1;if(n&&!r)return 1;if(i&&!s)return 1;if(s&&!i)return-1;if(!(r||n||i||s)){const r=e.startTime,i=t.startTime;if(r!==i)return r-i}return e.dateRange.tagOrder-t.dateRange.tagOrder}),this.events=s,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 n=this.items,s=this.parseSchedule(i,e),a=r||t.length||(null==n?void 0:n.length)!==s.length||s.some((e,t)=>Math.abs(e.playout.start-n[t].playout.start)>.005||Math.abs(e.playout.end-n[t].playout.end)>.005);a&&(this.items=s,this.onScheduleUpdate(t,n))}}parseDateRanges(e,t,r){const i=[],n=Object.keys(e);for(let s=0;s<n.length;s++){const a=n[s],o=e[a];if(o.isInterstitial){let e=this.eventMap[a];e?e.setDateRange(o):(e=new lw(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,n=i.live?1/0:i.edge;let s=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,d=t.cue.post,c=e[a-1]||null,u=t.appendInPlace,h=d?n:t.startOffset,f=t.duration,p=t.timelineOccupancy===aw.Range?f:0,m=t.resumptionOffset,g=(null==c?void 0:c.startTime)===h,v=h+t.cumulativeDuration;let y=u?v+f:h+m;if(l||!d&&h<=0){const e=o;o+=p,t.timelineStart=v;const i=s;s+=f,r.push({event:t,start:v,end:y,playout:{start:i,end:s},integrated:{start:e,end:o}})}else{if(!(h<=n))return;{if(!g){const n=h-i;if(n>.033){const l=i,d=o;o+=n;const c=s;s+=n;const u={previousEvent:e[a-1]||null,nextEvent:t,start:l,end:l+n,playout:{start:c,end:s},integrated:{start:d,end:o}};r.push(u)}else n>0&&c&&(c.cumulativeDuration+=n,r[r.length-1].end=h)}d&&(y=v),t.timelineStart=v;const n=o;o+=p;const l=s;s+=f,r.push({event:t,start:v,end:y,playout:{start:l,end:s},integrated:{start:n,end:o}})}}const b=t.resumeTime;i=d||b>n?n:b}),i<n){var a;const e=i,t=o,l=n-i;o+=l;const d=s;s+=l,r.push({previousEvent:(null==(a=r[r.length-1])?void 0:a.event)||null,nextEvent:null,start:i,end:e+l,playout:{start:d,end:s},integrated:{start:t,end:o}})}this.setDurations(n,s,o)}else{const e=0;r.push({previousEvent:null,nextEvent:null,start:e,end:n,playout:{start:e,end:n},integrated:{start:e,end:n}}),this.setDurations(n,n,n)}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 n=0,s=-1;e.forEach((a,o)=>{const l=a.cue.pre,d=a.cue.post,c=l?0:d?i:a.startTime;this.updateAssetDurations(a);if(s===c?a.cumulativeDuration=n:(n=0,s=c),!d&&a.snapOptions.in&&(a.resumeAnchor=jm(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=_f(a.resumeOffset)?a.resumeOffset:a.duration;n+=u})}primaryCanResumeInPlaceAt(e,t){const r=e.resumeTime,i=e.startTime+e.resumptionOffset;if(Math.abs(r-i)>sw)return this.log(`"${e.identifier}" resumption ${r} not aligned with estimated timeline end ${i}`),!1;return!Object.keys(t).some(i=>{const n=t[i].details,s=n.edge;if(r>=s)return this.log(`"${e.identifier}" resumption ${r} past ${i} playlist end ${s}`),!1;const a=jm(null,n.fragments,r);if(!a)return this.log(`"${e.identifier}" resumption ${r} does not align with any fragments in ${i} playlist (${n.fragStart}-${n.fragmentEnd})`),!0;const o="audio"===i?.175:0;return!(Math.abs(a.start-r)<sw+o||Math.abs(a.end-r)<sw+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,n=!1;for(let s=0;s<e.assetList.length;s++){const a=e.assetList[s],o=t+r;a.startOffset=r,a.timelineStart=o,i||(i=null===a.duration),n||(n=!!a.error);r+=a.error?0:a.duration||0}e.duration=i&&!n?Math.max(r,e.duration):r}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function mw(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}class gw{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const r=e.assetListUrl;let i;try{i=cw(r,this.hls.sessionId,e.baseUrl)}catch(t){const i=this.assignAssetListError(e,Ff.ASSET_LIST_LOAD_ERROR,t,r);return void this.hls.trigger($f.ERROR,i)}t&&"data:"!==i.protocol&&i.searchParams.set("_HLS_start_offset",""+t);const n=this.hls.config,s=new(0,n.loader)(n),a={responseType:"json",url:i.href},o=n.interstitialAssetListLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(t,r,i,n)=>{const s=t.data,a=null==s?void 0:s.ASSETS;if(!Array.isArray(a)){const t=this.assignAssetListError(e,Ff.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),i.url,r,n);return void this.hls.trigger($f.ERROR,t)}e.assetListResponse=s,this.hls.trigger($f.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:n})},onError:(t,r,i,n)=>{const s=this.assignAssetListError(e,Ff.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${r.url})`),r.url,n,i);this.hls.trigger($f.ERROR,s)},onTimeout:(t,r,i)=>{const n=this.assignAssetListError(e,Ff.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${r.url})`),r.url,t,i);this.hls.trigger($f.ERROR,n)}};return s.load(a,l,d),this.hls.trigger($f.ASSET_LIST_LOADING,{event:e}),s}assignAssetListError(e,t,r,i,n,s){return e.error=r,{type:Nf.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:r,networkDetails:s,stats:n}}}function vw(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function yw(e,t){return`[${e}] Advancing timeline position to ${t}`}class bw{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 Ew={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},ww=e=>String.fromCharCode(Ew[e]||e),Sw=15,Tw=100,xw={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Aw={17:2,18:4,21:6,22:8,23:10,19:13,20:15},kw={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Lw={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Iw=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Rw{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const r="function"==typeof t?t():t;np.log(`${this.time} [${e}] ${r}`)}}}const Pw=function(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t};class Dw{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 Cw{constructor(){this.uchar=" ",this.penState=new Dw}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 _w{constructor(e){this.chars=[],this.pos=0,this.currPenState=new Dw,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<Tw;e++)this.chars.push(new Cw);this.logger=e}equals(e){for(let t=0;t<Tw;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Tw;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Tw;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>Tw&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Tw)}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=ww(e);this.pos>=Tw?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<Tw;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<Tw;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 Ow{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Sw;t++)this.rows.push(new _w(e));this.logger=e}reset(){for(let e=0;e<Sw;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let r=0;r<Sw;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<Sw;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Sw;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 = "+_m(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<Sw;e++)this.rows[e].clear();const e=this.currRow+1-this.nrRollUpRows,r=this.lastOutputScreen;if(r){const i=r.rows[e].cueStartTime,n=this.logger.time;if(null!==i&&null!==n&&i<n)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 = "+_m(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<Sw;r++){const n=this.rows[r].getTextString();n&&(i=r+1,e?t.push("Row "+i+": '"+n+"'"):t.push(n.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}getTextAndFormat(){return this.rows}}class Mw{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 Ow(r),this.nonDisplayedMemory=new Ow(r),this.lastOutputScreen=new Ow(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: "+_m(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 Nw{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 Rw;this.channels=[null,new Mw(e,t,i),new Mw(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 n=!1,s=null;if(0===r&&0===i)continue;this.logger.log(3,()=>"["+Pw([t[e],t[e+1]])+"] -> ("+Pw([r,i])+")");const a=this.cmdHistory;if(r>=16&&r<=31){if($w(r,i,a)){Fw(null,null,a),this.logger.log(3,()=>"Repeated command ("+Pw([r,i])+") is dropped");continue}Fw(r,i,this.cmdHistory),n=this.parseCmd(r,i),n||(n=this.parseMidrow(r,i)),n||(n=this.parsePAC(r,i)),n||(n=this.parseBackgroundAttributes(r,i))}else Fw(null,null,a);if(!n&&(s=this.parseChars(r,i),s)){const e=this.currentChannel;if(e&&e>0){this.channels[e].insertChars(s)}else this.logger.log(2,"No channel found yet. TEXT-MODE?")}n||s||this.logger.log(2,()=>"Couldn't parse cleaned data "+Pw([r,i])+" orig: "+Pw([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 ("+Pw([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?xw[e]:kw[e]:1===i?Aw[e]:Lw[e];const n=this.channels[i];return!!n&&(n.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,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let e;e=17===n?t+80:18===n?t+112:t+144,this.logger.log(2,()=>"Special char '"+ww(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 = "+Pw(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=Iw[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));const n=e<=23?1:2;return this.channels[n].setBkgData(i),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}Fw(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 Fw(e,t,r){r.a=e,r.b=t}function $w(e,t,r){return r.a===e&&r.b===t}var Bw=function(){if(null!=Jg&&Jg.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 n(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 s(t,s,a){const o=this,l={enumerable:!0};o.hasBeenReset=!1;let d="",c=!1,u=t,h=s,f=a,p=null,m="",g=!0,v="auto",y="start",b=50,E="middle",w=50,S="middle";Object.defineProperty(o,"id",n({},l,{get:function(){return d},set:function(e){d=""+e}})),Object.defineProperty(o,"pauseOnExit",n({},l,{get:function(){return c},set:function(e){c=!!e}})),Object.defineProperty(o,"startTime",n({},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",n({},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",n({},l,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",n({},l,{get:function(){return p},set:function(e){p=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",n({},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",n({},l,{get:function(){return g},set:function(e){g=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",n({},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",n({},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",n({},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",n({},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",n({},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",n({},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 s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}();class Uw{decode(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function zw(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 Gw{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 jw(e,t,r,i){const n=i?e.split(i):[e];for(const e in n){if("string"!=typeof n[e])continue;const i=n[e].split(r);if(2!==i.length)continue;t(i[0],i[1])}}const Hw=new Bw(0,0,""),Vw="middle"===Hw.align?"middle":"center";function Ww(e,t,r){const i=e;function n(){const t=zw(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function s(){e=e.replace(/^\s+/,"")}if(s(),t.startTime=n(),s(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.slice(3),s(),t.endTime=n(),s(),function(e,t){const i=new Gw;jw(e,function(e,t){let n;switch(e){case"region":for(let n=r.length-1;n>=0;n--)if(r[n].id===t){i.set(e,r[n].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":n=t.split(","),i.integer(e,n[0]),i.percent(e,n[0])&&i.set("snapToLines",!1),i.alt(e,n[0],["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",Vw,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",Vw,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",Vw,"end","left","right"])}},/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");let n=i.get("line","auto");"auto"===n&&-1===Hw.line&&(n=-1),t.line=n,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",Vw);let s=i.get("position","auto");"auto"===s&&50===Hw.position&&(s="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=s}(e,t)}function Yw(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class Kw{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Uw,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=Yw(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){jw(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 n=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(n?n=!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 Bw(0,0,""),t.state="CUE",-1===e.indexOf("--\x3e")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Ww(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&&(n=!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 qw=/\r\n|\n\r|\n|\r/g,Xw=function(e,t,r=0){return e.slice(r,r+t.length)===t};function Qw(e,t,r){return nw(e.toString())+nw(t.toString())+nw(r)}function Zw(e,t,r,i,n,s,a){const o=new Kw,l=op(new Uint8Array(e)).trim().replace(qw,"\n").split("\n"),d=[],c=t?function(e,t=1){return wb(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 s=r[i];let a=r.ccOffset;const o=(f-c)/9e4;if(null!=s&&s.new&&(void 0!==p?a=r.ccOffset=s.start:function(e,t,r){let i=e[t],n=e[i.prevCC];if(!n||!n.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;null!=(s=n)&&s.new;){var s;e.ccOffset+=i.start-n.start,i.new=!1,i=n,n=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=Rb(9e4*(e.startTime+a-p),9e4*n)/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=Qw(e.startTime,e.endTime,m)),e.endTime>0&&d.push(e)},o.onparsingerror=function(e){u=e},o.onflush=function(){u?a(u):s(d)},l.forEach(e=>{if(m){if(Xw(e,"X-TIMESTAMP-MAP=")){m=!1,e.slice(16).split(",").forEach(e=>{Xw(e,"LOCAL:")?h=e.slice(6):Xw(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)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(_f(t)&&_f(r)&&_f(i)&&_f(n)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=6e4*i,t+=36e5*n,t}(h)/1e3}catch(e){u=e}return}""===e&&(m=!1)}o.parse(e+"\n")}),o.flush()}const Jw="stpp.ttml.im1t",eS=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,tS=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,rS={left:"start",center:"center",right:"end",start:"start",end:"end"};function iS(e,t,r,i){const n=Np(new Uint8Array(e),["mdat"]);if(0===n.length)return void i(new Error("Could not parse IMSC1 mdat"));const s=n.map(e=>op(e)),a=function(e,t,r=1,i=!1){return wb(e,t,1/r,i)}(t.baseTime,1,t.timescale);try{s.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 n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(n).reduce((e,t)=>(e[t]=i.getAttribute(`ttp:${t}`)||n[t],e),{}),a="preserve"!==i.getAttribute("xml:space"),o=sS(nS(i,"styling","style")),l=sS(nS(i,"layout","region")),d=nS(i,"body","[begin]");return[].map.call(d,e=>{const r=aS(e,a);if(!r||!e.hasAttribute("begin"))return null;const i=dS(e.getAttribute("begin"),s),n=dS(e.getAttribute("dur"),s);let d=dS(e.getAttribute("end"),s);if(null===i)throw lS(e);if(null===d){if(null===n)throw lS(e);d=i+n}const c=new Bw(i-t,d-t,r);c.id=Qw(c.startTime,c.endTime,c.text);const u=function(e,t,r){const i="http://www.w3.org/ns/ttml#styling";let n=null;const s=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;a&&r.hasOwnProperty(a)&&(n=r[a]);return s.reduce((r,s)=>{const a=oS(t,i,s)||oS(e,i,s)||oS(n,i,s);return a&&(r[s]=a),r},{})}(l[e.getAttribute("region")],o[e.getAttribute("style")],o),{textAlign:h}=u;if(h){const e=rS[h];e&&(c.lineAlign=e),c.align=h}return qf(c,u),c}).filter(e=>null!==e)}(e,a)))}catch(e){i(e)}}function nS(e,t,r){const i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function sS(e){return e.reduce((e,t)=>{const r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function aS(e,t){return[].slice.call(e.childNodes).reduce((e,r,i)=>{var n;return"br"===r.nodeName&&i?e+"\n":null!=(n=r.childNodes)&&n.length?aS(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function oS(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function lS(e){return new Error(`Could not parse ttml timestamp ${e}`)}function dS(e,t){if(!e)return null;let r=zw(e);return null===r&&(eS.test(e)?r=function(e,t){const r=eS.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):tS.test(e)&&(r=function(e,t){const r=tS.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 cS{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 uS(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function hS(e,t){return!!e&&e.kind===uS(t)&&Vb(t,e)}function fS(e,t,r,i){return Math.min(t,i)-Math.max(e,r)}const pS=/\s/,mS={newCue(e,t,r,i){const n=[];let s,a,o,l,d;const c=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(s=i.rows[h],o=!0,l=0,d="",!s.isEmpty()){var u;for(let e=0;e<s.chars.length;e++)pS.test(s.chars[e].uchar)&&o?l++:(d+=s.chars[e].uchar,o=!1);s.cueStartTime=t,t===r&&(r+=1e-4),l>=16?l--:l++;const i=Yw(d.trim()),f=Qw(t,r,i);null!=e&&null!=(u=e.cues)&&u.getCueById(f)||(a=new c(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)),n.push(a))}return e&&n.length&&(n.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),n.forEach(t=>ew(e,t))),n}};const gS=/(\d+)-(\d+)\/(\d+)/;class vS{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||yS,this.controller=new self.AbortController,this.stats=new bp}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 n=function(e,t){const r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(qf({},e.headers))};e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return r}(e,this.controller.signal),s="arraybuffer"===e.responseType,a=s?"byteLength":"length",{maxTimeToFirstByteMs:o,maxLoadTimeMs:l}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=o&&_f(o)?o:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},t.timeout);(Fb(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(r=>{var n;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 bS(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=gS.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(_f(e))return e}const r=e.get("Content-Length");if(r)return parseInt(r)}(r.headers)||i.total;const o=null==(n=this.callbacks)?void 0:n.onProgress;return o&&_f(t.highWaterMark)?this.loadProgressively(r,i,e,t.highWaterMark,o):s?r.arrayBuffer():"json"===e.responseType?r.json():r.text()}).then(r=>{var n,s;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 d={url:o.url,data:r,code:o.status},c=null==(n=this.callbacks)?void 0:n.onProgress;c&&!_f(t.highWaterMark)&&c(i,e,r,o),null==(s=this.callbacks)||s.onSuccess(d,i,e,o)}).catch(t=>{var r;if(self.clearTimeout(this.requestTimeout),i.aborted)return;const n=t&&t.code||0,s=t?t.message:null;null==(r=this.callbacks)||r.onError({code:n,text:s},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,n){const s=new hy,a=e.body.getReader(),o=()=>a.read().then(a=>{if(a.done)return s.dataLength&&n(t,r,s.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const l=a.value,d=l.length;return t.loaded+=d,d<i||s.dataLength?(s.push(l),s.dataLength>=i&&n(t,r,s.flush().buffer,e)):n(t,r,l.buffer,e),o()}).catch(()=>Promise.reject());return o()}}function yS(e,t){return new self.Request(e.url,t)}class bS extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}}const ES=/^age:\s*[\d.]+\s*$/im;class wS{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 bp,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 n=this.xhrSetup;n?Promise.resolve().then(()=>{if(this.loader===r&&!this.stats.aborted)return n(r,t.url)}).catch(e=>{if(this.loader===r&&!this.stats.aborted)return r.open("GET",t.url,!0),n(r,t.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(e=>{var n;null==(n=this.callbacks)||n.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:n,maxLoadTimeMs:s}=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=n&&_f(n)?n:s,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,n=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.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 n=null!=l?l:t.response;if(null!=n){var s,a;r.loading.end=Math.max(self.performance.now(),r.loading.first);const o="arraybuffer"===t.responseType?n.byteLength:n.length;r.loaded=r.total=o,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first);const l=null==(s=this.callbacks)?void 0:s.onProgress;l&&l(r,e,n,t);const d={url:t.responseURL,data:n,code:i};return void(null==(a=this.callbacks)||a.onSuccess(d,r,e,t))}}const d=n.loadPolicy.errorRetry;var o;if(Jm(d,r.retry,!1,{url:e.url,data:void 0,code:i}))this.retry(d);else np.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(Jm(e,this.stats.retry,!0))this.retry(e);else{var t;np.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=Qm(e,r.retry),r.retry++,np.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&&ES.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 SS=Qf(Qf({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:wS,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class extends Zf{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:n}=this,{autoLevelEnabled:s,media:a}=n;if(!r||!a)return;const o=performance.now(),l=i?i.stats:r.stats,d=i?i.duration:r.duration,c=o-l.loading.start,u=n.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(!s)return;const p=f>-1&&f!==h,m=!!e||p;if(!m&&(a.paused||!a.playbackRate||!a.readyState))return;const g=n.mainForwardBufferInfo;if(!m&&null===g)return;const v=this.bwEstimator.getEstimateTTFB(),y=Math.abs(a.playbackRate);if(c<=Math.max(v,d/(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=n.levels,x=T[h],A=Math.max(l.loaded,Math.round(d*(r.bitrate||x.averageBitrate)/8));let k=w?c-E:c;k<1&&w&&(k=Math.min(c,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,D=!0===(null==(t=(null==e?void 0:e.details)||this.hls.latestLevelDetails)?void 0:t.live),C=this.hls.config.abrBandWidthUpFactor;let _,O=Number.POSITIVE_INFINITY;for(_=h-1;_>u;_--){const e=T[_].maxBitrate,t=!T[_].details||D;if(O=this.getTimeToLoadFrag(I,P,d*e,t),O<Math.min(b,d+I))break}if(O>=R)return;if(O>10*d)return;w?this.bwEstimator.sample(c-Math.min(v,E),l.loaded):this.bwEstimator.sampleTTFB(c);const M=T[_].maxBitrate;this.getBwEstimate()*C>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: ${_f(S)?0|S:"Unknown"} bps\n New BW estimate: ${0|this.getBwEstimate()} bps\n Switching to level ${_} @ ${0|M} bps`),n.nextLoadLevel=n.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),n.trigger($f.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 Yf(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.FRAG_LOADING,this.onFragLoading,this),e.on($f.FRAG_LOADED,this.onFragLoaded,this),e.on($f.FRAG_BUFFERED,this.onFragBuffered,this),e.on($f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on($f.LEVEL_LOADED,this.onLevelLoaded,this),e.on($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on($f.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on($f.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.FRAG_LOADING,this.onFragLoading,this),e.off($f.FRAG_LOADED,this.onFragLoaded,this),e.off($f.FRAG_BUFFERED,this.onFragBuffered,this),e.off($f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off($f.LEVEL_LOADED,this.onLevelLoaded,this),e.off($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off($f.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off($f.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 Ff.BUFFER_ADD_CODEC_ERROR:case Ff.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case Ff.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,n=t-r.loading.start,s=r.loading.first?r.loading.first-r.loading.start:-1;if(r.loaded&&s>-1){const e=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(n-Math.min(e,s),r.loaded)}else this.bwEstimator.sampleTTFB(n)}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,n=i.end-i.first;_f(n)&&(this.lastLevelLoadSec=n/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===jf&&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,n=this.hls.levels[t.level],s=(n.loaded?n.loaded.bytes:0)+i.loaded,a=(n.loaded?n.loaded.duration:0)+e;n.loaded={bytes:s,duration:a},n.realBitrate=Math.round(8*s/a)}if(t.bitrateTest){const e={stats:i,frag:t,part:r,id:t.type};this.onFragBuffered($f.FRAG_BUFFERED,e),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:r,part:i}=t,n=null!=i&&i.stats.loaded?i.stats:r.stats;if(n.aborted)return;if(this.ignoreFragment(r))return;const s=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(s,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=s/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==jf||"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,n=this.findBestLevel(r,t,e,0,i,1,1);if(n>-1)return n;const s=this.hls.firstLevel,a=Math.min(Math.max(s,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${s} 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:n,minAutoLevel:s}=r,a=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay();let d=n.abrBandWidthFactor,c=n.abrBandWidthUpFactor;if(l){const e=this.findBestLevel(o,s,i,l,0,d,c);if(e>=0)return this.rebufferNotice=-1,e}let u=a?Math.min(a,n.maxStarvationDelay):n.maxStarvationDelay;if(!l){const e=this.bitrateTestDelay;if(e){u=(a?Math.min(a,n.maxLoadingDelay):n.maxLoadingDelay)-e,this.info(`bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*u)} ms`),d=c=1}}const h=this.findBestLevel(o,s,i,l,u,d,c);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[s],p=r.loadLevelObj;return p&&(null==f?void 0:f.bitrate)<p.bitrate?s: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,n,s,a){var o;const l=i+n,d=this.lastLoadedFragLevel,c=-1===d?this.hls.firstLevel:d,{fragCurrent:u,partCurrent:h}=this,{levels:f,allAudioTracks:p,loadLevel:m,config:g}=this.hls;if(1===f.length)return 0;const v=f[c],y=!(null==(o=this.hls.latestLevelDetails)||!o.live),b=-1===m||-1===d;let E,w="SDR",S=(null==v?void 0:v.frameRate)||0;const{audioPreference:T,videoPreference:x}=g,A=this.audioTracksByGroup||(this.audioTracksByGroup=Mm(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 n=r.audioGroups;let s=e[r.codecSet];s||(e[r.codecSet]=s={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!n,fragmentError:0}),s.minBitrate=Math.min(s.minBitrate,r.bitrate);const a=Math.min(r.height,r.width);return s.minHeight=Math.min(s.minHeight,a),s.minFramerate=Math.min(s.minFramerate,r.frameRate),s.minIndex=Math.min(s.minIndex,i),s.maxScore=Math.max(s.maxScore,r.score),s.fragmentError+=r.fragmentError,s.videoRanges[r.videoRange]=(s.videoRanges[r.videoRange]||0)+1,n&&n.forEach(e=>{if(!e)return;const r=t.groups[e];r&&(s.hasDefaultAudio=s.hasDefaultAudio||t.hasDefaultAudio?r.hasDefault:r.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(r.channels).forEach(e=>{s.channels[e]=(s.channels[e]||0)+r.channels[e]}))}),e},{})}(f,A,t,r)),n=function(e,t,r,i,n){const s=Object.keys(e),a=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,l=null==n?void 0:n.videoCodec,d=a&&2===parseInt(a);let c=!1,u=!1,h=1/0,f=1/0,p=1/0,m=1/0,g=0,v=[];const{preferHDR:y,allowedVideoRanges:b}=Cm(t,n);for(let t=s.length;t--;){const r=e[s[t]];c||(c=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=_f(h)?h:0,f=_f(f)?f:0;const E=Math.max(1080,h),w=Math.max(30,f);p=_f(p)?p:r,r=Math.max(p,r),u||(t=void 0);const S=s.length>1;return{codecSet:s.reduce((t,i)=>{const n=e[i];if(i===t)return t;if(v=u?b.filter(e=>n.videoRanges[e]>0):[],S){if(n.minBitrate>r)return Om(i,`min bitrate of ${n.minBitrate} > current estimate of ${r}`),t;if(!n.hasDefaultAudio)return Om(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!=0)return Om(i,`audio codec preference "${o}" not found`),t;if(a&&!d){if(!n.channels[a])return Om(i,`no renditions with ${a} channel sound found (channels options: ${Object.keys(n.channels)})`),t}else if((!o||d)&&c&&0===n.channels[2])return Om(i,"no renditions with stereo sound found"),t;if(n.minHeight>E)return Om(i,`min resolution of ${n.minHeight} > maximum of ${E}`),t;if(n.minFramerate>w)return Om(i,`min framerate of ${n.minFramerate} > maximum of ${w}`),t;if(!v.some(e=>n.videoRanges[e]>0))return Om(i,`no variants with VIDEO-RANGE of ${_m(v)} found`),t;if(l&&i.indexOf(l.substring(0,4))%5!=0)return Om(i,`video codec preference "${l}" not found`),t;if(n.maxScore<g)return Om(i,`max score of ${n.maxScore} < selected max of ${g}`),t}return t&&(om(i)>=om(t)||n.fragmentError>e[t].fragmentError)?t:(m=n.minIndex,g=n.maxScore,i)},void 0),videoRanges:v,preferHDR:y,minFramerate:f,minBitrate:p,minIndex:m}}(i,w,e,T,x),{codecSet:s,videoRanges:a,minFramerate:o,minBitrate:l,minIndex:d,preferHDR:c}=n;k=d,E=s,w=c?a[a.length-1]:a[0],S=o,e=Math.max(e,l),this.log(`picked start tier ${_m(n)}`)}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>c;if(!t)continue;if(g.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){const r=navigator.mediaCapabilities;"function"==typeof(null==r?void 0:r.decodingInfo)&&bm(t,A,w,S,e,T)?(t.supportedPromise=Em(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} ${_m(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&this.log(`MediaCapabilities decodingInfo for level ${i} not smooth or powerEfficient: ${_m(e)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${i} ${_m(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=vm}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:s*e;const D=L&&i>=2*L&&0===n?t.averageBitrate:t.maxBitrate,C=this.getTimeToLoadFrag(I,x,D*v,void 0===p);if(x>=D&&(o===d||0===t.loadError&&0===t.fragmentError)&&(C<=I||!_f(C)||y&&!this.bitrateTestDelay||C<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:${c}->${o} adjustedbw(${Math.round(x)})-bitrate=${Math.round(x-D)} ttfb:${I.toFixed(1)} avgDuration:${v.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${C.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 Zf{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($f.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=sp(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($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.MANIFEST_PARSED,this.onManifestParsed,this),e.on($f.BUFFER_RESET,this.onBufferReset,this),e.on($f.BUFFER_APPENDING,this.onBufferAppending,this),e.on($f.BUFFER_CODECS,this.onBufferCodecs,this),e.on($f.BUFFER_EOS,this.onBufferEos,this),e.on($f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.on($f.FRAG_PARSED,this.onFragParsed,this),e.on($f.FRAG_CHANGED,this.onFragChanged,this),e.on($f.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.MANIFEST_PARSED,this.onManifestParsed,this),e.off($f.BUFFER_RESET,this.onBufferReset,this),e.off($f.BUFFER_APPENDING,this.onBufferAppending,this),e.off($f.BUFFER_CODECS,this.onBufferCodecs,this),e.off($f.BUFFER_EOS,this.onBufferEos,this),e.off($f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.off($f.FRAG_PARSED,this.onFragParsed,this),e.off($f.FRAG_CHANGED,this.onFragChanged,this),e.off($f.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?qf(r,i.tracks):this.sourceBuffers.forEach(e=>{const[t]=e;t&&(r[t]=qf({},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=sp(this.appendSource);if(i){const e=!!t.mediaSource;(e||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const n=this.mediaSource=t.mediaSource||new i;if(this.assignMediaSource(n),e)this._objectUrl=r.src,this.attachTransferred();else{const e=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{r.removeAttribute("src");const t=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||t&&n instanceof t,Xb(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,n=i?Object.keys(i):null,s=n?n.length:0,a=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(i&&n&&s){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: ${_m(r,(e,t)=>"initSegment"===e?void 0:t)};\ntransfer tracks: ${_m(i,(e,t)=>"initSegment"===e?void 0:t)}}`),!ap(i,r)){t.mediaSource=null,t.tracks=void 0;const n=e.currentTime,s=this.details,a=Math.max(n,(null==s?void 0:s.fragments[0].start)||0);return a-n>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${n} -> ${a}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(i)}"->"${Object.keys(r)}") start time: ${a} currentTime: ${n}`),this.onMediaDetaching($f.MEDIA_DETACHING,{}),this.onMediaAttaching($f.MEDIA_ATTACHING,t),void(e.currentTime=a))}this.transferData=void 0,n.forEach(e=>{const t=e,r=i[t];if(r){const e=r.buffer;if(e){const i=this.fragmentTracker,n=r.id;if(i.hasFragments(n)||i.hasParts(n)){const r=Cg.getBuffered(e);i.detectEvictedFragments(t,r,n,null,!0)}const s=Qb(t),a=[t,e];this.sourceBuffers[s]=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:n,_objectUrl:s}=this;if(n){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"===n.readyState;try{const t=n.sourceBuffers;for(let r=t.length;r--;)e&&t[r].abort(),n.removeSourceBuffer(t[r]);e&&n.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}n.removeEventListener("sourceopen",this._onMediaSourceOpen),n.removeEventListener("sourceended",this._onMediaSourceEnded),n.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(n.removeEventListener("startstreaming",this._onStartStreaming),n.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}i&&(i.removeEventListener("emptied",this._onMediaEmptied),r||(s&&self.URL.revokeObjectURL(s),this.mediaSrc===s?(i.removeAttribute("src"),this.appendSource&&Xb(i),i.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger($f.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[Qb(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Wb(this.tracks)}onBufferCodecs(e,t){var r;const i=this.tracks,n=Object.keys(t);this.log(`BUFFER_CODECS: "${n}" (current SB count ${this.sourceBufferCount})`);const s="audiovideo"in t&&(i.audio||i.video)||i.audiovideo&&("audio"in t||"video"in t),a=!s&&this.sourceBufferCount&&this.media&&n.some(e=>!i[e]);s||a?this.warn(`Unsupported transition between "${Object.keys(i)}" and "${n}" SourceBuffers`):(n.forEach(e=>{var r,n;const s=t[e],{id:a,codec:o,levelCodec:l,container:d,metadata:c,supplemental:u}=s;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:d,levelCodec:l,metadata:c,id:a});const v=um(m,g),y=null==v?void 0:v.replace(Yb,"$1");let b=um(o,l);const E=null==(n=b)?void 0:n.replace(Yb,"$1");b&&v&&y!==E&&("audio"===e.slice(0,5)&&(b=cm(b,this.appendSource)),this.log(`switching codec ${m} to ${b}`),b!==(h.pendingCodec||h.codec)&&(h.pendingCodec=b),h.container=d,this.appendChangeType(e,d,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}`,n={label:`change-type=${i}`,execute:()=>{const n=this.tracks[e];if(n){const s=n.buffer;null!=s&&s.changeType&&(this.log(`changing ${e} sourceBuffer type to ${i}`),s.changeType(i),n.codec=r,n.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};this.append(n,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,jf))?void 0:t.gap))return;const n={label:"block-audio",execute:()=>{var e;const t=this.tracks.video;(this.lastVideoAppendEnd>i||null!=t&&t.buffer&&Cg.isBuffered(t.buffer,i)||!0===(null==(e=this.fragmentTracker.getAppendedFrag(i,jf))?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:n,frag:e},this.append(n,"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:n,parent:s,frag:a,part:o,chunkMeta:l,offset:d}=t,c=l.buffering[n],{sn:u,cc:h}=a,f=self.performance.now();c.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"===n&&"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"!==n||"main"===s||this.blockedAudioAppend||y.ending||y.ended){if("video"===n){const r=e.end;if(t){const e=t.frag.start;(r>e||r<this.lastVideoAppendEnd||Cg.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&&!Cg.isBuffered(b,t)&&this.lastVideoAppendEnd<t&&this.blockAudio(e):this.blockAudio(e)}}const E=(o||a).start,w={label:`append-${n}`,execute:()=>{var e;c.executeStart=self.performance.now();const t=null==(e=this.tracks[n])?void 0:e.buffer;t&&(v?this.updateTimestampOffset(t,E,.1,n,u,h):void 0!==d&&_f(d)&&this.updateTimestampOffset(t,d,1e-6,n,u,h)),this.appendExecutor(i,n)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();c.executeEnd=c.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]=Cg.getBuffered(r))}),this.appendErrors[n]=0,"audio"===n||"video"===n?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger($f.BUFFER_APPENDED,{type:n,frag:a,part:o,chunkMeta:l,parent:a.type,timeRanges:t})},onError:e=>{var t;const r={type:Nf.MEDIA_ERROR,parent:a.type,details:Ff.BUFFER_APPEND_ERROR,sourceBufferName:n,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=Ff.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!i)r.errorAction=dg(!0);else if(e.name===Kb&&0===this.sourceBufferCount)r.errorAction=dg(!0);else{const e=++this.appendErrors[n];this.warn(`Failed ${e}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${n}" sourceBuffer (${i||"no media error"})`),(e>=this.hls.config.appendErrorMaxRetry||i)&&(r.fatal=!0)}this.hls.trigger($f.ERROR,r)}};this.log(`queuing "${n}" append sn: ${u}${o?" p: "+o.index:""} of ${a.type===jf?"level":"track"} ${a.level} cc: ${h}`),this.append(w,n,this.isPending(this.tracks[n]))}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($f.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:n}=t;r?this.append(this.getFlushOp(r,i,n),r):this.sourceBuffers.forEach(([e])=>{e&&this.append(this.getFlushOp(e,i,n),e)})}onFragParsed(e,t){const{frag:r,part:i}=t,n=[],s=i?i.elementaryStreams:r.elementaryStreams;s[Sp]?n.push("audiovideo"):(s[Ep]&&n.push("audio"),s[wp]&&n.push("video"));0===n.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($f.FRAG_BUFFERED,{frag:r,part:i,stats:t,id:r.type})},n).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($f.BUFFERED_TO_END,void 0)):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})):(this.tracksEnded(),this.hls.trigger($f.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===Ff.BUFFER_APPEND_ERROR&&t.frag){var r;const e=null==(r=t.errorAction)?void 0:r.nextAutoLevel;_f(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,n=r.currentTime,s=t.levelTargetDuration,a=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(_f(a)&&a>=0){const e=Math.max(a,s),t=Math.floor(n/s)*s-e;this.flushBackBuffer(n,s,t)}const o=i.frontBufferFlushThreshold;if(_f(o)&&o>0){const e=Math.max(i.maxBufferLength,o),t=Math.max(e,s),r=Math.floor(n/s)*s+t;this.flushFrontBuffer(n,s,r)}}flushBackBuffer(e,t,r){this.sourceBuffers.forEach(([e,t])=>{if(t){const n=Cg.getBuffered(t);if(n.length>0&&r>n.start(0)){var i;this.hls.trigger($f.BACK_BUFFER_REACHED,{bufferEnd:r});const t=this.tracks[e];if(null!=(i=this.details)&&i.live)this.hls.trigger($f.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($f.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:e})}}})}flushFrontBuffer(e,t,r){this.sourceBuffers.forEach(([t,i])=>{if(i){const n=Cg.getBuffered(i),s=n.length;if(s<2)return;const a=n.start(s-1),o=n.end(s-1);if(r>a||e>=a&&e<=o)return;this.hls.trigger($f.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 n=null==(e=this.overrides)?void 0:e.duration;if(n)return _f(n)?{duration:n}:null;const s=this.media.duration;return i>(_f(r.duration)?r.duration:0)&&i>s||!_f(s)?{duration:i}:null}updateMediaSource({duration:e,start:t,end:r}){const i=this.mediaSource;this.media&&i&&"open"===i.readyState&&(i.duration!==e&&(_f(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}) ${_m(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($f.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($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.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 n in e){const s=n,a=e[s];if(this.isPending(a)){const e=this.getTrackCodec(a,s),n=`${a.container};codecs=${e}`;a.codec=e,this.log(`creating sourceBuffer(${n})${this.currentOp(s)?" Queued":""} ${_m(a)}`);try{const e=r.addSourceBuffer(n),i=Qb(s),o=[s,e];t[i]=o,a.buffer=e}catch(e){var i;return this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(s),null==(i=this.operationQueue)||i.removeBlockers(),delete this.tracks[s],void this.hls.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:s,mimeType:n,parent:a.id})}this.trackSourceBuffer(s,a)}}this.bufferCreated()}getTrackCodec(e,t){const r=e.supplemental;let i=e.codec;r&&("video"===t||"audiovideo"===t)&&im(r,"video")&&(i=function(e,t){const r=[];if(e){const t=e.split(",");for(let e=0;e<t.length;e++)rm(t[e],"video")||r.push(t[e])}return t&&r.push(t),r.join(",")}(i,r));const n=um(i,e.levelCodec);return n?"audio"===t.slice(0,5)?cm(n,this.appendSource):n:""}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($f.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($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});const n=this.currentOp(e);n&&n.onError(i)}updateTimestampOffset(e,t,r,i,n,s){const a=t-e.timestampOffset;Math.abs(a)>=r&&(this.log(`Updating ${i} SourceBuffer timestampOffset to ${t} (sn: ${n} cc: ${s})`),e.timestampOffset=t)}removeExecutor(e,t,r){const{media:i,mediaSource:n}=this,s=this.tracks[e],a=null==s?void 0:s.buffer;if(!i||!n||!a)return this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void this.shiftAndExecuteNext(e);const o=_f(i.duration)?i.duration:1/0,l=_f(n.duration)?n.duration:1/0,d=Math.max(0,t),c=Math.min(r,o,l);c>d&&(!s.ending||s.ended)?(s.ended=!1,this.log(`Removing [${d},${c}] from the ${e} SourceBuffer`),a.remove(d,c)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const r=this.tracks[t],i=null==r?void 0:r.buffer;if(!i)throw new qb(`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 n=i.buffer;if(!n)return;const s=r.bind(this,e);i.listeners.push({event:t,listener:s}),n.addEventListener(t,s)}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:Zb,errorController:class extends Zf{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($f.ERROR,this.onError,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off($f.ERROR,this.onError,this),e.off($f.ERROR,this.onErrorOut,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.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)===jf?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,n=t.context;switch(t.details){case Ff.FRAG_LOAD_ERROR:case Ff.FRAG_LOAD_TIMEOUT:case Ff.KEY_LOAD_ERROR:case Ff.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case Ff.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=dg());case Ff.FRAG_GAP:case Ff.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=rg);case Ff.LEVEL_EMPTY_ERROR:case Ff.LEVEL_PARSING_ERROR:{var s;const e=t.parent===jf?t.level:i.loadLevel;t.details===Ff.LEVEL_EMPTY_ERROR&&null!=(s=t.context)&&null!=(s=s.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case Ff.LEVEL_LOAD_ERROR:case Ff.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case Ff.AUDIO_TRACK_LOAD_ERROR:case Ff.AUDIO_TRACK_LOAD_TIMEOUT:case Ff.SUBTITLE_LOAD_ERROR:case Ff.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const e=i.loadLevelObj;if(e&&(n.type===zf&&e.hasAudioGroup(n.groupId)||n.type===Gf&&e.hasSubtitleGroup(n.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=rg,void(t.errorAction.flags=ag)}return;case Ff.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:rg,flags:og});case Ff.KEY_SYSTEM_SESSION_UPDATE_FAILED:case Ff.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case Ff.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:rg,flags:lg});case Ff.BUFFER_ADD_CODEC_ERROR:case Ff.REMUX_ALLOC_ERROR:case Ff.BUFFER_APPEND_ERROR:var a;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(a=t.level)?a:i.loadLevel);return;case Ff.INTERNAL_EXCEPTION:case Ff.BUFFER_APPENDING_ERROR:case Ff.BUFFER_FULL_ERROR:case Ff.LEVEL_SWITCH_ERROR:case Ff.BUFFER_STALLED_ERROR:case Ff.BUFFER_SEEK_OVER_HOLE:case Ff.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=dg())}t.type===Nf.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=dg())}getPlaylistRetryOrSwitchAction(e,t){const r=Xm(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(Jm(r,i,Ym(e),e.response))return{action:ng,flags:sg,retryConfig:r,retryCount:i};const n=this.getLevelSwitchAction(e,t);return r&&(n.retryConfig=r,n.retryCount=i),n}getFragRetryOrSwitchAction(e){const t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:s}=t.config,a=Xm(Km(e)?s:n,e),o=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(i&&(e.details!==Ff.FRAG_GAP&&i.fragmentError++,!qm(e))){if(Jm(a,o,Ym(e),e.response))return{action:ng,flags:sg,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 n,s;const t=e.details;i.loadError++,t===Ff.BUFFER_APPEND_ERROR&&i.fragmentError++;let l=-1;const{levels:d,loadLevel:c,minAutoLevel:u,maxAutoLevel:h}=r;r.autoLevelEnabled||r.config.preserveManualLevelOnError||(r.loadLevel=-1);const f=null==(n=e.frag)?void 0:n.type,p=(f===Hf&&t===Ff.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(t===Ff.BUFFER_ADD_CODEC_ERROR||t===Ff.BUFFER_APPEND_ERROR))&&d.some(({audioCodec:e})=>i.audioCodec!==e),m="video"===e.sourceBufferName&&(t===Ff.BUFFER_ADD_CODEC_ERROR||t===Ff.BUFFER_APPEND_ERROR)&&d.some(({codecSet:e,audioCodec:t})=>i.codecSet!==e&&i.audioCodec===t),{type:g,groupId:v}=null!=(s=e.context)?s:{};for(let r=d.length;r--;){const n=(r+c)%d.length;if(n!==c&&n>=u&&n<=h&&0===d[n].loadError){var a,o;const r=d[n];if(t===Ff.FRAG_GAP&&f===jf&&e.frag){const t=d[n].details;if(t){const r=jm(e.frag,t.fragments,e.frag.start);if(null!=r&&r.gap)continue}}else{if(g===zf&&r.hasAudioGroup(v)||g===Gf&&r.hasSubtitleGroup(v))continue;if(f===Hf&&null!=(a=i.audioGroups)&&a.some(e=>r.hasAudioGroup(e))||f===Vf&&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=n;break}}if(l>-1&&r.loadLevel!==l)return e.levelRetry=!0,this.playlistError=0,{action:rg,flags:sg,nextAutoLevel:l}}return{action:rg,flags:ag}}onErrorOut(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case tg:break;case rg:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===Ff.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,n=r.nextAutoLevel;switch(i){case sg:this.switchLevel(e,n);break;case og:{const i=this.getVariantLevelIndex(e.frag),n=t.levels[i],s=null==n?void 0:n.attrs["HDCP-LEVEL"];if(r.hdcpLevel=s,"NONE"===s)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(s){t.maxHdcpLevel=Tm[Tm.indexOf(s)-1],r.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case lg:{const t=e.decryptdata;if(t){const i=this.hls.levels,n=i.length;for(let r=n;r--;){var s,a;if(this.variantHasKey(i[r],t))this.log(`Banned key found in level ${r} (${i[r].bitrate}bps) or audio group "${null==(s=i[r].audioGroups)?void 0:s.join(",")}" (${null==(a=e.frag)?void 0:a.type} fragment) ${lp(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<n)r.resolved=!0;else if(o&&o.type!==jf){const e=o.decryptdata;e&&!t.matches(e)&&(r.resolved=!0)}}break}}r.resolved||this.switchLevel(e,n)}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===Ff.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName)){const t=mm(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($f.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on($f.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off($f.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off($f.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,n=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,a=1e3*n/e,o=this.hls;if(o.trigger($f.FPS_DROP,{currentDropped:n,currentDecoded:s,totalDroppedFrames:r}),a>0&&n>o.config.fpsDroppedMonitoringThreshold*s){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($f.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:lv,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:mS,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 cy{constructor(e,t,r){super(e,t,r,"subtitle-stream-controller",Vf),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($f.LEVEL_LOADED,this.onLevelLoaded,this),e.on($f.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on($f.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on($f.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on($f.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on($f.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off($f.LEVEL_LOADED,this.onLevelLoaded,this),e.off($f.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off($f.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off($f.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off($f.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off($f.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=Jv,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)||(xp(r)&&(this.fragPrevious=r),this.state=Jv),!i)return;const n=this.tracksBuffered[this.currentTrackId];if(!n)return;let s;const a=r.start;for(let e=0;e<n.length;e++)if(a>=n[e].start&&a<=n[e].end){s=n[e];break}const o=r.start+r.duration;s?s.end=o:(s={start:a,end:o},n.push(s)),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,Vf)}}onError(e,t){const r=t.frag;(null==r?void 0:r.type)===Vf&&(t.details===Ff.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Zv&&(this.state=Jv))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){this.levels&&jb(this.levels,t)?this.levels=t.map(e=>new Pm(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{const t=new Pm(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Vf),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!==Zv&&this.setInterval(500)}onSubtitleTrackLoaded(e,t){var r;const{currentTrackId:i,levels:n}=this,{details:s,id:a}=t;if(!n)return void this.warn(`Subtitle tracks were reset while loading level ${a}`);const o=n[a];if(a>=n.length||!o)return;this.log(`Subtitle track ${a} loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""},duration:${s.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(s.live||null!=(r=o.details)&&r.live){if(s.deltaUpdateFailed)return;const e=this.mainDetails;if(!e)return void(this.startFragRequested=!1);const t=e.fragments[0];var d;if(o.details)l=this.alignPlaylists(s,o.details,null==(d=this.levelLastLoaded)?void 0:d.details),0===l&&t&&(l=t.start,Nv(s,l));else s.hasProgramDateTime&&e.hasProgramDateTime?(Kv(s,e),l=s.fragmentStart):t&&(l=t.start,Nv(s,l));e&&!this.startFragRequested&&this.setStartPosition(e,l)}if(o.details=s,this.levelLastLoaded=o,a===i&&(this.hls.trigger($f.SUBTITLE_TRACK_UPDATED,{details:s,id:a,groupId:t.groupId}),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===Jv)){jm(null,s.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,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&null!=i&&i.key&&i.iv&&Yg(i.method)){const e=performance.now();this.decrypter.decrypt(new Uint8Array(r),i.key.buffer,i.iv.buffer,Kg(i.method)).catch(e=>{throw n.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(r=>{const i=performance.now();n.trigger($f.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:e,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=Jv})}}doTick(){if(this.media){if(this.state===Jv){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,n=this.getLoadPosition(),s=Cg.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,i.maxBufferHole),{end:a,len:o}=s,l=r.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;const d=l.fragments,c=d.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=jm(f,d,Math.max(d[0].start,a),t),!h&&f&&f.start<d[0].start&&(h=d[0])}else h=d[c-1];if(h=this.filterReplacedPrimary(h,r.details),!h)return;const p=d[h.sn-l.startSN-1];if(p&&p.cc===h.cc&&this.fragmentTracker.getState(p)===cg&&(h=p),this.fragmentTracker.getState(h)===cg){const e=this.mapToInitFragWhenRequired(h);e&&this.loadFragment(e,r,a)}}}else this.state=Jv}loadFragment(e,t,r){xp(e)?super.loadFragment(e,t,r):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new bw(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends Gb{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=iw(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($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.MANIFEST_PARSED,this.onManifestParsed,this),e.on($f.LEVEL_LOADING,this.onLevelLoading,this),e.on($f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on($f.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on($f.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.MANIFEST_PARSED,this.onManifestParsed,this),e.off($f.LEVEL_LOADING,this.onLevelLoading,this),e.off($f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off($f.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off($f.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;iw(r.textTracks).forEach(e=>{tw(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:n}=t,s=this.tracksInGroup[r];if(!s||s.groupId!==i)return void this.warn(`Subtitle track with id:${r} and group:${i} not found in active group ${null==s?void 0:s.groupId}`);const a=s.details;s.details=t.details,this.log(`Subtitle track ${r} "${s.name}" lang:${s.lang} group:${i} loaded [${n.startSN}-${n.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 n=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(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.subtitlePreference;if(!n&&t){this.selectDefaultTrack=!1;const r=Fm(t,e);if(r>-1)n=e[r];else{const e=Fm(t,this.tracks);n=this.tracks[e]}}let i=this.findTrackId(n);-1===i&&n&&(i=this.findTrackId(null));const s={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${null==r?void 0:r.join(",")}" group-id`),this.hls.trigger($f.SUBTITLE_TRACKS_UPDATED,s),-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 n=t[i];if((!r||n.default)&&(r||e)&&(!e||$m(n,e)))return i}if(e){for(let r=0;r<t.length;r++){const i=t[r];if(Hb(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(Hb(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(Vb(t[r],e))return r}}return-1}onError(e,t){!t.fatal&&t.context&&(t.context.type!==Gf||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&&$m(e,r))return r;const i=Fm(e,this.tracksInGroup);if(i>-1){const e=this.tracksInGroup[i];return this.setSubtitleTrack(i),e}if(r)return null;{const r=Fm(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,n=this.getUrlWithDirectives(e.url,t),s=e.details,a=null==s?void 0:s.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&&s.live?" age "+a.toFixed(1)+(s.type&&" "+s.type||""):""} ${n}`),this.hls.trigger($f.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:i,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=iw(e.textTracks),r=this.currentTrack;let i;if(r&&(i=t.filter(e=>Vb(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||!_f(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($f.SUBTITLE_TRACK_SWITCH,{id:e});const n=!!i.details&&!i.details.live;if(e===this.trackId&&i===r&&n)return;this.log(`Switching to subtitle-track ${e}`+(i?` "${i.name}" lang:${i.lang} group:${i.groupId}`:""));const{id:s,groupId:a="",name:o,type:l,url:d}=i;this.hls.trigger($f.SUBTITLE_TRACK_SWITCH,{id:s,groupId:a,name:o,type:l,url:d});const c=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(c)}},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($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.on($f.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on($f.FRAG_LOADING,this.onFragLoading,this),e.on($f.FRAG_LOADED,this.onFragLoaded,this),e.on($f.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on($f.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on($f.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on($f.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on($f.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.off($f.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off($f.FRAG_LOADING,this.onFragLoading,this),e.off($f.FRAG_LOADED,this.onFragLoaded,this),e.off($f.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off($f.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off($f.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off($f.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off($f.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new cS(this,"textTrack1"),t=new cS(this,"textTrack2"),r=new cS(this,"textTrack3"),i=new cS(this,"textTrack4");this.cea608Parser1=new Nw(1,e,t),this.cea608Parser2=new Nw(3,r,i)}addCues(e,t,r,i,n){let s=!1;for(let e=n.length;e--;){const i=n[e],a=fS(i[0],i[1],t,r);if(a>=0&&(i[0]=Math.min(i[0],t),i[1]=Math.max(i[1],r),s=!0,a/(r-t)>.5))return}if(s||n.push([t,r]),this.config.renderTextTracksNatively){const n=this.captionsTracks[e];this.Cues.newCue(n,t,r,i)}else{const n=this.Cues.newCue(null,t,r,i);this.hls.trigger($f.CUES_PARSED,{type:"captions",cues:n,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:n,trackId:s}){const{unparsedVttFrags:a}=this;r===jf&&(this.initPTS[t.cc]={baseTime:i,timescale:n,trackId:s}),a.length&&(this.unparsedVttFrags=[],a.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded($f.FRAG_LOADED,e):this.hls.trigger($f.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 n=r.textTracks[i];if(hS(n,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return n}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:n,languageCode:s}=t[e],a=this.getExistingTrack(n,s);if(a)r[e]=a,tw(r[e]),JE(r[e],i);else{const t=this.createTextTrack("captions",n,s);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($f.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=>{tw(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++)tw(t[e])}onSubtitleTracksUpdated(e,t){const r=t.subtitleTracks||[],i=r.some(e=>e.textCodec===Jw);if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(jb(this.tracks,r))return void(this.tracks=r);if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const e=this.media,t=e?iw(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]&&hS(t[i],e)){r=t[i],t[i]=null;break}r&&(i=r)}if(i)tw(i);else{const t=uS(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($f.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===jf){var r,i;const{cea608Parser1:e,cea608Parser2:n,lastSn:s}=this,{cc:a,sn:o}=t.frag,l=null!=(r=null==(i=t.part)?void 0:i.index)?r:-1;e&&n&&(o!==s+1||o===s&&l!==this.lastPartIndex+1||a!==this.lastCc)&&(e.reset(),n.reset()),this.lastCc=a,this.lastSn=o,this.lastPartIndex=l}}onFragLoaded(e,t){const{frag:r,payload:i}=t;if(r.type===Vf)if(i.byteLength){const e=r.decryptdata,n="stats"in t;if(null==e||!e.encrypted||n){const e=this.tracks[r.level],n=this.vttCCs;n[r.cc]||(n[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),e&&e.textCodec===Jw?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger($f.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;iS(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),r.trigger($f.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{r.logger.log(`Failed to parse IMSC1: ${t}`),r.trigger($f.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}_parseVTTs(e){var t;const{frag:r,payload:i}=e,{initPTS:n,unparsedVttFrags:s}=this,a=n.length-1;if(!n[r.cc]&&-1===a)return void s.push(e);const o=this.hls;Zw(null!=(t=r.initSegment)&&t.data?Wp(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($f.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},t=>{const n="Missing initPTS for VTT MPEGTS"===t.message;n?s.push(e):this._fallbackToIMSC1(r,i),o.logger.log(`Failed to parse VTT cue: ${t}`),n&&a>r.cc||o.trigger($f.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:t})})}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||iS(t,this.initPTS[e.cc],()=>{r.textCodec=Jw,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=>ew(r,e))}else{const i=this.tracks[t];if(!i)return;const n=i.default?"default":"subtitles"+t;r.trigger($f.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:r}=t;r.type===Vf&&this.onFragLoaded($f.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!==jf||"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:n}){const{media:s}=this;if(s&&!(s.currentTime<r)){if(!n||"video"===n){const{captionsTracks:e}=this;Object.keys(e).forEach(i=>rw(e[i],t,r))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==i){const{textTracks:e}=this;Object.keys(e).forEach(r=>rw(e[r],t,i))}}}extractCea608Data(e){const t=[[],[]],r=31&e[0];let i=2;for(let n=0;n<r;n++){const r=e[i++],n=127&e[i++],s=127&e[i++];if(0===n&&0===s)continue;if(!!(4&r)){const e=3&r;0!==e&&1!==e||(t[e].push(n),t[e].push(s))}}return t}},audioStreamController:class extends cy{constructor(e,t,r){super(e,t,r,"audio-stream-controller",Hf),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($f.LEVEL_LOADED,this.onLevelLoaded,this),e.on($f.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on($f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on($f.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on($f.BUFFER_RESET,this.onBufferReset,this),e.on($f.BUFFER_CREATED,this.onBufferCreated,this),e.on($f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on($f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on($f.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on($f.FRAG_LOADING,this.onFragLoading,this),e.on($f.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off($f.LEVEL_LOADED,this.onLevelLoaded,this),e.off($f.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off($f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off($f.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off($f.BUFFER_RESET,this.onBufferReset,this),e.off($f.BUFFER_CREATED,this.onBufferCreated,this),e.off($f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off($f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off($f.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off($f.FRAG_LOADING,this.onFragLoading,this),e.off($f.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:n,trackId:s}){if(r===jf){const e=t.cc,r=this.fragCurrent;if(this.initPTS[e]={baseTime:i,timescale:n,trackId:s},this.log(`InitPTS for cc: ${e} found from main: ${i/n} (${i}/${n}) trackId: ${s}`),this.mainAnchor=t,this.state===ly){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===Jv&&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 n=(i||e).cc,s=Wm(this.getLevelDetails(),n,this.getLoadPosition());s&&(this.log(`Syncing with main frag at ${s.start} cc ${s.cc}`),this.startFragRequested=!1,this.nextLoadPosition=s.start,this.resetLoadingState(),this.state===Jv&&this.doTickIdle())}startLoad(e,t){if(!this.levels)return this.startPosition=e,void(this.state=Zv);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=Jv):this.state=iy,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case Jv:this.doTickIdle();break;case iy:{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=ly}break}case ry:this.checkRetryDate();break;case ly:{const e=this.waitingData;if(e){const{frag:t,part:r,cache:i,complete:n}=e,s=this.mainAnchor;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.state=ty;const e={frag:t,part:r,payload:i.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(e),n&&super._handleFragmentLoadComplete(e)}else s&&s.cc!==e.frag.cc&&this.syncWithAnchor(s,e.frag)}else this.state=Jv}}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:n}=this,s=t.config;if(!this.buffering||!i&&!this.primaryPrefetch&&(this.startFragRequested||!s.startFragPrefetch)||null==r||!r[n])return;const a=r[n],o=a.details;if(!o||this.waitForLive(a)||this.waitForCdnTuneIn(o))return this.state=iy,void(this.startFragRequested=!1);const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,Ep,Hf));const d=this.getFwdBufferInfo(l,Hf);if(null===d)return;if(!this.switchingTrack&&this._streamEnded(d,o))return t.trigger($f.BUFFER_EOS,{type:"audio"}),void(this.state=ay);const c=d.len,u=t.maxBufferLength,h=o.fragments,f=h[0].start,p=this.getLoadPosition(),m=this.flushing?p:d.end;if(this.switchingTrack&&i){const e=p;o.PTSKnown&&e<f&&(d.end>f||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=f+.05)}if(c>=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,d,jf,u)),!g)return void(this.bufferFlushed=!0);let v=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&v&&xp(g)&&!g.endList&&(!o.live||!this.loadingParts&&m<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(v)===fg&&(this.mainFragLoading=v=null),v&&xp(v))){if(g.start>v.end){const e=this.fragmentTracker.getFragAtPos(m,jf);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 Pm(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!==Zv&&(this.setInterval(100),this.state=Jv,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($f.AUDIO_TRACK_LOADED,r))}onAudioTrackLoaded(e,t){var r;const{levels:i}=this,{details:n,id:s,groupId:a,track:o}=t;if(!i)return void this.warn(`Audio tracks reset while loading track ${s} "${o.name}" of "${a}"`);const l=this.mainDetails;if(!l||n.endCC>l.endCC||l.expired)return this.cachedTrackLoadedData=t,void(this.state!==Zv&&(this.state=iy));this.cachedTrackLoadedData=null,this.log(`Audio track ${s} "${o.name}" of "${a}" loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const d=i[s];let c=0;if(n.live||null!=(r=d.details)&&r.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;var u;if(d.details)c=this.alignPlaylists(n,d.details,null==(u=this.levelLastLoaded)?void 0:u.details);n.alignedSliding||(Yv(n,l),n.alignedSliding||Kv(n,l),c=n.fragmentStart)}d.details=n,this.levelLastLoaded=d,this.startFragRequested||this.setStartPosition(l,c),this.hls.trigger($f.AUDIO_TRACK_UPDATED,{details:n,id:s,groupId:t.groupId}),this.state!==iy||this.waitForCdnTuneIn(n)||(this.state=Jv),this.tick()}_handleFragmentLoadProgress(e){var t;const r=e.frag,{part:i,payload:n}=e,{config:s,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 d=l.details;if(!d)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);const c=s.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let u=this.transmuxer;u||(u=this.transmuxer=new zb(this.hls,Hf,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,s=-1!==t,a=new Pg(r.level,r.sn,r.stats.chunkCount,n.byteLength,t,s);u.push(n,f,c,"",r,i,d.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 [${d.startSN} ,${d.endSN}],track ${a}`);const{cache:e}=this.waitingData=this.waitingData||{frag:r,part:i,cache:new hy,complete:!1};e.push(new Uint8Array(n)),this.state!==Zv&&(this.state=ly)}}_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===jf&&xp(t.frag)&&(this.mainFragLoading=t,this.state===Jv&&this.tick())}onFragBuffered(e,t){const{frag:r,part:i}=t;if(r.type===Hf)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(xp(r)){this.fragPrevious=r;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger($f.AUDIO_TRACK_SWITCHED,Qf({},e)))}this.fragBufferedComplete(r,i),this.media&&this.tick()}else this.audioOnly||r.type!==jf||r.elementaryStreams.video||r.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}onError(e,t){var r;if(t.fatal)this.state=oy;else switch(t.details){case Ff.FRAG_GAP:case Ff.FRAG_PARSING_ERROR:case Ff.FRAG_DECRYPT_ERROR:case Ff.FRAG_LOAD_ERROR:case Ff.FRAG_LOAD_TIMEOUT:case Ff.KEY_LOAD_ERROR:case Ff.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Hf,t);break;case Ff.AUDIO_TRACK_LOAD_ERROR:case Ff.AUDIO_TRACK_LOAD_TIMEOUT:case Ff.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==iy||(null==(r=t.context)?void 0:r.type)!==zf||(this.state=Jv);break;case Ff.BUFFER_ADD_CODEC_ERROR:case Ff.BUFFER_APPEND_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case Ff.BUFFER_FULL_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case Ff.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,{type:t}){t!==wp&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==wp){this.flushing=!1,this.bufferFlushed=!0,this.state===ay&&(this.state=Jv);const e=this.mediaBuffer||this.media;e&&(this.afterBufferFlushed(e,t,Hf),this.tick())}}_handleTransmuxComplete(e){var t;const r="audio",{hls:i}=this,{remuxResult:n,chunkMeta:s}=e,a=this.getCurrentContext(s);if(!a)return void this.resetWhenMissingContext(s);const{frag:o,part:l,level:d}=a,{details:c}=d,{audio:u,text:h,id3:f,initSegment:p}=n;if(!this.fragContextChanged(o)&&c){if(this.state=ny,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=p&&p.tracks){const e=o.initSegment||o;if(this.unhandledEncryptionError(p,o))return;this._bufferInitSegment(d,p.tracks,e,s),i.trigger($f.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[Ep]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(Ep,e,t,r,i),this.bufferFragmentData(u,o,l,s)}if(null!=f&&null!=(t=f.samples)&&t.length){const e=qf({id:r,frag:o,details:c},f);i.trigger($f.FRAG_PARSING_METADATA,e)}if(h){const e=qf({id:r,frag:o,details:c},h);i.trigger($f.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(e,t,r,i){if(this.state!==ny)return;if(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio)return;const n=t.audio;n.id=Hf;const s=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${s}/${n.codec}]`),s&&1===s.split(",").length&&(n.levelCodec=s),this.hls.trigger($f.BUFFER_CODECS,t);const a=n.initSegment;if(null!=a&&a.byteLength){const e={type:"audio",frag:r,part:null,chunkMeta:i,parent:r.type,data:a};this.hls.trigger($f.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);var n;if(this.switchingTrack||i===cg||i===hg)if(xp(e))if(null!=(n=t.details)&&n.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=ly;const r=this.mainDetails;r&&r.fragmentStart!==t.details.fragmentStart&&Kv(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:n,audioCodec:s,channels:a}=this.bufferedTrack;$m({name:t,lang:r,assocLang:i,characteristics:n,audioCodec:s,channels:a},e,Bm)||(zm(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($f.AUDIO_TRACK_SWITCHED,Qf({},e))}},audioTrackController:class extends Gb{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($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.MANIFEST_PARSED,this.onManifestParsed,this),e.on($f.LEVEL_LOADING,this.onLevelLoading,this),e.on($f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on($f.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on($f.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.MANIFEST_PARSED,this.onManifestParsed,this),e.off($f.LEVEL_LOADING,this.onLevelLoading,this),e.off($f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off($f.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off($f.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:n}=t,s=this.tracksInGroup[r];if(!s||s.groupId!==i)return void this.warn(`Audio track with id:${r} and group:${i} not found in active group ${null==s?void 0:s.groupId}`);const a=s.details;s.details=t.details,this.log(`Audio track ${r} "${s.name}" lang:${s.lang} group:${i} loaded [${n.startSN}-${n.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 n=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(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.audioPreference;if(!n&&t){const r=Fm(t,e,Bm);if(r>-1)n=e[r];else{const e=Fm(t,this.tracks);n=this.tracks[e]}}let i=this.findTrackId(n);-1===i&&n&&(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($f.AUDIO_TRACKS_UPDATED,a);const o=this.trackId;if(-1!==i&&-1===o)this.setAudioTrack(i);else if(e.length&&-1===o){var s;const t=new Error(`No audio track selected for current audio group-ID(s): ${null==(s=this.groupIds)?void 0:s.join(",")} track count: ${e.length}`);this.warn(t.message),this.hls.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}}onError(e,t){!t.fatal&&t.context&&(t.context.type!==zf||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&&$m(e,i,Bm))return i;const n=Fm(e,this.tracksInGroup,Bm);if(n>-1){const e=this.tracksInGroup[n];return this.setAudioTrack(n),e}if(i){let i=t.loadLevel;-1===i&&(i=t.firstAutoLevel);const n=function(e,t,r,i,n){const s=t[i],a=t.reduce((e,t,r)=>{const i=t.uri;return(e[i]||(e[i]=[])).push(r),e},{})[s.uri];a.length>1&&(i=Math.max.apply(Math,a));const o=s.videoRange,l=s.frameRate,d=s.codecSet.substring(0,4),c=Um(t,i,t=>{if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==d)return!1;const i=t.audioGroups,s=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return Fm(e,s,n)>-1});return c>-1?c:Um(t,i,t=>{const i=t.audioGroups,s=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return Fm(e,s,n)>-1})}(e,t.levels,r,i,Bm);if(-1===n)return null;t.nextLoadLevel=n}if(e.channels||e.audioCodec){const t=Fm(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],n=i.details&&!i.details.live;if(e===this.trackId&&i===r&&n)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($f.AUDIO_TRACK_SWITCHING,Qf({},i)),n)return;const s=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(s)}findTrackId(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||$m(e,i,Bm)))return r}if(e){const{name:r,lang:i,assocLang:n,characteristics:s,audioCodec:a,channels:o}=e;for(let e=0;e<t.length;e++){if($m({name:r,lang:i,assocLang:n,characteristics:s,audioCodec:a,channels:o},t[e],Bm))return e}for(let r=0;r<t.length;r++){const i=t[r];if(Hb(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(Hb(e.attrs,i.attrs,["LANGUAGE"]))return r}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&zm(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const r=e.id,i=e.groupId,n=this.getUrlWithDirectives(e.url,t),s=e.details,a=null==s?void 0:s.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&&s.live?" age "+a.toFixed(1)+(s.type&&" "+s.type||""):""} ${n}`),this.hls.trigger($f.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:i,deliveryDirectives:t||null,track:e})}},emeController:KE,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:Jb.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],n=this.getObjectType(t),s={d:1e3*(r||t).duration,ot:n};n!==Jb.VIDEO&&n!==Jb.AUDIO&&n!=Jb.MUXED||(s.br=i.bitrate/1e3,s.tb=this.getTopBandwidth(n)/1e3,s.bl=this.getBufferLength(n));const a=r?this.getNextPart(r):this.getNextFrag(t);null!=a&&a.url&&a.url!==t.url&&(s.nor=a.url),this.apply(e,s)}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($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($f.MEDIA_DETACHED,this.onMediaDetached,this),e.on($f.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($f.MEDIA_DETACHED,this.onMediaDetached,this),e.off($f.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:eE.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){qf(t,this.createData());const r=t.ot===Jb.INIT||t.ot===Jb.VIDEO||t.ot===Jb.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 n={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),GE(e.headers,t,n)):e.url=VE(e.url,t,n)}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,n=null==(t=this.hls.levels[i.level])||null==(t=t.details)?void 0:t.partList;if(n){const{sn:e}=i;for(let t=n.length-1;t>=0;t--){const i=n[t];if(i.index===r&&i.fragment.sn===e)return n[t+1]}}}getObjectType(e){const{type:t}=e;return"subtitle"===t?Jb.TIMED_TEXT:"initSegment"===e.sn?Jb.INIT:"audio"===t?Jb.AUDIO:"main"===t?this.hls.audioTracks.length?Jb.VIDEO:Jb.MUXED:void 0}getTopBandwidth(e){let t,r=0;const i=this.hls;if(e===Jb.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===Jb.AUDIO?this.audioBuffer:this.videoBuffer;if(!r||!t)return NaN;return 1e3*Cg.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 Zf{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($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.on($f.MANIFEST_PARSED,this.onManifestParsed,this),e.on($f.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.off($f.MANIFEST_PARSED,this.onManifestParsed,this),e.off($f.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)===rg&&r.flags===ag){const e=this.levels;let i=this._pathwayPriority,n=this.pathwayId;if(t.context){const{groupId:r,pathwayId:i,type:s}=t.context;r&&e?n=this.getPathwayForGroupId(r,s,n):i&&(n=i)}n in this.penalizedPathways||(this.penalizedPathways[n]=performance.now()),!i&&e&&(i=this.pathways()),i&&i.length>1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==n),t.details!==Ff.BUFFER_APPEND_ERROR||t.fatal?r.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${n} levels: ${e?e.length:e} priorities: ${_m(i)} penalized: ${_m(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 n=e[i];if(n in r)continue;if(n===this.pathwayId)return;const s=this.hls.nextLoadLevel,a=this.hls.levels[s];if(t=this.getLevelsForPathway(n),t.length>0){this.log(`Setting Pathway to "${n}"`),this.pathwayId=n,zv(t),this.hls.trigger($f.LEVELS_UPDATED,{levels:t});const e=this.hls.levels[s];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=s);break}}}getPathwayForGroupId(e,t,r){const i=this.getLevelsForPathway(r).concat(this.levels||[]);for(let r=0;r<i.length;r++)if(t===zf&&i[r].hasAudioGroup(e)||t===Gf&&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:n,"BASE-ID":s,"URI-REPLACEMENT":a}=e;if(t.some(e=>e.pathwayId===n))return;const o=this.getLevelsForPathway(s).map(e=>{const t=new Ug(e.attrs);t["PATHWAY-ID"]=n;const s=t.AUDIO&&`${t.AUDIO}_clone_${n}`,o=t.SUBTITLES&&`${t.SUBTITLES}_clone_${n}`;s&&(r[t.AUDIO]=s,t.AUDIO=s),o&&(i[t.SUBTITLES]=o,t.SUBTITLES=o);const l=YE(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),d=new Pm({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++)d.addGroupId("audio",`${e.audioGroups[t]}_clone_${n}`);if(e.subtitleGroups)for(let t=1;t<e.subtitleGroups.length;t++)d.addGroupId("text",`${e.subtitleGroups[t]}_clone_${n}`);return d});t.push(...o),WE(this.audioTracks,r,a,n),WE(this.subtitleTracks,i,a,n)})}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 n={responseType:"json",url:i.href},s=t.steeringManifestLoadPolicy.default,a=s.errorRetry||s.timeoutRetry||{},o={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(e,t,r,n)=>{this.log(`Loaded steering manifest: "${i}"`);const s=e.data;if(1!==(null==s?void 0:s.VERSION))return void this.log(`Steering VERSION ${s.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=s.TTL;const{"RELOAD-URI":a,"PATHWAY-CLONES":o,"PATHWAY-PRIORITY":l}=s;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 d={steeringManifest:s,url:i.toString()};this.hls.trigger($f.STEERING_MANIFEST_LOADED,d),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 n=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&&(n=1e3*parseFloat(t))}return void this.log(`Steering manifest ${t.url} rate limited`)}this.scheduleRefresh(this.uri||t.url,n)},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(n,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 Zf{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 n;const t=this.findItemIndex(i);let s=this.schedule.findItemIndexAtTime(e);if(-1===s&&(s=t+(r?-1:1),this.log(`seeked ${r?"back ":""}to position not covered by schedule ${e} (resolving from ${t} to ${s})`)),!this.isInterstitial(i)&&null!=(n=this.media)&&n.paused&&(this.shouldPlay=!1),!r&&s>t){const e=this.schedule.findJumpRestrictedIndex(t+1,s);if(e>t)return void this.setSchedulePosition(e)}return void this.setSchedulePosition(s)}const s=this.playingAsset;if(!s){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=s.timelineStart,o=s.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,s))},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,n=r.events||[],s=r.items||[],a=r.durations,o=e.map(e=>e.identifier),l=!(!n.length&&!o.length);(l||t)&&this.log(`INTERSTITIALS_UPDATED (${n.length}): ${n}\nSchedule: ${s.map(e=>mw(e))} pos: ${this.timelinePos}`),o.length&&this.log(`Removed events ${o}`);let d=null,c=null;i&&(d=this.updateItem(i,this.timelinePos),this.itemsMatch(i,d)?this.playingItem=d:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const u=this.bufferingItem;if(u&&(c=this.updateItem(u,this.bufferedPos),this.itemsMatch(u,c)?this.bufferingItem=c: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)>sw&&this.warn(`${i} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),l||t){if(this.hls.trigger($f.INTERSTITIALS_UPDATED,{events:n.slice(0),schedule:s.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(d,i),u&&c!==d&&this.trimInPlace(c,u),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new gw(e),this.schedule=new pw(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.on($f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on($f.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on($f.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on($f.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on($f.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on($f.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on($f.BUFFER_APPENDED,this.onBufferAppended,this),e.on($f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on($f.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on($f.MEDIA_ENDED,this.onMediaEnded,this),e.on($f.ERROR,this.onError,this),e.on($f.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.off($f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off($f.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off($f.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off($f.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off($f.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off($f.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off($f.BUFFER_CODECS,this.onBufferCodecs,this),e.off($f.BUFFER_APPENDED,this.onBufferAppended,this),e.off($f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off($f.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off($f.MEDIA_ENDED,this.onMediaEnded,this),e.off($f.ERROR,this.onError,this),e.off($f.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){Xv(e,"play",this.onPlay),Xv(e,"pause",this.onPause),Xv(e,"seeking",this.onSeeking),Xv(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const r=this.media=t.media;qv(r,"seeking",this.onSeeking),qv(r,"timeupdate",this.onTimeupdate),qv(r,"play",this.onPlay),qv(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,s,a,o)=>{if(t){let l=t[i].start;const d=t.event;if(d){if("playout"===i||d.timelineOccupancy!==aw.Point){const e=r(s);(null==e?void 0:e.interstitial)===d&&(l+=e.assetItem.startOffset+e[o])}}else{l+=("bufferedPos"===a?n():e[a])-t.start}return l}return 0},n=()=>{const t=e.bufferedPos;return t===Number.MAX_VALUE?s("primary"):Math.max(t,0)},s=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,n)=>{var s,a;const o=e.effectivePlayingItem;if(null!=o&&null!=(s=o.event)&&s.restrictions.skip||!e.schedule)return;e.log(`seek to ${t} "${n}"`);const l=e.effectivePlayingItem,d=e.schedule.findItemIndexAtTime(t,n),c=null==(a=e.schedule.items)?void 0:a[d],u=e.getBufferingPlayer(),h=null==u?void 0:u.interstitial,f=null==h?void 0:h.appendInPlace,p=l&&e.itemsMatch(l,c);if(l&&(f||p)){const s=r(e.playingAsset),a=(null==s?void 0:s.media)||e.primaryMedia;if(a){const r="primary"===n?a.currentTime:i(l,n,e.playingAsset,"timelinePos","currentTime"),o=t-r,d=(f?r:a.currentTime)+o;if(d>=0&&(!s||f||d<=s.duration))return void(a.currentTime=d)}}if(c){let r=t;if("primary"!==n){const e=t-c[n].start;r=c.start+e}const i=!e.isInterstitial(c);if(e.isInterstitial(l)&&!l.event.appendInPlace||!i&&!c.event.appendInPlace){if(l){const s=e.findItemIndex(l);if(d>s){const t=e.schedule.findJumpRestrictedIndex(s+1,d);if(t>s)return void e.setSchedulePosition(t)}let a=0;if(i)e.timelinePos=r,e.checkBuffer();else{const e=c.event.assetList,r=t-(c[n]||c).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(d,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(),n=e.bufferingItem;var s;return n&&n===r&&(i(n,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-n.playout.start||(null==(s=e.bufferingAsset)?void 0:s.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 n()},get currentTime(){const t=e.timelinePos;return t>0?t:0},set currentTime(e){a(e,"primary")},get duration(){return s("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 s("integrated")},get seekableStart(){var t;return((t,r)=>{var i;if(0!==t&&"primary"!==r&&null!=(i=e.schedule)&&i.length){var n;const i=e.schedule.findItemIndexAtTime(t),s=null==(n=e.schedule.items)?void 0:n[i];if(s)return t+(s[r].start-s.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 n=null==(t=i)?void 0:t.currentTime;return void 0!==n&&_f(n)?n: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} ${_m(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 n=null;const s=this.hls,a=e!==s,o=a&&e.interstitial.appendInPlace,l=null==(r=this.detachedData)?void 0:r.mediaSource;let d;if(s.media)o&&(n=s.transferMedia(),this.detachedData=n),d="Primary";else if(l){const e=this.getBufferingPlayer();e?(n=e.transferMedia(),d=`${e}`):d="detached MediaSource"}else d="detached media";if(!n)if(l)n=this.detachedData,this.log(`using detachedData: MediaSource ${_m(n)}`);else if(!this.detachedData||s.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 c=n&&"mediaSource"in n&&"closed"!==(null==(i=n.mediaSource)?void 0:i.readyState),u=c&&n?n:t;this.log(`${c?"transfering MediaSource":"attaching media"} to ${a?e:"Primary"} from ${d} (media.currentTime: ${t.currentTime})`);const h=this.schedule;if(u===n&&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(yw("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),n=uw(r,i);if(r.isAssetPastPlayoutLimit(n)){if(this.schedule){var s;const t=null==(s=this.schedule.items)?void 0:s[this.findItemIndex(e)+1];t&&this.bufferedToItem(t)}}else this.bufferedToEvent(e,n)}advanceAfterAssetEnded(e,t,r){const i=uw(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 n=e.resumeTime;this.timelinePos<n&&(this.log(yw("advanceAfterAssetEnded",n)),this.timelinePos=n,e.appendInPlace&&this.advanceInPlace(n),this.checkBuffer(this.bufferedPos<n)),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,n=r.getEvent(i);if(n){const t=r.findEventIndex(i),s=r.findAssetIndex(n,e);this.advanceAfterAssetEnded(n,t,s-1)}}setSchedulePosition(e,t){var r;const i=null==(r=this.schedule)?void 0:r.items;if(!i||this.playbackDisabled)return;const n=e>=0?i[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${n?mw(n):n}) pos: ${this.timelinePos}`);const s=this.waitingItem||this.playingItem,a=this.playingLastItem;if(this.isInterstitial(s)){const r=s.event,d=this.playingAsset,c=null==d?void 0:d.identifier,u=c?this.getAssetPlayer(c):null;if(u&&c&&(!this.eventItemsMatch(s,n)||void 0!==t&&c!==r.assetList[t].identifier)){var o;const t=r.findAssetIndex(d);if(this.log(`INTERSTITIAL_ASSET_ENDED ${t+1}/${r.assetList.length} ${hw(d)}`),this.endedAsset=d,this.playingAsset=null,this.hls.trigger($f.INTERSTITIAL_ASSET_ENDED,{asset:d,assetListIndex:t,event:r,schedule:i.slice(0),scheduleIndex:e,player:u}),s!==this.playingItem)return void(this.itemsMatch(s,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(r,this.findItemIndex(this.playingItem),t));this.retreiveMediaSource(c,n),!u.media||null!=(o=this.detachedData)&&o.mediaSource||u.detachMedia()}if(!this.eventItemsMatch(s,n)&&(this.endedItem=s,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${r} ${mw(s)}`),r.hasPlayed=!0,this.hls.trigger($f.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(n&&e){const r=this.findItemIndex(n);this.advanceSchedule(r,e,t,s,a)}return}}this.advanceSchedule(e,i,t,s,a)}advanceSchedule(e,t,r,i,n){const s=this.schedule;if(!s)return;const a=t[e]||null,o=this.primaryMedia,l=this.playerQueue;if(l.length&&l.forEach(t=>{const r=t.interstitial,i=s.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 n=a.event;if(void 0===r){const t=uw(n,(r=s.findAssetIndex(n,this.timelinePos))-1);if(n.isAssetPastPlayoutLimit(t)||n.appendInPlace&&this.timelinePos===a.end)return void this.advanceAfterAssetEnded(n,e,r);r=t}const l=this.waitingItem;this.assetsBuffered(a,o)||this.setBufferingItem(a);let d=this.preloadAssets(n,r);if(this.eventItemsMatch(a,l||i)||(this.waitingItem=a,this.log(`INTERSTITIAL_STARTED ${mw(a)} ${n.appendInPlace?"append in place":""}`),this.hls.trigger($f.INTERSTITIAL_STARTED,{event:n,schedule:t.slice(0),scheduleIndex:e})),!n.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${n}`);if(n.assetListLoader&&(n.assetListLoader.destroy(),n.assetListLoader=void 0),!o)return void this.log(`Waiting for attachMedia to start Interstitial ${n}`);this.waitingItem=this.endedItem=null,this.playingItem=a;const c=n.assetList[r];if(!c)return void this.advanceAfterAssetEnded(n,e,r||0);if(d||(d=this.getAssetPlayer(c.identifier)),null===d||d.destroyed){const e=n.assetList.length;this.warn(`asset ${r+1}/${e} player destroyed ${n}`),d=this.createAssetPlayer(n,c,r),d.loadSource()}if(!this.eventItemsMatch(a,this.bufferingItem)&&n.appendInPlace&&this.isAssetBuffered(c))return;this.startAssetPlayer(d,r,t,e,o),this.shouldPlay&&vw(d.media)}else a?(this.resumePrimary(a,e,i),this.shouldPlay&&vw(this.hls.media)):n&&this.isInterstitial(i)&&(this.endedItem=null,this.playingItem=i,i.event.appendInPlace||this.attachPrimary(s.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,n;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${mw(e)}`),null==(i=this.detachedData)||!i.mediaSource){let r=this.timelinePos;(r<e.start||r>=e.end)&&(r=this.getPrimaryResumption(e,t),this.log(yw("resumePrimary",r)),this.timelinePos=r),this.attachPrimary(r,e)}if(!r)return;const s=null==(n=this.schedule)?void 0:n.items;s&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${mw(e)}`),this.hls.trigger($f.INTERSTITIALS_PRIMARY_RESUMED,{schedule:s.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 Cg.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 n=this.hls;n.media?this.checkBuffer():(this.transferMediaTo(n,i),r&&this.startLoadingPrimaryAt(e,r)),r||(this.log(yw("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($f.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on($f.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=Qf(Qf({},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=Qf(Qf({},this.altSelection),{},{audio:r}));const n=Qf(Qf({},i),{},{audio:r});this.mediaSelection=n}onSubtitleTrackUpdated(e,t){const r=this.hls.subtitleTracks[t.id],i=this.mediaSelection;if(!i)return void(this.altSelection=Qf(Qf({},this.altSelection),{},{subtitles:r}));const n=Qf(Qf({},i),{},{subtitles:r});this.mediaSelection=n}onAudioTrackSwitching(e,t){const r=Nm(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(r)))}onSubtitleTrackSwitch(e,t){const r=Nm(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=Cg.bufferInfo(this.primaryMedia,r,0);if(i.end>r||(i.nextStart||0)>r){this.log(`trim buffered interstitial ${mw(e)} (was ${mw(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=Cg.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,n=this.bufferingItem;if(this.bufferedPos>e||!i)return;if(1===t.length&&this.itemsMatch(t[0],n))return void(this.bufferedPos=e);const s=this.playingItem,a=this.findItemIndex(s);let o=i.findItemIndexAtTime(e);if(this.bufferedPos<e){var l;const r=this.findItemIndex(n),i=Math.min(r+1,t.length-1),s=t[i];if((-1===o&&n&&e>=n.end||null!=(l=s.event)&&l.appendInPlace&&e+.01>=s.start)&&(o=i),this.isInterstitial(n)){const e=n.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(s);else{const t=this.primaryDetails;this.primaryLive&&t&&e>t.edge-t.targetduration&&s.start<t.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(s)&&this.preloadAssets(s.event,0)}}else r&&s&&!this.itemsMatch(s,n)&&(o===a?this.bufferedToItem(s):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:n}=r;if(!i||!n)return t;const s=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 ${mw(e)}`+(t?` (${o.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(s){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($f.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:n.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,n=r.cue.once;if(i||!n){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,n=0===i&&!e.assetListLoader,s=e.cue.once;if(n){const n=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(n+.25)}let s,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-n;e>0&&(s=Math.round(1e3*e)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${r?1:i} ${e}${s?` live-start: ${o} start-offset: ${s}`:""}`),r)return this.createAsset(e,0,0,n,e.duration,r);const l=this.assetListLoader.loadAssetList(e,s);l&&(e.assetListLoader=l)}else if(!s&&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($f.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,n,s){const a={parentIdentifier:e.identifier,identifier:ow(e,s,t),duration:n,startOffset:r,timelineStart:i,uri:s};return this.createAssetPlayer(e,a,t)}createAssetPlayer(e,t,r){const i=this.hls,n=i.userConfig;let s=n.videoPreference;const a=i.loadLevelObj||i.levels[i.currentLevel];(s||a)&&(s=qf({},s),a.videoCodec&&(s.videoCodec=a.videoCodec),a.videoRange&&(s.allowedVideoRanges=[a.videoRange]));const o=i.audioTracks[i.audioTrack],l=i.subtitleTracks[i.subtitleTrack];let d=0;if(this.primaryLive||e.appendInPlace){const e=this.timelinePos-t.timelineStart;if(e>1){const r=t.duration;r&&e<r&&(d=e)}}const c=t.identifier,u=Qf(Qf({},n),{},{maxMaxBufferLength:Math.min(180,i.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:i.sessionId,assetPlayerId:c,abrEwmaDefaultEstimate:i.bandwidthEstimate,interstitialsController:void 0,startPosition:d,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:s,audioPreference:o||n.audioPreference,subtitlePreference:l||n.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(u.timelineOffset=t.timelineStart));const h=u.cmcd;null!=h&&h.sessionId&&h.contentId&&(u.cmcd=qf({},h,{contentId:nw(t.uri)})),this.getAssetPlayer(c)&&this.warn(`Duplicate date range identifier ${e} and asset ${c}`);const f=new fw(this.HlsPlayerClass,u,e,t);this.playerQueue.push(f),e.assetList[r]=t;let p=!0;const m=i=>{if(i.live){var n;const t=new Error(`Interstitials MUST be VOD assets ${e}`),i={fatal:!0,type:Nf.OTHER_ERROR,details:Ff.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},s=(null==(n=this.schedule)?void 0:n.findEventIndex(e.identifier))||-1;return void this.handleAssetItemError(i,e,s,r,t.message)}const s=i.edge-i.fragmentStart,a=t.duration;(p||null===a||s>a)&&(p=!1,this.log(`Interstitial asset "${c}" duration change ${a} > ${s}`),t.duration=s,this.updateSchedule())};f.on($f.LEVEL_UPDATED,(e,{details:t})=>m(t)),f.on($f.LEVEL_PTS_UPDATED,(e,{details:t})=>m(t)),f.on($f.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const g=(e,t)=>{const r=this.getAssetPlayer(c);if(r&&t.tracks){r.off($f.BUFFER_CODECS,g),r.tracks=t.tracks;const e=this.primaryMedia;this.bufferingAsset===r.assetItem&&e&&!r.media&&this.bufferAssetPlayer(r,e)}};f.on($f.BUFFER_CODECS,g);f.on($f.BUFFERED_TO_END,()=>{var r;const i=this.getAssetPlayer(c);if(this.log(`buffered to end of asset ${i}`),!i||!this.schedule)return;const n=this.schedule.findEventIndex(e.identifier),s=null==(r=this.schedule.items)?void 0:r[n];this.isInterstitial(s)&&this.advanceAssetBuffering(s,t)});const v=t=>()=>{if(!this.getAssetPlayer(c)||!this.schedule)return;this.shouldPlay=!0;const r=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,r,t)};return f.once($f.MEDIA_ENDED,v(r)),f.once($f.PLAYOUT_LIMIT_REACHED,v(1/0)),f.on($f.ERROR,(t,i)=>{if(!this.schedule)return;const n=this.getAssetPlayer(c);if(i.details===Ff.BUFFER_STALLED_ERROR)return null!=n&&n.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($f.DESTROYING,()=>{if(!this.getAssetPlayer(c)||!this.schedule)return;const t=new Error(`Asset player destroyed unexpectedly ${c}`),i={fatal:!0,type:Nf.OTHER_ERROR,details:Ff.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),r,t.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${hw(t)}`),this.hls.trigger($f.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?mw(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,n){const{interstitial:s,assetItem:a,assetId:o}=e,l=s.assetList.length,d=this.playingAsset;this.endedAsset=null,this.playingAsset=a,d&&d.identifier===o||(d&&(this.clearAssetPlayer(d.identifier,r[i]),delete d.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${l} ${hw(a)}`),this.hls.trigger($f.INTERSTITIAL_ASSET_STARTED,{asset:a,assetListIndex:t,event:s,schedule:r.slice(0),scheduleIndex:i,player:e})),this.bufferAssetPlayer(e,n)}bufferAssetPlayer(e,t){var r,i;if(!this.schedule)return;const{interstitial:n,assetItem:s}=e,a=this.schedule.findEventIndex(n.identifier),o=null==(r=this.schedule.items)?void 0:r[a];if(!o)return;e.loadSource(),this.setBufferingItem(o),this.bufferingAsset=s;const l=this.getBufferingPlayer();if(l===e)return;const d=n.appendInPlace;if(d&&!1===(null==l?void 0:l.interstitial.appendInPlace))return;const c=(null==l?void 0:l.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(d&&s!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(c&&!ap(c,e.tracks)){const t=new Error(`Asset ${hw(s)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(c)}')`),r={fatal:!0,type:Nf.OTHER_ERROR,details:Ff.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},i=n.findAssetIndex(s);return void this.handleAssetItemError(r,n,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,n=t.findAssetIndex(e,i),s=e.assetList[n];if(s){const a=this.getAssetPlayer(s.identifier);if(a){const o=a.currentTime||i-s.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,n)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,r,i,n){if(e.details===Ff.BUFFER_STALLED_ERROR)return;const s=t.assetList[i]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${s?hw(s):s} ${e.error}`),!this.schedule)return;const a=(null==s?void 0:s.identifier)||"",o=this.getAssetPlayerQueueIndex(a),l=this.playerQueue[o]||null,d=this.schedule.items,c=qf({},e,{fatal:!1,errorAction:dg(!0),asset:s,assetListIndex:i,event:t,schedule:d,scheduleIndex:r,player:l});if(this.hls.trigger($f.INTERSTITIAL_ASSET_ERROR,c),!e.fatal)return;const u=this.playingAsset,h=this.bufferingAsset,f=new Error(n);if(s&&(this.clearAssetPlayer(a,null),s.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: ${mw(r)} error: ${e.error}`),-1===i&&(i=this.hls.startPosition);const n=this.updateItem(r,i);this.itemsMatch(r,n)&&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 n=this.schedule.findItemIndexAtTime(i);this.setSchedulePosition(n)}onAssetListLoaded(e,t){var r,i;const n=t.event,s=n.identifier,a=t.assetListResponse.ASSETS;if(null==(r=this.schedule)||!r.hasEvent(s))return;const o=n.timelineStart,l=n.duration;let d=0;a.forEach((e,t)=>{const r=parseFloat(e.DURATION);this.createAsset(n,t,d,o+d,r,e.URI),d+=r}),n.duration=d,this.log(`Loaded asset-list with duration: ${d} (was: ${l}) ${n}`);const c=this.waitingItem,u=(null==c?void 0:c.event.identifier)===s;this.updateSchedule();const h=null==(i=this.bufferingItem)?void 0:i.event;if(u){var f;const e=this.schedule.findEventIndex(s),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 n.error=new Error(`Interstitial ${a.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${n}`),this.log(n.error.message),this.updateSchedule(!0),void this.primaryFallback(n)}this.setBufferingItem(t)}this.setSchedulePosition(e)}else if((null==h?void 0:h.identifier)===s){const e=n.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 Ff.ASSET_LIST_PARSING_ERROR:case Ff.ASSET_LIST_LOAD_ERROR:case Ff.ASSET_LIST_LOAD_TIMEOUT:{const e=t.interstitial;e&&(this.updateSchedule(!0),this.primaryFallback(e));break}case Ff.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 TS(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(TS):Object.keys(e).reduce((t,r)=>(t[r]=TS(e[r]),t),{}):e}function xS(e,t){const r=e.loader;if(r!==vS&&r!==wS)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=vS,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}}class AS extends Rg{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($f.MEDIA_ENDED,{stalled:!1}))},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.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;qv(r,"playing",this.onMediaPlaying),qv(r,"waiting",this.onMediaWaiting),qv(r,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:r}=this;r&&(Xv(r,"playing",this.onMediaPlaying),Xv(r,"waiting",this.onMediaWaiting),Xv(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 n=null==(r=this.hls)?void 0:r.config;if(!n)return;const s=this.media;if(!s)return;const{seeking:a}=s,o=this.seeking&&!a,l=!this.seeking&&a,d=s.paused&&!a||s.ended||0===s.playbackRate;if(this.seeking=a,e!==t)return t&&(this.ended=0),this.moved=!0,a||(this.nudgeRetry=0,n.nudgeOnVideoHole&&!d&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(l||o)return void(o&&this.stallResolved(e));if(d)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&s.ended&&this.hls&&(this.ended=e||1,this.hls.trigger($f.MEDIA_ENDED,{stalled:!1})));if(!Cg.getBuffered(s).length)return void(this.nudgeRetry=0);const c=Cg.bufferInfo(s,e,0),u=c.nextStart||0,h=this.fragmentTracker;if(a&&h&&this.hls){const t=kS(this.hls.inFlightFragments,e),r=c.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(!(c.len>0)&&!u)return;const t=Math.max(u,c.start||0)-e,r=!(null==f||!f.live)?2*f.targetduration:2,i=IS(e,h);if(t>0&&(t<=r||i))return void(s.paused||this._trySkipBufferHole(i))}const p=n.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($f.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(c),!this.media||!this.hls)return}const E=Cg.bufferInfo(s,e,n.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($f.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=Cg.bufferedInfo(Cg.timeRangesToArray(this.buffered.audio),e,0);if(r.len>1&&t>=r.start){const r=Cg.timeRangesToArray(i),n=Cg.bufferedInfo(r,t,0).bufferedIndex;if(n>-1&&n<r.length-1){const t=Cg.bufferedInfo(r,e,0).bufferedIndex,i=r[n].end,s=r[n+1].start;if((-1===t||t>n)&&s-i<1&&e-i<2){const r=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${i} -> ${s} buffered index: ${t}`);this.warn(r.message),this.media.currentTime+=1e-6;let n=IS(e,this.fragmentTracker);n&&"fragment"in n?n=n.fragment:n||(n=void 0);const a=Cg.bufferInfo(this.media,e,0);this.hls.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:r,reason:r.message,frag:n,buffer:a.len,bufferInfo:a})}}}}}_tryFixBufferStall(e,t,r){var i,n;const{fragmentTracker:s,media:a}=this,o=null==(i=this.hls)?void 0:i.config;if(!a||!s||!o)return;const l=null==(n=this.hls)?void 0:n.latestLevelDetails,d=IS(r,s);if(d||null!=l&&l.live&&r<l.fragmentStart){if(this._trySkipBufferHole(d)||!this.media)return}const c=e.buffered,u=this.adjacentTraversal(e,r);(c&&c.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,jf),n=r.getFragAtPos(i,jf);if(e&&n)return n.sn-e.sn<2}return!1}_reportStall(e){const{hls:t,media:r,stallReported:i,stalled:n}=this;if(!i&&null!==n&&r&&t){this.stallReported=!0;const i=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${_m(e)})`);this.warn(i.message),t.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len,bufferInfo:e,stalled:{start:n}})}}_trySkipBufferHole(e){var t;const{fragmentTracker:r,media:i}=this,n=null==(t=this.hls)?void 0:t.config;if(!i||!r||!n)return 0;const s=i.currentTime,a=Cg.bufferInfo(i,s,0),o=s<a.start?a.start:a.nextStart;if(o&&this.hls){const t=a.len<=n.maxBufferHole,d=a.len>0&&a.len<1&&i.readyState<3,c=o-s;if(c>0&&(t||d)){if(c>n.maxBufferHole){let t=!1;if(0===s){const e=r.getAppendedFrag(0,jf);e&&o<e.end&&(t=!0)}if(!t&&e){var l;if(null==(l=this.hls.loadLevelObj)||!l.details)return 0;if(kS(this.hls.inFlightFragments,o))return 0;let t=!1,i=e.end;for(;i<o;){const e=IS(i,r);if(!e){t=!0;break}i+=e.duration}if(t)return 0}}const t=Math.max(o+.05,s+.1);if(this.warn(`skipping hole, adjusting currentTime from ${s} to ${t}`),this.moved=!0,i.currentTime=t,null==e||!e.gap){const r=new Error(`fragment loaded with buffer holes, seeking from ${s} to ${t}`),i={type:Nf.MEDIA_ERROR,details:Ff.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($f.ERROR,i)}return t}}return 0}_tryNudgeBuffer(e){const{hls:t,media:r,nudgeRetry:i}=this,n=null==t?void 0:t.config;if(!r||!n)return 0;const s=r.currentTime;if(this.nudgeRetry++,i<n.nudgeMaxRetry){const a=s+(i+1)*n.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${s} to ${a}`);this.warn(o.message),r.currentTime=a,t.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.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 @${s} after ${n.nudgeMaxRetry} nudges`);this.error(r.message),t.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.BUFFER_STALLED_ERROR,error:r,fatal:!0,buffer:e.len,bufferInfo:e})}}}function kS(e,t){const r=LS(e.main);if(r&&r.start<=t)return r;const i=LS(e.audio);return i&&i.start<=t?i:null}function LS(e){if(!e)return null;switch(e.state){case Jv:case Zv:case ay:case oy:return null}return e.frag}function IS(e,t){return t.getAppendedFrag(e,jf)||t.getPartialFragment(e)}function RS(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function PS(e,t,r,i,n){let s=new e(t,r,"");try{s.value=i,n&&(s.type=n)}catch(a){s=new e(t,r,_m(n?Qf({type:n},i):i))}return s}const DS=(()=>{const e=RS();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class CS{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($f.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($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on($f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.on($f.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off($f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.off($f.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&&tw(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 JE(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:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const s=RS();if(s)for(let e=0;e<n.length;e++){const t=n[e].type;if(t===Uy.emsg&&!r||!i)continue;const a=Ny(n[e].data),o=n[e].pts;let l=o+n[e].duration;l>DS&&(l=DS);l-o<=0&&(l=o+.25);for(let e=0;e<a.length;e++){const r=a[e];if(!Fy(r)){this.updateId3CueEnds(o,t);const e=PS(s,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 n=i[r];n.type===t&&n.startTime<e&&n.endTime===DS&&(n.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:i}){const{id3Track:n,hls:s}=this;if(!s)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:o}}=s;if(n&&(a||o)){let e;e="audio"===i?e=>e.type===Uy.audioId3&&o:"video"===i?e=>e.type===Uy.emsg&&a:e=>e.type===Uy.audioId3&&o||e.type===Uy.emsg&&a,rw(n,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:n,interstitialsController:s}=this.hls.config;if(!n)return;const a=RS();if(r&&i&&!s){const{fragmentStart:t,fragmentEnd:i}=e;let n=this.assetCue;n?(n.startTime=t,n.endTime=i):a&&(n=this.assetCue=PS(a,t,i,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),n&&(n.id=r,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(n),n.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:o}=this,{dateRanges:l}=e,d=Object.keys(l);let c=this.dateRangeCuesAppended;var u;if(o&&t)if(null!=(u=o.cues)&&u.length){const e=Object.keys(c).filter(e=>!d.includes(e));for(let t=e.length;t--;){var h;const r=e[t],i=null==(h=c[r])?void 0:h.cues;delete c[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 c=this.dateRangeCuesAppended={};const f=e.fragments[e.fragments.length-1];if(0!==d.length&&_f(null==f?void 0:f.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let e=0;e<d.length;e++){const t=d[e],r=l[t],i=r.startTime,n=c[t],o=(null==n?void 0:n.cues)||{};let u=(null==n?void 0:n.durationKnown)||!1,h=DS;const{duration:f,endDate:p}=r;if(p&&null!==f)h=i+f,u=!0;else if(r.endOnNext&&!u){const e=d.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(!zg(l))continue;const d=o[l];if(d)!u||null!=n&&n.durationKnown?Math.abs(d.startTime-i)>.01&&(d.startTime=i,d.endTime=h):d.endTime=h;else if(a){let e=r.attr[l];Gg(l)&&(e=dp(e));const n=PS(a,i,h,{key:l,data:e},Uy.dateRange);n&&(n.id=t,this.id3Track.addCue(n),o[l]=n,s&&("X-ASSET-LIST"!==l&&"X-ASSET-URL"!==l||n.addEventListener("enter",this.onEventCueEnter)))}}c[t]={cues:o,dateRange:r,durationKnown:u}}}}}class _S{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:n}=this.config;if(!i||1===n||!t.live)return;const s=this.targetLatency;if(null===s)return;const a=r-s;if(a<Math.min(this.maxLatency,s+t.targetduration)&&a>.05&&this.forwardBufferLength>1){const t=Math.min(2,Math.max(1,n)),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:n,liveSyncDurationCount:s,lowLatencyMode:a}=this.config,o=this.hls.userConfig;let l=a&&r||t;(this._targetLatencyUpdated||o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==n?n:s*i);const d=i;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,d)}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,n=e-t-this.edgeStalled,s=i-r.totalduration,a=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(s,n),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($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.on($f.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.off($f.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===Ff.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 OS extends Gb{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($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.on($f.LEVEL_LOADED,this.onLevelLoaded,this),e.on($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on($f.FRAG_BUFFERED,this.onFragBuffered,this),e.on($f.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.off($f.LEVEL_LOADED,this.onLevelLoaded,this),e.off($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off($f.FRAG_BUFFERED,this.onFragBuffered,this),e.off($f.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=[],n={},s={};let a=!1,o=!1,l=!1;t.levels.forEach(e=>{const t=e.attrs;let{audioCodec:d,videoCodec:c}=e;d&&(e.audioCodec=d=cm(d,r)||void 0),c&&(c=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(",")}(c));const{width:u,height:h,unknownCodecs:f}=e,p=(null==f?void 0:f.length)||0;if(a||(a=!(!u||!h)),o||(o=!!c),l||(l=!!d),p||d&&!this.isAudioSupported(d)||c&&!this.isVideoSupported(c))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(n[w])if(n[w].uri===e.url||e.attrs["PATHWAY-ID"])n[w].addGroupId("audio",t.AUDIO),n[w].addGroupId("text",t.SUBTITLES);else{const t=s[w]+=1;e.attrs["PATHWAY-ID"]=new Array(t+1).join(".");const r=this.createLevel(e);n[w]=r,i.push(r)}else{const t=this.createLevel(e);n[w]=t,s[w]=1,i.push(t)}}),this.filterAndSortMediaOptions(i,t,a,o,l)}createLevel(e){const t=new Pm(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=ym(e,[])}return t}isAudioSupported(e){return im(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return im(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,r,i,n){var s;let a=[],o=[],l=e;const d=(null==(s=t.stats)?void 0:s.parsing)||{};if((r||i)&&n&&(l=l.filter(({videoCodec:e,videoRange:t,width:r,height:i})=>{return(!!e||!(!r||!i))&&(!!(n=t)&&xm.indexOf(n)>-1);var n})),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: ${_m(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($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:i,reason:r})}}),void(d.end=performance.now());t.audioTracks&&(a=t.audioTracks.filter(e=>!e.audioCodec||this.isAudioSupported(e.audioCodec)),MS(a)),t.subtitles&&(o=t.subtitles,MS(o));const c=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 xm.indexOf(e.videoRange)-xm.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){const r=am(e.videoCodec),i=am(t.videoCodec);if(r!==i)return i-r}if(e.uri===t.uri&&e.codecSet!==t.codecSet){const r=om(e.codecSet),i=om(t.codecSet);if(r!==i)return i-r}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});let u=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==c.length))for(let e=0;e<c.length;e++)if(c[e].pathwayId===l[0].pathwayId){u=c[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=n&&!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:n,video:i,altAudio:m&&!f&&a.some(e=>!!e.url)};d.end=performance.now(),this.hls.trigger($f.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($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.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,n=i?i.attrs["PATHWAY-ID"]:void 0,s=t[e],a=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=s,r===e&&i&&n===a)return;this.log(`Switching to level ${e} (${s.height?s.height+"p ":""}${s.videoRange?s.videoRange+" ":""}${s.codecSet?s.codecSet+" ":""}@${s.bitrate})${a?" with Pathway "+a:""} from level ${r}${n?" with Pathway "+n:""}`);const o={level:e,attrs:s.attrs,details:s.details,bitrate:s.bitrate,averageBitrate:s.averageBitrate,maxBitrate:s.maxBitrate,realBitrate:s.realBitrate,width:s.width,height:s.height,codecSet:s.codecSet,audioCodec:s.audioCodec,videoCodec:s.videoCodec,audioGroups:s.audioGroups,subtitleGroups:s.subtitleGroups,loaded:s.loaded,loadError:s.loadError,fragmentError:s.fragmentError,name:s.name,id:s.id,uri:s.uri,url:s.url,urlId:0,audioGroupIds:s.audioGroupIds,textGroupIds:s.textGroupIds};this.hls.trigger($f.LEVEL_SWITCHING,o);const l=s.details;if(!l||l.live){const e=this.switchParams(s.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===Uf&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(void 0!==t&&t.type===jf){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:n}=t,s=t.levelInfo;var a;if(!s)return this.warn(`Invalid level index ${i}`),void(null!=(a=t.deliveryDirectives)&&a.skip&&(n.deltaUpdateFailed=!0));if(s===this.currentLevel||t.withoutMultiVariant){0===s.fragmentError&&(s.loadError=0);let e=s.details;e===t.details&&e.advanced&&(e=void 0),this.playlistLoaded(i,t,e)}else null!=(r=t.deliveryDirectives)&&r.skip&&(n.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,n=e.attrs["PATHWAY-ID"],s=e.details,a=null==s?void 0:s.age;this.log(`Loading level index ${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${n?" Pathway "+n:""}${a&&s.live?" age "+a.toFixed(1)+(s.type&&" "+s.type||""):""} ${r}`),this.hls.trigger($f.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));zv(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($f.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($f.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function MS(e){const t={};e.forEach(e=>{const r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++})}function NS(){return self.SourceBuffer||self.WebKitSourceBuffer}function FS(){if(!sp())return!1;const e=NS();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}class $S extends cy{constructor(e,t,r){super(e,t,r,"stream-controller",jf),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||!_f(t))return;if(this.log(`Media seeked to ${t.toFixed(3)}`),!this.getBufferedFrag(t))return;const r=this.getFwdBufferInfoAtPos(e,t,jf,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($f.MANIFEST_PARSED,this.onManifestParsed,this),e.on($f.LEVEL_LOADING,this.onLevelLoading,this),e.on($f.LEVEL_LOADED,this.onLevelLoaded,this),e.on($f.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on($f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on($f.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on($f.BUFFER_CREATED,this.onBufferCreated,this),e.on($f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on($f.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off($f.MANIFEST_PARSED,this.onManifestParsed,this),e.off($f.LEVEL_LOADED,this.onLevelLoaded,this),e.off($f.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off($f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off($f.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off($f.BUFFER_CREATED,this.onBufferCreated,this),e.off($f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off($f.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=Jv,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=Zv}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case dy:{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=Jv;break}if(this.hls.nextLoadLevel!==this.level){this.state=Jv;break}break}case ry:this.checkRetryDate()}this.state===Jv&&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 n=this.buffering?e.nextLoadLevel:e.loadLevel;if(null==r||!r[n])return;const s=r[n],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($f.BUFFER_EOS,e),void(this.state=ay)}if(!this.buffering)return;e.loadLevel!==n&&-1===e.manualLevel&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;const l=s.details;if(!l||this.state===dy||this.waitForLive(s))return this.level=n,this.state=dy,void(this.startFragRequested=!1);const d=a.len,c=this.getMaxBufferLength(s.maxBitrate);if(d>=c)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&&xp(h)&&this.fragmentTracker.getState(h)!==fg){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?Ep:wp,t=(e===wp?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,jf)}h=this.getNextFragmentLoopLoading(h,l,a,jf,c)}h&&(!h.initSegment||h.initSegment.data||this.bitrateTest||(h=h.initSegment),this.loadFragment(h,s,u))}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);i===cg||i===hg?xp(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,jf)}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 n=this.getLevelDetails();if(null!=n&&n.live){const e=this.getMainFwdBufferInfo();if(!e||e.len<2*n.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 s=this.getBufferedFrag(t.currentTime+r);if(s){const e=this.followingBufferedFrag(s);if(e){this.abortCurrentFrag();const t=e.maxStartPTS?e.maxStartPTS:e.start,r=e.duration,i=Math.max(s.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 ey:case ty:case ry:case ny:case sy:this.state=Jv}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;qv(r,"playing",this.onMediaPlaying),qv(r,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:r}=this;r&&(Xv(r,"playing",this.onMediaPlaying),Xv(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($f.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 n=t.levels[e].audioCodec;n&&(r=r||-1!==n.indexOf("mp4a.40.2"),i=i||-1!==n.indexOf("mp4a.40.5"))}this.audioCodecSwitch=r&&i&&!function(){var e;const t=NS();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!==Jv)return;const i=t.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=dy)}onLevelLoaded(e,t){var r;const{levels:i,startFragRequested:n}=this,s=t.level,a=t.details,o=a.totalduration;if(!i)return void this.warn(`Levels were reset while loading level ${s}`);this.log(`Level ${s} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const l=t.levelInfo,d=this.fragCurrent;!d||this.state!==ty&&this.state!==ry||d.level!==t.level&&d.loader&&this.abortCurrentFrag();let c=0;if(a.live||null!=(r=l.details)&&r.live){var u;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;c=this.alignPlaylists(a,l.details,null==(u=this.levelLastLoaded)?void 0:u.details)}if(l.details=a,this.levelLastLoaded=l,n||this.setStartPosition(a,c),this.hls.trigger($f.LEVEL_UPDATED,{details:a,level:s}),this.state===dy){if(this.waitForCdnTuneIn(a))return;this.state=Jv}n&&a.live&&this.synchronizeToLiveEdge(a),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:r}=this;if(!r)return;const i=this.hls.liveSyncPosition,n=this.getLoadPosition(),s=e.fragmentStart,a=e.edge,o=n>=s-t.maxFragLookUpTolerance&&n<=a;if(null!==i&&r.duration>i&&(n<i||!o)){const s=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!o&&r.readyState<4||n<a-s)&&(this._hasEnoughToStart||(this.nextLoadPosition=i),r.readyState))if(this.warn(`Playback: ${n.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=Cg.bufferInfo(r,i,0);if(null==(l=e.buffered)||!l.length)return void(r.currentTime=i);if(e.start<=n)return void(r.currentTime=i);const{nextStart:t}=Cg.bufferedInfo(e.buffered,n,0);t&&(r.currentTime=t)}else r.currentTime=i}}_handleFragmentLoadProgress(e){var t;const r=e.frag,{part:i,payload:n}=e,{levels:s}=this;if(!s)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=s[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,d=o.PTSKnown||!o.live,c=null==(t=r.initSegment)?void 0:t.data,u=this._getAudioCodec(a),h=this.transmuxer=this.transmuxer||new zb(this.hls,jf,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,p=-1!==f,m=new Pg(r.level,r.sn,r.stats.chunkCount,n.byteLength,f,p),g=this.initPTS[r.cc];h.push(n,c,u,l,r,i,o.totalduration,d,m,g)}onAudioTrackSwitching(e,t){const r=this.hls,i=0!==this.altAudio;if(zm(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($f.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger($f.AUDIO_TRACK_SWITCHED,t)}),void r.trigger($f.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});r.trigger($f.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const r=zm(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,n,s=!1;for(const e in r){const t=r[e];if("main"===t.id){if(n=e,i=t,"video"===e){const t=r[e];t&&(this.videoBuffer=t.buffer)}}else s=!0}s&&i?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:r,part:i}=t,n=r.type===jf;if(n){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===sy&&(this.state=Jv));const e=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*e.total/(e.buffering.end-e.loading.first)),xp(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}const s=this.media;s&&(!this._hasEnoughToStart&&Cg.getBuffered(s).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),n&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var r;if(t.fatal)this.state=oy;else switch(t.details){case Ff.FRAG_GAP:case Ff.FRAG_PARSING_ERROR:case Ff.FRAG_DECRYPT_ERROR:case Ff.FRAG_LOAD_ERROR:case Ff.FRAG_LOAD_TIMEOUT:case Ff.KEY_LOAD_ERROR:case Ff.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(jf,t);break;case Ff.LEVEL_LOAD_ERROR:case Ff.LEVEL_LOAD_TIMEOUT:case Ff.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==dy||(null==(r=t.context)?void 0:r.type)!==Uf||(this.state=Jv);break;case Ff.BUFFER_ADD_CODEC_ERROR:case Ff.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case Ff.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 Ff.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onFragLoadEmergencyAborted(){this.state=Jv,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Ep||!this.altAudio){const e=(t===wp?this.videoBuffer:this.mediaBuffer)||this.media;e&&(this.afterBufferFlushed(e,t,jf),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 n=this.getLevelDetails(),s=Cg.getBuffered(e),a=s.length?s.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==n?void 0:n.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=Jv,this.startFragRequested=!1,this.bitrateTest=!1;const n=i.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),r.trigger($f.FRAG_LOADED,e),i.bitrateTest=!1}).catch(t=>{this.state!==Zv&&this.state!==oy&&(this.warn(t),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:r}=this,{remuxResult:i,chunkMeta:n}=e,s=this.getCurrentContext(n);if(!s)return void this.resetWhenMissingContext(n);const{frag:a,part:o,level:l}=s,{video:d,text:c,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=ny,h){const e=h.tracks;if(e){const i=a.initSegment||a;if(this.unhandledEncryptionError(h,a))return;this._bufferInitSegment(l,e,i,n),r.trigger($f.FRAG_PARSING_INIT_SEGMENT,{frag:i,id:t,tracks:e})}const i=h.initPTS,s=h.timescale,o=this.initPTS[a.cc];if(_f(i)&&(!o||o.baseTime!==i||o.timescale!==s)){const e=h.trackId;this.initPTS[a.cc]={baseTime:i,timescale:s,trackId:e},r.trigger($f.INIT_PTS_FOUND,{frag:a,id:t,initPTS:i,timescale:s,trackId:e})}}if(d&&f){p&&"audiovideo"===d.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:s,endDTS:l}=d;if(o)o.elementaryStreams[d.type]={startPTS:e,endPTS:i,startDTS:s,endDTS:l};else if(d.firstKeyFrame&&d.independent&&1===n.id&&!r&&(this.couldBacktrack=!0),d.dropped&&d.independent){const n=this.getMainFwdBufferInfo(),s=(n?n.end:this.getLoadPosition())+this.config.maxBufferHole,o=d.firstKeyFramePTS?d.firstKeyFramePTS:e;if(!t&&s<o-this.config.maxBufferHole&&!r)return void this.backtrack(a);r&&(a.gap=!0),a.setElementaryStreamInfo(d.type,a.start,i,a.start,l,!0)}else t&&e-(f.appliedTimelineOffset||0)>2&&(a.gap=!0);a.setElementaryStreamInfo(d.type,e,i,s,l),this.backtrackFragment&&(this.backtrackFragment=a),this.bufferFragmentData(d,a,o,n,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[Ep]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),a.setElementaryStreamInfo(Ep,e,t,r,i),this.bufferFragmentData(p,a,o,n)}if(f&&null!=u&&u.samples.length){const e={id:t,frag:a,details:f,samples:u.samples};r.trigger($f.FRAG_PARSING_METADATA,e)}if(f&&c){const e={id:t,frag:a,details:f,samples:c.samples};r.trigger($f.FRAG_PARSING_USERDATA,e)}}}logMuxedErr(e){this.warn(`${xp(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,r,i){if(this.state!==ny)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(r));const{audio:n,video:s,audiovideo:a}=t;if(n){const r=e.audioCodec;let i=um(n.codec,r);"mp4a"===i&&(i="mp4a.40.5");const s=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){i&&(i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");const e=n.metadata;e&&"channelCount"in e&&1!==(e.channelCount||1)&&-1===s.indexOf("firefox")&&(i="mp4a.40.5")}i&&-1!==i.indexOf("mp4a.40.5")&&-1!==s.indexOf("android")&&"audio/mpeg"!==n.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}"`),n.levelCodec=i,n.id=jf,this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${i||""}/${r||""}/${n.codec}]`),delete t.audiovideo}if(s){s.levelCodec=e.videoCodec,s.id=jf;const r=s.codec;if(4===(null==r?void 0:r.length))switch(r){case"hvc1":case"hev1":s.codec="hvc1.1.6.L120.90";break;case"av01":s.codec="av01.0.04M.08";break;case"avc1":s.codec="avc1.42e01e"}this.log(`Init video buffer, container:${s.container}, codecs[level/parsed]=[${e.videoCodec||""}/${r}]${s.codec!==r?" parsed-corrected="+s.codec:""}${s.supplemental?" supplemental="+s.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($f.BUFFER_CODECS,t),!this.hls)return;o.forEach(e=>{const n=t[e].initSegment;null!=n&&n.byteLength&&this.hls.trigger($f.BUFFER_APPENDING,{type:e,data:n,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,jf)}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=Jv}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&!1===e.seeking){const r=e.currentTime;if(Cg.isBuffered(e,r)?t=this.getAppendedFrag(r):Cg.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($f.FRAG_CHANGED,{frag:t}),e&&e.level===r||this.hls.trigger($f.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 _f(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(_f(t)){const e=this.getLevelDetails(),r=this.currentFrag||(e?jm(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 BS extends Zf{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=Ff.KEY_LOAD_ERROR,r,i,n){return new Ig({type:Nf.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,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,n=t.length;i<n;i++){const s=t[i];if(e.cc<=s.cc&&(!xp(e)||!xp(s)||e.sn<s.sn)||!r&&i==n-1)return this.emeController.selectKeySystemFormat(s).then(e=>{if(!this.emeController)return;s.setKeyFormat(e);const t=sv(e);return t?this.emeController.getKeySystemAccess([t]):void 0})}if(this.config.requireKeySystemAccessOnStart){const e=ov(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 n=e.decryptdata;if(!n){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,Ff.KEY_LOAD_ERROR,r))}const s=n.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,Ff.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${s}"`)));const a=US(n);let o=this.keyIdToKeyInfo[a];if(null!=(r=o)&&r.decryptdata.key)return n.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 n.key=r.decryptdata.key,{frag:e,keyInfo:r}})}}switch(this.log(`${this.keyIdToKeyInfo[a]?"Rel":"L"}oading${n.keyId?" keyId: "+lp(n.keyId):""} URI: ${n.uri} from ${e.type} ${e.level}`),o=this.keyIdToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===n.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,Ff.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.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 Hp(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 ${lp(t)}`),hv.setKeyIdForUri(e.decryptdata.uri,t)):(t=hv.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${lp(t)}`)),e.decryptdata.keyId=t}}if(!e.decryptdata.keyId&&!xp(t))return Promise.resolve(r);const n=this.emeController.loadKey(r);return(e.keyLoadPromise=n.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((n,s)=>{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},d={onSuccess:(e,t,r,i)=>{const{frag:a,keyInfo:o}=r,l=US(o.decryptdata);if(!a.decryptdata||o!==this.keyIdToKeyInfo[l])return s(this.createKeyLoadError(a,Ff.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,n({frag:a,keyInfo:o})},onError:(e,r,i,n)=>{this.resetLoader(r),s(this.createKeyLoadError(t,Ff.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),i,Qf({url:a.url,data:void 0},e)))},onTimeout:(e,r,i)=>{this.resetLoader(r),s(this.createKeyLoadError(t,Ff.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(e,r,i)=>{this.resetLoader(r),s(this.createKeyLoadError(t,Ff.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};i.load(a,l,d)})}resetLoader(e){const{frag:t,keyInfo:r,url:i}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null);const s=US(r.decryptdata)||i;delete this.keyIdToKeyInfo[s],n&&n.destroy()}}function US(e){if(e.keyFormat!==rv){const t=e.keyId;if(t)return lp(t)}return e.uri}function zS(e){const{type:t}=e;switch(t){case zf:return Hf;case Gf:return Vf;default:return jf}}function GS(e,t){let r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}class jS{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($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.LEVEL_LOADING,this.onLevelLoading,this),e.on($f.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on($f.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on($f.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.LEVEL_LOADING,this.onLevelLoading,this),e.off($f.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off($f.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off($f.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return this.loaders[e.type]=n,n}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:Bf,url:r,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:r,level:i,pathwayId:n,url:s,deliveryDirectives:a,levelInfo:o}=t;this.load({id:r,level:i,pathwayId:n,responseType:"text",type:Uf,url:s,deliveryDirectives:a,levelOrTrack:o})}onAudioTrackLoading(e,t){const{id:r,groupId:i,url:n,deliveryDirectives:s,track:a}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:zf,url:n,deliveryDirectives:s,levelOrTrack:a})}onSubtitleTrackLoading(e,t){const{id:r,groupId:i,url:n,deliveryDirectives:s,track:a}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:Gf,url:n,deliveryDirectives:s,levelOrTrack:a})}onLevelsUpdated(e,t){const r=this.loaders[Uf];if(r){const e=r.context;e&&!t.levels.some(t=>t===e.levelOrTrack)&&(r.abort(),delete this.loaders[Uf])}}load(e){var t;const r=this.hls.config;let i,n=this.getInternalLoader(e);if(n){const t=this.hls.logger,r=n.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}`),n.abort()}if(i=e.type===Bf?r.manifestLoadPolicy.default:qf({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(e),_f(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===Uf&&null!==e.level?t=this.hls.levels[e.level].details:e.type===zf&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===Gf&&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=qf({},i,{maxTimeToFirstByteMs:Math.min(t,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,i.maxTimeToFirstByteMs)})}}}const s=i.errorRetry||i.timeoutRetry||{},a={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},o={onSuccess:(e,t,r,i)=>{const n=this.getInternalLoader(r);this.resetInternalLoader(r.type);const s=e.data;t.parsing.start=performance.now(),bv.isMediaPlaylist(s)||r.type!==Bf?this.handleTrackOrLevelPlaylist(e,t,r,i||null,n):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)}};n.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 n=this.hls,s=e.data,a=GS(e,r),o=bv.parseMasterPlaylist(s,a);if(o.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);const{contentSteering:l,levels:d,sessionData:c,sessionKeys:u,startTimeOffset:h,variableList:f}=o;this.variableList=f,d.forEach(e=>{const{unknownCodecs:t}=e;if(t){const{preferManagedMediaSource:r}=this.hls.config;let{audioCodec:i,videoCodec:n}=e;for(let s=t.length;s--;){const a=t[s];im(a,"audio",r)?(e.audioCodec=i=i?`${i},${a}`:a,tm.audio[i.substring(0,4)]=2,t.splice(s,1)):im(a,"video",r)&&(e.videoCodec=n=n?`${n},${a}`:a,tm.video[n.substring(0,4)]=2,t.splice(s,1))}}});const{AUDIO:p=[],SUBTITLES:m,"CLOSED-CAPTIONS":g}=bv.parseMasterPlaylistMedia(s,a,o);if(p.length){p.some(e=>!e.url)||!d[0].audioCodec||d[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 Ug({}),bitrate:0,url:""}))}n.trigger($f.MANIFEST_LOADED,{levels:d,audioTracks:p,subtitles:m,captions:g,contentSteering:l,url:a,stats:t,networkDetails:i,sessionData:c,sessionKeys:u,startTimeOffset:h,variableList:f})}handleTrackOrLevelPlaylist(e,t,r,i,n){const s=this.hls,{id:a,level:o,type:l}=r,d=GS(e,r),c=_f(o)?o:_f(a)?a:0,u=zS(r),h=bv.parseLevelPlaylist(e.data,d,c,u,0,this.variableList);if(l===Bf){const e={attrs:new Ug({}),bitrate:0,details:h,name:"",url:d};h.requestScheduled=t.loading.start+Fv(h,0),s.trigger($f.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:d,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,n)}handleManifestParsingError(e,t,r,i,n){this.hls.trigger($f.ERROR,{type:Nf.NETWORK_ERROR,details:Ff.MANIFEST_PARSING_ERROR,fatal:t.type===Bf,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:n})}handleNetworkError(e,t,r=!1,i,n){let s=`A network ${r?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading ${e.type}`;e.type===Uf?s+=`: ${e.level} id: ${e.id}`:e.type!==zf&&e.type!==Gf||(s+=` id: ${e.id} group-id: "${e.groupId}"`);const a=new Error(s);this.hls.logger.warn(`[playlist-loader]: ${s}`);let o=Ff.UNKNOWN,l=!1;const d=this.getInternalLoader(e);switch(e.type){case Bf:o=r?Ff.MANIFEST_LOAD_TIMEOUT:Ff.MANIFEST_LOAD_ERROR,l=!0;break;case Uf:o=r?Ff.LEVEL_LOAD_TIMEOUT:Ff.LEVEL_LOAD_ERROR,l=!1;break;case zf:o=r?Ff.AUDIO_TRACK_LOAD_TIMEOUT:Ff.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case Gf:o=r?Ff.SUBTITLE_TRACK_LOAD_TIMEOUT:Ff.SUBTITLE_LOAD_ERROR,l=!1}d&&this.resetInternalLoader(e.type);const c={type:Nf.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:d,context:e,error:a,networkDetails:t,stats:n};if(i){const r=(null==t?void 0:t.url)||e.url;c.response=Qf({url:r,data:void 0},i)}this.hls.trigger($f.ERROR,c)}handlePlaylistLoaded(e,t,r,i,n,s){const a=this.hls,{type:o,level:l,levelOrTrack:d,id:c,groupId:u,deliveryDirectives:h}=i,f=GS(t,i),p=zS(i);let m="number"==typeof i.level&&p===jf?l:void 0;const g=e.playlistParsingError;if(g){if(this.hls.logger.warn(`${g} ${e.url}`),!a.config.ignorePlaylistParsingErrors)return void a.trigger($f.ERROR,{type:Nf.NETWORK_ERROR,details:Ff.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:i,level:m,parent:p,networkDetails:n,stats:r});e.playlistParsingError=null}if(!e.fragments.length){const s=e.playlistParsingError=new Error("No Segments found in Playlist");return void a.trigger($f.ERROR,{type:Nf.NETWORK_ERROR,details:Ff.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:s,reason:s.message,response:t,context:i,level:m,parent:p,networkDetails:n,stats:r})}switch(e.live&&s&&(s.getCacheAge&&(e.ageHeader=s.getCacheAge()||0),s.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case Bf:case Uf:if(m)if(d){if(d!==a.levels[m]){const e=a.levels.indexOf(d);e>-1&&(m=e)}}else m=0;a.trigger($f.LEVEL_LOADED,{details:e,levelInfo:d||a.levels[0],level:m||0,id:c||0,stats:r,networkDetails:n,deliveryDirectives:h,withoutMultiVariant:o===Bf});break;case zf:a.trigger($f.AUDIO_TRACK_LOADED,{details:e,track:d,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case Gf:a.trigger($f.SUBTITLE_TRACK_LOADED,{details:e,track:d,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h})}}}class HS{static get version(){return vy}static isMSESupported(){return FS()}static isSupported(){return function(){if(!FS())return!1;const e=sp();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(sm(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(sm(t,"audio"))))}()}static getMediaSource(){return sp()}static get Events(){return $f}static get MetadataSchema(){return Uy}static get ErrorTypes(){return Nf}static get ErrorDetails(){return Ff}static get DefaultConfig(){return HS.defaultConfig?HS.defaultConfig:SS}static set DefaultConfig(e){HS.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 gy,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=tp();if("object"==typeof console&&!0===e||"object"==typeof e){const n=["debug","log","info","warn","error"];n.forEach(t=>{i[t]=rp(t,e,r)});try{i.log(`Debug logs enabled for "${t}" in hls.js version 1.6.15`)}catch(e){return tp()}n.forEach(t=>{ip[t]=rp(t,e)})}else qf(ip,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=TS(e),n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{const s=`${"level"===e?"playlist":e}LoadPolicy`,a=void 0===t[s],o=[];n.forEach(r=>{const n=`${e}Loading${r}`,l=t[n];if(void 0!==l&&a){o.push(n);const e=i[s].default;switch(t[s]={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 "${s}": ${_m(t[s])}`)}),Qf(Qf({},i),t)}(HS.DefaultConfig,e,t);this.userConfig=e,r.progressive&&xS(r,t);const{abrController:i,bufferController:n,capLevelController:s,errorController:a,fpsController:o}=r,l=new a(this),d=this.abrController=new i(this),c=new pg(this),u=r.interstitialsController,h=u?this.interstitialsController=new u(this,HS):null,f=this.bufferController=new n(this,c),p=this.capLevelController=new s(this),m=new o(this),g=new jS(this),v=r.contentSteeringController,y=v?new v(this):null,b=this.levelController=new OS(this,y),E=new CS(this),w=new BS(this.config,this.logger),S=this.streamController=new $S(this,c,w),T=this.gapController=new AS(this,c);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=[d,f,T,p,m,E,c];this.audioTrackController=this.createController(r.audioTrackController,x);const k=r.audioStreamController;k&&x.push(this.audioStreamController=new k(this,c,w)),this.subtitleTrackController=this.createController(r.subtitleTrackController,x);const L=r.subtitleStreamController;L&&x.push(this.subtititleStreamController=new L(this,c,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(_S,A),this.coreComponents=A,x.push(l);const I=l.onErrorOut;"function"==typeof I&&this.on($f.ERROR,I,l),this.on($f.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===$f.ERROR;this.trigger($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.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($f.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($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.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($f.MEDIA_ATTACHING,i)}detachMedia(){this.logger.log("detachMedia"),this.trigger($f.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger($f.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,r=this._url,i=this._url=yp.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($f.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={[jf]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[Hf]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[Vf]=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 Tm.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 Em(e,Mm(t),navigator.mediaCapabilities)}}HS.defaultConfig=void 0;const VS=({file:e,startTime:n,poster:s,autoplay:o=!0,active:l=!0,visible:d=!0,muted:h=!0})=>{const f=r(null),{isReady:p,prewarm:m,setLowestResolution:g,startBufferBasedUpshift:v}=(({file:e,videoRef:t,autoplay:n=!0,startTime:s,enabled:o=!0,onReady:l,onError:d})=>{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==d||d(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 D=c(()=>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 s=()=>{};try{null===(r=h.current)||void 0===r||r.destroy()}catch(e){}if(h.current=null,v.current=!1,T(!1),b("loading"),HS.isSupported()){g.current=!1;const t=new HS({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,n=e.bitrate,s=e.name;return{id:t,height:r,width:i,bitrate:n,name:s,label:s||(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(),n&&i.play().catch(()=>{}))};t.on(HS.Events.MANIFEST_PARSED,()=>{r(),n||_()}),t.on(HS.Events.FRAG_BUFFERED,a),t.on(HS.Events.BUFFER_APPENDED,a),t.on(HS.Events.LEVEL_SWITCHED,(e,t)=>{const r=null==t?void 0:t.level;I(null==r||r<0?"auto":r)}),t.on(HS.Events.ERROR,(e,r)=>{var i,n,s,a,o;const l=500===(null!==(a=null!==(n=null===(i=null==r?void 0:r.response)||void 0===i?void 0:i.code)&&void 0!==n?n:null===(s=null==r?void 0:r.response)||void 0===s?void 0:s.status)&&void 0!==a?a:null===(o=null==r?void 0:r.response)||void 0===o?void 0:o.statusCode);if(r.type!==HS.ErrorTypes.NETWORK_ERROR||r.fatal){if(r.fatal){if(r.type===HS.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==d||d(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==d||d(new Error("HTTP 500")))}try{if(p.current>=5){b("error");try{t.destroy()}catch(e){}return h.current=null,void(null==d||d(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),s=()=>{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(),n&&i.play().catch(()=>{}))},r=()=>{if(v.current=!1,T(!1),p.current>=5)return b("error"),void(null==d||d(new Error("Max retry reached")));P()};i.addEventListener("loadedmetadata",t),i.addEventListener("error",r),n&&i.play().catch(()=>{}),s=()=>{i.removeEventListener("loadedmetadata",t),i.removeEventListener("error",r)}}else b("error"),null==d||d(new Error("HLS not supported"));return()=>{s(),R()}},[e,E,n,l,d,t,o]),i(()=>{if(!S)return;if(null==s||s<=0)return;const e=t.current;if(e)try{Math.abs(e.currentTime-s)>.5&&(e.currentTime=s)}catch(e){}},[S,s,t]),i(()=>{const e=t.current;if(!e)return;const r=()=>b("ready"),i=()=>b("ready"),n=()=>{"error"!==y&&b("loading")},s=()=>b("loading"),a=()=>{b("error"),null==d||d()};return e.addEventListener("playing",r),e.addEventListener("canplay",i),e.addEventListener("waiting",n),e.addEventListener("stalled",s),e.addEventListener("error",a),()=>{e.removeEventListener("playing",r),e.removeEventListener("canplay",i),e.removeEventListener("waiting",n),e.removeEventListener("stalled",s),e.removeEventListener("error",a)}},[y,d,t]);const C=c(()=>{const e=h.current;e&&!g.current&&(console.log("Set auto resolution"),e.nextLevel=-1,I("auto"))},[]),_=c(()=>{var e,t;const r=h.current;if(!r)return;const i=r.levels||[];if(i.length){let n=0;for(let r=1;r<i.length;r++)(null!==(e=i[r].height)&&void 0!==e?e:99999)<(null!==(t=i[n].height)&&void 0!==t?t:99999)&&(n=r);r.currentLevel=n}},[]),O=c((e=2)=>{const r=h.current,i=t.current;if(!r||!i||g.current)return()=>{};let n=!1;const s=()=>{if(!n)if(r.autoLevelEnabled)n=!0;else try{i.buffered.length>0&&i.buffered.end(0)-i.currentTime>=e&&(r.nextLevel=-1,I("auto"),n=!0)}catch(e){}};return r.on(HS.Events.FRAG_BUFFERED,s),()=>{r.off(HS.Events.FRAG_BUFFERED,s)}},[t]);return{playbackStatus:y,isReady:S,qualities:A,currentLevel:L,isAutoQuality:u(()=>"auto"===L,[L]),canSetResolution:!g.current&&HS.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)),n=i.find(e=>(e.height||0)<=r)||i[i.length-1];n&&(t.currentLevel=n.id,I(n.id))},setAutoResolution:C,prewarm:D,setLowestResolution:_,startBufferBasedUpshift:O}})({file:e,videoRef:f,autoplay:o,startTime:n,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:Rt(s||""),preload:"metadata",className:"w-full h-full object-cover object-center bg-black",style:{opacity:d&&p?1:0,transition:"opacity 200ms ease-in-out"}})},WS=({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," 시청")),YS=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:n,playback:s="hover"})=>{var a,o,l,d,c;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}=Df(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()},[s]),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){}},[s]);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)}},[s]);const R="hover"===s&&v,P=Boolean(k&&("autoplay"===s&&b||R&&h));return t.createElement("div",{className:"w-full h-full flex flex-col items-center justify-center",ref:u,onMouseEnter:()=>{"hover"===s&&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!=n?n:10}px`,backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",aspectRatio:w.height?void 0:r,backgroundImage:S?`url(${Rt(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(VS,{file:k,poster:S,autoplay:"autoplay"===s,active:"autoplay"===s&&b||R&&h,visible:P,muted:!0})),!P&&t.createElement(Rf,null),t.createElement(WS,{view:null!==(c=null===(d=e.statistics)||void 0===d?void 0:d.pageView)&&void 0!==c?c:0}))))},KS=e=>{var r,i,n,s;const{content:a,title:o,aspectRatio:l="9/16",card:d,titleFontSize:c}=e,h=null!==(r=null==d?void 0:d.layout)&&void 0!==r?r:"slider",f=null!==(i=null==d?void 0:d.sliderPerView)&&void 0!==i?i:3,p=null!==(n=null==d?void 0:d.gridColumns)&&void 0!==n?n:3,m=null!==(s=null==d?void 0:d.gap)&&void 0!==s?s:12,g=null==d?void 0:d.width,v=g?"auto":f,y=u(()=>({fontSize:c?`${c}px`:void 0,fontWeight:600}),[c]),{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(ds,{key:`${v}-${null!=g?g:""}-${m}`,slidesPerView:v,spaceBetween:m},a.map(r=>{var i,n;return t.createElement(cs,{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?t.createElement(YS,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.borderRadius,playback:e.playback}):t.createElement(Cf,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.borderRadius}),t.createElement("p",{className:"truncate",style:{color:null!==(n=null===(i=e.theme)||void 0===i?void 0:i.textColor)&&void 0!==n?n:"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,n;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?t.createElement(YS,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.borderRadius,playback:e.playback}):t.createElement(Cf,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.borderRadius}),t.createElement("p",{className:"truncate",style:{color:null!==(n=null===(i=e.theme)||void 0===i?void 0:i.textColor)&&void 0!==n?n:"black",fontSize:14,userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"}},r.eventName))})))):null};var qS;!function(e){e[e.READY=1]="READY",e[e.STREAMING=2]="STREAMING",e[e.PAUSED=3]="PAUSED"}(qS||(qS={}));const XS=({content:e})=>{const r=t.useMemo(()=>qe(e.start).tz("Asia/Seoul").format("M월 D일 A HH:mm"),[e.start]),i=e.eventStatus!==qS.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"}},"라이브 입장하기"))},QS=e=>{var r,i;const{content:n,aspectRatio:s="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:d}=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:`${d}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(Cf,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"})):"left"===a?t.createElement(t.Fragment,null,t.createElement("div",{className:"flex-1"},t.createElement("a",{href:`${d}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(Cf,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"}))),t.createElement(XS,{content:n})):t.createElement(t.Fragment,null,t.createElement(XS,{content:n}),t.createElement("div",{className:"flex-1"},t.createElement("a",{href:`${d}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(Cf,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"})))))},ZS=e=>{var r;const{theme:i,titleFontSize:n,title:s}=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({},n&&{fontSize:n}),{fontWeight:"bold",color:null==i?void 0:i.textColor,paddingTop:"10px",paddingBottom:"10px",marginBottom:"30px"})},s||("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?"다른 콘텐츠도 확인해 보세요.":"곧 혜택 가득한 라이브로 찾아올게요!")))},JS=e=>{var r,i,n,s;const{widgetType:a,theme:o,layout:l}=e,{liveWidget:d}=If(),c=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!==(n=null==l?void 0:l.paddingLeft)&&void 0!==n?n:0,f=null!==(s=null==l?void 0:l.paddingRight)&&void 0!==s?s:0;return d&&0!==d.length?t.createElement("div",{className:"w-full h-full",style:{backgroundColor:null==o?void 0:o.backgroundColor,color:null==o?void 0:o.textColor,paddingTop:c,paddingBottom:u,paddingLeft:h,paddingRight:f}},"ONE"===a&&"past"!==e.liveType?t.createElement(QS,Object.assign({content:d[0]},e)):t.createElement(KS,Object.assign({content:d},e))):t.createElement(ZS,Object.assign({},e))},eT=e=>{const{setLiveWidget:r,liveWidget:n}=If(),{userId:s,card:a,includeRepresentative:o,liveType:l}=e;return i(()=>{if(!s)return;if(n&&(null==a?void 0:a.visibleCount)&&n.length>Number(a.visibleCount))return void r(n.slice(0,null==a?void 0:a.visibleCount));x(void 0,void 0,void 0,function*(){const t=yield Ys(s,"past"===l?"FINISHED":"UPCOMING",(null==a?void 0:a.visibleCount)||6,o,e.sorting);t&&(yield Promise.all(t.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`,n=yield fetch(i);if(404!==n.status){if(!n.ok){const e=yield n.text().catch(()=>"");return console.error(`[ReplayStatistics] ${n.status} ${n.statusText} ${e}`),{pageView:0,like:0}}return n.json()}}))(s,e.eventId);e.statistics=t}))),r(t))})},[s,null==a?void 0:a.visibleCount,l,e.sorting,o]),t.createElement(fh.div,{className:"w-full h-full"},t.createElement(Eh,null),t.createElement(JS,Object.assign({},e)))},tT=({eventId:e})=>{const[r,i]=a(!1),{PLAYER_BASE_URL:n}=gt();if(r)return null;const{w:s,h:o,left:l,top:d}=(()=>{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(xf,{minWidth:240,lockAspectRatio:9/17.05,style:{zIndex:99999},default:{width:240,height:455,x:l+s-240-50,y:d+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(Ht,{size:16,color:"#888"}),t.createElement("button",{className:"cursor-pointer",style:{color:"#ccc",lineHeight:0},onClick:()=>i(!0),"aria-label":"Close"},t.createElement(Qt,{size:16}))),t.createElement("iframe",{src:`${n}/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"})))},rT=({eventId:e})=>e?t.createElement(fh.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:99999}},t.createElement(Eh,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(tT,{eventId:e}))):null;export{kh as CollectionShowcase,Lf as FloatingPlayer,rT as LiveFloatingPlayer,eT as LiveWidget,Od as PreviewPlayer,_d as ShoppingPlayer,Ct as ViewPlayer,Th as WidgetPlayer,mt as configure};
40
+ */function Ku(){if(Ou)return _u;Ou=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;return _u=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach(function(e){i[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(e){return!1}}()?Object.assign:function(i,n){for(var s,a,o=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(i),l=1;l<arguments.length;l++){for(var d in s=Object(arguments[l]))t.call(s,d)&&(o[d]=s[d]);if(e){a=e(s);for(var c=0;c<a.length;c++)r.call(s,a[c])&&(o[a[c]]=s[a[c]])}}return o},_u}function qu(){if(Nu)return Mu;Nu=1;return Mu="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}function Xu(){return $u?Fu:($u=1,Fu=Function.call.bind(Object.prototype.hasOwnProperty))}function Qu(){if(Uu)return Bu;Uu=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=qu(),r={},i=Xu();e=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function n(n,s,a,o,l){if("production"!==process.env.NODE_ENV)for(var d in n)if(i(n,d)){var c;try{if("function"!=typeof n[d]){var u=Error((o||"React class")+": "+a+" type `"+d+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof n[d]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw u.name="Invariant Violation",u}c=n[d](s,d,o,a,null,t)}catch(e){c=e}if(!c||c instanceof Error||e((o||"React class")+": type specification of "+a+" `"+d+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof c+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),c instanceof Error&&!(c.message in r)){r[c.message]=!0;var h=l?l():"";e("Failed "+a+" type: "+c.message+(null!=h?h:""))}}}return n.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(r={})},Bu=n}function Zu(){if(Gu)return zu;Gu=1;var e=Yu(),t=Ku(),r=qu(),i=Xu(),n=Qu(),s=function(){};function a(){return null}return"production"!==process.env.NODE_ENV&&(s=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),zu=function(o,l){var d="function"==typeof Symbol&&Symbol.iterator;var c="<<anonymous>>",u={array:m("array"),bigint:m("bigint"),bool:m("boolean"),func:m("function"),number:m("number"),object:m("object"),string:m("string"),symbol:m("symbol"),any:p(a),arrayOf:function(e){return p(function(t,i,n,s,a){if("function"!=typeof e)return new f("Property `"+a+"` of component `"+n+"` has invalid PropType notation inside arrayOf.");var o=t[i];if(!Array.isArray(o))return new f("Invalid "+s+" `"+a+"` of type `"+y(o)+"` supplied to `"+n+"`, expected an array.");for(var l=0;l<o.length;l++){var d=e(o,l,n,s,a+"["+l+"]",r);if(d instanceof Error)return d}return null})},element:p(function(e,t,r,i,n){var s=e[t];return o(s)?null:new f("Invalid "+i+" `"+n+"` of type `"+y(s)+"` supplied to `"+r+"`, expected a single ReactElement.")}),elementType:p(function(t,r,i,n,s){var a=t[r];return e.isValidElementType(a)?null:new f("Invalid "+n+" `"+s+"` of type `"+y(a)+"` supplied to `"+i+"`, expected a single ReactElement type.")}),instanceOf:function(e){return p(function(t,r,i,n,s){if(!(t[r]instanceof e)){var a=e.name||c;return new f("Invalid "+n+" `"+s+"` of type `"+(((o=t[r]).constructor&&o.constructor.name?o.constructor.name:c)+"` supplied to `")+i+"`, expected instance of `"+a+"`.")}var o;return null})},node:p(function(e,t,r,i,n){return v(e[t])?null:new f("Invalid "+i+" `"+n+"` supplied to `"+r+"`, expected a ReactNode.")}),objectOf:function(e){return p(function(t,n,s,a,o){if("function"!=typeof e)return new f("Property `"+o+"` of component `"+s+"` has invalid PropType notation inside objectOf.");var l=t[n],d=y(l);if("object"!==d)return new f("Invalid "+a+" `"+o+"` of type `"+d+"` supplied to `"+s+"`, expected an object.");for(var c in l)if(i(l,c)){var u=e(l,c,s,a,o+"."+c,r);if(u instanceof Error)return u}return null})},oneOf:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&s(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),a;return p(function(t,r,i,n,s){for(var a=t[r],o=0;o<e.length;o++)if(h(a,e[o]))return null;var l=JSON.stringify(e,function(e,t){return"symbol"===b(t)?String(t):t});return new f("Invalid "+n+" `"+s+"` of value `"+String(a)+"` supplied to `"+i+"`, expected one of "+l+".")})},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&s("Invalid argument supplied to oneOfType, expected an instance of array."),a;for(var t=0;t<e.length;t++){var n=e[t];if("function"!=typeof n)return s("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+E(n)+" at index "+t+"."),a}return p(function(t,n,s,a,o){for(var l=[],d=0;d<e.length;d++){var c=(0,e[d])(t,n,s,a,o,r);if(null==c)return null;c.data&&i(c.data,"expectedType")&&l.push(c.data.expectedType)}return new f("Invalid "+a+" `"+o+"` supplied to `"+s+"`"+(l.length>0?", expected one of type ["+l.join(", ")+"]":"")+".")})},shape:function(e){return p(function(t,i,n,s,a){var o=t[i],l=y(o);if("object"!==l)return new f("Invalid "+s+" `"+a+"` of type `"+l+"` supplied to `"+n+"`, expected `object`.");for(var d in e){var c=e[d];if("function"!=typeof c)return g(n,s,a,d,b(c));var u=c(o,d,n,s,a+"."+d,r);if(u)return u}return null})},exact:function(e){return p(function(n,s,a,o,l){var d=n[s],c=y(d);if("object"!==c)return new f("Invalid "+o+" `"+l+"` of type `"+c+"` supplied to `"+a+"`, expected `object`.");var u=t({},n[s],e);for(var h in u){var p=e[h];if(i(e,h)&&"function"!=typeof p)return g(a,o,l,h,b(p));if(!p)return new f("Invalid "+o+" `"+l+"` key `"+h+"` supplied to `"+a+"`.\nBad object: "+JSON.stringify(n[s],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var m=p(d,h,a,o,l+"."+h,r);if(m)return m}return null})}};function h(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function f(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function p(e){if("production"!==process.env.NODE_ENV)var t={},i=0;function n(n,a,o,d,u,h,p){if(d=d||c,h=h||o,p!==r){if(l){var m=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw m.name="Invariant Violation",m}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var g=d+":"+o;!t[g]&&i<3&&(s("You are manually calling a React.PropTypes validation function for the `"+h+"` prop on `"+d+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),t[g]=!0,i++)}}return null==a[o]?n?null===a[o]?new f("The "+u+" `"+h+"` is marked as required in `"+d+"`, but its value is `null`."):new f("The "+u+" `"+h+"` is marked as required in `"+d+"`, but its value is `undefined`."):null:e(a,o,d,u,h)}var a=n.bind(null,!1);return a.isRequired=n.bind(null,!0),a}function m(e){return p(function(t,r,i,n,s,a){var o=t[r];return y(o)!==e?new f("Invalid "+n+" `"+s+"` of type `"+b(o)+"` supplied to `"+i+"`, expected `"+e+"`.",{expectedType:e}):null})}function g(e,t,r,i,n){return new f((e||"React class")+": "+t+" type `"+r+"."+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+n+"`.")}function v(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(v);if(null===e||o(e))return!0;var t=function(e){var t=e&&(d&&e[d]||e["@@iterator"]);if("function"==typeof t)return t}(e);if(!t)return!1;var r,i=t.call(e);if(t!==e.entries){for(;!(r=i.next()).done;)if(!v(r.value))return!1}else for(;!(r=i.next()).done;){var n=r.value;if(n&&!v(n[1]))return!1}return!0;default:return!1}}function y(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function b(e){if(null==e)return""+e;var t=y(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function E(e){var t=b(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return f.prototype=Error.prototype,u.checkPropTypes=n,u.resetWarningCache=n.resetWarningCache,u.PropTypes=u,u},zu}function Ju(){if(Hu)return ju;Hu=1;var e=qu();function t(){}function r(){}return r.resetWarningCache=t,ju=function(){function i(t,r,i,n,s,a){if(a!==e){var o=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw o.name="Invariant Violation",o}}function n(){return i}i.isRequired=i;var s={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:n,element:i,elementType:i,instanceOf:n,node:i,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:r,resetWarningCache:t};return s.PropTypes=s,s}}function eh(){if(Vu)return Iu.exports;if(Vu=1,"production"!==process.env.NODE_ENV){var e=Yu();Iu.exports=Zu()(e.isElement,true)}else Iu.exports=Ju()();return Iu.exports}var th=je(eh()),rh="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ih(e,t){return e(t={exports:{}},t.exports),t.exports}var nh=ih(function(e){!function(t){var r=function(e,t,i){if(!l(t)||c(t)||u(t)||h(t)||o(t))return t;var n,s=0,a=0;if(d(t))for(n=[],a=t.length;s<a;s++)n.push(r(e,t[s],i));else for(var f in n={},t)Object.prototype.hasOwnProperty.call(t,f)&&(n[e(f,i)]=r(e,t[f],i));return n},i=function(e){return f(e)?e:(e=e.replace(/[\-_\s]+(.)?/g,function(e,t){return t?t.toUpperCase():""})).substr(0,1).toLowerCase()+e.substr(1)},n=function(e){var t=i(e);return t.substr(0,1).toUpperCase()+t.substr(1)},s=function(e,t){return function(e,t){var r=(t=t||{}).separator||"_",i=t.split||/(?=[A-Z])/;return e.split(i).join(r)}(e,t).toLowerCase()},a=Object.prototype.toString,o=function(e){return"function"==typeof e},l=function(e){return e===Object(e)},d=function(e){return"[object Array]"==a.call(e)},c=function(e){return"[object Date]"==a.call(e)},u=function(e){return"[object RegExp]"==a.call(e)},h=function(e){return"[object Boolean]"==a.call(e)},f=function(e){return(e-=0)==e},p=function(e,t){var r=t&&"process"in t?t.process:t;return"function"!=typeof r?e:function(t,i){return r(t,e,i)}},m={camelize:i,decamelize:s,pascalize:n,depascalize:s,camelizeKeys:function(e,t){return r(p(i,t),e)},decamelizeKeys:function(e,t){return r(p(s,t),e,t)},pascalizeKeys:function(e,t){return r(p(n,t),e)},depascalizeKeys:function(){return this.decamelizeKeys.apply(this,arguments)}};e.exports?e.exports=m:t.humps=m}(rh)}).decamelize,sh=function(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},ah=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],i=!0,n=!1,s=void 0;try{for(var a,o=e[Symbol.iterator]();!(i=(a=o.next()).done)&&(r.push(a.value),!t||r.length!==t);i=!0);}catch(e){n=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(n)throw s}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return sh(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?sh(e,t):void 0}}(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.")}()},oh=ih(function(e){function t(){return e.exports=t=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},t.apply(this,arguments)}e.exports=t}),lh=function(e,t){if(null==e)return{};var r,i,n=function(e,t){if(null==e)return{};var r,i,n={},s=Object.keys(e);for(i=0;i<s.length;i++)r=s[i],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i<s.length;i++)r=s[i],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n},dh=l(null);function ch(e){var r=e.children,i=void 0===r?"":r,n=lh(e,["children"]);return"string"!=typeof i&&(i=w(i)),t.createElement("template",oh({},n,{dangerouslySetInnerHTML:{__html:i}}))}function uh(e){var t=e.root,r=e.children;return b(void 0===r?null:r,t)}ch.propTypes={children:th.oneOfType([th.string,th.node])},uh.propTypes={root:th.object.isRequired,children:th.node};var hh=new Map;var fh=function(){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"core",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){return e.children};return new Proxy(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{get:function(l,d){var c=nh(d,{separator:"-"}),u="".concat(e,"-").concat(c);return hh.has(u)||hh.set(u,function(e){var s=n(function(n,s){var l,d,c=n.mode,u=void 0===c?"open":c,h=n.delegatesFocus,f=void 0!==h&&h,p=n.styleSheets,m=void 0===p?[]:p,g=n.ssr,v=void 0!==g&&g,y=n.children,b=lh(n,["mode","delegatesFocus","styleSheets","ssr","children"]),E=(d=r((l=s)&&l.current),i(function(){l&&(l.current=d.current)},[l]),d),w=a(null),S=ah(w,2),T=S[0],x=S[1],A="node_".concat(u).concat(f);return o(function(){if(E.current)try{if("function"==typeof s&&s(E.current),v){var e=E.current.shadowRoot;return void x(e)}var t=E.current.attachShadow({mode:u,delegatesFocus:f});m.length>0&&(t.adoptedStyleSheets=m),x(t)}catch(e){!function(e){var t=e.error,r=e.styleSheets,i=e.root;if("NotSupportedError"!==t.name)throw t;r.length>0&&(i.adoptedStyleSheets=r)}({error:e,styleSheets:m,root:T})}},[s,E,m]),t.createElement(t.Fragment,null,t.createElement(e.tag,oh({key:A,ref:E},b),(T||v)&&t.createElement(dh.Provider,{value:T},v?t.createElement(ch,{shadowroot:u,shadowrootmode:u},e.render({root:T,ssr:v,children:y})):t.createElement(uh,{root:T},e.render({root:T,ssr:v,children:y})))))});return s.propTypes={mode:th.oneOf(["open","closed"]),delegatesFocus:th.bool,styleSheets:th.arrayOf(th.instanceOf(globalThis.CSSStyleSheet)),ssr:th.bool,children:th.node},s}({tag:c,render:s})),hh.get(u)}})}();const ph='/*! 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-700:oklch(0.37 0.013 285.805);--color-black:#000;--color-white:#fff;--spacing:0.25rem;--container-sm:24rem;--container-lg:32rem;--text-xs:0.75rem;--text-xs--line-height:1.33333;--text-sm:0.875rem;--text-sm--line-height:1.42857;--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-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-4{top:calc(var(--spacing)*4)}.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}.z-\\[999999\\]{z-index:999999}.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-10{margin-inline:calc(var(--spacing)*10)}.mx-auto{margin-inline:auto}.my-0{margin-block:calc(var(--spacing)*0)}.my-2{margin-block:calc(var(--spacing)*2)}.my-10{margin-block:calc(var(--spacing)*10)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-auto{margin-top:auto}.mr-2{margin-right:calc(var(--spacing)*2)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.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-2{height:calc(var(--spacing)*2)}.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-\\[100px\\]{height:100px}.h-\\[125px\\]{height:125px}.h-\\[500px\\]{height:500px}.h-\\[600px\\]{height:600px}.h-auto{height:auto}.h-full{height:100%}.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%}.\\!w-auto{width:auto!important}.w-4{width:calc(var(--spacing)*4)}.w-4\\/5{width:80%}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-16{width:calc(var(--spacing)*16)}.w-32{width:calc(var(--spacing)*32)}.w-36{width:calc(var(--spacing)*36)}.w-\\[24px\\]{width:24px}.w-\\[50px\\]{width:50px}.w-\\[80\\%\\]{width:80%}.w-\\[100px\\]{width:100px}.w-\\[400px\\]{width:400px}.w-\\[500px\\]{width:500px}.w-\\[1024px\\]{width:1024px}.w-full{width:100%}.max-w-16{max-width:calc(var(--spacing)*16)}.max-w-52{max-width:calc(var(--spacing)*52)}.max-w-\\[40\\%\\]{max-width:40%}.max-w-\\[800px\\]{max-width:800px}.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-none{flex:none}.flex-shrink-0,.shrink-0{flex-shrink:0}.grow{flex-grow:1}.border-collapse{border-collapse:collapse}.translate-y-0\\.5{--tw-translate-y:calc(var(--spacing)*0.5);translate:var(--tw-translate-x) var(--tw-translate-y)}.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-baseline{align-items:baseline}.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}.justify-items-center{justify-items:center}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\\.5{gap:calc(var(--spacing)*1.5)}.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-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}.overflow-y-scroll{overflow-y:scroll}.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}.border-\\[\\#f4f3f6\\]{border-color:#f4f3f6}.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-background{background-color:var(--background)}.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-muted{background-color:var(--muted)}.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-4{padding-inline:calc(var(--spacing)*4)}.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-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-foreground{color:var(--foreground)}.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)}.line-through{text-decoration-line:line-through}.no-underline{text-decoration-line:none}.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}.group-data-\\[vaul-drawer-direction\\=bottom\\]\\/drawer-content\\:block{&:is(:where(.group\\/drawer-content)[data-vaul-drawer-direction=bottom] *){display:block}}.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\\=closed\\]\\:animate-out{&[data-state=closed]{--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial;animation-duration:.15s;animation-name:exit}}.data-\\[state\\=closed\\]\\:fade-out-0{&[data-state=closed]{--tw-exit-opacity:0}}.data-\\[state\\=open\\]\\:animate-in{&[data-state=open]{--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial;animation-duration:.15s;animation-name:enter}}.data-\\[state\\=open\\]\\:fade-in-0{&[data-state=open]{--tw-enter-opacity:0}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:inset-x-0{&[data-vaul-drawer-direction=bottom]{inset-inline:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:bottom-0{&[data-vaul-drawer-direction=bottom]{bottom:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:mt-24{&[data-vaul-drawer-direction=bottom]{margin-top:calc(var(--spacing)*24)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:max-h-\\[80vh\\]{&[data-vaul-drawer-direction=bottom]{max-height:80vh}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:rounded-t-lg{&[data-vaul-drawer-direction=bottom]{border-top-left-radius:var(--radius);border-top-right-radius:var(--radius)}}.data-\\[vaul-drawer-direction\\=bottom\\]\\:border-t{&[data-vaul-drawer-direction=bottom]{border-top-style:var(--tw-border-style);border-top-width:1px}}.data-\\[vaul-drawer-direction\\=left\\]\\:inset-y-0{&[data-vaul-drawer-direction=left]{inset-block:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=left\\]\\:left-0{&[data-vaul-drawer-direction=left]{left:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=left\\]\\:w-3\\/4{&[data-vaul-drawer-direction=left]{width:75%}}.data-\\[vaul-drawer-direction\\=left\\]\\:border-r{&[data-vaul-drawer-direction=left]{border-right-style:var(--tw-border-style);border-right-width:1px}}.data-\\[vaul-drawer-direction\\=right\\]\\:inset-y-0{&[data-vaul-drawer-direction=right]{inset-block:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=right\\]\\:right-0{&[data-vaul-drawer-direction=right]{right:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=right\\]\\:w-3\\/4{&[data-vaul-drawer-direction=right]{width:75%}}.data-\\[vaul-drawer-direction\\=right\\]\\:border-l{&[data-vaul-drawer-direction=right]{border-left-style:var(--tw-border-style);border-left-width:1px}}.data-\\[vaul-drawer-direction\\=top\\]\\:inset-x-0{&[data-vaul-drawer-direction=top]{inset-inline:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=top\\]\\:top-0{&[data-vaul-drawer-direction=top]{top:calc(var(--spacing)*0)}}.data-\\[vaul-drawer-direction\\=top\\]\\:mb-24{&[data-vaul-drawer-direction=top]{margin-bottom:calc(var(--spacing)*24)}}.data-\\[vaul-drawer-direction\\=top\\]\\:max-h-\\[80vh\\]{&[data-vaul-drawer-direction=top]{max-height:80vh}}.data-\\[vaul-drawer-direction\\=top\\]\\:rounded-b-lg{&[data-vaul-drawer-direction=top]{border-bottom-left-radius:var(--radius);border-bottom-right-radius:var(--radius)}}.data-\\[vaul-drawer-direction\\=top\\]\\:border-b{&[data-vaul-drawer-direction=top]{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}}.data-\\[vaul-drawer-direction\\=left\\]\\:sm\\:max-w-sm,.sm\\:flex-row,.sm\\:justify-end,.sm\\:mx-0{&[data-vaul-drawer-direction=left]{@media (width >= 40rem){max-width:var(--container-sm)}}}.data-\\[vaul-drawer-direction\\=right\\]\\:sm\\:max-w-sm{&[data-vaul-drawer-direction=right]{@media (width >= 40rem){max-width:var(--container-sm)}}}.\\[\\&\\[data-state\\=open\\]\\>svg\\]\\:rotate-180,.md\\:text-\\[15px\\]{&[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)}.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)}}',mh=ph.trim().length>0,gh="undefined"!=typeof window&&"adoptedStyleSheets"in Document.prototype&&"undefined"!=typeof CSSStyleSheet&&"replaceSync"in CSSStyleSheet.prototype;let vh=null;function yh(e){return vh||(vh=new CSSStyleSheet,vh.replaceSync(e)),vh}function bh(){return mh?ph: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 Eh=({extra:e})=>{const r=bh()+(e?"\n"+e:"");return t.createElement("style",null,r)};function wh(){const[e,n]=t.useState(null),s=r(null),{open:a,setOpen:o}=Gd();return i(()=>{s.current&&(s.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),s.current=e;const t=e.attachShadow({mode:"open"});!function(e){const t=bh();if(gh)e.adoptedStyleSheets=[yh(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),n(i),()=>e.remove()},[]),{container:e,setOpen:o}}const Sh=e=>{const{collectionId:r,isPreview:n,priceText:s,container:a}=e,{setIsPreview:o,setPriceText:l}=ea(),{setCollection:d,setNextKey:c,collection:u}=ia();i(()=>{s&&l(s);const e=Boolean(n);e&&o(e)},[]),i(()=>{x(void 0,void 0,void 0,function*(){var e;const t=yield Vs({collectionId:r,size:10});if(!t)return;const{contents:i,count:n}=t;(null==i?void 0:i.length)&&c(null===(e=i.at(-1))||void 0===e?void 0:e.shortsId),d(Object.assign(Object.assign({},t),{count:n}))})},[r]);const h=function(e){var t,r,i,n,s,a,o,l,d,c,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!==(n=e.borderLine)&&void 0!==n?n:Fe.DAY,exposeTitle:null===(s=e.exposeTitle)||void 0===s||s,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!==(d=e.exposeProductBanner)&&void 0!==d&&d,exposeProductBadge:null!==(c=e.exposeProductBadge)&&void 0!==c&&c,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:f}=function({collectionId:e,iconSize:r}){const{collection:i,setCollection:n,nextKey:s,setNextKey:a,isFetching:o,setIsFetching:l}=ia(),d=t.useRef(null),[c,u]=t.useState(0);return t.useEffect(()=>{if(!d.current)return;const e=new ResizeObserver(e=>{var t,r,i;const n=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(n)});return e.observe(d.current),()=>e.disconnect()},[]),t.useEffect(()=>{var e;if(!i||!i.contents)return;const t=Math.max(1,r+12),d=Math.ceil((c||0)/t)+4,u=null!==(e=i.count)&&void 0!==e?e:Number.MAX_SAFE_INTEGER,h=Math.min(u,d);if(i.contents.length>=h||o)return;let f=!1;return(()=>{x(this,void 0,void 0,function*(){var e,t,r,o,d;try{l(!0);let c=i,u=s||(null===(e=c.contents.at(-1))||void 0===e?void 0:e.shortsId)||void 0;const p=new Set(c.contents.map(e=>e.shortsId));for(;!f&&c.contents.length<h;){const e=Math.max(6,h-c.contents.length),i=yield Vs({collectionId:c.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 s=i.contents.filter(e=>!p.has(e.shortsId));if(!s.length)break;if(s.forEach(e=>p.add(e.shortsId)),c=Object.assign(Object.assign({},c),{contents:[...c.contents,...s]}),n(c),a(u||""),c.contents.length>=(null!==(d=c.count)&&void 0!==d?d: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,c,r,o,s,n,l,a]),{containerRef:d}}({collectionId:r,iconSize:h.iconSize});return t.createElement(fh.div,null,t.createElement(Eh,null),t.createElement("div",{ref:f},t.createElement(ku,{widgetPlayerOption:h,setCollectionUuid:e=>{d(Object.assign(Object.assign({},u),{uuid:e}))},portalContainer:a})))},Th=e=>{const{container:r}=wh();return r?t.createElement(ra,null,t.createElement(Sh,Object.assign({},e,{container:r}))):null},xh=({portalContainer:e,aspectRatio:r})=>{var n;const{collection:s,setNextKey:o}=ia(),[l,d]=a(),{setOpen:c,open:u}=Gd();i(()=>{u||l&&d(null)},[u]);const h=(null!==(n=Md().width)&&void 0!==n?n:0)<430||ma.isMobile;return t.createElement(t.Fragment,null,t.createElement("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${h?2:5}, 1fr)`}},null==s?void 0:s.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:Tt(e.media.objectId),poster:Rt(e.thumbPath)})),t.createElement(Hd,{hideMoreBadge:!0,showMoreBtn:!0,products:e.productsInfo,contentId:e.shortsId,setSelectedProducts:d})))),l&&t.createElement(Tu,{portalContainer:e,title:"상품 목록",contentClassName:"bg-white rounded p-4 product-dialog-container",description:"연결된 전체 상품 정보를 확인해 보세요"},t.createElement(xu,{products:l.productsInfo,contentId:l.shortsId})))},Ah=({collectionId:e,aspectRatio:r,container:n,isPreview:s})=>{const{setCollection:a,setNextKey:o}=ia();return i(()=>{x(void 0,void 0,void 0,function*(){var t;const r=yield Vs({collectionId:e,size:-1});if(!r)return;const{contents:i,count:n}=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:n}))})},[e]),t.createElement(fh.div,null,t.createElement(Eh,null),t.createElement(xh,{portalContainer:n,aspectRatio:r}))},kh=e=>{const{container:r}=wh();return r?t.createElement(ra,null,t.createElement(Ah,Object.assign({},e,{container:r}))):null},Lh=Js(e=>({shortform:null,setShortform:t=>e({shortform:t})}));var Ih={exports:{}},Rh={};function Ph(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=Ph(e[t]))&&(i&&(i+=" "),i+=r);else for(t in e)e[t]&&(i&&(i+=" "),i+=t);return i}function Dh(){for(var e,t,r=0,i="";r<arguments.length;)(e=arguments[r++])&&(t=Ph(e))&&(i&&(i+=" "),i+=t);return i}var Ch,_h=He(Object.freeze({__proto__:null,clsx:Dh,default:Dh})),Oh={},Mh={};function Nh(){if(Ch)return Mh;return Ch=1,Object.defineProperty(Mh,"__esModule",{value:!0}),Mh.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."))},Mh.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]},Mh.int=function(e){return parseInt(e,10)},Mh.isFunction=function(e){return"function"==typeof e||"[object Function]"===Object.prototype.toString.call(e)},Mh.isNum=function(e){return"number"==typeof e&&!isNaN(e)},Mh}var Fh,$h,Bh={};function Uh(){if($h)return Oh;$h=1,Object.defineProperty(Oh,"__esModule",{value:!0}),Oh.addClassName=a,Oh.addEvent=function(e,t,r,i){if(!e)return;const n={capture:!0,...i};e.addEventListener?e.addEventListener(t,r,n):e.attachEvent?e.attachEvent("on"+t,r):e["on"+t]=r},Oh.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")},Oh.createCSSTransform=function(e,r){const i=s(e,r,"px");return{[(0,t.browserPrefixToKey)("transform",t.default)]:i}},Oh.createSVGTransform=function(e,t){return s(e,t,"")},Oh.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)},Oh.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},Oh.getTranslation=s,Oh.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},Oh.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},Oh.matchesSelector=n,Oh.matchesSelectorAndParentsTo=function(e,t,r){let i=e;do{if(n(i,t))return!0;if(i===r)return!1;i=i.parentNode}while(i);return!1},Oh.offsetXYFromParent=function(e,t,r){const i=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect(),n=(e.clientX+t.scrollLeft-i.left)/r,s=(e.clientY+t.scrollTop-i.top)/r;return{x:n,y:s}},Oh.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},Oh.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},Oh.removeClassName=o,Oh.removeEvent=function(e,t,r,i){if(!e)return;const n={capture:!0,...i};e.removeEventListener?e.removeEventListener(t,r,n):e.detachEvent?e.detachEvent("on"+t,r):e["on"+t]=null},Oh.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=Nh(),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 n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var o=s?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(n,a,o):n[a]=e[a]}n.default=e,i&&i.set(e,n);return n}(function(){if(Fh)return Bh;Fh=1,Object.defineProperty(Bh,"__esModule",{value:!0}),Bh.browserPrefixToKey=r,Bh.browserPrefixToStyle=function(e,t){return t?"-".concat(t.toLowerCase(),"-").concat(e):e},Bh.default=void 0,Bh.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 n=null===(t=window.document)||void 0===t||null===(t=t.documentElement)||void 0===t?void 0:t.style;if(!n)return"";if(i in n)return"";for(let t=0;t<e.length;t++)if(r(i,e[t])in n)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 Bh.default=t(),Bh}());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 n(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 s(e,t,r){let{x:i,y:n}=e,s="translate(".concat(i).concat(r,",").concat(n).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);s="translate(".concat(e,", ").concat(i,")")+s}return s}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 Oh}var zh,Gh={};function jh(){if(zh)return Gh;zh=1,Object.defineProperty(Gh,"__esModule",{value:!0}),Gh.canDragX=function(e){return"both"===e.props.axis||"x"===e.props.axis},Gh.canDragY=function(e){return"both"===e.props.axis||"y"===e.props.axis},Gh.createCoreData=function(t,i,n){const s=!(0,e.isNum)(t.lastX),a=r(t);return s?{node:a,deltaX:0,deltaY:0,lastX:i,lastY:n,x:i,y:n}:{node:a,deltaX:i-t.lastX,deltaY:n-t.lastY,lastX:t.lastX,lastY:t.lastY,x:i,y:n}},Gh.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}},Gh.getBoundPosition=function(i,n,s){if(!i.props.bounds)return[n,s];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 n;if(n="parent"===a?o.parentNode:r.querySelector(a),!(n instanceof i.HTMLElement))throw new Error('Bounds selector "'+a+'" could not find an element.');const s=n,l=i.getComputedStyle(o),d=i.getComputedStyle(s);a={left:-o.offsetLeft+(0,e.int)(d.paddingLeft)+(0,e.int)(l.marginLeft),top:-o.offsetTop+(0,e.int)(d.paddingTop)+(0,e.int)(l.marginTop),right:(0,t.innerWidth)(s)-(0,t.outerWidth)(o)-o.offsetLeft+(0,e.int)(d.paddingRight)-(0,e.int)(l.marginRight),bottom:(0,t.innerHeight)(s)-(0,t.outerHeight)(o)-o.offsetTop+(0,e.int)(d.paddingBottom)-(0,e.int)(l.marginBottom)}}(0,e.isNum)(a.right)&&(n=Math.min(n,a.right));(0,e.isNum)(a.bottom)&&(s=Math.min(s,a.bottom));(0,e.isNum)(a.left)&&(n=Math.max(n,a.left));(0,e.isNum)(a.top)&&(s=Math.max(s,a.top));return[n,s]},Gh.getControlPosition=function(e,i,n){const s="number"==typeof i?(0,t.getTouch)(e,i):null;if("number"==typeof i&&!s)return null;const a=r(n),o=n.props.offsetParent||a.offsetParent||a.ownerDocument.body;return(0,t.offsetXYFromParent)(s||e,o,n.props.scale)},Gh.snapToGrid=function(e,t,r){const i=Math.round(t/e[0])*e[0],n=Math.round(r/e[1])*e[1];return[i,n]};var e=Nh(),t=Uh();function r(e){const t=e.findDOMNode();if(!t)throw new Error("<DraggableCore>: Unmounted during event!");return t}return Gh}var Hh,Vh,Wh,Yh,Kh={},qh={};function Xh(){if(Hh)return qh;return Hh=1,Object.defineProperty(qh,"__esModule",{value:!0}),qh.default=function(){},qh}function Qh(){if(Vh)return Kh;Vh=1,Object.defineProperty(Kh,"__esModule",{value:!0}),Kh.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=d(t);if(r&&r.has(e))return r.get(e);var i={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var a=n?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(i,s,a):i[s]=e[s]}i.default=e,r&&r.set(e,i);return i}(t),r=l(eh()),i=l(y),n=Uh(),s=jh(),a=Nh(),o=l(Xh());function l(e){return e&&e.__esModule?e:{default:e}}function d(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(d=function(e){return e?r:t})(e)}function c(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),c(this,"dragging",!1),c(this,"lastX",NaN),c(this,"lastY",NaN),c(this,"touchIdentifier",null),c(this,"mounted",!1),c(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,n.matchesSelectorAndParentsTo)(e.target,this.props.handle,t)||this.props.cancel&&(0,n.matchesSelectorAndParentsTo)(e.target,this.props.cancel,t))return;"touchstart"===e.type&&e.preventDefault();const i=(0,n.getTouchIdentifier)(e);this.touchIdentifier=i;const a=(0,s.getControlPosition)(e,i,this);if(null==a)return;const{x:l,y:d}=a,c=(0,s.createCoreData)(this,l,d);(0,o.default)("DraggableCore: handleDragStart: %j",c),(0,o.default)("calling",this.props.onStart);!1!==this.props.onStart(e,c)&&!1!==this.mounted&&(this.props.enableUserSelectHack&&(0,n.addUserSelectStyles)(r),this.dragging=!0,this.lastX=l,this.lastY=d,(0,n.addEvent)(r,f.move,this.handleDrag),(0,n.addEvent)(r,f.stop,this.handleDragStop))}),c(this,"handleDrag",e=>{const t=(0,s.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,s.snapToGrid)(this.props.grid,e,t),!e&&!t)return;r=this.lastX+e,i=this.lastY+t}const n=(0,s.createCoreData)(this,r,i);(0,o.default)("DraggableCore: handleDrag: %j",n);if(!1!==this.props.onDrag(e,n)&&!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)}}),c(this,"handleDragStop",e=>{if(!this.dragging)return;const t=(0,s.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,s.snapToGrid)(this.props.grid,e,t),r=this.lastX+e,i=this.lastY+t}const a=(0,s.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,n.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,n.removeEvent)(l.ownerDocument,f.move,this.handleDrag),(0,n.removeEvent)(l.ownerDocument,f.stop,this.handleDragStop))}),c(this,"onMouseDown",e=>(f=h,this.handleDragStart(e))),c(this,"onMouseUp",e=>(f=h,this.handleDragStop(e))),c(this,"onTouchStart",e=>(f=u,this.handleDragStart(e))),c(this,"onTouchEnd",e=>(f=u,this.handleDragStop(e)))}componentDidMount(){this.mounted=!0;const e=this.findDOMNode();e&&(0,n.addEvent)(e,u.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const e=this.findDOMNode();if(e){const{ownerDocument:t}=e;(0,n.removeEvent)(t,h.move,this.handleDrag),(0,n.removeEvent)(t,u.move,this.handleDrag),(0,n.removeEvent)(t,h.stop,this.handleDragStop),(0,n.removeEvent)(t,u.stop,this.handleDragStop),(0,n.removeEvent)(e,u.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,n.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 Kh.default=p,c(p,"displayName","DraggableCore"),c(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}),c(p,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1}),Kh}function Zh(){return Wh||(Wh=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"DraggableCore",{enumerable:!0,get:function(){return d.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={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var a=n?Object.getOwnPropertyDescriptor(e,s):null;a&&(a.get||a.set)?Object.defineProperty(i,s,a):i[s]=e[s]}i.default=e,r&&r.set(e,i);return i}(t),i=u(eh()),n=u(y),s=u(_h),a=Uh(),o=jh(),l=Nh(),d=u(Qh()),c=u(Xh());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 m 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,c.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,c.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,c.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[n,s]=(0,o.getBoundPosition)(this,i.x,i.y);i.x=n,i.y=s,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,c.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:n.default.findDOMNode(this)}render(){const{axis:e,bounds:t,children:i,defaultPosition:n,defaultClassName:l,defaultClassNameDragging:c,defaultClassNameDragged:u,position:h,positionOffset:p,scale:m,...g}=this.props;let v={},y=null;const b=!Boolean(h)||this.state.dragging,E=h||n,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,s.default)(i.props.className||"",l,{[c]:this.state.dragging,[u]:this.state.dragged});return r.createElement(d.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=m,p(m,"displayName","Draggable"),p(m,"propTypes",{...d.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(m,"defaultProps",{...d.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})}(Rh)),Rh}var Jh=function(){if(Yh)return Ih.exports;Yh=1;const{default:e,DraggableCore:t}=Zh();return Ih.exports=e,Ih.exports.default=e,Ih.exports.DraggableCore=t,Ih.exports}(),ef=je(Jh),tf=function(){return tf=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},tf.apply(this,arguments)},rf={width:"100%",height:"10px",top:"0px",left:"0px",cursor:"row-resize"},nf={width:"10px",height:"100%",top:"0px",left:"0px",cursor:"col-resize"},sf={width:"20px",height:"20px",position:"absolute",zIndex:1},af={top:tf(tf({},rf),{top:"-5px"}),right:tf(tf({},nf),{left:void 0,right:"-5px"}),bottom:tf(tf({},rf),{top:void 0,bottom:"-5px"}),left:tf(tf({},nf),{left:"-5px"}),topRight:tf(tf({},sf),{right:"-10px",top:"-10px",cursor:"ne-resize"}),bottomRight:tf(tf({},sf),{right:"-10px",bottom:"-10px",cursor:"se-resize"}),bottomLeft:tf(tf({},sf),{left:"-10px",bottom:"-10px",cursor:"sw-resize"}),topLeft:tf(tf({},sf),{left:"-10px",top:"-10px",cursor:"nw-resize"})},of=h(function(e){var t=e.onResizeStart,r=e.direction,i=e.children,n=e.replaceStyles,s=e.className,a=c(function(e){t(e,r)},[t,r]),o=c(function(e){t(e,r)},[t,r]),l=u(function(){return tf(tf({position:"absolute",userSelect:"none"},af[r]),null!=n?n:{})},[n,r]);return p("div",{className:s||void 0,style:l,onMouseDown:a,onTouchStart:o,children:i})}),lf=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)}}(),df=function(){return df=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},df.apply(this,arguments)},cf={width:"auto",height:"auto"},uf=function(e,t,r){return Math.max(Math.min(e,r),t)},hf=function(e,t,r){var i=Math.round(e/t);return i*t+r*(i-1)},ff=function(e,t){return new RegExp(e,"i").test(t)},pf=function(e){return Boolean(e.touches&&e.touches.length)},mf=function(e,t,r){void 0===r&&(r=0);var i=t.reduce(function(r,i,n){return Math.abs(i-e)<Math.abs(t[r]-e)?n:r},0),n=Math.abs(t[i]-e);return 0===r||n<r?t[i]:e},gf=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")},vf=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},yf=["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"],bf="__resizable_base__",Ef=function(e){function t(t){var r,i,n,s,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(bf):t.className+=bf,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!==(s=null===(n=a.propsSize)||void 0===n?void 0:n.height)&&void 0!==s?s:"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 lf(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||cf},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,n=this.resizable.style.position;"relative"!==n&&(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=n}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(),n=Number(e.state[t].toString().replace("px",""))/i[t]*100;return"".concat(n,"%")}return gf(e.state[t])};return{width:t&&void 0!==t.width&&!this.state.isResizing?gf(t.width):r("width"),height:t&&void 0!==t.height&&!this.state.isResizing?gf(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,n=this.props.boundsByDirection,s=this.state.direction,a=n&&ff("left",s),o=n&&ff("top",s);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,n=(r=this.props.resizeRatio||1,Array.isArray(r)?r:[r,r]),s=n[0],a=n[1],o=this.state,l=o.direction,d=o.original,c=this.props,u=c.lockAspectRatio,h=c.lockAspectRatioExtraHeight,f=c.lockAspectRatioExtraWidth,p=d.width,m=d.height,g=h||0,v=f||0;return ff("right",l)&&(p=d.width+(e-d.x)*s/i,u&&(m=(p-v)/this.ratio+g)),ff("left",l)&&(p=d.width-(e-d.x)*s/i,u&&(m=(p-v)/this.ratio+g)),ff("bottom",l)&&(m=d.height+(t-d.y)*a/i,u&&(p=(m-g)*this.ratio+v)),ff("top",l)&&(m=d.height-(t-d.y)*a/i,u&&(p=(m-g)*this.ratio+v)),{newWidth:p,newHeight:m}},t.prototype.calculateNewSizeFromAspectRatio=function(e,t,r,i){var n=this.props,s=n.lockAspectRatio,a=n.lockAspectRatioExtraHeight,o=n.lockAspectRatioExtraWidth,l=void 0===i.width?10:i.width,d=void 0===r.width||r.width<0?e:r.width,c=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(s){var p=(c-h)*this.ratio+f,m=(u-h)*this.ratio+f,g=(l-f)/this.ratio+h,v=(d-f)/this.ratio+h,y=Math.max(l,p),b=Math.min(d,m),E=Math.max(c,g),w=Math.min(u,v);e=uf(e,y,b),t=uf(t,E,w)}else e=uf(e,l,d),t=uf(t,c,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 n=this.resizable.getBoundingClientRect(),s=n.left,a=n.top,o=n.right,l=n.bottom;this.resizableLeft=s*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,n=0;if(e.nativeEvent&&function(e){return Boolean((e.clientX||0===e.clientX)&&(e.clientY||0===e.clientY))}(e.nativeEvent)?(i=e.nativeEvent.clientX,n=e.nativeEvent.clientY):e.nativeEvent&&pf(e.nativeEvent)&&(i=e.nativeEvent.touches[0].clientX,n=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 s=this.window.getComputedStyle(this.resizable);if("auto"!==s.flexBasis){var a=this.parentNode;if(a){var o=this.window.getComputedStyle(a).flexDirection;this.flexDir=o.startsWith("row")?"row":"column",r=s.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var l={original:{x:i,y:n,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:df(df({},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&&pf(e))try{e.preventDefault(),e.stopPropagation()}catch(e){}var r=this.props,i=r.maxWidth,n=r.maxHeight,s=r.minWidth,a=r.minHeight,o=pf(e)?e.touches[0].clientX:e.clientX,l=pf(e)?e.touches[0].clientY:e.clientY,d=this.state,c=d.direction,u=d.original,h=d.width,f=d.height,p=this.getParentSize(),m=function(e,t,r,i,n,s,a){return i=vf(i,e.width,t,r),n=vf(n,e.height,t,r),s=vf(s,e.width,t,r),a=vf(a,e.height,t,r),{maxWidth:void 0===i?void 0:Number(i),maxHeight:void 0===n?void 0:Number(n),minWidth:void 0===s?void 0:Number(s),minHeight:void 0===a?void 0:Number(a)}}(p,this.window.innerWidth,this.window.innerHeight,i,n,s,a);i=m.maxWidth,n=m.maxHeight,s=m.minWidth,a=m.minHeight;var g=this.calculateNewSizeFromDirection(o,l),v=g.newHeight,y=g.newWidth,b=this.calculateNewMaxFromBoundary(i,n);this.props.snap&&this.props.snap.x&&(y=mf(y,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(v=mf(v,this.props.snap.y,this.props.snapGap));var w=this.calculateNewSizeFromAspectRatio(y,v,{width:b.maxWidth,height:b.maxHeight},{width:s,height:a});if(y=w.newWidth,v=w.newHeight,this.props.grid){var S=hf(y,this.props.grid[0],this.props.gridGap?this.props.gridGap[0]:0),T=hf(v,this.props.grid[1],this.props.gridGap?this.props.gridGap[1]:0),x=this.props.snapGap||0;y=0===x||Math.abs(S-y)<=x?S:y,v=0===x||Math.abs(T-v)<=x?T:v}var A={width:y-u.width,height:v-u.height};if(this.delta=A,h&&"string"==typeof h)if(h.endsWith("%")){var k=y/p.width*100;y="".concat(k,"%")}else if(h.endsWith("vw")){var L=y/this.window.innerWidth*100;y="".concat(L,"vw")}else if(h.endsWith("vh")){var I=y/this.window.innerHeight*100;y="".concat(I,"vh")}if(f&&"string"==typeof f)if(f.endsWith("%")){k=v/p.height*100;v="".concat(k,"%")}else if(f.endsWith("vw")){L=v/this.window.innerWidth*100;v="".concat(L,"vw")}else if(f.endsWith("vh")){I=v/this.window.innerHeight*100;v="".concat(I,"vh")}var R={width:this.createSizeForCssProperty(y,"width"),height:this.createSizeForCssProperty(v,"height")};"row"===this.flexDir?R.flexBasis=R.width:"column"===this.flexDir&&(R.flexBasis=R.height);var P=this.state.width!==R.width,D=this.state.height!==R.height,C=this.state.flexBasis!==R.flexBasis,_=P||D||C;_&&E(function(){t.setState(R)}),this.props.onResize&&_&&this.props.onResize(e,c,this.resizable,A)}},t.prototype.onMouseUp=function(e){var t,r,i=this.state,n=i.isResizing,s=i.direction;i.original,n&&this.resizable&&(this.props.onResizeStop&&this.props.onResizeStop(e,s,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:df(df({},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,n=t.handleClasses,s=t.handleWrapperStyle,a=t.handleWrapperClass,o=t.handleComponent;if(!r)return null;var l=Object.keys(r).map(function(t){return!1!==r[t]?p(of,{direction:t,onResizeStart:e.onResizeStart,replaceStyles:i&&i[t],className:n&&n[t],children:o&&o[t]?o[t]:null},t):null});return p("div",{className:a,style:s,children:l})},t.prototype.render=function(){var e=this,t=Object.keys(this.props).reduce(function(t,r){return-1!==yf.indexOf(r)||(t[r]=e.props[r]),t},{}),r=df(df(df({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 g(i,df({style:r,className:this.props.className},t,{ref:function(t){t&&(e.resizable=t)},children:[this.state.isResizing&&p("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),wf=function(e,t){return wf=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])},wf(e,t)};var Sf=function(){return Sf=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},Sf.apply(this,arguments)};var Tf={width:"auto",height:"auto",display:"inline-block",position:"absolute",top:0,left:0},xf=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}wf(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(),n=i.x,s=i.y;this.draggable.setState({x:n-t,y:s-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,n=this.getParent(),s=this.props.scale;if("parent"===this.props.bounds)i=n;else{if("body"===this.props.bounds){var a=n.getBoundingClientRect(),o=a.left,l=a.top,d=document.body.getBoundingClientRect(),c=-(o-n.offsetLeft*s-d.left)/s,u=-(l-n.offsetTop*s-d.top)/s,h=(document.body.offsetWidth-this.resizable.size.width*s)/s+c,f=(document.body.offsetHeight-this.resizable.size.height*s)/s+u;return this.setState({bounds:{top:u,right:h,bottom:f,left:c}})}if("window"===this.props.bounds){if(!this.resizable)return;var p=n.getBoundingClientRect(),m=p.left,g=p.top,v=-(m-n.offsetLeft*s)/s,y=-(g-n.offsetTop*s)/s;h=(window.innerWidth-this.resizable.size.width*s)/s+v,f=(window.innerHeight-this.resizable.size.height*s)/s+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&&n instanceof HTMLElement){var b=i.getBoundingClientRect(),E=b.left,w=b.top,S=n.getBoundingClientRect(),T=(E-S.left)/s,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/s,bottom:x+(i.offsetHeight-this.resizable.size.height)-A.top,left:T-A.left/s}})}}}},t.prototype.onDrag=function(e,t){if(this.props.onDrag){var r=this.offsetFromParent,i=r.left,n=r.top;return this.props.dragAxis&&"both"!==this.props.dragAxis?"x"===this.props.dragAxis?this.props.onDrag(e,Sf(Sf({},t),{x:t.x+i,y:this.originalPosition.y+n,deltaY:0})):"y"===this.props.dragAxis?this.props.onDrag(e,Sf(Sf({},t),{x:this.originalPosition.x+i,y:t.y+n,deltaX:0})):void 0:this.props.onDrag(e,Sf(Sf({},t),{x:t.x+i,y:t.y+n}))}},t.prototype.onDragStop=function(e,t){if(this.props.onDragStop){var r=this.offsetFromParent,i=r.left,n=r.top;return this.props.dragAxis&&"both"!==this.props.dragAxis?"x"===this.props.dragAxis?this.props.onDragStop(e,Sf(Sf({},t),{x:t.x+i,y:this.originalPosition.y+n,deltaY:0})):"y"===this.props.dragAxis?this.props.onDragStop(e,Sf(Sf({},t),{x:this.originalPosition.x+i,y:t.y+n,deltaX:0})):void 0:this.props.onDragStop(e,Sf(Sf({},t),{x:t.x+i,y:t.y+n}))}},t.prototype.onResizeStart=function(e,t,r){e.stopPropagation(),this.setState({resizing:!0});var i=this.props.scale,n=this.offsetFromParent,s=this.getDraggablePosition();if(this.resizingPosition={x:s.x+n.left,y:s.y+n.top},this.originalPosition=s,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 d=this.getMaxSizesFromProps(),c=d.maxWidth,u=d.maxHeight,h=this.getParentSize();if(c&&"string"==typeof c)if(c.endsWith("%")){var f=Number(c.replace("%",""))/100;c=h.width*f}else c.endsWith("px")&&(c=Number(c.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(c)?c:k})}if(T||this.props.lockAspectRatio&&!S&&!x){k=E+(y-m)/i;this.setState({maxWidth:k>Number(c)?c: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 n=this,s={x:this.originalPosition.x,y:this.originalPosition.y},a=-i.width,o=-i.height;["top","left","topLeft","bottomLeft","topRight"].includes(t)&&("bottomLeft"===t?s.x+=a:("topRight"===t||(s.x+=a),s.y+=o));var l=this.draggable.state;s.x===l.x&&s.y===l.y||E(function(){n.draggable.setState(s)}),this.updateOffsetFromParent();var d=this.offsetFromParent,c=this.getDraggablePosition().x+d.left,u=this.getDraggablePosition().y+d.top;this.resizingPosition={x:c,y:u},this.props.onResize&&this.props.onResize(e,t,r,i,{x:c,y:u})},t.prototype.onResizeStop=function(e,t,r,i){this.setState({resizing:!1});var n=this.getMaxSizesFromProps(),s=n.maxWidth,a=n.maxHeight;this.setState({maxWidth:s,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(),n=i.left,s=i.top,a=r.getBoundingClientRect(),o=this.getDraggablePosition(),l=t.scrollLeft,d=t.scrollTop;this.offsetFromParent={left:a.left-n+l-o.x*e,top:a.top-s+d-o.y*e}},t.prototype.render=function(){var e=this,t=this.props,r=t.disableDragging,i=t.style,n=t.dragHandleClassName,a=t.position,o=t.onMouseDown,l=t.onMouseUp,d=t.dragAxis,c=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 n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(r[i[n]]=e[i[n]])}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?Sf({},this.props.default):void 0;delete A.default;var L,I=r||n?{cursor:"auto"}:{cursor:"move"},R=Sf(Sf(Sf({},Tf),I),i),P=this.offsetFromParent,D=P.left,C=P.top;a&&(L={x:a.x-D,y:a.y-C});var _,O=this.state.resizing?void 0:L,M=this.state.resizing?"both":d;return s(ef,{ref:function(t){t&&(e.draggable=t)},handle:n?".".concat(n):void 0,defaultPosition:k,onMouseDown:o,onMouseUp:l,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop,axis:M,disabled:r,grid:c,bounds:u?this.state.bounds:void 0,position:O,enableUserSelectHack:h,cancel:f,scale:S,allowAnyClick:T,nodeRef:this.resizableElement,positionOffset:x},s(Ef,Sf({},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 Af=({shortform:e,setClose:r})=>{const[n,s]=t.useState(!0),[o,l]=a(!0),[d,c]=a(!1),u=t.useRef(null),h=()=>{u.current&&(window.clearTimeout(u.current),u.current=null)},f=(e=1500)=>{h(),u.current=window.setTimeout(()=>c(!1),e)};return i(()=>()=>h(),[]),t.createElement("div",{className:"relative w-full h-full",onClick:()=>{c(!0),f(2e3)},onMouseLeave:()=>f(800),onMouseEnter:()=>d&&f(1500)},t.createElement("div",{className:"absolute inset-0 bg-black",style:{zIndex:1,opacity:d?.4:0,transition:"opacity 300ms ease",pointerEvents:d?"auto":"none"}}),t.createElement("div",{className:"absolute inset-0",style:{zIndex:2,opacity:d?1:0,transition:"opacity 300ms ease",pointerEvents:d?"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(),s(e=>!e)},"aria-label":n?"Unmute":"Mute"},n?t.createElement(Xt,{size:20}):t.createElement(qt,{size:20})),t.createElement("button",{className:"cursor-pointer",onClick:e=>{null==e||e.stopPropagation(),r()},"aria-label":"Close"},t.createElement(Qt,{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(Wt,{size:28}):t.createElement(Yt,{size:28})))),t.createElement(Ct,{shortform:e,mute:n,play:o}))},kf=({shortsId:e,type:r})=>{const{shortform:n}=Lh(),[s,o]=a(!1),{playtime:l}=Fs(),d=()=>{if(!n)return;o(!0);const{shortsId:e,uuid:t,userId:r}=n;zs({contentId:e,uuid:t,type:Et.SHORTS,playtime:l,userId:r})};(({shorform:e,playtime:t})=>{i(()=>{if(!e)return;const{shortsId:t,shortsUuid:r,userId:i}=e;Us({contentId:t,uuid:r,type:Et.SHORTS,userId:i,isFirstPlay:!Lt(t)})},[]);const r=Ms();i(()=>{if(!e||r)return;const{shortsId:i,uuid:n,userId:s}=e;zs({contentId:i,uuid:n,type:Et.SHORTS,playtime:t,userId:s})},[r])})({shorform:n,playtime:l});const{w:c,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 n&&!s&&t.createElement(xf,{minWidth:240,lockAspectRatio:9/16,style:{zIndex:99999},default:{width:240,height:427,x:h+c-240-50,y:f+u-427-50},bounds:"window"},"shopping"===r&&n.productsInfo.length>0?t.createElement(Dd,{shortForm:n,handleClose:d}):t.createElement(Af,{shortform:n,setClose:d}))},Lf=({shortsId:e,type:r,isPreview:n})=>{const{setShortform:s,shortform:a}=Lh();return i(()=>{if(!e)return;e&&x(void 0,void 0,void 0,function*(){const t=yield Ws(e,n);t&&s(Object.assign(Object.assign({},t),{uuid:kt()}))})},[e]),a?t.createElement(fh.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:99999}},t.createElement(Eh,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(kf,{shortsId:e,type:r}))):null},If=Js(e=>({liveWidget:null,setLiveWidget:t=>e({liveWidget:t}),nextKey:"",setNextKey:t=>e({nextKey:t}),isFetching:!1,setIsFetching:t=>e({isFetching:t})})),Rf=({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"}})},Pf=({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"})},Df=(e,r)=>{const[i,n]=t.useState({}),[s,a]=t.useState({primary:20,secondary:12});return t.useEffect(()=>{const t=r.current;if(!t)return;const i=()=>{const r=t.getBoundingClientRect(),i=Math.max(0,Math.floor(r.width)),s=Math.max(0,Math.floor(r.height)),[o,l]=e.includes("/")?e.split("/").map(e=>parseFloat(e)):[1,1],d=l/o;let c,u;i>0&&s>0?(c=i,u=Math.round(c*d),u>s&&(u=s,c=Math.round(u/d)),n({width:c,height:u})):n({});const h="number"==typeof c?c: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:s,boxSize:i}},Cf=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:n})=>{var s,o;const{leftTime:l}=(e=>{const{start:t}=e,r=qe().tz("Asia/Seoul").unix(),[i,n]=a(t-r>0?t-r:0);return Ns(()=>{n(i<=0?0:e=>e-1)},1e3),{leftTime:i}})(e),d=null===(o=null===(s=null==e?void 0:e.designInfo)||void 0===s?void 0:s.thumbPath)||void 0===o?void 0:o.preview,c=t.useRef(null),{boxSize:u,fontSize:h}=Df(r,c),{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:c},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!=n?n:10}px`,backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",aspectRatio:u.height?void 0:r,backgroundImage:d?`url(${Rt(d)})`:void 0,backgroundColor:d?void 0:"black"}},1===e.openStatus?t.createElement(t.Fragment,null,t.createElement(Pf,{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(Rf,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(Rf,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`}},"곧 라이브가 시작됩니다!")))))},_f=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},Of=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=Mf},Mf=Number.MAX_SAFE_INTEGER||9007199254740991;let Nf=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}({}),Ff=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}({}),$f=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 Bf="manifest",Uf="level",zf="audioTrack",Gf="subtitleTrack",jf="main",Hf="audio",Vf="subtitle";class Wf{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 Yf{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 Wf(e),this.fast_=new Wf(t),this.defaultTTFB_=i,this.ttfb_=new Wf(e)}update(e,t){const{slow_:r,fast_:i,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new Wf(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new Wf(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Wf(e,n.getEstimate(),n.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 Kf(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 qf(){return qf=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},qf.apply(null,arguments)}function Xf(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 Qf(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Xf(Object(r),!0).forEach(function(t){Kf(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Xf(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class Zf{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=Jf,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 Jf=function(){},ep={trace:Jf,debug:Jf,log:Jf,warn:Jf,info:Jf,error:Jf};function tp(){return qf({},ep)}function rp(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}] >`):Jf}(e,r)}const ip=tp();const np=ip;function sp(e=!0){if("undefined"==typeof self)return;return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function ap(e,t){const r=Object.keys(e),i=Object.keys(t),n=r.length,s=i.length;return!n||!s||n===s&&!r.some(e=>-1===i.indexOf(e))}function op(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,n,s,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:n=e[o++],a+=String.fromCharCode((31&i)<<6|63&n);break;case 14:n=e[o++],s=e[o++],a+=String.fromCharCode((15&i)<<12|(63&n)<<6|63&s)}}return a}function lp(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 dp(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function cp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var up,hp={exports:{}};var fp,pp,mp,gp,vp,yp=up?hp.exports:(up=1,fp=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,pp=/^(?=([^\/?#]*))\1([^]*)$/,mp=/(?:\/|^)\.(?=\/)/g,gp=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,hp.exports=vp={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=vp.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=vp.normalizePath(i.path),vp.buildURLFromParts(i)}var n=vp.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=vp.normalizePath(n.path),vp.buildURLFromParts(n)):t;var s=vp.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var a=pp.exec(s.path);s.netLoc=a[1],s.path=a[2]}s.netLoc&&!s.path&&(s.path="/");var o={scheme:s.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(o.netLoc=s.netLoc,"/"!==n.path[0]))if(n.path){var l=s.path,d=l.substring(0,l.lastIndexOf("/")+1)+n.path;o.path=vp.normalizePath(d)}else o.path=s.path,n.params||(o.params=s.params,n.query||(o.query=s.query));return null===o.path&&(o.path=r.alwaysNormalize?vp.normalizePath(n.path):n.path),vp.buildURLFromParts(o)},parseURL:function(e){var t=fp.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(mp,"");e.length!==(e=e.replace(gp,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}});class bp{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 Ep="audio",wp="video",Sp="audiovideo";class Tp{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=Lp(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={[Ep]:null,[wp]:null,[Sp]: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 bp),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=yp.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[Ep]=null,e[wp]=null,e[Sp]=null}}function xp(e){return"initSegment"!==e.sn}class Ap extends Tp{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(_f(e)&&_f(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=_f(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){_f(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}get ref(){return xp(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,n,s=!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,n)):a[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:s}}}class kp extends Tp{constructor(e,t,r,i,n){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 s=e.enumeratedString("BYTERANGE");s&&this.setByteRange(s,n),n&&(this.fragOffset=n.fragOffset+n.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 Lp(e,t){const r=Object.getPrototypeOf(e);if(r){const e=Object.getOwnPropertyDescriptor(r,t);return e||Lp(r,t)}}const Ip=Math.pow(2,32)-1,Rp=[].push,Pp={video:1,audio:2,id3:3,text:4};function Dp(e){return String.fromCharCode.apply(null,e)}function Cp(e,t){const r=e[t]<<8|e[t+1];return r<0?65536+r:r}function _p(e,t){const r=Mp(e,t);return r<0?4294967296+r:r}function Op(e,t){let r=_p(e,t);return r*=Math.pow(2,32),r+=_p(e,t+4),r}function Mp(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function Np(e,t){const r=[];if(!t.length)return r;const i=e.byteLength;for(let n=0;n<i;){const s=_p(e,n),a=s>1?n+s:i;if(Dp(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,a));else{const i=Np(e.subarray(n+8,a),t.slice(1));i.length&&Rp.apply(r,i)}n=a}return r}function Fp(e){const t=[],r=e[0];let i=8;const n=_p(e,i);i+=4;let s=0,a=0;0===r?(s=_p(e,i),a=_p(e,i+4),i+=8):(s=Op(e,i),a=Op(e,i+8),i+=16),i+=2;let o=e.length+a;const l=Cp(e,i);i+=2;for(let r=0;r<l;r++){let r=i;const s=_p(e,r);r+=4;const a=2147483647&s;if(1===(2147483648&s)>>>31)return np.warn("SIDX has hierarchical references (not supported)"),null;const l=_p(e,r);r+=4,t.push({referenceSize:a,subsegmentDuration:l,info:{duration:l/n,start:o,end:o+a-1}}),o+=a,r+=4,i=r}return{earliestPresentationTime:s,timescale:n,version:r,referencesCount:l,references:t}}function $p(e){const t=[],r=Np(e,["moov","trak"]);for(let e=0;e<r.length;e++){const i=r[e],n=Np(i,["tkhd"])[0];if(n){let e=n[0];const r=_p(n,0===e?12:20),s=Np(i,["mdia","mdhd"])[0];if(s){e=s[0];const n=_p(s,0===e?12:20),a=Np(i,["mdia","hdlr"])[0];if(a){const e=Dp(a.subarray(8,12)),s={soun:Ep,vide:wp}[e],o=Bp(Np(i,["mdia","minf","stbl","stsd"])[0]);s?(t[r]={timescale:n,type:s,stsd:o},t[s]=Qf({timescale:n,id:r},o)):t[r]={timescale:n,type:e,stsd:o}}}}}return Np(e,["moov","mvex","trex"]).forEach(e=>{const r=_p(e,4),i=t[r];i&&(i.default={duration:_p(e,12),flags:_p(e,20)})}),t}function Bp(e){const t=e.subarray(8),r=t.subarray(86),i=Dp(t.subarray(4,8));let n,s=i;const a="enca"===i||"encv"===i;if(a){const e=Np(t,[i])[0];Np(e.subarray("enca"===i?28:78),["sinf"]).forEach(e=>{const t=Np(e,["schm"])[0];if(t){const r=Dp(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=Np(e,["frma"])[0];t&&(s=Dp(t))}}})}const o=s;switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const e=Np(r,["avcC"])[0];e&&e.length>3&&(s+="."+Gp(e[1])+Gp(e[2])+Gp(e[3]),n=Up("avc1"===o?"dva1":"dvav",r));break}case"mp4a":{const e=Np(t,[i])[0],r=Np(e.subarray(28),["esds"])[0];if(r&&r.length>7){let e=4;if(3!==r[e++])break;e=zp(r,e),e+=2;const t=r[e++];if(128&t&&(e+=2),64&t&&(e+=r[e++]),4!==r[e++])break;e=zp(r,e);const i=r[e++];if(64!==i)break;if(s+="."+Gp(i),e+=12,5!==r[e++])break;e=zp(r,e);const n=r[e++];let a=(248&n)>>3;31===a&&(a+=1+((7&n)<<3)+((224&r[e])>>5)),s+="."+a}break}case"hvc1":case"hev1":{const e=Np(r,["hvcC"])[0];if(e&&e.length>12){const t=e[1],r=["","A","B","C"][t>>6],i=31&t,n=_p(e,2),a=(32&t)>>5?"H":"L",o=e[12],l=e.subarray(6,12);s+="."+r+i,s+="."+function(e){let t=0;for(let r=0;r<32;r++)t|=(e>>r&1)<<31-r;return t>>>0}(n).toString(16).toUpperCase(),s+="."+a+o;let d="";for(let e=l.length;e--;){const t=l[e];if(t||d){d="."+t.toString(16).toUpperCase()+d}}s+=d}n=Up("hev1"==o?"dvhe":"dvh1",r);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":s=Up(s,r)||s;break;case"vp09":{const e=Np(r,["vpcC"])[0];if(e&&e.length>6){const t=e[4],r=e[5],i=e[6]>>4&15;s+="."+jp(t)+"."+jp(r)+"."+jp(i)}break}case"av01":{const e=Np(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,d=2===t&&o?l?12:10:o?10:8,c=(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;s+="."+t+"."+jp(i)+a+"."+jp(d)+"."+c+"."+u+h+f+"."+jp(p)+"."+jp(m)+"."+jp(g)+"."+v,n=Up("dav1",r)}break}}return{codec:s,encrypted:a,supplemental:n}}function Up(e,t){const r=Np(t,["dvvC"]),i=r.length?r[0]:Np(t,["dvcC"])[0];if(i){const t=i[2]>>1&127,r=i[2]<<5&32|i[3]>>3&31;return e+"."+jp(t)+"."+jp(r)}}function zp(e,t){const r=t+5;for(;128&e[t++]&&t<r;);return t}function Gp(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function jp(e){return(e<10?"0":"")+e}function Hp(e,t){Np(e,["moov","trak"]).forEach(e=>{const r=Np(e,["mdia","minf","stbl","stsd"])[0];if(!r)return;const i=r.subarray(8);let n=Np(i,["enca"]);const s=n.length>0;s||(n=Np(i,["encv"])),n.forEach(e=>{Np(s?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{const r=Vp(e);r&&t(r,s)})})})}function Vp(e){const t=Np(e,["schm"])[0];if(t){const r=Dp(t.subarray(4,8));if("cbcs"===r||"cenc"===r){const t=Np(e,["schi","tenc"])[0];if(t)return t}}}function Wp(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function Yp(e,t){const r=[],i=t.samples,n=t.timescale,s=t.id;let a=!1;return Np(i,["moof"]).map(o=>{const l=o.byteOffset-8;Np(o,["traf"]).map(o=>{const d=Np(o,["tfdt"]).map(e=>{const t=e[0];let r=_p(e,4);return 1===t&&(r*=Math.pow(2,32),r+=_p(e,8)),r/n})[0];return void 0!==d&&(e=d),Np(o,["tfhd"]).map(d=>{const c=_p(d,4),u=16777215&_p(d,0);let h=0;const f=!!(16&u);let p=0;const m=!!(32&u);let g=8;c===s&&(!!(1&u)&&(g+=8),!!(2&u)&&(g+=4),!!(8&u)&&(h=_p(d,g),g+=4),f&&(p=_p(d,g),g+=4),m&&(g+=4),"video"===t.type&&(a=Kp(t.codec)),Np(o,["trun"]).map(s=>{const o=s[0],d=16777215&_p(s,0),c=!!(1&d);let u=0;const f=!!(4&d),m=!!(256&d);let g=0;const v=!!(512&d);let y=0;const b=!!(1024&d),E=!!(2048&d);let w=0;const S=_p(s,4);let T=8;c&&(u=_p(s,T),T+=4),f&&(T+=4);let x=u+l;for(let l=0;l<S;l++){if(m?(g=_p(s,T),T+=4):g=h,v?(y=_p(s,T),T+=4):y=p,b&&(T+=4),E&&(w=0===o?_p(s,T):Mp(s,T),T+=4),t.type===wp){let t=0;for(;t<y;){const s=_p(i,x);if(x+=4,qp(a,i[x])){Xp(i.subarray(x,x+s),a?2:1,e+w/n,r)}x+=s,t+=s+4}}e+=g/n}}))})})}),r}function Kp(e){if(!e)return!1;const t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function qp(e,t){if(e){const e=t>>1&63;return 39===e||40===e}return 6===(31&t)}function Xp(e,t,r,i){const n=Qp(e);let s=0;s+=t;let a=0,o=0,l=0;for(;s<n.length;){a=0;do{if(s>=n.length)break;l=n[s++],a+=l}while(255===l);o=0;do{if(s>=n.length)break;l=n[s++],o+=l}while(255===l);const e=n.length-s;let t=s;if(o<e)s+=o;else if(o>e){np.error(`Malformed SEI payload. ${o} is too small, only ${e} bytes left to parse.`);break}if(4===a){if(181===n[t++]){const e=Cp(n,t);if(t+=2,49===e){const e=_p(n,t);if(t+=4,1195456820===e){const e=n[t++];if(3===e){const s=n[t++],o=64&s,l=o?2+3*(31&s):0,d=new Uint8Array(l);if(o){d[0]=s;for(let e=1;e<l;e++)d[e]=n[t++]}i.push({type:e,payloadType:a,pts:r,bytes:d})}}}}}else if(5===a&&o>16){const e=[];for(let r=0;r<16;r++){const i=n[t++].toString(16);e.push(1==i.length?"0"+i:i),3!==r&&5!==r&&7!==r&&9!==r||e.push("-")}const s=o-16,l=new Uint8Array(s);for(let e=0;e<s;e++)l[e]=n[t++];i.push({payloadType:a,pts:r,uuid:e.join(""),userData:op(l),userDataBytes:l})}}}function Qp(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 n=t-r.length,s=new Uint8Array(n);let a=0;for(i=0;i<n;a++,i++)a===r[0]&&(a++,r.shift()),s[i]=e[a];return s}function Zp(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");let i,n,s;i=0,n=new Uint8Array,s=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,n=r;for(;n--;)i+=t[n].byteLength;const s=new Uint8Array(i);for(s[0]=i>>24&255,s[1]=i>>16&255,s[2]=i>>8&255,s[3]=255&i,s.set(e,4),n=0,i=8;n<r;n++)s.set(t[n],i),i+=t[n].byteLength;return s}([112,115,115,104],new Uint8Array([0,0,0,0]),e,s,n,a,r)}function Jp(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 n=e.getUint32(8)>>>24;if(0!==n&&1!==n)return{offset:r,size:t};const s=e.buffer,a=lp(new Uint8Array(s,r+12,16));let o=null,l=null,d=0;if(0===n)d=28;else{const n=e.getUint32(28);if(!n||i<32+16*n)return{offset:r,size:t};o=[];for(let e=0;e<n;e++)o.push(new Uint8Array(s,r+32+16*e,16));d=32+16*n}if(!d)return{offset:r,size:t};const c=e.getUint32(d);return t-32<c?{offset:r,size:t}:(l=new Uint8Array(s,r+d+4,c),{version:n,systemId:a,kids:o,data:l,offset:r,size:t})}const em=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),tm={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 rm(e,t){const r=tm[t];return!!r&&!!r[e.slice(0,4)]}function im(e,t,r=!0){return!e.split(",").some(e=>!nm(e,t,r))}function nm(e,t,r=!0){var i;const n=sp(r);return null!=(i=null==n?void 0:n.isTypeSupported(sm(e,t)))&&i}function sm(e,t){return`${t}/mp4;codecs=${e}`}function am(e){if(e){const t=e.substring(0,4);return tm.video[t]}return 2}function om(e){const t=em();return e.split(",").reduce((e,r)=>{const i=t&&Kp(r)?9:tm.video[r];return i?(2*i+e)/(e?3:2):(tm.audio[r]+e)/(e?2:1)},0)}const lm={};const dm=/flac|opus|mp4a\.40\.34/i;function cm(e,t=!0){return e.replace(dm,e=>function(e,t=!0){if(lm[e])return lm[e];const r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e];for(let n=0;n<r.length;n++){var i;if(nm(r[n],"audio",t))return lm[e]=r[n],r[n];if("mp3"===r[n]&&null!=(i=sp(t))&&i.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t))}function um(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(hm(e,"audio")||hm(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 hm(e,t){return rm(e,t)&&nm(e,t)}function fm(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 pm(e){const t=sp(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 mm(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const gm={supported:!1,smooth:!1,powerEfficient:!1},vm={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function ym(e,t){return{supported:!1,configurations:t,decodingInfoResults:[gm],error:e}}function bm(e,t,r,i,n,s){const a=e.videoCodec,o=e.audioCodec?e.audioGroups:null,l=null==s?void 0:s.audioCodec,d=null==s?void 0:s.channels,c=d?parseInt(d):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=>Kp(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(n,8e6))||!!u&&_f(c)&&Object.keys(u).some(e=>parseInt(e)>c)}function Em(e,t,r,i={}){const n=e.videoCodec;if(!n&&!e.audioCodec||!r)return Promise.resolve(vm);const s=[],a=function(e){var t;const r=null==(t=e.videoCodec)?void 0:t.split(","),i=Sm(e),n=e.width||640,s=e.height||480,a=e.frameRate||30,o=e.videoRange.toLowerCase();return r?r.map(e=>{const t={contentType:sm(fm(e),"video"),width:n,height:s,bitrate:i,framerate:a};return"sdr"!==o&&(t.transferFunction=o),t}):[]}(e),o=a.length,l=function(e,t,r){var i;const n=null==(i=e.audioCodec)?void 0:i.split(","),s=Sm(e);if(n&&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||"");n.forEach(t=>{const n={contentType:sm(t,"audio"),bitrate:r?wm(t,s):s};i&&(n.channels=""+i),e.push(n)})}return e},e):e},[]);return[]}(e,t,o>0),d=l.length;for(let e=o||1*d||1;e--;){const t={type:"media-source"};if(o&&(t.video=a[e%o]),d){t.audio=l[e%d];const r=t.audio.bitrate;t.video&&r&&(t.video.bitrate-=r)}s.push(t)}if(n){const e=navigator.userAgent;if(n.split(",").some(e=>Kp(e))&&em())return Promise.resolve(ym(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${e})`),s))}return Promise.all(s.map(e=>{const t=function(e){let t="";const{audio:r,video:i}=e;if(i){t+=`${mm(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?"_":""}${mm(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:s,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:s,decodingInfoResults:[],error:e}))}function wm(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 Sm(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}const Tm=["NONE","TYPE-0","TYPE-1",null];const xm=["SDR","PQ","HLG"];var Am="",km="YES",Lm="v2";function Im(e){const{canSkipUntil:t,canSkipDateRanges:r,age:i}=e;return t&&i<t/2?r?Lm:km:Am}class Rm{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 Pm{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 Dm(this._audioGroups,e)}hasSubtitleGroup(e){return Dm(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 Dm(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function Cm(e,t){let r=!1,i=[];if(e&&(r="SDR"!==e,i=[e]),t){i=t.allowedVideoRanges||xm.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 _m=(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 Om(e,t){np.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function Mm(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 Nm(e){if(!e)return e;const{lang:t,assocLang:r,characteristics:i,channels:n,audioCodec:s}=e;return{lang:t,assocLang:r,characteristics:i,channels:n,audioCodec:s}}function Fm(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($m(e,t[i],r))return i}return-1}function $m(e,t,r){const{groupId:i,name:n,lang:s,assocLang:a,default:o}=e,l=e.forced;return(void 0===i||t.groupId===i)&&(void 0===n||t.name===n)&&(void 0===s||function(e,t="--"){if(e.length===t.length)return e===t;return e.startsWith(t)||t.startsWith(e)}(s,t.lang))&&(void 0===s||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 Bm(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 Um(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 zm(e,t){var r;return!!e&&e!==(null==(r=t.loadLevelObj)?void 0:r.uri)}const Gm=function(e,t){let r=0,i=e.length-1,n=null,s=null;for(;r<=i;){n=(r+i)/2|0,s=e[n];const a=t(s);if(a>0)r=n+1;else{if(!(a<0))return s;i=n-1}}return null};function jm(e,t,r=0,i=0,n=.005){let s=null;if(e){s=t[1+e.sn-t[0].sn]||null;const i=e.endDTS-r;i>0&&i<15e-7&&(r+=15e-7),s&&e.level!==s.level&&s.end<=e.end&&(s=t[2+e.sn-t[0].sn]||null)}else 0===r&&0===t[0].start&&(s=t[0]);if(s&&((!e||e.level===s.level)&&0===Hm(r,i,s)||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}(s,e,Math.min(n,i))))return s;const a=Gm(t,Hm.bind(null,r,i));return!a||a===e&&s?s:a}function Hm(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 Vm(e,t,r){const i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function Wm(e,t,r){if(e&&e.startCC<=t&&e.endCC>=t){let i=e.fragments;const{fragmentHint:n}=e;let s;return n&&(i=i.concat(n)),Gm(i,e=>e.cc<t?1:e.cc>t?-1:(s=e,e.end<=r?1:e.start>r?-1:0)),s||null}return null}function Ym(e){switch(e.details){case Ff.FRAG_LOAD_TIMEOUT:case Ff.KEY_LOAD_TIMEOUT:case Ff.LEVEL_LOAD_TIMEOUT:case Ff.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Km(e){return e.details.startsWith("key")}function qm(e){return Km(e)&&!!e.frag&&!e.frag.decryptdata}function Xm(e,t){const r=Ym(t);return e.default[(r?"timeout":"error")+"Retry"]}function Qm(e,t){const r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function Zm(e){return Qf(Qf({},e),{errorRetry:null,timeoutRetry:null})}function Jm(e,t,r,i){if(!e)return!1;const n=null==i?void 0:i.code,s=t<e.maxNumRetry&&(function(e){return eg(e)||!!e&&(e<400||e>499)}(n)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,s):s}function eg(e){return 0===e&&!1===navigator.onLine}var tg=0,rg=2,ig=3,ng=5,sg=0,ag=1,og=2,lg=4;function dg(e){const t={action:tg,flags:sg};return e&&(t.resolved=!0),t}var cg="NOT_LOADED",ug="APPENDING",hg="PARTIAL",fg="OK";class pg{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($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.BUFFER_APPENDED,this.onBufferAppended,this),e.on($f.FRAG_BUFFERED,this.onFragBuffered,this),e.on($f.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.BUFFER_APPENDED,this.onBufferAppended,this),e.off($f.FRAG_BUFFERED,this.onFragBuffered,this),e.off($f.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,n=Object.keys(i);for(let s=n.length;s--;){const a=i[n[s]];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,n){this.timeRanges&&(this.timeRanges[e]=t);const s=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach(i=>{const a=this.fragments[i];if(!a)return;if(s>=a.body.sn)return;if(!a.buffered&&(!a.loaded||n))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=gg(r),n=this.fragments[i];if(!n||n.buffered&&r.gap)return;const s=!r.relurl;Object.keys(t).forEach(i=>{const a=r.elementaryStreams[i];if(!a)return;const o=t[i],l=s||!0===a.partial;n.range[i]=this.getBufferedTimes(r,e.part,l,o)}),n.loaded=null,Object.keys(n.range).length?(this.bufferedEnd(n,r),mg(n)||this.removeParts(r.sn-1,r.type)):this.removeFragment(n.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]=vg(r,t=>t.fragment.sn>=e))}fragBuffered(e,t){const r=gg(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 n={time:[],partial:r},s=e.start,a=e.end,o=e.minEndPTS||a,l=e.maxStartPTS||s;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){n.time.push({startPTS:Math.max(s,i.start(e)),endPTS:Math.min(a,i.end(e))});break}if(s<r&&a>t){const t=Math.max(s,i.start(e)),r=Math.min(a,i.end(e));r>t&&(n.partial=!0,n.time.push({startPTS:t,endPTS:r}))}else if(a<=t)break}return n}getPartialFragment(e){let t,r,i,n=null,s=0;const{bufferPadding:a,fragments:o}=this;return Object.keys(o).forEach(l=>{const d=o[l];d&&mg(d)&&(r=d.body.start-a,i=d.body.end+a,e>=r&&e<=i&&(t=Math.min(e-r,i-e),s<=t&&(n=d.body,s=t)))}),n}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||mg(t))}getState(e){const t=gg(e),r=this.fragments[t];return r?r.buffered?mg(r)?hg:fg:ug:cg}isTimeBuffered(e,t,r){let i,n;for(let s=0;s<r.length;s++){if(i=r.start(s)-this.bufferPadding,n=r.end(s)+this.bufferPadding,e>=i&&t<=n)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,n=gg(r);this.fragments[n]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:r,part:i,timeRanges:n,type:s}=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=n;const o=n[s];this.detectEvictedFragments(s,o,a,i)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=gg(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 n=t[r[i]];if((null==n?void 0:n.body.type)===e)return!0}return!1}hasParts(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}removeFragmentsInRange(e,t,r,i,n){i&&!this.hasGaps||Object.keys(this.fragments).forEach(s=>{const a=this.fragments[s];if(!a)return;const o=a.body;o.type!==r||i&&!o.gap||o.start<t&&o.end>e&&(a.buffered||n)&&this.removeFragment(o)})}removeFragment(e){const t=gg(e);e.clearElementaryStreamInfo();const r=this.activePartLists[e.type];if(r){const t=e.sn;this.activePartLists[e.type]=vg(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 mg(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 gg(e){return`${e.type}_${e.level}_${e.sn}`}function vg(e,t){return e.filter(e=>{const r=t(e);return r||e.clearElementaryStreamInfo(),r})}var yg=0,bg=1;class Eg{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 yg:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case bg: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 wg{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],n=r[1],s=r[2],a=r[3],o=this.invSubMix,l=o[0],d=o[1],c=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,n[f]=v<<16|v>>>16,s[f]=v<<8|v>>>24,a[f]=v,v=16843009*g^65537*m^257*o^16843008*f,l[r]=v<<24|v>>>8,d[r]=v<<16|v>>>16,c[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 n=this.keySize=t.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);const s=this.ksRows=4*(n+6+1);let a,o;const l=this.keySchedule=new Uint32Array(s),d=this.invKeySchedule=new Uint32Array(s),c=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<s;a++)a<n?v=l[a]=t[a]:(y=v,a%n===0?(y=y<<8|y>>>24,y=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[255&y],y^=u[a/n|0]<<24):n>6&&a%n===4&&(y=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[255&y]),l[a]=v=(l[a-n]^y)>>>0);for(o=0;o<s;o++)a=s-o,y=3&o?l[a]:l[a-4],d[o]=o<4||a<=4?y:f[c[y>>>24]]^p[c[y>>>16&255]]^m[c[y>>>8&255]]^g[c[255&y]],d[o]=d[o]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,r){const i=this.keySize+6,n=this.invKeySchedule,s=this.invSBox,a=this.invSubMix,o=a[0],l=a[1],d=a[2],c=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,D;const C=this.networkToHostOrderSwap;for(;t<g.length;){for(k=C(g[t]),L=C(g[t+1]),I=C(g[t+2]),R=C(g[t+3]),S=k^n[0],T=R^n[1],x=I^n[2],A=L^n[3],P=4,D=1;D<i;D++)y=o[S>>>24]^l[T>>16&255]^d[x>>8&255]^c[255&A]^n[P],b=o[T>>>24]^l[x>>16&255]^d[A>>8&255]^c[255&S]^n[P+1],E=o[x>>>24]^l[A>>16&255]^d[S>>8&255]^c[255&T]^n[P+2],w=o[A>>>24]^l[S>>16&255]^d[T>>8&255]^c[255&x]^n[P+3],S=y,T=b,x=E,A=w,P+=4;y=s[S>>>24]<<24^s[T>>16&255]<<16^s[x>>8&255]<<8^s[255&A]^n[P],b=s[T>>>24]<<24^s[x>>16&255]<<16^s[A>>8&255]<<8^s[255&S]^n[P+1],E=s[x>>>24]<<24^s[A>>16&255]<<16^s[S>>8&255]<<8^s[255&T]^n[P+2],w=s[A>>>24]<<24^s[S>>16&255]<<16^s[T>>8&255]<<8^s[255&x]^n[P+3],v[t]=C(y^h),v[t+1]=C(w^f),v[t+2]=C(E^p),v[t+3]=C(b^m),h=k,f=L,p=I,m=R,t+=4}return v.buffer}}class Sg{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 yg:return"AES-CBC";case bg: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 Tg{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((n,s)=>{const a=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(a,t,r,i);const o=this.flush();o?n(o.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r,i)}softwareDecrypt(e,t,r,i){const{currentIV:n,currentResult:s,remainderData:a}=this;if(i!==yg||16!==t.byteLength)return np.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),a&&(e=Wp(a,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;n&&(r=n);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new wg),l.expandKey(t);const d=s;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=o.slice(-16).buffer,d||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 Sg(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 Eg(this.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)}).catch(n=>(np.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,r,i)))}onWebCryptoError(e,t,r,i){const n=this.enableSoftwareAES;if(n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,i);const n=this.flush();if(n)return n.buffer}throw new Error("WebCrypto"+(n?" 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&&(np.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const xg=Math.pow(2,17);class Ag{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 Ig({type:Nf.NETWORK_ERROR,details:Ff.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,n=i.fLoader,s=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(Lg(e));e.gap=!1}const l=this.loader=n?new n(i):new s(i),d=kg(e);e.loader=l;const c=Zm(i.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:xg};e.stats=l.stats;const h={onSuccess:(t,r,i,n)=>{this.resetLoader(e,l);let s=t.data;i.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),a({frag:e,part:null,payload:s,networkDetails:n})},onError:(t,i,n,s)=>{this.resetLoader(e,l),o(new Ig({type:Nf.NETWORK_ERROR,details:Ff.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Qf({url:r,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:n,stats:s}))},onAbort:(t,r,i)=>{this.resetLoader(e,l),o(new Ig({type:Nf.NETWORK_ERROR,details:Ff.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:(t,r,i)=>{this.resetLoader(e,l),o(new Ig({type:Nf.NETWORK_ERROR,details:Ff.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:i,stats:t}))}};t&&(h.onProgress=(r,i,n,s)=>t({frag:e,part:null,payload:n,networkDetails:s})),l.load(d,u,h)})}loadPart(e,t,r){this.abort();const i=this.config,n=i.fLoader,s=i.loader;return new Promise((a,o)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void o(Lg(e,t));const l=this.loader=n?new n(i):new s(i),d=kg(e,t);e.loader=l;const c=Zm(i.fragLoadPolicy.default),u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:xg};t.stats=l.stats,l.load(d,u,{onSuccess:(i,n,s,o)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const d={frag:e,part:t,payload:i.data,networkDetails:o};r(d),a(d)},onError:(r,i,n,s)=>{this.resetLoader(e,l),o(new Ig({type:Nf.NETWORK_ERROR,details:Ff.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Qf({url:d.url,data:void 0},r),error:new Error(`HTTP Error ${r.code} ${r.text}`),networkDetails:n,stats:s}))},onAbort:(r,i,n)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),o(new Ig({type:Nf.NETWORK_ERROR,details:Ff.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:n,stats:r}))},onTimeout:(r,i,n)=>{this.resetLoader(e,l),o(new Ig({type:Nf.NETWORK_ERROR,details:Ff.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:n,stats:r}))}})})}updateStatsFromPart(e,t){const r=e.stats,i=t.stats,n=i.total;if(r.loaded+=i.loaded,n){const i=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/n),i),a=(i-s)*Math.round(r.loaded/s);r.total=r.loaded+a}else r.total=Math.max(r.loaded,r.total);const s=r.loading,a=i.loading;s.start?s.first+=a.first-a.start:(s.start=a.start,s.first=a.first),s.end=a.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function kg(e,t=null){const r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},n=r.byteRangeStartOffset,s=r.byteRangeEndOffset;if(_f(n)&&_f(s)){var a;let t=n,r=s;if("initSegment"===e.sn&&("AES-128"===(o=null==(a=e.decryptdata)?void 0:a.method)||"AES-256"===o)){const e=s-n;e%16&&(r=s+(16-e%16)),0!==n&&(i.resetIV=!0,t=n-16)}i.rangeStart=t,i.rangeEnd=r}var o;return i}function Lg(e,t){const r=new Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:Nf.MEDIA_ERROR,details:Ff.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new Ig(i)}class Ig extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Rg extends Zf{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 Pg{constructor(e,t,r,i=0,n=-1,s=!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=n,this.partial=s}}const Dg={length:0,start:()=>0,end:()=>0};class Cg{static isBuffered(e,t){if(e){const r=Cg.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=Cg.getBuffered(e);return Cg.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=Cg.bufferedRanges(e);if(i.length)return Cg.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,n=[];if(r)for(let s=0;s<e.length;s++){t>=e[s].start&&t<=e[s].end&&(i=s);const a=n.length;if(a){const t=n[a-1].end;e[s].start-t<r?e[s].end>t&&(n[a-1].end=e[s].end):n.push(e[s])}else n.push(e[s])}else n=e;let s,a=0,o=t,l=t;for(let e=0;e<n.length;e++){const d=n[e].start,c=n[e].end;if(-1===i&&t>=d&&t<=c&&(i=e),t+r>=d&&t<c)o=d,l=c,a=l-t;else if(t+r<d){s=d;break}}return{len:a,start:o||0,end:l||0,nextStart:s,buffered:e,bufferedIndex:i}}static getBuffered(e){try{return e.buffered||Dg}catch(e){return np.log("failed to get media.buffered",e),Dg}}}const _g=/\{\$([a-zA-Z0-9-_]+)\}/g;function Og(e){return _g.test(e)}function Mg(e,t){if(null!==e.variableList||e.hasVariableRefs){const r=e.variableList;return t.replace(_g,t=>{const i=t.substring(2,t.length-1),n=null==r?void 0:r[i];return void 0===n?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"`)),t):n})}return t}function Ng(e,t,r){let i,n,s=e.variableList;if(s||(e.variableList=s={}),"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}"`);n=e.get(i)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else i=t.NAME,n=t.VALUE;i in s?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):s[i]=n||""}function Fg(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 $g=/^(\d+)x(\d+)$/,Bg=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Ug{constructor(e,t){"string"==typeof e&&(e=Ug.parseAttrList(e,t)),qf(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=$g.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(Bg.lastIndex=0;null!==(r=Bg.exec(e));){const n=r[1].trim();let s=r[2];const a=0===s.indexOf('"')&&s.lastIndexOf('"')===s.length-1;let o=!1;if(a)s=s.slice(1,-1);else switch(n){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":o=!0}if(t&&(a||o))s=Mg(t,s);else if(!o&&!a)switch(n){case"CLOSED-CAPTIONS":if("NONE"===s)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":np.warn(`${e}: attribute ${n} is missing quotes`)}i[n]=s}return i}}function zg(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function Gg(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}class jg{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]){np.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=qf(new Ug({}),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"]);_f(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?(np.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(_f(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return"com.apple.hls.interstitial"===this.class}get isValid(){return!!this.id&&!this._badValueForSameId&&_f(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 Hg{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&&_f(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 Vg(e,t){return e.length===t.length&&!e.some((e,r)=>e!==t[r])}function Wg(e,t){return!e&&!t||!(!e||!t)&&Vg(e,t)}function Yg(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function Kg(e){switch(e){case"AES-128":case"AES-256":return yg;case"AES-256-CTR":return bg;default:throw new Error(`invalid full segment method ${e}`)}}function qg(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function Xg(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function Qg(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 Zg(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],n=i[1];t?(e.splice(-1,1),r=qg(n)):r=function(e){const t=Xg(e).subarray(0,16),r=new Uint8Array(16);return r.set(t,16-t.length),r}(n)}}return r}const Jg="undefined"!=typeof self?self:void 0;var ev={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},tv="org.w3.clearkey",rv="com.apple.streamingkeydelivery",iv="com.microsoft.playready",nv="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function sv(e){switch(e){case rv:return ev.FAIRPLAY;case iv:return ev.PLAYREADY;case nv:return ev.WIDEVINE;case tv:return ev.CLEARKEY}}function av(e){switch(e){case ev.FAIRPLAY:return rv;case ev.PLAYREADY:return iv;case ev.WIDEVINE:return nv;case ev.CLEARKEY:return tv}}function ov(e){const{drmSystems:t,widevineLicenseUrl:r}=e,i=t?[ev.FAIRPLAY,ev.WIDEVINE,ev.PLAYREADY,ev.CLEARKEY].filter(e=>!!t[e]):[];return!i[ev.WIDEVINE]&&r&&i.push(ev.WIDEVINE),i}const lv=null!=Jg&&null!=(dv=Jg.navigator)&&dv.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var dv;function cv(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),n=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(n){const e=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE");if(e){const t=qg(e).subarray(0,16);return Qg(t),t}}return null}let uv={};class hv{static clearKeyUriToKeyIdMap(){uv={}}static setKeyIdForUri(e,t){uv[e]=t}static addKeyIdForUri(e){const t=Object.keys(uv).length%Number.MAX_SAFE_INTEGER,r=new Uint8Array(16);return new DataView(r.buffer,12,4).setUint32(0,t),uv[e]=r,r}constructor(e,t,r,i=[1],n=null,s){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=n,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&!Yg(e),null!=s&&s.startsWith("0x")&&(this.keyId=new Uint8Array(dp(s)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&Vg(e.keyFormatVersions,this.keyFormatVersions)&&Wg(e.iv,this.iv)&&Wg(e.keyId,this.keyId)}isSupported(){if(this.method){if(Yg(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case rv:case nv:case iv:case tv: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(Yg(this.method)){let t=this.iv;t||("number"!=typeof e&&(np.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 hv(this.method,this.uri,"identity",this.keyFormatVersions,t)}if(this.keyId){const e=uv[this.uri];if(e&&!Vg(this.keyId,e)&&hv.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const r=Zg(this.uri);if(r)switch(this.keyFormat){case nv: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=Jp(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=fv(t));break;case iv:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Zp(e,0,r),this.keyId=cv(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[nv];if(t)return t.keyId;return null}(t),e||(e=fv(t),e||(e=uv[this.uri])),e&&(this.keyId=e,hv.setKeyIdForUri(this.uri,e))}return this}}function fv(e){const t=null==e?void 0:e[iv];if(t){const e=Zg(t.uri);if(e)return cv(e)}return null}const pv=/#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,mv=/#EXT-X-MEDIA:(.*)/g,gv=/^#EXT(?:INF|-X-TARGETDURATION):/m,vv=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),yv=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 bv{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 yp.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return gv.test(e)}static parseMasterPlaylist(e,t){const r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Og(e)},i=[];if(pv.lastIndex=0,!e.startsWith("#EXTM3U"))return r.playlistParsingError=new Error("no EXTM3U delimiter"),r;let n;for(;null!=(n=pv.exec(e));)if(n[1]){var s;const e=new Ug(n[1],r),a=Mg(r,n[2]),o={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:bv.resolve(a,t)},l=e.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),xv(e.CODECS,o);const d=e["SUPPLEMENTAL-CODECS"];d&&(o.supplemental={},xv(d,o.supplemental)),null!=(s=o.unknownCodecs)&&s.length||i.push(o),r.levels.push(o)}else if(n[3]){const e=n[3],i=n[4];switch(e){case"SESSION-DATA":{const e=new Ug(i,r),t=e["DATA-ID"];t&&(null===r.sessionData&&(r.sessionData={}),r.sessionData[t]=e);break}case"SESSION-KEY":{const e=Sv(i,t,r);e.encrypted&&e.isSupported()?(null===r.sessionKeys&&(r.sessionKeys=[]),r.sessionKeys.push(e)):np.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":Ng(r,new Ug(i,r),t);break;case"CONTENT-STEERING":{const e=new Ug(i,r);r.contentSteering={uri:bv.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":r.startTimeOffset=Tv(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 n={},s=r.levels,a={AUDIO:s.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:s.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]};let o=0;for(mv.lastIndex=0;null!==(i=mv.exec(e));){const e=new Ug(i[1],r),s=e.TYPE;if(s){const r=a[s],i=n[s]||[];n[s]=i;const l=e.LANGUAGE,d=e["ASSOC-LANGUAGE"],c=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:s,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:l,url:e.URI?bv.resolve(e.URI,t):""};if(d&&(f.assocLang=d),c&&(f.channels=c),u&&(f.characteristics=u),h&&(f.instreamId=h),null!=r&&r.length){const e=bv.findGroup(r,f.groupId)||r[0];Av(f,e,"audioCodec"),Av(f,e,"textCodec")}i.push(f)}}return n}static parseLevelPlaylist(e,t,r,i,n,s){var a;const o={url:t},l=new Hg(t),d=l.fragments,c=[];let u,h,f,p,m=null,g=0,v=0,y=0,b=0,E=0,w=null,S=new Ap(i,o),T=-1,x=!1,A=null;if(vv.lastIndex=0,l.m3u8=e,l.hasVariableRefs=Og(e),"#EXTM3U"!==(null==(a=vv.exec(e))?void 0:a[0]))return l.playlistParsingError=new Error("Missing format identifier #EXTM3U"),l;for(;null!==(u=vv.exec(e));){x&&(x=!1,S=new Ap(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(_f(S.duration)){S.playlistOffset=y,S.setStart(y),f&&Iv(S,f,l),S.sn=g,S.level=r,S.cc=b,d.push(S);const e=(" "+u[3]).slice(1);S.relurl=Mg(l,e),kv(S,w,c),w=S,y+=S.duration,g++,v=0,x=!0}}else{if(u=u[0].match(yv),!u){np.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),n=(" "+u[h+1]).slice(1),a=u[h+2]?(" "+u[h+2]).slice(1):null;switch(e){case"BYTERANGE":w?S.setByteRange(n,w):S.setByteRange(n);break;case"PROGRAM-DATE-TIME":S.rawProgramDateTime=n,S.tagList.push(["PROGRAM-DATE-TIME",n]),-1===T&&(T=d.length);break;case"PLAYLIST-TYPE":l.type&&Rv(l,e,u),l.type=n.toUpperCase();break;case"MEDIA-SEQUENCE":0!==l.startSN?Rv(l,e,u):d.length>0&&Pv(l,e,u),g=l.startSN=parseInt(n);break;case"SKIP":{l.skippedSegments&&Rv(l,e,u);const t=new Ug(n,l),r=t.decimalInteger("SKIPPED-SEGMENTS");if(_f(r)){l.skippedSegments+=r;for(let e=r;e--;)d.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&&Rv(l,e,u),l.targetduration=Math.max(parseInt(n),1);break;case"VERSION":null!==l.version&&Rv(l,e,u),l.version=parseInt(n);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":l.live||Rv(l,e,u),l.live=!1;break;case"#":(n||a)&&S.tagList.push(a?[n,a]:[n]);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,n]),E=1e3*parseInt(n),_f(E)?S.bitrate=E:E=0;break;case"DATERANGE":{const e=new Ug(n,l),t=new jg(e,l.dateRanges[e.ID],l.dateRangeTagCount);l.dateRangeTagCount++,t.isValid||l.skippedSegments?l.dateRanges[t.id]=t:np.warn(`Ignoring invalid DATERANGE tag: "${n}"`),S.tagList.push(["EXT-X-DATERANGE",n]);break}case"DEFINE":{const e=new Ug(n,l);"IMPORT"in e?Fg(l,e,s):Ng(l,e,t)}break;case"DISCONTINUITY-SEQUENCE":0!==l.startCC?Rv(l,e,u):d.length>0&&Pv(l,e,u),l.startCC=b=parseInt(n);break;case"KEY":{const e=Sv(n,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=qf({},f)),f[e.keyFormat]=e)}else np.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${n}"`);break}case"START":l.startTimeOffset=Tv(n);break;case"MAP":{const e=new Ug(n,l);if(S.duration){const t=new Ap(i,o);Lv(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;Lv(S,e,r,f),m=S,x=!0}m.cc=b;break}case"SERVER-CONTROL":p&&Rv(l,e,u),p=new Ug(n),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&&Rv(l,e,u);const t=new Ug(n);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 Ug(n,l),s=new kp(i,S,o,r,t);e.push(s),S.duration+=s.duration;break}case"PRELOAD-HINT":{const e=new Ug(n,l);l.preloadHint=e;break}case"RENDITION-REPORT":{const e=new Ug(n,l);l.renditionReports=l.renditionReports||[],l.renditionReports.push(e);break}default:np.warn(`line parsed but not handled: ${u}`)}}}w&&!w.relurl?(d.pop(),y-=w.duration,l.partList&&(l.fragmentHint=w)):l.partList&&(kv(S,w,c),S.cc=b,l.fragmentHint=S,f&&Iv(S,f,l)),l.targetduration||(l.playlistParsingError=new Error("Missing Target Duration"));const k=d.length,L=d[0],I=d[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}}(d,T),L&&c.unshift(L))}return l.fragmentHint&&(y+=l.fragmentHint.duration),l.totalduration=y,c.length&&l.dateRangeTagCount&&L&&Ev(c,l),l.endCC=b,l}}function Ev(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],n=t.live?1/0:t.totalduration,s=Object.keys(t.dateRanges);for(let o=s.length;o--;){const l=t.dateRanges[s[o]],d=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=wv(t,d,e,i,n);if(-1!==r){l.tagAnchor=t.fragments[r].ref;break}}}}function wv(e,t,r,i,n){const s=r[i];if(s){const o=s.programDateTime;if(t>=o||0===i){var a;if(t<=o+1e3*(((null==(a=r[i+1])?void 0:a.start)||n)-s.start)){const n=r[i].sn-e.startSN;if(n<0)return-1;const s=e.fragments;if(s.length>r.length){for(let a=(r[i+1]||s[s.length-1]).sn-e.startSN;a>n;a--){const e=s[a].programDateTime;if(t>=e&&t<e+1e3*s[a].duration)return a}}return n}}}return-1}function Sv(e,t,r){var i,n;const s=new Ug(e,r),a=null!=(i=s.METHOD)?i:"",o=s.URI,l=s.hexadecimalInteger("IV"),d=s.KEYFORMATVERSIONS,c=null!=(n=s.KEYFORMAT)?n:"identity";o&&s.IV&&!l&&np.error(`Invalid IV: ${s.IV}`);const u=o?bv.resolve(o,t):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new hv(a,u,c,h,l,s.KEYID)}function Tv(e){const t=new Ug(e).decimalFloatingPoint("TIME-OFFSET");return _f(t)?t:null}function xv(e,t){let r=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{const i=r.filter(t=>rm(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 Av(e,t,r){const i=t[r];i&&(e[r]=i)}function kv(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function Lv(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 Iv(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 Rv(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${r[0]})`)}function Pv(e,t,r){e.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${r[0]})`)}function Dv(e,t){const r=t.startPTS;if(_f(r)){let i,n=0;t.sn>e.sn?(n=r-e.start,i=e):(n=e.start-r,i=t),i.duration!==n&&i.setDuration(n)}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 Cv(e,t,r,i,n,s,a){i-r<=0&&(a.warn("Fragment should have a positive duration",t),i=r+t.duration,s=n+t.duration);let o=r,l=i;const d=t.startPTS,c=t.endPTS;if(_f(d)){const u=Math.abs(d-r);e&&u>e.totalduration?a.warn(`media timestamps and playlist times differ by ${u}s for level ${t.level} ${e.url}`):_f(t.deltaPTS)?t.deltaPTS=Math.max(u,t.deltaPTS):t.deltaPTS=u,o=Math.max(r,d),r=Math.min(r,d),n=void 0!==t.startDTS?Math.min(n,t.startDTS):n,l=Math.min(i,c),i=Math.max(i,c),s=void 0!==t.endDTS?Math.max(s,t.endDTS):s}const u=r-t.start;0!==t.start&&t.setStart(r),t.setDuration(i-t.start),t.startPTS=r,t.maxStartPTS=o,t.startDTS=n,t.endPTS=i,t.minEndPTS=l,t.endDTS=s;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--)Dv(m[f],m[f-1]);for(f=p;f<m.length-1;f++)Dv(m[f],m[f+1]);return e.fragmentHint&&Dv(m[m.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,u}function _v(e,t,r){if(e===t)return;let i=null;const n=e.fragments;for(let e=n.length-1;e>=0;e--){const t=n[e].initSegment;if(t){i=t;break}}let s;e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,r){const i=t.skippedSegments,n=Math.max(e.startSN,t.startSN)-t.startSN,s=(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 d=n;d<=s;d++){const n=l[a+d];let s=o[d];if(i&&!s&&n&&(s=t.fragments[d]=n),n&&s){r(n,s,d,o);const i=n.relurl,a=s.relurl;if(i&&Gv(i,a))return void(t.playlistParsingError=Ov(`media sequence mismatch ${s.sn}:`,e,t,n,s));if(n.cc!==s.cc)return void(t.playlistParsingError=Ov(`discontinuity sequence mismatch (${n.cc}!=${s.cc})`,e,t,n,s))}}}(e,t,(e,r,n,a)=>{if((!t.startCC||t.skippedSegments)&&r.cc!==e.cc){const i=e.cc-r.cc;for(let e=n;e<a.length;e++)a[e].cc+=i;t.endCC=a[a.length-1].cc}_f(e.startPTS)&&_f(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&&(s=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:n}=t,s=qf({},e);n&&n.forEach(e=>{delete s[e]});const a=Object.keys(s).length;if(!a)return i;return Object.keys(i).forEach(e=>{const t=s[e],n=new jg(i[e].attr,t);n.isValid?(s[e]=n,t||(n.tagOrder+=a)):r.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${_m(i[e].attr)}"`)}),s}(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&&kv(o[e],o[e-1],i);Ev(i,t)}t.endCC=a[a.length-1].cc}if(!t.startCC){var l;const r=$v(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 n=0,s=e.length;n<=s;n++){const s=e[n],a=t[n+i];s&&a&&s.index===a.index&&s.fragment.sn===a.fragment.sn?r(s,a):i--}}}(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),s?Cv(t,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS,r):Mv(e,t),a.length&&(t.totalduration=t.edge-a[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;const d=t.advancedDateTime;if(t.advanced&&d){const e=t.edge;t.driftStart||(t.driftStartTime=d,t.driftStart=e),t.driftEndTime=d,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}function Ov(e,t,r,i,n){return new Error(`${e} ${n.url}\nPlaylist starting @${t.startSN}\n${t.m3u8}\n\nPlaylist starting @${r.startSN}\n${r.m3u8}`)}function Mv(e,t,r=!0){const i=t.startSN+t.skippedSegments-e.startSN,n=e.fragments,s=i>=0;let a=0;if(s&&i<n.length)a=n[i].start;else if(s&&t.startSN===e.endSN+1)a=e.fragmentEnd;else if(s&&r)a=e.fragmentStart+i*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;a=e.fragmentStart}Nv(t,a)}function Nv(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 Fv(e,t=1/0){let r=1e3*e.targetduration;if(e.updated){const i=e.fragments,n=4;if(i.length&&r*n>t){const e=1e3*i[i.length-1].duration;e<r&&(r=e)}}else r/=2;return Math.round(r)}function $v(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 Bv(e,t,r){return e?Uv(e.partList,t,r):null}function Uv(e,t,r){if(e)for(let i=e.length;i--;){const n=e[i];if(n.index===r&&n.fragment.sn===t)return n}return null}function zv(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 Gv(e,t){return!(e===t||!t)&&jv(e)!==jv(t)}function jv(e){return e.replace(/\?[^?]*$/,"")}function Hv(e,t){for(let i=0,n=e.length;i<n;i++){var r;if((null==(r=e[i])?void 0:r.cc)===t)return e[i]}return null}function Vv(e,t){const r=e.start+t;e.startPTS=r,e.setStart(r),e.endPTS=r+e.duration}function Wv(e,t){const r=t.fragments;for(let t=0,i=r.length;t<i;t++)Vv(r[t],e);t.fragmentHint&&Vv(t.fragmentHint,e),t.alignedSliding=!0}function Yv(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=Hv(t.fragments,r),n=Hv(e.fragments,r);if(!i||!n)return;np.log(`Aligning playlist at start of dicontinuity sequence ${r}`);Wv(i.start-n.start,e)}function Kv(e,t){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;const r=e.fragments,i=t.fragments;if(!r.length||!i.length)return;let n,s;const a=Math.min(t.endCC,e.endCC);t.startCC<a&&e.startCC<a&&(n=Hv(i,a),s=Hv(r,a)),n&&s||(n=i[Math.floor(i.length/2)],s=Hv(r,n.cc)||r[Math.floor(r.length/2)]);const o=n.programDateTime,l=s.programDateTime;if(!o||!l)return;Wv((l-o)/1e3-(s.start-n.start),e)}function qv(e,t,r){Xv(e,t,r),e.addEventListener(t,r)}function Xv(e,t,r){e.removeEventListener(t,r)}const Qv=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},Zv="STOPPED",Jv="IDLE",ey="KEY_LOADING",ty="FRAG_LOADING",ry="FRAG_LOADING_WAITING_RETRY",iy="WAITING_TRACK",ny="PARSING",sy="PARSED",ay="ENDED",oy="ERROR",ly="WAITING_INIT_PTS",dy="WAITING_LEVEL";class cy extends Rg{constructor(e,t,r,i,n){super(i,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Zv,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:n}=this,s=r?r.currentTime:0,a=Cg.bufferInfo(i||r,s,e.maxBufferHole),o=!a.len;if(this.log(`Media seeking to ${_f(s)?s.toFixed(3):s}, state: ${n}, ${o?"out of":"in"} buffer`),this.state===ay)this.resetLoadingState();else if(t){const r=e.maxFragLookUpTolerance,i=t.start-r,n=t.start+t.duration+r;if(o||n<a.start||i>a.end){const e=s>n;(s<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(s,1/0,this.playlistType,!0);if(s>this.lastCurrentTime&&(this.lastCurrentTime=s),!this.loadingParts){const e=Math.max(a.end,s),t=this.shouldLoadParts(this.getLevelDetails(),e);t&&(this.log(`LL-Part loading ON after seeking to ${s.toFixed(2)} with buffer @${e.toFixed(2)}`),this.loadingParts=t)}}this.hls.hasEnoughToStart||(this.log(`Setting ${o?"startPosition":"nextLoadPosition"} to ${s} for seek without enough to start`),this.nextLoadPosition=s,o&&(this.startPosition=s)),o&&this.state===Jv&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=n,this.hls=e,this.fragmentLoader=new Ag(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Tg(e.config)}registerListeners(){const{hls:e}=this;e.on($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.on($f.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.off($f.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===Zv)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=Zv}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 n=e.buffered;this.config.maxBufferHole&&n&&n.length>1&&(e=Cg.bufferedInfo(n,e.start,0));const s=e.nextStart;if(s&&s>i&&s<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 Cg.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;qv(r,"seeking",this.onMediaSeeking),qv(r,"ended",this.onMediaEnded);const i=this.config;this.levels&&i.autoStartLoad&&this.state===Zv&&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),Xv(i,"seeking",this.onMediaSeeking),Xv(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=Zv,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===ty||!this.fragCurrent&&t===ny)&&(this.fragmentTracker.removeFragment(r),this.state=Jv):("payload"in e&&(this.log(`Loaded ${r.type} sn: ${r.sn} of ${this.playlistLabel()} ${r.level}`),this.hls.trigger($f.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))}).catch(t=>{this.state!==Zv&&this.state!==oy&&(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)===ug){const t=e.type,i=this.getFwdBufferInfo(this.mediaBuffer,t),n=Math.max(e.duration,i?i.len:this.config.maxBufferLength),s=this.backtrackFragment;(1===(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(n,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)===hg&&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($f.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,n=r.decryptdata;if(i&&i.byteLength>0&&null!=n&&n.key&&n.iv&&Yg(n.method)){const s=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,Kg(n.method)).catch(e=>{throw t.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e}).then(i=>{const n=self.performance.now();return t.trigger($f.FRAG_DECRYPTED,{frag:r,payload:i,stats:{tstart:s,tdecrypt:n}}),e.payload=i,this.completeInitSegmentLoad(e)})}return this.completeInitSegmentLoad(e)}).catch(t=>{this.state!==Zv&&this.state!==oy&&(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!==Zv&&(this.state=Jv),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 n=e.tracks;if(n&&!t.encrypted&&(null!=(r=n.audio)&&r.encrypted||null!=(i=n.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($f.ERROR,{type:Nf.KEY_SYSTEM_ERROR,details:Ff.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?Qv(Cg.getBuffered(r)):"(detached)"})`),xp(e)){var i;if(e.type!==Vf){const t=e.elementaryStreams;if(!Object.keys(t).some(e=>!!t[e]))return void(this.state=Jv)}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=Jv}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:r,part:i,partsLoaded:n}=e,s=!n||0===n.length||n.some(e=>!e),a=new Pg(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!s);t.flush(a)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,i){var n;this.fragCurrent=e;const s=t.details;if(!this.levels||!s)throw new Error(`frag load aborted, missing level${s?"":" detail"}s`);let a=null;if(!e.encrypted||null!=(n=e.decryptdata)&&n.key)e.encrypted||(a=this.keyLoader.loadClear(e,s.encryptedFragments,this.startFragRequested),a&&this.log("[eme] blocking frag load until media-keys acquired"));else if(this.log(`Loading key for ${e.sn} of [${s.startSN}-${s.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=ey,this.fragCurrent=e,a=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger($f.KEY_LOADED,e),this.state===ey&&(this.state=Jv),e}),this.hls.trigger($f.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);const o=this.fragPrevious;if(xp(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&&xp(e)){const n=s.partList;if(n&&i){r>s.fragmentEnd&&s.fragmentHint&&(e=s.fragmentHint);const o=this.getNextPart(n,e,r);if(o>-1){const l=n[o];let d;return e=this.fragCurrent=l.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${l.index} (${o}/${n.length-1}) of ${this.fragInfo(e,!1,l)}) cc: ${e.cc} [${s.startSN}-${s.endSN}], target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=ty,d=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($f.FRAG_LOADING,{frag:e,part:l,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):d}if(!e.url||this.loadedEndOfParts(n,r))return Promise.resolve(null)}}var l;if(xp(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=s.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} ${"["+s.startSN+"-"+s.endSN+"]"}, target: ${parseFloat(r.toFixed(3))}`),_f(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=ty;const d=this.config.progressive&&e.type!==Vf;let c;return c=d&&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,d?i:void 0),a]).then(([e])=>(!d&&i&&i(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger($f.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c}doFragPartsLoad(e,t,r,i){return new Promise((n,s)=>{var a;const o=[],l=null==(a=r.details)?void 0:a.partList,d=t=>{this.fragmentLoader.loadPart(e,t,i).then(i=>{o[t.index]=i;const s=i.part;this.hls.trigger($f.FRAG_LOADED,i);const a=Bv(r.details,e.sn,t.index+1)||Uv(l,e.sn,t.index+1);if(!a)return n({frag:e,part:s,partsLoaded:o});d(a)}).catch(s)};d(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===Ff.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===Nf.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger($f.ERROR,t)}else this.hls.trigger($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==ny)return void(this.fragCurrent||this.state===Zv||this.state===oy||(this.state=Jv));const{frag:r,part:i,level:n}=t,s=self.performance.now();r.stats.parsing.end=s,i&&(i.stats.parsing.end=s);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,n,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var r;const n=e.partList[0];if(n.fragment.type===Vf)return!1;if(t>=n.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())>n.start-n.fragment.duration)return!0}}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:r}=this,{level:i,sn:n,part:s}=e;if(null==t||!t[i])return this.warn(`Levels object was unset while buffering fragment ${n} of ${this.playlistLabel()} ${i}. The current chunk will not be buffered.`),null;const a=t[i],o=a.details,l=s>-1?Bv(o,n,s):null,d=l?l.fragment:$v(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:a}):null}bufferFragmentData(e,t,r,i,n){if(this.state!==ny)return;const{data1:s,data2:a}=e;let o=s;if(a&&(o=Wp(s,a)),!o.length)return;const l=this.initPTS[t.cc],d=l?-l.baseTime/l.timescale:void 0,c={type:e.type,frag:t,part:r,chunkMeta:i,offset:d,parent:t.type,data:o};if(this.hls.trigger($f.BUFFER_APPENDING,c),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Cg.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);const r=t.currentTime,i=Cg.bufferInfo(t,r,0),n=e.duration,s=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),a=Math.max(Math.min(e.start-s,i.end-s),r+s);e.start-a>s&&this.flushMainBuffer(a,e.start)}getFwdBufferInfo(e,t){var r;const i=this.getLoadPosition();if(!_f(i))return null;const n=this.lastCurrentTime>i||null!=(r=this.media)&&r.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,i,t,n)}getFwdBufferInfoAtPos(e,t,r,i){const n=Cg.bufferInfo(e,t,i);if(0===n.len&&void 0!==n.nextStart){const s=this.fragmentTracker.getBufferedFrag(t,r);if(s&&(n.nextStart<=s.end||s.gap)){const r=Math.max(Math.min(n.nextStart,s.end)-t,i);return Cg.bufferInfo(e,t,r)}}return n}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),n=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return n>=i&&(r.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),!0)}getAppendedFrag(e,t=jf){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:n}=this,s=r[0].start,a=n.lowLatencyMode&&!!t.partList;let o=null;if(t.live){const r=n.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<s){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,n=o?(-1!==r&&r>=s?r:i)||o.start:e;this.log(`Setting startPosition to ${n} to match start frag at live edge. mainStart: ${r} liveSyncPosition: ${i} frag.start: ${null==(l=o)?void 0:l.start}`),this.startPosition=this.nextLoadPosition=n}}else e<=s&&(o=r[0]);if(!o){const r=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,r,t)}let d=this.filterReplacedPrimary(o,t);if(!d&&o){const e=o.sn-t.startSN;d=this.filterReplacedPrimary(r[e+1]||null,t)}return this.mapToInitFragWhenRequired(d)}isLoopLoading(e,t){const r=this.fragmentTracker.getState(e);return(r===fg||r===hg&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,i,n){let s=null;if(e.gap&&(s=this.getNextFragment(this.nextLoadPosition,t),s&&!s.gap&&r.nextStart)){const e=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i,0);if(null!==e&&r.len+e.len>=n){const e=s.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,s}get primaryPrefetch(){if(uy(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(uy(this.config)&&e.type!==Vf){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 n=null==r?void 0:r.playerQueue;if(n)for(let t=n.length;t--;){const r=n[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,n=!1,s=!0;for(let a=0,o=e.length;a<o;a++){const o=e[a];if(s=s&&!o.independent,i>-1&&r<o.start)break;const l=o.loaded;l?i=-1:(n||(o.independent||s)&&o.fragment===t)&&(o.fragment!==t&&this.warn(`Need buffer at ${r} but next unloaded part starts at ${o.start}`),i=a),n=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||!_f(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 n=e[i];if(Vm(t,r,n))return n}return null}(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){const n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){const s=t[n-e.startSN];r.cc===s.cc&&(i=s,this.log(`Live playlist, switching playlist, load frag with next SN: ${i.sn}`))}i||(i=Wm(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:n}=this,{fragments:s,endSN:a}=r;const{fragmentHint:o}=r,{maxFragLookUpTolerance:l}=i,d=r.partList,c=!!(this.loadingParts&&null!=d&&d.length&&o);let u;if(c&&!this.bitrateTest&&d[d.length-1].fragment.sn===o.sn&&(s=s.concat(o),a=o.sn),e<t){var h;u=jm(n,s,e,e<this.lastCurrentTime||e>t-l||null!=(h=this.media)&&h.paused||!this.startFragRequested?0:l)}else u=s[s.length-1];if(u){const e=u.sn-r.startSN,t=this.fragmentTracker.getState(u);if((t===fg||t===hg&&u.gap)&&(n=u),n&&u.sn===n.sn&&(!c||d[0].fragment.sn>u.sn||!r.live)){if(u.level===n.level){const t=s[e+1];u=u.sn<a&&this.fragmentTracker.getState(t)!==fg?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 n=e.fragmentStart,s=!t,a=e.alignedSliding&&_f(n);if(s||!a&&!n){!function(e,t){e&&(Yv(t,e),t.alignedSliding||Kv(t,e),t.alignedSliding||t.skippedSegments||Mv(e,t,!1))}(r,e);const n=e.fragmentStart;return this.log(`Live playlist sliding: ${n.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${i}`),n}return n}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 n=null!==this.startTimeOffset,s=n?this.startTimeOffset:e.startTimeOffset;null!==s&&_f(s)?(r=t+s,s<0&&(r+=e.edge),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Setting startPosition to ${r} for start time offset ${s} found in ${n?"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&&xp(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===ry)||(this.state=Jv)}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 n;if(this.fragContextChanged(i))return void this.warn(`Frag load error must match current frag to retry ${i.url} > ${null==(n=this.fragCurrent)?void 0:n.url}`);const s=t.details===Ff.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(i,!0);const a=t.errorAction;if(!a)return void(this.state=oy);const{action:o,flags:l,retryCount:d=0,retryConfig:c}=a,u=!!c,h=u&&o===ng,f=u&&!a.resolved&&l===ag,p=null==(r=this.hls.latestLevelDetails)?void 0:r.live;if(!h&&f&&xp(i)&&!i.endList&&p&&!qm(t))this.resetFragmentErrors(e),this.treatAsGap(i),a.resolved=!0;else if((h||f)&&d<c.maxNumRetry){var m;const r=eg(null==(m=t.response)?void 0:m.code),n=Qm(c,d);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+n,this.state=ry,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 ${d+1}/${c.maxNumRetry} in ${n}ms`)}else if(c){if(this.resetFragmentErrors(e),!(d<c.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${d})`);s||o===ig||(a.resolved=!0)}else this.state=o===rg?dy:oy;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,r=t===1/0;(!t||e>=t||r&&!eg(0))&&(r&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=Jv)}reduceLengthAndFlushBuffer(e){if(this.state===ny||this.state===sy){const t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);const s=!n;return s&&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(),s}return!1}resetFragmentErrors(e){e===Hf&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==Zv&&(this.state=Jv)}afterBufferFlushed(e,t,r){if(!e)return;const i=Cg.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===ay&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==Zv&&(this.state=Jv)}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 n=r.details;if(!n)return void this.warn("level.details undefined");if(!Object.keys(e.elementaryStreams).reduce((t,s)=>{const a=e.elementaryStreams[s];if(a){const o=a.endPTS-a.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${e.sn} ${s} duration reliably (${o})`),t||!1;const l=i?0:Cv(n,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS,this);return this.hls.trigger($f.LEVEL_PTS_UPDATED,{details:n,level:r,drift:l,type:s,frag:e,start:a.startPTS,end:a.endPTS}),!0}return t},!1)){var s;const t=null===(null==(s=this.transmuxer)?void 0:s.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($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.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=sy,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger($f.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===jf?"level":"track"}fragInfo(e,t=!0,r){var i,n;return`${this.playlistLabel()} ${e.level} (${r?"part":"frag"}:[${(null!=(i=t&&!r?e.startPTS:(r||e).start)?i:NaN).toFixed(3)}-${(null!=(n=t&&!r?e.endPTS:(r||e).end)?n: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 uy(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}class hy{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 n=e[t];r.set(n,i),i+=n.length}return r}(e,t),this.reset(),r):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}var fy,py={exports:{}};var my=(fy||(fy=1,function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,i,s,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new n(i,s||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,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},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 n=0,s=i.length,a=new Array(s);n<s;n++)a[n]=i[n].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,n,s,a){var o=r?r+e:e;if(!this._events[o])return!1;var l,d,c=this._events[o],u=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,i),!0;case 4:return c.fn.call(c.context,t,i,n),!0;case 5:return c.fn.call(c.context,t,i,n,s),!0;case 6:return c.fn.call(c.context,t,i,n,s,a),!0}for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c.fn.apply(c.context,l)}else{var h,f=c.length;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),u){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,i);break;case 4:c[d].fn.call(c[d].context,t,i,n);break;default:if(!l)for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];c[d].fn.apply(c[d].context,l)}}return!0},o.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,n){var s=r?r+e:e;if(!this._events[s])return this;if(!t)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||a(this,s);else{for(var l=0,d=[],c=o.length;l<c;l++)(o[l].fn!==t||n&&!o[l].once||i&&o[l].context!==i)&&d.push(o[l]);d.length?this._events[s]=1===d.length?d[0]:d:a(this,s)}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}(py)),py.exports),gy=cp(my);const vy="1.6.15",yy={};function by(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 Ey(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 wy(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 Sy(e,t){const r=t;let i=0;for(;Ey(e,t);){i+=10;i+=wy(e,t+6),by(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(r,r+i)}function Ty(e,t){return 255===e[t]&&240==(246&e[t+1])}function xy(e,t){return 1&e[t+1]?7:9}function Ay(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function ky(e,t){return t+1<e.length&&Ty(e,t)}function Ly(e,t){if(ky(e,t)){const r=xy(e,t);if(t+r>=e.length)return!1;const i=Ay(e,t);if(i<=r)return!1;const n=t+i;return n===e.length||ky(e,n)}return!1}function Iy(e,t,r,i,n){if(!e.samplerate){const s=function(e,t,r,i){const n=t[r+2],s=n>>2&15;if(s>12){const t=new Error(`invalid ADTS sampling index:${s}`);return void e.emit($f.ERROR,$f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.FRAG_PARSING_ERROR,fatal:!0,error:t,reason:t.message})}const a=1+(n>>6&3),o=t[r+3]>>6&3|(1&n)<<2,l="mp4a.40."+a,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][s];let c=s;5!==a&&29!==a||(c-=3);const u=[a<<3|(14&c)>>1,(1&c)<<7|o<<3];return np.log(`manifest codec:${i}, parsed codec:${l}, channels:${o}, rate:${d} (ADTS object type:${a} sampling index:${s})`),{config:u,samplerate:d,channelCount:o,codec:l,parsedCodec:l,manifestCodec:i}}(t,r,i,n);if(!s)return;qf(e,s)}}function Ry(e){return 9216e4/e}function Py(e,t,r,i,n){const s=i+n*Ry(e.samplerate),a=function(e,t){const r=xy(e,t);if(t+r<=e.length){const i=Ay(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);let o;if(a){const{frameLength:i,headerLength:n}=a,l=n+i,d=Math.max(0,r+l-t.length);d?(o=new Uint8Array(l-n),o.set(t.subarray(r+n,t.length),0)):o=t.subarray(r+n,r+l);const c={unit:o,pts:s};return d||e.samples.push(c),{sample:c,length:l,missing:d}}const l=t.length-r;o=new Uint8Array(l),o.set(t.subarray(r,t.length),0);return{sample:{unit:o,pts:s},length:l,missing:-1}}function Dy(e,t){return Ey(e,t)&&wy(e,t+6)+10<=e.length-t}function Cy(e,t=0,r=1/0){return function(e,t,r,i){const n=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e);let s=1;"BYTES_PER_ELEMENT"in i&&(s=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)/s,l=(a+t)/s,d=Math.floor(Math.max(0,Math.min(l,o))),c=Math.floor(Math.min(d+Math.max(r,0),o));var u;return new i(n,d,c-d)}(e,t,r,Uint8Array)}function _y(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=op(Cy(e.data,1,r)),n=e.data[2+r],s=e.data.subarray(3+r).indexOf(0);if(-1===s)return;const a=op(Cy(e.data,3+r,s));let o;return o="--\x3e"===i?op(Cy(e.data,4+r+s)):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+s)),t.mimeType=i,t.pictureType=n,t.description=a,t.data=o,t}function Oy(e){return"PRIV"===e.type?function(e){if(e.size<2)return;const t=op(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=op(e.data.subarray(t),!0);t+=r.length+1;const i=op(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=op(e.data);return{key:e.type,info:"",data:t}}(e):"APIC"===e.type?_y(e):function(e){if(e.size<2)return;if("TXXX"===e.type){let t=1;const r=op(e.data.subarray(t),!0);t+=r.length+1;const i=op(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=op(e.data.subarray(1));return{key:e.type,info:"",data:t}}(e)}function My(e){const t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=wy(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}function Ny(e){let t=0;const r=[];for(;Ey(e,t);){const i=wy(e,t+6);e[t+5]>>6&1&&(t+=10),t+=10;const n=t+i;for(;t+10<n;){const i=My(e.subarray(t)),n=Oy(i);n&&r.push(n),t+=i.size+10}by(e,t)&&(t+=10)}return r}function Fy(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function $y(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 By(e){const t=Ny(e);for(let e=0;e<t.length;e++){const r=t[e];if(Fy(r))return $y(r)}}let Uy=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 zy(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class Gy{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=Wp(this.cachedData,e),this.cachedData=null);let r,i=Sy(e,0),n=i?i.length:0;const s=this._audioTrack,a=this._id3Track,o=i?By(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&_f(o))&&(this.basePTS=jy(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:Uy.audioId3,duration:Number.POSITIVE_INFINITY});n<l;){if(this.canParse(e,n)){const t=this.appendFrame(s,e,n);t?(this.frameIndex++,this.lastPTS=t.sample.pts,n+=t.length,r=n):n=l}else Dy(e,n)?(i=Sy(e,n),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Uy.audioId3,duration:Number.POSITIVE_INFINITY}),n+=i.length,r=n):n++;if(n===l&&r!==l){const t=e.slice(r);this.cachedData?this.cachedData=Wp(this.cachedData,t):this.cachedData=t}}return{audioTrack:s,videoTrack:zy(),id3Track:a,textTrack:zy()}}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:zy(),id3Track:this._id3Track,textTrack:zy()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const jy=(e,t,r)=>{if(_f(e))return 90*e;return 9e4*t+(r?9e4*r.baseTime/r.timescale:0)};let Hy=null;const Vy=[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],Wy=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Yy=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Ky=[0,1,1,4];function qy(e,t,r,i,n){if(r+24>t.length)return;const s=Xy(t,r);if(s&&r+s.frameLength<=t.length){const a=i+n*(9e4*s.samplesPerFrame/s.sampleRate),o={unit:t.subarray(r,r+s.frameLength),pts:a,dts:a};return e.config=[],e.channelCount=s.channelCount,e.samplerate=s.sampleRate,e.samples.push(o),{sample:o,length:s.frameLength,missing:0}}}function Xy(e,t){const r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,s=e[t+2]>>2&3;if(1!==r&&0!==n&&15!==n&&3!==s){const a=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*Vy[14*(3===r?3-i:3===i?3:4)+n-1],d=Wy[3*(3===r?0:2===r?1:2)+s],c=3===o?1:2,u=Yy[r][i],h=Ky[i],f=8*u*h,p=Math.floor(u*l/d+a)*h;if(null===Hy){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Hy=e?parseInt(e[1]):0}return!!Hy&&Hy<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:d,channelCount:c,frameLength:p,samplesPerFrame:f}}}function Qy(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function Zy(e,t){return t+1<e.length&&Qy(e,t)}function Jy(e,t){if(t+1<e.length&&Qy(e,t)){const r=4,i=Xy(e,t);let n=r;null!=i&&i.frameLength&&(n=i.frameLength);const s=t+n;return s===e.length||Zy(e,s)}return!1}const eb=(e,t)=>{let r=0,i=5;t+=i;const n=new Uint32Array(1),s=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=e[t];const o=Math.min(i,8),l=8-o;s[0]=4278190080>>>24+l<<l,n[0]=(a[0]&s[0])>>l,r=r?r<<o|n[0]:n[0],t+=1,i-=o}return r};class tb extends Gy{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=rb(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=Sy(e,0);if(!t)return!1;const r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==By(t)&&eb(e,r)<16}}function rb(e,t,r,i,n){if(r+8>t.length)return-1;if(11!==t[r]||119!==t[r+1])return-1;const s=t[r+4]>>6;if(s>=3)return-1;const a=[48e3,44100,32e3][s],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+s];if(r+l>t.length)return-1;const d=t[r+6]>>5;let c=0;2===d?c+=2:(1&d&&1!==d&&(c+=2),4&d&&(c+=2));const u=(t[r+6]<<8|t[r+7])>>12-c&1,h=[2,1,2,3,3,4,4,5][d]+u,f=t[r+5]>>3,p=7&t[r+5],m=new Uint8Array([s<<6|f<<1|p>>2,(3&p)<<6|d<<3|u<<2|o>>4,o<<4&224]),g=i+n*(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 ib=/\/emsg[-/]ID3/i;function nb(e,t){return _f(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}class sb{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Tg(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,yg)}decryptAacSample(e,t,r){const i=e[t].unit;if(i.length<=16)return;const n=i.subarray(16,i.length-i.length%16),s=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(s).then(n=>{const s=new Uint8Array(n);i.set(s,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,n){const s=Qp(n.data),a=this.getAvcEncryptedData(s);this.decryptBuffer(a.buffer).then(a=>{n.data=this.getAvcDecryptedUnit(s,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 n=e[t].units;for(;!(r>=n.length);r++){const s=n[r];if(!(s.data.length<=48||1!==s.type&&5!==s.type||(this.decryptAvcSample(e,t,r,i,s),this.decrypter.isSync())))return}}}}class ab{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 n=e.naluState||0;const s=n,a=[];let o,l,d,c=0,u=-1,h=0;for(-1===n&&(u=0,h=this.getNALuType(t,0),n=0,c=1);c<i;)if(o=t[c++],n)if(1!==n)if(o)if(1===o){if(l=c-n-1,u>=0){const e={data:t.subarray(u,l),type:h};a.push(e)}else{const r=this.getLastNalUnit(e.samples);r&&(s&&c<=4-s&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-s)),l>0&&(r.data=Wp(r.data,t.subarray(0,l)),r.state=0))}c<i?(d=this.getNALuType(t,c),u=c,h=d,n=0):n=-1}else n=0;else n=3;else n=o?0:2;else n=o?0:1;if(u>=0&&n>=0){const e={data:t.subarray(u,i),type:h,state:n};a.push(e)}if(0===a.length){const r=this.getLastNalUnit(e.samples);r&&(r.data=Wp(r.data,t))}return e.naluState=n,a}}class ob{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),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");i.set(e.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n}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&&np.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 lb extends ab{parsePES(e,t,r,i){const n=this.parseNALu(e,r.data,i);let s,a=this.VideoSample,o=!1;r.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),n.forEach(i=>{var n,l;switch(i.type){case 1:{let t=!1;s=!0;const n=i.data;if(o&&n.length>4){const e=this.readSliceType(n);2!==e&&4!==e&&7!==e&&9!==e||(t=!0)}var d;if(t)null!=(d=a)&&d.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:s=!0,null!=(n=a)&&n.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:s=!0,Xp(i.data,1,r.pts,t.samples);break;case 7:{var c,u;s=!0,o=!0;const t=i.data,r=this.readSPS(t);if(!e.sps||e.width!==r.width||e.height!==r.height||(null==(c=e.pixelRatio)?void 0:c[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 n="avc1.";for(let e=0;e<3;e++){let t=i[e].toString(16);t.length<2&&(t="0"+t),n+=t}e.codec=n}break}case 8:s=!0,e.pps=[i.data];break;case 9:s=!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:s=!0;break;default:s=!1}if(a&&s){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 ob(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let r,i=8,n=8;for(let s=0;s<e;s++)0!==n&&(r=t.readEG(),n=(i+r+256)%256),i=0===n?i:n}readSPS(e){const t=new ob(e);let r,i,n,s=0,a=0,o=0,l=0;const d=t.readUByte.bind(t),c=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);d();const v=d();if(c(5),f(3),d(),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,n=0;n<i;n++)h()&&g(n<6?16:64,t)}m();const y=u();if(0===y)u();else if(1===y)for(f(1),p(),p(),r=u(),n=0;n<r;n++)p();m(),f(1);const b=u(),E=u(),w=c(1);0===w&&f(1),f(1),h()&&(s=u(),a=u(),o=u(),l=u());let S=[1,1];if(h()&&h()){switch(d()){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=[d()<<8|d(),d()<<8|d()]}}return{width:Math.ceil(16*(b+1)-2*s-2*a),height:(2-w)*(E+1)*16-(w?2:4)*(o+l),pixelRatio:S}}}class db extends ab{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,r,i){const n=this.parseNALu(e,r.data,i);let s,a=this.VideoSample,o=!1;r.data=null,a&&n.length&&!e.audFound&&(this.pushAccessUnit(a,e),a=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),n.forEach(i=>{var n,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,s=!0;break;case 16:case 17:case 18:case 21:var d;if(s=!0,o)null!=(d=a)&&d.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:s=!0,null!=(n=a)&&n.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:s=!0,Xp(i.data,2,r.pts,t.samples);break;case 32:s=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=qf(e.params,this.readVPS(i.data)),this.initVPS=i.data),e.vps=[i.data];break;case 33:if(s=!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(s=!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:s=!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:s=!1}if(a&&s){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 ob(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 ob(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const r=t.readBits(3);t.readBoolean();const i=t.readBits(2),n=t.readBoolean(),s=t.readBits(5),a=t.readUByte(),o=t.readUByte(),l=t.readUByte(),d=t.readUByte(),c=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 D=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<=D;e++){const e=t.readBoolean();let i=!1;e||(i=t.readBoolean()),(e||i)&&r++}D=r}else{const e=t.readUEG(),r=t.readUEG();D=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 C=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 n=!1;(e||i)&&(n=t.readBoolean(),n&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),n&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let s=0;s<=r;s++){M=t.readBoolean();let r=!1;M||t.readBoolean()?t.readEG():r=t.readBoolean();const s=r?1:t.readUEG()+1;if(e)for(let e=0;e<s;e++)t.readUEG(),t.readUEG(),n&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(i)for(let e=0;e<s;e++)t.readUEG(),t.readUEG(),n&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),C=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|d;let j=0;for(let e=0;e<32;e++)j=(j|(G>>e&1)<<31-e)>>>0;let H=j.toString(16);1===s&&"2"===H&&(H="6");return{codecString:`hvc1.${z}${s}.${H}.${n?"H":"L"}${g}.B0`,params:{general_tier_flag:n,general_profile_idc:s,general_profile_space:i,general_profile_compatibility_flags:[a,o,l,d],general_constraint_indicator_flags:[c,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:C,chroma_format_idc:b,frame_rate:{fixed:M,fps:F/N}},width:B,height:U,pixelRatio:[_,O]}}readPPS(e){const t=new ob(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 n=1;return i&&r?n=0:i?n=3:r&&(n=2),{parallelismType:n}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const cb=188;class ub{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=ub.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-cb)+1,i=0;for(;i<r;){let n=!1,s=-1,a=0;for(let o=i;o<t;o+=cb){if(71!==e[o]||t-o!==cb&&71!==e[o+cb]){if(a)return-1;break}if(a++,-1===s&&(s=o,0!==s&&(r=Math.min(s+18612,e.length-cb)+1)),n||(n=0===hb(e,o)),n&&a>1&&(0===s&&a>2||o+cb>r))return s}i++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:Pp[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=ub.createTrack("video"),this._videoTrack.duration=i,this._audioTrack=ub.createTrack("audio",i),this._id3Track=ub.createTrack("id3"),this._txtTrack=ub.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 n;r||(this.sampleAes=null);const s=this._videoTrack,a=this._audioTrack,o=this._id3Track,l=this._txtTrack;let d=s.pid,c=s.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=Wp(this.remainderData,e)).length,this.remainderData=null),y<cb&&!i)return this.remainderData=e,{audioTrack:a,videoTrack:s,id3Track:o,textTrack:l};const b=Math.max(0,ub.syncOffset(e));y-=(y-b)%cb,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+=cb)if(71===e[t]){const i=!!(64&e[t+1]),y=hb(e,t);let E;if((48&e[t+3])>>4>1){if(E=t+5+e[t+4],E===t+cb)continue}else E=t+4;switch(y){case d:i&&(c&&(n=vb(c,this.logger))&&(this.readyVideoParser(s.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(s,l,n,!1)),c={data:[],size:0}),c&&(c.data.push(e.subarray(E,t+cb)),c.size+=t+cb-E);break;case u:if(i){if(f&&(n=vb(f,this.logger)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,n);break;case"mp3":this.parseMPEGPES(a,n);break;case"ac3":this.parseAC3PES(a,n)}f={data:[],size:0}}f&&(f.data.push(e.subarray(E,t+cb)),f.size+=t+cb-E);break;case h:i&&(p&&(n=vb(p,this.logger))&&this.parseID3PES(o,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(E,t+cb)),p.size+=t+cb-E);break;case 0:i&&(E+=e[E]+1),v=this._pmtId=fb(e,E);break;case v:{i&&(E+=e[E]+1);const n=pb(e,E,this.typeSupported,r,this.observer,this.logger);d=n.videoPid,d>0&&(s.pid=d,s.segmentCodec=n.segmentVideoCodec),u=n.audioPid,u>0&&(a.pid=u,a.segmentCodec=n.segmentAudioCodec),h=n.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&&mb(this.observer,new Error(`Found ${E} TS packet/s that do not start with 0x47`),void 0,this.logger),s.pesData=c,a.pesData=f,o.pesData=p;const w={audioTrack:a,videoTrack:s,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:n}=e,s=r.pesData,a=t.pesData,o=i.pesData;let l;if(s&&(l=vb(s,this.logger))?(this.readyVideoParser(r.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(r,n,l,!0),r.pesData=null)):r.pesData=s,a&&(l=vb(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=vb(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),n=this.sampleAes=new sb(this.observer,this.config,t);return this.decrypt(i,n)}readyVideoParser(e){null===this.videoParser&&("avc"===e?this.videoParser=new lb:"hevc"===e&&(this.videoParser=new db))}decrypt(e,t){return new Promise(r=>{const{audioTrack:i,videoTrack:n}=e;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.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 n,s,a,o=t.data;if(i){this.aacOverFlow=null;const t=i.missing,n=i.sample.unit.byteLength;if(-1===t)o=Wp(i.sample.unit,o);else{const s=n-t;i.sample.unit.set(o.subarray(0,t),s),e.samples.push(i.sample),r=i.missing}}for(n=r,s=o.length;n<s-1&&!ky(o,n);n++);if(n!==r){let e;const t=n<s-1;if(e=t?`AAC PES did not start with ADTS header,offset:${n}`:"No ADTS header found in AAC PES",mb(this.observer,new Error(e),t,this.logger),!t)return}if(Iy(e,this.observer,o,n,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!i)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");{const t=Ry(e.samplerate);a=i.sample.pts+t}}let l,d=0;for(;n<s;){if(l=Py(e,o,n,a,d),n+=l.length,l.missing){this.aacOverFlow=l;break}for(d++;n<s-1&&!ky(o,n);n++);}}parseMPEGPES(e,t){const r=t.data,i=r.length;let n=0,s=0;const a=t.pts;if(void 0!==a)for(;s<i;)if(Zy(r,s)){const t=qy(e,r,s,a,n);if(!t)break;s+=t.length,n++}else s++;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 n=r.length;let s,a=0,o=0;for(;o<n&&(s=rb(e,r,o,i,a++))>0;)o+=s}}parseID3PES(e,t){if(void 0===t.pts)return void this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");const r=qf({},t,{type:this._videoTrack?Uy.emsg:Uy.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}}function hb(e,t){return((31&e[t+1])<<8)+e[t+2]}function fb(e,t){return(31&e[t+10])<<8|e[t+11]}function pb(e,t,r,i,n,s){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=hb(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){gb("ADTS AAC",s);break}case 15:-1===a.audioPid&&(a.audioPid=o);break;case 21:-1===a.id3Pid&&(a.id3Pid=o);break;case 219:if(!i){gb("H.264",s);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"):s.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){gb("AC-3",s);break}case 129:r.ac3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="ac3"):s.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===a.audioPid&&l>0){let i=t+5,n=l;for(;n>2;){if(106===e[i])!0!==r.ac3?s.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,n-=t}}break;case 194:case 135:return mb(n,new Error("Unsupported EC-3 in M2TS found"),void 0,s),a;case 36:-1===a.videoPid&&(a.videoPid=o,a.segmentVideoCodec="hevc",s.log("HEVC in M2TS found"))}t+=l+5}return a}function mb(e,t,r,i){i.warn(`parsing error: ${t.message}`),e.emit($f.ERROR,$f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function gb(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function vb(e,t){let r,i,n,s,a,o=0;const l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=Wp(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 d=r[7];192&d&&(s=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&d?(a=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2,s-a>54e5&&(t.warn(`${Math.round((s-a)/9e4)}s delta between PTS and DTS, align them`),s=a)):a=s),n=r[8];let c=n+9;if(e.size<=c)return null;e.size-=c;const u=new Uint8Array(e.size);for(let e=0,t=l.length;e<t;e++){r=l[e];let t=r.byteLength;if(c){if(c>t){c-=t;continue}r=r.subarray(c),t-=c,c=0}u.set(r,o),o+=t}return i&&(i-=n+3),{data:u,pts:s,dts:a,len:i}}return null}class yb{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 bb=Math.pow(2,32)-1;class Eb{static init(){let e;for(e in Eb.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:[]},Eb.types)Eb.types.hasOwnProperty(e)&&(Eb.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]);Eb.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]),n=new Uint8Array([0,0,0,0,0,0,0,0]);Eb.STTS=Eb.STSC=Eb.STCO=n,Eb.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Eb.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Eb.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),Eb.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const s=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),o=new Uint8Array([0,0,0,1]);Eb.FTYP=Eb.box(Eb.types.ftyp,s,o,s,a),Eb.DINF=Eb.box(Eb.types.dinf,Eb.box(Eb.types.dref,i))}static box(e,...t){let r=8,i=t.length;const n=i;for(;i--;)r+=t[i].byteLength;const s=new Uint8Array(r);for(s[0]=r>>24&255,s[1]=r>>16&255,s[2]=r>>8&255,s[3]=255&r,s.set(e,4),i=0,r=8;i<n;i++)s.set(t[i],r),r+=t[i].byteLength;return s}static hdlr(e){return Eb.box(Eb.types.hdlr,Eb.HDLR_TYPES[e])}static mdat(e){return Eb.box(Eb.types.mdat,e)}static mdhd(e,t){t*=e;const r=Math.floor(t/(bb+1)),i=Math.floor(t%(bb+1));return Eb.box(Eb.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 Eb.box(Eb.types.mdia,Eb.mdhd(e.timescale||0,e.duration||0),Eb.hdlr(e.type),Eb.minf(e))}static mfhd(e){return Eb.box(Eb.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?Eb.box(Eb.types.minf,Eb.box(Eb.types.smhd,Eb.SMHD),Eb.DINF,Eb.stbl(e)):Eb.box(Eb.types.minf,Eb.box(Eb.types.vmhd,Eb.VMHD),Eb.DINF,Eb.stbl(e))}static moof(e,t,r){return Eb.box(Eb.types.moof,Eb.mfhd(e),Eb.traf(r,t))}static moov(e){let t=e.length;const r=[];for(;t--;)r[t]=Eb.trak(e[t]);return Eb.box.apply(null,[Eb.types.moov,Eb.mvhd(e[0].timescale||0,e[0].duration||0)].concat(r).concat(Eb.mvex(e)))}static mvex(e){let t=e.length;const r=[];for(;t--;)r[t]=Eb.trex(e[t]);return Eb.box.apply(null,[Eb.types.mvex,...r])}static mvhd(e,t){t*=e;const r=Math.floor(t/(bb+1)),i=Math.floor(t%(bb+1)),n=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 Eb.box(Eb.types.mvhd,n)}static sdtp(e){const t=e.samples||[],r=new Uint8Array(4+t.length);let i,n;for(i=0;i<t.length;i++)n=t[i].flags,r[i+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return Eb.box(Eb.types.sdtp,r)}static stbl(e){return Eb.box(Eb.types.stbl,Eb.stsd(e),Eb.box(Eb.types.stts,Eb.STTS),Eb.box(Eb.types.stsc,Eb.STSC),Eb.box(Eb.types.stsz,Eb.STSZ),Eb.box(Eb.types.stco,Eb.STCO))}static avc1(e){let t,r,i,n=[],s=[];for(t=0;t<e.sps.length;t++)r=e.sps[t],i=r.byteLength,n.push(i>>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(r));for(t=0;t<e.pps.length;t++)r=e.pps[t],i=r.byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(r));const a=Eb.box(Eb.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|e.sps.length].concat(n).concat([e.pps.length]).concat(s))),o=e.width,l=e.height,d=e.pixelRatio[0],c=e.pixelRatio[1];return Eb.box(Eb.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,Eb.box(Eb.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Eb.box(Eb.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,c>>24,c>>16&255,c>>8&255,255&c])))}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 Eb.box(Eb.types.mp4a,Eb.audioStsd(e),Eb.box(Eb.types.esds,Eb.esds(e)))}static mp3(e){return Eb.box(Eb.types[".mp3"],Eb.audioStsd(e))}static ac3(e){return Eb.box(Eb.types["ac-3"],Eb.audioStsd(e),Eb.box(Eb.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if("audio"===e.type){if("aac"===t)return Eb.box(Eb.types.stsd,Eb.STSD,Eb.mp4a(e));if("ac3"===t&&e.config)return Eb.box(Eb.types.stsd,Eb.STSD,Eb.ac3(e));if("mp3"===t&&"mp3"===e.codec)return Eb.box(Eb.types.stsd,Eb.STSD,Eb.mp3(e))}else{if(!e.pps||!e.sps)throw new Error("video track missing pps or sps");if("avc"===t)return Eb.box(Eb.types.stsd,Eb.STSD,Eb.avc1(e));if("hevc"===t&&e.vps)return Eb.box(Eb.types.stsd,Eb.STSD,Eb.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,n=e.height||0,s=Math.floor(r/(bb+1)),a=Math.floor(r%(bb+1));return Eb.box(Eb.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,s>>24,s>>16&255,s>>8&255,255&s,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,n>>8&255,255&n,0,0]))}static traf(e,t){const r=Eb.sdtp(e),i=e.id,n=Math.floor(t/(bb+1)),s=Math.floor(t%(bb+1));return Eb.box(Eb.types.traf,Eb.box(Eb.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),Eb.box(Eb.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s])),Eb.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,Eb.box(Eb.types.trak,Eb.tkhd(e),Eb.mdia(e))}static trex(e){const t=e.id;return Eb.box(Eb.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,n=12+16*i,s=new Uint8Array(n);let a,o,l,d,c,u;for(t+=8+n,s.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,d=o.size,c=o.flags,u=o.cts,s.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,d>>>24&255,d>>>16&255,d>>>8&255,255&d,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,61440&c.degradPrio,15&c.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*a);return Eb.box(Eb.types.trun,s)}static initSegment(e){Eb.types||Eb.init();const t=Eb.moov(e);return Wp(Eb.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 n=i.length;for(let e=0;e<r.length;e+=1){n+=3;for(let t=0;t<r[e].length;t+=1)n+=2+r[e][t].length}const s=new Uint8Array(n);s.set(i,0),n=i.length;const a=r.length-1;for(let e=0;e<r.length;e+=1){s.set(new Uint8Array([32+e|(e===a?128:0),0,r[e].length]),n),n+=3;for(let t=0;t<r[e].length;t+=1)s.set(new Uint8Array([r[e][t].length>>8,255&r[e][t].length]),n),n+=2,s.set(r[e][t],n),n+=r[e][t].length}const o=Eb.box(Eb.types.hvcC,s),l=e.width,d=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return Eb.box(Eb.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,d>>8&255,255&d,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,Eb.box(Eb.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Eb.box(Eb.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,u>>24,u>>16&255,u>>8&255,255&u])))}}Eb.types=void 0,Eb.HDLR_TYPES=void 0,Eb.STTS=void 0,Eb.STSC=void 0,Eb.STCO=void 0,Eb.STSZ=void 0,Eb.VMHD=void 0,Eb.SMHD=void 0,Eb.STSD=void 0,Eb.FTYP=void 0,Eb.DINF=void 0;function wb(e,t,r=1,i=!1){const n=e*t*r;return i?Math.round(n):n}function Sb(e,t=!1){return wb(e,1e3,1/9e4,t)}function Tb(e){const{baseTime:t,timescale:r,trackId:i}=e;return`${t/r} (${t}/${r}) trackId: ${i}`}let xb,Ab=null,kb=null;function Lb(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 Ib extends Zf{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===Ab){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ab=e?parseInt(e[1]):0}if(null===kb){const e=navigator.userAgent.match(/Safari\/(\d+)/i);kb=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?Tb(t):t} > ${e?Tb(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 n=i.pts,s=n-e;return s<-4294967296&&(t=!0,n=Rb(n,r),s=n-e),s>0?e:n},r);return t&&this.debug("PTS rollover detected"),i}remux(e,t,r,i,n,s,a,o){let l,d,c,u,h,f,p=n,m=n;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||(c=this.generateIS(e,t,n,s));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=(Rb(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"),c=this.generateIS(e,t,n,s)),d=this.remuxAudio(e,p,this.isAudioContiguous,s,v||E||o===Hf?m:void 0),E){const i=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),c=this.generateIS(e,t,n,s)),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=Pb(r,n,this._initPTS,this._initDTS)),i.samples.length&&(u=Db(i,n,this._initPTS))),{audio:d,video:l,initSegment:c,independent:f,text:u,id3:h}}computeInitPts(e,t,r,i){const n=Math.round(r*t);let s=Rb(e,n);if(s<n+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(n-s)/t} ${i}`);s<n+t;)s+=8589934592;return s-n}generateIS(e,t,r,i){const n=e.samples,s=t.samples,a=this.typeSupported,o={},l=this._initPTS;let d,c,u,h=!l||i,f="audio/mp4",p=-1;if(h&&(d=c=1/0),e.config&&n.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):Eb.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(p=e.id,u=e.inputTimeScale,l&&u===l.timescale?h=!1:d=c=this.computeInitPts(n[0].pts,u,r,"audio"))}if(t.sps&&t.pps&&s.length){if(t.timescale=t.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Eb.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(s),t=Rb(s[0].dts,e),i=this.computeInitPts(t,u,r,"video"),n=this.computeInitPts(e,u,r,"video");c=Math.min(c,i),d=Math.min(d,n)}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} ${d/u} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${r} offset: ${d/u} (${d}/${u}) trackId: ${p}`),this._initPTS={baseTime:d,timescale:u,trackId:p},this._initDTS={baseTime:c,timescale:u,trackId:p}):d=u=void 0,{tracks:o,initPTS:d,timescale:u,trackId:p}}remuxVideo(e,t,r,i){const n=e.inputTimeScale,s=e.samples,a=[],o=s.length,l=this._initPTS,d=l.baseTime*n/l.timescale;let c,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=d+t*n,i=s[0].pts-Rb(s[0].dts,s[0].pts);Ab&&null!==h&&Math.abs(e-i-(h+d))<15e3?r=!0:h=e-i-d}const y=h+d;for(let e=0;e<o;e++){const t=s[e];t.pts=Rb(t.pts,y),t.dts=Rb(t.dts,y),t.dts<s[e>0?e-1:e].dts&&(v=!0)}v&&s.sort(function(e,t){const r=e.dts-t.dts,i=e.pts-t.pts;return r||i}),c=s[0].dts,u=s[s.length-1].dts;const b=u-c,E=b?Math.round(b/(o-1)):p||e.inputTimeScale/30;if(r){const r=c-y,i=r>E,n=r<-1;if((i||n)&&(i?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Sb(r,!0)} ms (${r}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Sb(-r,!0)} ms (${r}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!n||y>=s[0].pts||Ab)){c=y;const e=s[0].pts-r;if(i)s[0].dts=c,s[0].pts=e;else{let t=!0;for(let i=0;i<s.length&&!(s[i].dts>e&&t);i++){const e=s[i].pts;if(s[i].dts-=r,s[i].pts-=r,i<s.length-1){const r=s[i+1].pts;t=r<=s[i].pts==r<=e}}}this.log(`Video: Initial PTS/DTS adjusted: ${Sb(e,!0)}/${Sb(c,!0)}, delta: ${Sb(r,!0)} ms`)}}c=Math.max(0,c);let w=0,S=0,T=c;for(let e=0;e<o;e++){const t=s[e],r=t.units,i=r.length;let n=0;for(let e=0;e<i;e++)n+=r[e].data.length;S+=n,w+=i,t.length=n,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=s[o-1].dts;const x=S+4*w+8;let A;try{A=new Uint8Array(x)}catch(e){return void this.observer.emit($f.ERROR,$f.ERROR,{type:Nf.MUX_ERROR,details:Ff.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(Eb.types.mdat,4);let L=!1,I=Number.POSITIVE_INFINITY,R=Number.POSITIVE_INFINITY,P=Number.NEGATIVE_INFINITY,D=Number.NEGATIVE_INFINITY;for(let e=0;e<o;e++){const t=s[e],r=t.units;let l,c=0;for(let e=0,t=r.length;e<t;e++){const t=r[e],i=t.data,n=t.data.byteLength;k.setUint32(f,n),f+=4,A.set(i,f),f+=n,c+=4+n}if(e<o-1)p=s[e+1].dts-t.dts,l=s[e+1].pts-t.pts;else{const r=this.config,a=e>0?t.dts-s[e-1].dts:E;if(l=e>0?t.pts-s[e-1].pts:E,r.stretchShortVideoTrack&&null!==this.nextAudioTs){const e=Math.floor(r.maxBufferHole*n),s=(i?m+i*n:this.nextAudioTs+d)-t.pts;s>e?(p=s-a,p<0?p=a:L=!0,this.log(`It is approximately ${s/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),D=Math.max(D,l),a.push(Lb(t.key,p,c,u))}if(a.length)if(Ab){if(Ab<70){const e=a[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(kb&&D-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=c;for(let t=0,r=a.length;t<r;t++){const i=e+a[t].duration,n=e+a[t].cts;if(t<r-1){const e=i+a[t+1].cts;a[t].duration=e-n}else a[t].duration=t?a[t-1].duration:E;a[t].cts=0,e=i}}p=L||!p?E:p;const C=u+p;this.nextVideoTs=h=C-d,this.videoSampleDuration=p,this.isVideoContiguous=!0;const _={data1:Eb.moof(e.sequenceNumber++,c,qf(e,{samples:a})),data2:A,startPTS:(m-d)/n,endPTS:(g+p-d)/n,startDTS:(c-d)/n,endDTS:h/n,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,n){const s=e.inputTimeScale,a=s/(e.samplerate?e.samplerate:s),o=this.getSamplesPerFrame(e),l=o*a,d=this._initPTS,c="mp3"===e.segmentCodec&&this.typeSupported.mpeg,u=[],h=void 0!==n;let f=e.samples,p=c?0:8,m=this.nextAudioTs||-1;const g=d.baseTime*s/d.timescale,v=g+t*s;if(this.isAudioContiguous=r=r||f.length&&m>0&&(i&&Math.abs(v-(m+g))<9e3||Math.abs(Rb(f[0].pts,v)-(m+g))<20*l),f.forEach(function(e){e.pts=Rb(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} / ${s})`),!f.length)return;m=0===n?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 n=f[r],a=n.pts,o=a-i,d=Math.abs(1e3*o/s);if(o<=-t*l&&h)0===r&&(this.warn(`Audio frame @ ${(a/s).toFixed(3)}s overlaps marker by ${Math.round(1e3*o/s)} ms.`),this.nextAudioTs=m=a-g,i=a);else if(o>=t*l&&d<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)/s).toFixed(3)}s due to ${Math.round(1e3*o/s)} ms gap.`);for(let s=0;s<t;s++){let t=yb.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=n.unit.subarray()),f.splice(r,0,{unit:t,pts:i}),i+=l,r++}}n.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],n=i.unit;let s=i.pts;if(null!==E){u[t-1].duration=Math.round((s-E)/a)}else{if(r&&"aac"===e.segmentCodec&&(s=m+g),b=s,!(w>0))return;w+=p;try{y=new Uint8Array(w)}catch(e){return void this.observer.emit($f.ERROR,$f.ERROR,{type:Nf.MUX_ERROR,details:Ff.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:w,reason:`fail allocating audio mdat ${w}`})}if(!c){new DataView(y.buffer).setUint32(0,w),y.set(Eb.types.mdat,4)}}y.set(n,p);const l=n.byteLength;p+=l,u.push(Lb(!0,o,l,0)),E=s}const T=u.length;if(!T)return;const x=u[u.length-1];m=E-g,this.nextAudioTs=m+a*x.duration;const A=c?new Uint8Array(0):Eb.moof(e.sequenceNumber++,b/a,qf({},e,{samples:u}));e.samples=[];const k=(b-g)/s,L=this.nextAudioTs/s,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 Rb(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 Pb(e,t,r,i){const n=e.samples.length;if(!n)return;const s=e.inputTimeScale;for(let a=0;a<n;a++){const n=e.samples[a];n.pts=Rb(n.pts-r.baseTime*s/r.timescale,t*s)/s,n.dts=Rb(n.dts-i.baseTime*s/i.timescale,t*s)/s}const a=e.samples;return e.samples=[],{samples:a}}function Db(e,t,r){const i=e.samples.length;if(!i)return;const n=e.inputTimeScale;for(let s=0;s<i;s++){const i=e.samples[s];i.pts=Rb(i.pts-r.baseTime*n/r.timescale,t*n)/n}e.samples.sort((e,t)=>e.pts-t.pts);const s=e.samples;return e.samples=[],{samples:s}}function Cb(e,t,r=!1){return void 0!==(null==e?void 0:e.start)?(e.start+(r?e.duration:0))/e.timescale:t}function _b(e,t,r){const i=e.codec;if(i&&i.length>4)return i;if(t===Ep){if("ec-3"===i||"ac-3"===i||"alac"===i)return i;if("fLaC"===i||"Opus"===i){return cm(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{xb=self.performance.now.bind(self.performance)}catch(e){xb=Date.now}const Ob=[{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 n=this.videoTrack=zy("video",1),s=this.audioTrack=zy("audio",1),a=this.txtTrack=zy("text",1);if(this.id3Track=zy("id3",1),this.timeOffset=0,null==e||!e.byteLength)return;const o=$p(e);if(o.video){const{id:e,timescale:t,codec:r,supplemental:i}=o.video;n.id=e,n.timescale=a.timescale=t,n.codec=r,n.supplemental=i}if(o.audio){const{id:e,timescale:t,codec:r}=o.audio;s.id=e,s.timescale=t,s.codec=r}a.id=Pp.text,n.sampleDuration=0,n.duration=s.duration=i}resetContiguity(){this.remainderData=null}static probe(e){return function(e){const t=e.byteLength;for(let r=0;r<t;){const i=_p(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,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Wp(this.remainderData,e));const t=function(e){const t={valid:null,remainder:null},r=Np(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 s=this.extractID3Track(i,t);return n.samples=Yp(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,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=Yp(e,t),{videoTrack:t,audioTrack:zy(),id3Track:i,textTrack:zy()}}extractID3Track(e,t){const r=this.id3Track;if(e.samples.length){const i=Np(e.samples,["emsg"]);i&&i.forEach(e=>{const i=function(e){const t=e[0];let r="",i="",n=0,s=0,a=0,o=0,l=0,d=0;if(0===t){for(;"\0"!==Dp(e.subarray(d,d+1));)r+=Dp(e.subarray(d,d+1)),d+=1;for(r+=Dp(e.subarray(d,d+1)),d+=1;"\0"!==Dp(e.subarray(d,d+1));)i+=Dp(e.subarray(d,d+1)),d+=1;i+=Dp(e.subarray(d,d+1)),d+=1,n=_p(e,12),s=_p(e,16),o=_p(e,20),l=_p(e,24),d=28}else if(1===t){d+=4,n=_p(e,d),d+=4;const t=_p(e,d);d+=4;const s=_p(e,d);for(d+=4,a=2**32*t+s,Of(a)||(a=Number.MAX_SAFE_INTEGER,np.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=_p(e,d),d+=4,l=_p(e,d),d+=4;"\0"!==Dp(e.subarray(d,d+1));)r+=Dp(e.subarray(d,d+1)),d+=1;for(r+=Dp(e.subarray(d,d+1)),d+=1;"\0"!==Dp(e.subarray(d,d+1));)i+=Dp(e.subarray(d,d+1)),d+=1;i+=Dp(e.subarray(d,d+1)),d+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:a,presentationTimeDelta:s,eventDuration:o,id:l,payload:e.subarray(d,e.byteLength)}}(e);if(ib.test(i.schemeIdUri)){const e=nb(i,t);let n=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;n<=.001&&(n=Number.POSITIVE_INFINITY);const s=i.payload;r.samples.push({data:s,len:s.byteLength,dts:e,pts:e,type:Uy.emsg,duration:n})}else if(this.config.enableEmsgKLVMetadata&&i.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const e=nb(i,t);r.samples.push({data:i.payload,len:i.payload.byteLength,dts:e,pts:e,type:Uy.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 Zf{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:n,video:s}=this.initData=$p(e);if(t)!function(e,t){if(!e||!t)return;const r=t.keyId;r&&t.isCommonEncryption&&Hp(e,(e,t)=>{const i=e.subarray(8,24);i.some(e=>0!==e)||(np.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${lp(i)} -> ${lp(r)}`),e.set(r,8))})}(e,t);else{const e=n||s;null!=e&&e.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${e.codec}")!`)}n&&(r=_b(n,Ep,this)),s&&(i=_b(s,wp,this));const a={};n&&s?a.audiovideo={container:"video/mp4",codec:r+","+i,supplemental:s.supplemental,encrypted:s.encrypted,initSegment:e,id:"main"}:n?a.audio={container:"audio/mp4",codec:r,encrypted:n.encrypted,initSegment:e,id:"audio"}:s?a.video={container:"video/mp4",codec:i,supplemental:s.supplemental,encrypted:s.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=a}remux(e,t,r,i,n,s){var a,o;let{initPTS:l,lastEndTime:d}=this;const c={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};_f(d)||(d=this.lastEndTime=n||0);const u=t.samples;if(!u.length)return c;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."),c;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1);const p=function(e,t,r){const i={},n=Np(e,["moof","traf"]);for(let e=0;e<n.length;e++){const s=n[e],a=Np(s,["tfhd"])[0],o=_p(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 d=i[o],c=Np(s,["tfdt"])[0];if(c){const e=c[0];let t=_p(c,4);1===e&&(t===Ip?r.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(t*=Ip+1,t+=_p(c,8))),_f(t)&&(!_f(d.start)||t<d.start)&&(d.start=t)}const u=l.default,h=_p(a,0)|(null==u?void 0:u.flags);let f=(null==u?void 0:u.duration)||0;8&h&&(f=_p(a,2&h?12:8));const p=Np(s,["trun"]);let m=d.start||0,g=0,v=f;for(let e=0;e<p.length;e++){const t=p[e],r=_p(t,4),i=d.sampleCount;d.sampleCount+=r;const n=1&t[3],s=4&t[3],a=1&t[2],o=2&t[2],l=4&t[2],c=8&t[2];let u=8,h=r;for(n&&(u+=4),s&&r&&(1&t[u+1]||void 0!==d.keyFrameIndex||(d.keyFrameIndex=i),u+=4,a?(v=_p(t,u),u+=4):v=f,o&&(u+=4),c&&(u+=4),m+=v,g+=v,h--);h--;)a?(v=_p(t,u),u+=4):v=f,o&&(u+=4),l&&(1&t[u+1]||void 0===d.keyFrameIndex&&(d.keyFrameIndex=d.sampleCount-(h+1),d.keyFrameStart=m),u+=4),c&&(u+=4),m+=v,g+=v;!g&&f&&(g+=f*r)}d.duration+=g}if(!Object.keys(i).some(e=>i[e].duration)){let t=1/0,r=0;const n=Np(e,["sidx"]);for(let e=0;e<n.length;e++){const i=Fp(n[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&&_f(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=Cb(g,1/0),y=Cb(m,1/0),b=Cb(g,0,!0),E=Cb(m,0,!0);let w=n,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-n*e,r=T?f.audio.id:f.video.id;w=x.start/e,S=T?E-y:b-v,!s&&l||!function(e,t,r,i){if(null===e)return!0;const n=Math.max(i,1),s=t-e.baseTime/e.timescale;return Math.abs(s-r)>n}(l,w,n,S)&&e===l.timescale||(l&&this.warn(`Timestamps at playlist time: ${s?"":"~"}${n} ${t/e} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${n} offset: ${w-n} (${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: ${n}`);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};c.audio=L&&!I?P:void 0,c.video=I?P:void 0;const D=null==g?void 0:g.sampleCount;if(D){const e=g.keyFrameIndex,t=-1!==e;P.nb=D,P.dropped=0===e||this.isVideoContiguous?0:t?e:D,P.independent=t,P.firstKeyFrame=e,t&&g.keyFrameStart&&(P.firstKeyFramePTS=(g.keyFrameStart-l.baseTime)/l.timescale),this.isVideoContiguous||(c.independent=t),this.isVideoContiguous||(this.isVideoContiguous=t),P.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${e}/${D} dropped: ${P.dropped} start: ${P.firstKeyFramePTS||"NA"}`)}return c.initSegment=h,c.id3=Pb(r,n,l,l),i.samples.length&&(c.text=Db(i,n,l)),c}}},{demux:ub,remux:Ib},{demux:class extends Gy{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=Sy(e,0);let i=(null==r?void 0:r.length)||0;if(Jy(e,i))return!1;for(let r=e.length;i<r;i++)if(Ly(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)&&Ty(e,t)&&Ay(e,t)<=e.length-t}(e,t)}appendFrame(e,t,r){Iy(e,this.observer,t,r,e.manifestCodec);const i=Py(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}},remux:Ib},{demux:class extends Gy{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=Sy(e,0);let r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==By(t)&&eb(e,r)<=16)return!1;for(let t=e.length;r<t;r++)if(Jy(e,r))return np.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return Qy(e,t)&&4<=e.length-t}(e,t)}appendFrame(e,t,r){if(null!==this.basePTS)return qy(e,t,r,this.basePTS,this.frameIndex)}},remux:Ib}];Ob.splice(2,0,{demux:tb,remux:Ib});class Mb{constructor(e,t,r,i,n,s){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=n,this.logger=s}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,i){const n=r.transmuxing;n.executeStart=xb();let s=new Uint8Array(e);const{currentTransmuxState:a,transmuxConfig:o}=this;i&&(this.currentTransmuxState=i);const{contiguous:l,discontinuity:d,trackSwitch:c,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}(s,t);if(b&&Yg(b.method)){const e=this.getDecrypter(),t=Kg(b.method);if(!e.isSync())return this.asyncResult=!0,this.decryptionPromise=e.webCryptoDecrypt(s,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(s,b.key.buffer,b.iv.buffer,t);if(r.part>-1){const t=e.flush();i=t?t.buffer:t}if(!i)return n.executeEnd=xb(),Nb(r);s=new Uint8Array(i)}}const E=this.needsProbing(d,c);if(E){const e=this.configureTransmuxer(s);if(e)return this.logger.warn(`[transmuxer] ${e.message}`),this.observer.emit($f.ERROR,$f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),n.executeEnd=xb(),Nb(r)}(d||c||f||E)&&this.resetInitSegment(y,p,m,v,t),(d||f||E)&&this.resetInitialTimestamp(g),l||this.resetContiguity();const w=this.transmux(s,b,h,u,r);this.asyncResult=Fb(w);const S=this.currentTransmuxState;return S.contiguous=!0,S.discontinuity=!1,S.trackSwitch=!1,n.executeEnd=xb(),w}flush(e){const t=e.transmuxing;t.executeStart=xb();const{decrypter:r,currentTransmuxState:i,decryptionPromise:n}=this;if(n)return this.asyncResult=!0,n.then(()=>this.flush(e));const s=[],{timeOffset:a}=i;if(r){const t=r.flush();t&&s.push(this.push(t.buffer,null,e))}const{demuxer:o,remuxer:l}=this;if(!o||!l){t.executeEnd=xb();const r=[Nb(e)];return this.asyncResult?Promise.resolve(r):r}const d=o.flush(a);return Fb(d)?(this.asyncResult=!0,d.then(t=>(this.flushRemux(s,t,e),s))):(this.flushRemux(s,d,e),this.asyncResult?Promise.resolve(s):s)}flushRemux(e,t,r){const{audioTrack:i,videoTrack:n,id3Track:s,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===jf?"level":"track"} ${r.level}`);const d=this.remuxer.remux(i,n,s,a,l,o,!0,this.id);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=xb()}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,n){const{demuxer:s,remuxer:a}=this;s&&a&&(s.resetInitSegment(e,t,r,i),a.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,i,n){let s;return s=t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,n):this.transmuxUnencrypted(e,r,i,n),s}transmuxUnencrypted(e,t,r,i){const{audioTrack:n,videoTrack:s,id3Track:a,textTrack:o}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,s,a,o,t,r,!1,this.id),chunkMeta:i}}transmuxSampleAes(e,t,r,i,n){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:n}))}configureTransmuxer(e){const{config:t,observer:r,typeSupported:i}=this;let n;for(let t=0,r=Ob.length;t<r;t++){var s;if(null!=(s=Ob[t].demux)&&s.probe(e,this.logger)){n=Ob[t];break}}if(!n)return new Error("Failed to find demuxer by probing fragment data");const a=this.demuxer,o=this.remuxer,l=n.remux,d=n.demux;o&&o instanceof l||(this.remuxer=new l(r,t,i,this.logger)),a&&a instanceof d||(this.demuxer=new d(r,t,i,this.logger),this.probe=d.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Tg(this.config)),e}}const Nb=e=>({remuxResult:{},chunkMeta:e});function Fb(e){return"then"in e&&e.then instanceof Function}class $b{constructor(e,t,r,i,n){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=n||null}}class Bb{constructor(e,t,r,i,n,s){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=n,this.initSegmentChange=s}}let Ub=0;class zb{constructor(e,t,r,i){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Ub++,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($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})};const n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;const s=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===$f.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new gy,this.observer.on($f.FRAG_DECRYPTED,s),this.observer.on($f.ERROR,s);const a=pm(n.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){const r=this.hls.logger;if(n.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{n.workerPath?(r.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=function(e){const t=yy[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 yy[e]=i,i}(n.workerPath)):(r.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){const e=yy[vy];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 yy[vy]=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:_m(n)})}catch(i){r.warn(`Error setting up "${t}" Web Worker, fallback to inline`,i),this.terminateWorker(),this.error=null,this.transmuxer=new Mb(this.observer,a,n,"",t,e.logger)}return}}this.transmuxer=new Mb(this.observer,a,n,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=Ub++;const t=this.hls.config,r=pm(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:_m(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=yy[e||vy];if(t&&1===t.clientCount--){const{worker:r,objectURL:i}=t;delete yy[e||vy],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,n,s,a,o,l,d){var c,u;l.transmuxing.start=self.performance.now();const{instanceNo:h,transmuxer:f}=this,p=s?s.start:n.start,m=n.decryptdata,g=this.frag,v=!(g&&n.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===n.stats.parsing.start)&&(n.stats.parsing.start=T),!s||!E&&S||(s.stats.parsing.start=T);const x=!(g&&(null==(c=n.initSegment)?void 0:c.url)===(null==(u=g.initSegment)?void 0:u.url)),A=new Bb(v,S,o,y,p,x);if(!S||v||x){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${n.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id===jf?"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 $b(r,i,t,a,d);this.configureTransmuxer(e)}if(this.frag=n,this.part=s,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);Fb(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);Fb(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($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.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 Gb extends Zf{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 n=-1;for(let r=0;r<i.length;r++){const s=i[r];let a;try{a=new self.URL(s.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),a=s.URI||""}if(a===e){n=r;break}a===e.substring(0,a.length)&&(n=r)}if(-1!==n){const e=i[n],s=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&&Im(r);return new Rm(s,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:n}=t,s=self.performance.now(),a=n.loading.first?Math.max(0,s-n.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){_v(r,i,this);const e=i.playlistParsingError;if(e){this.warn(e);const r=this.hls;if(!r.config.ignorePlaylistParsingErrors){var l;const{networkDetails:s}=t;return void r.trigger($f.ERROR,{type:Nf.NETWORK_ERROR,details:Ff.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:s,stats:n})}i.playlistParsingError=null}}-1===i.requestScheduled&&(i.requestScheduled=n.loading.start);const d=this.hls.mainForwardBufferInfo,c=d?d.end-d.len:0,u=Fv(i,1e3*(i.edge-c));if(i.requestScheduled+u<s?i.requestScheduled=s: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,n=i.lastPartSn,a=i.endSN,l=i.lastPartIndex,d=n===a;-1!==l?d?(f=a+1,p=e?0:l):(f=n,p=e?l+1:i.maxPartIndex):f=a+1;const c=i.age,u=c+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 ${c.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 ${c.toFixed(2)}s goal: ${m} skip sn ${e} to part ${p}`)}i.tuneInGoal=m}if(h=this.getDeliveryDirectives(i,t.deliveryDirectives,f,p),e||!d)return i.requestScheduled=s,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=n.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 n=self.performance.now(),s=i.requestScheduled;if(n>=s)return void this.loadingPlaylist(e,t);const a=s-n;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 n=Im(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=Am),new Rm(r,i,n)}checkRetry(e){const t=e.details,r=Ym(e),i=e.errorAction,{action:n,retryCount:s=0,retryConfig:a}=i||{},o=!!i&&!!a&&(n===ng||!i.resolved&&n===rg);if(o){var l;if(s>=a.maxNumRetry)return!1;if(r&&null!=(l=e.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const e=Qm(a,s);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),e),this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,i.resolved=!0}return o}}function jb(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Hb(e[r].attrs,t[r].attrs))return!1;return!0}function Hb(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 Vb(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}class Wb{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 n=null==(r=this.tracks[e])?void 0:r.buffer;null!=n&&n.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 Yb=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Kb="HlsJsTrackRemovedError";class qb extends Error{constructor(e){super(e),this.name=Kb}}function Xb(e){const t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function Qb(e){return"audio"===e?1:0}class Zb{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($f.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on($f.MANIFEST_PARSED,this.onManifestParsed,this),e.on($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on($f.BUFFER_CODECS,this.onBufferCodecs,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off($f.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off($f.MANIFEST_PARSED,this.onManifestParsed,this),e.off($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off($f.BUFFER_CODECS,this.onBufferCodecs,this),e.off($f.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&&_f(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,Zb.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 n=e.length-1;const s=Math.max(t,r);for(let t=0;t<e.length;t+=1){const r=e[t];if((r.width>=s||r.height>=s)&&i(r,e[t+1])){n=t;break}}return n}}const Jb={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},eE={HLS:"h"};class tE{constructor(e,t){Array.isArray(e)&&(e=e.map(e=>e instanceof tE?e:new tE(e))),this.value=e,this.params=t}}function rE(e,t,r,i){return new Error(`failed to ${e} "${n=t,Array.isArray(n)?JSON.stringify(n):n instanceof Map?"Map{}":n instanceof Set?"Set{}":"object"==typeof n?JSON.stringify(n):String(n)}" as ${r}`,{cause:i});var n}function iE(e,t,r){return rE("serialize",e,t,r)}class nE{constructor(e){this.description=e}}const sE="Bare Item";function aE(e){if(!1===ArrayBuffer.isView(e))throw iE(e,"Byte Sequence");return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function oE(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw iE(e,"Integer");return e.toString()}function lE(e,t){if(e<0)return-lE(-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 dE(e){const t=lE(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw iE(e,"Decimal");const r=t.toString();return r.includes(".")?r:`${r}.0`}const cE=/[\x00-\x1f\x7f]+/;function uE(e){const t=(r=e).description||r.toString().slice(7,-1);var r;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw iE(t,"Token");return t}function hE(e){switch(typeof e){case"number":if(!_f(e))throw iE(e,sE);return Number.isInteger(e)?oE(e):dE(e);case"string":return function(e){if(cE.test(e))throw iE(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return uE(e);case"boolean":return function(e){if("boolean"!=typeof e)throw iE(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${oE(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return aE(e);if(e instanceof nE)return uE(e);default:throw iE(e,sE)}}function fE(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw iE(e,"Key");return e}function pE(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${fE(e)}`:`;${fE(e)}=${hE(t)}`).join("")}function mE(e){return e instanceof tE?`${hE(e.value)}${pE(e.params)}`:hE(e)}function gE(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw iE(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 tE==!1&&(t=new tE(t));let r=fE(e);var i;return!0===t.value?r+=pE(t.params):(r+="=",Array.isArray(t.value)?r+=`(${(i=t).value.map(mE).join(" ")})${pE(i.params)}`:r+=mE(t)),r}).join(`,${i}`)}function vE(e,t){return gE(e,t)}const yE="CMCD-Object",bE="CMCD-Request",EE="CMCD-Session",wE="CMCD-Status",SE={br:yE,ab:yE,d:yE,ot:yE,tb:yE,tpb:yE,lb:yE,tab:yE,lab:yE,url:yE,pb:bE,bl:bE,tbl:bE,dl:bE,ltc:bE,mtp:bE,nor:bE,nrr:bE,rc:bE,sn:bE,sta:bE,su:bE,ttfb:bE,ttfbb:bE,ttlb:bE,cmsdd:bE,cmsds:bE,smrt:bE,df:bE,cs:bE,ts:bE,cid:EE,pr:EE,sf:EE,sid:EE,st:EE,v:EE,msd:EE,bs:wE,bsd:wE,cdn:wE,rtp:wE,bg:wE,pt:wE,ec:wE,e:wE},TE=bE;function xE(e,t){const r={};if(!e)return r;const i=Object.keys(e),n=t?(s=t,Object.keys(s).reduce((e,t)=>{var r;return null===(r=s[t])||void 0===r||r.forEach(r=>e[r]=t),e},{})):{};var s;return i.reduce((t,r)=>{var i;const s=SE[r]||n[r]||TE;return(null!==(i=t[s])&&void 0!==i?i:t[s]={})[r]=e[r],t},r)}const AE="event";const kE=e=>Math.round(e),LE=(e,t)=>Array.isArray(e)?e.map(e=>LE(e,t)):e instanceof tE&&"string"==typeof e.value?new tE(LE(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 n=r.pathname.split("/").slice(1),s=i.pathname.split("/").slice(1,-1);for(;n[0]===s[0];)n.shift(),s.shift();for(;s.length;)s.shift(),n.unshift("..");return n.join("/")+r.search+r.hash}(e,t.baseUrl)),1===t.version?encodeURIComponent(e):e),IE=e=>100*kE(e/100),RE={br:kE,d:kE,bl:IE,dl:IE,mtp:IE,nor:(e,t)=>{let r=e;return t.version>=2&&(e instanceof tE&&"string"==typeof e.value?r=new tE([e]):"string"==typeof e&&(r=[e])),LE(r,t)},rtp:IE,tb:kE},PE="request",DE="response",CE=["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"],_E=["e"],OE=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function ME(e){return OE.test(e)}const NE=["d","dl","nor","ot","rtp","su"];const FE=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];const $E=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function BE(e){return $E.includes(e)||ME(e)}const UE={[DE]:function(e){return CE.includes(e)||NE.includes(e)||FE.includes(e)||ME(e)},[AE]:function(e){return CE.includes(e)||_E.includes(e)||ME(e)},[PE]:function(e){return CE.includes(e)||NE.includes(e)||ME(e)}};function zE(e,t={}){const r={};if(null==e||"object"!=typeof e)return r;const i=t.version||e.v||1,n=t.reportingMode||PE,s=1===i?BE:UE[n];let a=Object.keys(e).filter(s);const o=t.filter;"function"==typeof o&&(a=a.filter(o));const l=n===DE||n===AE;l&&!a.includes("ts")&&a.push("ts"),i>1&&!a.includes("v")&&a.push("v");const d=qf({},RE,t.formatters),c={version:i,reportingMode:n,baseUrl:t.baseUrl};return a.sort().forEach(t=>{let n=e[t];const s=d[t];if("function"==typeof s&&(n=s(n,c)),"v"===t){if(1===i)return;n=i}"pr"==t&&1===n||(l&&"ts"===t&&!_f(n)&&(n=Date.now()),function(e){return"number"==typeof e?_f(e):null!=e&&""!==e&&!1!==e}(n)&&(function(e){return["ot","sf","st","e","sta"].includes(e)}(t)&&"string"==typeof n&&(n=new nE(n)),r[t]=n))}),r}function GE(e,t,r){return qf(e,function(e,t={}){const r={};if(!e)return r;const i=xE(zE(e,t),null==t?void 0:t.customHeaderMap);return Object.entries(i).reduce((e,[t,r])=>{const i=vE(r,{whitespace:!1});return i&&(e[t]=i),e},r)}(t,r))}function jE(e,t={}){if(!e)return"";const r=function(e,t={}){return e?vE(zE(e,t),{whitespace:!1}):""}(e,t);return encodeURIComponent(r)}const HE=/CMCD=[^&#]+/;function VE(e,t,r){const i=function(e,t={}){return e?`CMCD=${jE(e,t)}`:""}(t,r);if(!i)return e;if(HE.test(e))return e.replace(HE,i);const n=e.includes("?")?"&":"?";return`${e}${n}${i}`}function WE(e,t,r,i){e&&Object.keys(t).forEach(n=>{const s=e.filter(e=>e.groupId===n).map(e=>{const s=qf({},e);return s.details=void 0,s.attrs=new Ug(s.attrs),s.url=s.attrs.URI=YE(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),s.groupId=s.attrs["GROUP-ID"]=t[n],s.attrs["PATHWAY-ID"]=i,s});e.push(...s)})}function YE(e,t,r,i){const{HOST:n,PARAMS:s,[r]:a}=i;let o;t&&(o=null==a?void 0:a[t],o&&(e=o));const l=new self.URL(e);return n&&!o&&(l.host=n),s&&Object.keys(s).sort().forEach(e=>{e&&l.searchParams.set(e,s[e])}),l.href}class KE extends Zf{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=KE.CDMCleanupPromise?[KE.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=ov(this.config));const t=e.map(av).filter(e=>!!e);this.keyFormatPromise=this.getKeyFormatPromise(t)}this.keyFormatPromise.then(n=>{const s=sv(n);if("sinf"!==t||s!==ev.FAIRPLAY)return void this.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${s}`);let a;try{const e=Dp(new Uint8Array(r)),t=Vp(qg(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=lp(a),{keyIdToKeySessionPromise:l,mediaKeySessions:d}=this;let c=l[o];for(let e=0;e<d.length;e++){const i=d[e],n=i.decryptdata;if(!n.keyId)continue;const s=lp(n.keyId);if(Vg(a,n.keyId)||-1!==n.uri.replace(/-/g,"").indexOf(o)){if(c=l[s],!c)continue;if(n.pssh)break;delete l[s],n.pssh=new Uint8Array(r),n.keyId=a,c=l[o]=c.then(()=>this.generateRequestWithPreferredKeySession(i,t,r,"encrypted-event-key-match")),c.catch(e=>this.handleError(e));break}}c||this.handleError(new Error(`Key ID ${o} not encountered in playlist. Key-system sessions ${d.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($f.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on($f.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on($f.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on($f.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on($f.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off($f.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off($f.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off($f.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off($f.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===ev.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),n=t.map(e=>e.videoCodec).filter(r);return i.length+n.length===0&&n.push("avc1.42e01e"),new Promise((t,r)=>{const s=e=>{const a=e.shift();this.getMediaKeysPromise(a,i,n).then(e=>t({keySystem:a,mediaKeys:e})).catch(t=>{e.length?s(e):r(t instanceof QE?t:new QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};s(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:r}=this.config;if("function"!=typeof r){let e=`Configured requestMediaKeySystemAccess is not a function ${r}`;return null===lv&&"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 n=function(e,t,r,i){let n;switch(e){case ev.FAIRPLAY:n=["cenc","sinf"];break;case ev.WIDEVINE:case ev.PLAYREADY:n=["cenc"];break;case ev.CLEARKEY:n=["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}))}]}(n,t,r,i)}(e,t,r,this.config.drmSystemOptions||{});let s=this.keySystemAccessPromises[e],a=null==(i=s)?void 0:i.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${_m(n)}`),a=this.requestMediaKeySystemAccess(e,n);const t=s=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 n=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 n.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),n})}return a.then(()=>s.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${lp(e.keyId||[])} keyUri: ${e.uri}`);const i=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const r=this.createMediaKeySessionContext(e),i=qE(t),n="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,n,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 ${lp(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})=>av(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=av(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=ov(this.config),r=e.map(sv).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=XE(e,t[r]);if(i)return i}}loadKey(e){const t=e.keyInfo.decryptdata,r=qE(t),i=this.bannedKeyIds[r];if(i||"internal-error"===this.getKeyStatus(t)){const r=ZE(i||"internal-error",t);return this.handleError(r,e.frag),Promise.reject(r)}const n=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${n}`);const s=this.keyIdToKeySessionPromise[r];if(!s){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 ${n}`),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 s.catch(r=>{if(r instanceof QE){const i=Qf({},r.data);"internal-error"===this.getKeyStatus(t)&&(i.decryptdata=t);const n=new QE(i,r.message);this.handleError(n,e.frag)}}),s}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof QE){t&&(e.data.frag=t);const r=e.data.decryptdata;this.error(`${e.message}${r?` (${lp(r.keyId||[])})`:""}`),this.hls.trigger($f.ERROR,e.data)}else this.error(e.message),this.hls.trigger($f.ERROR,{type:Nf.KEY_SYSTEM_ERROR,details:Ff.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){const t=qE(e),r=this.keyIdToKeySessionPromise[t];if(!r){const t=sv(e.keyFormat),r=t?[t]:ov(this.config);return this.attemptKeySystemAccess(r)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=ov(this.config)),0===e.length)throw new QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${_m({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 n;const s=null==(n=this.config.drmSystems)||null==(n=n[e.keySystem])?void 0:n.generateRequest;if(s)try{const i=s.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=qE(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 gy,d=e._onmessage=t=>{const r=e.mediaKeysSession;if(!r)return void l.emit("error",new Error("invalid state"));const{messageType:i,message:n}=t;this.log(`"${i}" message event for session "${r.sessionId}" message size: ${n.byteLength}`),"license-request"===i||"license-renewal"===i?this.renewLicense(e,n).catch(e=>{l.eventNames().length?l.emit("error",e):this.handleError(e)}):"license-release"===i?e.keySystem===ev.FAIRPLAY&&this.updateKeySession(e,Xg("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${i}"`)},c=(e,t)=>{let r;t.keyStatus=e,e.startsWith("usable")?l.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?r=ZE(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 ${_m(r)} in key-session "${e.mediaKeysSession.sessionId}"`),void this.renewKeySession(e);let i=r[a];if(i)c(i,e);else{var n;const t=1e3;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(n=e.keyStatusTimeouts)[a]||(n[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.`),c(r,e);this.log(`key status for ${a} in key-session "${e.mediaKeysSession.sessionId}" timed out after ${t}ms`),i="internal-error",c(i,e)},t)),this.log(`No status for keyId ${a} (${_m(r)}).`)}};qv(e.mediaKeysSession,"message",d),qv(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 QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.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 n="buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i);if(e.keySystem===ev.PLAYREADY&&16===n.length){const e=lp(n);t[e]=r,Qg(n)}const s=lp(n);"internal-error"===r&&(this.bannedKeyIds[s]=r),this.log(`key status change "${r}" for keyStatuses keyId: ${s} key-session "${e.mediaKeysSession.sessionId}"`),t[s]=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((n,s)=>{const a={responseType:"arraybuffer",url:i},o=t.certLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(e,t,r,i)=>{n(e.data)},onError:(t,r,n,o)=>{s(new QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:Qf({url:a.url,data:void 0},t)},`"${e}" certificate request failed (${i}). Status: ${t.code} (${t.text})`))},onTimeout:(t,r,n)=>{s(new QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:{url:a.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(e,t,r)=>{s(new Error("aborted"))}};r.load(a,l,d)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((i,n)=>{e.setServerCertificate(r).then(n=>{this.log(`setServerCertificate ${n?"success":"not supported by CDM"} (${r.byteLength}) on "${t}"`),i(e)}).catch(e=>{n(new QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.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 QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.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"),n=i.querySelectorAll("HttpHeader");if(n.length>0){let t;for(let r=0,i=n.length;r<i;r++){var s,a;t=n[r];const i=null==(s=t.querySelector("name"))?void 0:s.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 Xg(atob(l))}setupLicenseXHR(e,t,r,i){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,i)}).catch(s=>{if(!r.decryptdata)throw s;return e.open("POST",t,!0),n.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,n)=>{const s=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${s}`);const a=new XMLHttpRequest;a.responseType="arraybuffer",a.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(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,s,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)n(new QE({type:Nf.KEY_SYSTEM_ERROR,details:Ff.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:a,response:{url:s,data:void 0,code:a.status,text:a.statusText}},`License Request XHR failed (${s}). 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,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=a,this.setupLicenseXHR(a,s,e,t).then(({xhr:t,licenseChallenge:r})=>{e.keySystem==ev.PLAYREADY&&(r=this.unpackPlayReadyKeyMessage(t,r)),t.send(r)}).catch(n)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const r=t.media;this.media=r,qv(r,"encrypted",this.onMediaEncrypted),qv(r,"waitingforkey",this.onWaitingForKey);const i=this.mediaResolved;i?i():this.mediaKeys=r.mediaKeys}onMediaDetached(){const e=this.media;e&&(Xv(e,"encrypted",this.onMediaEncrypted),Xv(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,hv.clearKeyUriToKeyIdMap();const n=i.length;KE.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($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.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($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${e}`)})}).then(()=>{n&&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: ${lp((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 n=this.mediaKeySessions.indexOf(e);n>-1&&this.mediaKeySessions.splice(n,1);const{keyStatusTimeouts:s}=e;s&&Object.keys(s).forEach(e=>self.clearTimeout(s[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($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.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($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}function qE(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return lp(e.keyId)}function XE(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}KE.CDMCleanupPromise=void 0;class QE 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 ZE(e,t){const r="output-restricted"===e,i=r?Ff.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:Ff.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new QE({type:Nf.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:t},r?"HDCP level output restricted":`key status changed to "${e}"`)}function JE(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 ew(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){np.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){np.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===r&&(e.mode=r)}function tw(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 rw(e,t,r,i){const n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0){const n=function(e,t,r){const i=[],n=function(e,t){if(t<=e[0].startTime)return 0;const r=e.length-1;if(t>e[r].endTime)return-1;let i,n=0,s=r;for(;n<=s;)if(i=Math.floor((s+n)/2),t<e[i].startTime)s=i-1;else{if(!(t>e[i].startTime&&n<r))return i;n=i+1}return e[n].startTime-t<t-e[s].startTime?n:s}(e,t);if(n>-1)for(let s=n,a=e.length;s<a;s++){const n=e[s];if(n.startTime>=t&&n.endTime<=r)i.push(n);else if(n.startTime>r)return i}return i}(e.cues,t,r);for(let t=0;t<n.length;t++)i&&!i(n[t])||e.removeCue(n[t])}"disabled"===n&&(e.mode=n)}function iw(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 nw(e){let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}const sw=.025;let aw=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function ow(e,t,r){return`${e.identifier}-${r+1}-${nw(t)}`}class lw{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 dw(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-dw(t,e)<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=_f(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 dw(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)<sw))}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"]?aw.Range:aw.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 dw(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<sw)?t.start:t.start+t.duration}function cw(e,t,r){const i=new self.URL(e,r);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function uw(e,t){for(;null!=(r=e.assetList[++t])&&r.error;)var r;return t}function hw(e){const t=e.timelineStart,r=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+r).toFixed(2)}]`}class fw{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($f.PLAYOUT_LIMIT_REACHED,{})};const n=this.hls=new e(t);this.interstitial=r,this.assetItem=i;const s=()=>{this.hasDetails=!0};n.once($f.LEVEL_LOADED,s),n.once($f.AUDIO_TRACK_LOADED,s),n.once($f.SUBTITLE_TRACK_LOADED,s),n.on($f.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t;this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&n.on($f.BUFFER_APPENDED,()=>{const e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,n.trigger($f.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=cw(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,n=Cg.bufferInfo(e,i,0);return this.getAssetTime(n.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=Cg.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: ${hw(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}class pw extends Zf{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!=(n=i[r])&&n.event;){var n;r--}return r}findItemIndexAtTime(e,t){const r=this.items;if(r)for(let i=0;i<r.length;i++){let n=r[i];if(t&&"primary"!==t&&(n=n[t]),e===n.start||e>n.start&&e<n.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 n=r[e];if(!n.error){const r=n.timelineStart;if(t===r||t>r&&(t<r+(n.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,n=this.events,s=this.parseDateRanges(i,{url:r.url},t),a=Object.keys(i),o=n?n.filter(e=>!a.includes(e.identifier)):[];s.length&&s.sort((e,t)=>{const r=e.cue.pre,i=e.cue.post,n=t.cue.pre,s=t.cue.post;if(r&&!n)return-1;if(n&&!r)return 1;if(i&&!s)return 1;if(s&&!i)return-1;if(!(r||n||i||s)){const r=e.startTime,i=t.startTime;if(r!==i)return r-i}return e.dateRange.tagOrder-t.dateRange.tagOrder}),this.events=s,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 n=this.items,s=this.parseSchedule(i,e),a=r||t.length||(null==n?void 0:n.length)!==s.length||s.some((e,t)=>Math.abs(e.playout.start-n[t].playout.start)>.005||Math.abs(e.playout.end-n[t].playout.end)>.005);a&&(this.items=s,this.onScheduleUpdate(t,n))}}parseDateRanges(e,t,r){const i=[],n=Object.keys(e);for(let s=0;s<n.length;s++){const a=n[s],o=e[a];if(o.isInterstitial){let e=this.eventMap[a];e?e.setDateRange(o):(e=new lw(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,n=i.live?1/0:i.edge;let s=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,d=t.cue.post,c=e[a-1]||null,u=t.appendInPlace,h=d?n:t.startOffset,f=t.duration,p=t.timelineOccupancy===aw.Range?f:0,m=t.resumptionOffset,g=(null==c?void 0:c.startTime)===h,v=h+t.cumulativeDuration;let y=u?v+f:h+m;if(l||!d&&h<=0){const e=o;o+=p,t.timelineStart=v;const i=s;s+=f,r.push({event:t,start:v,end:y,playout:{start:i,end:s},integrated:{start:e,end:o}})}else{if(!(h<=n))return;{if(!g){const n=h-i;if(n>.033){const l=i,d=o;o+=n;const c=s;s+=n;const u={previousEvent:e[a-1]||null,nextEvent:t,start:l,end:l+n,playout:{start:c,end:s},integrated:{start:d,end:o}};r.push(u)}else n>0&&c&&(c.cumulativeDuration+=n,r[r.length-1].end=h)}d&&(y=v),t.timelineStart=v;const n=o;o+=p;const l=s;s+=f,r.push({event:t,start:v,end:y,playout:{start:l,end:s},integrated:{start:n,end:o}})}}const b=t.resumeTime;i=d||b>n?n:b}),i<n){var a;const e=i,t=o,l=n-i;o+=l;const d=s;s+=l,r.push({previousEvent:(null==(a=r[r.length-1])?void 0:a.event)||null,nextEvent:null,start:i,end:e+l,playout:{start:d,end:s},integrated:{start:t,end:o}})}this.setDurations(n,s,o)}else{const e=0;r.push({previousEvent:null,nextEvent:null,start:e,end:n,playout:{start:e,end:n},integrated:{start:e,end:n}}),this.setDurations(n,n,n)}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 n=0,s=-1;e.forEach((a,o)=>{const l=a.cue.pre,d=a.cue.post,c=l?0:d?i:a.startTime;this.updateAssetDurations(a);if(s===c?a.cumulativeDuration=n:(n=0,s=c),!d&&a.snapOptions.in&&(a.resumeAnchor=jm(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=_f(a.resumeOffset)?a.resumeOffset:a.duration;n+=u})}primaryCanResumeInPlaceAt(e,t){const r=e.resumeTime,i=e.startTime+e.resumptionOffset;if(Math.abs(r-i)>sw)return this.log(`"${e.identifier}" resumption ${r} not aligned with estimated timeline end ${i}`),!1;return!Object.keys(t).some(i=>{const n=t[i].details,s=n.edge;if(r>=s)return this.log(`"${e.identifier}" resumption ${r} past ${i} playlist end ${s}`),!1;const a=jm(null,n.fragments,r);if(!a)return this.log(`"${e.identifier}" resumption ${r} does not align with any fragments in ${i} playlist (${n.fragStart}-${n.fragmentEnd})`),!0;const o="audio"===i?.175:0;return!(Math.abs(a.start-r)<sw+o||Math.abs(a.end-r)<sw+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,n=!1;for(let s=0;s<e.assetList.length;s++){const a=e.assetList[s],o=t+r;a.startOffset=r,a.timelineStart=o,i||(i=null===a.duration),n||(n=!!a.error);r+=a.error?0:a.duration||0}e.duration=i&&!n?Math.max(r,e.duration):r}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function mw(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}class gw{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const r=e.assetListUrl;let i;try{i=cw(r,this.hls.sessionId,e.baseUrl)}catch(t){const i=this.assignAssetListError(e,Ff.ASSET_LIST_LOAD_ERROR,t,r);return void this.hls.trigger($f.ERROR,i)}t&&"data:"!==i.protocol&&i.searchParams.set("_HLS_start_offset",""+t);const n=this.hls.config,s=new(0,n.loader)(n),a={responseType:"json",url:i.href},o=n.interstitialAssetListLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(t,r,i,n)=>{const s=t.data,a=null==s?void 0:s.ASSETS;if(!Array.isArray(a)){const t=this.assignAssetListError(e,Ff.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),i.url,r,n);return void this.hls.trigger($f.ERROR,t)}e.assetListResponse=s,this.hls.trigger($f.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:n})},onError:(t,r,i,n)=>{const s=this.assignAssetListError(e,Ff.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${r.url})`),r.url,n,i);this.hls.trigger($f.ERROR,s)},onTimeout:(t,r,i)=>{const n=this.assignAssetListError(e,Ff.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${r.url})`),r.url,t,i);this.hls.trigger($f.ERROR,n)}};return s.load(a,l,d),this.hls.trigger($f.ASSET_LIST_LOADING,{event:e}),s}assignAssetListError(e,t,r,i,n,s){return e.error=r,{type:Nf.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:r,networkDetails:s,stats:n}}}function vw(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function yw(e,t){return`[${e}] Advancing timeline position to ${t}`}class bw{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 Ew={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},ww=e=>String.fromCharCode(Ew[e]||e),Sw=15,Tw=100,xw={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Aw={17:2,18:4,21:6,22:8,23:10,19:13,20:15},kw={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Lw={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Iw=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Rw{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const r="function"==typeof t?t():t;np.log(`${this.time} [${e}] ${r}`)}}}const Pw=function(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t};class Dw{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 Cw{constructor(){this.uchar=" ",this.penState=new Dw}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 _w{constructor(e){this.chars=[],this.pos=0,this.currPenState=new Dw,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<Tw;e++)this.chars.push(new Cw);this.logger=e}equals(e){for(let t=0;t<Tw;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Tw;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Tw;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>Tw&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Tw)}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=ww(e);this.pos>=Tw?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<Tw;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<Tw;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 Ow{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Sw;t++)this.rows.push(new _w(e));this.logger=e}reset(){for(let e=0;e<Sw;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let r=0;r<Sw;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<Sw;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Sw;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 = "+_m(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<Sw;e++)this.rows[e].clear();const e=this.currRow+1-this.nrRollUpRows,r=this.lastOutputScreen;if(r){const i=r.rows[e].cueStartTime,n=this.logger.time;if(null!==i&&null!==n&&i<n)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 = "+_m(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<Sw;r++){const n=this.rows[r].getTextString();n&&(i=r+1,e?t.push("Row "+i+": '"+n+"'"):t.push(n.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}getTextAndFormat(){return this.rows}}class Mw{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 Ow(r),this.nonDisplayedMemory=new Ow(r),this.lastOutputScreen=new Ow(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: "+_m(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 Nw{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 Rw;this.channels=[null,new Mw(e,t,i),new Mw(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 n=!1,s=null;if(0===r&&0===i)continue;this.logger.log(3,()=>"["+Pw([t[e],t[e+1]])+"] -> ("+Pw([r,i])+")");const a=this.cmdHistory;if(r>=16&&r<=31){if($w(r,i,a)){Fw(null,null,a),this.logger.log(3,()=>"Repeated command ("+Pw([r,i])+") is dropped");continue}Fw(r,i,this.cmdHistory),n=this.parseCmd(r,i),n||(n=this.parseMidrow(r,i)),n||(n=this.parsePAC(r,i)),n||(n=this.parseBackgroundAttributes(r,i))}else Fw(null,null,a);if(!n&&(s=this.parseChars(r,i),s)){const e=this.currentChannel;if(e&&e>0){this.channels[e].insertChars(s)}else this.logger.log(2,"No channel found yet. TEXT-MODE?")}n||s||this.logger.log(2,()=>"Couldn't parse cleaned data "+Pw([r,i])+" orig: "+Pw([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 ("+Pw([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?xw[e]:kw[e]:1===i?Aw[e]:Lw[e];const n=this.channels[i];return!!n&&(n.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,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let e;e=17===n?t+80:18===n?t+112:t+144,this.logger.log(2,()=>"Special char '"+ww(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 = "+Pw(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=Iw[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));const n=e<=23?1:2;return this.channels[n].setBkgData(i),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}Fw(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 Fw(e,t,r){r.a=e,r.b=t}function $w(e,t,r){return r.a===e&&r.b===t}var Bw=function(){if(null!=Jg&&Jg.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 n(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 s(t,s,a){const o=this,l={enumerable:!0};o.hasBeenReset=!1;let d="",c=!1,u=t,h=s,f=a,p=null,m="",g=!0,v="auto",y="start",b=50,E="middle",w=50,S="middle";Object.defineProperty(o,"id",n({},l,{get:function(){return d},set:function(e){d=""+e}})),Object.defineProperty(o,"pauseOnExit",n({},l,{get:function(){return c},set:function(e){c=!!e}})),Object.defineProperty(o,"startTime",n({},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",n({},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",n({},l,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",n({},l,{get:function(){return p},set:function(e){p=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",n({},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",n({},l,{get:function(){return g},set:function(e){g=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",n({},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",n({},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",n({},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",n({},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",n({},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",n({},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 s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}();class Uw{decode(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function zw(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 Gw{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 jw(e,t,r,i){const n=i?e.split(i):[e];for(const e in n){if("string"!=typeof n[e])continue;const i=n[e].split(r);if(2!==i.length)continue;t(i[0],i[1])}}const Hw=new Bw(0,0,""),Vw="middle"===Hw.align?"middle":"center";function Ww(e,t,r){const i=e;function n(){const t=zw(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function s(){e=e.replace(/^\s+/,"")}if(s(),t.startTime=n(),s(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.slice(3),s(),t.endTime=n(),s(),function(e,t){const i=new Gw;jw(e,function(e,t){let n;switch(e){case"region":for(let n=r.length-1;n>=0;n--)if(r[n].id===t){i.set(e,r[n].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":n=t.split(","),i.integer(e,n[0]),i.percent(e,n[0])&&i.set("snapToLines",!1),i.alt(e,n[0],["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",Vw,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",Vw,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",Vw,"end","left","right"])}},/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");let n=i.get("line","auto");"auto"===n&&-1===Hw.line&&(n=-1),t.line=n,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",Vw);let s=i.get("position","auto");"auto"===s&&50===Hw.position&&(s="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=s}(e,t)}function Yw(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class Kw{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Uw,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=Yw(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){jw(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 n=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(n?n=!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 Bw(0,0,""),t.state="CUE",-1===e.indexOf("--\x3e")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Ww(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&&(n=!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 qw=/\r\n|\n\r|\n|\r/g,Xw=function(e,t,r=0){return e.slice(r,r+t.length)===t};function Qw(e,t,r){return nw(e.toString())+nw(t.toString())+nw(r)}function Zw(e,t,r,i,n,s,a){const o=new Kw,l=op(new Uint8Array(e)).trim().replace(qw,"\n").split("\n"),d=[],c=t?function(e,t=1){return wb(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 s=r[i];let a=r.ccOffset;const o=(f-c)/9e4;if(null!=s&&s.new&&(void 0!==p?a=r.ccOffset=s.start:function(e,t,r){let i=e[t],n=e[i.prevCC];if(!n||!n.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;null!=(s=n)&&s.new;){var s;e.ccOffset+=i.start-n.start,i.new=!1,i=n,n=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=Rb(9e4*(e.startTime+a-p),9e4*n)/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=Qw(e.startTime,e.endTime,m)),e.endTime>0&&d.push(e)},o.onparsingerror=function(e){u=e},o.onflush=function(){u?a(u):s(d)},l.forEach(e=>{if(m){if(Xw(e,"X-TIMESTAMP-MAP=")){m=!1,e.slice(16).split(",").forEach(e=>{Xw(e,"LOCAL:")?h=e.slice(6):Xw(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)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(_f(t)&&_f(r)&&_f(i)&&_f(n)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=6e4*i,t+=36e5*n,t}(h)/1e3}catch(e){u=e}return}""===e&&(m=!1)}o.parse(e+"\n")}),o.flush()}const Jw="stpp.ttml.im1t",eS=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,tS=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,rS={left:"start",center:"center",right:"end",start:"start",end:"end"};function iS(e,t,r,i){const n=Np(new Uint8Array(e),["mdat"]);if(0===n.length)return void i(new Error("Could not parse IMSC1 mdat"));const s=n.map(e=>op(e)),a=function(e,t,r=1,i=!1){return wb(e,t,1/r,i)}(t.baseTime,1,t.timescale);try{s.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 n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(n).reduce((e,t)=>(e[t]=i.getAttribute(`ttp:${t}`)||n[t],e),{}),a="preserve"!==i.getAttribute("xml:space"),o=sS(nS(i,"styling","style")),l=sS(nS(i,"layout","region")),d=nS(i,"body","[begin]");return[].map.call(d,e=>{const r=aS(e,a);if(!r||!e.hasAttribute("begin"))return null;const i=dS(e.getAttribute("begin"),s),n=dS(e.getAttribute("dur"),s);let d=dS(e.getAttribute("end"),s);if(null===i)throw lS(e);if(null===d){if(null===n)throw lS(e);d=i+n}const c=new Bw(i-t,d-t,r);c.id=Qw(c.startTime,c.endTime,c.text);const u=function(e,t,r){const i="http://www.w3.org/ns/ttml#styling";let n=null;const s=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;a&&r.hasOwnProperty(a)&&(n=r[a]);return s.reduce((r,s)=>{const a=oS(t,i,s)||oS(e,i,s)||oS(n,i,s);return a&&(r[s]=a),r},{})}(l[e.getAttribute("region")],o[e.getAttribute("style")],o),{textAlign:h}=u;if(h){const e=rS[h];e&&(c.lineAlign=e),c.align=h}return qf(c,u),c}).filter(e=>null!==e)}(e,a)))}catch(e){i(e)}}function nS(e,t,r){const i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function sS(e){return e.reduce((e,t)=>{const r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function aS(e,t){return[].slice.call(e.childNodes).reduce((e,r,i)=>{var n;return"br"===r.nodeName&&i?e+"\n":null!=(n=r.childNodes)&&n.length?aS(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function oS(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function lS(e){return new Error(`Could not parse ttml timestamp ${e}`)}function dS(e,t){if(!e)return null;let r=zw(e);return null===r&&(eS.test(e)?r=function(e,t){const r=eS.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):tS.test(e)&&(r=function(e,t){const r=tS.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 cS{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 uS(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function hS(e,t){return!!e&&e.kind===uS(t)&&Vb(t,e)}function fS(e,t,r,i){return Math.min(t,i)-Math.max(e,r)}const pS=/\s/,mS={newCue(e,t,r,i){const n=[];let s,a,o,l,d;const c=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(s=i.rows[h],o=!0,l=0,d="",!s.isEmpty()){var u;for(let e=0;e<s.chars.length;e++)pS.test(s.chars[e].uchar)&&o?l++:(d+=s.chars[e].uchar,o=!1);s.cueStartTime=t,t===r&&(r+=1e-4),l>=16?l--:l++;const i=Yw(d.trim()),f=Qw(t,r,i);null!=e&&null!=(u=e.cues)&&u.getCueById(f)||(a=new c(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)),n.push(a))}return e&&n.length&&(n.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),n.forEach(t=>ew(e,t))),n}};const gS=/(\d+)-(\d+)\/(\d+)/;class vS{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||yS,this.controller=new self.AbortController,this.stats=new bp}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 n=function(e,t){const r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(qf({},e.headers))};e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return r}(e,this.controller.signal),s="arraybuffer"===e.responseType,a=s?"byteLength":"length",{maxTimeToFirstByteMs:o,maxLoadTimeMs:l}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=o&&_f(o)?o:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},t.timeout);(Fb(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(r=>{var n;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 bS(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=gS.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(_f(e))return e}const r=e.get("Content-Length");if(r)return parseInt(r)}(r.headers)||i.total;const o=null==(n=this.callbacks)?void 0:n.onProgress;return o&&_f(t.highWaterMark)?this.loadProgressively(r,i,e,t.highWaterMark,o):s?r.arrayBuffer():"json"===e.responseType?r.json():r.text()}).then(r=>{var n,s;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 d={url:o.url,data:r,code:o.status},c=null==(n=this.callbacks)?void 0:n.onProgress;c&&!_f(t.highWaterMark)&&c(i,e,r,o),null==(s=this.callbacks)||s.onSuccess(d,i,e,o)}).catch(t=>{var r;if(self.clearTimeout(this.requestTimeout),i.aborted)return;const n=t&&t.code||0,s=t?t.message:null;null==(r=this.callbacks)||r.onError({code:n,text:s},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,n){const s=new hy,a=e.body.getReader(),o=()=>a.read().then(a=>{if(a.done)return s.dataLength&&n(t,r,s.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const l=a.value,d=l.length;return t.loaded+=d,d<i||s.dataLength?(s.push(l),s.dataLength>=i&&n(t,r,s.flush().buffer,e)):n(t,r,l.buffer,e),o()}).catch(()=>Promise.reject());return o()}}function yS(e,t){return new self.Request(e.url,t)}class bS extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}}const ES=/^age:\s*[\d.]+\s*$/im;class wS{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 bp,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 n=this.xhrSetup;n?Promise.resolve().then(()=>{if(this.loader===r&&!this.stats.aborted)return n(r,t.url)}).catch(e=>{if(this.loader===r&&!this.stats.aborted)return r.open("GET",t.url,!0),n(r,t.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(e=>{var n;null==(n=this.callbacks)||n.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:n,maxLoadTimeMs:s}=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=n&&_f(n)?n:s,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,n=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.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 n=null!=l?l:t.response;if(null!=n){var s,a;r.loading.end=Math.max(self.performance.now(),r.loading.first);const o="arraybuffer"===t.responseType?n.byteLength:n.length;r.loaded=r.total=o,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first);const l=null==(s=this.callbacks)?void 0:s.onProgress;l&&l(r,e,n,t);const d={url:t.responseURL,data:n,code:i};return void(null==(a=this.callbacks)||a.onSuccess(d,r,e,t))}}const d=n.loadPolicy.errorRetry;var o;if(Jm(d,r.retry,!1,{url:e.url,data:void 0,code:i}))this.retry(d);else np.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(Jm(e,this.stats.retry,!0))this.retry(e);else{var t;np.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=Qm(e,r.retry),r.retry++,np.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&&ES.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 SS=Qf(Qf({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:wS,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class extends Zf{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:n}=this,{autoLevelEnabled:s,media:a}=n;if(!r||!a)return;const o=performance.now(),l=i?i.stats:r.stats,d=i?i.duration:r.duration,c=o-l.loading.start,u=n.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(!s)return;const p=f>-1&&f!==h,m=!!e||p;if(!m&&(a.paused||!a.playbackRate||!a.readyState))return;const g=n.mainForwardBufferInfo;if(!m&&null===g)return;const v=this.bwEstimator.getEstimateTTFB(),y=Math.abs(a.playbackRate);if(c<=Math.max(v,d/(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=n.levels,x=T[h],A=Math.max(l.loaded,Math.round(d*(r.bitrate||x.averageBitrate)/8));let k=w?c-E:c;k<1&&w&&(k=Math.min(c,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,D=!0===(null==(t=(null==e?void 0:e.details)||this.hls.latestLevelDetails)?void 0:t.live),C=this.hls.config.abrBandWidthUpFactor;let _,O=Number.POSITIVE_INFINITY;for(_=h-1;_>u;_--){const e=T[_].maxBitrate,t=!T[_].details||D;if(O=this.getTimeToLoadFrag(I,P,d*e,t),O<Math.min(b,d+I))break}if(O>=R)return;if(O>10*d)return;w?this.bwEstimator.sample(c-Math.min(v,E),l.loaded):this.bwEstimator.sampleTTFB(c);const M=T[_].maxBitrate;this.getBwEstimate()*C>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: ${_f(S)?0|S:"Unknown"} bps\n New BW estimate: ${0|this.getBwEstimate()} bps\n Switching to level ${_} @ ${0|M} bps`),n.nextLoadLevel=n.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),n.trigger($f.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 Yf(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.FRAG_LOADING,this.onFragLoading,this),e.on($f.FRAG_LOADED,this.onFragLoaded,this),e.on($f.FRAG_BUFFERED,this.onFragBuffered,this),e.on($f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on($f.LEVEL_LOADED,this.onLevelLoaded,this),e.on($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on($f.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on($f.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.FRAG_LOADING,this.onFragLoading,this),e.off($f.FRAG_LOADED,this.onFragLoaded,this),e.off($f.FRAG_BUFFERED,this.onFragBuffered,this),e.off($f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off($f.LEVEL_LOADED,this.onLevelLoaded,this),e.off($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off($f.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off($f.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 Ff.BUFFER_ADD_CODEC_ERROR:case Ff.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case Ff.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,n=t-r.loading.start,s=r.loading.first?r.loading.first-r.loading.start:-1;if(r.loaded&&s>-1){const e=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(n-Math.min(e,s),r.loaded)}else this.bwEstimator.sampleTTFB(n)}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,n=i.end-i.first;_f(n)&&(this.lastLevelLoadSec=n/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===jf&&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,n=this.hls.levels[t.level],s=(n.loaded?n.loaded.bytes:0)+i.loaded,a=(n.loaded?n.loaded.duration:0)+e;n.loaded={bytes:s,duration:a},n.realBitrate=Math.round(8*s/a)}if(t.bitrateTest){const e={stats:i,frag:t,part:r,id:t.type};this.onFragBuffered($f.FRAG_BUFFERED,e),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:r,part:i}=t,n=null!=i&&i.stats.loaded?i.stats:r.stats;if(n.aborted)return;if(this.ignoreFragment(r))return;const s=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(s,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=s/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==jf||"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,n=this.findBestLevel(r,t,e,0,i,1,1);if(n>-1)return n;const s=this.hls.firstLevel,a=Math.min(Math.max(s,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${s} 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:n,minAutoLevel:s}=r,a=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay();let d=n.abrBandWidthFactor,c=n.abrBandWidthUpFactor;if(l){const e=this.findBestLevel(o,s,i,l,0,d,c);if(e>=0)return this.rebufferNotice=-1,e}let u=a?Math.min(a,n.maxStarvationDelay):n.maxStarvationDelay;if(!l){const e=this.bitrateTestDelay;if(e){u=(a?Math.min(a,n.maxLoadingDelay):n.maxLoadingDelay)-e,this.info(`bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*u)} ms`),d=c=1}}const h=this.findBestLevel(o,s,i,l,u,d,c);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[s],p=r.loadLevelObj;return p&&(null==f?void 0:f.bitrate)<p.bitrate?s: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,n,s,a){var o;const l=i+n,d=this.lastLoadedFragLevel,c=-1===d?this.hls.firstLevel:d,{fragCurrent:u,partCurrent:h}=this,{levels:f,allAudioTracks:p,loadLevel:m,config:g}=this.hls;if(1===f.length)return 0;const v=f[c],y=!(null==(o=this.hls.latestLevelDetails)||!o.live),b=-1===m||-1===d;let E,w="SDR",S=(null==v?void 0:v.frameRate)||0;const{audioPreference:T,videoPreference:x}=g,A=this.audioTracksByGroup||(this.audioTracksByGroup=Mm(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 n=r.audioGroups;let s=e[r.codecSet];s||(e[r.codecSet]=s={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!n,fragmentError:0}),s.minBitrate=Math.min(s.minBitrate,r.bitrate);const a=Math.min(r.height,r.width);return s.minHeight=Math.min(s.minHeight,a),s.minFramerate=Math.min(s.minFramerate,r.frameRate),s.minIndex=Math.min(s.minIndex,i),s.maxScore=Math.max(s.maxScore,r.score),s.fragmentError+=r.fragmentError,s.videoRanges[r.videoRange]=(s.videoRanges[r.videoRange]||0)+1,n&&n.forEach(e=>{if(!e)return;const r=t.groups[e];r&&(s.hasDefaultAudio=s.hasDefaultAudio||t.hasDefaultAudio?r.hasDefault:r.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(r.channels).forEach(e=>{s.channels[e]=(s.channels[e]||0)+r.channels[e]}))}),e},{})}(f,A,t,r)),n=function(e,t,r,i,n){const s=Object.keys(e),a=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,l=null==n?void 0:n.videoCodec,d=a&&2===parseInt(a);let c=!1,u=!1,h=1/0,f=1/0,p=1/0,m=1/0,g=0,v=[];const{preferHDR:y,allowedVideoRanges:b}=Cm(t,n);for(let t=s.length;t--;){const r=e[s[t]];c||(c=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=_f(h)?h:0,f=_f(f)?f:0;const E=Math.max(1080,h),w=Math.max(30,f);p=_f(p)?p:r,r=Math.max(p,r),u||(t=void 0);const S=s.length>1;return{codecSet:s.reduce((t,i)=>{const n=e[i];if(i===t)return t;if(v=u?b.filter(e=>n.videoRanges[e]>0):[],S){if(n.minBitrate>r)return Om(i,`min bitrate of ${n.minBitrate} > current estimate of ${r}`),t;if(!n.hasDefaultAudio)return Om(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!=0)return Om(i,`audio codec preference "${o}" not found`),t;if(a&&!d){if(!n.channels[a])return Om(i,`no renditions with ${a} channel sound found (channels options: ${Object.keys(n.channels)})`),t}else if((!o||d)&&c&&0===n.channels[2])return Om(i,"no renditions with stereo sound found"),t;if(n.minHeight>E)return Om(i,`min resolution of ${n.minHeight} > maximum of ${E}`),t;if(n.minFramerate>w)return Om(i,`min framerate of ${n.minFramerate} > maximum of ${w}`),t;if(!v.some(e=>n.videoRanges[e]>0))return Om(i,`no variants with VIDEO-RANGE of ${_m(v)} found`),t;if(l&&i.indexOf(l.substring(0,4))%5!=0)return Om(i,`video codec preference "${l}" not found`),t;if(n.maxScore<g)return Om(i,`max score of ${n.maxScore} < selected max of ${g}`),t}return t&&(om(i)>=om(t)||n.fragmentError>e[t].fragmentError)?t:(m=n.minIndex,g=n.maxScore,i)},void 0),videoRanges:v,preferHDR:y,minFramerate:f,minBitrate:p,minIndex:m}}(i,w,e,T,x),{codecSet:s,videoRanges:a,minFramerate:o,minBitrate:l,minIndex:d,preferHDR:c}=n;k=d,E=s,w=c?a[a.length-1]:a[0],S=o,e=Math.max(e,l),this.log(`picked start tier ${_m(n)}`)}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>c;if(!t)continue;if(g.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){const r=navigator.mediaCapabilities;"function"==typeof(null==r?void 0:r.decodingInfo)&&bm(t,A,w,S,e,T)?(t.supportedPromise=Em(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} ${_m(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&this.log(`MediaCapabilities decodingInfo for level ${i} not smooth or powerEfficient: ${_m(e)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${i} ${_m(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=vm}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:s*e;const D=L&&i>=2*L&&0===n?t.averageBitrate:t.maxBitrate,C=this.getTimeToLoadFrag(I,x,D*v,void 0===p);if(x>=D&&(o===d||0===t.loadError&&0===t.fragmentError)&&(C<=I||!_f(C)||y&&!this.bitrateTestDelay||C<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:${c}->${o} adjustedbw(${Math.round(x)})-bitrate=${Math.round(x-D)} ttfb:${I.toFixed(1)} avgDuration:${v.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${C.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 Zf{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($f.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=sp(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($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.MANIFEST_PARSED,this.onManifestParsed,this),e.on($f.BUFFER_RESET,this.onBufferReset,this),e.on($f.BUFFER_APPENDING,this.onBufferAppending,this),e.on($f.BUFFER_CODECS,this.onBufferCodecs,this),e.on($f.BUFFER_EOS,this.onBufferEos,this),e.on($f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.on($f.FRAG_PARSED,this.onFragParsed,this),e.on($f.FRAG_CHANGED,this.onFragChanged,this),e.on($f.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.MANIFEST_PARSED,this.onManifestParsed,this),e.off($f.BUFFER_RESET,this.onBufferReset,this),e.off($f.BUFFER_APPENDING,this.onBufferAppending,this),e.off($f.BUFFER_CODECS,this.onBufferCodecs,this),e.off($f.BUFFER_EOS,this.onBufferEos,this),e.off($f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.off($f.FRAG_PARSED,this.onFragParsed,this),e.off($f.FRAG_CHANGED,this.onFragChanged,this),e.off($f.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?qf(r,i.tracks):this.sourceBuffers.forEach(e=>{const[t]=e;t&&(r[t]=qf({},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=sp(this.appendSource);if(i){const e=!!t.mediaSource;(e||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const n=this.mediaSource=t.mediaSource||new i;if(this.assignMediaSource(n),e)this._objectUrl=r.src,this.attachTransferred();else{const e=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{r.removeAttribute("src");const t=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||t&&n instanceof t,Xb(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,n=i?Object.keys(i):null,s=n?n.length:0,a=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(i&&n&&s){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: ${_m(r,(e,t)=>"initSegment"===e?void 0:t)};\ntransfer tracks: ${_m(i,(e,t)=>"initSegment"===e?void 0:t)}}`),!ap(i,r)){t.mediaSource=null,t.tracks=void 0;const n=e.currentTime,s=this.details,a=Math.max(n,(null==s?void 0:s.fragments[0].start)||0);return a-n>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${n} -> ${a}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(i)}"->"${Object.keys(r)}") start time: ${a} currentTime: ${n}`),this.onMediaDetaching($f.MEDIA_DETACHING,{}),this.onMediaAttaching($f.MEDIA_ATTACHING,t),void(e.currentTime=a))}this.transferData=void 0,n.forEach(e=>{const t=e,r=i[t];if(r){const e=r.buffer;if(e){const i=this.fragmentTracker,n=r.id;if(i.hasFragments(n)||i.hasParts(n)){const r=Cg.getBuffered(e);i.detectEvictedFragments(t,r,n,null,!0)}const s=Qb(t),a=[t,e];this.sourceBuffers[s]=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:n,_objectUrl:s}=this;if(n){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"===n.readyState;try{const t=n.sourceBuffers;for(let r=t.length;r--;)e&&t[r].abort(),n.removeSourceBuffer(t[r]);e&&n.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}n.removeEventListener("sourceopen",this._onMediaSourceOpen),n.removeEventListener("sourceended",this._onMediaSourceEnded),n.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(n.removeEventListener("startstreaming",this._onStartStreaming),n.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}i&&(i.removeEventListener("emptied",this._onMediaEmptied),r||(s&&self.URL.revokeObjectURL(s),this.mediaSrc===s?(i.removeAttribute("src"),this.appendSource&&Xb(i),i.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger($f.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[Qb(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Wb(this.tracks)}onBufferCodecs(e,t){var r;const i=this.tracks,n=Object.keys(t);this.log(`BUFFER_CODECS: "${n}" (current SB count ${this.sourceBufferCount})`);const s="audiovideo"in t&&(i.audio||i.video)||i.audiovideo&&("audio"in t||"video"in t),a=!s&&this.sourceBufferCount&&this.media&&n.some(e=>!i[e]);s||a?this.warn(`Unsupported transition between "${Object.keys(i)}" and "${n}" SourceBuffers`):(n.forEach(e=>{var r,n;const s=t[e],{id:a,codec:o,levelCodec:l,container:d,metadata:c,supplemental:u}=s;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:d,levelCodec:l,metadata:c,id:a});const v=um(m,g),y=null==v?void 0:v.replace(Yb,"$1");let b=um(o,l);const E=null==(n=b)?void 0:n.replace(Yb,"$1");b&&v&&y!==E&&("audio"===e.slice(0,5)&&(b=cm(b,this.appendSource)),this.log(`switching codec ${m} to ${b}`),b!==(h.pendingCodec||h.codec)&&(h.pendingCodec=b),h.container=d,this.appendChangeType(e,d,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}`,n={label:`change-type=${i}`,execute:()=>{const n=this.tracks[e];if(n){const s=n.buffer;null!=s&&s.changeType&&(this.log(`changing ${e} sourceBuffer type to ${i}`),s.changeType(i),n.codec=r,n.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};this.append(n,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,jf))?void 0:t.gap))return;const n={label:"block-audio",execute:()=>{var e;const t=this.tracks.video;(this.lastVideoAppendEnd>i||null!=t&&t.buffer&&Cg.isBuffered(t.buffer,i)||!0===(null==(e=this.fragmentTracker.getAppendedFrag(i,jf))?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:n,frag:e},this.append(n,"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:n,parent:s,frag:a,part:o,chunkMeta:l,offset:d}=t,c=l.buffering[n],{sn:u,cc:h}=a,f=self.performance.now();c.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"===n&&"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"!==n||"main"===s||this.blockedAudioAppend||y.ending||y.ended){if("video"===n){const r=e.end;if(t){const e=t.frag.start;(r>e||r<this.lastVideoAppendEnd||Cg.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&&!Cg.isBuffered(b,t)&&this.lastVideoAppendEnd<t&&this.blockAudio(e):this.blockAudio(e)}}const E=(o||a).start,w={label:`append-${n}`,execute:()=>{var e;c.executeStart=self.performance.now();const t=null==(e=this.tracks[n])?void 0:e.buffer;t&&(v?this.updateTimestampOffset(t,E,.1,n,u,h):void 0!==d&&_f(d)&&this.updateTimestampOffset(t,d,1e-6,n,u,h)),this.appendExecutor(i,n)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();c.executeEnd=c.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]=Cg.getBuffered(r))}),this.appendErrors[n]=0,"audio"===n||"video"===n?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger($f.BUFFER_APPENDED,{type:n,frag:a,part:o,chunkMeta:l,parent:a.type,timeRanges:t})},onError:e=>{var t;const r={type:Nf.MEDIA_ERROR,parent:a.type,details:Ff.BUFFER_APPEND_ERROR,sourceBufferName:n,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=Ff.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!i)r.errorAction=dg(!0);else if(e.name===Kb&&0===this.sourceBufferCount)r.errorAction=dg(!0);else{const e=++this.appendErrors[n];this.warn(`Failed ${e}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${n}" sourceBuffer (${i||"no media error"})`),(e>=this.hls.config.appendErrorMaxRetry||i)&&(r.fatal=!0)}this.hls.trigger($f.ERROR,r)}};this.log(`queuing "${n}" append sn: ${u}${o?" p: "+o.index:""} of ${a.type===jf?"level":"track"} ${a.level} cc: ${h}`),this.append(w,n,this.isPending(this.tracks[n]))}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($f.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:n}=t;r?this.append(this.getFlushOp(r,i,n),r):this.sourceBuffers.forEach(([e])=>{e&&this.append(this.getFlushOp(e,i,n),e)})}onFragParsed(e,t){const{frag:r,part:i}=t,n=[],s=i?i.elementaryStreams:r.elementaryStreams;s[Sp]?n.push("audiovideo"):(s[Ep]&&n.push("audio"),s[wp]&&n.push("video"));0===n.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($f.FRAG_BUFFERED,{frag:r,part:i,stats:t,id:r.type})},n).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($f.BUFFERED_TO_END,void 0)):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})):(this.tracksEnded(),this.hls.trigger($f.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===Ff.BUFFER_APPEND_ERROR&&t.frag){var r;const e=null==(r=t.errorAction)?void 0:r.nextAutoLevel;_f(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,n=r.currentTime,s=t.levelTargetDuration,a=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(_f(a)&&a>=0){const e=Math.max(a,s),t=Math.floor(n/s)*s-e;this.flushBackBuffer(n,s,t)}const o=i.frontBufferFlushThreshold;if(_f(o)&&o>0){const e=Math.max(i.maxBufferLength,o),t=Math.max(e,s),r=Math.floor(n/s)*s+t;this.flushFrontBuffer(n,s,r)}}flushBackBuffer(e,t,r){this.sourceBuffers.forEach(([e,t])=>{if(t){const n=Cg.getBuffered(t);if(n.length>0&&r>n.start(0)){var i;this.hls.trigger($f.BACK_BUFFER_REACHED,{bufferEnd:r});const t=this.tracks[e];if(null!=(i=this.details)&&i.live)this.hls.trigger($f.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($f.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:e})}}})}flushFrontBuffer(e,t,r){this.sourceBuffers.forEach(([t,i])=>{if(i){const n=Cg.getBuffered(i),s=n.length;if(s<2)return;const a=n.start(s-1),o=n.end(s-1);if(r>a||e>=a&&e<=o)return;this.hls.trigger($f.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 n=null==(e=this.overrides)?void 0:e.duration;if(n)return _f(n)?{duration:n}:null;const s=this.media.duration;return i>(_f(r.duration)?r.duration:0)&&i>s||!_f(s)?{duration:i}:null}updateMediaSource({duration:e,start:t,end:r}){const i=this.mediaSource;this.media&&i&&"open"===i.readyState&&(i.duration!==e&&(_f(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}) ${_m(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($f.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($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.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 n in e){const s=n,a=e[s];if(this.isPending(a)){const e=this.getTrackCodec(a,s),n=`${a.container};codecs=${e}`;a.codec=e,this.log(`creating sourceBuffer(${n})${this.currentOp(s)?" Queued":""} ${_m(a)}`);try{const e=r.addSourceBuffer(n),i=Qb(s),o=[s,e];t[i]=o,a.buffer=e}catch(e){var i;return this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(s),null==(i=this.operationQueue)||i.removeBlockers(),delete this.tracks[s],void this.hls.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:s,mimeType:n,parent:a.id})}this.trackSourceBuffer(s,a)}}this.bufferCreated()}getTrackCodec(e,t){const r=e.supplemental;let i=e.codec;r&&("video"===t||"audiovideo"===t)&&im(r,"video")&&(i=function(e,t){const r=[];if(e){const t=e.split(",");for(let e=0;e<t.length;e++)rm(t[e],"video")||r.push(t[e])}return t&&r.push(t),r.join(",")}(i,r));const n=um(i,e.levelCodec);return n?"audio"===t.slice(0,5)?cm(n,this.appendSource):n:""}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($f.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($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});const n=this.currentOp(e);n&&n.onError(i)}updateTimestampOffset(e,t,r,i,n,s){const a=t-e.timestampOffset;Math.abs(a)>=r&&(this.log(`Updating ${i} SourceBuffer timestampOffset to ${t} (sn: ${n} cc: ${s})`),e.timestampOffset=t)}removeExecutor(e,t,r){const{media:i,mediaSource:n}=this,s=this.tracks[e],a=null==s?void 0:s.buffer;if(!i||!n||!a)return this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void this.shiftAndExecuteNext(e);const o=_f(i.duration)?i.duration:1/0,l=_f(n.duration)?n.duration:1/0,d=Math.max(0,t),c=Math.min(r,o,l);c>d&&(!s.ending||s.ended)?(s.ended=!1,this.log(`Removing [${d},${c}] from the ${e} SourceBuffer`),a.remove(d,c)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const r=this.tracks[t],i=null==r?void 0:r.buffer;if(!i)throw new qb(`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 n=i.buffer;if(!n)return;const s=r.bind(this,e);i.listeners.push({event:t,listener:s}),n.addEventListener(t,s)}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:Zb,errorController:class extends Zf{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($f.ERROR,this.onError,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off($f.ERROR,this.onError,this),e.off($f.ERROR,this.onErrorOut,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.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)===jf?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,n=t.context;switch(t.details){case Ff.FRAG_LOAD_ERROR:case Ff.FRAG_LOAD_TIMEOUT:case Ff.KEY_LOAD_ERROR:case Ff.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case Ff.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=dg());case Ff.FRAG_GAP:case Ff.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=rg);case Ff.LEVEL_EMPTY_ERROR:case Ff.LEVEL_PARSING_ERROR:{var s;const e=t.parent===jf?t.level:i.loadLevel;t.details===Ff.LEVEL_EMPTY_ERROR&&null!=(s=t.context)&&null!=(s=s.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case Ff.LEVEL_LOAD_ERROR:case Ff.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case Ff.AUDIO_TRACK_LOAD_ERROR:case Ff.AUDIO_TRACK_LOAD_TIMEOUT:case Ff.SUBTITLE_LOAD_ERROR:case Ff.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const e=i.loadLevelObj;if(e&&(n.type===zf&&e.hasAudioGroup(n.groupId)||n.type===Gf&&e.hasSubtitleGroup(n.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=rg,void(t.errorAction.flags=ag)}return;case Ff.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:rg,flags:og});case Ff.KEY_SYSTEM_SESSION_UPDATE_FAILED:case Ff.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case Ff.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:rg,flags:lg});case Ff.BUFFER_ADD_CODEC_ERROR:case Ff.REMUX_ALLOC_ERROR:case Ff.BUFFER_APPEND_ERROR:var a;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(a=t.level)?a:i.loadLevel);return;case Ff.INTERNAL_EXCEPTION:case Ff.BUFFER_APPENDING_ERROR:case Ff.BUFFER_FULL_ERROR:case Ff.LEVEL_SWITCH_ERROR:case Ff.BUFFER_STALLED_ERROR:case Ff.BUFFER_SEEK_OVER_HOLE:case Ff.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=dg())}t.type===Nf.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=dg())}getPlaylistRetryOrSwitchAction(e,t){const r=Xm(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(Jm(r,i,Ym(e),e.response))return{action:ng,flags:sg,retryConfig:r,retryCount:i};const n=this.getLevelSwitchAction(e,t);return r&&(n.retryConfig=r,n.retryCount=i),n}getFragRetryOrSwitchAction(e){const t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:s}=t.config,a=Xm(Km(e)?s:n,e),o=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(i&&(e.details!==Ff.FRAG_GAP&&i.fragmentError++,!qm(e))){if(Jm(a,o,Ym(e),e.response))return{action:ng,flags:sg,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 n,s;const t=e.details;i.loadError++,t===Ff.BUFFER_APPEND_ERROR&&i.fragmentError++;let l=-1;const{levels:d,loadLevel:c,minAutoLevel:u,maxAutoLevel:h}=r;r.autoLevelEnabled||r.config.preserveManualLevelOnError||(r.loadLevel=-1);const f=null==(n=e.frag)?void 0:n.type,p=(f===Hf&&t===Ff.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(t===Ff.BUFFER_ADD_CODEC_ERROR||t===Ff.BUFFER_APPEND_ERROR))&&d.some(({audioCodec:e})=>i.audioCodec!==e),m="video"===e.sourceBufferName&&(t===Ff.BUFFER_ADD_CODEC_ERROR||t===Ff.BUFFER_APPEND_ERROR)&&d.some(({codecSet:e,audioCodec:t})=>i.codecSet!==e&&i.audioCodec===t),{type:g,groupId:v}=null!=(s=e.context)?s:{};for(let r=d.length;r--;){const n=(r+c)%d.length;if(n!==c&&n>=u&&n<=h&&0===d[n].loadError){var a,o;const r=d[n];if(t===Ff.FRAG_GAP&&f===jf&&e.frag){const t=d[n].details;if(t){const r=jm(e.frag,t.fragments,e.frag.start);if(null!=r&&r.gap)continue}}else{if(g===zf&&r.hasAudioGroup(v)||g===Gf&&r.hasSubtitleGroup(v))continue;if(f===Hf&&null!=(a=i.audioGroups)&&a.some(e=>r.hasAudioGroup(e))||f===Vf&&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=n;break}}if(l>-1&&r.loadLevel!==l)return e.levelRetry=!0,this.playlistError=0,{action:rg,flags:sg,nextAutoLevel:l}}return{action:rg,flags:ag}}onErrorOut(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case tg:break;case rg:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===Ff.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,n=r.nextAutoLevel;switch(i){case sg:this.switchLevel(e,n);break;case og:{const i=this.getVariantLevelIndex(e.frag),n=t.levels[i],s=null==n?void 0:n.attrs["HDCP-LEVEL"];if(r.hdcpLevel=s,"NONE"===s)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(s){t.maxHdcpLevel=Tm[Tm.indexOf(s)-1],r.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case lg:{const t=e.decryptdata;if(t){const i=this.hls.levels,n=i.length;for(let r=n;r--;){var s,a;if(this.variantHasKey(i[r],t))this.log(`Banned key found in level ${r} (${i[r].bitrate}bps) or audio group "${null==(s=i[r].audioGroups)?void 0:s.join(",")}" (${null==(a=e.frag)?void 0:a.type} fragment) ${lp(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<n)r.resolved=!0;else if(o&&o.type!==jf){const e=o.decryptdata;e&&!t.matches(e)&&(r.resolved=!0)}}break}}r.resolved||this.switchLevel(e,n)}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===Ff.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName)){const t=mm(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($f.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on($f.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off($f.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off($f.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,n=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,a=1e3*n/e,o=this.hls;if(o.trigger($f.FPS_DROP,{currentDropped:n,currentDecoded:s,totalDroppedFrames:r}),a>0&&n>o.config.fpsDroppedMonitoringThreshold*s){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($f.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:lv,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:mS,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 cy{constructor(e,t,r){super(e,t,r,"subtitle-stream-controller",Vf),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($f.LEVEL_LOADED,this.onLevelLoaded,this),e.on($f.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on($f.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on($f.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on($f.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on($f.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off($f.LEVEL_LOADED,this.onLevelLoaded,this),e.off($f.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off($f.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off($f.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off($f.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off($f.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=Jv,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)||(xp(r)&&(this.fragPrevious=r),this.state=Jv),!i)return;const n=this.tracksBuffered[this.currentTrackId];if(!n)return;let s;const a=r.start;for(let e=0;e<n.length;e++)if(a>=n[e].start&&a<=n[e].end){s=n[e];break}const o=r.start+r.duration;s?s.end=o:(s={start:a,end:o},n.push(s)),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,Vf)}}onError(e,t){const r=t.frag;(null==r?void 0:r.type)===Vf&&(t.details===Ff.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Zv&&(this.state=Jv))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){this.levels&&jb(this.levels,t)?this.levels=t.map(e=>new Pm(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{const t=new Pm(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Vf),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!==Zv&&this.setInterval(500)}onSubtitleTrackLoaded(e,t){var r;const{currentTrackId:i,levels:n}=this,{details:s,id:a}=t;if(!n)return void this.warn(`Subtitle tracks were reset while loading level ${a}`);const o=n[a];if(a>=n.length||!o)return;this.log(`Subtitle track ${a} loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""},duration:${s.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(s.live||null!=(r=o.details)&&r.live){if(s.deltaUpdateFailed)return;const e=this.mainDetails;if(!e)return void(this.startFragRequested=!1);const t=e.fragments[0];var d;if(o.details)l=this.alignPlaylists(s,o.details,null==(d=this.levelLastLoaded)?void 0:d.details),0===l&&t&&(l=t.start,Nv(s,l));else s.hasProgramDateTime&&e.hasProgramDateTime?(Kv(s,e),l=s.fragmentStart):t&&(l=t.start,Nv(s,l));e&&!this.startFragRequested&&this.setStartPosition(e,l)}if(o.details=s,this.levelLastLoaded=o,a===i&&(this.hls.trigger($f.SUBTITLE_TRACK_UPDATED,{details:s,id:a,groupId:t.groupId}),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===Jv)){jm(null,s.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,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&null!=i&&i.key&&i.iv&&Yg(i.method)){const e=performance.now();this.decrypter.decrypt(new Uint8Array(r),i.key.buffer,i.iv.buffer,Kg(i.method)).catch(e=>{throw n.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(r=>{const i=performance.now();n.trigger($f.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:e,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=Jv})}}doTick(){if(this.media){if(this.state===Jv){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,n=this.getLoadPosition(),s=Cg.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,i.maxBufferHole),{end:a,len:o}=s,l=r.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;const d=l.fragments,c=d.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=jm(f,d,Math.max(d[0].start,a),t),!h&&f&&f.start<d[0].start&&(h=d[0])}else h=d[c-1];if(h=this.filterReplacedPrimary(h,r.details),!h)return;const p=d[h.sn-l.startSN-1];if(p&&p.cc===h.cc&&this.fragmentTracker.getState(p)===cg&&(h=p),this.fragmentTracker.getState(h)===cg){const e=this.mapToInitFragWhenRequired(h);e&&this.loadFragment(e,r,a)}}}else this.state=Jv}loadFragment(e,t,r){xp(e)?super.loadFragment(e,t,r):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new bw(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends Gb{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=iw(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($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.MANIFEST_PARSED,this.onManifestParsed,this),e.on($f.LEVEL_LOADING,this.onLevelLoading,this),e.on($f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on($f.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on($f.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.MANIFEST_PARSED,this.onManifestParsed,this),e.off($f.LEVEL_LOADING,this.onLevelLoading,this),e.off($f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off($f.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off($f.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;iw(r.textTracks).forEach(e=>{tw(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:n}=t,s=this.tracksInGroup[r];if(!s||s.groupId!==i)return void this.warn(`Subtitle track with id:${r} and group:${i} not found in active group ${null==s?void 0:s.groupId}`);const a=s.details;s.details=t.details,this.log(`Subtitle track ${r} "${s.name}" lang:${s.lang} group:${i} loaded [${n.startSN}-${n.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 n=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(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.subtitlePreference;if(!n&&t){this.selectDefaultTrack=!1;const r=Fm(t,e);if(r>-1)n=e[r];else{const e=Fm(t,this.tracks);n=this.tracks[e]}}let i=this.findTrackId(n);-1===i&&n&&(i=this.findTrackId(null));const s={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${null==r?void 0:r.join(",")}" group-id`),this.hls.trigger($f.SUBTITLE_TRACKS_UPDATED,s),-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 n=t[i];if((!r||n.default)&&(r||e)&&(!e||$m(n,e)))return i}if(e){for(let r=0;r<t.length;r++){const i=t[r];if(Hb(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(Hb(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(Vb(t[r],e))return r}}return-1}onError(e,t){!t.fatal&&t.context&&(t.context.type!==Gf||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&&$m(e,r))return r;const i=Fm(e,this.tracksInGroup);if(i>-1){const e=this.tracksInGroup[i];return this.setSubtitleTrack(i),e}if(r)return null;{const r=Fm(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,n=this.getUrlWithDirectives(e.url,t),s=e.details,a=null==s?void 0:s.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&&s.live?" age "+a.toFixed(1)+(s.type&&" "+s.type||""):""} ${n}`),this.hls.trigger($f.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:i,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=iw(e.textTracks),r=this.currentTrack;let i;if(r&&(i=t.filter(e=>Vb(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||!_f(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($f.SUBTITLE_TRACK_SWITCH,{id:e});const n=!!i.details&&!i.details.live;if(e===this.trackId&&i===r&&n)return;this.log(`Switching to subtitle-track ${e}`+(i?` "${i.name}" lang:${i.lang} group:${i.groupId}`:""));const{id:s,groupId:a="",name:o,type:l,url:d}=i;this.hls.trigger($f.SUBTITLE_TRACK_SWITCH,{id:s,groupId:a,name:o,type:l,url:d});const c=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(c)}},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($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.on($f.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on($f.FRAG_LOADING,this.onFragLoading,this),e.on($f.FRAG_LOADED,this.onFragLoaded,this),e.on($f.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on($f.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on($f.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on($f.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on($f.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.off($f.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off($f.FRAG_LOADING,this.onFragLoading,this),e.off($f.FRAG_LOADED,this.onFragLoaded,this),e.off($f.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off($f.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off($f.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off($f.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off($f.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new cS(this,"textTrack1"),t=new cS(this,"textTrack2"),r=new cS(this,"textTrack3"),i=new cS(this,"textTrack4");this.cea608Parser1=new Nw(1,e,t),this.cea608Parser2=new Nw(3,r,i)}addCues(e,t,r,i,n){let s=!1;for(let e=n.length;e--;){const i=n[e],a=fS(i[0],i[1],t,r);if(a>=0&&(i[0]=Math.min(i[0],t),i[1]=Math.max(i[1],r),s=!0,a/(r-t)>.5))return}if(s||n.push([t,r]),this.config.renderTextTracksNatively){const n=this.captionsTracks[e];this.Cues.newCue(n,t,r,i)}else{const n=this.Cues.newCue(null,t,r,i);this.hls.trigger($f.CUES_PARSED,{type:"captions",cues:n,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:n,trackId:s}){const{unparsedVttFrags:a}=this;r===jf&&(this.initPTS[t.cc]={baseTime:i,timescale:n,trackId:s}),a.length&&(this.unparsedVttFrags=[],a.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded($f.FRAG_LOADED,e):this.hls.trigger($f.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 n=r.textTracks[i];if(hS(n,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return n}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:n,languageCode:s}=t[e],a=this.getExistingTrack(n,s);if(a)r[e]=a,tw(r[e]),JE(r[e],i);else{const t=this.createTextTrack("captions",n,s);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($f.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=>{tw(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++)tw(t[e])}onSubtitleTracksUpdated(e,t){const r=t.subtitleTracks||[],i=r.some(e=>e.textCodec===Jw);if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(jb(this.tracks,r))return void(this.tracks=r);if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const e=this.media,t=e?iw(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]&&hS(t[i],e)){r=t[i],t[i]=null;break}r&&(i=r)}if(i)tw(i);else{const t=uS(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($f.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===jf){var r,i;const{cea608Parser1:e,cea608Parser2:n,lastSn:s}=this,{cc:a,sn:o}=t.frag,l=null!=(r=null==(i=t.part)?void 0:i.index)?r:-1;e&&n&&(o!==s+1||o===s&&l!==this.lastPartIndex+1||a!==this.lastCc)&&(e.reset(),n.reset()),this.lastCc=a,this.lastSn=o,this.lastPartIndex=l}}onFragLoaded(e,t){const{frag:r,payload:i}=t;if(r.type===Vf)if(i.byteLength){const e=r.decryptdata,n="stats"in t;if(null==e||!e.encrypted||n){const e=this.tracks[r.level],n=this.vttCCs;n[r.cc]||(n[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),e&&e.textCodec===Jw?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger($f.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;iS(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),r.trigger($f.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{r.logger.log(`Failed to parse IMSC1: ${t}`),r.trigger($f.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}_parseVTTs(e){var t;const{frag:r,payload:i}=e,{initPTS:n,unparsedVttFrags:s}=this,a=n.length-1;if(!n[r.cc]&&-1===a)return void s.push(e);const o=this.hls;Zw(null!=(t=r.initSegment)&&t.data?Wp(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($f.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},t=>{const n="Missing initPTS for VTT MPEGTS"===t.message;n?s.push(e):this._fallbackToIMSC1(r,i),o.logger.log(`Failed to parse VTT cue: ${t}`),n&&a>r.cc||o.trigger($f.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:t})})}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||iS(t,this.initPTS[e.cc],()=>{r.textCodec=Jw,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=>ew(r,e))}else{const i=this.tracks[t];if(!i)return;const n=i.default?"default":"subtitles"+t;r.trigger($f.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:r}=t;r.type===Vf&&this.onFragLoaded($f.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!==jf||"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:n}){const{media:s}=this;if(s&&!(s.currentTime<r)){if(!n||"video"===n){const{captionsTracks:e}=this;Object.keys(e).forEach(i=>rw(e[i],t,r))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==i){const{textTracks:e}=this;Object.keys(e).forEach(r=>rw(e[r],t,i))}}}extractCea608Data(e){const t=[[],[]],r=31&e[0];let i=2;for(let n=0;n<r;n++){const r=e[i++],n=127&e[i++],s=127&e[i++];if(0===n&&0===s)continue;if(!!(4&r)){const e=3&r;0!==e&&1!==e||(t[e].push(n),t[e].push(s))}}return t}},audioStreamController:class extends cy{constructor(e,t,r){super(e,t,r,"audio-stream-controller",Hf),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($f.LEVEL_LOADED,this.onLevelLoaded,this),e.on($f.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on($f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on($f.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on($f.BUFFER_RESET,this.onBufferReset,this),e.on($f.BUFFER_CREATED,this.onBufferCreated,this),e.on($f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on($f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on($f.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on($f.FRAG_LOADING,this.onFragLoading,this),e.on($f.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off($f.LEVEL_LOADED,this.onLevelLoaded,this),e.off($f.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off($f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off($f.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off($f.BUFFER_RESET,this.onBufferReset,this),e.off($f.BUFFER_CREATED,this.onBufferCreated,this),e.off($f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off($f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off($f.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off($f.FRAG_LOADING,this.onFragLoading,this),e.off($f.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:n,trackId:s}){if(r===jf){const e=t.cc,r=this.fragCurrent;if(this.initPTS[e]={baseTime:i,timescale:n,trackId:s},this.log(`InitPTS for cc: ${e} found from main: ${i/n} (${i}/${n}) trackId: ${s}`),this.mainAnchor=t,this.state===ly){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===Jv&&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 n=(i||e).cc,s=Wm(this.getLevelDetails(),n,this.getLoadPosition());s&&(this.log(`Syncing with main frag at ${s.start} cc ${s.cc}`),this.startFragRequested=!1,this.nextLoadPosition=s.start,this.resetLoadingState(),this.state===Jv&&this.doTickIdle())}startLoad(e,t){if(!this.levels)return this.startPosition=e,void(this.state=Zv);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=Jv):this.state=iy,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case Jv:this.doTickIdle();break;case iy:{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=ly}break}case ry:this.checkRetryDate();break;case ly:{const e=this.waitingData;if(e){const{frag:t,part:r,cache:i,complete:n}=e,s=this.mainAnchor;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.state=ty;const e={frag:t,part:r,payload:i.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(e),n&&super._handleFragmentLoadComplete(e)}else s&&s.cc!==e.frag.cc&&this.syncWithAnchor(s,e.frag)}else this.state=Jv}}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:n}=this,s=t.config;if(!this.buffering||!i&&!this.primaryPrefetch&&(this.startFragRequested||!s.startFragPrefetch)||null==r||!r[n])return;const a=r[n],o=a.details;if(!o||this.waitForLive(a)||this.waitForCdnTuneIn(o))return this.state=iy,void(this.startFragRequested=!1);const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,Ep,Hf));const d=this.getFwdBufferInfo(l,Hf);if(null===d)return;if(!this.switchingTrack&&this._streamEnded(d,o))return t.trigger($f.BUFFER_EOS,{type:"audio"}),void(this.state=ay);const c=d.len,u=t.maxBufferLength,h=o.fragments,f=h[0].start,p=this.getLoadPosition(),m=this.flushing?p:d.end;if(this.switchingTrack&&i){const e=p;o.PTSKnown&&e<f&&(d.end>f||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=f+.05)}if(c>=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,d,jf,u)),!g)return void(this.bufferFlushed=!0);let v=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&v&&xp(g)&&!g.endList&&(!o.live||!this.loadingParts&&m<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(v)===fg&&(this.mainFragLoading=v=null),v&&xp(v))){if(g.start>v.end){const e=this.fragmentTracker.getFragAtPos(m,jf);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 Pm(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!==Zv&&(this.setInterval(100),this.state=Jv,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($f.AUDIO_TRACK_LOADED,r))}onAudioTrackLoaded(e,t){var r;const{levels:i}=this,{details:n,id:s,groupId:a,track:o}=t;if(!i)return void this.warn(`Audio tracks reset while loading track ${s} "${o.name}" of "${a}"`);const l=this.mainDetails;if(!l||n.endCC>l.endCC||l.expired)return this.cachedTrackLoadedData=t,void(this.state!==Zv&&(this.state=iy));this.cachedTrackLoadedData=null,this.log(`Audio track ${s} "${o.name}" of "${a}" loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const d=i[s];let c=0;if(n.live||null!=(r=d.details)&&r.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;var u;if(d.details)c=this.alignPlaylists(n,d.details,null==(u=this.levelLastLoaded)?void 0:u.details);n.alignedSliding||(Yv(n,l),n.alignedSliding||Kv(n,l),c=n.fragmentStart)}d.details=n,this.levelLastLoaded=d,this.startFragRequested||this.setStartPosition(l,c),this.hls.trigger($f.AUDIO_TRACK_UPDATED,{details:n,id:s,groupId:t.groupId}),this.state!==iy||this.waitForCdnTuneIn(n)||(this.state=Jv),this.tick()}_handleFragmentLoadProgress(e){var t;const r=e.frag,{part:i,payload:n}=e,{config:s,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 d=l.details;if(!d)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);const c=s.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let u=this.transmuxer;u||(u=this.transmuxer=new zb(this.hls,Hf,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,s=-1!==t,a=new Pg(r.level,r.sn,r.stats.chunkCount,n.byteLength,t,s);u.push(n,f,c,"",r,i,d.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 [${d.startSN} ,${d.endSN}],track ${a}`);const{cache:e}=this.waitingData=this.waitingData||{frag:r,part:i,cache:new hy,complete:!1};e.push(new Uint8Array(n)),this.state!==Zv&&(this.state=ly)}}_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===jf&&xp(t.frag)&&(this.mainFragLoading=t,this.state===Jv&&this.tick())}onFragBuffered(e,t){const{frag:r,part:i}=t;if(r.type===Hf)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(xp(r)){this.fragPrevious=r;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger($f.AUDIO_TRACK_SWITCHED,Qf({},e)))}this.fragBufferedComplete(r,i),this.media&&this.tick()}else this.audioOnly||r.type!==jf||r.elementaryStreams.video||r.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}onError(e,t){var r;if(t.fatal)this.state=oy;else switch(t.details){case Ff.FRAG_GAP:case Ff.FRAG_PARSING_ERROR:case Ff.FRAG_DECRYPT_ERROR:case Ff.FRAG_LOAD_ERROR:case Ff.FRAG_LOAD_TIMEOUT:case Ff.KEY_LOAD_ERROR:case Ff.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Hf,t);break;case Ff.AUDIO_TRACK_LOAD_ERROR:case Ff.AUDIO_TRACK_LOAD_TIMEOUT:case Ff.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==iy||(null==(r=t.context)?void 0:r.type)!==zf||(this.state=Jv);break;case Ff.BUFFER_ADD_CODEC_ERROR:case Ff.BUFFER_APPEND_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case Ff.BUFFER_FULL_ERROR:if("audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case Ff.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,{type:t}){t!==wp&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==wp){this.flushing=!1,this.bufferFlushed=!0,this.state===ay&&(this.state=Jv);const e=this.mediaBuffer||this.media;e&&(this.afterBufferFlushed(e,t,Hf),this.tick())}}_handleTransmuxComplete(e){var t;const r="audio",{hls:i}=this,{remuxResult:n,chunkMeta:s}=e,a=this.getCurrentContext(s);if(!a)return void this.resetWhenMissingContext(s);const{frag:o,part:l,level:d}=a,{details:c}=d,{audio:u,text:h,id3:f,initSegment:p}=n;if(!this.fragContextChanged(o)&&c){if(this.state=ny,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=p&&p.tracks){const e=o.initSegment||o;if(this.unhandledEncryptionError(p,o))return;this._bufferInitSegment(d,p.tracks,e,s),i.trigger($f.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[Ep]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),o.setElementaryStreamInfo(Ep,e,t,r,i),this.bufferFragmentData(u,o,l,s)}if(null!=f&&null!=(t=f.samples)&&t.length){const e=qf({id:r,frag:o,details:c},f);i.trigger($f.FRAG_PARSING_METADATA,e)}if(h){const e=qf({id:r,frag:o,details:c},h);i.trigger($f.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(e,t,r,i){if(this.state!==ny)return;if(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio)return;const n=t.audio;n.id=Hf;const s=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${s}/${n.codec}]`),s&&1===s.split(",").length&&(n.levelCodec=s),this.hls.trigger($f.BUFFER_CODECS,t);const a=n.initSegment;if(null!=a&&a.byteLength){const e={type:"audio",frag:r,part:null,chunkMeta:i,parent:r.type,data:a};this.hls.trigger($f.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);var n;if(this.switchingTrack||i===cg||i===hg)if(xp(e))if(null!=(n=t.details)&&n.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=ly;const r=this.mainDetails;r&&r.fragmentStart!==t.details.fragmentStart&&Kv(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:n,audioCodec:s,channels:a}=this.bufferedTrack;$m({name:t,lang:r,assocLang:i,characteristics:n,audioCodec:s,channels:a},e,Bm)||(zm(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($f.AUDIO_TRACK_SWITCHED,Qf({},e))}},audioTrackController:class extends Gb{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($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.MANIFEST_PARSED,this.onManifestParsed,this),e.on($f.LEVEL_LOADING,this.onLevelLoading,this),e.on($f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on($f.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on($f.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.MANIFEST_PARSED,this.onManifestParsed,this),e.off($f.LEVEL_LOADING,this.onLevelLoading,this),e.off($f.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off($f.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off($f.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:n}=t,s=this.tracksInGroup[r];if(!s||s.groupId!==i)return void this.warn(`Audio track with id:${r} and group:${i} not found in active group ${null==s?void 0:s.groupId}`);const a=s.details;s.details=t.details,this.log(`Audio track ${r} "${s.name}" lang:${s.lang} group:${i} loaded [${n.startSN}-${n.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 n=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(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.audioPreference;if(!n&&t){const r=Fm(t,e,Bm);if(r>-1)n=e[r];else{const e=Fm(t,this.tracks);n=this.tracks[e]}}let i=this.findTrackId(n);-1===i&&n&&(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($f.AUDIO_TRACKS_UPDATED,a);const o=this.trackId;if(-1!==i&&-1===o)this.setAudioTrack(i);else if(e.length&&-1===o){var s;const t=new Error(`No audio track selected for current audio group-ID(s): ${null==(s=this.groupIds)?void 0:s.join(",")} track count: ${e.length}`);this.warn(t.message),this.hls.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}}onError(e,t){!t.fatal&&t.context&&(t.context.type!==zf||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&&$m(e,i,Bm))return i;const n=Fm(e,this.tracksInGroup,Bm);if(n>-1){const e=this.tracksInGroup[n];return this.setAudioTrack(n),e}if(i){let i=t.loadLevel;-1===i&&(i=t.firstAutoLevel);const n=function(e,t,r,i,n){const s=t[i],a=t.reduce((e,t,r)=>{const i=t.uri;return(e[i]||(e[i]=[])).push(r),e},{})[s.uri];a.length>1&&(i=Math.max.apply(Math,a));const o=s.videoRange,l=s.frameRate,d=s.codecSet.substring(0,4),c=Um(t,i,t=>{if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==d)return!1;const i=t.audioGroups,s=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return Fm(e,s,n)>-1});return c>-1?c:Um(t,i,t=>{const i=t.audioGroups,s=r.filter(e=>!i||-1!==i.indexOf(e.groupId));return Fm(e,s,n)>-1})}(e,t.levels,r,i,Bm);if(-1===n)return null;t.nextLoadLevel=n}if(e.channels||e.audioCodec){const t=Fm(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],n=i.details&&!i.details.live;if(e===this.trackId&&i===r&&n)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($f.AUDIO_TRACK_SWITCHING,Qf({},i)),n)return;const s=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(s)}findTrackId(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||$m(e,i,Bm)))return r}if(e){const{name:r,lang:i,assocLang:n,characteristics:s,audioCodec:a,channels:o}=e;for(let e=0;e<t.length;e++){if($m({name:r,lang:i,assocLang:n,characteristics:s,audioCodec:a,channels:o},t[e],Bm))return e}for(let r=0;r<t.length;r++){const i=t[r];if(Hb(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(Hb(e.attrs,i.attrs,["LANGUAGE"]))return r}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&zm(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const r=e.id,i=e.groupId,n=this.getUrlWithDirectives(e.url,t),s=e.details,a=null==s?void 0:s.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&&s.live?" age "+a.toFixed(1)+(s.type&&" "+s.type||""):""} ${n}`),this.hls.trigger($f.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:i,deliveryDirectives:t||null,track:e})}},emeController:KE,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:Jb.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],n=this.getObjectType(t),s={d:1e3*(r||t).duration,ot:n};n!==Jb.VIDEO&&n!==Jb.AUDIO&&n!=Jb.MUXED||(s.br=i.bitrate/1e3,s.tb=this.getTopBandwidth(n)/1e3,s.bl=this.getBufferLength(n));const a=r?this.getNextPart(r):this.getNextFrag(t);null!=a&&a.url&&a.url!==t.url&&(s.nor=a.url),this.apply(e,s)}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($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($f.MEDIA_DETACHED,this.onMediaDetached,this),e.on($f.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($f.MEDIA_DETACHED,this.onMediaDetached,this),e.off($f.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:eE.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){qf(t,this.createData());const r=t.ot===Jb.INIT||t.ot===Jb.VIDEO||t.ot===Jb.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 n={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),GE(e.headers,t,n)):e.url=VE(e.url,t,n)}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,n=null==(t=this.hls.levels[i.level])||null==(t=t.details)?void 0:t.partList;if(n){const{sn:e}=i;for(let t=n.length-1;t>=0;t--){const i=n[t];if(i.index===r&&i.fragment.sn===e)return n[t+1]}}}getObjectType(e){const{type:t}=e;return"subtitle"===t?Jb.TIMED_TEXT:"initSegment"===e.sn?Jb.INIT:"audio"===t?Jb.AUDIO:"main"===t?this.hls.audioTracks.length?Jb.VIDEO:Jb.MUXED:void 0}getTopBandwidth(e){let t,r=0;const i=this.hls;if(e===Jb.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===Jb.AUDIO?this.audioBuffer:this.videoBuffer;if(!r||!t)return NaN;return 1e3*Cg.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 Zf{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($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.on($f.MANIFEST_PARSED,this.onManifestParsed,this),e.on($f.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.off($f.MANIFEST_PARSED,this.onManifestParsed,this),e.off($f.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)===rg&&r.flags===ag){const e=this.levels;let i=this._pathwayPriority,n=this.pathwayId;if(t.context){const{groupId:r,pathwayId:i,type:s}=t.context;r&&e?n=this.getPathwayForGroupId(r,s,n):i&&(n=i)}n in this.penalizedPathways||(this.penalizedPathways[n]=performance.now()),!i&&e&&(i=this.pathways()),i&&i.length>1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==n),t.details!==Ff.BUFFER_APPEND_ERROR||t.fatal?r.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${n} levels: ${e?e.length:e} priorities: ${_m(i)} penalized: ${_m(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 n=e[i];if(n in r)continue;if(n===this.pathwayId)return;const s=this.hls.nextLoadLevel,a=this.hls.levels[s];if(t=this.getLevelsForPathway(n),t.length>0){this.log(`Setting Pathway to "${n}"`),this.pathwayId=n,zv(t),this.hls.trigger($f.LEVELS_UPDATED,{levels:t});const e=this.hls.levels[s];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=s);break}}}getPathwayForGroupId(e,t,r){const i=this.getLevelsForPathway(r).concat(this.levels||[]);for(let r=0;r<i.length;r++)if(t===zf&&i[r].hasAudioGroup(e)||t===Gf&&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:n,"BASE-ID":s,"URI-REPLACEMENT":a}=e;if(t.some(e=>e.pathwayId===n))return;const o=this.getLevelsForPathway(s).map(e=>{const t=new Ug(e.attrs);t["PATHWAY-ID"]=n;const s=t.AUDIO&&`${t.AUDIO}_clone_${n}`,o=t.SUBTITLES&&`${t.SUBTITLES}_clone_${n}`;s&&(r[t.AUDIO]=s,t.AUDIO=s),o&&(i[t.SUBTITLES]=o,t.SUBTITLES=o);const l=YE(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),d=new Pm({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++)d.addGroupId("audio",`${e.audioGroups[t]}_clone_${n}`);if(e.subtitleGroups)for(let t=1;t<e.subtitleGroups.length;t++)d.addGroupId("text",`${e.subtitleGroups[t]}_clone_${n}`);return d});t.push(...o),WE(this.audioTracks,r,a,n),WE(this.subtitleTracks,i,a,n)})}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 n={responseType:"json",url:i.href},s=t.steeringManifestLoadPolicy.default,a=s.errorRetry||s.timeoutRetry||{},o={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(e,t,r,n)=>{this.log(`Loaded steering manifest: "${i}"`);const s=e.data;if(1!==(null==s?void 0:s.VERSION))return void this.log(`Steering VERSION ${s.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=s.TTL;const{"RELOAD-URI":a,"PATHWAY-CLONES":o,"PATHWAY-PRIORITY":l}=s;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 d={steeringManifest:s,url:i.toString()};this.hls.trigger($f.STEERING_MANIFEST_LOADED,d),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 n=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&&(n=1e3*parseFloat(t))}return void this.log(`Steering manifest ${t.url} rate limited`)}this.scheduleRefresh(this.uri||t.url,n)},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(n,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 Zf{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 n;const t=this.findItemIndex(i);let s=this.schedule.findItemIndexAtTime(e);if(-1===s&&(s=t+(r?-1:1),this.log(`seeked ${r?"back ":""}to position not covered by schedule ${e} (resolving from ${t} to ${s})`)),!this.isInterstitial(i)&&null!=(n=this.media)&&n.paused&&(this.shouldPlay=!1),!r&&s>t){const e=this.schedule.findJumpRestrictedIndex(t+1,s);if(e>t)return void this.setSchedulePosition(e)}return void this.setSchedulePosition(s)}const s=this.playingAsset;if(!s){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=s.timelineStart,o=s.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,s))},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,n=r.events||[],s=r.items||[],a=r.durations,o=e.map(e=>e.identifier),l=!(!n.length&&!o.length);(l||t)&&this.log(`INTERSTITIALS_UPDATED (${n.length}): ${n}\nSchedule: ${s.map(e=>mw(e))} pos: ${this.timelinePos}`),o.length&&this.log(`Removed events ${o}`);let d=null,c=null;i&&(d=this.updateItem(i,this.timelinePos),this.itemsMatch(i,d)?this.playingItem=d:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const u=this.bufferingItem;if(u&&(c=this.updateItem(u,this.bufferedPos),this.itemsMatch(u,c)?this.bufferingItem=c: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)>sw&&this.warn(`${i} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),l||t){if(this.hls.trigger($f.INTERSTITIALS_UPDATED,{events:n.slice(0),schedule:s.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(d,i),u&&c!==d&&this.trimInPlace(c,u),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new gw(e),this.schedule=new pw(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.on($f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on($f.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on($f.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on($f.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on($f.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on($f.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on($f.BUFFER_APPENDED,this.onBufferAppended,this),e.on($f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on($f.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on($f.MEDIA_ENDED,this.onMediaEnded,this),e.on($f.ERROR,this.onError,this),e.on($f.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.off($f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off($f.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off($f.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off($f.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off($f.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off($f.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off($f.BUFFER_CODECS,this.onBufferCodecs,this),e.off($f.BUFFER_APPENDED,this.onBufferAppended,this),e.off($f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off($f.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off($f.MEDIA_ENDED,this.onMediaEnded,this),e.off($f.ERROR,this.onError,this),e.off($f.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){Xv(e,"play",this.onPlay),Xv(e,"pause",this.onPause),Xv(e,"seeking",this.onSeeking),Xv(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const r=this.media=t.media;qv(r,"seeking",this.onSeeking),qv(r,"timeupdate",this.onTimeupdate),qv(r,"play",this.onPlay),qv(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,s,a,o)=>{if(t){let l=t[i].start;const d=t.event;if(d){if("playout"===i||d.timelineOccupancy!==aw.Point){const e=r(s);(null==e?void 0:e.interstitial)===d&&(l+=e.assetItem.startOffset+e[o])}}else{l+=("bufferedPos"===a?n():e[a])-t.start}return l}return 0},n=()=>{const t=e.bufferedPos;return t===Number.MAX_VALUE?s("primary"):Math.max(t,0)},s=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,n)=>{var s,a;const o=e.effectivePlayingItem;if(null!=o&&null!=(s=o.event)&&s.restrictions.skip||!e.schedule)return;e.log(`seek to ${t} "${n}"`);const l=e.effectivePlayingItem,d=e.schedule.findItemIndexAtTime(t,n),c=null==(a=e.schedule.items)?void 0:a[d],u=e.getBufferingPlayer(),h=null==u?void 0:u.interstitial,f=null==h?void 0:h.appendInPlace,p=l&&e.itemsMatch(l,c);if(l&&(f||p)){const s=r(e.playingAsset),a=(null==s?void 0:s.media)||e.primaryMedia;if(a){const r="primary"===n?a.currentTime:i(l,n,e.playingAsset,"timelinePos","currentTime"),o=t-r,d=(f?r:a.currentTime)+o;if(d>=0&&(!s||f||d<=s.duration))return void(a.currentTime=d)}}if(c){let r=t;if("primary"!==n){const e=t-c[n].start;r=c.start+e}const i=!e.isInterstitial(c);if(e.isInterstitial(l)&&!l.event.appendInPlace||!i&&!c.event.appendInPlace){if(l){const s=e.findItemIndex(l);if(d>s){const t=e.schedule.findJumpRestrictedIndex(s+1,d);if(t>s)return void e.setSchedulePosition(t)}let a=0;if(i)e.timelinePos=r,e.checkBuffer();else{const e=c.event.assetList,r=t-(c[n]||c).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(d,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(),n=e.bufferingItem;var s;return n&&n===r&&(i(n,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-n.playout.start||(null==(s=e.bufferingAsset)?void 0:s.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 n()},get currentTime(){const t=e.timelinePos;return t>0?t:0},set currentTime(e){a(e,"primary")},get duration(){return s("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 s("integrated")},get seekableStart(){var t;return((t,r)=>{var i;if(0!==t&&"primary"!==r&&null!=(i=e.schedule)&&i.length){var n;const i=e.schedule.findItemIndexAtTime(t),s=null==(n=e.schedule.items)?void 0:n[i];if(s)return t+(s[r].start-s.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 n=null==(t=i)?void 0:t.currentTime;return void 0!==n&&_f(n)?n: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} ${_m(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 n=null;const s=this.hls,a=e!==s,o=a&&e.interstitial.appendInPlace,l=null==(r=this.detachedData)?void 0:r.mediaSource;let d;if(s.media)o&&(n=s.transferMedia(),this.detachedData=n),d="Primary";else if(l){const e=this.getBufferingPlayer();e?(n=e.transferMedia(),d=`${e}`):d="detached MediaSource"}else d="detached media";if(!n)if(l)n=this.detachedData,this.log(`using detachedData: MediaSource ${_m(n)}`);else if(!this.detachedData||s.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 c=n&&"mediaSource"in n&&"closed"!==(null==(i=n.mediaSource)?void 0:i.readyState),u=c&&n?n:t;this.log(`${c?"transfering MediaSource":"attaching media"} to ${a?e:"Primary"} from ${d} (media.currentTime: ${t.currentTime})`);const h=this.schedule;if(u===n&&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(yw("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),n=uw(r,i);if(r.isAssetPastPlayoutLimit(n)){if(this.schedule){var s;const t=null==(s=this.schedule.items)?void 0:s[this.findItemIndex(e)+1];t&&this.bufferedToItem(t)}}else this.bufferedToEvent(e,n)}advanceAfterAssetEnded(e,t,r){const i=uw(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 n=e.resumeTime;this.timelinePos<n&&(this.log(yw("advanceAfterAssetEnded",n)),this.timelinePos=n,e.appendInPlace&&this.advanceInPlace(n),this.checkBuffer(this.bufferedPos<n)),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,n=r.getEvent(i);if(n){const t=r.findEventIndex(i),s=r.findAssetIndex(n,e);this.advanceAfterAssetEnded(n,t,s-1)}}setSchedulePosition(e,t){var r;const i=null==(r=this.schedule)?void 0:r.items;if(!i||this.playbackDisabled)return;const n=e>=0?i[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${n?mw(n):n}) pos: ${this.timelinePos}`);const s=this.waitingItem||this.playingItem,a=this.playingLastItem;if(this.isInterstitial(s)){const r=s.event,d=this.playingAsset,c=null==d?void 0:d.identifier,u=c?this.getAssetPlayer(c):null;if(u&&c&&(!this.eventItemsMatch(s,n)||void 0!==t&&c!==r.assetList[t].identifier)){var o;const t=r.findAssetIndex(d);if(this.log(`INTERSTITIAL_ASSET_ENDED ${t+1}/${r.assetList.length} ${hw(d)}`),this.endedAsset=d,this.playingAsset=null,this.hls.trigger($f.INTERSTITIAL_ASSET_ENDED,{asset:d,assetListIndex:t,event:r,schedule:i.slice(0),scheduleIndex:e,player:u}),s!==this.playingItem)return void(this.itemsMatch(s,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(r,this.findItemIndex(this.playingItem),t));this.retreiveMediaSource(c,n),!u.media||null!=(o=this.detachedData)&&o.mediaSource||u.detachMedia()}if(!this.eventItemsMatch(s,n)&&(this.endedItem=s,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${r} ${mw(s)}`),r.hasPlayed=!0,this.hls.trigger($f.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(n&&e){const r=this.findItemIndex(n);this.advanceSchedule(r,e,t,s,a)}return}}this.advanceSchedule(e,i,t,s,a)}advanceSchedule(e,t,r,i,n){const s=this.schedule;if(!s)return;const a=t[e]||null,o=this.primaryMedia,l=this.playerQueue;if(l.length&&l.forEach(t=>{const r=t.interstitial,i=s.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 n=a.event;if(void 0===r){const t=uw(n,(r=s.findAssetIndex(n,this.timelinePos))-1);if(n.isAssetPastPlayoutLimit(t)||n.appendInPlace&&this.timelinePos===a.end)return void this.advanceAfterAssetEnded(n,e,r);r=t}const l=this.waitingItem;this.assetsBuffered(a,o)||this.setBufferingItem(a);let d=this.preloadAssets(n,r);if(this.eventItemsMatch(a,l||i)||(this.waitingItem=a,this.log(`INTERSTITIAL_STARTED ${mw(a)} ${n.appendInPlace?"append in place":""}`),this.hls.trigger($f.INTERSTITIAL_STARTED,{event:n,schedule:t.slice(0),scheduleIndex:e})),!n.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${n}`);if(n.assetListLoader&&(n.assetListLoader.destroy(),n.assetListLoader=void 0),!o)return void this.log(`Waiting for attachMedia to start Interstitial ${n}`);this.waitingItem=this.endedItem=null,this.playingItem=a;const c=n.assetList[r];if(!c)return void this.advanceAfterAssetEnded(n,e,r||0);if(d||(d=this.getAssetPlayer(c.identifier)),null===d||d.destroyed){const e=n.assetList.length;this.warn(`asset ${r+1}/${e} player destroyed ${n}`),d=this.createAssetPlayer(n,c,r),d.loadSource()}if(!this.eventItemsMatch(a,this.bufferingItem)&&n.appendInPlace&&this.isAssetBuffered(c))return;this.startAssetPlayer(d,r,t,e,o),this.shouldPlay&&vw(d.media)}else a?(this.resumePrimary(a,e,i),this.shouldPlay&&vw(this.hls.media)):n&&this.isInterstitial(i)&&(this.endedItem=null,this.playingItem=i,i.event.appendInPlace||this.attachPrimary(s.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,n;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${mw(e)}`),null==(i=this.detachedData)||!i.mediaSource){let r=this.timelinePos;(r<e.start||r>=e.end)&&(r=this.getPrimaryResumption(e,t),this.log(yw("resumePrimary",r)),this.timelinePos=r),this.attachPrimary(r,e)}if(!r)return;const s=null==(n=this.schedule)?void 0:n.items;s&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${mw(e)}`),this.hls.trigger($f.INTERSTITIALS_PRIMARY_RESUMED,{schedule:s.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 Cg.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 n=this.hls;n.media?this.checkBuffer():(this.transferMediaTo(n,i),r&&this.startLoadingPrimaryAt(e,r)),r||(this.log(yw("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($f.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on($f.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=Qf(Qf({},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=Qf(Qf({},this.altSelection),{},{audio:r}));const n=Qf(Qf({},i),{},{audio:r});this.mediaSelection=n}onSubtitleTrackUpdated(e,t){const r=this.hls.subtitleTracks[t.id],i=this.mediaSelection;if(!i)return void(this.altSelection=Qf(Qf({},this.altSelection),{},{subtitles:r}));const n=Qf(Qf({},i),{},{subtitles:r});this.mediaSelection=n}onAudioTrackSwitching(e,t){const r=Nm(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(r)))}onSubtitleTrackSwitch(e,t){const r=Nm(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=Cg.bufferInfo(this.primaryMedia,r,0);if(i.end>r||(i.nextStart||0)>r){this.log(`trim buffered interstitial ${mw(e)} (was ${mw(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=Cg.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,n=this.bufferingItem;if(this.bufferedPos>e||!i)return;if(1===t.length&&this.itemsMatch(t[0],n))return void(this.bufferedPos=e);const s=this.playingItem,a=this.findItemIndex(s);let o=i.findItemIndexAtTime(e);if(this.bufferedPos<e){var l;const r=this.findItemIndex(n),i=Math.min(r+1,t.length-1),s=t[i];if((-1===o&&n&&e>=n.end||null!=(l=s.event)&&l.appendInPlace&&e+.01>=s.start)&&(o=i),this.isInterstitial(n)){const e=n.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(s);else{const t=this.primaryDetails;this.primaryLive&&t&&e>t.edge-t.targetduration&&s.start<t.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(s)&&this.preloadAssets(s.event,0)}}else r&&s&&!this.itemsMatch(s,n)&&(o===a?this.bufferedToItem(s):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:n}=r;if(!i||!n)return t;const s=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 ${mw(e)}`+(t?` (${o.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(s){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($f.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:n.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,n=r.cue.once;if(i||!n){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,n=0===i&&!e.assetListLoader,s=e.cue.once;if(n){const n=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(n+.25)}let s,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-n;e>0&&(s=Math.round(1e3*e)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${r?1:i} ${e}${s?` live-start: ${o} start-offset: ${s}`:""}`),r)return this.createAsset(e,0,0,n,e.duration,r);const l=this.assetListLoader.loadAssetList(e,s);l&&(e.assetListLoader=l)}else if(!s&&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($f.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,n,s){const a={parentIdentifier:e.identifier,identifier:ow(e,s,t),duration:n,startOffset:r,timelineStart:i,uri:s};return this.createAssetPlayer(e,a,t)}createAssetPlayer(e,t,r){const i=this.hls,n=i.userConfig;let s=n.videoPreference;const a=i.loadLevelObj||i.levels[i.currentLevel];(s||a)&&(s=qf({},s),a.videoCodec&&(s.videoCodec=a.videoCodec),a.videoRange&&(s.allowedVideoRanges=[a.videoRange]));const o=i.audioTracks[i.audioTrack],l=i.subtitleTracks[i.subtitleTrack];let d=0;if(this.primaryLive||e.appendInPlace){const e=this.timelinePos-t.timelineStart;if(e>1){const r=t.duration;r&&e<r&&(d=e)}}const c=t.identifier,u=Qf(Qf({},n),{},{maxMaxBufferLength:Math.min(180,i.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:i.sessionId,assetPlayerId:c,abrEwmaDefaultEstimate:i.bandwidthEstimate,interstitialsController:void 0,startPosition:d,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:s,audioPreference:o||n.audioPreference,subtitlePreference:l||n.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(u.timelineOffset=t.timelineStart));const h=u.cmcd;null!=h&&h.sessionId&&h.contentId&&(u.cmcd=qf({},h,{contentId:nw(t.uri)})),this.getAssetPlayer(c)&&this.warn(`Duplicate date range identifier ${e} and asset ${c}`);const f=new fw(this.HlsPlayerClass,u,e,t);this.playerQueue.push(f),e.assetList[r]=t;let p=!0;const m=i=>{if(i.live){var n;const t=new Error(`Interstitials MUST be VOD assets ${e}`),i={fatal:!0,type:Nf.OTHER_ERROR,details:Ff.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},s=(null==(n=this.schedule)?void 0:n.findEventIndex(e.identifier))||-1;return void this.handleAssetItemError(i,e,s,r,t.message)}const s=i.edge-i.fragmentStart,a=t.duration;(p||null===a||s>a)&&(p=!1,this.log(`Interstitial asset "${c}" duration change ${a} > ${s}`),t.duration=s,this.updateSchedule())};f.on($f.LEVEL_UPDATED,(e,{details:t})=>m(t)),f.on($f.LEVEL_PTS_UPDATED,(e,{details:t})=>m(t)),f.on($f.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const g=(e,t)=>{const r=this.getAssetPlayer(c);if(r&&t.tracks){r.off($f.BUFFER_CODECS,g),r.tracks=t.tracks;const e=this.primaryMedia;this.bufferingAsset===r.assetItem&&e&&!r.media&&this.bufferAssetPlayer(r,e)}};f.on($f.BUFFER_CODECS,g);f.on($f.BUFFERED_TO_END,()=>{var r;const i=this.getAssetPlayer(c);if(this.log(`buffered to end of asset ${i}`),!i||!this.schedule)return;const n=this.schedule.findEventIndex(e.identifier),s=null==(r=this.schedule.items)?void 0:r[n];this.isInterstitial(s)&&this.advanceAssetBuffering(s,t)});const v=t=>()=>{if(!this.getAssetPlayer(c)||!this.schedule)return;this.shouldPlay=!0;const r=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,r,t)};return f.once($f.MEDIA_ENDED,v(r)),f.once($f.PLAYOUT_LIMIT_REACHED,v(1/0)),f.on($f.ERROR,(t,i)=>{if(!this.schedule)return;const n=this.getAssetPlayer(c);if(i.details===Ff.BUFFER_STALLED_ERROR)return null!=n&&n.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($f.DESTROYING,()=>{if(!this.getAssetPlayer(c)||!this.schedule)return;const t=new Error(`Asset player destroyed unexpectedly ${c}`),i={fatal:!0,type:Nf.OTHER_ERROR,details:Ff.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(i,e,this.schedule.findEventIndex(e.identifier),r,t.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${hw(t)}`),this.hls.trigger($f.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?mw(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,n){const{interstitial:s,assetItem:a,assetId:o}=e,l=s.assetList.length,d=this.playingAsset;this.endedAsset=null,this.playingAsset=a,d&&d.identifier===o||(d&&(this.clearAssetPlayer(d.identifier,r[i]),delete d.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${l} ${hw(a)}`),this.hls.trigger($f.INTERSTITIAL_ASSET_STARTED,{asset:a,assetListIndex:t,event:s,schedule:r.slice(0),scheduleIndex:i,player:e})),this.bufferAssetPlayer(e,n)}bufferAssetPlayer(e,t){var r,i;if(!this.schedule)return;const{interstitial:n,assetItem:s}=e,a=this.schedule.findEventIndex(n.identifier),o=null==(r=this.schedule.items)?void 0:r[a];if(!o)return;e.loadSource(),this.setBufferingItem(o),this.bufferingAsset=s;const l=this.getBufferingPlayer();if(l===e)return;const d=n.appendInPlace;if(d&&!1===(null==l?void 0:l.interstitial.appendInPlace))return;const c=(null==l?void 0:l.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(d&&s!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(c&&!ap(c,e.tracks)){const t=new Error(`Asset ${hw(s)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(c)}')`),r={fatal:!0,type:Nf.OTHER_ERROR,details:Ff.INTERSTITIAL_ASSET_ITEM_ERROR,error:t},i=n.findAssetIndex(s);return void this.handleAssetItemError(r,n,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,n=t.findAssetIndex(e,i),s=e.assetList[n];if(s){const a=this.getAssetPlayer(s.identifier);if(a){const o=a.currentTime||i-s.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,n)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,r,i,n){if(e.details===Ff.BUFFER_STALLED_ERROR)return;const s=t.assetList[i]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${s?hw(s):s} ${e.error}`),!this.schedule)return;const a=(null==s?void 0:s.identifier)||"",o=this.getAssetPlayerQueueIndex(a),l=this.playerQueue[o]||null,d=this.schedule.items,c=qf({},e,{fatal:!1,errorAction:dg(!0),asset:s,assetListIndex:i,event:t,schedule:d,scheduleIndex:r,player:l});if(this.hls.trigger($f.INTERSTITIAL_ASSET_ERROR,c),!e.fatal)return;const u=this.playingAsset,h=this.bufferingAsset,f=new Error(n);if(s&&(this.clearAssetPlayer(a,null),s.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: ${mw(r)} error: ${e.error}`),-1===i&&(i=this.hls.startPosition);const n=this.updateItem(r,i);this.itemsMatch(r,n)&&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 n=this.schedule.findItemIndexAtTime(i);this.setSchedulePosition(n)}onAssetListLoaded(e,t){var r,i;const n=t.event,s=n.identifier,a=t.assetListResponse.ASSETS;if(null==(r=this.schedule)||!r.hasEvent(s))return;const o=n.timelineStart,l=n.duration;let d=0;a.forEach((e,t)=>{const r=parseFloat(e.DURATION);this.createAsset(n,t,d,o+d,r,e.URI),d+=r}),n.duration=d,this.log(`Loaded asset-list with duration: ${d} (was: ${l}) ${n}`);const c=this.waitingItem,u=(null==c?void 0:c.event.identifier)===s;this.updateSchedule();const h=null==(i=this.bufferingItem)?void 0:i.event;if(u){var f;const e=this.schedule.findEventIndex(s),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 n.error=new Error(`Interstitial ${a.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${n}`),this.log(n.error.message),this.updateSchedule(!0),void this.primaryFallback(n)}this.setBufferingItem(t)}this.setSchedulePosition(e)}else if((null==h?void 0:h.identifier)===s){const e=n.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 Ff.ASSET_LIST_PARSING_ERROR:case Ff.ASSET_LIST_LOAD_ERROR:case Ff.ASSET_LIST_LOAD_TIMEOUT:{const e=t.interstitial;e&&(this.updateSchedule(!0),this.primaryFallback(e));break}case Ff.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 TS(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(TS):Object.keys(e).reduce((t,r)=>(t[r]=TS(e[r]),t),{}):e}function xS(e,t){const r=e.loader;if(r!==vS&&r!==wS)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=vS,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}}class AS extends Rg{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($f.MEDIA_ENDED,{stalled:!1}))},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.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;qv(r,"playing",this.onMediaPlaying),qv(r,"waiting",this.onMediaWaiting),qv(r,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:r}=this;r&&(Xv(r,"playing",this.onMediaPlaying),Xv(r,"waiting",this.onMediaWaiting),Xv(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 n=null==(r=this.hls)?void 0:r.config;if(!n)return;const s=this.media;if(!s)return;const{seeking:a}=s,o=this.seeking&&!a,l=!this.seeking&&a,d=s.paused&&!a||s.ended||0===s.playbackRate;if(this.seeking=a,e!==t)return t&&(this.ended=0),this.moved=!0,a||(this.nudgeRetry=0,n.nudgeOnVideoHole&&!d&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(l||o)return void(o&&this.stallResolved(e));if(d)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&s.ended&&this.hls&&(this.ended=e||1,this.hls.trigger($f.MEDIA_ENDED,{stalled:!1})));if(!Cg.getBuffered(s).length)return void(this.nudgeRetry=0);const c=Cg.bufferInfo(s,e,0),u=c.nextStart||0,h=this.fragmentTracker;if(a&&h&&this.hls){const t=kS(this.hls.inFlightFragments,e),r=c.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(!(c.len>0)&&!u)return;const t=Math.max(u,c.start||0)-e,r=!(null==f||!f.live)?2*f.targetduration:2,i=IS(e,h);if(t>0&&(t<=r||i))return void(s.paused||this._trySkipBufferHole(i))}const p=n.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($f.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(c),!this.media||!this.hls)return}const E=Cg.bufferInfo(s,e,n.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($f.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=Cg.bufferedInfo(Cg.timeRangesToArray(this.buffered.audio),e,0);if(r.len>1&&t>=r.start){const r=Cg.timeRangesToArray(i),n=Cg.bufferedInfo(r,t,0).bufferedIndex;if(n>-1&&n<r.length-1){const t=Cg.bufferedInfo(r,e,0).bufferedIndex,i=r[n].end,s=r[n+1].start;if((-1===t||t>n)&&s-i<1&&e-i<2){const r=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${i} -> ${s} buffered index: ${t}`);this.warn(r.message),this.media.currentTime+=1e-6;let n=IS(e,this.fragmentTracker);n&&"fragment"in n?n=n.fragment:n||(n=void 0);const a=Cg.bufferInfo(this.media,e,0);this.hls.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:r,reason:r.message,frag:n,buffer:a.len,bufferInfo:a})}}}}}_tryFixBufferStall(e,t,r){var i,n;const{fragmentTracker:s,media:a}=this,o=null==(i=this.hls)?void 0:i.config;if(!a||!s||!o)return;const l=null==(n=this.hls)?void 0:n.latestLevelDetails,d=IS(r,s);if(d||null!=l&&l.live&&r<l.fragmentStart){if(this._trySkipBufferHole(d)||!this.media)return}const c=e.buffered,u=this.adjacentTraversal(e,r);(c&&c.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,jf),n=r.getFragAtPos(i,jf);if(e&&n)return n.sn-e.sn<2}return!1}_reportStall(e){const{hls:t,media:r,stallReported:i,stalled:n}=this;if(!i&&null!==n&&r&&t){this.stallReported=!0;const i=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${_m(e)})`);this.warn(i.message),t.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len,bufferInfo:e,stalled:{start:n}})}}_trySkipBufferHole(e){var t;const{fragmentTracker:r,media:i}=this,n=null==(t=this.hls)?void 0:t.config;if(!i||!r||!n)return 0;const s=i.currentTime,a=Cg.bufferInfo(i,s,0),o=s<a.start?a.start:a.nextStart;if(o&&this.hls){const t=a.len<=n.maxBufferHole,d=a.len>0&&a.len<1&&i.readyState<3,c=o-s;if(c>0&&(t||d)){if(c>n.maxBufferHole){let t=!1;if(0===s){const e=r.getAppendedFrag(0,jf);e&&o<e.end&&(t=!0)}if(!t&&e){var l;if(null==(l=this.hls.loadLevelObj)||!l.details)return 0;if(kS(this.hls.inFlightFragments,o))return 0;let t=!1,i=e.end;for(;i<o;){const e=IS(i,r);if(!e){t=!0;break}i+=e.duration}if(t)return 0}}const t=Math.max(o+.05,s+.1);if(this.warn(`skipping hole, adjusting currentTime from ${s} to ${t}`),this.moved=!0,i.currentTime=t,null==e||!e.gap){const r=new Error(`fragment loaded with buffer holes, seeking from ${s} to ${t}`),i={type:Nf.MEDIA_ERROR,details:Ff.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($f.ERROR,i)}return t}}return 0}_tryNudgeBuffer(e){const{hls:t,media:r,nudgeRetry:i}=this,n=null==t?void 0:t.config;if(!r||!n)return 0;const s=r.currentTime;if(this.nudgeRetry++,i<n.nudgeMaxRetry){const a=s+(i+1)*n.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${s} to ${a}`);this.warn(o.message),r.currentTime=a,t.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.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 @${s} after ${n.nudgeMaxRetry} nudges`);this.error(r.message),t.trigger($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.BUFFER_STALLED_ERROR,error:r,fatal:!0,buffer:e.len,bufferInfo:e})}}}function kS(e,t){const r=LS(e.main);if(r&&r.start<=t)return r;const i=LS(e.audio);return i&&i.start<=t?i:null}function LS(e){if(!e)return null;switch(e.state){case Jv:case Zv:case ay:case oy:return null}return e.frag}function IS(e,t){return t.getAppendedFrag(e,jf)||t.getPartialFragment(e)}function RS(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function PS(e,t,r,i,n){let s=new e(t,r,"");try{s.value=i,n&&(s.type=n)}catch(a){s=new e(t,r,_m(n?Qf({type:n},i):i))}return s}const DS=(()=>{const e=RS();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class CS{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($f.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($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on($f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.on($f.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off($f.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off($f.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.off($f.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&&tw(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 JE(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:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const s=RS();if(s)for(let e=0;e<n.length;e++){const t=n[e].type;if(t===Uy.emsg&&!r||!i)continue;const a=Ny(n[e].data),o=n[e].pts;let l=o+n[e].duration;l>DS&&(l=DS);l-o<=0&&(l=o+.25);for(let e=0;e<a.length;e++){const r=a[e];if(!Fy(r)){this.updateId3CueEnds(o,t);const e=PS(s,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 n=i[r];n.type===t&&n.startTime<e&&n.endTime===DS&&(n.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:i}){const{id3Track:n,hls:s}=this;if(!s)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:o}}=s;if(n&&(a||o)){let e;e="audio"===i?e=>e.type===Uy.audioId3&&o:"video"===i?e=>e.type===Uy.emsg&&a:e=>e.type===Uy.audioId3&&o||e.type===Uy.emsg&&a,rw(n,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:n,interstitialsController:s}=this.hls.config;if(!n)return;const a=RS();if(r&&i&&!s){const{fragmentStart:t,fragmentEnd:i}=e;let n=this.assetCue;n?(n.startTime=t,n.endTime=i):a&&(n=this.assetCue=PS(a,t,i,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),n&&(n.id=r,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(n),n.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:o}=this,{dateRanges:l}=e,d=Object.keys(l);let c=this.dateRangeCuesAppended;var u;if(o&&t)if(null!=(u=o.cues)&&u.length){const e=Object.keys(c).filter(e=>!d.includes(e));for(let t=e.length;t--;){var h;const r=e[t],i=null==(h=c[r])?void 0:h.cues;delete c[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 c=this.dateRangeCuesAppended={};const f=e.fragments[e.fragments.length-1];if(0!==d.length&&_f(null==f?void 0:f.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let e=0;e<d.length;e++){const t=d[e],r=l[t],i=r.startTime,n=c[t],o=(null==n?void 0:n.cues)||{};let u=(null==n?void 0:n.durationKnown)||!1,h=DS;const{duration:f,endDate:p}=r;if(p&&null!==f)h=i+f,u=!0;else if(r.endOnNext&&!u){const e=d.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(!zg(l))continue;const d=o[l];if(d)!u||null!=n&&n.durationKnown?Math.abs(d.startTime-i)>.01&&(d.startTime=i,d.endTime=h):d.endTime=h;else if(a){let e=r.attr[l];Gg(l)&&(e=dp(e));const n=PS(a,i,h,{key:l,data:e},Uy.dateRange);n&&(n.id=t,this.id3Track.addCue(n),o[l]=n,s&&("X-ASSET-LIST"!==l&&"X-ASSET-URL"!==l||n.addEventListener("enter",this.onEventCueEnter)))}}c[t]={cues:o,dateRange:r,durationKnown:u}}}}}class _S{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:n}=this.config;if(!i||1===n||!t.live)return;const s=this.targetLatency;if(null===s)return;const a=r-s;if(a<Math.min(this.maxLatency,s+t.targetduration)&&a>.05&&this.forwardBufferLength>1){const t=Math.min(2,Math.max(1,n)),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:n,liveSyncDurationCount:s,lowLatencyMode:a}=this.config,o=this.hls.userConfig;let l=a&&r||t;(this._targetLatencyUpdated||o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==n?n:s*i);const d=i;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,d)}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,n=e-t-this.edgeStalled,s=i-r.totalduration,a=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(s,n),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($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.on($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.on($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.on($f.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off($f.MEDIA_ATTACHED,this.onMediaAttached,this),e.off($f.MEDIA_DETACHING,this.onMediaDetaching,this),e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.LEVEL_UPDATED,this.onLevelUpdated,this),e.off($f.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===Ff.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 OS extends Gb{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($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.on($f.LEVEL_LOADED,this.onLevelLoaded,this),e.on($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on($f.FRAG_BUFFERED,this.onFragBuffered,this),e.on($f.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.MANIFEST_LOADED,this.onManifestLoaded,this),e.off($f.LEVEL_LOADED,this.onLevelLoaded,this),e.off($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off($f.FRAG_BUFFERED,this.onFragBuffered,this),e.off($f.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=[],n={},s={};let a=!1,o=!1,l=!1;t.levels.forEach(e=>{const t=e.attrs;let{audioCodec:d,videoCodec:c}=e;d&&(e.audioCodec=d=cm(d,r)||void 0),c&&(c=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(",")}(c));const{width:u,height:h,unknownCodecs:f}=e,p=(null==f?void 0:f.length)||0;if(a||(a=!(!u||!h)),o||(o=!!c),l||(l=!!d),p||d&&!this.isAudioSupported(d)||c&&!this.isVideoSupported(c))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(n[w])if(n[w].uri===e.url||e.attrs["PATHWAY-ID"])n[w].addGroupId("audio",t.AUDIO),n[w].addGroupId("text",t.SUBTITLES);else{const t=s[w]+=1;e.attrs["PATHWAY-ID"]=new Array(t+1).join(".");const r=this.createLevel(e);n[w]=r,i.push(r)}else{const t=this.createLevel(e);n[w]=t,s[w]=1,i.push(t)}}),this.filterAndSortMediaOptions(i,t,a,o,l)}createLevel(e){const t=new Pm(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=ym(e,[])}return t}isAudioSupported(e){return im(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return im(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,r,i,n){var s;let a=[],o=[],l=e;const d=(null==(s=t.stats)?void 0:s.parsing)||{};if((r||i)&&n&&(l=l.filter(({videoCodec:e,videoRange:t,width:r,height:i})=>{return(!!e||!(!r||!i))&&(!!(n=t)&&xm.indexOf(n)>-1);var n})),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: ${_m(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($f.ERROR,{type:Nf.MEDIA_ERROR,details:Ff.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:i,reason:r})}}),void(d.end=performance.now());t.audioTracks&&(a=t.audioTracks.filter(e=>!e.audioCodec||this.isAudioSupported(e.audioCodec)),MS(a)),t.subtitles&&(o=t.subtitles,MS(o));const c=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 xm.indexOf(e.videoRange)-xm.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){const r=am(e.videoCodec),i=am(t.videoCodec);if(r!==i)return i-r}if(e.uri===t.uri&&e.codecSet!==t.codecSet){const r=om(e.codecSet),i=om(t.codecSet);if(r!==i)return i-r}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});let u=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==c.length))for(let e=0;e<c.length;e++)if(c[e].pathwayId===l[0].pathwayId){u=c[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=n&&!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:n,video:i,altAudio:m&&!f&&a.some(e=>!!e.url)};d.end=performance.now(),this.hls.trigger($f.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($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.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,n=i?i.attrs["PATHWAY-ID"]:void 0,s=t[e],a=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=s,r===e&&i&&n===a)return;this.log(`Switching to level ${e} (${s.height?s.height+"p ":""}${s.videoRange?s.videoRange+" ":""}${s.codecSet?s.codecSet+" ":""}@${s.bitrate})${a?" with Pathway "+a:""} from level ${r}${n?" with Pathway "+n:""}`);const o={level:e,attrs:s.attrs,details:s.details,bitrate:s.bitrate,averageBitrate:s.averageBitrate,maxBitrate:s.maxBitrate,realBitrate:s.realBitrate,width:s.width,height:s.height,codecSet:s.codecSet,audioCodec:s.audioCodec,videoCodec:s.videoCodec,audioGroups:s.audioGroups,subtitleGroups:s.subtitleGroups,loaded:s.loaded,loadError:s.loadError,fragmentError:s.fragmentError,name:s.name,id:s.id,uri:s.uri,url:s.url,urlId:0,audioGroupIds:s.audioGroupIds,textGroupIds:s.textGroupIds};this.hls.trigger($f.LEVEL_SWITCHING,o);const l=s.details;if(!l||l.live){const e=this.switchParams(s.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===Uf&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(void 0!==t&&t.type===jf){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:n}=t,s=t.levelInfo;var a;if(!s)return this.warn(`Invalid level index ${i}`),void(null!=(a=t.deliveryDirectives)&&a.skip&&(n.deltaUpdateFailed=!0));if(s===this.currentLevel||t.withoutMultiVariant){0===s.fragmentError&&(s.loadError=0);let e=s.details;e===t.details&&e.advanced&&(e=void 0),this.playlistLoaded(i,t,e)}else null!=(r=t.deliveryDirectives)&&r.skip&&(n.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,n=e.attrs["PATHWAY-ID"],s=e.details,a=null==s?void 0:s.age;this.log(`Loading level index ${i}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""}${n?" Pathway "+n:""}${a&&s.live?" age "+a.toFixed(1)+(s.type&&" "+s.type||""):""} ${r}`),this.hls.trigger($f.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));zv(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($f.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($f.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function MS(e){const t={};e.forEach(e=>{const r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++})}function NS(){return self.SourceBuffer||self.WebKitSourceBuffer}function FS(){if(!sp())return!1;const e=NS();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}class $S extends cy{constructor(e,t,r){super(e,t,r,"stream-controller",jf),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||!_f(t))return;if(this.log(`Media seeked to ${t.toFixed(3)}`),!this.getBufferedFrag(t))return;const r=this.getFwdBufferInfoAtPos(e,t,jf,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($f.MANIFEST_PARSED,this.onManifestParsed,this),e.on($f.LEVEL_LOADING,this.onLevelLoading,this),e.on($f.LEVEL_LOADED,this.onLevelLoaded,this),e.on($f.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on($f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on($f.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on($f.BUFFER_CREATED,this.onBufferCreated,this),e.on($f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on($f.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off($f.MANIFEST_PARSED,this.onManifestParsed,this),e.off($f.LEVEL_LOADED,this.onLevelLoaded,this),e.off($f.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off($f.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off($f.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off($f.BUFFER_CREATED,this.onBufferCreated,this),e.off($f.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off($f.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off($f.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=Jv,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=Zv}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case dy:{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=Jv;break}if(this.hls.nextLoadLevel!==this.level){this.state=Jv;break}break}case ry:this.checkRetryDate()}this.state===Jv&&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 n=this.buffering?e.nextLoadLevel:e.loadLevel;if(null==r||!r[n])return;const s=r[n],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($f.BUFFER_EOS,e),void(this.state=ay)}if(!this.buffering)return;e.loadLevel!==n&&-1===e.manualLevel&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;const l=s.details;if(!l||this.state===dy||this.waitForLive(s))return this.level=n,this.state=dy,void(this.startFragRequested=!1);const d=a.len,c=this.getMaxBufferLength(s.maxBitrate);if(d>=c)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&&xp(h)&&this.fragmentTracker.getState(h)!==fg){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?Ep:wp,t=(e===wp?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,jf)}h=this.getNextFragmentLoopLoading(h,l,a,jf,c)}h&&(!h.initSegment||h.initSegment.data||this.bitrateTest||(h=h.initSegment),this.loadFragment(h,s,u))}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);i===cg||i===hg?xp(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,jf)}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 n=this.getLevelDetails();if(null!=n&&n.live){const e=this.getMainFwdBufferInfo();if(!e||e.len<2*n.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 s=this.getBufferedFrag(t.currentTime+r);if(s){const e=this.followingBufferedFrag(s);if(e){this.abortCurrentFrag();const t=e.maxStartPTS?e.maxStartPTS:e.start,r=e.duration,i=Math.max(s.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 ey:case ty:case ry:case ny:case sy:this.state=Jv}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;qv(r,"playing",this.onMediaPlaying),qv(r,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:r}=this;r&&(Xv(r,"playing",this.onMediaPlaying),Xv(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($f.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 n=t.levels[e].audioCodec;n&&(r=r||-1!==n.indexOf("mp4a.40.2"),i=i||-1!==n.indexOf("mp4a.40.5"))}this.audioCodecSwitch=r&&i&&!function(){var e;const t=NS();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!==Jv)return;const i=t.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=dy)}onLevelLoaded(e,t){var r;const{levels:i,startFragRequested:n}=this,s=t.level,a=t.details,o=a.totalduration;if(!i)return void this.warn(`Levels were reset while loading level ${s}`);this.log(`Level ${s} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const l=t.levelInfo,d=this.fragCurrent;!d||this.state!==ty&&this.state!==ry||d.level!==t.level&&d.loader&&this.abortCurrentFrag();let c=0;if(a.live||null!=(r=l.details)&&r.live){var u;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;c=this.alignPlaylists(a,l.details,null==(u=this.levelLastLoaded)?void 0:u.details)}if(l.details=a,this.levelLastLoaded=l,n||this.setStartPosition(a,c),this.hls.trigger($f.LEVEL_UPDATED,{details:a,level:s}),this.state===dy){if(this.waitForCdnTuneIn(a))return;this.state=Jv}n&&a.live&&this.synchronizeToLiveEdge(a),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:r}=this;if(!r)return;const i=this.hls.liveSyncPosition,n=this.getLoadPosition(),s=e.fragmentStart,a=e.edge,o=n>=s-t.maxFragLookUpTolerance&&n<=a;if(null!==i&&r.duration>i&&(n<i||!o)){const s=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!o&&r.readyState<4||n<a-s)&&(this._hasEnoughToStart||(this.nextLoadPosition=i),r.readyState))if(this.warn(`Playback: ${n.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=Cg.bufferInfo(r,i,0);if(null==(l=e.buffered)||!l.length)return void(r.currentTime=i);if(e.start<=n)return void(r.currentTime=i);const{nextStart:t}=Cg.bufferedInfo(e.buffered,n,0);t&&(r.currentTime=t)}else r.currentTime=i}}_handleFragmentLoadProgress(e){var t;const r=e.frag,{part:i,payload:n}=e,{levels:s}=this;if(!s)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=s[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,d=o.PTSKnown||!o.live,c=null==(t=r.initSegment)?void 0:t.data,u=this._getAudioCodec(a),h=this.transmuxer=this.transmuxer||new zb(this.hls,jf,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,p=-1!==f,m=new Pg(r.level,r.sn,r.stats.chunkCount,n.byteLength,f,p),g=this.initPTS[r.cc];h.push(n,c,u,l,r,i,o.totalduration,d,m,g)}onAudioTrackSwitching(e,t){const r=this.hls,i=0!==this.altAudio;if(zm(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($f.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger($f.AUDIO_TRACK_SWITCHED,t)}),void r.trigger($f.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});r.trigger($f.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const r=zm(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,n,s=!1;for(const e in r){const t=r[e];if("main"===t.id){if(n=e,i=t,"video"===e){const t=r[e];t&&(this.videoBuffer=t.buffer)}}else s=!0}s&&i?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:r,part:i}=t,n=r.type===jf;if(n){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===sy&&(this.state=Jv));const e=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*e.total/(e.buffering.end-e.loading.first)),xp(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}const s=this.media;s&&(!this._hasEnoughToStart&&Cg.getBuffered(s).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),n&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var r;if(t.fatal)this.state=oy;else switch(t.details){case Ff.FRAG_GAP:case Ff.FRAG_PARSING_ERROR:case Ff.FRAG_DECRYPT_ERROR:case Ff.FRAG_LOAD_ERROR:case Ff.FRAG_LOAD_TIMEOUT:case Ff.KEY_LOAD_ERROR:case Ff.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(jf,t);break;case Ff.LEVEL_LOAD_ERROR:case Ff.LEVEL_LOAD_TIMEOUT:case Ff.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==dy||(null==(r=t.context)?void 0:r.type)!==Uf||(this.state=Jv);break;case Ff.BUFFER_ADD_CODEC_ERROR:case Ff.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case Ff.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 Ff.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onFragLoadEmergencyAborted(){this.state=Jv,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Ep||!this.altAudio){const e=(t===wp?this.videoBuffer:this.mediaBuffer)||this.media;e&&(this.afterBufferFlushed(e,t,jf),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 n=this.getLevelDetails(),s=Cg.getBuffered(e),a=s.length?s.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==n?void 0:n.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=Jv,this.startFragRequested=!1,this.bitrateTest=!1;const n=i.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),r.trigger($f.FRAG_LOADED,e),i.bitrateTest=!1}).catch(t=>{this.state!==Zv&&this.state!==oy&&(this.warn(t),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:r}=this,{remuxResult:i,chunkMeta:n}=e,s=this.getCurrentContext(n);if(!s)return void this.resetWhenMissingContext(n);const{frag:a,part:o,level:l}=s,{video:d,text:c,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=ny,h){const e=h.tracks;if(e){const i=a.initSegment||a;if(this.unhandledEncryptionError(h,a))return;this._bufferInitSegment(l,e,i,n),r.trigger($f.FRAG_PARSING_INIT_SEGMENT,{frag:i,id:t,tracks:e})}const i=h.initPTS,s=h.timescale,o=this.initPTS[a.cc];if(_f(i)&&(!o||o.baseTime!==i||o.timescale!==s)){const e=h.trackId;this.initPTS[a.cc]={baseTime:i,timescale:s,trackId:e},r.trigger($f.INIT_PTS_FOUND,{frag:a,id:t,initPTS:i,timescale:s,trackId:e})}}if(d&&f){p&&"audiovideo"===d.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:s,endDTS:l}=d;if(o)o.elementaryStreams[d.type]={startPTS:e,endPTS:i,startDTS:s,endDTS:l};else if(d.firstKeyFrame&&d.independent&&1===n.id&&!r&&(this.couldBacktrack=!0),d.dropped&&d.independent){const n=this.getMainFwdBufferInfo(),s=(n?n.end:this.getLoadPosition())+this.config.maxBufferHole,o=d.firstKeyFramePTS?d.firstKeyFramePTS:e;if(!t&&s<o-this.config.maxBufferHole&&!r)return void this.backtrack(a);r&&(a.gap=!0),a.setElementaryStreamInfo(d.type,a.start,i,a.start,l,!0)}else t&&e-(f.appliedTimelineOffset||0)>2&&(a.gap=!0);a.setElementaryStreamInfo(d.type,e,i,s,l),this.backtrackFragment&&(this.backtrackFragment=a),this.bufferFragmentData(d,a,o,n,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[Ep]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),a.setElementaryStreamInfo(Ep,e,t,r,i),this.bufferFragmentData(p,a,o,n)}if(f&&null!=u&&u.samples.length){const e={id:t,frag:a,details:f,samples:u.samples};r.trigger($f.FRAG_PARSING_METADATA,e)}if(f&&c){const e={id:t,frag:a,details:f,samples:c.samples};r.trigger($f.FRAG_PARSING_USERDATA,e)}}}logMuxedErr(e){this.warn(`${xp(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,r,i){if(this.state!==ny)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(r));const{audio:n,video:s,audiovideo:a}=t;if(n){const r=e.audioCodec;let i=um(n.codec,r);"mp4a"===i&&(i="mp4a.40.5");const s=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){i&&(i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");const e=n.metadata;e&&"channelCount"in e&&1!==(e.channelCount||1)&&-1===s.indexOf("firefox")&&(i="mp4a.40.5")}i&&-1!==i.indexOf("mp4a.40.5")&&-1!==s.indexOf("android")&&"audio/mpeg"!==n.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}"`),n.levelCodec=i,n.id=jf,this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${i||""}/${r||""}/${n.codec}]`),delete t.audiovideo}if(s){s.levelCodec=e.videoCodec,s.id=jf;const r=s.codec;if(4===(null==r?void 0:r.length))switch(r){case"hvc1":case"hev1":s.codec="hvc1.1.6.L120.90";break;case"av01":s.codec="av01.0.04M.08";break;case"avc1":s.codec="avc1.42e01e"}this.log(`Init video buffer, container:${s.container}, codecs[level/parsed]=[${e.videoCodec||""}/${r}]${s.codec!==r?" parsed-corrected="+s.codec:""}${s.supplemental?" supplemental="+s.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($f.BUFFER_CODECS,t),!this.hls)return;o.forEach(e=>{const n=t[e].initSegment;null!=n&&n.byteLength&&this.hls.trigger($f.BUFFER_APPENDING,{type:e,data:n,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,jf)}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=Jv}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&!1===e.seeking){const r=e.currentTime;if(Cg.isBuffered(e,r)?t=this.getAppendedFrag(r):Cg.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($f.FRAG_CHANGED,{frag:t}),e&&e.level===r||this.hls.trigger($f.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 _f(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(_f(t)){const e=this.getLevelDetails(),r=this.currentFrag||(e?jm(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 BS extends Zf{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=Ff.KEY_LOAD_ERROR,r,i,n){return new Ig({type:Nf.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,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,n=t.length;i<n;i++){const s=t[i];if(e.cc<=s.cc&&(!xp(e)||!xp(s)||e.sn<s.sn)||!r&&i==n-1)return this.emeController.selectKeySystemFormat(s).then(e=>{if(!this.emeController)return;s.setKeyFormat(e);const t=sv(e);return t?this.emeController.getKeySystemAccess([t]):void 0})}if(this.config.requireKeySystemAccessOnStart){const e=ov(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 n=e.decryptdata;if(!n){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,Ff.KEY_LOAD_ERROR,r))}const s=n.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,Ff.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${s}"`)));const a=US(n);let o=this.keyIdToKeyInfo[a];if(null!=(r=o)&&r.decryptdata.key)return n.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 n.key=r.decryptdata.key,{frag:e,keyInfo:r}})}}switch(this.log(`${this.keyIdToKeyInfo[a]?"Rel":"L"}oading${n.keyId?" keyId: "+lp(n.keyId):""} URI: ${n.uri} from ${e.type} ${e.level}`),o=this.keyIdToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===n.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,Ff.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.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 Hp(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 ${lp(t)}`),hv.setKeyIdForUri(e.decryptdata.uri,t)):(t=hv.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${lp(t)}`)),e.decryptdata.keyId=t}}if(!e.decryptdata.keyId&&!xp(t))return Promise.resolve(r);const n=this.emeController.loadKey(r);return(e.keyLoadPromise=n.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((n,s)=>{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},d={onSuccess:(e,t,r,i)=>{const{frag:a,keyInfo:o}=r,l=US(o.decryptdata);if(!a.decryptdata||o!==this.keyIdToKeyInfo[l])return s(this.createKeyLoadError(a,Ff.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,n({frag:a,keyInfo:o})},onError:(e,r,i,n)=>{this.resetLoader(r),s(this.createKeyLoadError(t,Ff.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),i,Qf({url:a.url,data:void 0},e)))},onTimeout:(e,r,i)=>{this.resetLoader(r),s(this.createKeyLoadError(t,Ff.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(e,r,i)=>{this.resetLoader(r),s(this.createKeyLoadError(t,Ff.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};i.load(a,l,d)})}resetLoader(e){const{frag:t,keyInfo:r,url:i}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null);const s=US(r.decryptdata)||i;delete this.keyIdToKeyInfo[s],n&&n.destroy()}}function US(e){if(e.keyFormat!==rv){const t=e.keyId;if(t)return lp(t)}return e.uri}function zS(e){const{type:t}=e;switch(t){case zf:return Hf;case Gf:return Vf;default:return jf}}function GS(e,t){let r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}class jS{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($f.MANIFEST_LOADING,this.onManifestLoading,this),e.on($f.LEVEL_LOADING,this.onLevelLoading,this),e.on($f.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on($f.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on($f.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off($f.MANIFEST_LOADING,this.onManifestLoading,this),e.off($f.LEVEL_LOADING,this.onLevelLoading,this),e.off($f.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off($f.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off($f.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return this.loaders[e.type]=n,n}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:Bf,url:r,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:r,level:i,pathwayId:n,url:s,deliveryDirectives:a,levelInfo:o}=t;this.load({id:r,level:i,pathwayId:n,responseType:"text",type:Uf,url:s,deliveryDirectives:a,levelOrTrack:o})}onAudioTrackLoading(e,t){const{id:r,groupId:i,url:n,deliveryDirectives:s,track:a}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:zf,url:n,deliveryDirectives:s,levelOrTrack:a})}onSubtitleTrackLoading(e,t){const{id:r,groupId:i,url:n,deliveryDirectives:s,track:a}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:Gf,url:n,deliveryDirectives:s,levelOrTrack:a})}onLevelsUpdated(e,t){const r=this.loaders[Uf];if(r){const e=r.context;e&&!t.levels.some(t=>t===e.levelOrTrack)&&(r.abort(),delete this.loaders[Uf])}}load(e){var t;const r=this.hls.config;let i,n=this.getInternalLoader(e);if(n){const t=this.hls.logger,r=n.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}`),n.abort()}if(i=e.type===Bf?r.manifestLoadPolicy.default:qf({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(e),_f(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===Uf&&null!==e.level?t=this.hls.levels[e.level].details:e.type===zf&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===Gf&&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=qf({},i,{maxTimeToFirstByteMs:Math.min(t,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,i.maxTimeToFirstByteMs)})}}}const s=i.errorRetry||i.timeoutRetry||{},a={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},o={onSuccess:(e,t,r,i)=>{const n=this.getInternalLoader(r);this.resetInternalLoader(r.type);const s=e.data;t.parsing.start=performance.now(),bv.isMediaPlaylist(s)||r.type!==Bf?this.handleTrackOrLevelPlaylist(e,t,r,i||null,n):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)}};n.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 n=this.hls,s=e.data,a=GS(e,r),o=bv.parseMasterPlaylist(s,a);if(o.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);const{contentSteering:l,levels:d,sessionData:c,sessionKeys:u,startTimeOffset:h,variableList:f}=o;this.variableList=f,d.forEach(e=>{const{unknownCodecs:t}=e;if(t){const{preferManagedMediaSource:r}=this.hls.config;let{audioCodec:i,videoCodec:n}=e;for(let s=t.length;s--;){const a=t[s];im(a,"audio",r)?(e.audioCodec=i=i?`${i},${a}`:a,tm.audio[i.substring(0,4)]=2,t.splice(s,1)):im(a,"video",r)&&(e.videoCodec=n=n?`${n},${a}`:a,tm.video[n.substring(0,4)]=2,t.splice(s,1))}}});const{AUDIO:p=[],SUBTITLES:m,"CLOSED-CAPTIONS":g}=bv.parseMasterPlaylistMedia(s,a,o);if(p.length){p.some(e=>!e.url)||!d[0].audioCodec||d[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 Ug({}),bitrate:0,url:""}))}n.trigger($f.MANIFEST_LOADED,{levels:d,audioTracks:p,subtitles:m,captions:g,contentSteering:l,url:a,stats:t,networkDetails:i,sessionData:c,sessionKeys:u,startTimeOffset:h,variableList:f})}handleTrackOrLevelPlaylist(e,t,r,i,n){const s=this.hls,{id:a,level:o,type:l}=r,d=GS(e,r),c=_f(o)?o:_f(a)?a:0,u=zS(r),h=bv.parseLevelPlaylist(e.data,d,c,u,0,this.variableList);if(l===Bf){const e={attrs:new Ug({}),bitrate:0,details:h,name:"",url:d};h.requestScheduled=t.loading.start+Fv(h,0),s.trigger($f.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:d,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,n)}handleManifestParsingError(e,t,r,i,n){this.hls.trigger($f.ERROR,{type:Nf.NETWORK_ERROR,details:Ff.MANIFEST_PARSING_ERROR,fatal:t.type===Bf,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:n})}handleNetworkError(e,t,r=!1,i,n){let s=`A network ${r?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading ${e.type}`;e.type===Uf?s+=`: ${e.level} id: ${e.id}`:e.type!==zf&&e.type!==Gf||(s+=` id: ${e.id} group-id: "${e.groupId}"`);const a=new Error(s);this.hls.logger.warn(`[playlist-loader]: ${s}`);let o=Ff.UNKNOWN,l=!1;const d=this.getInternalLoader(e);switch(e.type){case Bf:o=r?Ff.MANIFEST_LOAD_TIMEOUT:Ff.MANIFEST_LOAD_ERROR,l=!0;break;case Uf:o=r?Ff.LEVEL_LOAD_TIMEOUT:Ff.LEVEL_LOAD_ERROR,l=!1;break;case zf:o=r?Ff.AUDIO_TRACK_LOAD_TIMEOUT:Ff.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case Gf:o=r?Ff.SUBTITLE_TRACK_LOAD_TIMEOUT:Ff.SUBTITLE_LOAD_ERROR,l=!1}d&&this.resetInternalLoader(e.type);const c={type:Nf.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:d,context:e,error:a,networkDetails:t,stats:n};if(i){const r=(null==t?void 0:t.url)||e.url;c.response=Qf({url:r,data:void 0},i)}this.hls.trigger($f.ERROR,c)}handlePlaylistLoaded(e,t,r,i,n,s){const a=this.hls,{type:o,level:l,levelOrTrack:d,id:c,groupId:u,deliveryDirectives:h}=i,f=GS(t,i),p=zS(i);let m="number"==typeof i.level&&p===jf?l:void 0;const g=e.playlistParsingError;if(g){if(this.hls.logger.warn(`${g} ${e.url}`),!a.config.ignorePlaylistParsingErrors)return void a.trigger($f.ERROR,{type:Nf.NETWORK_ERROR,details:Ff.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:i,level:m,parent:p,networkDetails:n,stats:r});e.playlistParsingError=null}if(!e.fragments.length){const s=e.playlistParsingError=new Error("No Segments found in Playlist");return void a.trigger($f.ERROR,{type:Nf.NETWORK_ERROR,details:Ff.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:s,reason:s.message,response:t,context:i,level:m,parent:p,networkDetails:n,stats:r})}switch(e.live&&s&&(s.getCacheAge&&(e.ageHeader=s.getCacheAge()||0),s.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case Bf:case Uf:if(m)if(d){if(d!==a.levels[m]){const e=a.levels.indexOf(d);e>-1&&(m=e)}}else m=0;a.trigger($f.LEVEL_LOADED,{details:e,levelInfo:d||a.levels[0],level:m||0,id:c||0,stats:r,networkDetails:n,deliveryDirectives:h,withoutMultiVariant:o===Bf});break;case zf:a.trigger($f.AUDIO_TRACK_LOADED,{details:e,track:d,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case Gf:a.trigger($f.SUBTITLE_TRACK_LOADED,{details:e,track:d,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:h})}}}class HS{static get version(){return vy}static isMSESupported(){return FS()}static isSupported(){return function(){if(!FS())return!1;const e=sp();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(sm(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(sm(t,"audio"))))}()}static getMediaSource(){return sp()}static get Events(){return $f}static get MetadataSchema(){return Uy}static get ErrorTypes(){return Nf}static get ErrorDetails(){return Ff}static get DefaultConfig(){return HS.defaultConfig?HS.defaultConfig:SS}static set DefaultConfig(e){HS.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 gy,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=tp();if("object"==typeof console&&!0===e||"object"==typeof e){const n=["debug","log","info","warn","error"];n.forEach(t=>{i[t]=rp(t,e,r)});try{i.log(`Debug logs enabled for "${t}" in hls.js version 1.6.15`)}catch(e){return tp()}n.forEach(t=>{ip[t]=rp(t,e)})}else qf(ip,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=TS(e),n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{const s=`${"level"===e?"playlist":e}LoadPolicy`,a=void 0===t[s],o=[];n.forEach(r=>{const n=`${e}Loading${r}`,l=t[n];if(void 0!==l&&a){o.push(n);const e=i[s].default;switch(t[s]={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 "${s}": ${_m(t[s])}`)}),Qf(Qf({},i),t)}(HS.DefaultConfig,e,t);this.userConfig=e,r.progressive&&xS(r,t);const{abrController:i,bufferController:n,capLevelController:s,errorController:a,fpsController:o}=r,l=new a(this),d=this.abrController=new i(this),c=new pg(this),u=r.interstitialsController,h=u?this.interstitialsController=new u(this,HS):null,f=this.bufferController=new n(this,c),p=this.capLevelController=new s(this),m=new o(this),g=new jS(this),v=r.contentSteeringController,y=v?new v(this):null,b=this.levelController=new OS(this,y),E=new CS(this),w=new BS(this.config,this.logger),S=this.streamController=new $S(this,c,w),T=this.gapController=new AS(this,c);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=[d,f,T,p,m,E,c];this.audioTrackController=this.createController(r.audioTrackController,x);const k=r.audioStreamController;k&&x.push(this.audioStreamController=new k(this,c,w)),this.subtitleTrackController=this.createController(r.subtitleTrackController,x);const L=r.subtitleStreamController;L&&x.push(this.subtititleStreamController=new L(this,c,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(_S,A),this.coreComponents=A,x.push(l);const I=l.onErrorOut;"function"==typeof I&&this.on($f.ERROR,I,l),this.on($f.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===$f.ERROR;this.trigger($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.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($f.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($f.ERROR,{type:Nf.OTHER_ERROR,details:Ff.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($f.MEDIA_ATTACHING,i)}detachMedia(){this.logger.log("detachMedia"),this.trigger($f.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger($f.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,r=this._url,i=this._url=yp.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($f.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={[jf]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[Hf]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[Vf]=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 Tm.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 Em(e,Mm(t),navigator.mediaCapabilities)}}HS.defaultConfig=void 0;const VS=({file:e,startTime:n,poster:s,autoplay:o=!0,active:l=!0,visible:d=!0,muted:h=!0})=>{const f=r(null),{isReady:p,prewarm:m,setLowestResolution:g,startBufferBasedUpshift:v}=(({file:e,videoRef:t,autoplay:n=!0,startTime:s,enabled:o=!0,onReady:l,onError:d})=>{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==d||d(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 D=c(()=>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 s=()=>{};try{null===(r=h.current)||void 0===r||r.destroy()}catch(e){}if(h.current=null,v.current=!1,T(!1),b("loading"),HS.isSupported()){g.current=!1;const t=new HS({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,n=e.bitrate,s=e.name;return{id:t,height:r,width:i,bitrate:n,name:s,label:s||(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(),n&&i.play().catch(()=>{}))};t.on(HS.Events.MANIFEST_PARSED,()=>{r(),n||_()}),t.on(HS.Events.FRAG_BUFFERED,a),t.on(HS.Events.BUFFER_APPENDED,a),t.on(HS.Events.LEVEL_SWITCHED,(e,t)=>{const r=null==t?void 0:t.level;I(null==r||r<0?"auto":r)}),t.on(HS.Events.ERROR,(e,r)=>{var i,n,s,a,o;const l=500===(null!==(a=null!==(n=null===(i=null==r?void 0:r.response)||void 0===i?void 0:i.code)&&void 0!==n?n:null===(s=null==r?void 0:r.response)||void 0===s?void 0:s.status)&&void 0!==a?a:null===(o=null==r?void 0:r.response)||void 0===o?void 0:o.statusCode);if(r.type!==HS.ErrorTypes.NETWORK_ERROR||r.fatal){if(r.fatal){if(r.type===HS.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==d||d(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==d||d(new Error("HTTP 500")))}try{if(p.current>=5){b("error");try{t.destroy()}catch(e){}return h.current=null,void(null==d||d(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),s=()=>{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(),n&&i.play().catch(()=>{}))},r=()=>{if(v.current=!1,T(!1),p.current>=5)return b("error"),void(null==d||d(new Error("Max retry reached")));P()};i.addEventListener("loadedmetadata",t),i.addEventListener("error",r),n&&i.play().catch(()=>{}),s=()=>{i.removeEventListener("loadedmetadata",t),i.removeEventListener("error",r)}}else b("error"),null==d||d(new Error("HLS not supported"));return()=>{s(),R()}},[e,E,n,l,d,t,o]),i(()=>{if(!S)return;if(null==s||s<=0)return;const e=t.current;if(e)try{Math.abs(e.currentTime-s)>.5&&(e.currentTime=s)}catch(e){}},[S,s,t]),i(()=>{const e=t.current;if(!e)return;const r=()=>b("ready"),i=()=>b("ready"),n=()=>{"error"!==y&&b("loading")},s=()=>b("loading"),a=()=>{b("error"),null==d||d()};return e.addEventListener("playing",r),e.addEventListener("canplay",i),e.addEventListener("waiting",n),e.addEventListener("stalled",s),e.addEventListener("error",a),()=>{e.removeEventListener("playing",r),e.removeEventListener("canplay",i),e.removeEventListener("waiting",n),e.removeEventListener("stalled",s),e.removeEventListener("error",a)}},[y,d,t]);const C=c(()=>{const e=h.current;e&&!g.current&&(console.log("Set auto resolution"),e.nextLevel=-1,I("auto"))},[]),_=c(()=>{var e,t;const r=h.current;if(!r)return;const i=r.levels||[];if(i.length){let n=0;for(let r=1;r<i.length;r++)(null!==(e=i[r].height)&&void 0!==e?e:99999)<(null!==(t=i[n].height)&&void 0!==t?t:99999)&&(n=r);r.currentLevel=n}},[]),O=c((e=2)=>{const r=h.current,i=t.current;if(!r||!i||g.current)return()=>{};let n=!1;const s=()=>{if(!n)if(r.autoLevelEnabled)n=!0;else try{i.buffered.length>0&&i.buffered.end(0)-i.currentTime>=e&&(r.nextLevel=-1,I("auto"),n=!0)}catch(e){}};return r.on(HS.Events.FRAG_BUFFERED,s),()=>{r.off(HS.Events.FRAG_BUFFERED,s)}},[t]);return{playbackStatus:y,isReady:S,qualities:A,currentLevel:L,isAutoQuality:u(()=>"auto"===L,[L]),canSetResolution:!g.current&&HS.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)),n=i.find(e=>(e.height||0)<=r)||i[i.length-1];n&&(t.currentLevel=n.id,I(n.id))},setAutoResolution:C,prewarm:D,setLowestResolution:_,startBufferBasedUpshift:O}})({file:e,videoRef:f,autoplay:o,startTime:n,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:Rt(s||""),preload:"metadata",className:"w-full h-full object-cover object-center bg-black",style:{opacity:d&&p?1:0,transition:"opacity 200ms ease-in-out"}})},WS=({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," 시청")),YS=({content:e,aspectRatio:r="9/16",cursor:i="default",borderRadius:n,playback:s="hover"})=>{var a,o,l,d,c;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}=Df(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()},[s]),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){}},[s]);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)}},[s]);const R="hover"===s&&v,P=Boolean(k&&("autoplay"===s&&b||R&&h));return t.createElement("div",{className:"w-full h-full flex flex-col items-center justify-center",ref:u,onMouseEnter:()=>{"hover"===s&&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!=n?n:10}px`,backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"cover",aspectRatio:w.height?void 0:r,backgroundImage:S?`url(${Rt(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(VS,{file:k,poster:S,autoplay:"autoplay"===s,active:"autoplay"===s&&b||R&&h,visible:P,muted:!0})),!P&&t.createElement(Rf,null),t.createElement(WS,{view:null!==(c=null===(d=e.statistics)||void 0===d?void 0:d.pageView)&&void 0!==c?c:0}))))},KS=e=>{var r,i,n,s;const{content:a,title:o,aspectRatio:l="9/16",card:d,titleFontSize:c}=e,h=null!==(r=null==d?void 0:d.layout)&&void 0!==r?r:"slider",f=null!==(i=null==d?void 0:d.sliderPerView)&&void 0!==i?i:3,p=null!==(n=null==d?void 0:d.gridColumns)&&void 0!==n?n:3,m=null!==(s=null==d?void 0:d.gap)&&void 0!==s?s:12,g=null==d?void 0:d.width,v=g?"auto":f,y=u(()=>({fontSize:c?`${c}px`:void 0,fontWeight:600}),[c]),{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(ds,{key:`${v}-${null!=g?g:""}-${m}`,slidesPerView:v,spaceBetween:m},a.map(r=>{var i,n;return t.createElement(cs,{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?t.createElement(YS,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.borderRadius,playback:e.playback}):t.createElement(Cf,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.borderRadius}),t.createElement("p",{className:"truncate",style:{color:null!==(n=null===(i=e.theme)||void 0===i?void 0:i.textColor)&&void 0!==n?n:"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,n;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?t.createElement(YS,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.borderRadius,playback:e.playback}):t.createElement(Cf,{content:r,aspectRatio:l,cursor:"pointer",borderRadius:null==d?void 0:d.borderRadius}),t.createElement("p",{className:"truncate",style:{color:null!==(n=null===(i=e.theme)||void 0===i?void 0:i.textColor)&&void 0!==n?n:"black",fontSize:14,userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"}},r.eventName))})))):null};var qS;!function(e){e[e.READY=1]="READY",e[e.STREAMING=2]="STREAMING",e[e.PAUSED=3]="PAUSED"}(qS||(qS={}));const XS=({content:e})=>{const r=t.useMemo(()=>qe(e.start).tz("Asia/Seoul").format("M월 D일 A HH:mm"),[e.start]),i=e.eventStatus!==qS.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"}},"라이브 입장하기"))},QS=e=>{var r,i;const{content:n,aspectRatio:s="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:d}=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:`${d}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(Cf,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"})):"left"===a?t.createElement(t.Fragment,null,t.createElement("div",{className:"flex-1"},t.createElement("a",{href:`${d}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(Cf,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"}))),t.createElement(XS,{content:n})):t.createElement(t.Fragment,null,t.createElement(XS,{content:n}),t.createElement("div",{className:"flex-1"},t.createElement("a",{href:`${d}/live/${n.eventId}`,target:"_blank",rel:"noopener noreferrer",style:l?{width:`${l}px`}:void 0},t.createElement(Cf,{content:n,aspectRatio:s,borderRadius:o,cursor:"pointer"})))))},ZS=e=>{var r;const{theme:i,titleFontSize:n,title:s}=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({},n&&{fontSize:n}),{fontWeight:"bold",color:null==i?void 0:i.textColor,paddingTop:"10px",paddingBottom:"10px",marginBottom:"30px"})},s||("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 JS(t){var{className:r}=t,i=T(t,["className"]);return e.createElement("div",Object.assign({className:wt("animate-pulse rounded-md bg-gray-200",r)},i))}const eT=e=>{var r,i,n,s,a,o,l,d,c;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!==(n=null==u?void 0:u.gridColumns)&&void 0!==n?n:3,b=null!==(s=null==u?void 0:u.gap)&&void 0!==s?s: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!==(d=null==p?void 0:p.paddingLeft)&&void 0!==d?d:0,x=null!==(c=null==p?void 0:p.paddingRight)&&void 0!==c?c: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(JS,{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(JS,{style:{aspectRatio:h,borderRadius:E,width:"100%"}}),t.createElement(JS,{className:"h-3.5 w-4/5"})))))},tT=e=>{var r,i,n,s;const{widgetType:a,theme:o,layout:l}=e,{liveWidget:d}=If(),c=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!==(n=null==l?void 0:l.paddingLeft)&&void 0!==n?n:0,f=null!==(s=null==l?void 0:l.paddingRight)&&void 0!==s?s:0;return null===d?t.createElement(eT,Object.assign({},e)):0===d.length?t.createElement(ZS,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:c,paddingBottom:u,paddingLeft:h,paddingRight:f}},"ONE"===a&&"past"!==e.liveType?t.createElement(QS,Object.assign({content:d[0]},e)):t.createElement(KS,Object.assign({content:d},e)))},rT=e=>{const{setLiveWidget:r,liveWidget:n}=If(),{userId:s,card:a,includeRepresentative:o,liveType:l}=e;return i(()=>{if(!s)return;if(n&&(null==a?void 0:a.visibleCount)&&n.length>Number(a.visibleCount))return void r(n.slice(0,null==a?void 0:a.visibleCount));const t=new AbortController;return x(void 0,void 0,void 0,function*(){const i=yield Ys(s,"past"===l?"FINISHED":"UPCOMING",(null==a?void 0:a.visibleCount)||6,o,e.sorting);if(!i||t.signal.aborted)return;r(i);const n=yield Promise.allSettled(i.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`,n=yield fetch(i);if(404!==n.status){if(!n.ok){const e=yield n.text().catch(()=>"");return console.error(`[ReplayStatistics] ${n.status} ${n.statusText} ${e}`),{pageView:0,like:0}}return n.json()}}))(s,e.eventId);return Object.assign(Object.assign({},e),{statistics:t})})));t.signal.aborted||r(n.map((e,t)=>"fulfilled"===e.status?e.value:i[t]))}),()=>t.abort()},[s,null==a?void 0:a.visibleCount,l,e.sorting,o]),t.createElement(fh.div,{className:"w-full h-full"},t.createElement(Eh,null),t.createElement(tT,Object.assign({},e)))},iT=({eventId:e})=>{const[r,i]=a(!1),{PLAYER_BASE_URL:n}=gt();if(r)return null;const{w:s,h:o,left:l,top:d}=(()=>{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(xf,{minWidth:240,lockAspectRatio:9/17.05,style:{zIndex:99999},default:{width:240,height:455,x:l+s-240-50,y:d+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(Ht,{size:16,color:"#888"}),t.createElement("button",{className:"cursor-pointer",style:{color:"#ccc",lineHeight:0},onClick:()=>i(!0),"aria-label":"Close"},t.createElement(Qt,{size:16}))),t.createElement("iframe",{src:`${n}/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"})))},nT=({eventId:e})=>e?t.createElement(fh.div,{style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:99999}},t.createElement(Eh,null),t.createElement("div",{style:{pointerEvents:"auto"}},t.createElement(iT,{eventId:e}))):null;export{kh as CollectionShowcase,Lf as FloatingPlayer,nT as LiveFloatingPlayer,rT as LiveWidget,Od as PreviewPlayer,_d as ShoppingPlayer,Ct as ViewPlayer,Th as WidgetPlayer,mt as configure};