hamrahi-player-library 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -0
- package/dist/hamrahi-player-library.css +7 -0
- package/dist/hamrahi-player-library.js +6 -0
- package/dist/hamrahi-player-library.umd.cjs +64 -0
- package/dist/index-2OVdYUgm.js +21871 -0
- package/dist/main.d.ts +1 -0
- package/dist/nonStaticVideoTag-CaUIINW6.js +137 -0
- package/dist/notActive-DokxPXmF.js +10 -0
- package/dist/staticPlayer-CqHC_NDw.js +13 -0
- package/dist/staticVideoTag-Bq3QUZG0.js +57 -0
- package/dist/touchVolumeBrightness-zJwzVg8P.js +131 -0
- package/dist/useHideSubtitle-xaoPFO2J.js +29 -0
- package/dist/user.actions-ChPfxQsM.js +29 -0
- package/dist/videoArea-B8winUaa.js +1379 -0
- package/dist/videoPlayerLibrary/components/custom-components/backwardForward/backwardForward.d.ts +3 -0
- package/dist/videoPlayerLibrary/components/custom-components/elapsedTime/elapsedTime.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/emoji/emoji.d.ts +3 -0
- package/dist/videoPlayerLibrary/components/custom-components/footer/controllbar/controllbar.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/footer/controllbar/controllbarTooltip.d.ts +3 -0
- package/dist/videoPlayerLibrary/components/custom-components/footer/footer.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/footer/progressbar/markers/markers.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/footer/progressbar/progressbar.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/fullScreen/fullScreen.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/header/header.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/loader/loader.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/lockUnlock/lock.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/lockUnlock/unlock.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/main/main.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/markersList/markersList.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/markersList/markersListIcon.d.ts +3 -0
- package/dist/videoPlayerLibrary/components/custom-components/miniPlayer/miniPlayer.d.ts +4 -0
- package/dist/videoPlayerLibrary/components/custom-components/miniPlayer/videoTag/miniPlayerNonStaticVideoTag.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/miniPlayer/videoTag/miniPlayerStaticVideoTag.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/miniPlayer/videoTag/videoTag.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/notActive/notActive.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/pictureInPicture/pictureInPicture.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/playPause/miniPlayerPlayPause.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/playPause/playPause.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/popover/popover.d.ts +3 -0
- package/dist/videoPlayerLibrary/components/custom-components/qualityLevels/qualityLevels.d.ts +3 -0
- package/dist/videoPlayerLibrary/components/custom-components/settings/settings.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/soundVolume/soundVolume.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/speed/speed.d.ts +3 -0
- package/dist/videoPlayerLibrary/components/custom-components/subtitles/displaySubtitle.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/subtitles/subtitleIcon.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/subtitles/subtitleSettingMenu.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/title/title.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/toggle/toggle.d.ts +3 -0
- package/dist/videoPlayerLibrary/components/custom-components/tooltip/tooltip.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/touchVolumeBrightness/touchVolumeBrightness.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/videoArea/videoArea.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/videoAreaShadow.tsx/videoAreaShadow.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/videoTag/nonStaticVideoTag.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/videoTag/staticVideoTag.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/custom-components/videoTag/videoTag.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/icon-components/closeIcon.d.ts +3 -0
- package/dist/videoPlayerLibrary/components/icon-components/mute.d.ts +3 -0
- package/dist/videoPlayerLibrary/components/icon-components/speed.d.ts +3 -0
- package/dist/videoPlayerLibrary/components/icon-components/unMute.d.ts +3 -0
- package/dist/videoPlayerLibrary/components/videoPlayer/staticPlayer/staticPlayer.d.ts +2 -0
- package/dist/videoPlayerLibrary/components/videoPlayer/videoPlayer.d.ts +6 -0
- package/dist/videoPlayerLibrary/components/videoPlayer/vodPlayer/vodPlayer.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/conditions/conditions.d.ts +1 -0
- package/dist/videoPlayerLibrary/helpers/configs/nextConfigs/env.d.ts +4 -0
- package/dist/videoPlayerLibrary/helpers/configs/npmPackage/npmPackage.d.ts +1 -0
- package/dist/videoPlayerLibrary/helpers/configs/npmPackage/npmPackage_lib.d.ts +1 -0
- package/dist/videoPlayerLibrary/helpers/configs/propsColors.d.ts +1 -0
- package/dist/videoPlayerLibrary/helpers/constants.d.ts +4 -0
- package/dist/videoPlayerLibrary/helpers/environment.d.ts +5 -0
- package/dist/videoPlayerLibrary/helpers/errorBoundary/errorBoundary.d.ts +14 -0
- package/dist/videoPlayerLibrary/helpers/errorBoundary/errorBoundaryFunctions.d.ts +6 -0
- package/dist/videoPlayerLibrary/helpers/getDetailsConfigs.d.ts +3 -0
- package/dist/videoPlayerLibrary/helpers/helpers.d.ts +27 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useActiveInActive.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useBeforeUnload.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useContinuousPlaybackInterval.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useFullScreen.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useGetData/useGetData.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useGetData/useGetDetails.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useGetData/useGetMarkers.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useHandleKeyPress.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useHandleParams.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useHandleResize.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useHideSubtitle.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useJumpToCurrentTime.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useKeyPress.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useLongPress.d.ts +7 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useOnClickOutside.d.ts +3 -0
- package/dist/videoPlayerLibrary/helpers/hooks/usePingPong.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/hooks/useSetSubtitleFirstPlay.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/interfaces/enums.d.ts +100 -0
- package/dist/videoPlayerLibrary/helpers/interfaces/interfaces.d.ts +252 -0
- package/dist/videoPlayerLibrary/helpers/logs/fluentdLogger.d.ts +1 -0
- package/dist/videoPlayerLibrary/helpers/logs/logs.d.ts +163 -0
- package/dist/videoPlayerLibrary/helpers/redux/actions/controller.actions.d.ts +12 -0
- package/dist/videoPlayerLibrary/helpers/redux/actions/playerCore.actions.d.ts +116 -0
- package/dist/videoPlayerLibrary/helpers/redux/actions/progressbar.actions.d.ts +15 -0
- package/dist/videoPlayerLibrary/helpers/redux/actions/user.actions.d.ts +2 -0
- package/dist/videoPlayerLibrary/helpers/redux/actions/videoData.actions.d.ts +7 -0
- package/dist/videoPlayerLibrary/helpers/redux/hooks.d.ts +4 -0
- package/dist/videoPlayerLibrary/helpers/redux/slices/controllerSlice.d.ts +26 -0
- package/dist/videoPlayerLibrary/helpers/redux/slices/miniPlayerSlice.d.ts +11 -0
- package/dist/videoPlayerLibrary/helpers/redux/slices/popoversSlice.d.ts +12 -0
- package/dist/videoPlayerLibrary/helpers/redux/slices/userSlice.d.ts +10 -0
- package/dist/videoPlayerLibrary/helpers/redux/slices/videoDataSlice.d.ts +20 -0
- package/dist/videoPlayerLibrary/helpers/redux/store.d.ts +18 -0
- package/dist/videoPlayerLibrary/helpers/services/apiCaller.d.ts +3 -0
- package/dist/videoPlayerLibrary/helpers/services/baseUrl.d.ts +3 -0
- package/dist/videoPlayerLibrary/helpers/services/services.d.ts +8 -0
- package/dist/videoPlayerLibrary/images/importImages.d.ts +2 -0
- package/dist/videoPlayerLibrary/index.d.ts +3 -0
- package/dist/videoPlayerLibrary/miniPlayerLibrary.d.ts +4 -0
- package/dist/videoPlayerLibrary/videoPlayerLibrary.d.ts +4 -0
- package/dist/vodPlayer-BZxT6vEI.js +24 -0
- package/package.json +63 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
(function(Le,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],S):(Le=typeof globalThis<"u"?globalThis:Le||self,S(Le.videoPlayerLibrary={},Le.jsxRuntime,Le.React,Le.reactDom))})(this,function(Le,S,P,Iu){"use strict";var Vy=Object.defineProperty;var Gy=(Le,S,P)=>S in Le?Vy(Le,S,{enumerable:!0,configurable:!0,writable:!0,value:P}):Le[S]=P;var Du=(Le,S,P)=>Gy(Le,typeof S!="symbol"?S+"":S,P);function Ru(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const Ne=Ru(P);var Pe=(n=>(n[n.vttDisable=-2]="vttDisable",n[n.backwardForwardInActive=1]="backwardForwardInActive",n[n.videoPlayer=2]="videoPlayer",n[n.mainIcons=3]="mainIcons",n[n.footer=4]="footer",n[n.vtt=5]="vtt",n[n.markers=6]="markers",n[n.videoPlayerInFullScreen=1e6]="videoPlayerInFullScreen",n[n.popoverBlurBackground=1000001]="popoverBlurBackground",n[n.backwardForwardActive=1000002]="backwardForwardActive",n[n.miniPlayer=1000003]="miniPlayer",n[n.popoverContent=1000004]="popoverContent",n[n.maxPopover=1000005]="maxPopover",n[n.videoPlayerInPictureInPicture=1000006]="videoPlayerInPictureInPicture",n))(Pe||{}),me=(n=>(n.main="main",n.qualityLevels="qualityLevels",n.speed="speed",n.subtitles="subtitles",n))(me||{}),Tt=(n=>(n.static="static",n.vod="vod",n))(Tt||{}),qn=(n=>(n.speed="speed",n))(qn||{}),T=(n=>(n.showHeader="showHeader",n.showMain="showMain",n.showFooter="showFooter",n.showTouchVolumeBrightness="showTouchVolumeBrightness",n.showBackwardForward="showBackwardForward",n.showTitle="showTitle",n.showSettingPopover="showSettingPopover",n.showSpeedPopover="showSpeedPopover",n.showQualityLevelsPopover="showQualityLevelsPopover",n.showSettingIcon="showSettingIcon",n.showBanner="showBanner",n.showProgressbar="showProgressbar",n.showPictureInPicture="showPictureInPicture",n.showSubtitle="showSubtitle",n.showMarkerListPopover="showMarkerListPopover",n.hidePopovers="hidePopovers",n.isLandscape="isLandscape",n.isTouchScreen="isTouchScreen",n.isTouchScreenPortrait="isTouchScreenPortrait",n.isTouchScreenLandscape="isTouchScreenLandscape",n.isActiveElements="isActiveElements",n.isPlay="isPlay",n.isPlayMiniPlayer="isPlayMiniPlayer",n.isFirstPlay="isFirstPlay",n.isLock="isLock",n.isIOS="isIOS",n.isLoading="isLoading",n.isStaticFormat="isStaticFormat",n.isEnded="isEnded",n.isAutoPlay="isAutoPlay",n.isFullScreen="isFullScreen",n.isValidAddress="isValidAddress",n.isFetchDetails="isFetchDetails",n.isAutoQuality="isAutoQuality",n.isPressKeySpace="isPressKeySpace",n.isPressKeyI="isPressKeyI",n.isPressKeyF="isPressKeyF",n.isPressKeyS="isPressKeyS",n.isPressKeyArrowRight="isPressKeyArrowRight",n.isPressKeyArrowLeft="isPressKeyArrowLeft",n.isPressKeyM="isPressKeyM",n.isPressKeyC="isPressKeyC",n.isSendTimelineLog="isSendTimelineLog",n.isReady="isReady",n.isSelectedSubtitle="isSelectedSubtitle",n.isMiniPlayerAndMainPlayerSame="isMiniPlayerAndMainPlayerSame",n.hasTitle="hasTitle",n.hasBanner="hasBanner",n.hasStreamLink="hasStreamLink",n.hasManualQuality="hasManualQuality",n.hasSound="hasSound",n.hasAutoPlay="hasAutoPlay",n.hasFullScreenParams="hasFullScreenParams",n.hasOnFinishedParams="hasOnFinishedParams",n.hasSubtitles="hasSubtitles",n.hasSubtitlesInDetails="hasSubtitlesInDetails",n.hasActiveCue="hasActiveCue",n.hasOnPlayParams="hasOnPlayParams",n.hasOnPauseParams="hasOnPauseParams",n.hasPlayStatusParams="hasPlayStatusParams",n.hasMiniPlayer="hasMiniPlayer",n.hasCurrentTimeParams="hasCurrentTimeParams",n.hasMarkers="hasMarkers",n.hasSubtitlesInParams="hasSubtitlesInParams",n.getDetails="getDetails",n.getMarkers="getMarkers",n.canPlayVideo="canPlayVideo",n.setSubtitleFirstPlay="setSubtitleFirstPlay",n.hasNoSpeed="hasNoSpeed",n))(T||{}),Ls={exports:{}},Yn={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* use-sync-external-store-with-selector.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Gi;function ku(){if(Gi)return Yn;Gi=1;var n=P;function e(l,c){return l===c&&(l!==0||1/l===1/c)||l!==l&&c!==c}var t=typeof Object.is=="function"?Object.is:e,s=n.useSyncExternalStore,r=n.useRef,i=n.useEffect,a=n.useMemo,o=n.useDebugValue;return Yn.useSyncExternalStoreWithSelector=function(l,c,u,d,f){var g=r(null);if(g.current===null){var h={hasValue:!1,value:null};g.current=h}else h=g.current;g=a(function(){function p(b){if(!E){if(E=!0,x=b,b=d(b),f!==void 0&&h.hasValue){var I=h.value;if(f(I,b))return v=I}return v=b}if(I=v,t(x,b))return I;var A=d(b);return f!==void 0&&f(I,A)?(x=b,I):(x=b,v=A)}var E=!1,x,v,w=u===void 0?null:u;return[function(){return p(c())},w===null?void 0:function(){return p(w())}]},[c,u,d,f]);var m=s(l,g[0],g[1]);return i(function(){h.hasValue=!0,h.value=m},[m]),o(m),m},Yn}var Xn={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* use-sync-external-store-with-selector.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var Hi;function Pu(){return Hi||(Hi=1,process.env.NODE_ENV!=="production"&&function(){function n(l,c){return l===c&&(l!==0||1/l===1/c)||l!==l&&c!==c}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var e=P,t=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,r=e.useRef,i=e.useEffect,a=e.useMemo,o=e.useDebugValue;Xn.useSyncExternalStoreWithSelector=function(l,c,u,d,f){var g=r(null);if(g.current===null){var h={hasValue:!1,value:null};g.current=h}else h=g.current;g=a(function(){function p(b){if(!E){if(E=!0,x=b,b=d(b),f!==void 0&&h.hasValue){var I=h.value;if(f(I,b))return v=I}return v=b}if(I=v,t(x,b))return I;var A=d(b);return f!==void 0&&f(I,A)?(x=b,I):(x=b,v=A)}var E=!1,x,v,w=u===void 0?null:u;return[function(){return p(c())},w===null?void 0:function(){return p(w())}]},[c,u,d,f]);var m=s(l,g[0],g[1]);return i(function(){h.hasValue=!0,h.value=m},[m]),o(m),m},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Xn}var Ki;function _u(){return Ki||(Ki=1,process.env.NODE_ENV==="production"?Ls.exports=ku():Ls.exports=Pu()),Ls.exports}var Ou=_u();function Fu(n){n()}function Mu(){let n=null,e=null;return{clear(){n=null,e=null},notify(){Fu(()=>{let t=n;for(;t;)t.callback(),t=t.next})},get(){const t=[];let s=n;for(;s;)t.push(s),s=s.next;return t},subscribe(t){let s=!0;const r=e={callback:t,next:null,prev:e};return r.prev?r.prev.next=r:n=r,function(){!s||n===null||(s=!1,r.next?r.next.prev=r.prev:e=r.prev,r.prev?r.prev.next=r.next:n=r.next)}}}}var Wi={notify(){},get:()=>[]};function Nu(n,e){let t,s=Wi,r=0,i=!1;function a(m){u();const p=s.subscribe(m);let E=!1;return()=>{E||(E=!0,p(),d())}}function o(){s.notify()}function l(){h.onStateChange&&h.onStateChange()}function c(){return i}function u(){r++,t||(t=n.subscribe(l),s=Mu())}function d(){r--,t&&r===0&&(t(),t=void 0,s.clear(),s=Wi)}function f(){i||(i=!0,u())}function g(){i&&(i=!1,d())}const h={addNestedSub:a,notifyNestedSubs:o,handleChangeWrapper:l,isSubscribed:c,trySubscribe:f,tryUnsubscribe:g,getListeners:()=>s};return h}var Bu=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Uu=Bu(),$u=()=>typeof navigator<"u"&&navigator.product==="ReactNative",Vu=$u(),Gu=()=>Uu||Vu?Ne.useLayoutEffect:Ne.useEffect,Hu=Gu();function ji(n,e){return n===e?n!==0||e!==0||1/n===1/e:n!==n&&e!==e}function K(n,e){if(ji(n,e))return!0;if(typeof n!="object"||n===null||typeof e!="object"||e===null)return!1;const t=Object.keys(n),s=Object.keys(e);if(t.length!==s.length)return!1;for(let r=0;r<t.length;r++)if(!Object.prototype.hasOwnProperty.call(e,t[r])||!ji(n[t[r]],e[t[r]]))return!1;return!0}var Zn=Symbol.for("react-redux-context"),Qn=typeof globalThis<"u"?globalThis:{};function Ku(){if(!Ne.createContext)return{};const n=Qn[Zn]??(Qn[Zn]=new Map);let e=n.get(Ne.createContext);return e||(e=Ne.createContext(null),process.env.NODE_ENV!=="production"&&(e.displayName="ReactRedux"),n.set(Ne.createContext,e)),e}var ht=Ku();function Wu(n){const{children:e,context:t,serverState:s,store:r}=n,i=Ne.useMemo(()=>{const l=Nu(r),c={store:r,subscription:l,getServerState:s?()=>s:void 0};if(process.env.NODE_ENV==="production")return c;{const{identityFunctionCheck:u="once",stabilityCheck:d="once"}=n;return Object.assign(c,{stabilityCheck:d,identityFunctionCheck:u})}},[r,s]),a=Ne.useMemo(()=>r.getState(),[r]);Hu(()=>{const{subscription:l}=i;return l.onStateChange=l.notifyNestedSubs,l.trySubscribe(),a!==r.getState()&&l.notifyNestedSubs(),()=>{l.tryUnsubscribe(),l.onStateChange=void 0}},[i,a]);const o=t||ht;return Ne.createElement(o.Provider,{value:i},e)}var zi=Wu;function Jn(n=ht){return function(){const t=Ne.useContext(n);if(process.env.NODE_ENV!=="production"&&!t)throw new Error("could not find react-redux context value; please ensure the component is wrapped in a <Provider>");return t}}var qi=Jn();function Yi(n=ht){const e=n===ht?qi:Jn(n),t=()=>{const{store:s}=e();return s};return Object.assign(t,{withTypes:()=>t}),t}var ju=Yi();function zu(n=ht){const e=n===ht?ju:Yi(n),t=()=>e().dispatch;return Object.assign(t,{withTypes:()=>t}),t}var qu=zu(),Yu=(n,e)=>n===e;function Xu(n=ht){const e=n===ht?qi:Jn(n),t=(s,r={})=>{const{equalityFn:i=Yu}=typeof r=="function"?{equalityFn:r}:r;if(process.env.NODE_ENV!=="production"){if(!s)throw new Error("You must pass a selector to useSelector");if(typeof s!="function")throw new Error("You must pass a function as a selector to useSelector");if(typeof i!="function")throw new Error("You must pass a function as an equality function to useSelector")}const a=e(),{store:o,subscription:l,getServerState:c}=a,u=Ne.useRef(!0),d=Ne.useCallback({[s.name](g){const h=s(g);if(process.env.NODE_ENV!=="production"){const{devModeChecks:m={}}=typeof r=="function"?{}:r,{identityFunctionCheck:p,stabilityCheck:E}=a,{identityFunctionCheck:x,stabilityCheck:v}={stabilityCheck:E,identityFunctionCheck:p,...m};if(v==="always"||v==="once"&&u.current){const w=s(g);if(!i(h,w)){let b;try{throw new Error}catch(I){({stack:b}=I)}console.warn("Selector "+(s.name||"unknown")+` returned a different result when called with the same parameters. This can lead to unnecessary rerenders.
|
|
18
|
+
Selectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization`,{state:g,selected:h,selected2:w,stack:b})}}if((x==="always"||x==="once"&&u.current)&&h===g){let w;try{throw new Error}catch(b){({stack:w}=b)}console.warn("Selector "+(s.name||"unknown")+` returned the root state when called. This can lead to unnecessary rerenders.
|
|
19
|
+
Selectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.`,{stack:w})}u.current&&(u.current=!1)}return h}}[s.name],[s]),f=Ou.useSyncExternalStoreWithSelector(l.addNestedSub,o.getState,c||o.getState,d,i);return Ne.useDebugValue(f),f};return Object.assign(t,{withTypes:()=>t}),t}var Zu=Xu();function Ae(n){return`Minified Redux error #${n}; visit https://redux.js.org/Errors?code=${n} for the full message or use the non-minified dev environment for full errors. `}var Qu=typeof Symbol=="function"&&Symbol.observable||"@@observable",Xi=Qu,er=()=>Math.random().toString(36).substring(7).split("").join("."),Ju={INIT:`@@redux/INIT${er()}`,REPLACE:`@@redux/REPLACE${er()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${er()}`},xt=Ju;function es(n){if(typeof n!="object"||n===null)return!1;let e=n;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(n)===e||Object.getPrototypeOf(n)===null}function ed(n){if(n===void 0)return"undefined";if(n===null)return"null";const e=typeof n;switch(e){case"boolean":case"string":case"number":case"symbol":case"function":return e}if(Array.isArray(n))return"array";if(nd(n))return"date";if(sd(n))return"error";const t=td(n);switch(t){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return t}return Object.prototype.toString.call(n).slice(8,-1).toLowerCase().replace(/\s/g,"")}function td(n){return typeof n.constructor=="function"?n.constructor.name:null}function sd(n){return n instanceof Error||typeof n.message=="string"&&n.constructor&&typeof n.constructor.stackTraceLimit=="number"}function nd(n){return n instanceof Date?!0:typeof n.toDateString=="function"&&typeof n.getDate=="function"&&typeof n.setDate=="function"}function pt(n){let e=typeof n;return process.env.NODE_ENV!=="production"&&(e=ed(n)),e}function Zi(n,e,t){if(typeof n!="function")throw new Error(process.env.NODE_ENV==="production"?Ae(2):`Expected the root reducer to be a function. Instead, received: '${pt(n)}'`);if(typeof e=="function"&&typeof t=="function"||typeof t=="function"&&typeof arguments[3]=="function")throw new Error(process.env.NODE_ENV==="production"?Ae(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if(typeof e=="function"&&typeof t>"u"&&(t=e,e=void 0),typeof t<"u"){if(typeof t!="function")throw new Error(process.env.NODE_ENV==="production"?Ae(1):`Expected the enhancer to be a function. Instead, received: '${pt(t)}'`);return t(Zi)(n,e)}let s=n,r=e,i=new Map,a=i,o=0,l=!1;function c(){a===i&&(a=new Map,i.forEach((p,E)=>{a.set(E,p)}))}function u(){if(l)throw new Error(process.env.NODE_ENV==="production"?Ae(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return r}function d(p){if(typeof p!="function")throw new Error(process.env.NODE_ENV==="production"?Ae(4):`Expected the listener to be a function. Instead, received: '${pt(p)}'`);if(l)throw new Error(process.env.NODE_ENV==="production"?Ae(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let E=!0;c();const x=o++;return a.set(x,p),function(){if(E){if(l)throw new Error(process.env.NODE_ENV==="production"?Ae(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");E=!1,c(),a.delete(x),i=null}}}function f(p){if(!es(p))throw new Error(process.env.NODE_ENV==="production"?Ae(7):`Actions must be plain objects. Instead, the actual type was: '${pt(p)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(typeof p.type>"u")throw new Error(process.env.NODE_ENV==="production"?Ae(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if(typeof p.type!="string")throw new Error(process.env.NODE_ENV==="production"?Ae(17):`Action "type" property must be a string. Instead, the actual type was: '${pt(p.type)}'. Value was: '${p.type}' (stringified)`);if(l)throw new Error(process.env.NODE_ENV==="production"?Ae(9):"Reducers may not dispatch actions.");try{l=!0,r=s(r,p)}finally{l=!1}return(i=a).forEach(x=>{x()}),p}function g(p){if(typeof p!="function")throw new Error(process.env.NODE_ENV==="production"?Ae(10):`Expected the nextReducer to be a function. Instead, received: '${pt(p)}`);s=p,f({type:xt.REPLACE})}function h(){const p=d;return{subscribe(E){if(typeof E!="object"||E===null)throw new Error(process.env.NODE_ENV==="production"?Ae(11):`Expected the observer to be an object. Instead, received: '${pt(E)}'`);function x(){const w=E;w.next&&w.next(u())}return x(),{unsubscribe:p(x)}},[Xi](){return this}}}return f({type:xt.INIT}),{dispatch:f,subscribe:d,getState:u,replaceReducer:g,[Xi]:h}}function Qi(n){typeof console<"u"&&typeof console.error=="function"&&console.error(n);try{throw new Error(n)}catch{}}function rd(n,e,t,s){const r=Object.keys(e),i=t&&t.type===xt.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(r.length===0)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!es(n))return`The ${i} has unexpected type of "${pt(n)}". Expected argument to be an object with the following keys: "${r.join('", "')}"`;const a=Object.keys(n).filter(o=>!e.hasOwnProperty(o)&&!s[o]);if(a.forEach(o=>{s[o]=!0}),!(t&&t.type===xt.REPLACE)&&a.length>0)return`Unexpected ${a.length>1?"keys":"key"} "${a.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${r.join('", "')}". Unexpected keys will be ignored.`}function id(n){Object.keys(n).forEach(e=>{const t=n[e];if(typeof t(void 0,{type:xt.INIT})>"u")throw new Error(process.env.NODE_ENV==="production"?Ae(12):`The slice reducer for key "${e}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(typeof t(void 0,{type:xt.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(process.env.NODE_ENV==="production"?Ae(13):`The slice reducer for key "${e}" returned undefined when probed with a random type. Don't try to handle '${xt.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)})}function ad(n){const e=Object.keys(n),t={};for(let a=0;a<e.length;a++){const o=e[a];process.env.NODE_ENV!=="production"&&typeof n[o]>"u"&&Qi(`No reducer provided for key "${o}"`),typeof n[o]=="function"&&(t[o]=n[o])}const s=Object.keys(t);let r;process.env.NODE_ENV!=="production"&&(r={});let i;try{id(t)}catch(a){i=a}return function(o={},l){if(i)throw i;if(process.env.NODE_ENV!=="production"){const d=rd(o,t,l,r);d&&Qi(d)}let c=!1;const u={};for(let d=0;d<s.length;d++){const f=s[d],g=t[f],h=o[f],m=g(h,l);if(typeof m>"u"){const p=l&&l.type;throw new Error(process.env.NODE_ENV==="production"?Ae(14):`When called with an action of type ${p?`"${String(p)}"`:"(unknown type)"}, the slice reducer for key "${f}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}u[f]=m,c=c||m!==h}return c=c||s.length!==Object.keys(o).length,c?u:o}}function As(...n){return n.length===0?e=>e:n.length===1?n[0]:n.reduce((e,t)=>(...s)=>e(t(...s)))}function od(...n){return e=>(t,s)=>{const r=e(t,s);let i=()=>{throw new Error(process.env.NODE_ENV==="production"?Ae(15):"Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const a={getState:r.getState,dispatch:(l,...c)=>i(l,...c)},o=n.map(l=>l(a));return i=As(...o)(r.dispatch),{...r,dispatch:i}}}function Ji(n){return es(n)&&"type"in n&&typeof n.type=="string"}var ea=Symbol.for("immer-nothing"),ta=Symbol.for("immer-draftable"),Be=Symbol.for("immer-state"),ld=process.env.NODE_ENV!=="production"?[function(n){return`The plugin for '${n}' has not been loaded into Immer. To enable the plugin, import and call \`enable${n}()\` when initializing your application.`},function(n){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${n}'`},"This object has been frozen and should not be mutated",function(n){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(n){return`'current' expects a draft, got: ${n}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(n){return`'original' expects a draft, got: ${n}`}]:[];function _e(n,...e){if(process.env.NODE_ENV!=="production"){const t=ld[n],s=typeof t=="function"?t.apply(null,e):t;throw new Error(`[Immer] ${s}`)}throw new Error(`[Immer] minified error nr: ${n}. Full error at: https://bit.ly/3cXEKWf`)}var Ut=Object.getPrototypeOf;function vt(n){return!!n&&!!n[Be]}function it(n){var e;return n?sa(n)||Array.isArray(n)||!!n[ta]||!!((e=n.constructor)!=null&&e[ta])||Rs(n)||ks(n):!1}var cd=Object.prototype.constructor.toString();function sa(n){if(!n||typeof n!="object")return!1;const e=Ut(n);if(e===null)return!0;const t=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return t===Object?!0:typeof t=="function"&&Function.toString.call(t)===cd}function Ds(n,e){Is(n)===0?Reflect.ownKeys(n).forEach(t=>{e(t,n[t],n)}):n.forEach((t,s)=>e(s,t,n))}function Is(n){const e=n[Be];return e?e.type_:Array.isArray(n)?1:Rs(n)?2:ks(n)?3:0}function tr(n,e){return Is(n)===2?n.has(e):Object.prototype.hasOwnProperty.call(n,e)}function na(n,e,t){const s=Is(n);s===2?n.set(e,t):s===3?n.add(t):n[e]=t}function ud(n,e){return n===e?n!==0||1/n===1/e:n!==n&&e!==e}function Rs(n){return n instanceof Map}function ks(n){return n instanceof Set}function bt(n){return n.copy_||n.base_}function sr(n,e){if(Rs(n))return new Map(n);if(ks(n))return new Set(n);if(Array.isArray(n))return Array.prototype.slice.call(n);const t=sa(n);if(e===!0||e==="class_only"&&!t){const s=Object.getOwnPropertyDescriptors(n);delete s[Be];let r=Reflect.ownKeys(s);for(let i=0;i<r.length;i++){const a=r[i],o=s[a];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(s[a]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[a]})}return Object.create(Ut(n),s)}else{const s=Ut(n);if(s!==null&&t)return{...n};const r=Object.create(s);return Object.assign(r,n)}}function nr(n,e=!1){return Ps(n)||vt(n)||!it(n)||(Is(n)>1&&(n.set=n.add=n.clear=n.delete=dd),Object.freeze(n),e&&Object.entries(n).forEach(([t,s])=>nr(s,!0))),n}function dd(){_e(2)}function Ps(n){return Object.isFrozen(n)}var fd={};function Ct(n){const e=fd[n];return e||_e(0,n),e}var ts;function ra(){return ts}function hd(n,e){return{drafts_:[],parent_:n,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ia(n,e){e&&(Ct("Patches"),n.patches_=[],n.inversePatches_=[],n.patchListener_=e)}function rr(n){ir(n),n.drafts_.forEach(pd),n.drafts_=null}function ir(n){n===ts&&(ts=n.parent_)}function aa(n){return ts=hd(ts,n)}function pd(n){const e=n[Be];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function oa(n,e){e.unfinalizedDrafts_=e.drafts_.length;const t=e.drafts_[0];return n!==void 0&&n!==t?(t[Be].modified_&&(rr(e),_e(4)),it(n)&&(n=_s(e,n),e.parent_||Os(e,n)),e.patches_&&Ct("Patches").generateReplacementPatches_(t[Be].base_,n,e.patches_,e.inversePatches_)):n=_s(e,t,[]),rr(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),n!==ea?n:void 0}function _s(n,e,t){if(Ps(e))return e;const s=e[Be];if(!s)return Ds(e,(r,i)=>la(n,s,e,r,i,t)),e;if(s.scope_!==n)return e;if(!s.modified_)return Os(n,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;const r=s.copy_;let i=r,a=!1;s.type_===3&&(i=new Set(r),r.clear(),a=!0),Ds(i,(o,l)=>la(n,s,r,o,l,t,a)),Os(n,r,!1),t&&n.patches_&&Ct("Patches").generatePatches_(s,t,n.patches_,n.inversePatches_)}return s.copy_}function la(n,e,t,s,r,i,a){if(process.env.NODE_ENV!=="production"&&r===t&&_e(5),vt(r)){const o=i&&e&&e.type_!==3&&!tr(e.assigned_,s)?i.concat(s):void 0,l=_s(n,r,o);if(na(t,s,l),vt(l))n.canAutoFreeze_=!1;else return}else a&&t.add(r);if(it(r)&&!Ps(r)){if(!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1)return;_s(n,r),(!e||!e.scope_.parent_)&&typeof s!="symbol"&&Object.prototype.propertyIsEnumerable.call(t,s)&&Os(n,r)}}function Os(n,e,t=!1){!n.parent_&&n.immer_.autoFreeze_&&n.canAutoFreeze_&&nr(e,t)}function gd(n,e){const t=Array.isArray(n),s={type_:t?1:0,scope_:e?e.scope_:ra(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:n,draft_:null,copy_:null,revoke_:null,isManual_:!1};let r=s,i=ar;t&&(r=[s],i=ss);const{revoke:a,proxy:o}=Proxy.revocable(r,i);return s.draft_=o,s.revoke_=a,o}var ar={get(n,e){if(e===Be)return n;const t=bt(n);if(!tr(t,e))return md(n,t,e);const s=t[e];return n.finalized_||!it(s)?s:s===or(n.base_,e)?(cr(n),n.copy_[e]=ur(s,n)):s},has(n,e){return e in bt(n)},ownKeys(n){return Reflect.ownKeys(bt(n))},set(n,e,t){const s=ca(bt(n),e);if(s!=null&&s.set)return s.set.call(n.draft_,t),!0;if(!n.modified_){const r=or(bt(n),e),i=r==null?void 0:r[Be];if(i&&i.base_===t)return n.copy_[e]=t,n.assigned_[e]=!1,!0;if(ud(t,r)&&(t!==void 0||tr(n.base_,e)))return!0;cr(n),lr(n)}return n.copy_[e]===t&&(t!==void 0||e in n.copy_)||Number.isNaN(t)&&Number.isNaN(n.copy_[e])||(n.copy_[e]=t,n.assigned_[e]=!0),!0},deleteProperty(n,e){return or(n.base_,e)!==void 0||e in n.base_?(n.assigned_[e]=!1,cr(n),lr(n)):delete n.assigned_[e],n.copy_&&delete n.copy_[e],!0},getOwnPropertyDescriptor(n,e){const t=bt(n),s=Reflect.getOwnPropertyDescriptor(t,e);return s&&{writable:!0,configurable:n.type_!==1||e!=="length",enumerable:s.enumerable,value:t[e]}},defineProperty(){_e(11)},getPrototypeOf(n){return Ut(n.base_)},setPrototypeOf(){_e(12)}},ss={};Ds(ar,(n,e)=>{ss[n]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}}),ss.deleteProperty=function(n,e){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(e))&&_e(13),ss.set.call(this,n,e,void 0)},ss.set=function(n,e,t){return process.env.NODE_ENV!=="production"&&e!=="length"&&isNaN(parseInt(e))&&_e(14),ar.set.call(this,n[0],e,t,n[0])};function or(n,e){const t=n[Be];return(t?bt(t):n)[e]}function md(n,e,t){var r;const s=ca(e,t);return s?"value"in s?s.value:(r=s.get)==null?void 0:r.call(n.draft_):void 0}function ca(n,e){if(!(e in n))return;let t=Ut(n);for(;t;){const s=Object.getOwnPropertyDescriptor(t,e);if(s)return s;t=Ut(t)}}function lr(n){n.modified_||(n.modified_=!0,n.parent_&&lr(n.parent_))}function cr(n){n.copy_||(n.copy_=sr(n.base_,n.scope_.immer_.useStrictShallowCopy_))}var yd=class{constructor(n){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,s)=>{if(typeof e=="function"&&typeof t!="function"){const i=t;t=e;const a=this;return function(l=i,...c){return a.produce(l,u=>t.call(this,u,...c))}}typeof t!="function"&&_e(6),s!==void 0&&typeof s!="function"&&_e(7);let r;if(it(e)){const i=aa(this),a=ur(e,void 0);let o=!0;try{r=t(a),o=!1}finally{o?rr(i):ir(i)}return ia(i,s),oa(r,i)}else if(!e||typeof e!="object"){if(r=t(e),r===void 0&&(r=e),r===ea&&(r=void 0),this.autoFreeze_&&nr(r,!0),s){const i=[],a=[];Ct("Patches").generateReplacementPatches_(e,r,i,a),s(i,a)}return r}else _e(1,e)},this.produceWithPatches=(e,t)=>{if(typeof e=="function")return(a,...o)=>this.produceWithPatches(a,l=>e(l,...o));let s,r;return[this.produce(e,t,(a,o)=>{s=a,r=o}),s,r]},typeof(n==null?void 0:n.autoFreeze)=="boolean"&&this.setAutoFreeze(n.autoFreeze),typeof(n==null?void 0:n.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(n.useStrictShallowCopy)}createDraft(n){it(n)||_e(8),vt(n)&&(n=Ed(n));const e=aa(this),t=ur(n,void 0);return t[Be].isManual_=!0,ir(e),t}finishDraft(n,e){const t=n&&n[Be];(!t||!t.isManual_)&&_e(9);const{scope_:s}=t;return ia(s,e),oa(void 0,s)}setAutoFreeze(n){this.autoFreeze_=n}setUseStrictShallowCopy(n){this.useStrictShallowCopy_=n}applyPatches(n,e){let t;for(t=e.length-1;t>=0;t--){const r=e[t];if(r.path.length===0&&r.op==="replace"){n=r.value;break}}t>-1&&(e=e.slice(t+1));const s=Ct("Patches").applyPatches_;return vt(n)?s(n,e):this.produce(n,r=>s(r,e))}};function ur(n,e){const t=Rs(n)?Ct("MapSet").proxyMap_(n,e):ks(n)?Ct("MapSet").proxySet_(n,e):gd(n,e);return(e?e.scope_:ra()).drafts_.push(t),t}function Ed(n){return vt(n)||_e(10,n),ua(n)}function ua(n){if(!it(n)||Ps(n))return n;const e=n[Be];let t;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,t=sr(n,e.scope_.immer_.useStrictShallowCopy_)}else t=sr(n,!0);return Ds(t,(s,r)=>{na(t,s,ua(r))}),e&&(e.finalized_=!1),t}var Ue=new yd,da=Ue.produce;Ue.produceWithPatches.bind(Ue),Ue.setAutoFreeze.bind(Ue),Ue.setUseStrictShallowCopy.bind(Ue),Ue.applyPatches.bind(Ue),Ue.createDraft.bind(Ue),Ue.finishDraft.bind(Ue);var Sd=(n,e,t)=>{if(e.length===1&&e[0]===t){let s=!1;try{const r={};n(r)===r&&(s=!0)}catch{}if(s){let r;try{throw new Error}catch(i){({stack:r}=i)}console.warn(`The result function returned its own inputs without modification. e.g
|
|
20
|
+
\`createSelector([state => state.todos], todos => todos)\`
|
|
21
|
+
This could lead to inefficient memoization and unnecessary re-renders.
|
|
22
|
+
Ensure transformation logic is in the result function, and extraction logic is in the input selectors.`,{stack:r})}}},Td=(n,e,t)=>{const{memoize:s,memoizeOptions:r}=e,{inputSelectorResults:i,inputSelectorResultsCopy:a}=n,o=s(()=>({}),...r);if(!(o.apply(null,i)===o.apply(null,a))){let c;try{throw new Error}catch(u){({stack:c}=u)}console.warn(`An input selector returned a different result when passed same arguments.
|
|
23
|
+
This means your output selector will likely run more frequently than intended.
|
|
24
|
+
Avoid returning a new reference inside your input selector, e.g.
|
|
25
|
+
\`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)\``,{arguments:t,firstInputs:i,secondInputs:a,stack:c})}},xd={inputStabilityCheck:"once",identityFunctionCheck:"once"};function vd(n,e=`expected a function, instead received ${typeof n}`){if(typeof n!="function")throw new TypeError(e)}function bd(n,e=`expected an object, instead received ${typeof n}`){if(typeof n!="object")throw new TypeError(e)}function Cd(n,e="expected all items to be functions, instead received the following types: "){if(!n.every(t=>typeof t=="function")){const t=n.map(s=>typeof s=="function"?`function ${s.name||"unnamed"}()`:typeof s).join(", ");throw new TypeError(`${e}[${t}]`)}}var fa=n=>Array.isArray(n)?n:[n];function wd(n){const e=Array.isArray(n[0])?n[0]:n;return Cd(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function ha(n,e){const t=[],{length:s}=n;for(let r=0;r<s;r++)t.push(n[r].apply(null,e));return t}var Ld=(n,e)=>{const{identityFunctionCheck:t,inputStabilityCheck:s}={...xd,...e};return{identityFunctionCheck:{shouldRun:t==="always"||t==="once"&&n,run:Sd},inputStabilityCheck:{shouldRun:s==="always"||s==="once"&&n,run:Td}}},Ad=class{constructor(n){this.value=n}deref(){return this.value}},Dd=typeof WeakRef<"u"?WeakRef:Ad,Id=0,pa=1;function Fs(){return{s:Id,v:void 0,o:null,p:null}}function ga(n,e={}){let t=Fs();const{resultEqualityCheck:s}=e;let r,i=0;function a(){var d;let o=t;const{length:l}=arguments;for(let f=0,g=l;f<g;f++){const h=arguments[f];if(typeof h=="function"||typeof h=="object"&&h!==null){let m=o.o;m===null&&(o.o=m=new WeakMap);const p=m.get(h);p===void 0?(o=Fs(),m.set(h,o)):o=p}else{let m=o.p;m===null&&(o.p=m=new Map);const p=m.get(h);p===void 0?(o=Fs(),m.set(h,o)):o=p}}const c=o;let u;if(o.s===pa)u=o.v;else if(u=n.apply(null,arguments),i++,s){const f=((d=r==null?void 0:r.deref)==null?void 0:d.call(r))??r;f!=null&&s(f,u)&&(u=f,i!==0&&i--),r=typeof u=="object"&&u!==null||typeof u=="function"?new Dd(u):u}return c.s=pa,c.v=u,u}return a.clearCache=()=>{t=Fs(),a.resetResultsCount()},a.resultsCount=()=>i,a.resetResultsCount=()=>{i=0},a}function Rd(n,...e){const t=typeof n=="function"?{memoize:n,memoizeOptions:e}:n,s=(...r)=>{let i=0,a=0,o,l={},c=r.pop();typeof c=="object"&&(l=c,c=r.pop()),vd(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const u={...t,...l},{memoize:d,memoizeOptions:f=[],argsMemoize:g=ga,argsMemoizeOptions:h=[],devModeChecks:m={}}=u,p=fa(f),E=fa(h),x=wd(r),v=d(function(){return i++,c.apply(null,arguments)},...p);let w=!0;const b=g(function(){a++;const A=ha(x,arguments);if(o=v.apply(null,A),process.env.NODE_ENV!=="production"){const{identityFunctionCheck:F,inputStabilityCheck:U}=Ld(w,m);if(F.shouldRun&&F.run(c,A,o),U.shouldRun){const O=ha(x,arguments);U.run({inputSelectorResults:A,inputSelectorResultsCopy:O},{memoize:d,memoizeOptions:p},arguments)}w&&(w=!1)}return o},...E);return Object.assign(b,{resultFunc:c,memoizedResultFunc:v,dependencies:x,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>o,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:d,argsMemoize:g})};return Object.assign(s,{withTypes:()=>s}),s}var kd=Rd(ga),Pd=Object.assign((n,e=kd)=>{bd(n,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof n}`);const t=Object.keys(n),s=t.map(i=>n[i]);return e(s,(...i)=>i.reduce((a,o,l)=>(a[t[l]]=o,a),{}))},{withTypes:()=>Pd});function ma(n){return({dispatch:t,getState:s})=>r=>i=>typeof i=="function"?i(t,s,n):r(i)}var _d=ma(),Od=ma,Fd=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?As:As.apply(null,arguments)},Md=n=>n&&typeof n.match=="function";function ya(n,e){function t(...s){if(e){let r=e(...s);if(!r)throw new Error(process.env.NODE_ENV==="production"?fe(0):"prepareAction did not return an object");return{type:n,payload:r.payload,..."meta"in r&&{meta:r.meta},..."error"in r&&{error:r.error}}}return{type:n,payload:s[0]}}return t.toString=()=>`${n}`,t.type=n,t.match=s=>Ji(s)&&s.type===n,t}function Nd(n){return typeof n=="function"&&"type"in n&&Md(n)}function Bd(n){const e=n?`${n}`.split("/"):[],t=e[e.length-1]||"actionCreator";return`Detected an action creator with type "${n||"unknown"}" being dispatched.
|
|
26
|
+
Make sure you're calling the action creator before dispatching, i.e. \`dispatch(${t}())\` instead of \`dispatch(${t})\`. This is necessary even if the action has no payload.`}function Ud(n={}){if(process.env.NODE_ENV==="production")return()=>t=>s=>t(s);const{isActionCreator:e=Nd}=n;return()=>t=>s=>(e(s)&&console.warn(Bd(s.type)),t(s))}function Ea(n,e){let t=0;return{measureTime(s){const r=Date.now();try{return s()}finally{const i=Date.now();t+=i-r}},warnIfExceeded(){t>n&&console.warn(`${e} took ${t}ms, which is more than the warning threshold of ${n}ms.
|
|
27
|
+
If your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.
|
|
28
|
+
It is disabled in production builds, so you don't need to worry about that.`)}}}var Sa=class ws extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,ws.prototype)}static get[Symbol.species](){return ws}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new ws(...e[0].concat(this)):new ws(...e.concat(this))}};function Ta(n){return it(n)?da(n,()=>{}):n}function xa(n,e,t){return n.has(e)?n.get(e):n.set(e,t(e)).get(e)}function $d(n){return typeof n!="object"||n==null||Object.isFrozen(n)}function Vd(n,e,t){const s=va(n,e,t);return{detectMutations(){return ba(n,e,s,t)}}}function va(n,e=[],t,s="",r=new Set){const i={value:t};if(!n(t)&&!r.has(t)){r.add(t),i.children={};for(const a in t){const o=s?s+"."+a:a;e.length&&e.indexOf(o)!==-1||(i.children[a]=va(n,e,t[a],o))}}return i}function ba(n,e=[],t,s,r=!1,i=""){const a=t?t.value:void 0,o=a===s;if(r&&!o&&!Number.isNaN(s))return{wasMutated:!0,path:i};if(n(a)||n(s))return{wasMutated:!1};const l={};for(let u in t.children)l[u]=!0;for(let u in s)l[u]=!0;const c=e.length>0;for(let u in l){const d=i?i+"."+u:u;if(c&&e.some(h=>h instanceof RegExp?h.test(d):d===h))continue;const f=ba(n,e,t.children[u],s[u],o,d);if(f.wasMutated)return f}return{wasMutated:!1}}function Gd(n={}){if(process.env.NODE_ENV==="production")return()=>e=>t=>e(t);{let e=function(o,l,c,u){return JSON.stringify(o,t(l,u),c)},t=function(o,l){let c=[],u=[];return l||(l=function(d,f){return c[0]===f?"[Circular ~]":"[Circular ~."+u.slice(0,c.indexOf(f)).join(".")+"]"}),function(d,f){if(c.length>0){var g=c.indexOf(this);~g?c.splice(g+1):c.push(this),~g?u.splice(g,1/0,d):u.push(d),~c.indexOf(f)&&(f=l.call(this,d,f))}else c.push(f);return o==null?f:o.call(this,d,f)}},{isImmutable:s=$d,ignoredPaths:r,warnAfter:i=32}=n;const a=Vd.bind(null,s,r);return({getState:o})=>{let l=o(),c=a(l),u;return d=>f=>{const g=Ea(i,"ImmutableStateInvariantMiddleware");g.measureTime(()=>{if(l=o(),u=c.detectMutations(),c=a(l),u.wasMutated)throw new Error(process.env.NODE_ENV==="production"?fe(19):`A state mutation was detected between dispatches, in the path '${u.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)});const h=d(f);return g.measureTime(()=>{if(l=o(),u=c.detectMutations(),c=a(l),u.wasMutated)throw new Error(process.env.NODE_ENV==="production"?fe(20):`A state mutation was detected inside a dispatch, in the path: ${u.path||""}. Take a look at the reducer(s) handling the action ${e(f)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}),g.warnIfExceeded(),h}}}}function Ca(n){const e=typeof n;return n==null||e==="string"||e==="boolean"||e==="number"||Array.isArray(n)||es(n)}function dr(n,e="",t=Ca,s,r=[],i){let a;if(!t(n))return{keyPath:e||"<root>",value:n};if(typeof n!="object"||n===null||i!=null&&i.has(n))return!1;const o=s!=null?s(n):Object.entries(n),l=r.length>0;for(const[c,u]of o){const d=e?e+"."+c:c;if(!(l&&r.some(g=>g instanceof RegExp?g.test(d):d===g))){if(!t(u))return{keyPath:d,value:u};if(typeof u=="object"&&(a=dr(u,d,t,s,r,i),a))return a}}return i&&wa(n)&&i.add(n),!1}function wa(n){if(!Object.isFrozen(n))return!1;for(const e of Object.values(n))if(!(typeof e!="object"||e===null)&&!wa(e))return!1;return!0}function Hd(n={}){if(process.env.NODE_ENV==="production")return()=>e=>t=>e(t);{const{isSerializable:e=Ca,getEntries:t,ignoredActions:s=[],ignoredActionPaths:r=["meta.arg","meta.baseQueryMeta"],ignoredPaths:i=[],warnAfter:a=32,ignoreState:o=!1,ignoreActions:l=!1,disableCache:c=!1}=n,u=!c&&WeakSet?new WeakSet:void 0;return d=>f=>g=>{if(!Ji(g))return f(g);const h=f(g),m=Ea(a,"SerializableStateInvariantMiddleware");return!l&&!(s.length&&s.indexOf(g.type)!==-1)&&m.measureTime(()=>{const p=dr(g,"",e,t,r,u);if(p){const{keyPath:E,value:x}=p;console.error(`A non-serializable value was detected in an action, in the path: \`${E}\`. Value:`,x,`
|
|
29
|
+
Take a look at the logic that dispatched this action: `,g,`
|
|
30
|
+
(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)`,`
|
|
31
|
+
(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)`)}}),o||(m.measureTime(()=>{const p=d.getState(),E=dr(p,"",e,t,i,u);if(E){const{keyPath:x,value:v}=E;console.error(`A non-serializable value was detected in the state, in the path: \`${x}\`. Value:`,v,`
|
|
32
|
+
Take a look at the reducer(s) handling this action type: ${g.type}.
|
|
33
|
+
(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}}),m.warnIfExceeded()),h}}}function Ms(n){return typeof n=="boolean"}var Kd=()=>function(e){const{thunk:t=!0,immutableCheck:s=!0,serializableCheck:r=!0,actionCreatorCheck:i=!0}=e??{};let a=new Sa;if(t&&(Ms(t)?a.push(_d):a.push(Od(t.extraArgument))),process.env.NODE_ENV!=="production"){if(s){let o={};Ms(s)||(o=s),a.unshift(Gd(o))}if(r){let o={};Ms(r)||(o=r),a.push(Hd(o))}if(i){let o={};Ms(i)||(o=i),a.unshift(Ud(o))}}return a},Wd="RTK_autoBatch",La=n=>e=>{setTimeout(e,n)},jd=(n={type:"raf"})=>e=>(...t)=>{const s=e(...t);let r=!0,i=!1,a=!1;const o=new Set,l=n.type==="tick"?queueMicrotask:n.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:La(10):n.type==="callback"?n.queueNotification:La(n.timeout),c=()=>{a=!1,i&&(i=!1,o.forEach(u=>u()))};return Object.assign({},s,{subscribe(u){const d=()=>r&&u(),f=s.subscribe(d);return o.add(u),()=>{f(),o.delete(u)}},dispatch(u){var d;try{return r=!((d=u==null?void 0:u.meta)!=null&&d[Wd]),i=!r,i&&(a||(a=!0,l(c))),s.dispatch(u)}finally{r=!0}}})},zd=n=>function(t){const{autoBatch:s=!0}=t??{};let r=new Sa(n);return s&&r.push(jd(typeof s=="object"?s:void 0)),r};function qd(n){const e=Kd(),{reducer:t=void 0,middleware:s,devTools:r=!0,preloadedState:i=void 0,enhancers:a=void 0}=n;let o;if(typeof t=="function")o=t;else if(es(t))o=ad(t);else throw new Error(process.env.NODE_ENV==="production"?fe(1):"`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");if(process.env.NODE_ENV!=="production"&&s&&typeof s!="function")throw new Error(process.env.NODE_ENV==="production"?fe(2):"`middleware` field must be a callback");let l;if(typeof s=="function"){if(l=s(e),process.env.NODE_ENV!=="production"&&!Array.isArray(l))throw new Error(process.env.NODE_ENV==="production"?fe(3):"when using a middleware builder function, an array of middleware must be returned")}else l=e();if(process.env.NODE_ENV!=="production"&&l.some(h=>typeof h!="function"))throw new Error(process.env.NODE_ENV==="production"?fe(4):"each middleware provided to configureStore must be a function");let c=As;r&&(c=Fd({trace:process.env.NODE_ENV!=="production",...typeof r=="object"&&r}));const u=od(...l),d=zd(u);if(process.env.NODE_ENV!=="production"&&a&&typeof a!="function")throw new Error(process.env.NODE_ENV==="production"?fe(5):"`enhancers` field must be a callback");let f=typeof a=="function"?a(d):d();if(process.env.NODE_ENV!=="production"&&!Array.isArray(f))throw new Error(process.env.NODE_ENV==="production"?fe(6):"`enhancers` callback must return an array");if(process.env.NODE_ENV!=="production"&&f.some(h=>typeof h!="function"))throw new Error(process.env.NODE_ENV==="production"?fe(7):"each enhancer provided to configureStore must be a function");process.env.NODE_ENV!=="production"&&l.length&&!f.includes(u)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");const g=c(...f);return Zi(o,i,g)}function Aa(n){const e={},t=[];let s;const r={addCase(i,a){if(process.env.NODE_ENV!=="production"){if(t.length>0)throw new Error(process.env.NODE_ENV==="production"?fe(26):"`builder.addCase` should only be called before calling `builder.addMatcher`");if(s)throw new Error(process.env.NODE_ENV==="production"?fe(27):"`builder.addCase` should only be called before calling `builder.addDefaultCase`")}const o=typeof i=="string"?i:i.type;if(!o)throw new Error(process.env.NODE_ENV==="production"?fe(28):"`builder.addCase` cannot be called with an empty action type");if(o in e)throw new Error(process.env.NODE_ENV==="production"?fe(29):`\`builder.addCase\` cannot be called with two reducers for the same action type '${o}'`);return e[o]=a,r},addMatcher(i,a){if(process.env.NODE_ENV!=="production"&&s)throw new Error(process.env.NODE_ENV==="production"?fe(30):"`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return t.push({matcher:i,reducer:a}),r},addDefaultCase(i){if(process.env.NODE_ENV!=="production"&&s)throw new Error(process.env.NODE_ENV==="production"?fe(31):"`builder.addDefaultCase` can only be called once");return s=i,r}};return n(r),[e,t,s]}function Yd(n){return typeof n=="function"}function Xd(n,e){if(process.env.NODE_ENV!=="production"&&typeof e=="object")throw new Error(process.env.NODE_ENV==="production"?fe(8):"The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let[t,s,r]=Aa(e),i;if(Yd(n))i=()=>Ta(n());else{const o=Ta(n);i=()=>o}function a(o=i(),l){let c=[t[l.type],...s.filter(({matcher:u})=>u(l)).map(({reducer:u})=>u)];return c.filter(u=>!!u).length===0&&(c=[r]),c.reduce((u,d)=>{if(d)if(vt(u)){const g=d(u,l);return g===void 0?u:g}else{if(it(u))return da(u,f=>d(f,l));{const f=d(u,l);if(f===void 0){if(u===null)return u;throw Error("A case reducer on a non-draftable value must not return undefined")}return f}}return u},o)}return a.getInitialState=i,a}var Zd=Symbol.for("rtk-slice-createasyncthunk");function Qd(n,e){return`${n}/${e}`}function Jd({creators:n}={}){var t;const e=(t=n==null?void 0:n.asyncThunk)==null?void 0:t[Zd];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(process.env.NODE_ENV==="production"?fe(11):"`name` is a required option for createSlice");typeof process<"u"&&process.env.NODE_ENV==="development"&&r.initialState===void 0&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const o=(typeof r.reducers=="function"?r.reducers(t0()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(v,w){const b=typeof v=="string"?v:v.type;if(!b)throw new Error(process.env.NODE_ENV==="production"?fe(12):"`context.addCase` cannot be called with an empty action type");if(b in c.sliceCaseReducersByType)throw new Error(process.env.NODE_ENV==="production"?fe(13):"`context.addCase` cannot be called with two reducers for the same action type: "+b);return c.sliceCaseReducersByType[b]=w,u},addMatcher(v,w){return c.sliceMatchers.push({matcher:v,reducer:w}),u},exposeAction(v,w){return c.actionCreators[v]=w,u},exposeCaseReducer(v,w){return c.sliceCaseReducersByName[v]=w,u}};l.forEach(v=>{const w=o[v],b={reducerName:v,type:Qd(i,v),createNotation:typeof r.reducers=="function"};n0(w)?i0(b,w,u,e):s0(b,w,u)});function d(){if(process.env.NODE_ENV!=="production"&&typeof r.extraReducers=="object")throw new Error(process.env.NODE_ENV==="production"?fe(14):"The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[v={},w=[],b=void 0]=typeof r.extraReducers=="function"?Aa(r.extraReducers):[r.extraReducers],I={...v,...c.sliceCaseReducersByType};return Xd(r.initialState,A=>{for(let F in I)A.addCase(F,I[F]);for(let F of c.sliceMatchers)A.addMatcher(F.matcher,F.reducer);for(let F of w)A.addMatcher(F.matcher,F.reducer);b&&A.addDefaultCase(b)})}const f=v=>v,g=new Map;let h;function m(v,w){return h||(h=d()),h(v,w)}function p(){return h||(h=d()),h.getInitialState()}function E(v,w=!1){function b(A){let F=A[v];if(typeof F>"u"){if(w)F=p();else if(process.env.NODE_ENV!=="production")throw new Error(process.env.NODE_ENV==="production"?fe(15):"selectSlice returned undefined for an uninjected slice reducer")}return F}function I(A=f){const F=xa(g,w,()=>new WeakMap);return xa(F,A,()=>{const U={};for(const[O,B]of Object.entries(r.selectors??{}))U[O]=e0(B,A,p,w);return U})}return{reducerPath:v,getSelectors:I,get selectors(){return I(b)},selectSlice:b}}const x={name:i,reducer:m,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:p,...E(a),injectInto(v,{reducerPath:w,...b}={}){const I=w??a;return v.inject({reducerPath:I,reducer:m},b),{...x,...E(I,!0)}}};return x}}function e0(n,e,t,s){function r(i,...a){let o=e(i);if(typeof o>"u"){if(s)o=t();else if(process.env.NODE_ENV!=="production")throw new Error(process.env.NODE_ENV==="production"?fe(16):"selectState returned undefined for an uninjected slice reducer")}return n(o,...a)}return r.unwrapped=n,r}var ns=Jd();function t0(){function n(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return n.withTypes=()=>n,{reducer(e){return Object.assign({[e.name](...t){return e(...t)}}[e.name],{_reducerDefinitionType:"reducer"})},preparedReducer(e,t){return{_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}},asyncThunk:n}}function s0({type:n,reducerName:e,createNotation:t},s,r){let i,a;if("reducer"in s){if(t&&!r0(s))throw new Error(process.env.NODE_ENV==="production"?fe(17):"Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");i=s.reducer,a=s.prepare}else i=s;r.addCase(n,i).exposeCaseReducer(e,i).exposeAction(e,a?ya(n,a):ya(n))}function n0(n){return n._reducerDefinitionType==="asyncThunk"}function r0(n){return n._reducerDefinitionType==="reducerWithPrepare"}function i0({type:n,reducerName:e},t,s,r){if(!r)throw new Error(process.env.NODE_ENV==="production"?fe(18):"Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:i,fulfilled:a,pending:o,rejected:l,settled:c,options:u}=t,d=r(n,i,u);s.exposeAction(e,d),a&&s.addCase(d.fulfilled,a),o&&s.addCase(d.pending,o),l&&s.addCase(d.rejected,l),c&&s.addMatcher(d.settled,c),s.exposeCaseReducer(e,{fulfilled:a||Ns,pending:o||Ns,rejected:l||Ns,settled:c||Ns})}function Ns(){}function fe(n){return`Minified Redux Toolkit error #${n}; visit https://redux-toolkit.js.org/Errors?code=${n} for the full message or use the non-minified dev environment for full errors. `}const Da={play:!1,isAutoPlay:!0,duration:0,currentTime:0,qualityLevels:[],manualQuality:void 0,autoQuality:void 0,activeElements:!0,isLoading:!1,isFullScreen:!1,bufferedTimeWidth:0,firstPlay:!0,activePointerProgressBar:!1,delayTurnOffControlbar:!1,canPlayVideo:!1,lock:!1,isEnded:!1,tooltipTime:0},Ia=ns({name:"controller",initialState:Da,reducers:{setPlay:(n,e)=>{n.play=e.payload},setIsAutoPlay:(n,e)=>{n.isAutoPlay=e.payload},setDuration:(n,e)=>{n.duration=e.payload},setCurrentTime:(n,e)=>{n.currentTime=e.payload},setManualQuality:(n,e)=>{n.manualQuality=e.payload},setAutoQuality:(n,e)=>{n.autoQuality=e.payload},setQualityLevels:(n,e)=>{n.qualityLevels=e.payload},setActiveElements:(n,e)=>{n.activeElements=e.payload},setIsLoading:(n,e)=>{n.isLoading=e.payload},setIsFullScreen:(n,e)=>{n.isFullScreen=e.payload},setBufferedTimeWidth:(n,e)=>{n.bufferedTimeWidth=e.payload},setFirstPlay:(n,e)=>{n.firstPlay=e.payload},setActivePointerProgressBar:(n,e)=>{n.activePointerProgressBar=e.payload},setDelayTurnOffControlbar:(n,e)=>{n.delayTurnOffControlbar=e.payload},setCanPlayVideo:(n,e)=>{n.canPlayVideo=e.payload},setLock:(n,e)=>{n.lock=e.payload},setIsEnded:(n,e)=>{n.isEnded=e.payload},setTooltipTime:(n,e)=>{n.tooltipTime=e.payload},setClearControllerSlice:()=>Da}}),{setPlay:Xe,setIsAutoPlay:Hy,setDuration:Ra,setCurrentTime:$t,setQualityLevels:a0,setAutoQuality:Bs,setActiveElements:Se,setIsLoading:Vt,setIsFullScreen:rs,setBufferedTimeWidth:ka,setFirstPlay:fr,setActivePointerProgressBar:Pa,setDelayTurnOffControlbar:hr,setManualQuality:o0,setCanPlayVideo:_a,setLock:l0,setIsEnded:pr,setTooltipTime:c0,setClearControllerSlice:u0}=Ia.actions,d0=Ia.reducer,Oa=ns({name:"videoData",initialState:{details:{stream_link:"",type:"",banner:"",id:void 0,title:void 0,vtt:void 0,vtt_mobile:void 0,user_id:null,content_id:void 0,content_type:null,duration:0,subtitles:void 0},params:{type:"",id:"",bannerAlt:"",fullscreen:"",autoplay:"",banner:"",provider:"cafevdo",onFinished:void 0,onPlay:void 0,onPause:void 0,playStatus:void 0,currentTime:void 0,daaniHashCode:void 0},markers:[],videoElementSizeInfo:{bottom:0,top:0,right:0,left:0,width:0,height:0},isFetchDetails:!1,isValidAddress:!1,videoTimelines:[],isReady:!1,subtitles:[],selectedSubtitle:void 0,subtitleText:void 0},reducers:{setInfo:(n,e)=>{n.details=e.payload},setPlayerParams:(n,e)=>{n.params=e.payload},setMarkers:(n,e)=>{n.markers=e.payload},setVideoElementSizeInfo:(n,e)=>{n.videoElementSizeInfo=e.payload},setIsFetchDetails:(n,e)=>{n.isFetchDetails=e.payload},setIsValidAddress:(n,e)=>{n.isValidAddress=e.payload},setVideoTimelines:(n,e)=>{n.videoTimelines=e.payload},setIsReady:(n,e)=>{n.isReady=e.payload},setSubtitles:(n,e)=>{n.subtitles=e.payload},setSelectedSubtitle:(n,e)=>{n.selectedSubtitle=e.payload},setSubtitleText:(n,e)=>{n.subtitleText=e.payload},setClearVideoDataSlice:n=>{n.subtitles=[],n.selectedSubtitle=void 0,n.subtitleText=void 0}}}),{setInfo:Fa,setPlayerParams:f0,setVideoElementSizeInfo:Ma,setMarkers:Wy,setIsFetchDetails:Na,setIsValidAddress:Ba,setVideoTimelines:Us,setIsReady:h0,setSubtitles:$s,setSubtitleText:is,setSelectedSubtitle:as,setClearVideoDataSlice:p0}=Oa.actions,g0=Oa.reducer,Ua=ns({name:"popover",initialState:{settingPopover:!1,speedPopover:!1,qualityLevelsPopover:!1,markersListPopover:!1},reducers:{setSettingPopover:(n,e)=>{n.settingPopover=e.payload},setSpeedPopover:(n,e)=>{n.speedPopover=e.payload},setQualityLevelsPopover:(n,e)=>{n.qualityLevelsPopover=e.payload},setMarkersListPopover:(n,e)=>{n.markersListPopover=e.payload},setClearPopoversSlice:n=>{n.settingPopover=!1,n.speedPopover=!1,n.qualityLevelsPopover=!1,n.markersListPopover=!1}}}),{setSettingPopover:wt,setSpeedPopover:Vs,setQualityLevelsPopover:Gs,setMarkersListPopover:Hs,setClearPopoversSlice:Ks}=Ua.actions,m0=Ua.reducer,$a={settings:{quality:-1,brightness:100,volume:100,speed:1},videoSettings:{time:0}},Va=ns({name:"user",initialState:$a,reducers:{setUserSettings:(n,e)=>{n.settings=e.payload},setVideoSettings:(n,e)=>{n.videoSettings=e.payload},setClearUserSlice:()=>$a}}),{setUserSettings:at,setVideoSettings:y0,setClearUserSlice:E0}=Va.actions,S0=Va.reducer,Ga={params:{id:"0",type:"",currentTime:0,autoPlay:!1,onClose:()=>{}},details:{},play:!1},Ha=ns({name:"user",initialState:Ga,reducers:{setMiniPlayerInfo:(n,e)=>{n.params={...e.payload,id:e.payload.type===Tt.static?window.atob(e.payload.id):e.payload.id,banner:e.payload.banner?e.payload.banner:void 0}},setDetailsMiniPlayer:(n,e)=>{n.details=e.payload},setPlayMiniPlayer:(n,e)=>{n.play=e.payload},setClearMiniPlayerSlice:()=>Ga}}),{setMiniPlayerInfo:T0,setDetailsMiniPlayer:x0,setPlayMiniPlayer:gt,setClearMiniPlayerSlice:v0}=Ha.actions,b0=Ha.reducer,R=qd({reducer:{controller:d0,videoData:g0,popovers:m0,user:S0,miniPlayer:b0},devTools:!0,middleware:n=>n({serializableCheck:!1})}),C0=n=>new Promise(e=>setTimeout(e,n*1e3)),ot=()=>{let n=localStorage.getItem("hamrahiUUID");return n||(n=w0(),localStorage.setItem("hamrahiUUID",n)),n.toString()},w0=()=>{let n="xxxxxxxx-xxxx-Mxxx-Nxxx-x".replace(/[xMN]/g,e=>{let t;return e==="M"?t=Math.floor(1+Math.random()*5):e==="N"?t=Math.floor(8+Math.random()*4):t=Math.floor(Math.random()*16),t.toString(16)});return n+=Date.now().toString(16),n},Gt=()=>"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch,Ka=()=>{const{isFullScreen:n}=R.getState().controller;return Gt()&&n},L0=()=>{const{isFullScreen:n}=R.getState().controller;return Gt()&&!n},Ws=()=>["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,os=n=>(n<10?"0":"")+n,js=n=>{const e=Math.floor(n/3600),t=Math.floor(n%3600/60),s=Math.floor(n%3600%60);return e<1?`${os(t)}:${os(s)}`:`${os(e)}:${os(t)}:${os(s)}`},zs=n=>["mp4","mkv","mov","m4v"].includes(n)?"mp4":n==="webm"||n==="flv"?n:["mp3","ogg"].includes(n)?"mp3":!1,A0=n=>{const e=new URL(n);let t=n;return e.search.length?t+=`&uuid=${ot()}`:t+=`?uuid=${ot()}`},gr=(n,e)=>{try{return[n.target.id,n.target.parentNode.id,n.target.parentNode.parentNode.id,n.target.parentNode.parentNode.parentNode.id,n.target.parentNode.parentNode.parentNode.parentNode.id].includes(e)}catch{return!1}},Wa=n=>{let e="";n==="mainPlayer"?e=R.getState().videoData.details.stream_link:e=R.getState().miniPlayer.details.stream_link;let t="";return e&&(t=e.split("m3u8")[1]),t?t=`${t}&uuid=${ot()}`:t=`?uuid=${ot()}`,t},D0=(n,e)=>{const t=document.getElementById(e),s=document.createElement("span");s.style.width=s.style.height="50px",s.style.left=`${n.touches[0].clientX-t.offsetLeft-25}px`,s.style.top=`${n.touches[0].clientY-t.offsetTop-25}px`,s.classList.add("pl-ripple");const r=t.getElementsByClassName("pl-ripple")[0];r&&r.remove(),t.appendChild(s)},I0=n=>n>=200&&n<300,ja=()=>{const n=R.dispatch;n(p0()),n(u0()),n(E0()),n(Ks())},za=n=>{let e,t=[];for(e=0;e<n.length;e++)t[e]=n[e].weight+(t[e-1]||0);let s=Math.random()*t[t.length-1];for(e=0;e<t.length&&!(t[e]>s);e++);return n[e].domain},qa=n=>{let e=0;performance&&performance.getEntriesByType("navigation")&&(e=performance.getEntriesByType("navigation")[0].duration),n.current=e},Ya=(n,e,t)=>{const s=e*window.devicePixelRatio,r=t*window.devicePixelRatio;let i=[];return C(T.isTouchScreenPortrait)?i=n.filter(a=>Number(a.split("x")[0].trim())<=s):i=n.filter(a=>Number(a.split("x")[0].trim())<=r||Number(a.split("x")[1].trim())<=s),i.indexOf(i[i.length-1])},Xa=(n,e)=>{let t={};for(const s in n){const r=e?`${e}_${s}`:s;typeof n[s]=="object"&&!Array.isArray(n[s])?t={...t,...Xa(n[s],r)}:t[r]=n[s]}return t},Za=n=>{const e={fa:1,en:2};return n.slice().sort((t,s)=>{const r=e[t.lang]||999,i=e[s.lang]||999;return r-i})},Qa=n=>{let e;switch(n){case"fa":e="فارسی";break;case"en":e="انگلیسی";break;case"ar":e="عربی";break;case"tr":e="ترکی";break}return e},R0=n=>n.split(/\r?\n|\r|\n/g),k0=n=>{if(n){const e=n.offsetLeft-n.offsetWidth/2,t=window.innerWidth-(n.offsetLeft+n.offsetWidth);if(e>=0&&t>=0)return"inViewport";if(e<0)return"OutViewPortFromLeft";if(t<0)return"OutViewPortFromRight"}},P0=n=>(n=n.replace(/\d{2}:\d{2}:\d{2}\.\d{3} --> \d{2}:\d{2}:\d{2}\.\d{3}.*\n/g,""),n=n.replace(/<[^>]+>/g,""),n=n.replace(/\n+/g,`
|
|
34
|
+
`),n=n.trim(),n),C=n=>{var U;const{params:e,details:t,isValidAddress:s,isFetchDetails:r,isReady:i,subtitles:a,selectedSubtitle:o,markers:l}=R.getState().videoData,{firstPlay:c,lock:u,canPlayVideo:d,manualQuality:f,activeElements:g,isLoading:h,isEnded:m,isAutoPlay:p,play:E,isFullScreen:x}=R.getState().controller,{settingPopover:v,speedPopover:w,qualityLevelsPopover:b,markersListPopover:I}=R.getState().popovers,{settings:A}=R.getState().user,F=R.getState().miniPlayer;switch(n){case T.showHeader:return!c&&d;case T.showMain:return!u||c;case T.showFooter:return!c&&d;case T.showTouchVolumeBrightness:return!c&&Ka()&&!u&&!m;case T.showBackwardForward:return!c&&Gt()&&!u;case T.showTitle:return!zs(e.type)&&x&&!u;case T.showSettingPopover:return v;case T.showSpeedPopover:return w;case T.showQualityLevelsPopover:return b;case T.showSettingIcon:return!zs(e.type)&&!Ws()&&!x;case T.showBanner:return c&&(t.banner||e.banner);case T.showProgressbar:return!Ws();case T.showPictureInPicture:return!Ws();case T.showSubtitle:return!!o;case T.showMarkerListPopover:return I;case T.hidePopovers:return!v;case T.isLandscape:return window.innerHeight<=window.innerWidth;case T.isTouchScreen:return Gt();case T.isTouchScreenPortrait:return L0();case T.isTouchScreenLandscape:return Ka();case T.isActiveElements:return g;case T.isPlay:return E;case T.isPlayMiniPlayer:return F.play;case T.isFirstPlay:return c;case T.isLock:return u;case T.isIOS:return Ws();case T.isLoading:return h;case T.isStaticFormat:return e.type===Tt.static;case T.isEnded:return m;case T.isAutoPlay:return p;case T.isFullScreen:return x;case T.isValidAddress:return s;case T.isFetchDetails:return r;case T.isAutoQuality:return A.quality===-1;case T.isPressKeySpace:return!u;case T.isPressKeyI:return!u&&!c;case T.isPressKeyF:return!u&&!c;case T.isPressKeyS:return!u&&!c;case T.isPressKeyArrowRight:return!c&&!u;case T.isPressKeyArrowLeft:return!c&&!u;case T.isPressKeyM:return!c&&!u;case T.isPressKeyC:return!u&&!c&&!!a&&a.length>0;case T.isSendTimelineLog:return!zs(e.type);case T.isReady:return i;case T.isSelectedSubtitle:return!!a&&a.length>0&&o;case T.isMiniPlayerAndMainPlayerSame:return e.id===F.params.id;case T.hasTitle:return t.title;case T.hasBanner:return t.banner;case T.hasStreamLink:return t.stream_link;case T.hasManualQuality:return f!=null;case T.hasSound:return!!A.volume;case T.hasAutoPlay:return e.autoplay==="true";case T.hasFullScreenParams:return e.fullscreen==="true";case T.hasOnFinishedParams:return!!e.onFinished;case T.hasSubtitles:return!!a&&a.length>0;case T.hasSubtitlesInDetails:return t.subtitles&&t.subtitles.length>0;case T.hasActiveCue:return o&&o.activeCues&&o.activeCues.length>0;case T.hasOnPlayParams:return!!e.onPlay;case T.hasOnPauseParams:return!!e.onPause;case T.hasPlayStatusParams:return e.playStatus!==void 0;case T.hasMiniPlayer:return F.params.id;case T.hasCurrentTimeParams:return e.currentTime!==void 0;case T.hasMarkers:return l.length!==0;case T.hasSubtitlesInParams:return e.subtitles&&e.subtitles.length;case T.hasNoSpeed:return!((U=e.featureExec)!=null&&U.includes(qn.speed));case T.getDetails:return!!e.type&&e.id;case T.getMarkers:return String(e.type)==="vod"&&e.id&&r;case T.canPlayVideo:return d;case T.setSubtitleFirstPlay:return t.subtitles&&t.subtitles.length>0&&!c&&!zs(e.type)}},xe=()=>qu(),V=Zu,_0=n=>{const e=xe();let t={};const s=()=>{e(f0(t)),e(h0(!0))},r=()=>{n.uuid&&(localStorage.setItem("hamrahiUUID",n.uuid),t.uuid=n.uuid)},i=()=>{t={provider:"cafevdo",...n}},a=()=>{t={id:window.atob(n.id),type:n.type,fullscreen:n.fullscreen,autoplay:n.autoplay,banner:n.banner&&n.banner!=="undefined"?n.banner:void 0,uuid:ot(),bannerAlt:n.bannerAlt,onFinished:n.onFinished,onClickMiniPlayerIcon:n.onClickMiniPlayerIcon,currentTime:n.currentTime,subtitles:n.subtitles,daaniHashCode:n.daaniHashCode,featureExec:n.featureExec,primaryColor:n.primaryColor}},o=async()=>{t={},Object.keys(n).includes("type")&&(String(n.type)===Tt.vod?i():String(n.type)===Tt.static&&a(),r(),s())};P.useEffect(()=>{o()},[n])},N=()=>document.getElementById("player-tag"),Ve=()=>document.getElementById("mini-player-video-tag"),mt=()=>document.getElementById("time-progress-bar"),qs=()=>R.getState().videoData.videoElementSizeInfo.width-2;function Ja(n,e){return function(){return n.apply(e,arguments)}}const{toString:O0}=Object.prototype,{getPrototypeOf:mr}=Object,Ys=(n=>e=>{const t=O0.call(e);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),je=n=>(n=n.toLowerCase(),e=>Ys(e)===n),Xs=n=>e=>typeof e===n,{isArray:Ht}=Array,ls=Xs("undefined");function F0(n){return n!==null&&!ls(n)&&n.constructor!==null&&!ls(n.constructor)&&$e(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const eo=je("ArrayBuffer");function M0(n){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&eo(n.buffer),e}const N0=Xs("string"),$e=Xs("function"),to=Xs("number"),Zs=n=>n!==null&&typeof n=="object",B0=n=>n===!0||n===!1,Qs=n=>{if(Ys(n)!=="object")return!1;const e=mr(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)},U0=je("Date"),$0=je("File"),V0=je("Blob"),G0=je("FileList"),H0=n=>Zs(n)&&$e(n.pipe),K0=n=>{let e;return n&&(typeof FormData=="function"&&n instanceof FormData||$e(n.append)&&((e=Ys(n))==="formdata"||e==="object"&&$e(n.toString)&&n.toString()==="[object FormData]"))},W0=je("URLSearchParams"),[j0,z0,q0,Y0]=["ReadableStream","Request","Response","Headers"].map(je),X0=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function cs(n,e,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let s,r;if(typeof n!="object"&&(n=[n]),Ht(n))for(s=0,r=n.length;s<r;s++)e.call(null,n[s],s,n);else{const i=t?Object.getOwnPropertyNames(n):Object.keys(n),a=i.length;let o;for(s=0;s<a;s++)o=i[s],e.call(null,n[o],o,n)}}function so(n,e){e=e.toLowerCase();const t=Object.keys(n);let s=t.length,r;for(;s-- >0;)if(r=t[s],e===r.toLowerCase())return r;return null}const Lt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,no=n=>!ls(n)&&n!==Lt;function yr(){const{caseless:n}=no(this)&&this||{},e={},t=(s,r)=>{const i=n&&so(e,r)||r;Qs(e[i])&&Qs(s)?e[i]=yr(e[i],s):Qs(s)?e[i]=yr({},s):Ht(s)?e[i]=s.slice():e[i]=s};for(let s=0,r=arguments.length;s<r;s++)arguments[s]&&cs(arguments[s],t);return e}const Z0=(n,e,t,{allOwnKeys:s}={})=>(cs(e,(r,i)=>{t&&$e(r)?n[i]=Ja(r,t):n[i]=r},{allOwnKeys:s}),n),Q0=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),J0=(n,e,t,s)=>{n.prototype=Object.create(e.prototype,s),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:e.prototype}),t&&Object.assign(n.prototype,t)},ef=(n,e,t,s)=>{let r,i,a;const o={};if(e=e||{},n==null)return e;do{for(r=Object.getOwnPropertyNames(n),i=r.length;i-- >0;)a=r[i],(!s||s(a,n,e))&&!o[a]&&(e[a]=n[a],o[a]=!0);n=t!==!1&&mr(n)}while(n&&(!t||t(n,e))&&n!==Object.prototype);return e},tf=(n,e,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=e.length;const s=n.indexOf(e,t);return s!==-1&&s===t},sf=n=>{if(!n)return null;if(Ht(n))return n;let e=n.length;if(!to(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=n[e];return t},nf=(n=>e=>n&&e instanceof n)(typeof Uint8Array<"u"&&mr(Uint8Array)),rf=(n,e)=>{const s=(n&&n[Symbol.iterator]).call(n);let r;for(;(r=s.next())&&!r.done;){const i=r.value;e.call(n,i[0],i[1])}},af=(n,e)=>{let t;const s=[];for(;(t=n.exec(e))!==null;)s.push(t);return s},of=je("HTMLFormElement"),lf=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,s,r){return s.toUpperCase()+r}),ro=(({hasOwnProperty:n})=>(e,t)=>n.call(e,t))(Object.prototype),cf=je("RegExp"),io=(n,e)=>{const t=Object.getOwnPropertyDescriptors(n),s={};cs(t,(r,i)=>{let a;(a=e(r,i,n))!==!1&&(s[i]=a||r)}),Object.defineProperties(n,s)},uf=n=>{io(n,(e,t)=>{if($e(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const s=n[t];if($e(s)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},df=(n,e)=>{const t={},s=r=>{r.forEach(i=>{t[i]=!0})};return Ht(n)?s(n):s(String(n).split(e)),t},ff=()=>{},hf=(n,e)=>n!=null&&Number.isFinite(n=+n)?n:e,Er="abcdefghijklmnopqrstuvwxyz",ao="0123456789",oo={DIGIT:ao,ALPHA:Er,ALPHA_DIGIT:Er+Er.toUpperCase()+ao},pf=(n=16,e=oo.ALPHA_DIGIT)=>{let t="";const{length:s}=e;for(;n--;)t+=e[Math.random()*s|0];return t};function gf(n){return!!(n&&$e(n.append)&&n[Symbol.toStringTag]==="FormData"&&n[Symbol.iterator])}const mf=n=>{const e=new Array(10),t=(s,r)=>{if(Zs(s)){if(e.indexOf(s)>=0)return;if(!("toJSON"in s)){e[r]=s;const i=Ht(s)?[]:{};return cs(s,(a,o)=>{const l=t(a,r+1);!ls(l)&&(i[o]=l)}),e[r]=void 0,i}}return s};return t(n,0)},yf=je("AsyncFunction"),Ef=n=>n&&(Zs(n)||$e(n))&&$e(n.then)&&$e(n.catch),lo=((n,e)=>n?setImmediate:e?((t,s)=>(Lt.addEventListener("message",({source:r,data:i})=>{r===Lt&&i===t&&s.length&&s.shift()()},!1),r=>{s.push(r),Lt.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",$e(Lt.postMessage)),Sf=typeof queueMicrotask<"u"?queueMicrotask.bind(Lt):typeof process<"u"&&process.nextTick||lo,_={isArray:Ht,isArrayBuffer:eo,isBuffer:F0,isFormData:K0,isArrayBufferView:M0,isString:N0,isNumber:to,isBoolean:B0,isObject:Zs,isPlainObject:Qs,isReadableStream:j0,isRequest:z0,isResponse:q0,isHeaders:Y0,isUndefined:ls,isDate:U0,isFile:$0,isBlob:V0,isRegExp:cf,isFunction:$e,isStream:H0,isURLSearchParams:W0,isTypedArray:nf,isFileList:G0,forEach:cs,merge:yr,extend:Z0,trim:X0,stripBOM:Q0,inherits:J0,toFlatObject:ef,kindOf:Ys,kindOfTest:je,endsWith:tf,toArray:sf,forEachEntry:rf,matchAll:af,isHTMLForm:of,hasOwnProperty:ro,hasOwnProp:ro,reduceDescriptors:io,freezeMethods:uf,toObjectSet:df,toCamelCase:lf,noop:ff,toFiniteNumber:hf,findKey:so,global:Lt,isContextDefined:no,ALPHABET:oo,generateString:pf,isSpecCompliantForm:gf,toJSONObject:mf,isAsyncFn:yf,isThenable:Ef,setImmediate:lo,asap:Sf};function ee(n,e,t,s,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),s&&(this.request=s),r&&(this.response=r,this.status=r.status?r.status:null)}_.inherits(ee,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:_.toJSONObject(this.config),code:this.code,status:this.status}}});const co=ee.prototype,uo={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{uo[n]={value:n}}),Object.defineProperties(ee,uo),Object.defineProperty(co,"isAxiosError",{value:!0}),ee.from=(n,e,t,s,r,i)=>{const a=Object.create(co);return _.toFlatObject(n,a,function(l){return l!==Error.prototype},o=>o!=="isAxiosError"),ee.call(a,n.message,e,t,s,r),a.cause=n,a.name=n.name,i&&Object.assign(a,i),a};const Tf=null;function Sr(n){return _.isPlainObject(n)||_.isArray(n)}function fo(n){return _.endsWith(n,"[]")?n.slice(0,-2):n}function ho(n,e,t){return n?n.concat(e).map(function(r,i){return r=fo(r),!t&&i?"["+r+"]":r}).join(t?".":""):e}function xf(n){return _.isArray(n)&&!n.some(Sr)}const vf=_.toFlatObject(_,{},null,function(e){return/^is[A-Z]/.test(e)});function Js(n,e,t){if(!_.isObject(n))throw new TypeError("target must be an object");e=e||new FormData,t=_.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,p){return!_.isUndefined(p[m])});const s=t.metaTokens,r=t.visitor||u,i=t.dots,a=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&_.isSpecCompliantForm(e);if(!_.isFunction(r))throw new TypeError("visitor must be a function");function c(h){if(h===null)return"";if(_.isDate(h))return h.toISOString();if(!l&&_.isBlob(h))throw new ee("Blob is not supported. Use a Buffer instead.");return _.isArrayBuffer(h)||_.isTypedArray(h)?l&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,m,p){let E=h;if(h&&!p&&typeof h=="object"){if(_.endsWith(m,"{}"))m=s?m:m.slice(0,-2),h=JSON.stringify(h);else if(_.isArray(h)&&xf(h)||(_.isFileList(h)||_.endsWith(m,"[]"))&&(E=_.toArray(h)))return m=fo(m),E.forEach(function(v,w){!(_.isUndefined(v)||v===null)&&e.append(a===!0?ho([m],w,i):a===null?m:m+"[]",c(v))}),!1}return Sr(h)?!0:(e.append(ho(p,m,i),c(h)),!1)}const d=[],f=Object.assign(vf,{defaultVisitor:u,convertValue:c,isVisitable:Sr});function g(h,m){if(!_.isUndefined(h)){if(d.indexOf(h)!==-1)throw Error("Circular reference detected in "+m.join("."));d.push(h),_.forEach(h,function(E,x){(!(_.isUndefined(E)||E===null)&&r.call(e,E,_.isString(x)?x.trim():x,m,f))===!0&&g(E,m?m.concat(x):[x])}),d.pop()}}if(!_.isObject(n))throw new TypeError("data must be an object");return g(n),e}function po(n){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(s){return e[s]})}function Tr(n,e){this._pairs=[],n&&Js(n,this,e)}const go=Tr.prototype;go.append=function(e,t){this._pairs.push([e,t])},go.toString=function(e){const t=e?function(s){return e.call(this,s,po)}:po;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function bf(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function mo(n,e,t){if(!e)return n;const s=t&&t.encode||bf;_.isFunction(t)&&(t={serialize:t});const r=t&&t.serialize;let i;if(r?i=r(e,t):i=_.isURLSearchParams(e)?e.toString():new Tr(e,t).toString(s),i){const a=n.indexOf("#");a!==-1&&(n=n.slice(0,a)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}class yo{constructor(){this.handlers=[]}use(e,t,s){return this.handlers.push({fulfilled:e,rejected:t,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){_.forEach(this.handlers,function(s){s!==null&&e(s)})}}const Eo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Cf={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Tr,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},xr=typeof window<"u"&&typeof document<"u",vr=typeof navigator=="object"&&navigator||void 0,wf=xr&&(!vr||["ReactNative","NativeScript","NS"].indexOf(vr.product)<0),Lf=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Af=xr&&window.location.href||"http://localhost",Re={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:xr,hasStandardBrowserEnv:wf,hasStandardBrowserWebWorkerEnv:Lf,navigator:vr,origin:Af},Symbol.toStringTag,{value:"Module"})),...Cf};function Df(n,e){return Js(n,new Re.classes.URLSearchParams,Object.assign({visitor:function(t,s,r,i){return Re.isNode&&_.isBuffer(t)?(this.append(s,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},e))}function If(n){return _.matchAll(/\w+|\[(\w*)]/g,n).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Rf(n){const e={},t=Object.keys(n);let s;const r=t.length;let i;for(s=0;s<r;s++)i=t[s],e[i]=n[i];return e}function So(n){function e(t,s,r,i){let a=t[i++];if(a==="__proto__")return!0;const o=Number.isFinite(+a),l=i>=t.length;return a=!a&&_.isArray(r)?r.length:a,l?(_.hasOwnProp(r,a)?r[a]=[r[a],s]:r[a]=s,!o):((!r[a]||!_.isObject(r[a]))&&(r[a]=[]),e(t,s,r[a],i)&&_.isArray(r[a])&&(r[a]=Rf(r[a])),!o)}if(_.isFormData(n)&&_.isFunction(n.entries)){const t={};return _.forEachEntry(n,(s,r)=>{e(If(s),r,t,0)}),t}return null}function kf(n,e,t){if(_.isString(n))try{return(e||JSON.parse)(n),_.trim(n)}catch(s){if(s.name!=="SyntaxError")throw s}return(0,JSON.stringify)(n)}const us={transitional:Eo,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const s=t.getContentType()||"",r=s.indexOf("application/json")>-1,i=_.isObject(e);if(i&&_.isHTMLForm(e)&&(e=new FormData(e)),_.isFormData(e))return r?JSON.stringify(So(e)):e;if(_.isArrayBuffer(e)||_.isBuffer(e)||_.isStream(e)||_.isFile(e)||_.isBlob(e)||_.isReadableStream(e))return e;if(_.isArrayBufferView(e))return e.buffer;if(_.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(s.indexOf("application/x-www-form-urlencoded")>-1)return Df(e,this.formSerializer).toString();if((o=_.isFileList(e))||s.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Js(o?{"files[]":e}:e,l&&new l,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),kf(e)):e}],transformResponse:[function(e){const t=this.transitional||us.transitional,s=t&&t.forcedJSONParsing,r=this.responseType==="json";if(_.isResponse(e)||_.isReadableStream(e))return e;if(e&&_.isString(e)&&(s&&!this.responseType||r)){const a=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(o){if(a)throw o.name==="SyntaxError"?ee.from(o,ee.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Re.classes.FormData,Blob:Re.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_.forEach(["delete","get","head","post","put","patch"],n=>{us.headers[n]={}});const Pf=_.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),_f=n=>{const e={};let t,s,r;return n&&n.split(`
|
|
35
|
+
`).forEach(function(a){r=a.indexOf(":"),t=a.substring(0,r).trim().toLowerCase(),s=a.substring(r+1).trim(),!(!t||e[t]&&Pf[t])&&(t==="set-cookie"?e[t]?e[t].push(s):e[t]=[s]:e[t]=e[t]?e[t]+", "+s:s)}),e},To=Symbol("internals");function ds(n){return n&&String(n).trim().toLowerCase()}function en(n){return n===!1||n==null?n:_.isArray(n)?n.map(en):String(n)}function Of(n){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=t.exec(n);)e[s[1]]=s[2];return e}const Ff=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function br(n,e,t,s,r){if(_.isFunction(s))return s.call(this,e,t);if(r&&(e=t),!!_.isString(e)){if(_.isString(s))return e.indexOf(s)!==-1;if(_.isRegExp(s))return s.test(e)}}function Mf(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,s)=>t.toUpperCase()+s)}function Nf(n,e){const t=_.toCamelCase(" "+e);["get","set","has"].forEach(s=>{Object.defineProperty(n,s+t,{value:function(r,i,a){return this[s].call(this,e,r,i,a)},configurable:!0})})}class Oe{constructor(e){e&&this.set(e)}set(e,t,s){const r=this;function i(o,l,c){const u=ds(l);if(!u)throw new Error("header name must be a non-empty string");const d=_.findKey(r,u);(!d||r[d]===void 0||c===!0||c===void 0&&r[d]!==!1)&&(r[d||l]=en(o))}const a=(o,l)=>_.forEach(o,(c,u)=>i(c,u,l));if(_.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(_.isString(e)&&(e=e.trim())&&!Ff(e))a(_f(e),t);else if(_.isHeaders(e))for(const[o,l]of e.entries())i(l,o,s);else e!=null&&i(t,e,s);return this}get(e,t){if(e=ds(e),e){const s=_.findKey(this,e);if(s){const r=this[s];if(!t)return r;if(t===!0)return Of(r);if(_.isFunction(t))return t.call(this,r,s);if(_.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ds(e),e){const s=_.findKey(this,e);return!!(s&&this[s]!==void 0&&(!t||br(this,this[s],s,t)))}return!1}delete(e,t){const s=this;let r=!1;function i(a){if(a=ds(a),a){const o=_.findKey(s,a);o&&(!t||br(s,s[o],o,t))&&(delete s[o],r=!0)}}return _.isArray(e)?e.forEach(i):i(e),r}clear(e){const t=Object.keys(this);let s=t.length,r=!1;for(;s--;){const i=t[s];(!e||br(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){const t=this,s={};return _.forEach(this,(r,i)=>{const a=_.findKey(s,i);if(a){t[a]=en(r),delete t[i];return}const o=e?Mf(i):String(i).trim();o!==i&&delete t[i],t[o]=en(r),s[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return _.forEach(this,(s,r)=>{s!=null&&s!==!1&&(t[r]=e&&_.isArray(s)?s.join(", "):s)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
|
|
36
|
+
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const s=new this(e);return t.forEach(r=>s.set(r)),s}static accessor(e){const s=(this[To]=this[To]={accessors:{}}).accessors,r=this.prototype;function i(a){const o=ds(a);s[o]||(Nf(r,a),s[o]=!0)}return _.isArray(e)?e.forEach(i):i(e),this}}Oe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),_.reduceDescriptors(Oe.prototype,({value:n},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>n,set(s){this[t]=s}}}),_.freezeMethods(Oe);function Cr(n,e){const t=this||us,s=e||t,r=Oe.from(s.headers);let i=s.data;return _.forEach(n,function(o){i=o.call(t,i,r.normalize(),e?e.status:void 0)}),r.normalize(),i}function xo(n){return!!(n&&n.__CANCEL__)}function Kt(n,e,t){ee.call(this,n??"canceled",ee.ERR_CANCELED,e,t),this.name="CanceledError"}_.inherits(Kt,ee,{__CANCEL__:!0});function vo(n,e,t){const s=t.config.validateStatus;!t.status||!s||s(t.status)?n(t):e(new ee("Request failed with status code "+t.status,[ee.ERR_BAD_REQUEST,ee.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Bf(n){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}function Uf(n,e){n=n||10;const t=new Array(n),s=new Array(n);let r=0,i=0,a;return e=e!==void 0?e:1e3,function(l){const c=Date.now(),u=s[i];a||(a=c),t[r]=l,s[r]=c;let d=i,f=0;for(;d!==r;)f+=t[d++],d=d%n;if(r=(r+1)%n,r===i&&(i=(i+1)%n),c-a<e)return;const g=u&&c-u;return g?Math.round(f*1e3/g):void 0}}function $f(n,e){let t=0,s=1e3/e,r,i;const a=(c,u=Date.now())=>{t=u,r=null,i&&(clearTimeout(i),i=null),n.apply(null,c)};return[(...c)=>{const u=Date.now(),d=u-t;d>=s?a(c,u):(r=c,i||(i=setTimeout(()=>{i=null,a(r)},s-d)))},()=>r&&a(r)]}const tn=(n,e,t=3)=>{let s=0;const r=Uf(50,250);return $f(i=>{const a=i.loaded,o=i.lengthComputable?i.total:void 0,l=a-s,c=r(l),u=a<=o;s=a;const d={loaded:a,total:o,progress:o?a/o:void 0,bytes:l,rate:c||void 0,estimated:c&&o&&u?(o-a)/c:void 0,event:i,lengthComputable:o!=null,[e?"download":"upload"]:!0};n(d)},t)},bo=(n,e)=>{const t=n!=null;return[s=>e[0]({lengthComputable:t,total:n,loaded:s}),e[1]]},Co=n=>(...e)=>_.asap(()=>n(...e)),Vf=Re.hasStandardBrowserEnv?((n,e)=>t=>(t=new URL(t,Re.origin),n.protocol===t.protocol&&n.host===t.host&&(e||n.port===t.port)))(new URL(Re.origin),Re.navigator&&/(msie|trident)/i.test(Re.navigator.userAgent)):()=>!0,Gf=Re.hasStandardBrowserEnv?{write(n,e,t,s,r,i){const a=[n+"="+encodeURIComponent(e)];_.isNumber(t)&&a.push("expires="+new Date(t).toGMTString()),_.isString(s)&&a.push("path="+s),_.isString(r)&&a.push("domain="+r),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read(n){const e=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(n){this.write(n,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Hf(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function Kf(n,e){return e?n.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):n}function wo(n,e){return n&&!Hf(e)?Kf(n,e):e}const Lo=n=>n instanceof Oe?{...n}:n;function At(n,e){e=e||{};const t={};function s(c,u,d,f){return _.isPlainObject(c)&&_.isPlainObject(u)?_.merge.call({caseless:f},c,u):_.isPlainObject(u)?_.merge({},u):_.isArray(u)?u.slice():u}function r(c,u,d,f){if(_.isUndefined(u)){if(!_.isUndefined(c))return s(void 0,c,d,f)}else return s(c,u,d,f)}function i(c,u){if(!_.isUndefined(u))return s(void 0,u)}function a(c,u){if(_.isUndefined(u)){if(!_.isUndefined(c))return s(void 0,c)}else return s(void 0,u)}function o(c,u,d){if(d in e)return s(c,u);if(d in n)return s(void 0,c)}const l={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(c,u,d)=>r(Lo(c),Lo(u),d,!0)};return _.forEach(Object.keys(Object.assign({},n,e)),function(u){const d=l[u]||r,f=d(n[u],e[u],u);_.isUndefined(f)&&d!==o||(t[u]=f)}),t}const Ao=n=>{const e=At({},n);let{data:t,withXSRFToken:s,xsrfHeaderName:r,xsrfCookieName:i,headers:a,auth:o}=e;e.headers=a=Oe.from(a),e.url=mo(wo(e.baseURL,e.url),n.params,n.paramsSerializer),o&&a.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):"")));let l;if(_.isFormData(t)){if(Re.hasStandardBrowserEnv||Re.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((l=a.getContentType())!==!1){const[c,...u]=l?l.split(";").map(d=>d.trim()).filter(Boolean):[];a.setContentType([c||"multipart/form-data",...u].join("; "))}}if(Re.hasStandardBrowserEnv&&(s&&_.isFunction(s)&&(s=s(e)),s||s!==!1&&Vf(e.url))){const c=r&&i&&Gf.read(i);c&&a.set(r,c)}return e},Wf=typeof XMLHttpRequest<"u"&&function(n){return new Promise(function(t,s){const r=Ao(n);let i=r.data;const a=Oe.from(r.headers).normalize();let{responseType:o,onUploadProgress:l,onDownloadProgress:c}=r,u,d,f,g,h;function m(){g&&g(),h&&h(),r.cancelToken&&r.cancelToken.unsubscribe(u),r.signal&&r.signal.removeEventListener("abort",u)}let p=new XMLHttpRequest;p.open(r.method.toUpperCase(),r.url,!0),p.timeout=r.timeout;function E(){if(!p)return;const v=Oe.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),b={data:!o||o==="text"||o==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:v,config:n,request:p};vo(function(A){t(A),m()},function(A){s(A),m()},b),p=null}"onloadend"in p?p.onloadend=E:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(E)},p.onabort=function(){p&&(s(new ee("Request aborted",ee.ECONNABORTED,n,p)),p=null)},p.onerror=function(){s(new ee("Network Error",ee.ERR_NETWORK,n,p)),p=null},p.ontimeout=function(){let w=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const b=r.transitional||Eo;r.timeoutErrorMessage&&(w=r.timeoutErrorMessage),s(new ee(w,b.clarifyTimeoutError?ee.ETIMEDOUT:ee.ECONNABORTED,n,p)),p=null},i===void 0&&a.setContentType(null),"setRequestHeader"in p&&_.forEach(a.toJSON(),function(w,b){p.setRequestHeader(b,w)}),_.isUndefined(r.withCredentials)||(p.withCredentials=!!r.withCredentials),o&&o!=="json"&&(p.responseType=r.responseType),c&&([f,h]=tn(c,!0),p.addEventListener("progress",f)),l&&p.upload&&([d,g]=tn(l),p.upload.addEventListener("progress",d),p.upload.addEventListener("loadend",g)),(r.cancelToken||r.signal)&&(u=v=>{p&&(s(!v||v.type?new Kt(null,n,p):v),p.abort(),p=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const x=Bf(r.url);if(x&&Re.protocols.indexOf(x)===-1){s(new ee("Unsupported protocol "+x+":",ee.ERR_BAD_REQUEST,n));return}p.send(i||null)})},jf=(n,e)=>{const{length:t}=n=n?n.filter(Boolean):[];if(e||t){let s=new AbortController,r;const i=function(c){if(!r){r=!0,o();const u=c instanceof Error?c:this.reason;s.abort(u instanceof ee?u:new Kt(u instanceof Error?u.message:u))}};let a=e&&setTimeout(()=>{a=null,i(new ee(`timeout ${e} of ms exceeded`,ee.ETIMEDOUT))},e);const o=()=>{n&&(a&&clearTimeout(a),a=null,n.forEach(c=>{c.unsubscribe?c.unsubscribe(i):c.removeEventListener("abort",i)}),n=null)};n.forEach(c=>c.addEventListener("abort",i));const{signal:l}=s;return l.unsubscribe=()=>_.asap(o),l}},zf=function*(n,e){let t=n.byteLength;if(t<e){yield n;return}let s=0,r;for(;s<t;)r=s+e,yield n.slice(s,r),s=r},qf=async function*(n,e){for await(const t of Yf(n))yield*zf(t,e)},Yf=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const e=n.getReader();try{for(;;){const{done:t,value:s}=await e.read();if(t)break;yield s}}finally{await e.cancel()}},Do=(n,e,t,s)=>{const r=qf(n,e);let i=0,a,o=l=>{a||(a=!0,s&&s(l))};return new ReadableStream({async pull(l){try{const{done:c,value:u}=await r.next();if(c){o(),l.close();return}let d=u.byteLength;if(t){let f=i+=d;t(f)}l.enqueue(new Uint8Array(u))}catch(c){throw o(c),c}},cancel(l){return o(l),r.return()}},{highWaterMark:2})},sn=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Io=sn&&typeof ReadableStream=="function",Xf=sn&&(typeof TextEncoder=="function"?(n=>e=>n.encode(e))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),Ro=(n,...e)=>{try{return!!n(...e)}catch{return!1}},Zf=Io&&Ro(()=>{let n=!1;const e=new Request(Re.origin,{body:new ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type");return n&&!e}),ko=64*1024,wr=Io&&Ro(()=>_.isReadableStream(new Response("").body)),nn={stream:wr&&(n=>n.body)};sn&&(n=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!nn[e]&&(nn[e]=_.isFunction(n[e])?t=>t[e]():(t,s)=>{throw new ee(`Response type '${e}' is not supported`,ee.ERR_NOT_SUPPORT,s)})})})(new Response);const Qf=async n=>{if(n==null)return 0;if(_.isBlob(n))return n.size;if(_.isSpecCompliantForm(n))return(await new Request(Re.origin,{method:"POST",body:n}).arrayBuffer()).byteLength;if(_.isArrayBufferView(n)||_.isArrayBuffer(n))return n.byteLength;if(_.isURLSearchParams(n)&&(n=n+""),_.isString(n))return(await Xf(n)).byteLength},Jf=async(n,e)=>{const t=_.toFiniteNumber(n.getContentLength());return t??Qf(e)},Lr={http:Tf,xhr:Wf,fetch:sn&&(async n=>{let{url:e,method:t,data:s,signal:r,cancelToken:i,timeout:a,onDownloadProgress:o,onUploadProgress:l,responseType:c,headers:u,withCredentials:d="same-origin",fetchOptions:f}=Ao(n);c=c?(c+"").toLowerCase():"text";let g=jf([r,i&&i.toAbortSignal()],a),h;const m=g&&g.unsubscribe&&(()=>{g.unsubscribe()});let p;try{if(l&&Zf&&t!=="get"&&t!=="head"&&(p=await Jf(u,s))!==0){let b=new Request(e,{method:"POST",body:s,duplex:"half"}),I;if(_.isFormData(s)&&(I=b.headers.get("content-type"))&&u.setContentType(I),b.body){const[A,F]=bo(p,tn(Co(l)));s=Do(b.body,ko,A,F)}}_.isString(d)||(d=d?"include":"omit");const E="credentials"in Request.prototype;h=new Request(e,{...f,signal:g,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:s,duplex:"half",credentials:E?d:void 0});let x=await fetch(h);const v=wr&&(c==="stream"||c==="response");if(wr&&(o||v&&m)){const b={};["status","statusText","headers"].forEach(U=>{b[U]=x[U]});const I=_.toFiniteNumber(x.headers.get("content-length")),[A,F]=o&&bo(I,tn(Co(o),!0))||[];x=new Response(Do(x.body,ko,A,()=>{F&&F(),m&&m()}),b)}c=c||"text";let w=await nn[_.findKey(nn,c)||"text"](x,n);return!v&&m&&m(),await new Promise((b,I)=>{vo(b,I,{data:w,headers:Oe.from(x.headers),status:x.status,statusText:x.statusText,config:n,request:h})})}catch(E){throw m&&m(),E&&E.name==="TypeError"&&/fetch/i.test(E.message)?Object.assign(new ee("Network Error",ee.ERR_NETWORK,n,h),{cause:E.cause||E}):ee.from(E,E&&E.code,n,h)}})};_.forEach(Lr,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});const Po=n=>`- ${n}`,eh=n=>_.isFunction(n)||n===null||n===!1,_o={getAdapter:n=>{n=_.isArray(n)?n:[n];const{length:e}=n;let t,s;const r={};for(let i=0;i<e;i++){t=n[i];let a;if(s=t,!eh(t)&&(s=Lr[(a=String(t)).toLowerCase()],s===void 0))throw new ee(`Unknown adapter '${a}'`);if(s)break;r[a||"#"+i]=s}if(!s){const i=Object.entries(r).map(([o,l])=>`adapter ${o} `+(l===!1?"is not supported by the environment":"is not available in the build"));let a=e?i.length>1?`since :
|
|
37
|
+
`+i.map(Po).join(`
|
|
38
|
+
`):" "+Po(i[0]):"as no adapter specified";throw new ee("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return s},adapters:Lr};function Ar(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new Kt(null,n)}function Oo(n){return Ar(n),n.headers=Oe.from(n.headers),n.data=Cr.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),_o.getAdapter(n.adapter||us.adapter)(n).then(function(s){return Ar(n),s.data=Cr.call(n,n.transformResponse,s),s.headers=Oe.from(s.headers),s},function(s){return xo(s)||(Ar(n),s&&s.response&&(s.response.data=Cr.call(n,n.transformResponse,s.response),s.response.headers=Oe.from(s.response.headers))),Promise.reject(s)})}const Fo="1.7.9",rn={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{rn[n]=function(s){return typeof s===n||"a"+(e<1?"n ":" ")+n}});const Mo={};rn.transitional=function(e,t,s){function r(i,a){return"[Axios v"+Fo+"] Transitional option '"+i+"'"+a+(s?". "+s:"")}return(i,a,o)=>{if(e===!1)throw new ee(r(a," has been removed"+(t?" in "+t:"")),ee.ERR_DEPRECATED);return t&&!Mo[a]&&(Mo[a]=!0,console.warn(r(a," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,a,o):!0}},rn.spelling=function(e){return(t,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};function th(n,e,t){if(typeof n!="object")throw new ee("options must be an object",ee.ERR_BAD_OPTION_VALUE);const s=Object.keys(n);let r=s.length;for(;r-- >0;){const i=s[r],a=e[i];if(a){const o=n[i],l=o===void 0||a(o,i,n);if(l!==!0)throw new ee("option "+i+" must be "+l,ee.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new ee("Unknown option "+i,ee.ERR_BAD_OPTION)}}const an={assertOptions:th,validators:rn},Ze=an.validators;class Dt{constructor(e){this.defaults=e,this.interceptors={request:new yo,response:new yo}}async request(e,t){try{return await this._request(e,t)}catch(s){if(s instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const i=r.stack?r.stack.replace(/^.+\n/,""):"";try{s.stack?i&&!String(s.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(s.stack+=`
|
|
39
|
+
`+i):s.stack=i}catch{}}throw s}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=At(this.defaults,t);const{transitional:s,paramsSerializer:r,headers:i}=t;s!==void 0&&an.assertOptions(s,{silentJSONParsing:Ze.transitional(Ze.boolean),forcedJSONParsing:Ze.transitional(Ze.boolean),clarifyTimeoutError:Ze.transitional(Ze.boolean)},!1),r!=null&&(_.isFunction(r)?t.paramsSerializer={serialize:r}:an.assertOptions(r,{encode:Ze.function,serialize:Ze.function},!0)),an.assertOptions(t,{baseUrl:Ze.spelling("baseURL"),withXsrfToken:Ze.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=i&&_.merge(i.common,i[t.method]);i&&_.forEach(["delete","get","head","post","put","patch","common"],h=>{delete i[h]}),t.headers=Oe.concat(a,i);const o=[];let l=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(l=l&&m.synchronous,o.unshift(m.fulfilled,m.rejected))});const c=[];this.interceptors.response.forEach(function(m){c.push(m.fulfilled,m.rejected)});let u,d=0,f;if(!l){const h=[Oo.bind(this),void 0];for(h.unshift.apply(h,o),h.push.apply(h,c),f=h.length,u=Promise.resolve(t);d<f;)u=u.then(h[d++],h[d++]);return u}f=o.length;let g=t;for(d=0;d<f;){const h=o[d++],m=o[d++];try{g=h(g)}catch(p){m.call(this,p);break}}try{u=Oo.call(this,g)}catch(h){return Promise.reject(h)}for(d=0,f=c.length;d<f;)u=u.then(c[d++],c[d++]);return u}getUri(e){e=At(this.defaults,e);const t=wo(e.baseURL,e.url);return mo(t,e.params,e.paramsSerializer)}}_.forEach(["delete","get","head","options"],function(e){Dt.prototype[e]=function(t,s){return this.request(At(s||{},{method:e,url:t,data:(s||{}).data}))}}),_.forEach(["post","put","patch"],function(e){function t(s){return function(i,a,o){return this.request(At(o||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:i,data:a}))}}Dt.prototype[e]=t(),Dt.prototype[e+"Form"]=t(!0)});class Dr{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const s=this;this.promise.then(r=>{if(!s._listeners)return;let i=s._listeners.length;for(;i-- >0;)s._listeners[i](r);s._listeners=null}),this.promise.then=r=>{let i;const a=new Promise(o=>{s.subscribe(o),i=o}).then(r);return a.cancel=function(){s.unsubscribe(i)},a},e(function(i,a,o){s.reason||(s.reason=new Kt(i,a,o),t(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=s=>{e.abort(s)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new Dr(function(r){e=r}),cancel:e}}}function sh(n){return function(t){return n.apply(null,t)}}function nh(n){return _.isObject(n)&&n.isAxiosError===!0}const Ir={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ir).forEach(([n,e])=>{Ir[e]=n});function No(n){const e=new Dt(n),t=Ja(Dt.prototype.request,e);return _.extend(t,Dt.prototype,e,{allOwnKeys:!0}),_.extend(t,e,null,{allOwnKeys:!0}),t.create=function(r){return No(At(n,r))},t}const ge=No(us);ge.Axios=Dt,ge.CanceledError=Kt,ge.CancelToken=Dr,ge.isCancel=xo,ge.VERSION=Fo,ge.toFormData=Js,ge.AxiosError=ee,ge.Cancel=ge.CanceledError,ge.all=function(e){return Promise.all(e)},ge.spread=sh,ge.isAxiosError=nh,ge.mergeConfig=At,ge.AxiosHeaders=Oe,ge.formToJSON=n=>So(_.isHTMLForm(n)?new FormData(n):n),ge.getAdapter=_o.getAdapter,ge.HttpStatusCode=Ir,ge.default=ge;const Rr={baseUrl:"https://hamrahi.cloud",fluentdUrl:"https://hamrahi.cloud"},Bo=()=>Rr.baseUrl+"/live/api",Uo=()=>Rr.fluentdUrl,rh=()=>Rr.baseUrl+"/emoji",kr=()=>({vod:{getVodUrl:`${Bo()}/v1/live/details/vod/`,getMarkerUrl:n=>`${Bo()}/v1/live/list-event/vod/${n}/`},videoTimelineLog:`${Uo()}/video-timeline.log`,logs:`${Uo()}/drive-endpoint.log`}),oe=n=>{const{details:e,params:t}=R.getState().videoData;let s={...n,timestamp:Date.now(),clientUUID:ot(),uuid:ot(),link:window.location.href,user_id:e.user_id,live_id:null,format:void 0,content_type:e.content_type,content_id:e.content_id,daaniHashCode:t.daaniHashCode};ln({url:kr().logs,method:"post",data:s})},ih=n=>{const{params:e,details:t}=R.getState().videoData,{settings:s}=R.getState().user;return{category:"speedChange",previousSelectedSpeed:s.speed,selectedSpeed:n,id:Number(e.id),type:e.type,src:C(T.hasStreamLink)?t.stream_link:e.id,provider:e.provider}},ah=n=>{const{params:e,details:t}=R.getState().videoData,{qualityLevels:s,manualQuality:r,autoQuality:i}=R.getState().controller;return{category:"qualityChangeRequest",currentPlayingQuality:`${s[C(T.isAutoQuality)?i??r:r]}P`,previousSelectedQuality:C(T.isAutoQuality)?"auto":`${s[r]}P`,selectedQuality:n,id:Number(e.id),type:e.type,src:C(T.hasStreamLink)?t.stream_link:e.id,provider:e.provider}},oh=n=>{const{params:e,details:t}=R.getState().videoData,{qualityLevels:s,autoQuality:r}=R.getState().controller,{settings:i}=R.getState().user;return{category:"catchUpLoading",previousVideoTime:Number(sessionStorage.getItem("previousVideoTime")),currentVideoTime:N().currentTime,duration:n,quality:`${C(T.isAutoQuality)?s[r]:s[i.quality]}P`,isAutoQuality:C(T.isAutoQuality),id:Number(e.id),type:e.type,src:C(T.hasStreamLink)?t.stream_link:e.id,provider:e.provider}},lh=n=>{const{params:e,details:t}=R.getState().videoData;return{category:n==="backward"?"backward":"forward",id:Number(e.id),type:e.type,src:t.stream_link?t.stream_link:e.id,provider:e.provider}},Pr=n=>{const{params:e,details:t}=R.getState().videoData;return{category:n,id:Number(e.id),type:e.type,src:C(T.hasStreamLink)?t.stream_link:e.id}},ch=(n,e)=>{const{params:t,details:s}=R.getState().videoData;return{category:"brightnessChange",source:n,target:e,id:Number(t.id),type:t.type,src:C(T.hasStreamLink)?s.stream_link:t.id}},on=(n,e)=>{const{params:t,details:s}=R.getState().videoData;return{category:"volumeChange",source:n,target:e,id:Number(t.id),type:t.type,src:C(T.hasStreamLink)?s.stream_link:t.id}},uh=n=>{const{params:e,details:t}=R.getState().videoData;return{category:n,id:Number(e.id),type:e.type,src:C(T.hasStreamLink)?t.stream_link:e.id}},dh=(n,e,t,s)=>({category:"player-error",type:n,message:e,statusCode:t,url:s}),fh=(n,e)=>{const{params:t,details:s}=R.getState().videoData,{duration:r}=R.getState().controller;return{category:"video-timeline",video_id:+t.id,video_type:t.type,start:n,end:e,watchedDuration:e-n,video_duration:Math.floor(r),clientUUID:ot(),user_id:s.user_id,content_type:s.content_type,content_id:s.content_id}},$o=(n,e,t)=>{const{params:s,details:r}=R.getState().videoData;return{category:"autoQualityChange",sourceQuality:n,targetQuality:e,diffQuality:t,id:Number(s.id),type:s.type,src:C(T.hasStreamLink)?r.stream_link:s.id,provider:s.provider}},hh=(n,e)=>{const{params:t,details:s}=R.getState().videoData;return{category:"pingpong",id:Number(t.id),type:t.type,src:C(T.hasStreamLink)?s.stream_link:t.id,PingPongDuration:Number((new Date().getTime()-n).toFixed(2)),PingPongSourceQuality:`${e[0]}P`,PingPongTargetQuality:`${e[1]}P`,provider:t.provider}},Vo=n=>{const{params:e,details:t}=R.getState().videoData;return{category:n?"playVideo":"pauseVideo",id:Number(e.id),type:e.type,src:t.stream_link?t.stream_link:e.id,provider:e.provider}},Go=(n,e,t,s,r)=>{const{params:i,details:a}=R.getState().videoData,o=Date.now()-r.current+n+e,l=window.performance.memory,c=JSON.parse(JSON.stringify(window.performance.timing));return{category:"initLog",id:Number(i.id),type:i.type,origin:new URL(C(T.hasStreamLink)?a.stream_link:i.id).origin,src:C(T.hasStreamLink)?a.stream_link:i.id,loading:n,bannerLoading:!C(T.hasBanner)||t<0?0:t,waiting:e,firstChunkPlaying:s<0?0:s,totalTime:o,provider:i.provider,performance:Xa({memory:l,timing:c},"performance"),userAgent:window.navigator.userAgent}},ph=(n,e,t,s,r)=>{const{params:i,details:a}=R.getState().videoData,{settings:o}=R.getState().user,l=Date.now()-t.current;return{category:"loading",id:Number(i.id),type:i.type,src:C(T.hasStreamLink)?a.stream_link:i.id,duration:n,quality:`${e}P`,isAutoQuality:C(T.isAutoQuality),previousLoaderDiff:l,counter:s.current,loadingPercentile:Number((n/l).toFixed(2)),videoTime:N().currentTime,videoEntranceTime:r,speed:o.speed,provider:i.provider}},fs=n=>{const{params:e,details:t}=R.getState().videoData;return{category:"subtitle",language:n,id:Number(e.id),type:e.type,src:C(T.hasStreamLink)?t.stream_link:e.id}},Ho=(n,e,t,s,r)=>{const{params:i,details:a}=R.getState().videoData;return{category:"eventMarkerClick",video_id:Number(i.id),markerId:n,markerTime:e,markerTitle:t,markerDescription:s,markerSticker:r,type:i.type,src:C(T.hasStreamLink)?a.stream_link:i.id,provider:i.provider}},lt=n=>{n&&oe(dh(n.type,n.message,n.statusCode,n.url))},ln=async({url:n,method:e="GET",data:t,headers:s,retryCount:r=1,maxRetryCount:i=0,errorMessage:a,retryPolicy:o,errorCallback:l,timeoutCount:c})=>{let u={url:n,method:e,headers:{...s,"Content-Type":"application/json"},timeout:c?c*1e3:void 0};t?e==="GET"?u={...u,params:{uuid:R.getState().videoData.params.uuid,provider:R.getState().videoData.params.provider==="unknown"?void 0:R.getState().videoData.params.provider,...t}}:u={...u,data:{uuid:R.getState().videoData.params.uuid,provider:R.getState().videoData.params.provider==="unknown"?void 0:R.getState().videoData.params.provider,...t}}:e==="GET"?u={...u,params:{uuid:R.getState().videoData.params.uuid,provider:R.getState().videoData.params.provider==="unknown"?void 0:R.getState().videoData.params.provider}}:u={...u,data:{uuid:R.getState().videoData.params.uuid,provider:R.getState().videoData.params.provider==="unknown"?void 0:R.getState().videoData.params.provider}};try{return await ge(u)}catch(d){if(lt({type:"API-ERROR",message:d.message?d.message:"",statusCode:d.response&&d.response.status?d.response.status:void 0,url:n}),!(d&&d.response&&d.response.status===401)){l&&l(d.response.status,d.response.message);let f=0,g=0;if(o!==void 0){for(let h=0;h<o.length;h++)if((o[h].codeAbove&&d.response.status>=o[h].codeAbove||o[h].codeBelow&&d.response.status<=o[h].codeBelow)&&(o[h].excludeCodes.length===0||!o[h].excludeCodes.includes(d.response.status))||o[h].includeCodes.length===0||o[h].includeCodes.includes(d.response.status)){g=o[h].count,f=o[h].delay;break}}else g=i,f=r+1;if(r<g)return await C0(f),ln({url:n,method:e,data:t,headers:s,retryCount:r+1,newMaxRetryCount:g,errorMessage:a,retryPolicy:o,errorCallback:l});if(d.response)return{data:d.response.data?d.response.data:{detail:"عملیات با خطا مواجه شده است."},status:d.response.status}}}},_r=n=>{if(n===null||n.target.nodeName!=="INPUT"){const e=R.dispatch;n!==null&&(n.stopPropagation(),n.preventDefault()),N().paused?N().play():N().pause(),e(Xe(!N().paused)),Ve()&&Ve().played&&(Ve().pause(),e(gt(!1)))}},gh=()=>{const n=R.dispatch,{play:e}=R.getState().controller;n(Xe(e)),setTimeout(()=>{N()&&(e?N().play():N().pause())},0)},mh=n=>{if(n===null||n.target.nodeName!=="INPUT"){const e=R.dispatch;Ve().paused?Ve().play():Ve().pause(),e(gt(!Ve().paused)),N()&&N().played&&(N().pause(),e(Xe(!1)))}},cn=n=>{const e=R.dispatch,{settings:t}=R.getState().user;e(at({...t,volume:n})),C(T.isIOS)?N().muted=!N().muted:N().volume=n/100},It=(n,e=15,t)=>{if(n==="touchBackward"?n="backward":n==="touchForward"&&(n="forward"),t&&t.target.nodeName==="INPUT"||n==="backward"&&N().currentTime<15||n==="forward"&&N().duration-N().currentTime<15)return;oe(lh(n));let s=0;n==="backward"?e===0?s=0:s=N().currentTime-e:n==="forward"&&(e===N().duration?s=e:s=N().currentTime+e),N().currentTime=s},Or=()=>{const n=R.dispatch,e=document.fullscreenElement;C(T.isIOS)?N().webkitEnterFullScreen?(n(Xe(!1)),N().webkitEnterFullScreen()):(n(Ks()),oe(Pr("fullScreen"))):e?(n(rs(!1)),document.exitFullscreen()):(n(Ks()),document.documentElement.requestFullscreen(),n(rs(!0)),oe(Pr("fullScreen")))},Fr=()=>{C(T.isTouchScreen)&&!C(T.isIOS)&&(C(T.isLandscape)&&!C(T.isFullScreen)?window.screen.orientation.lock("portrait"):window.screen.orientation.lock("landscape"))},Ko=n=>{const e=R.dispatch;e(l0(n==="lock")),oe(uh(n)),n==="unlock"&&localStorage.setItem("unlock-click","true")},hs=(n,e)=>{if(C(T.isSendTimelineLog)){const t=R.dispatch,{videoTimelines:s}=R.getState().videoData;let r=Math.floor(n),i=Math.floor(e);s.length===0?t(Us([r>=N().duration?i:r])):(s[0]<r&&ln({url:kr().videoTimelineLog,method:"post",data:fh(s[0],r)}),i&&i>=N().duration?t(Us([])):t(Us([i])))}},Wo=()=>{var t;const n=R.dispatch,e=(t=document.getElementById("video-area"))==null?void 0:t.getBoundingClientRect();e.height=e.width*9/16,e&&n(Ma(e))},yh=n=>{!C(T.isTouchScreen)&&n.target.nodeName!=="INPUT"&&Or()},Eh=n=>{const{params:e}=R.getState().videoData;return kr().vod.getVodUrl+(n||e.id)},ps={url:"",maxRetryCount:0,headers:{},retryPolicy:[],errorCallback:void 0},Sh=n=>(ps.url=Eh(n),ps.maxRetryCount=3,ps.retryPolicy=[{codeAbove:500,codeBelow:null,excludeCodes:[],includeCodes:[409],delay:1,count:3},{codeAbove:null,codeBelow:404,excludeCodes:[403,402,401,400],includeCodes:[],delay:10,count:6}],ps),Th=n=>(Sh(n),ps),jo=async n=>{const e=R.dispatch;try{const t=await ln({...Th(n)});if(I0(t.status)){if(await ge.head("https://"+za(t.data.hls_links)+t.data.path),n)return e(x0(t.data));xh(t.data)}else throw new Error(JSON.stringify({status:t.status,message:t.data}))}catch{e(Na(!0)),e(Ba(!1))}},xh=n=>{const e=R.dispatch,{params:t}=R.getState().videoData;e(Fa({...n,subtitles:C(T.hasSubtitlesInParams)?t.subtitles:n.subtitles,stream_link:!!n.stream_link&&A0("https://"+za(n.hls_links)+n.path)})),e(Na(!0)),e(Ba(!0))},un=()=>{const n=R.dispatch,{subtitles:e,selectedSubtitle:t}=R.getState().videoData,s=e.find(r=>r.language==="fa");t?(Object.values(N().textTracks).find(r=>r.mode==="showing").mode="disabled",n(as(void 0)),oe(fs("empty"))):s?(s.mode="showing",n(as(s)),oe(fs(s.language))):(N().textTracks[0].mode="showing",n(as(N().textTracks[0])),oe(fs(N().textTracks[0].language)))},Rt=(n,e)=>{const t=P.useRef(e);P.useEffect(()=>{t.current=e},[]),P.useEffect(()=>{const s=r=>{r.code===n&&!["INPUT","TEXTAREA"].includes(r.target.nodeName)&&!r.target.isContentEditable&&t.current(r)};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[n])},vh=()=>{Rt("Space",n=>{C(T.isPressKeySpace)&&_r(n)}),Rt("ArrowRight",n=>{C(T.isPressKeyArrowRight)&&It("forward",15,n)}),Rt("ArrowLeft",n=>{C(T.isPressKeyArrowLeft)&&It("backward",15,n)}),Rt("KeyI",()=>{C(T.isPressKeyI)&&N().requestPictureInPicture()}),Rt("KeyF",()=>{C(T.isPressKeyF)&&Or()}),Rt("KeyM",()=>{if(C(T.isPressKeyM)){const{settings:n}=R.getState().user;cn(n.volume?0:50)}}),Rt("KeyC",()=>{C(T.isPressKeyC)&&un()})},bh=P.lazy(()=>Promise.resolve().then(()=>wy)),Ch=P.lazy(()=>Promise.resolve().then(()=>ky)),wh=n=>{const{params:e}=V(({videoData:{isReady:s,params:r}})=>({isReady:s,params:r}),K);P.useEffect(()=>(e.id&&n.params.id!==e.id&&(e.type===Tt.static&&(N().pause(),N().removeAttribute("src"),N().load()),ja()),()=>ja()),[n.params.id]),_0(n.params),vh(),V(({controller:{isFullScreen:s}})=>({isFullScreen:s}),K);let t=S.jsx(S.Fragment,{});return C(T.isReady)?t=S.jsx(P.Suspense,{fallback:"",children:S.jsx("div",{className:`pl-h-full !pl-select-none desktop:pl-h-auto ${!C(T.isTouchScreen)&&"pl-rounded-[12px]"} ${C(T.isFullScreen)&&"pl-fixed pl-right-0 pl-top-0 pl-h-screen pl-w-screen !pl-overflow-hidden"}`,style:{zIndex:Pe.videoPlayerInFullScreen,touchAction:"pan-y"},children:C(T.isStaticFormat)?S.jsx(bh,{}):S.jsx(Ch,{})})}):t=S.jsx("div",{className:"!pl-aspect-video pl-max-h-screen pl-w-full pl-overflow-hidden pl-rounded-[12px] pl-bg-white"}),S.jsx("div",{dir:"rtl",className:"pl-h-full pl-w-full pl-rounded-[12px]",id:"parent-player",children:t})};class zo extends P.Component{constructor(){super(...arguments);Du(this,"state",{hasError:!1,error:null,errorInfo:null})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,s){this.setState({error:t,errorInfo:s}),lt({type:"OTHER_ERROR",message:t.message})}render(){return this.state.hasError?S.jsx(S.Fragment,{}):this.props.children}}const Lh=({params:n})=>(P.useEffect(()=>{n.primaryColor&&document.documentElement.style.setProperty("--color-primary",n.primaryColor)},[n.primaryColor]),S.jsx(zi,{store:R,children:S.jsx(zo,{children:S.jsx(wh,{params:n})})})),re={fullScreen:"data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2%209.75C1.59%209.75%201.25%209.41%201.25%209V6.5C1.25%203.61%203.61%201.25%206.5%201.25H9C9.41%201.25%209.75%201.59%209.75%202C9.75%202.41%209.41%202.75%209%202.75H6.5C4.43%202.75%202.75%204.43%202.75%206.5V9C2.75%209.41%202.41%209.75%202%209.75Z'%20fill='white'/%3e%3cpath%20d='M22%209.75C21.59%209.75%2021.25%209.41%2021.25%209V6.5C21.25%204.43%2019.57%202.75%2017.5%202.75H15C14.59%202.75%2014.25%202.41%2014.25%202C14.25%201.59%2014.59%201.25%2015%201.25H17.5C20.39%201.25%2022.75%203.61%2022.75%206.5V9C22.75%209.41%2022.41%209.75%2022%209.75Z'%20fill='white'/%3e%3cpath%20d='M17.5%2022.75H16C15.59%2022.75%2015.25%2022.41%2015.25%2022C15.25%2021.59%2015.59%2021.25%2016%2021.25H17.5C19.57%2021.25%2021.25%2019.57%2021.25%2017.5V16C21.25%2015.59%2021.59%2015.25%2022%2015.25C22.41%2015.25%2022.75%2015.59%2022.75%2016V17.5C22.75%2020.39%2020.39%2022.75%2017.5%2022.75Z'%20fill='white'/%3e%3cpath%20d='M9%2022.75H6.5C3.61%2022.75%201.25%2020.39%201.25%2017.5V15C1.25%2014.59%201.59%2014.25%202%2014.25C2.41%2014.25%202.75%2014.59%202.75%2015V17.5C2.75%2019.57%204.43%2021.25%206.5%2021.25H9C9.41%2021.25%209.75%2021.59%209.75%2022C9.75%2022.41%209.41%2022.75%209%2022.75Z'%20fill='white'/%3e%3c/svg%3e",nonFullScreen:"data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7.875%201.41667C8.21667%201.41667%208.5%201.7%208.5%202.04167L8.5%204.125C8.5%206.53333%206.53333%208.5%204.125%208.5L2.04167%208.5C1.7%208.5%201.41667%208.21667%201.41667%207.875C1.41667%207.53333%201.7%207.25%202.04167%207.25L4.125%207.25C5.85%207.25%207.25%205.85%207.25%204.125L7.25%202.04167C7.25%201.7%207.53333%201.41667%207.875%201.41667Z'%20fill='white'/%3e%3cpath%20d='M12.0417%201.41667C12.3833%201.41667%2012.6667%201.7%2012.6667%202.04167L12.6667%204.125C12.6667%205.85%2014.0667%207.25%2015.7917%207.25L17.875%207.25C18.2167%207.25%2018.5%207.53333%2018.5%207.875C18.5%208.21667%2018.2167%208.5%2017.875%208.5L15.7917%208.5C13.3833%208.5%2011.4167%206.53333%2011.4167%204.125L11.4167%202.04167C11.4167%201.7%2011.7%201.41667%2012.0417%201.41667Z'%20fill='white'/%3e%3cpath%20d='M16.376%2011.42L17.792%2011.42C18.179%2011.42%2018.5%2011.741%2018.5%2012.128C18.5%2012.515%2018.179%2012.836%2017.792%2012.836L16.376%2012.836C14.4219%2012.836%2012.836%2014.4219%2012.836%2016.376L12.836%2017.792C12.836%2018.179%2012.515%2018.5%2012.128%2018.5C11.741%2018.5%2011.42%2018.179%2011.42%2017.792L11.42%2016.376C11.42%2013.6478%2013.6478%2011.42%2016.376%2011.42Z'%20fill='white'/%3e%3cpath%20d='M2.04167%2011.4167L4.125%2011.4167C6.53333%2011.4167%208.5%2013.3833%208.5%2015.7917L8.5%2017.875C8.5%2018.2167%208.21667%2018.5%207.875%2018.5C7.53333%2018.5%207.25%2018.2167%207.25%2017.875L7.25%2015.7917C7.25%2014.0667%205.85%2012.6667%204.125%2012.6667L2.04167%2012.6667C1.7%2012.6667%201.41667%2012.3833%201.41667%2012.0417C1.41667%2011.7%201.7%2011.4167%202.04167%2011.4167Z'%20fill='white'/%3e%3c/svg%3e",settings:"data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M10%2013.125C8.275%2013.125%206.875%2011.725%206.875%2010C6.875%208.275%208.275%206.875%2010%206.875C11.725%206.875%2013.125%208.275%2013.125%2010C13.125%2011.725%2011.725%2013.125%2010%2013.125ZM10%208.125C8.96667%208.125%208.125%208.96667%208.125%2010C8.125%2011.0333%208.96667%2011.875%2010%2011.875C11.0333%2011.875%2011.875%2011.0333%2011.875%2010C11.875%208.96667%2011.0333%208.125%2010%208.125Z'%20fill='white'/%3e%3cpath%20d='M12.675%2018.4916C12.5%2018.4916%2012.325%2018.4666%2012.15%2018.425C11.6333%2018.2833%2011.2%2017.9583%2010.925%2017.5L10.825%2017.3333C10.3333%2016.4833%209.65829%2016.4833%209.16663%2017.3333L9.07496%2017.4916C8.79996%2017.9583%208.36663%2018.2916%207.84996%2018.425C7.32496%2018.5666%206.78329%2018.4916%206.32496%2018.2166L4.89163%2017.3916C4.38329%2017.1%204.01663%2016.625%203.85829%2016.05C3.70829%2015.475%203.78329%2014.8833%204.07496%2014.375C4.31663%2013.95%204.38329%2013.5666%204.24163%2013.325C4.09996%2013.0833%203.74163%2012.9416%203.24996%2012.9416C2.03329%2012.9416%201.04163%2011.95%201.04163%2010.7333V9.26662C1.04163%208.04995%202.03329%207.05829%203.24996%207.05829C3.74163%207.05829%204.09996%206.91662%204.24163%206.67495C4.38329%206.43329%204.32496%206.04995%204.07496%205.62495C3.78329%205.11662%203.70829%204.51662%203.85829%203.94995C4.00829%203.37495%204.37496%202.89995%204.89163%202.60829L6.33329%201.78329C7.27496%201.22495%208.51663%201.54995%209.08329%202.50829L9.18329%202.67495C9.67496%203.52495%2010.35%203.52495%2010.8416%202.67495L10.9333%202.51662C11.5%201.54995%2012.7416%201.22495%2013.6916%201.79162L15.125%202.61662C15.6333%202.90829%2016%203.38329%2016.1583%203.95829C16.3083%204.53329%2016.2333%205.12495%2015.9416%205.63329C15.7%206.05829%2015.6333%206.44162%2015.775%206.68329C15.9166%206.92495%2016.275%207.06662%2016.7666%207.06662C17.9833%207.06662%2018.975%208.05829%2018.975%209.27495V10.7416C18.975%2011.9583%2017.9833%2012.95%2016.7666%2012.95C16.275%2012.95%2015.9166%2013.0916%2015.775%2013.3333C15.6333%2013.575%2015.6916%2013.9583%2015.9416%2014.3833C16.2333%2014.8916%2016.3166%2015.4916%2016.1583%2016.0583C16.0083%2016.6333%2015.6416%2017.1083%2015.125%2017.4L13.6833%2018.225C13.3666%2018.4%2013.025%2018.4916%2012.675%2018.4916ZM9.99996%2015.4083C10.7416%2015.4083%2011.4333%2015.875%2011.9083%2016.7L12%2016.8583C12.1%2017.0333%2012.2666%2017.1583%2012.4666%2017.2083C12.6666%2017.2583%2012.8666%2017.2333%2013.0333%2017.1333L14.475%2016.3C14.6916%2016.175%2014.8583%2015.9666%2014.925%2015.7166C14.9916%2015.4666%2014.9583%2015.2083%2014.8333%2014.9916C14.3583%2014.175%2014.3%2013.3333%2014.6666%2012.6916C15.0333%2012.05%2015.7916%2011.6833%2016.7416%2011.6833C17.275%2011.6833%2017.7%2011.2583%2017.7%2010.725V9.25829C17.7%208.73329%2017.275%208.29995%2016.7416%208.29995C15.7916%208.29995%2015.0333%207.93329%2014.6666%207.29162C14.3%206.64995%2014.3583%205.80829%2014.8333%204.99162C14.9583%204.77495%2014.9916%204.51662%2014.925%204.26662C14.8583%204.01662%2014.7%203.81662%2014.4833%203.68329L13.0416%202.85829C12.6833%202.64162%2012.2083%202.76662%2011.9916%203.13329L11.9%203.29162C11.425%204.11662%2010.7333%204.58329%209.99163%204.58329C9.24996%204.58329%208.55829%204.11662%208.08329%203.29162L7.99163%203.12495C7.78329%202.77495%207.31663%202.64995%206.95829%202.85829L5.51663%203.69162C5.29996%203.81662%205.13329%204.02495%205.06663%204.27495C4.99996%204.52495%205.03329%204.78329%205.15829%204.99995C5.63329%205.81662%205.69163%206.65829%205.32496%207.29995C4.95829%207.94162%204.19996%208.30829%203.24996%208.30829C2.71663%208.30829%202.29163%208.73329%202.29163%209.26662V10.7333C2.29163%2011.2583%202.71663%2011.6916%203.24996%2011.6916C4.19996%2011.6916%204.95829%2012.0583%205.32496%2012.7C5.69163%2013.3416%205.63329%2014.1833%205.15829%2015C5.03329%2015.2166%204.99996%2015.475%205.06663%2015.725C5.13329%2015.975%205.29163%2016.175%205.50829%2016.3083L6.94996%2017.1333C7.12496%2017.2416%207.33329%2017.2666%207.52496%2017.2166C7.72496%2017.1666%207.89163%2017.0333%207.99996%2016.8583L8.09163%2016.7C8.56663%2015.8833%209.25829%2015.4083%209.99996%2015.4083Z'%20fill='white'/%3e%3c/svg%3e",bigPlay:"data:image/svg+xml,%3csvg%20width='29'%20height='29'%20viewBox='0%200%2029%2029'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M0.333252%205.20762V23.4614C0.333252%2027.1999%204.78234%2029.546%208.33325%2027.6768L17.0017%2023.1181L25.6701%2018.5403C29.221%2016.6711%2029.221%2011.998%2025.6701%2010.1287L17.0017%205.55095L8.33325%200.992273C4.78234%20-0.876977%200.333252%201.45005%200.333252%205.20762Z'%20fill='white'/%3e%3c/svg%3e",bigPause:"data:image/svg+xml,%3csvg%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M17.75%2031.85V8.15C17.75%205.9%2016.8%205%2014.4%205H8.35C5.95%205%205%205.9%205%208.15V31.85C5%2034.1%205.95%2035%208.35%2035H14.4C16.8%2035%2017.75%2034.1%2017.75%2031.85Z'%20fill='white'/%3e%3cpath%20d='M35%2031.85V8.15C35%205.9%2034.05%205%2031.65%205H25.6C23.2167%205%2022.25%205.9%2022.25%208.15V31.85C22.25%2034.1%2023.2%2035%2025.6%2035H31.65C34.05%2035%2035%2034.1%2035%2031.85Z'%20fill='white'/%3e%3c/svg%3e",mute:"data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M12.5%206.97499V6.17499C12.5%203.69165%2010.775%202.74165%208.67496%204.05832L6.24163%205.58332C5.97496%205.74165%205.66663%205.83332%205.35829%205.83332H4.16663C2.49996%205.83332%201.66663%206.66665%201.66663%208.33332V11.6667C1.66663%2013.3333%202.49996%2014.1667%204.16663%2014.1667H5.83329'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M8.67505%2015.9417C10.775%2017.2584%2012.5%2016.3001%2012.5%2013.8251V10.7917'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M15.675%207.8501C16.425%209.64176%2016.2%2011.7334%2015%2013.3334'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M17.625%206.5C18.85%209.40833%2018.4834%2012.8083%2016.525%2015.4167'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M18.3333%201.66675L1.66663%2018.3334'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",unMute:"data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M1.66663%208.33332V11.6667C1.66663%2013.3333%202.49996%2014.1667%204.16663%2014.1667H5.35829C5.66663%2014.1667%205.97496%2014.2583%206.24163%2014.4167L8.67496%2015.9417C10.775%2017.2583%2012.5%2016.3%2012.5%2013.825V6.17499C12.5%203.69165%2010.775%202.74165%208.67496%204.05832L6.24163%205.58332C5.97496%205.74165%205.66663%205.83332%205.35829%205.83332H4.16663C2.49996%205.83332%201.66663%206.66665%201.66663%208.33332Z'%20stroke='white'%20stroke-width='1.5'/%3e%3cpath%20d='M15%206.66663C16.4833%208.64163%2016.4833%2011.3583%2015%2013.3333'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M16.525%204.58337C18.9334%207.79171%2018.9334%2012.2084%2016.525%2015.4167'%20stroke='white'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",backward15:"data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14.4301%2016.9199H12.1401C11.7301%2016.9199%2011.3901%2016.5799%2011.3901%2016.1699C11.3901%2015.7599%2011.7301%2015.4199%2012.1401%2015.4199H14.4301C14.8601%2015.4199%2015.2101%2015.0699%2015.2101%2014.6399C15.2101%2014.2099%2014.8601%2013.8599%2014.4301%2013.8599H12.1401C11.9001%2013.8599%2011.6701%2013.7399%2011.5301%2013.5499C11.3901%2013.3599%2011.3501%2013.0999%2011.4301%2012.8699L12.1901%2010.5799C12.2901%2010.2699%2012.5801%2010.0699%2012.9001%2010.0699H15.9601C16.3701%2010.0699%2016.7101%2010.4099%2016.7101%2010.8199C16.7101%2011.2299%2016.3701%2011.5699%2015.9601%2011.5699H13.4401L13.1801%2012.3599H14.4301C15.6901%2012.3599%2016.7101%2013.3799%2016.7101%2014.6399C16.7101%2015.8999%2015.6801%2016.9199%2014.4301%2016.9199Z'%20fill='white'/%3e%3cpath%20d='M9.54004%2016.92C9.13004%2016.92%208.79004%2016.58%208.79004%2016.17V12.78L8.60004%2013C8.32004%2013.31%207.85004%2013.33%207.54004%2013.06C7.24004%2012.78%207.21004%2012.31%207.49004%2012L8.99004%2010.33C9.20004%2010.1%209.53004%2010.02%209.82004%2010.13C10.11%2010.24%2010.3%2010.52%2010.3%2010.83V16.18C10.29%2016.59%209.96004%2016.92%209.54004%2016.92Z'%20fill='white'/%3e%3cpath%20d='M12%203.48006C11.92%203.48006%2011.84%203.49006%2011.76%203.49006L12.58%202.47006C12.84%202.15006%2012.79%201.67006%2012.46%201.42006C12.13%201.17006%2011.67%201.21006%2011.41%201.54006L9.43998%204.00006C9.42998%204.01006%209.42998%204.02006%209.41998%204.04006C9.38998%204.08006%209.36998%204.13006%209.34998%204.17006C9.32998%204.22006%209.30998%204.26006%209.29998%204.30006C9.28998%204.35006%209.28998%204.39006%209.28998%204.44006C9.28998%204.49006%209.28998%204.54006%209.28998%204.59006C9.28998%204.61006%209.28998%204.62006%209.28998%204.64006C9.29998%204.67006%209.31998%204.69006%209.32998%204.72006C9.34998%204.77006%209.36998%204.81006%209.38998%204.86006C9.41998%204.90006%209.44998%204.94006%209.48998%204.97006C9.50998%205.00006%209.51998%205.03006%209.54998%205.05006C9.56998%205.06006%209.57998%205.07006%209.59998%205.08006C9.61998%205.10006%209.64998%205.11006%209.67998%205.12006C9.72998%205.15006%209.78998%205.17006%209.83998%205.18006C9.87998%205.20006%209.90998%205.20006%209.93998%205.20006C9.96998%205.20006%209.98998%205.21006%2010.02%205.21006C10.05%205.21006%2010.07%205.20006%2010.09%205.19006C10.12%205.19006%2010.15%205.20006%2010.18%205.19006C10.82%205.04006%2011.42%204.97006%2011.99%204.97006C16.48%204.97006%2020.13%208.62006%2020.13%2013.1101C20.13%2017.6001%2016.48%2021.2501%2011.99%2021.2501C7.49998%2021.2501%203.84998%2017.6001%203.84998%2013.1101C3.84998%2011.3701%204.41998%209.69006%205.49998%208.25006C5.74998%207.92006%205.67998%207.45006%205.34998%207.20006C5.01998%206.95006%204.54998%207.02006%204.29998%207.35006C3.01998%209.05006%202.34998%2011.0401%202.34998%2013.1101C2.34998%2018.4201%206.66997%2022.7501%2011.99%2022.7501C17.31%2022.7501%2021.63%2018.4301%2021.63%2013.1101C21.63%207.79006%2017.31%203.48006%2012%203.48006Z'%20fill='white'/%3e%3c/svg%3e",forward15:"data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14.4301%2016.9199H12.1401C11.7301%2016.9199%2011.3901%2016.5799%2011.3901%2016.1699C11.3901%2015.7599%2011.7301%2015.4199%2012.1401%2015.4199H14.4301C14.8601%2015.4199%2015.2101%2015.0699%2015.2101%2014.6399C15.2101%2014.2099%2014.8601%2013.8599%2014.4301%2013.8599H12.1401C11.9001%2013.8599%2011.6701%2013.7399%2011.5301%2013.5499C11.3901%2013.3599%2011.3501%2013.0999%2011.4301%2012.8699L12.1901%2010.5799C12.2901%2010.2699%2012.5801%2010.0699%2012.9001%2010.0699H15.9601C16.3701%2010.0699%2016.7101%2010.4099%2016.7101%2010.8199C16.7101%2011.2299%2016.3701%2011.5699%2015.9601%2011.5699H13.4401L13.1801%2012.3599H14.4301C15.6901%2012.3599%2016.7101%2013.3799%2016.7101%2014.6399C16.7101%2015.8999%2015.6801%2016.9199%2014.4301%2016.9199Z'%20fill='white'/%3e%3cpath%20d='M9.54004%2016.92C9.13004%2016.92%208.79004%2016.58%208.79004%2016.17V12.78L8.60004%2013C8.32004%2013.31%207.85004%2013.33%207.54004%2013.06C7.24004%2012.78%207.21004%2012.31%207.49004%2012L8.99004%2010.33C9.20004%2010.1%209.53004%2010.02%209.82004%2010.13C10.11%2010.24%2010.3%2010.52%2010.3%2010.83V16.18C10.29%2016.59%209.96004%2016.92%209.54004%2016.92Z'%20fill='white'/%3e%3cpath%20d='M19.69%207.35002C19.44%207.02002%2018.97%206.95002%2018.64%207.20002C18.31%207.45002%2018.24%207.92002%2018.49%208.25002C19.57%209.69002%2020.14%2011.37%2020.14%2013.11C20.14%2017.6%2016.49%2021.25%2012%2021.25C7.50998%2021.25%203.85998%2017.6%203.85998%2013.11C3.85998%208.62002%207.50998%204.98002%2012%204.98002C12.58%204.98002%2013.17%205.05002%2013.81%205.20002C13.84%205.21002%2013.87%205.20002%2013.9%205.20002C13.93%205.20002%2013.95%205.22002%2013.97%205.22002C14%205.22002%2014.02%205.21002%2014.05%205.21002C14.08%205.21002%2014.11%205.20002%2014.15%205.19002C14.21%205.18002%2014.26%205.15002%2014.31%205.13002C14.34%205.11002%2014.37%205.10002%2014.4%205.08002C14.41%205.07002%2014.43%205.07002%2014.44%205.06002C14.47%205.04002%2014.48%205.01002%2014.5%204.99002C14.54%204.95002%2014.57%204.92002%2014.6%204.87002C14.63%204.83002%2014.64%204.78002%2014.66%204.73002C14.67%204.70002%2014.69%204.67002%2014.7%204.64002C14.7%204.62002%2014.7%204.61002%2014.7%204.59002C14.71%204.54002%2014.71%204.49002%2014.7%204.44002C14.7%204.39002%2014.7%204.35002%2014.69%204.30002C14.68%204.26002%2014.66%204.22002%2014.64%204.17002C14.62%204.12002%2014.6%204.07002%2014.57%204.03002C14.57%204.02002%2014.57%204.01002%2014.56%204.00002L12.58%201.53002C12.32%201.21002%2011.85%201.15002%2011.53%201.41002C11.21%201.67002%2011.16%202.14002%2011.41%202.46002L12.23%203.48002C12.15%203.48002%2012.07%203.47002%2011.99%203.47002C6.67998%203.47002%202.34998%207.79002%202.34998%2013.11C2.34998%2018.43%206.66997%2022.75%2011.99%2022.75C17.31%2022.75%2021.63%2018.43%2021.63%2013.11C21.64%2011.04%2020.96%209.05002%2019.69%207.35002Z'%20fill='white'/%3e%3c/svg%3e",chevronRight:"data:image/svg+xml,%3csvg%20width='18'%20height='18'%20viewBox='0%200%2018%2018'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6.75004%202.49761C6.89254%202.49761%207.03504%202.55011%207.14754%202.66261L12.0375%207.55261C12.8325%208.34761%2012.8325%209.65261%2012.0375%2010.4476L7.14754%2015.3376C6.93004%2015.5551%206.57004%2015.5551%206.35254%2015.3376C6.13504%2015.1201%206.13504%2014.7601%206.35254%2014.5426L11.2425%209.65261C11.6025%209.29261%2011.6025%208.70761%2011.2425%208.34761L6.35254%203.45761C6.13504%203.24011%206.13504%202.88011%206.35254%202.66261C6.46504%202.55761%206.60754%202.49761%206.75004%202.49761Z'%20fill='white'/%3e%3c/svg%3e",pictureInPicture:"data:image/svg+xml,%3csvg%20width='18'%20height='18'%20viewBox='0%200%2018%2018'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M9.13013%207.72396C8.49563%207.72396%207.93338%207.95288%207.53288%208.38254C7.13682%208.80737%206.9443%209.37888%206.9443%209.98921V11.773C6.9443%2012.3826%207.1354%2012.9545%207.53121%2013.3799C7.9318%2013.8104%208.49446%2014.039%209.13013%2014.039H11.8836C12.5192%2014.039%2013.082%2013.8104%2013.4827%2013.38C13.8788%2012.9547%2014.0702%2012.3829%2014.0702%2011.773V9.98921C14.0702%209.37954%2013.8787%208.80796%2013.4827%208.38271C13.082%207.95254%2012.5192%207.72396%2011.8836%207.72396H9.13013ZM8.1943%209.98921C8.1943%209.63863%208.30255%209.39004%208.44721%209.23496C8.58721%209.08471%208.80538%208.97396%209.13013%208.97396H11.8836C12.2105%208.97396%2012.4285%209.08496%2012.568%209.23471C12.7122%209.38954%2012.8202%209.63804%2012.8202%209.98921V11.773C12.8202%2012.1247%2012.7121%2012.3734%2012.568%2012.5282C12.4285%2012.678%2012.2105%2012.789%2011.8836%2012.789H9.13013C8.80338%2012.789%208.58563%2012.678%208.44638%2012.5284C8.30238%2012.3736%208.1943%2012.1249%208.1943%2011.773V9.98921Z'%20fill='white'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M5.55509%200.875C4.17553%200.875%203.00718%201.36764%202.18678%202.24781C1.37092%203.12309%200.944946%204.33172%200.944946%205.68865V12.3113C0.944946%2013.6675%201.36863%2014.8763%202.18376%2015.7519C3.0036%2016.6326%204.17229%2017.125%205.55509%2017.125H12.5832C13.9663%2017.125%2015.1354%2016.6327%2015.9555%2015.752C16.771%2014.8763%2017.195%2013.6676%2017.195%2012.3113V5.68865C17.195%204.33241%2016.771%203.12367%2015.9556%202.24804C15.1356%201.36737%2013.9668%200.875%2012.584%200.875H5.55509ZM2.19495%205.68865C2.19495%204.59126%202.53681%203.70555%203.10116%203.1001C3.66096%202.49952%204.48518%202.125%205.55509%202.125H12.584C13.658%202.125%2014.4821%202.49979%2015.0409%203.09987C15.6043%203.70497%2015.945%204.59057%2015.945%205.68865V12.3113C15.945%2013.4094%2015.6043%2014.295%2015.0408%2014.9001C14.482%2015.5002%2013.6576%2015.875%2012.5832%2015.875H5.55509C4.48113%2015.875%203.65725%2015.5002%203.0987%2014.9002C2.53545%2014.2951%202.19495%2013.4095%202.19495%2012.3113V5.68865Z'%20fill='white'/%3e%3c/svg%3e",lock:"data:image/svg+xml,%3csvg%20width='14'%20height='16'%20viewBox='0%200%2014%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6.99975%2012.4695C6.62095%2012.4687%206.25087%2012.3556%205.93631%2012.1445C5.62167%2011.9335%205.37671%2011.634%205.23231%2011.2837C5.08797%2010.9335%205.05065%2010.5484%205.12509%2010.1769C5.19954%209.80548%205.38239%209.46444%205.65063%209.19692C5.91879%208.9294%206.26031%208.7474%206.63191%208.67388C7.00351%208.60036%207.38855%208.63868%207.73839%208.78388C8.08831%208.92916%208.38719%209.17492%208.59751%209.48996C8.80775%209.80508%208.91991%2010.1755%208.91975%2010.5543C8.91847%2011.0627%208.71559%2011.5498%208.35567%2011.9088C7.99575%2012.2678%207.50815%2012.4695%206.99975%2012.4695ZM6.99975%209.83828C6.85847%209.83908%206.72063%209.88164%206.60343%209.9606C6.48631%2010.0396%206.39519%2010.1514%206.34151%2010.2821C6.28775%2010.4128%206.27391%2010.5564%206.30167%2010.6949C6.32943%2010.8334%206.39759%2010.9607%206.49743%2011.0605C6.59735%2011.1604%206.72455%2011.2285%206.86311%2011.2563C7.00159%2011.284%207.14519%2011.2702%207.27591%2011.2165C7.40655%2011.1628%207.51839%2011.0716%207.59735%2010.9545C7.67639%2010.8374%207.71895%2010.6996%207.71975%2010.5583C7.71975%2010.3673%207.64383%2010.1842%207.50887%2010.0492C7.37383%209.91412%207.19071%209.83828%206.99975%209.83828Z'%20fill='white'/%3e%3cpath%20d='M10.56%206.56697C10.4009%206.56697%2010.2483%206.50377%2010.1358%206.39125C10.0232%206.27873%209.96004%206.12612%209.96004%205.96698V4.28699C9.94804%203.50988%209.63092%202.76865%209.07708%202.22337C8.52332%201.67808%207.77724%201.37249%207.00004%201.37258H6.96244C6.19148%201.3786%205.45372%201.6867%204.90742%202.23073C4.36116%202.77474%204.05001%203.51129%204.04082%204.28218V5.96218C4.04082%206.12131%203.97761%206.27393%203.86509%206.38645C3.75256%206.49897%203.59995%206.56217%203.44082%206.56217C3.28169%206.56217%203.12908%206.49897%203.01656%206.38645C2.90403%206.27393%202.84082%206.12131%202.84082%205.96218V4.27418C2.85189%203.18905%203.28844%202.15162%204.05652%201.38503C4.8246%200.618446%205.86292%200.183934%206.94804%200.174982C8.04956%200.169374%209.10988%200.59323%209.90404%201.35658C10.2962%201.73705%2010.609%202.19153%2010.8244%202.69371C11.0396%203.19589%2011.1532%203.73581%2011.1584%204.28218V5.96698C11.1584%206.12584%2011.0954%206.27821%2010.9832%206.39069C10.8711%206.50313%2010.7189%206.56657%2010.56%206.56697Z'%20fill='white'/%3e%3cpath%20d='M9.1601%2015.7892H4.84009C3.9404%2015.8864%203.03035%2015.7856%202.17371%2015.494C1.55896%2015.1986%201.06319%2014.7025%200.768099%2014.0876C0.475555%2013.2312%200.374515%2012.3209%200.472099%2011.4212V9.71636C0.374659%208.81636%200.475691%207.90596%200.768099%207.04916C1.06391%206.435%201.55951%205.93942%202.17371%205.6436C3.03034%205.35189%203.9404%205.25113%204.84009%205.3484H9.1601C10.0598%205.25113%2010.9699%205.35189%2011.8265%205.6436C12.4407%205.93942%2012.9363%206.435%2013.2321%207.04916C13.5245%207.90596%2013.6255%208.81636%2013.5281%209.71636V11.4212C13.6256%2012.3212%2013.5246%2013.2316%2013.2321%2014.0884C12.9369%2014.7028%2012.4415%2015.1984%2011.8273%2015.494C10.9703%2015.7856%2010.0601%2015.8864%209.1601%2015.7892ZM4.84009%206.54836C4.11926%206.47548%203.39116%206.53564%202.6921%206.72596C2.32372%206.90356%202.02647%207.20084%201.84891%207.56916C1.65927%208.26812%201.59935%208.99588%201.6721%209.71636V11.4212C1.59943%2012.142%201.65936%2012.87%201.84891%2013.5692C2.02679%2013.9376%202.32431%2014.2348%202.6929%2014.4124C3.39183%2014.602%204.11957%2014.6619%204.84009%2014.5892H9.1601C9.8809%2014.6618%2010.6089%2014.6019%2011.3081%2014.4124C11.6763%2014.2346%2011.9735%2013.9374%2012.1513%2013.5692C12.3408%2012.87%2012.4007%2012.142%2012.3281%2011.4212V9.71636C12.4008%208.99588%2012.3409%208.26812%2012.1513%207.56916C11.9737%207.20084%2011.6765%206.90356%2011.3081%206.72596C10.6091%206.53564%209.88098%206.47548%209.1601%206.54836H4.84009Z'%20fill='white'/%3e%3c/svg%3e",unlock:"data:image/svg+xml,%3csvg%20width='14'%20height='16'%20viewBox='0%200%2014%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9.1601%2015.8053H4.84006C3.94037%2015.9025%203.03032%2015.8017%202.17368%2015.5101C1.55957%2015.2137%201.06405%2014.7179%200.768064%2014.1037C0.475576%2013.2472%200.374536%2012.337%200.472072%2011.4373V9.73166C0.374624%208.83166%200.475664%207.92118%200.768064%207.06446C1.06431%206.44918%201.56076%205.95269%202.17607%205.65645C3.03282%205.36405%203.94325%205.26301%204.84326%205.36045H9.1601C10.0599%205.26293%2010.97%205.36397%2011.8265%205.65645C12.4409%205.95237%2012.9365%206.4483%2013.2321%207.06286C13.5247%207.91902%2013.6257%208.82894%2013.5281%209.72846V11.4341C13.6255%2012.3341%2013.5245%2013.2445%2013.2321%2014.1013C12.9363%2014.7153%2012.4411%2015.2108%2011.8273%2015.5069C10.9706%2015.7995%2010.0603%2015.9013%209.1601%2015.8053ZM4.84006%206.56366C4.11945%206.49038%203.39151%206.55086%202.69287%206.74206C2.32455%206.91934%202.0273%207.2163%201.84968%207.58446C1.65937%208.28326%201.59916%209.0111%201.67207%209.73166V11.4373C1.59905%2012.1578%201.65926%2012.8857%201.84968%2013.5845C2.02747%2013.9529%202.32462%2014.2503%202.69287%2014.4285C3.3918%2014.618%204.11954%2014.6779%204.84006%2014.6053H9.1601C9.88089%2014.6782%2010.609%2014.618%2011.3081%2014.4277C11.6763%2014.2502%2011.9735%2013.9533%2012.1513%2013.5853C12.3407%2012.8861%2012.4007%2012.1581%2012.3281%2011.4373V9.73166C12.4009%209.01142%2012.341%208.2839%2012.1513%207.58526C11.9739%207.2167%2011.6766%206.91942%2011.3081%206.74206C10.6091%206.55086%209.88097%206.49038%209.1601%206.56366H4.84006Z'%20fill='white'/%3e%3cpath%20d='M6.99975%2012.4985C6.62159%2012.4985%206.25191%2012.3863%205.93751%2012.1763C5.62303%2011.9661%205.37799%2011.6675%205.23327%2011.3182C5.08856%2010.9687%205.05069%2010.5843%205.12447%2010.2135C5.19823%209.84258%205.38039%209.50186%205.64775%209.2345C5.91519%208.96706%206.25583%208.78498%206.62671%208.71122C6.99759%208.63746%207.38207%208.6753%207.73143%208.82002C8.08079%208.96474%208.37943%209.20978%208.58951%209.52418C8.79959%209.83866%208.91175%2010.2083%208.91175%2010.5865C8.91111%2011.0934%208.70943%2011.5793%208.35103%2011.9378C7.99263%2012.2962%207.50663%2012.4979%206.99975%2012.4985ZM6.99975%209.8745C6.85895%209.8745%206.72127%209.91618%206.60415%209.99442C6.48711%2010.0727%206.39583%2010.1839%206.34191%2010.314C6.28807%2010.4441%206.27391%2010.5872%206.30143%2010.7254C6.32887%2010.8635%206.39671%2010.9903%206.49623%2011.0899C6.59583%2011.1895%206.72271%2011.2573%206.86079%2011.2847C6.99895%2011.3123%207.14207%2011.2982%207.27223%2011.2443C7.40231%2011.1903%207.51351%2011.0991%207.59175%2010.982C7.66999%2010.8649%207.71175%2010.7273%207.71175%2010.5865C7.71151%2010.3977%207.63647%2010.2167%207.50295%2010.0832C7.36951%209.94978%207.18847%209.87466%206.99975%209.8745Z'%20fill='white'/%3e%3cpath%20d='M3.45181%206.56472C3.29268%206.56472%203.14006%206.50152%203.02754%206.38896C2.91502%206.27644%202.85181%206.12383%202.85181%205.96469V4.2767C2.85965%203.29932%203.21213%202.35606%203.84714%201.61303C4.48216%200.870007%205.35897%200.374879%206.32321%200.214847C7.28745%200.0548071%208.27721%200.240135%209.11817%200.738183C9.95913%201.23623%2010.5974%202.01506%2010.9206%202.9375C10.9492%203.0125%2010.9624%203.09246%2010.9595%203.17267C10.9566%203.25288%2010.9377%203.3317%2010.9038%203.40445C10.8699%203.47721%2010.8218%203.54242%2010.7622%203.59624C10.7027%203.65006%2010.633%203.69139%2010.5572%203.71778C10.4814%203.74417%2010.4011%203.75509%2010.321%203.74988C10.241%203.74467%2010.1626%203.72345%2010.091%203.68747C10.0192%203.65149%209.95544%203.60148%209.90336%203.54041C9.85128%203.47933%209.81201%203.40843%209.78784%203.33189C9.55912%202.67479%209.10569%202.1196%208.50745%201.76434C7.90929%201.40908%207.20473%201.27659%206.51833%201.39028C5.83193%201.50396%205.20777%201.8565%204.75601%202.38565C4.30426%202.91481%204.05401%203.58655%204.04941%204.28229V5.96629C4.049%206.12473%203.98591%206.27657%203.87395%206.38869C3.762%206.5008%203.61025%206.56408%203.45181%206.56472Z'%20fill='white'/%3e%3c/svg%3e",arrowLeft:"data:image/svg+xml,%3csvg%20width='23'%20height='24'%20viewBox='0%200%2023%2024'%20fill='white'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M20.0182%2023.9979C21.4008%2023.9432%2022.6699%2022.815%2022.6699%2021.295L22.6699%202.70464C22.6699%200.677986%2020.4125%20-0.651722%2018.6399%200.330475L1.86725%209.62567C0.0436726%2010.6363%200.0436726%2013.3634%201.86725%2014.374L18.6399%2023.6692C19.0831%2023.9147%2019.5573%2024.0162%2020.0182%2023.9979Z'%20fill='white'/%3e%3c/svg%3e",speed:"data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8.1543%202.49976C8.1543%202.15458%208.43405%201.87476%208.7793%201.87476H12.285C12.6301%201.87476%2012.91%202.15458%2012.91%202.49976C12.91%202.84493%2012.6301%203.12476%2012.285%203.12476H8.7793C8.43405%203.12476%208.1543%202.84493%208.1543%202.49976Z'%20fill='black'%20fill-opacity='0.5'/%3e%3cpath%20d='M3.52295%2011.1133C3.52295%207.24291%206.66036%204.10457%2010.5317%204.10457C14.4022%204.10457%2017.5395%207.24296%2017.5395%2011.1133C17.5395%2014.9833%2014.4025%2018.1234%2010.5319%2018.1236L7.2249%2018.1253C6.87972%2018.1254%206.59977%2017.8457%206.5996%2017.5005C6.59942%2017.1553%206.87911%2016.8754%207.22429%2016.8753L10.5313%2016.8736C13.7111%2016.8736%2016.2895%2014.2937%2016.2895%2011.1133C16.2895%207.93311%2013.7116%205.35457%2010.5317%205.35457C7.35082%205.35457%204.77295%207.93316%204.77295%2011.1133C4.77295%2011.4584%204.49312%2011.7383%204.14795%2011.7383C3.80277%2011.7383%203.52295%2011.4584%203.52295%2011.1133Z'%20fill='black'%20fill-opacity='0.5'/%3e%3cpath%20d='M4.52962%2015.3888C4.52962%2015.0436%204.80944%2014.7638%205.15462%2014.7638H8.73116C9.07633%2014.7638%209.35616%2015.0436%209.35616%2015.3888C9.35616%2015.7339%209.07633%2016.0138%208.73116%2016.0138H5.15462C4.80944%2016.0138%204.52962%2015.7339%204.52962%2015.3888Z'%20fill='black'%20fill-opacity='0.5'/%3e%3cpath%20d='M3.08594%2012.6528C2.74076%2012.6528%202.46094%2012.9326%202.46094%2013.2778C2.46094%2013.6229%202.74076%2013.9028%203.08594%2013.9028H6.66247C7.00765%2013.9028%207.28747%2013.6229%207.28747%2013.2778C7.28747%2012.9326%207.00765%2012.6528%206.66247%2012.6528H3.08594Z'%20fill='black'%20fill-opacity='0.5'/%3e%3cpath%20d='M13.415%209.08101C13.6591%208.83693%2013.6591%208.44126%2013.415%208.19714C13.1709%207.95306%2012.7752%207.95306%2012.5311%208.19714L10.0805%2010.6477C9.83644%2010.8918%209.83644%2011.2875%2010.0805%2011.5316C10.3246%2011.7757%2010.7204%2011.7757%2010.9644%2011.5316L13.415%209.08101Z'%20fill='black'%20fill-opacity='0.5'/%3e%3c/svg%3e",speed1:"data:image/svg+xml,%3csvg%20width='18'%20height='15'%20viewBox='0%200%2018%2015'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M10.5488%201.53559C8.20532%201.02852%205.66339%201.68608%203.84359%203.50588C1.15649%206.19298%201.00481%2010.4572%203.39041%2013.3215C3.55135%2013.5148%203.8176%2013.6347%204.13036%2013.6347H13.8687C14.1816%2013.6347%2014.4476%2013.5149%2014.6085%2013.3217C16.0815%2011.5533%2016.5884%209.25027%2016.1258%207.11249C16.0528%206.77512%2016.2671%206.44245%2016.6045%206.36945C16.9418%206.29645%2017.2745%206.51077%2017.3475%206.84814C17.8886%209.34866%2017.2968%2012.0474%2015.569%2014.1217C15.1326%2014.6455%2014.489%2014.8847%2013.8687%2014.8847H4.13036C3.50995%2014.8847%202.86616%2014.6453%202.42991%2014.1215C-0.36559%2010.765%20-0.188583%205.77029%202.95971%202.622C5.09241%200.489299%208.07189%20-0.279272%2010.8132%200.31386C11.1505%200.386857%2011.3648%200.719527%2011.2918%201.0569C11.2188%201.39427%2010.8862%201.60859%2010.5488%201.53559Z'%20fill='white'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M14.9976%202.66523C15.2417%202.9093%2015.2417%203.30503%2014.9976%203.54911L10.7129%207.83399C10.8469%208.09798%2010.9225%208.39667%2010.9225%208.713C10.9225%209.78688%2010.0519%2010.6574%208.97805%2010.6574C7.90417%2010.6574%207.03362%209.78688%207.03362%208.713C7.03362%207.63912%207.90417%206.76856%208.97805%206.76856C9.27953%206.76856%209.56498%206.83718%209.81965%206.95963C9.82222%206.95697%209.82483%206.95432%209.82746%206.95168L14.1137%202.66525C14.3578%202.42116%2014.7535%202.42115%2014.9976%202.66523ZM9.67249%208.713C9.67249%209.09652%209.36158%209.40743%208.97805%209.40743C8.59453%209.40743%208.28362%209.09652%208.28362%208.713C8.28362%208.32947%208.59453%208.01856%208.97805%208.01856C9.36158%208.01856%209.67249%208.32947%209.67249%208.713Z'%20fill='white'/%3e%3c/svg%3e",tick:"data:image/svg+xml,%3csvg%20width='15'%20height='11'%20viewBox='0%200%2015%2011'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5.36893%2010.7566C5.06878%2010.7566%204.78364%2010.6366%204.57354%2010.4265L0.326413%206.17934C-0.108804%205.74412%20-0.108804%205.02376%200.326413%204.58854C0.761631%204.15333%201.48199%204.15333%201.91721%204.58854L5.36893%208.04027L13.0828%200.326413C13.518%20-0.108804%2014.2384%20-0.108804%2014.6736%200.326413C15.1088%200.761631%2015.1088%201.48199%2014.6736%201.91721L6.16433%2010.4265C5.95423%2010.6366%205.66908%2010.7566%205.36893%2010.7566Z'%20fill='white'/%3e%3c/svg%3e",qualitySetting:"data:image/svg+xml,%3csvg%20width='18'%20height='18'%20viewBox='0%200%2018%2018'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M2.11683%202.24781C2.93723%201.36764%204.10557%200.875%205.48513%200.875H12.5141C13.8968%200.875%2015.0657%201.36737%2015.8857%202.24804C16.7011%203.12367%2017.125%204.33241%2017.125%205.68865V12.3113C17.125%2013.6676%2016.7011%2014.8763%2015.8856%2015.752C15.0654%2016.6327%2013.8964%2017.125%2012.5133%2017.125H5.48513C4.10233%2017.125%202.93365%2016.6326%202.11381%2015.7519C1.29868%2014.8763%200.875%2013.6675%200.875%2012.3113V5.68865C0.875%204.33172%201.30098%203.12309%202.11683%202.24781ZM3.03121%203.1001C2.46687%203.70556%202.125%204.59126%202.125%205.68865V12.3113C2.125%2013.4095%202.46551%2014.2951%203.02876%2014.9002C3.58729%2015.5002%204.41117%2015.875%205.48513%2015.875H12.5133C13.5877%2015.875%2014.412%2015.5002%2014.9708%2014.9001C15.5343%2014.295%2015.875%2013.4094%2015.875%2012.3113V5.68865C15.875%204.59057%2015.5343%203.70497%2014.9709%203.09987C14.4122%202.49979%2013.588%202.125%2012.5141%202.125H5.48513C4.41523%202.125%203.59101%202.49952%203.03121%203.1001ZM7.45442%204.75486C7.79958%204.75486%208.07942%205.03467%208.07942%205.37986V6.42142C8.0795%206.42605%208.07958%206.43068%208.07958%206.43533C8.07958%206.43998%208.0795%206.44462%208.07942%206.44925V7.49042C8.07942%207.83558%207.79958%208.11542%207.45442%208.11542C7.10925%208.11542%206.82942%207.83558%206.82942%207.49042V7.06033H5.52238C5.1772%207.06033%204.89738%206.78052%204.89738%206.43533C4.89738%206.09016%205.1772%205.81033%205.52238%205.81033H6.82942V5.37986C6.82942%205.03467%207.10925%204.75486%207.45442%204.75486ZM8.87858%206.43533C8.87858%206.09016%209.15842%205.81033%209.50358%205.81033H12.476C12.8212%205.81033%2013.101%206.09016%2013.101%206.43533C13.101%206.78052%2012.8212%207.06033%2012.476%207.06033H9.50358C9.15842%207.06033%208.87858%206.78052%208.87858%206.43533ZM9.88683%209.88417C10.232%209.88417%2010.5118%2010.164%2010.5118%2010.5092V11.55C10.5119%2011.5546%2010.512%2011.5592%2010.512%2011.5638C10.512%2011.5685%2010.5119%2011.5732%2010.5118%2011.5777V12.6198C10.5118%2012.9649%2010.232%2013.2448%209.88683%2013.2448C9.54167%2013.2448%209.26183%2012.9649%209.26183%2012.6198V12.1888H5.52238C5.1772%2012.1888%204.89738%2011.9091%204.89738%2011.5638C4.89738%2011.2187%205.1772%2010.9388%205.52238%2010.9388H9.26183V10.5092C9.26183%2010.164%209.54167%209.88417%209.88683%209.88417ZM11.3102%2011.5638C11.3102%2011.2187%2011.5901%2010.9388%2011.9353%2010.9388H12.4752C12.8204%2010.9388%2013.1002%2011.2187%2013.1002%2011.5638C13.1002%2011.9091%2012.8204%2012.1888%2012.4752%2012.1888H11.9353C11.5901%2012.1888%2011.3102%2011.9091%2011.3102%2011.5638Z'%20fill='black'%20fill-opacity='0.5'/%3e%3c/svg%3e",qualitySetting1:"data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M3.11683%203.24781C3.93723%202.36764%205.10557%201.875%206.48513%201.875H13.5141C14.8968%201.875%2016.0657%202.36737%2016.8857%203.24804C17.7011%204.12367%2018.125%205.33241%2018.125%206.68865V13.3113C18.125%2014.6676%2017.7011%2015.8763%2016.8856%2016.752C16.0654%2017.6327%2014.8964%2018.125%2013.5133%2018.125H6.48513C5.10233%2018.125%203.93365%2017.6326%203.11381%2016.7519C2.29868%2015.8763%201.875%2014.6675%201.875%2013.3113V6.68865C1.875%205.33172%202.30098%204.12309%203.11683%203.24781ZM4.03121%204.1001C3.46687%204.70556%203.125%205.59126%203.125%206.68865V13.3113C3.125%2014.4095%203.46551%2015.2951%204.02876%2015.9002C4.58729%2016.5002%205.41117%2016.875%206.48513%2016.875H13.5133C14.5877%2016.875%2015.412%2016.5002%2015.9708%2015.9001C16.5343%2015.295%2016.875%2014.4094%2016.875%2013.3113V6.68865C16.875%205.59057%2016.5343%204.70497%2015.9709%204.09987C15.4122%203.49979%2014.588%203.125%2013.5141%203.125H6.48513C5.41523%203.125%204.59101%203.49952%204.03121%204.1001ZM8.45442%205.75486C8.79958%205.75486%209.07942%206.03467%209.07942%206.37986V7.42142C9.0795%207.42605%209.07958%207.43068%209.07958%207.43533C9.07958%207.43998%209.0795%207.44462%209.07942%207.44925V8.49042C9.07942%208.83558%208.79958%209.11542%208.45442%209.11542C8.10925%209.11542%207.82942%208.83558%207.82942%208.49042V8.06033H6.52238C6.1772%208.06033%205.89738%207.78052%205.89738%207.43533C5.89738%207.09016%206.1772%206.81033%206.52238%206.81033H7.82942V6.37986C7.82942%206.03467%208.10925%205.75486%208.45442%205.75486ZM9.87858%207.43533C9.87858%207.09016%2010.1584%206.81033%2010.5036%206.81033H13.476C13.8212%206.81033%2014.101%207.09016%2014.101%207.43533C14.101%207.78052%2013.8212%208.06033%2013.476%208.06033H10.5036C10.1584%208.06033%209.87858%207.78052%209.87858%207.43533ZM10.8868%2010.8842C11.232%2010.8842%2011.5118%2011.164%2011.5118%2011.5092V12.55C11.5119%2012.5546%2011.512%2012.5592%2011.512%2012.5638C11.512%2012.5685%2011.5119%2012.5732%2011.5118%2012.5777V13.6198C11.5118%2013.9649%2011.232%2014.2448%2010.8868%2014.2448C10.5417%2014.2448%2010.2618%2013.9649%2010.2618%2013.6198V13.1888H6.52238C6.1772%2013.1888%205.89738%2012.9091%205.89738%2012.5638C5.89738%2012.2187%206.1772%2011.9388%206.52238%2011.9388H10.2618V11.5092C10.2618%2011.164%2010.5417%2010.8842%2010.8868%2010.8842ZM12.3102%2012.5638C12.3102%2012.2187%2012.5901%2011.9388%2012.9353%2011.9388H13.4752C13.8204%2011.9388%2014.1002%2012.2187%2014.1002%2012.5638C14.1002%2012.9091%2013.8204%2013.1888%2013.4752%2013.1888H12.9353C12.5901%2013.1888%2012.3102%2012.9091%2012.3102%2012.5638Z'%20fill='white'/%3e%3c/svg%3e",notFound:"data:image/svg+xml,%3csvg%20width='123'%20height='72'%20viewBox='0%200%20123%2072'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20opacity='0.5'%3e%3cg%20opacity='0.3'%20filter='url(%23filter0_f_113_8034)'%3e%3cellipse%20cx='59.429'%20cy='67.3152'%20rx='56.5'%20ry='2.5'%20fill='url(%23paint0_linear_113_8034)'/%3e%3c/g%3e%3cpath%20d='M31.1913%205.75171H89.5312C95.4885%205.75171%20100.323%2010.5866%20100.323%2016.5438V56.0536C100.323%2062.0109%2095.4885%2066.8457%2089.5312%2066.8457H31.1913C25.234%2066.8457%2020.3992%2062.0109%2020.3992%2056.0536V16.5438C20.3992%2010.5866%2025.234%205.75171%2031.1913%205.75171Z'%20fill='%23E3E3E3'/%3e%3cpath%20d='M113.586%2042.8287L119.243%2048.4856'%20stroke='%23C0BCBC'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M119.243%2042.8286L113.586%2048.4855'%20stroke='%23C0BCBC'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M4.75732%2019.8287L10.4142%2025.4856'%20stroke='%23C0BCBC'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M10.4142%2019.8286L4.75732%2025.4855'%20stroke='%23C0BCBC'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M100.327%2022.8965V16.5438C100.327%2010.5832%2095.4952%205.75171%2089.5345%205.75171H31.1913C25.2307%205.75171%2020.3992%2010.5866%2020.3992%2016.5438V22.8965H100.327Z'%20fill='%23AAAAAA'/%3e%3cpath%20d='M32.7025%2014.3256C32.7025%2015.8434%2031.4695%2017.0764%2029.9517%2017.0764C28.4339%2017.0764%2027.1975%2015.8434%2027.1975%2014.3256C27.1975%2012.8078%2028.4305%2011.5748%2029.9517%2011.5748C31.4728%2011.5748%2032.7025%2012.8078%2032.7025%2014.3256Z'%20fill='%23DADADA'/%3e%3cpath%20d='M40.2545%2014.3255C40.2545%2015.8433%2039.0215%2017.0763%2037.5037%2017.0763C35.9859%2017.0763%2034.7495%2015.8433%2034.7495%2014.3255C34.7495%2012.8077%2035.9792%2011.5747%2037.5037%2011.5747C39.0282%2011.5747%2040.2545%2012.8077%2040.2545%2014.3255Z'%20fill='%23DADADA'/%3e%3cpath%20d='M47.8069%2014.3255C47.8069%2015.8433%2046.5739%2017.0763%2045.0594%2017.0763C43.5449%2017.0763%2042.3086%2015.8433%2042.3086%2014.3255C42.3086%2012.8077%2043.5416%2011.5747%2045.0594%2011.5747C46.5772%2011.5747%2047.8069%2012.8077%2047.8069%2014.3255Z'%20fill='%23DADADA'/%3e%3cpath%20d='M92.7577%2014.3257C92.7577%2016.0479%2091.3639%2017.4417%2089.6417%2017.4417H57.9622C56.2434%2017.4417%2054.8462%2016.0446%2054.8462%2014.3257C54.8462%2012.6035%2056.2434%2011.2097%2057.9622%2011.2097H89.6417C91.3639%2011.2097%2092.7577%2012.6035%2092.7577%2014.3257Z'%20fill='white'/%3e%3cpath%20d='M50.0952%2051.0009V35.528C50.0952%2031.7318%2052.7857%2030.1805%2056.076%2032.0736L57.5234%2032.9112C60.8069%2034.8076%2066.1913%2037.9169%2069.4748%2039.8133L70.9256%2040.651C74.2159%2042.5508%2074.2159%2045.6534%2070.9256%2047.5531L69.4748%2048.3874C66.1913%2050.2872%2060.8103%2053.3932%2057.5234%2055.2896L56.076%2056.1238C52.7857%2058.0203%2050.0952%2056.469%2050.0952%2052.6728V51.0009Z'%20fill='%23AAAAAA'/%3e%3c/g%3e%3ccircle%20cx='96.6863'%20cy='13.6848'%20r='12.5'%20fill='%23DC1964'%20stroke='%23C80250'%20stroke-width='2'/%3e%3cpath%20d='M100.98%206.29301C101.37%205.90249%20102.004%205.90249%20102.394%206.29302L104.121%208.01955C104.511%208.41008%20104.511%209.04324%20104.121%209.43376L92.62%2020.9345C92.2294%2021.325%2091.5963%2021.325%2091.2058%2020.9345L89.4792%2019.2079C89.0887%2018.8174%2089.0887%2018.1842%2089.4792%2017.7937L100.98%206.29301Z'%20fill='white'/%3e%3cpath%20d='M92.6199%206.29301C92.2294%205.90249%2091.5962%205.90249%2091.2057%206.29302L89.4792%208.01955C89.0886%208.41008%2089.0886%209.04324%2089.4792%209.43376L100.98%2020.9345C101.37%2021.325%20102.004%2021.325%20102.394%2020.9345L104.121%2019.2079C104.511%2018.8174%20104.511%2018.1842%20104.121%2017.7937L92.6199%206.29301Z'%20fill='white'/%3e%3cdefs%3e%3cfilter%20id='filter0_f_113_8034'%20x='0.928955'%20y='62.8152'%20width='117'%20height='9'%20filterUnits='userSpaceOnUse'%20color-interpolation-filters='sRGB'%3e%3cfeFlood%20flood-opacity='0'%20result='BackgroundImageFix'/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='BackgroundImageFix'%20result='shape'/%3e%3cfeGaussianBlur%20stdDeviation='1'%20result='effect1_foregroundBlur_113_8034'/%3e%3c/filter%3e%3clinearGradient%20id='paint0_linear_113_8034'%20x1='2.92896'%20y1='67.3152'%20x2='115.929'%20y2='67.3152'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-opacity='0'/%3e%3cstop%20offset='0.342341'/%3e%3cstop%20offset='0.694197'/%3e%3cstop%20offset='1'%20stop-opacity='0'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",closeSquare:"data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6.11357%2010.3867C5.9869%2010.3867%205.86023%2010.34%205.76023%2010.24C5.5669%2010.0467%205.5669%209.72666%205.76023%209.53332L9.53357%205.75999C9.7269%205.56666%2010.0469%205.56666%2010.2402%205.75999C10.4336%205.95332%2010.4336%206.27332%2010.2402%206.46666L6.4669%2010.24C6.37357%2010.34%206.24023%2010.3867%206.11357%2010.3867Z'%20fill='white'/%3e%3cpath%20d='M9.8869%2010.3867C9.76023%2010.3867%209.63357%2010.34%209.53357%2010.24L5.76023%206.46666C5.5669%206.27332%205.5669%205.95332%205.76023%205.75999C5.95357%205.56666%206.27357%205.56666%206.4669%205.75999L10.2402%209.53332C10.4336%209.72666%2010.4336%2010.0467%2010.2402%2010.24C10.1402%2010.34%2010.0136%2010.3867%209.8869%2010.3867Z'%20fill='white'/%3e%3cpath%20d='M10.0002%2015.1666H6.00016C2.38016%2015.1666%200.833496%2013.62%200.833496%209.99998V5.99998C0.833496%202.37998%202.38016%200.833313%206.00016%200.833313H10.0002C13.6202%200.833313%2015.1668%202.37998%2015.1668%205.99998V9.99998C15.1668%2013.62%2013.6202%2015.1666%2010.0002%2015.1666ZM6.00016%201.83331C2.92683%201.83331%201.8335%202.92665%201.8335%205.99998V9.99998C1.8335%2013.0733%202.92683%2014.1666%206.00016%2014.1666H10.0002C13.0735%2014.1666%2014.1668%2013.0733%2014.1668%209.99998V5.99998C14.1668%202.92665%2013.0735%201.83331%2010.0002%201.83331H6.00016Z'%20fill='white'/%3e%3c/svg%3e",sun:"data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9.99935%2015.8327C13.221%2015.8327%2015.8327%2013.221%2015.8327%209.99935C15.8327%206.77769%2013.221%204.16602%209.99935%204.16602C6.77769%204.16602%204.16602%206.77769%204.16602%209.99935C4.16602%2013.221%206.77769%2015.8327%209.99935%2015.8327Z'%20fill='%23FAD832'/%3e%3cpath%20d='M10.0007%2019.134C9.54232%2019.134%209.16732%2018.7923%209.16732%2018.334V18.2673C9.16732%2017.809%209.54232%2017.434%2010.0007%2017.434C10.459%2017.434%2010.834%2017.809%2010.834%2018.2673C10.834%2018.7257%2010.459%2019.134%2010.0007%2019.134ZM15.9507%2016.784C15.734%2016.784%2015.5257%2016.7007%2015.359%2016.5423L15.2507%2016.434C14.9256%2016.109%2014.9256%2015.584%2015.2507%2015.259C15.5757%2014.934%2016.1006%2014.934%2016.4256%2015.259L16.534%2015.3673C16.859%2015.6923%2016.859%2016.2173%2016.534%2016.5423C16.3757%2016.7007%2016.1673%2016.784%2015.9507%2016.784ZM4.05065%2016.784C3.83398%2016.784%203.62565%2016.7007%203.45898%2016.5423C3.13398%2016.2173%203.13398%2015.6923%203.45898%2015.3673L3.56732%2015.259C3.89232%2014.934%204.41732%2014.934%204.74232%2015.259C5.06732%2015.584%205.06732%2016.109%204.74232%2016.434L4.63398%2016.5423C4.47565%2016.7007%204.25898%2016.784%204.05065%2016.784ZM18.334%2010.834H18.2673C17.809%2010.834%2017.434%2010.459%2017.434%2010.0007C17.434%209.54232%2017.809%209.16732%2018.2673%209.16732C18.7257%209.16732%2019.134%209.54232%2019.134%2010.0007C19.134%2010.459%2018.7923%2010.834%2018.334%2010.834ZM1.73398%2010.834H1.66732C1.20898%2010.834%200.833984%2010.459%200.833984%2010.0007C0.833984%209.54232%201.20898%209.16732%201.66732%209.16732C2.12565%209.16732%202.53398%209.54232%202.53398%2010.0007C2.53398%2010.459%202.19232%2010.834%201.73398%2010.834ZM15.8423%204.99232C15.6257%204.99232%2015.4173%204.90898%2015.2507%204.75065C14.9256%204.42565%2014.9256%203.90065%2015.2507%203.57565L15.359%203.46732C15.684%203.14232%2016.209%203.14232%2016.534%203.46732C16.859%203.79232%2016.859%204.31732%2016.534%204.64232L16.4256%204.75065C16.2673%204.90898%2016.059%204.99232%2015.8423%204.99232ZM4.15898%204.99232C3.94232%204.99232%203.73398%204.90898%203.56732%204.75065L3.45898%204.63398C3.13398%204.30898%203.13398%203.78398%203.45898%203.45898C3.78398%203.13398%204.30898%203.13398%204.63398%203.45898L4.74232%203.56732C5.06732%203.89232%205.06732%204.41732%204.74232%204.74232C4.58398%204.90898%204.36732%204.99232%204.15898%204.99232ZM10.0007%202.53398C9.54232%202.53398%209.16732%202.19232%209.16732%201.73398V1.66732C9.16732%201.20898%209.54232%200.833984%2010.0007%200.833984C10.459%200.833984%2010.834%201.20898%2010.834%201.66732C10.834%202.12565%2010.459%202.53398%2010.0007%202.53398Z'%20fill='%23FAD832'/%3e%3c/svg%3e",subtitleFill:"data:image/svg+xml,%3csvg%20width='18'%20height='16'%20viewBox='0%200%2018%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M1.55605%201.58869C2.4097%200.672867%203.63139%200.151733%205.09542%200.151733H12.9053C14.3732%200.151733%2015.5952%200.672683%2016.4483%201.58885C17.2983%202.50166%2017.7508%203.77289%2017.7508%205.22246V10.7792C17.7508%2012.2288%2017.2983%2013.5%2016.4482%2014.4129C15.595%2015.329%2014.3727%2015.85%2012.9044%2015.85H5.09542C3.62761%2015.85%202.40569%2015.329%201.55282%2014.4128C0.703099%2013.5%200.250824%2012.2287%200.250824%2010.7792V5.22246C0.250824%203.77242%200.705432%202.50128%201.55605%201.58869ZM14.3827%205.87049C13.2061%204.69387%2011.2978%204.69417%2010.1207%205.87028C8.94399%207.04688%208.94407%208.95529%2010.1202%2010.1325C11.2974%2011.3086%2013.2061%2011.3094%2014.3827%2010.1328C14.6267%209.88871%2014.6267%209.49296%2014.3827%209.24888C14.1386%209.00479%2013.7428%209.00479%2013.4988%209.24888C12.8107%209.93704%2011.6937%209.93738%2011.0043%209.24888C10.3158%208.55954%2010.3162%207.44279%2011.0041%206.75462C11.6935%206.06583%2012.8106%206.06614%2013.4988%206.75438C13.7428%206.99846%2014.1386%206.99846%2014.3827%206.75438C14.6267%206.51029%2014.6267%206.11457%2014.3827%205.87049ZM5.20517%206.75454C5.82661%206.12646%206.81647%206.07034%207.50899%206.59638C7.78382%206.80521%208.17591%206.75163%208.38474%206.47671C8.59349%206.20188%208.53999%205.80979%208.26507%205.60099C7.08453%204.70423%205.39123%204.79152%204.31885%205.87306C3.13605%207.04688%203.13987%208.95613%204.31896%2010.1352C5.39081%2011.207%207.08204%2011.2945%208.26199%2010.4095C8.53816%2010.2024%208.59416%209.81063%208.38699%209.53454C8.17991%209.25838%207.78816%209.20238%207.51199%209.40946C6.81814%209.92988%205.82469%209.87321%205.20284%209.25138C4.5088%208.55729%204.51188%207.44121%205.2007%206.75896L5.20517%206.75454Z'%20fill='white'/%3e%3c/svg%3e",subtitleOutline:"data:image/svg+xml,%3csvg%20width='18'%20height='17'%20viewBox='0%200%2018%2017'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14.3817%207.54529C14.1375%207.78953%2013.7416%207.78953%2013.4983%207.54529C12.8099%206.85699%2011.6925%206.85699%2011.0032%207.54529C10.3151%208.23362%2010.3151%209.35112%2011.0032%2010.0403C11.6925%2010.7286%2012.8099%2010.7278%2013.4983%2010.0403C13.7416%209.79612%2014.1375%209.79612%2014.3817%2010.0403C14.6259%2010.2836%2014.6259%2010.6795%2014.3817%2010.9236C13.205%2012.1003%2011.2966%2012.1003%2010.1199%2010.9245L10.5137%2010.5297L10.119%2010.9236C8.94345%209.74612%208.94345%207.83779%2010.119%206.66193L10.5617%207.10362L10.1199%206.66112C11.2966%205.48528%2013.205%205.48528%2014.3817%206.66193C14.6259%206.90526%2014.6259%207.30112%2014.3817%207.54529Z'%20fill='white'/%3e%3cpath%20d='M8.38602%2010.3253C8.59352%2010.6019%208.53735%2010.9936%208.26069%2011.2003C7.08067%2012.0853%205.39%2011.9978%204.31822%2010.9261C3.1382%209.7461%203.13495%207.83527%204.31985%206.66191C5.39285%205.58251%207.08433%205.49553%208.26435%206.39193C8.53902%206.60108%208.59227%206.99277%208.38394%207.26779C8.17486%207.54277%207.78335%207.5961%207.50835%207.38777C6.81578%206.86109%205.82579%206.9178%205.20404%207.54527L5.19997%207.55026C4.51068%208.23193%204.50824%209.3486%205.2016%2010.0428C5.82415%2010.6644%206.81741%2010.7211%207.51077%2010.2003C7.78744%209.9936%208.17927%2010.0494%208.38602%2010.3253Z'%20fill='white'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M5.09499%200.734375C3.57929%200.734375%202.29999%201.2752%201.40236%202.23772C0.510029%203.19521%200.041687%204.52023%200.041687%206.01356V11.5702C0.041687%2013.0627%200.507587%2014.3877%201.39911%2015.346C2.29592%2016.3085%203.57521%2016.8494%205.09499%2016.8494H12.9034C14.4232%2016.8494%2015.7033%2016.3085%2016.6001%2015.346C17.4916%2014.3877%2017.9584%2013.0627%2017.9584%2011.5702V6.01356C17.9584%204.52105%2017.4916%203.19608%2016.6001%202.23772C15.7033%201.2752%2014.424%200.734375%2012.9043%200.734375H5.09499ZM1.29169%206.01356C1.29169%204.77938%201.6758%203.77774%202.31749%203.09023C2.95347%202.40689%203.88853%201.98438%205.09499%201.98438H12.9043C14.1152%201.98438%2015.0499%202.4077%2015.685%203.08937C16.325%203.77688%2016.7084%204.77938%2016.7084%206.01356V11.5702C16.7084%2012.8044%2016.325%2013.8069%2015.685%2014.4935C15.0499%2015.176%2014.1144%2015.5994%2012.9034%2015.5994H5.09499C3.88405%2015.5994%202.949%2015.176%202.31423%2014.4944C1.67499%2013.8069%201.29169%2012.8044%201.29169%2011.5702V6.01356Z'%20fill='white'/%3e%3c/svg%3e",subtitleOutlineGray:"data:image/svg+xml,%3csvg%20width='18'%20height='17'%20viewBox='0%200%2018%2017'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14.382%207.54529C14.1378%207.78953%2013.7419%207.78953%2013.4986%207.54529C12.8102%206.85699%2011.6928%206.85699%2011.0035%207.54529C10.3154%208.23362%2010.3154%209.35112%2011.0035%2010.0403C11.6928%2010.7286%2012.8102%2010.7278%2013.4986%2010.0403C13.7419%209.79612%2014.1378%209.79612%2014.382%2010.0403C14.6262%2010.2836%2014.6262%2010.6795%2014.382%2010.9236C13.2053%2012.1003%2011.2969%2012.1003%2010.1202%2010.9245L10.514%2010.5297L10.1193%2010.9236C8.94376%209.74612%208.94376%207.83779%2010.1193%206.66193L10.562%207.10362L10.1202%206.66112C11.2969%205.48528%2013.2053%205.48528%2014.382%206.66193C14.6262%206.90526%2014.6262%207.30112%2014.382%207.54529Z'%20fill='black'%20fill-opacity='0.5'/%3e%3cpath%20d='M8.38633%2010.3253C8.59383%2010.6019%208.53766%2010.9936%208.26099%2011.2003C7.08098%2012.0853%205.3903%2011.9978%204.31853%2010.9261C3.13851%209.7461%203.13525%207.83527%204.32015%206.66191C5.39315%205.58251%207.08463%205.49553%208.26466%206.39193C8.53933%206.60108%208.59258%206.99277%208.38424%207.26779C8.17516%207.54277%207.78366%207.5961%207.50866%207.38777C6.81608%206.86109%205.82609%206.9178%205.20434%207.54527L5.20028%207.55026C4.51098%208.23193%204.50854%209.3486%205.2019%2010.0428C5.82446%2010.6644%206.81771%2010.7211%207.51108%2010.2003C7.78774%209.9936%208.17958%2010.0494%208.38633%2010.3253Z'%20fill='black'%20fill-opacity='0.5'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M5.09529%200.734375C3.57959%200.734375%202.30029%201.2752%201.40267%202.23772C0.510334%203.19521%200.0419922%204.52023%200.0419922%206.01356V11.5702C0.0419922%2013.0627%200.507892%2014.3877%201.39942%2015.346C2.29623%2016.3085%203.57552%2016.8494%205.09529%2016.8494H12.9037C14.4235%2016.8494%2015.7036%2016.3085%2016.6004%2015.346C17.4919%2014.3877%2017.9587%2013.0627%2017.9587%2011.5702V6.01356C17.9587%204.52105%2017.4919%203.19608%2016.6004%202.23772C15.7036%201.2752%2014.4243%200.734375%2012.9046%200.734375H5.09529ZM1.29199%206.01356C1.29199%204.77938%201.67611%203.77774%202.31779%203.09023C2.95378%202.40689%203.88883%201.98438%205.09529%201.98438H12.9046C14.1155%201.98438%2015.0502%202.4077%2015.6853%203.08937C16.3253%203.77688%2016.7087%204.77938%2016.7087%206.01356V11.5702C16.7087%2012.8044%2016.3253%2013.8069%2015.6853%2014.4935C15.0502%2015.176%2014.1147%2015.5994%2012.9037%2015.5994H5.09529C3.88436%2015.5994%202.9493%2015.176%202.31453%2014.4944C1.67529%2013.8069%201.29199%2012.8044%201.29199%2011.5702V6.01356Z'%20fill='black'%20fill-opacity='0.5'/%3e%3c/svg%3e",close:"data:image/svg+xml,%3csvg%20width='12'%20height='12'%20viewBox='0%200%2012%2012'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.66797%202.66675L9.05507%209.05385'%20stroke='white'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M2.66797%209.05371L9.05507%202.66661'%20stroke='white'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e"},Ah=()=>(V(({miniPlayer:{play:n}})=>({play:n}),K),S.jsx("div",{className:`${!C(T.isTouchScreen)&&"hover:pl-scale-125"} pl-cursor-pointer pl-transition-transform pl-ease-in-out`,onContextMenu:n=>n.preventDefault(),children:S.jsx("img",{src:C(T.isPlayMiniPlayer)?re.bigPause:re.bigPlay,alt:C(T.isPlayMiniPlayer)?"pause":"play",onClick:n=>mh(n),onDoubleClick:n=>n.stopPropagation(),className:`pl-size-5 ${C(T.isPlayMiniPlayer)?"pl-big-play-icon":"pl-big-pause-icon"}`})}));function Dh(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var qo={exports:{}};(function(n,e){(function(t){var s=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,c,u){if(u=u||{},l=l.trim(),c=c.trim(),!c){if(!u.alwaysNormalize)return l;var d=o.parseURL(l);if(!d)throw new Error("Error trying to parse base URL.");return d.path=o.normalizePath(d.path),o.buildURLFromParts(d)}var f=o.parseURL(c);if(!f)throw new Error("Error trying to parse relative URL.");if(f.scheme)return u.alwaysNormalize?(f.path=o.normalizePath(f.path),o.buildURLFromParts(f)):c;var g=o.parseURL(l);if(!g)throw new Error("Error trying to parse base URL.");if(!g.netLoc&&g.path&&g.path[0]!=="/"){var h=r.exec(g.path);g.netLoc=h[1],g.path=h[2]}g.netLoc&&!g.path&&(g.path="/");var m={scheme:g.scheme,netLoc:f.netLoc,path:null,params:f.params,query:f.query,fragment:f.fragment};if(!f.netLoc&&(m.netLoc=g.netLoc,f.path[0]!=="/"))if(!f.path)m.path=g.path,f.params||(m.params=g.params,f.query||(m.query=g.query));else{var p=g.path,E=p.substring(0,p.lastIndexOf("/")+1)+f.path;m.path=o.normalizePath(E)}return m.path===null&&(m.path=u.alwaysNormalize?o.normalizePath(f.path):f.path),o.buildURLFromParts(m)},parseURL:function(l){var c=s.exec(l);return c?{scheme:c[1]||"",netLoc:c[2]||"",path:c[3]||"",params:c[4]||"",query:c[5]||"",fragment:c[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(i,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};n.exports=o})()})(qo);var Mr=qo.exports;function Yo(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);e&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,s)}return t}function ve(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Yo(Object(t),!0).forEach(function(s){kh(n,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Yo(Object(t)).forEach(function(s){Object.defineProperty(n,s,Object.getOwnPropertyDescriptor(t,s))})}return n}function Ih(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var s=t.call(n,e||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function Rh(n){var e=Ih(n,"string");return typeof e=="symbol"?e:String(e)}function kh(n,e,t){return e=Rh(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function ye(){return ye=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[s]=t[s])}return n},ye.apply(this,arguments)}const H=Number.isFinite||function(n){return typeof n=="number"&&isFinite(n)},Ph=Number.isSafeInteger||function(n){return typeof n=="number"&&Math.abs(n)<=_h},_h=Number.MAX_SAFE_INTEGER||9007199254740991;let y=function(n){return n.MEDIA_ATTACHING="hlsMediaAttaching",n.MEDIA_ATTACHED="hlsMediaAttached",n.MEDIA_DETACHING="hlsMediaDetaching",n.MEDIA_DETACHED="hlsMediaDetached",n.BUFFER_RESET="hlsBufferReset",n.BUFFER_CODECS="hlsBufferCodecs",n.BUFFER_CREATED="hlsBufferCreated",n.BUFFER_APPENDING="hlsBufferAppending",n.BUFFER_APPENDED="hlsBufferAppended",n.BUFFER_EOS="hlsBufferEos",n.BUFFER_FLUSHING="hlsBufferFlushing",n.BUFFER_FLUSHED="hlsBufferFlushed",n.MANIFEST_LOADING="hlsManifestLoading",n.MANIFEST_LOADED="hlsManifestLoaded",n.MANIFEST_PARSED="hlsManifestParsed",n.LEVEL_SWITCHING="hlsLevelSwitching",n.LEVEL_SWITCHED="hlsLevelSwitched",n.LEVEL_LOADING="hlsLevelLoading",n.LEVEL_LOADED="hlsLevelLoaded",n.LEVEL_UPDATED="hlsLevelUpdated",n.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",n.LEVELS_UPDATED="hlsLevelsUpdated",n.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",n.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",n.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",n.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",n.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",n.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",n.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",n.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",n.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",n.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",n.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",n.CUES_PARSED="hlsCuesParsed",n.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",n.INIT_PTS_FOUND="hlsInitPtsFound",n.FRAG_LOADING="hlsFragLoading",n.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",n.FRAG_LOADED="hlsFragLoaded",n.FRAG_DECRYPTED="hlsFragDecrypted",n.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",n.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",n.FRAG_PARSING_METADATA="hlsFragParsingMetadata",n.FRAG_PARSED="hlsFragParsed",n.FRAG_BUFFERED="hlsFragBuffered",n.FRAG_CHANGED="hlsFragChanged",n.FPS_DROP="hlsFpsDrop",n.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",n.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",n.ERROR="hlsError",n.DESTROYING="hlsDestroying",n.KEY_LOADING="hlsKeyLoading",n.KEY_LOADED="hlsKeyLoaded",n.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",n.BACK_BUFFER_REACHED="hlsBackBufferReached",n.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",n}({}),Z=function(n){return n.NETWORK_ERROR="networkError",n.MEDIA_ERROR="mediaError",n.KEY_SYSTEM_ERROR="keySystemError",n.MUX_ERROR="muxError",n.OTHER_ERROR="otherError",n}({}),k=function(n){return n.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",n.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",n.KEY_SYSTEM_NO_SESSION="keySystemNoSession",n.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",n.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",n.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",n.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",n.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",n.MANIFEST_LOAD_ERROR="manifestLoadError",n.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",n.MANIFEST_PARSING_ERROR="manifestParsingError",n.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",n.LEVEL_EMPTY_ERROR="levelEmptyError",n.LEVEL_LOAD_ERROR="levelLoadError",n.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",n.LEVEL_PARSING_ERROR="levelParsingError",n.LEVEL_SWITCH_ERROR="levelSwitchError",n.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",n.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",n.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",n.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",n.FRAG_LOAD_ERROR="fragLoadError",n.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",n.FRAG_DECRYPT_ERROR="fragDecryptError",n.FRAG_PARSING_ERROR="fragParsingError",n.FRAG_GAP="fragGap",n.REMUX_ALLOC_ERROR="remuxAllocError",n.KEY_LOAD_ERROR="keyLoadError",n.KEY_LOAD_TIMEOUT="keyLoadTimeOut",n.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",n.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",n.BUFFER_APPEND_ERROR="bufferAppendError",n.BUFFER_APPENDING_ERROR="bufferAppendingError",n.BUFFER_STALLED_ERROR="bufferStalledError",n.BUFFER_FULL_ERROR="bufferFullError",n.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",n.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",n.INTERNAL_EXCEPTION="internalException",n.INTERNAL_ABORTED="aborted",n.UNKNOWN="unknown",n}({});const kt=function(){},Nr={trace:kt,debug:kt,log:kt,warn:kt,info:kt,error:kt};let gs=Nr;function Oh(n){const e=self.console[n];return e?e.bind(self.console,`[${n}] >`):kt}function Fh(n,...e){e.forEach(function(t){gs[t]=n[t]?n[t].bind(n):Oh(t)})}function Mh(n,e){if(typeof console=="object"&&n===!0||typeof n=="object"){Fh(n,"debug","log","info","warn","error");try{gs.log(`Debug logs enabled for "${e}" in hls.js version 1.5.20`)}catch{gs=Nr}}else gs=Nr}const L=gs,Nh=/^(\d+)x(\d+)$/,Xo=/(.+?)=(".*?"|.*?)(?:,|$)/g;class pe{constructor(e){typeof e=="string"&&(e=pe.parseAttrList(e)),ye(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}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=(t.length&1?"0":"")+t;const s=new Uint8Array(t.length/2);for(let r=0;r<t.length/2;r++)s[r]=parseInt(t.slice(r*2,r*2+2),16);return s}else 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 s=this[e];return s?parseFloat(s):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){const t=Nh.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const s={},r='"';for(Xo.lastIndex=0;(t=Xo.exec(e))!==null;){let i=t[2];i.indexOf(r)===0&&i.lastIndexOf(r)===i.length-1&&(i=i.slice(1,-1));const a=t[1].trim();s[a]=i}return s}}function Bh(n){return n!=="ID"&&n!=="CLASS"&&n!=="START-DATE"&&n!=="DURATION"&&n!=="END-DATE"&&n!=="END-ON-NEXT"}function Uh(n){return n==="SCTE35-OUT"||n==="SCTE35-IN"}class Zo{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const s=t.attr;for(const r in s)if(Object.prototype.hasOwnProperty.call(e,r)&&e[r]!==s[r]){L.warn(`DATERANGE tag attribute: "${r}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=r;break}e=ye(new pe({}),s,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const s=new Date(this.attr["END-DATE"]);H(s.getTime())&&(this._endDate=s)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(H(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&H(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class dn{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 le={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Qo{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[le.AUDIO]:null,[le.VIDEO]:null,[le.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){const s=e.split("@",2);let r;s.length===1?r=(t==null?void 0:t.byteRangeEndOffset)||0:r=parseInt(s[1]),this._byteRange=[r,parseInt(s[0])+r]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Mr.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class Br extends Qo{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new dn,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const s=Object.keys(this.levelkeys);if(s.length===1)return this._decryptdata=this.levelkeys[s[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!H(this.programDateTime))return null;const e=H(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){const t=Object.keys(this.levelkeys),s=t.length;if(s>1||s===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,s,r,i,a=!1){const{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:s,startDTS:r,endDTS:i,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,s),l.startDTS=Math.min(l.startDTS,r),l.endDTS=Math.max(l.endDTS,i)}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[le.AUDIO]=null,e[le.VIDEO]=null,e[le.AUDIOVIDEO]=null}}class $h extends Qo{constructor(e,t,s,r,i){super(s),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new dn,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=r;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,i),i&&(this.fragOffset=i.fragOffset+i.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)}}const Vh=10;class Gh{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,s=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!s||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&s>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?H(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Vh}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function Ur(n){return Uint8Array.from(atob(n),e=>e.charCodeAt(0))}function Hh(n){const e=$r(n).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function Kh(n){const e=function(s,r,i){const a=s[r];s[r]=s[i],s[i]=a};e(n,0,3),e(n,1,2),e(n,4,5),e(n,6,7)}function Wh(n){const e=n.split(":");let t=null;if(e[0]==="data"&&e.length===2){const s=e[1].split(";"),r=s[s.length-1].split(",");if(r.length===2){const i=r[0]==="base64",a=r[1];i?(s.splice(-1,1),t=Ur(a)):t=Hh(a)}}return t}function $r(n){return Uint8Array.from(unescape(encodeURIComponent(n)),e=>e.charCodeAt(0))}const Wt=typeof self<"u"?self:void 0;var ae={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Fe={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Vr(n){switch(n){case Fe.FAIRPLAY:return ae.FAIRPLAY;case Fe.PLAYREADY:return ae.PLAYREADY;case Fe.WIDEVINE:return ae.WIDEVINE;case Fe.CLEARKEY:return ae.CLEARKEY}}var fn={CENC:"1077efecc0b24d02ace33c1e52e2fb4b",CLEARKEY:"e2719d58a985b3c9781ab030af78d30e",FAIRPLAY:"94ce86fb07ff4f43adb893d2fa968ca2",PLAYREADY:"9a04f07998404286ab92e65be0885f95",WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function Gr(n){if(n===fn.WIDEVINE)return ae.WIDEVINE;if(n===fn.PLAYREADY)return ae.PLAYREADY;if(n===fn.CENC||n===fn.CLEARKEY)return ae.CLEARKEY}function Hr(n){switch(n){case ae.FAIRPLAY:return Fe.FAIRPLAY;case ae.PLAYREADY:return Fe.PLAYREADY;case ae.WIDEVINE:return Fe.WIDEVINE;case ae.CLEARKEY:return Fe.CLEARKEY}}function hn(n){const{drmSystems:e,widevineLicenseUrl:t}=n,s=e?[ae.FAIRPLAY,ae.WIDEVINE,ae.PLAYREADY,ae.CLEARKEY].filter(r=>!!e[r]):[];return!s[ae.WIDEVINE]&&t&&s.push(ae.WIDEVINE),s}const Jo=function(n){return Wt!=null&&(n=Wt.navigator)!=null&&n.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function jh(n,e,t,s){let r;switch(n){case ae.FAIRPLAY:r=["cenc","sinf"];break;case ae.WIDEVINE:case ae.PLAYREADY:r=["cenc"];break;case ae.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${n}`)}return zh(r,e,t,s)}function zh(n,e,t,s){return[{initDataTypes:n,persistentState:s.persistentState||"optional",distinctiveIdentifier:s.distinctiveIdentifier||"optional",sessionTypes:s.sessionTypes||[s.sessionType||"temporary"],audioCapabilities:e.map(i=>({contentType:`audio/mp4; codecs="${i}"`,robustness:s.audioRobustness||"",encryptionScheme:s.audioEncryptionScheme||null})),videoCapabilities:t.map(i=>({contentType:`video/mp4; codecs="${i}"`,robustness:s.videoRobustness||"",encryptionScheme:s.videoEncryptionScheme||null}))}]}function el(n){const e=new Uint16Array(n.buffer,n.byteOffset,n.byteLength/2),t=String.fromCharCode.apply(null,Array.from(e)),s=t.substring(t.indexOf("<"),t.length),a=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("KID")[0];if(a){const o=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(o){const l=Ur(o).subarray(0,16);return Kh(l),l}}return null}function Pt(n,e,t){return Uint8Array.prototype.slice?n.slice(e,t):new Uint8Array(Array.prototype.slice.call(n,e,t))}const Kr=(n,e)=>e+10<=n.length&&n[e]===73&&n[e+1]===68&&n[e+2]===51&&n[e+3]<255&&n[e+4]<255&&n[e+6]<128&&n[e+7]<128&&n[e+8]<128&&n[e+9]<128,tl=(n,e)=>e+10<=n.length&&n[e]===51&&n[e+1]===68&&n[e+2]===73&&n[e+3]<255&&n[e+4]<255&&n[e+6]<128&&n[e+7]<128&&n[e+8]<128&&n[e+9]<128,ms=(n,e)=>{const t=e;let s=0;for(;Kr(n,e);){s+=10;const r=pn(n,e+6);s+=r,tl(n,e+10)&&(s+=10),e+=s}if(s>0)return n.subarray(t,t+s)},pn=(n,e)=>{let t=0;return t=(n[e]&127)<<21,t|=(n[e+1]&127)<<14,t|=(n[e+2]&127)<<7,t|=n[e+3]&127,t},qh=(n,e)=>Kr(n,e)&&pn(n,e+6)+10<=n.length-e,Wr=n=>{const e=nl(n);for(let t=0;t<e.length;t++){const s=e[t];if(sl(s))return e2(s)}},sl=n=>n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp",Yh=n=>{const e=String.fromCharCode(n[0],n[1],n[2],n[3]),t=pn(n,4),s=10;return{type:e,size:t,data:n.subarray(s,s+t)}},nl=n=>{let e=0;const t=[];for(;Kr(n,e);){const s=pn(n,e+6);e+=10;const r=e+s;for(;e+8<r;){const i=Yh(n.subarray(e)),a=Xh(i);a&&t.push(a),e+=i.size+10}tl(n,e)&&(e+=10)}return t},Xh=n=>n.type==="PRIV"?Zh(n):n.type[0]==="W"?Jh(n):Qh(n),Zh=n=>{if(n.size<2)return;const e=Qe(n.data,!0),t=new Uint8Array(n.data.subarray(e.length+1));return{key:n.type,info:e,data:t.buffer}},Qh=n=>{if(n.size<2)return;if(n.type==="TXXX"){let t=1;const s=Qe(n.data.subarray(t),!0);t+=s.length+1;const r=Qe(n.data.subarray(t));return{key:n.type,info:s,data:r}}const e=Qe(n.data.subarray(1));return{key:n.type,data:e}},Jh=n=>{if(n.type==="WXXX"){if(n.size<2)return;let t=1;const s=Qe(n.data.subarray(t),!0);t+=s.length+1;const r=Qe(n.data.subarray(t));return{key:n.type,info:s,data:r}}const e=Qe(n.data);return{key:n.type,data:e}},e2=n=>{if(n.data.byteLength===8){const e=new Uint8Array(n.data),t=e[3]&1;let s=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return s/=45,t&&(s+=4772185884e-2),Math.round(s)}},Qe=(n,e=!1)=>{const t=t2();if(t){const c=t.decode(n);if(e){const u=c.indexOf("\0");return u!==-1?c.substring(0,u):c}return c.replace(/\0/g,"")}const s=n.length;let r,i,a,o="",l=0;for(;l<s;){if(r=n[l++],r===0&&e)return o;if(r===0||r===3)continue;switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(r);break;case 12:case 13:i=n[l++],o+=String.fromCharCode((r&31)<<6|i&63);break;case 14:i=n[l++],a=n[l++],o+=String.fromCharCode((r&15)<<12|(i&63)<<6|(a&63)<<0);break}}return o};let jr;function t2(){if(!navigator.userAgent.includes("PlayStation 4"))return!jr&&typeof self.TextDecoder<"u"&&(jr=new self.TextDecoder("utf-8")),jr}const Je={hexDump:function(n){let e="";for(let t=0;t<n.length;t++){let s=n[t].toString(16);s.length<2&&(s="0"+s),e+=s}return e}},gn=Math.pow(2,32)-1,s2=[].push,rl={video:1,audio:2,id3:3,text:4};function Te(n){return String.fromCharCode.apply(null,n)}function il(n,e){const t=n[e]<<8|n[e+1];return t<0?65536+t:t}function z(n,e){const t=ol(n,e);return t<0?4294967296+t:t}function al(n,e){let t=z(n,e);return t*=Math.pow(2,32),t+=z(n,e+4),t}function ol(n,e){return n[e]<<24|n[e+1]<<16|n[e+2]<<8|n[e+3]}function zr(n,e,t){n[e]=t>>24,n[e+1]=t>>16&255,n[e+2]=t>>8&255,n[e+3]=t&255}function n2(n){const e=n.byteLength;for(let t=0;t<e;){const s=z(n,t);if(s>8&&n[t+4]===109&&n[t+5]===111&&n[t+6]===111&&n[t+7]===102)return!0;t=s>1?t+s:e}return!1}function J(n,e){const t=[];if(!e.length)return t;const s=n.byteLength;for(let r=0;r<s;){const i=z(n,r),a=Te(n.subarray(r+4,r+8)),o=i>1?r+i:s;if(a===e[0])if(e.length===1)t.push(n.subarray(r+8,o));else{const l=J(n.subarray(r+8,o),e.slice(1));l.length&&s2.apply(t,l)}r=o}return t}function r2(n){const e=[],t=n[0];let s=8;const r=z(n,s);s+=4;let i=0,a=0;t===0?(i=z(n,s),a=z(n,s+4),s+=8):(i=al(n,s),a=al(n,s+8),s+=16),s+=2;let o=n.length+a;const l=il(n,s);s+=2;for(let c=0;c<l;c++){let u=s;const d=z(n,u);u+=4;const f=d&2147483647;if((d&2147483648)>>>31===1)return L.warn("SIDX has hierarchical references (not supported)"),null;const h=z(n,u);u+=4,e.push({referenceSize:f,subsegmentDuration:h,info:{duration:h/r,start:o,end:o+f-1}}),o+=f,u+=4,s=u}return{earliestPresentationTime:i,timescale:r,version:t,referencesCount:l,references:e}}function ll(n){const e=[],t=J(n,["moov","trak"]);for(let r=0;r<t.length;r++){const i=t[r],a=J(i,["tkhd"])[0];if(a){let o=a[0];const l=z(a,o===0?12:20),c=J(i,["mdia","mdhd"])[0];if(c){o=c[0];const u=z(c,o===0?12:20),d=J(i,["mdia","hdlr"])[0];if(d){const f=Te(d.subarray(8,12)),g={soun:le.AUDIO,vide:le.VIDEO}[f];if(g){const h=J(i,["mdia","minf","stbl","stsd"])[0],m=i2(h);e[l]={timescale:u,type:g},e[g]=ve({timescale:u,id:l},m)}}}}}return J(n,["moov","mvex","trex"]).forEach(r=>{const i=z(r,4),a=e[i];a&&(a.default={duration:z(r,12),flags:z(r,20)})}),e}function i2(n){const e=n.subarray(8),t=e.subarray(86),s=Te(e.subarray(4,8));let r=s;const i=s==="enca"||s==="encv";if(i){const o=J(e,[s])[0].subarray(s==="enca"?28:78);J(o,["sinf"]).forEach(c=>{const u=J(c,["schm"])[0];if(u){const d=Te(u.subarray(4,8));if(d==="cbcs"||d==="cenc"){const f=J(c,["frma"])[0];f&&(r=Te(f))}}})}switch(r){case"avc1":case"avc2":case"avc3":case"avc4":{const a=J(t,["avcC"])[0];r+="."+mn(a[1])+mn(a[2])+mn(a[3]);break}case"mp4a":{const a=J(e,[s])[0],o=J(a.subarray(28),["esds"])[0];if(o&&o.length>12){let l=4;if(o[l++]!==3)break;l=qr(o,l),l+=2;const c=o[l++];if(c&128&&(l+=2),c&64&&(l+=o[l++]),o[l++]!==4)break;l=qr(o,l);const u=o[l++];if(u===64)r+="."+mn(u);else break;if(l+=12,o[l++]!==5)break;l=qr(o,l);const d=o[l++];let f=(d&248)>>3;f===31&&(f+=1+((d&7)<<3)+((o[l]&224)>>5)),r+="."+f}break}case"hvc1":case"hev1":{const a=J(t,["hvcC"])[0],o=a[1],l=["","A","B","C"][o>>6],c=o&31,u=z(a,2),d=(o&32)>>5?"H":"L",f=a[12],g=a.subarray(6,12);r+="."+l+c,r+="."+u.toString(16).toUpperCase(),r+="."+d+f;let h="";for(let m=g.length;m--;){const p=g[m];(p||h)&&(h="."+p.toString(16).toUpperCase()+h)}r+=h;break}case"dvh1":case"dvhe":{const a=J(t,["dvcC"])[0],o=a[2]>>1&127,l=a[2]<<5&32|a[3]>>3&31;r+="."+et(o)+"."+et(l);break}case"vp09":{const a=J(t,["vpcC"])[0],o=a[4],l=a[5],c=a[6]>>4&15;r+="."+et(o)+"."+et(l)+"."+et(c);break}case"av01":{const a=J(t,["av1C"])[0],o=a[1]>>>5,l=a[1]&31,c=a[2]>>>7?"H":"M",u=(a[2]&64)>>6,d=(a[2]&32)>>5,f=o===2&&u?d?12:10:u?10:8,g=(a[2]&16)>>4,h=(a[2]&8)>>3,m=(a[2]&4)>>2,p=a[2]&3;r+="."+o+"."+et(l)+c+"."+et(f)+"."+g+"."+h+m+p+"."+et(1)+"."+et(1)+"."+et(1)+"."+0;break}}return{codec:r,encrypted:i}}function qr(n,e){const t=e+5;for(;n[e++]&128&&e<t;);return e}function mn(n){return("0"+n.toString(16).toUpperCase()).slice(-2)}function et(n){return(n<10?"0":"")+n}function a2(n,e){if(!n||!e)return n;const t=e.keyId;return t&&e.isCommonEncryption&&J(n,["moov","trak"]).forEach(r=>{const a=J(r,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=J(a,["enca"]);const l=o.length>0;l||(o=J(a,["encv"])),o.forEach(c=>{const u=l?c.subarray(28):c.subarray(78);J(u,["sinf"]).forEach(f=>{const g=cl(f);if(g){const h=g.subarray(8,24);h.some(m=>m!==0)||(L.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Je.hexDump(h)} -> ${Je.hexDump(t)}`),g.set(t,8))}})})}),n}function cl(n){const e=J(n,["schm"])[0];if(e){const t=Te(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return J(n,["schi","tenc"])[0]}return null}function o2(n,e){return J(e,["moof","traf"]).reduce((t,s)=>{const r=J(s,["tfdt"])[0],i=r[0],a=J(s,["tfhd"]).reduce((o,l)=>{const c=z(l,4),u=n[c];if(u){let d=z(r,4);if(i===1){if(d===gn)return L.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;d*=gn+1,d+=z(r,8)}const f=u.timescale||9e4,g=d/f;if(H(g)&&(o===null||g<o))return g}return o},null);return a!==null&&H(a)&&(t===null||a<t)?a:t},null)}function l2(n,e){let t=0,s=0,r=0;const i=J(n,["moof","traf"]);for(let a=0;a<i.length;a++){const o=i[a],l=J(o,["tfhd"])[0],c=z(l,4),u=e[c];if(!u)continue;const d=u.default,f=z(l,0)|(d==null?void 0:d.flags);let g=d==null?void 0:d.duration;f&8&&(f&2?g=z(l,12):g=z(l,8));const h=u.timescale||9e4,m=J(o,["trun"]);for(let p=0;p<m.length;p++){if(t=c2(m[p]),!t&&g){const E=z(m[p],4);t=g*E}u.type===le.VIDEO?s+=t/h:u.type===le.AUDIO&&(r+=t/h)}}if(s===0&&r===0){let a=1/0,o=0,l=0;const c=J(n,["sidx"]);for(let u=0;u<c.length;u++){const d=r2(c[u]);if(d!=null&&d.references){a=Math.min(a,d.earliestPresentationTime/d.timescale);const f=d.references.reduce((g,h)=>g+h.info.duration||0,0);o=Math.max(o,f+d.earliestPresentationTime/d.timescale),l=o-a}}if(l&&H(l))return l}return s||r}function c2(n){const e=z(n,0);let t=8;e&1&&(t+=4),e&4&&(t+=4);let s=0;const r=z(n,4);for(let i=0;i<r;i++){if(e&256){const a=z(n,t);s+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return s}function u2(n,e,t){J(e,["moof","traf"]).forEach(s=>{J(s,["tfhd"]).forEach(r=>{const i=z(r,4),a=n[i];if(!a)return;const o=a.timescale||9e4;J(s,["tfdt"]).forEach(l=>{const c=l[0],u=t*o;if(u){let d=z(l,4);if(c===0)d-=u,d=Math.max(d,0),zr(l,4,d);else{d*=Math.pow(2,32),d+=z(l,8),d-=u,d=Math.max(d,0);const f=Math.floor(d/(gn+1)),g=Math.floor(d%(gn+1));zr(l,4,f),zr(l,8,g)}}})})})}function d2(n){const e={valid:null,remainder:null},t=J(n,["moof"]);if(t.length<2)return e.remainder=n,e;const s=t[t.length-1];return e.valid=Pt(n,0,s.byteOffset-8),e.remainder=Pt(n,s.byteOffset-8),e}function Ge(n,e){const t=new Uint8Array(n.length+e.length);return t.set(n),t.set(e,n.length),t}function ul(n,e){const t=[],s=e.samples,r=e.timescale,i=e.id;let a=!1;return J(s,["moof"]).map(l=>{const c=l.byteOffset-8;J(l,["traf"]).map(d=>{const f=J(d,["tfdt"]).map(g=>{const h=g[0];let m=z(g,4);return h===1&&(m*=Math.pow(2,32),m+=z(g,8)),m/r})[0];return f!==void 0&&(n=f),J(d,["tfhd"]).map(g=>{const h=z(g,4),m=z(g,0)&16777215,p=(m&1)!==0,E=(m&2)!==0,x=(m&8)!==0;let v=0;const w=(m&16)!==0;let b=0;const I=(m&32)!==0;let A=8;h===i&&(p&&(A+=8),E&&(A+=4),x&&(v=z(g,A),A+=4),w&&(b=z(g,A),A+=4),I&&(A+=4),e.type==="video"&&(a=f2(e.codec)),J(d,["trun"]).map(F=>{const U=F[0],O=z(F,0)&16777215,B=(O&1)!==0;let Y=0;const $=(O&4)!==0,j=(O&256)!==0;let Q=0;const X=(O&512)!==0;let ne=0;const ue=(O&1024)!==0,W=(O&2048)!==0;let G=0;const ie=z(F,4);let te=8;B&&(Y=z(F,te),te+=4),$&&(te+=4);let ce=Y+c;for(let Ee=0;Ee<ie;Ee++){if(j?(Q=z(F,te),te+=4):Q=v,X?(ne=z(F,te),te+=4):ne=b,ue&&(te+=4),W&&(U===0?G=z(F,te):G=ol(F,te),te+=4),e.type===le.VIDEO){let we=0;for(;we<ne;){const Ie=z(s,ce);if(ce+=4,h2(a,s[ce])){const We=s.subarray(ce,ce+Ie);dl(We,a?2:1,n+G/r,t)}ce+=Ie,we+=Ie+4}}n+=Q/r}}))})})}),t}function f2(n){if(!n)return!1;const e=n.indexOf("."),t=e<0?n:n.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function h2(n,e){if(n){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function dl(n,e,t,s){const r=fl(n);let i=0;i+=e;let a=0,o=0,l=0;for(;i<r.length;){a=0;do{if(i>=r.length)break;l=r[i++],a+=l}while(l===255);o=0;do{if(i>=r.length)break;l=r[i++],o+=l}while(l===255);const c=r.length-i;let u=i;if(o<c)i+=o;else if(o>c){L.error(`Malformed SEI payload. ${o} is too small, only ${c} bytes left to parse.`);break}if(a===4){if(r[u++]===181){const f=il(r,u);if(u+=2,f===49){const g=z(r,u);if(u+=4,g===1195456820){const h=r[u++];if(h===3){const m=r[u++],p=31&m,E=64&m,x=E?2+p*3:0,v=new Uint8Array(x);if(E){v[0]=m;for(let w=1;w<x;w++)v[w]=r[u++]}s.push({type:h,payloadType:a,pts:t,bytes:v})}}}}}else if(a===5&&o>16){const d=[];for(let h=0;h<16;h++){const m=r[u++].toString(16);d.push(m.length==1?"0"+m:m),(h===3||h===5||h===7||h===9)&&d.push("-")}const f=o-16,g=new Uint8Array(f);for(let h=0;h<f;h++)g[h]=r[u++];s.push({payloadType:a,pts:t,uuid:d.join(""),userData:Qe(g),userDataBytes:g})}}}function fl(n){const e=n.byteLength,t=[];let s=1;for(;s<e-2;)n[s]===0&&n[s+1]===0&&n[s+2]===3?(t.push(s+2),s+=2):s++;if(t.length===0)return n;const r=e-t.length,i=new Uint8Array(r);let a=0;for(s=0;s<r;a++,s++)a===t[0]&&(a++,t.shift()),i[s]=n[a];return i}function p2(n){const e=n[0];let t="",s="",r=0,i=0,a=0,o=0,l=0,c=0;if(e===0){for(;Te(n.subarray(c,c+1))!=="\0";)t+=Te(n.subarray(c,c+1)),c+=1;for(t+=Te(n.subarray(c,c+1)),c+=1;Te(n.subarray(c,c+1))!=="\0";)s+=Te(n.subarray(c,c+1)),c+=1;s+=Te(n.subarray(c,c+1)),c+=1,r=z(n,12),i=z(n,16),o=z(n,20),l=z(n,24),c=28}else if(e===1){c+=4,r=z(n,c),c+=4;const d=z(n,c);c+=4;const f=z(n,c);for(c+=4,a=2**32*d+f,Ph(a)||(a=Number.MAX_SAFE_INTEGER,L.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=z(n,c),c+=4,l=z(n,c),c+=4;Te(n.subarray(c,c+1))!=="\0";)t+=Te(n.subarray(c,c+1)),c+=1;for(t+=Te(n.subarray(c,c+1)),c+=1;Te(n.subarray(c,c+1))!=="\0";)s+=Te(n.subarray(c,c+1)),c+=1;s+=Te(n.subarray(c,c+1)),c+=1}const u=n.subarray(c,n.byteLength);return{schemeIdUri:t,value:s,timeScale:r,presentationTime:a,presentationTimeDelta:i,eventDuration:o,id:l,payload:u}}function g2(n,...e){const t=e.length;let s=8,r=t;for(;r--;)s+=e[r].byteLength;const i=new Uint8Array(s);for(i[0]=s>>24&255,i[1]=s>>16&255,i[2]=s>>8&255,i[3]=s&255,i.set(n,4),r=0,s=8;r<t;r++)i.set(e[r],s),s+=e[r].byteLength;return i}function m2(n,e,t){if(n.byteLength!==16)throw new RangeError("Invalid system id");let s,r;s=0,r=new Uint8Array;let i;s>0?(i=new Uint8Array(4),e.length>0&&new DataView(i.buffer).setUint32(0,e.length,!1)):i=new Uint8Array;const a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),g2([112,115,115,104],new Uint8Array([s,0,0,0]),n,i,r,a,t||new Uint8Array)}function y2(n){const e=[];if(n instanceof ArrayBuffer){const t=n.byteLength;let s=0;for(;s+32<t;){const r=new DataView(n,s),i=E2(r);e.push(i),s+=i.size}}return e}function E2(n){const e=n.getUint32(0),t=n.byteOffset,s=n.byteLength;if(s<e)return{offset:t,size:s};if(n.getUint32(4)!==1886614376)return{offset:t,size:e};const i=n.getUint32(8)>>>24;if(i!==0&&i!==1)return{offset:t,size:e};const a=n.buffer,o=Je.hexDump(new Uint8Array(a,t+12,16)),l=n.getUint32(28);let c=null,u=null;if(i===0){if(e-32<l||l<22)return{offset:t,size:e};u=new Uint8Array(a,t+32,l)}else if(i===1){if(!l||s<t+32+l*16+16)return{offset:t,size:e};c=[];for(let d=0;d<l;d++)c.push(new Uint8Array(a,t+32+d*16,16))}return{version:i,systemId:o,kids:c,data:u,offset:t,size:e}}let yn={};class ys{static clearKeyUriToKeyIdMap(){yn={}}constructor(e,t,s,r=[1],i=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=s,this.keyFormatVersions=r,this.iv=i,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Fe.FAIRPLAY:case Fe.WIDEVINE:case Fe.PLAYREADY:case Fe.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&L.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const s=S2(e);return new ys(this.method,this.uri,"identity",this.keyFormatVersions,s)}const t=Wh(this.uri);if(t)switch(this.keyFormat){case Fe.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case Fe.PLAYREADY:{const s=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=m2(s,null,t),this.keyId=el(t);break}default:{let s=t.subarray(0,16);if(s.length!==16){const r=new Uint8Array(16);r.set(s,16-s.length),s=r}this.keyId=s;break}}if(!this.keyId||this.keyId.byteLength!==16){let s=yn[this.uri];if(!s){const r=Object.keys(yn).length%Number.MAX_SAFE_INTEGER;s=new Uint8Array(16),new DataView(s.buffer,12,4).setUint32(0,r),yn[this.uri]=s}this.keyId=s}return this}}function S2(n){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=n>>8*(15-t)&255;return e}const hl=/\{\$([a-zA-Z0-9-_]+)\}/g;function pl(n){return hl.test(n)}function Me(n,e,t){if(n.variableList!==null||n.hasVariableRefs)for(let s=t.length;s--;){const r=t[s],i=e[r];i&&(e[r]=Yr(n,i))}}function Yr(n,e){if(n.variableList!==null||n.hasVariableRefs){const t=n.variableList;return e.replace(hl,s=>{const r=s.substring(2,s.length-1),i=t==null?void 0:t[r];return i===void 0?(n.playlistParsingError||(n.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),s):i})}return e}function gl(n,e,t){let s=n.variableList;s||(n.variableList=s={});let r,i;if("QUERYPARAM"in e){r=e.QUERYPARAM;try{const a=new self.URL(t).searchParams;if(a.has(r))i=a.get(r);else throw new Error(`"${r}" does not match any query parameter in URI: "${t}"`)}catch(a){n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else r=e.NAME,i=e.VALUE;r in s?n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):s[r]=i||""}function T2(n,e,t){const s=e.IMPORT;if(t&&s in t){let r=n.variableList;r||(n.variableList=r={}),r[s]=t[s]}else n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${s}"`))}function _t(n=!0){return typeof self>"u"?void 0:(n||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function x2(n){return typeof self<"u"&&n===self.ManagedMediaSource}const En={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function v2(n,e){const t=En[e];return!!t&&!!t[n.slice(0,4)]}function Xr(n,e,t=!0){return!n.split(",").some(s=>!ml(s,e,t))}function ml(n,e,t=!0){var s;const r=_t(t);return(s=r==null?void 0:r.isTypeSupported(Es(n,e)))!=null?s:!1}function Es(n,e){return`${e}/mp4;codecs="${n}"`}function yl(n){if(n){const e=n.substring(0,4);return En.video[e]}return 2}function Sn(n){return n.split(",").reduce((e,t)=>{const s=En.video[t];return s?(s*2+e)/(e?3:2):(En.audio[t]+e)/(e?2:1)},0)}const Zr={};function b2(n,e=!0){if(Zr[n])return Zr[n];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[n];for(let s=0;s<t.length;s++)if(ml(t[s],"audio",e))return Zr[n]=t[s],t[s];return n}const C2=/flac|opus/i;function Tn(n,e=!0){return n.replace(C2,t=>b2(t.toLowerCase(),e))}function El(n,e){return n&&n!=="mp4a"?n:e&&e.split(",")[0]}function w2(n){const e=n.split(",");for(let t=0;t<e.length;t++){const s=e[t].split(".");if(s.length>2){let r=s.shift()+".";r+=parseInt(s.shift()).toString(16),r+=("000"+parseInt(s.shift()).toString(16)).slice(-4),e[t]=r}}return e.join(",")}const Sl=/#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,Tl=/#EXT-X-MEDIA:(.*)/g,L2=/^#EXT(?:INF|-X-TARGETDURATION):/m,xl=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),A2=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class tt{static findGroup(e,t){for(let s=0;s<e.length;s++){const r=e[s];if(r.id===t)return r}}static resolve(e,t){return Mr.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return L2.test(e)}static parseMasterPlaylist(e,t){const s=pl(e),r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:s},i=[];Sl.lastIndex=0;let a;for(;(a=Sl.exec(e))!=null;)if(a[1]){var o;const c=new pe(a[1]);Me(r,c,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const u=Yr(r,a[2]),d={attrs:c,bitrate:c.decimalInteger("BANDWIDTH")||c.decimalInteger("AVERAGE-BANDWIDTH"),name:c.NAME,url:tt.resolve(u,t)},f=c.decimalResolution("RESOLUTION");f&&(d.width=f.width,d.height=f.height),D2(c.CODECS,d),(o=d.unknownCodecs)!=null&&o.length||i.push(d),r.levels.push(d)}else if(a[3]){const c=a[3],u=a[4];switch(c){case"SESSION-DATA":{const d=new pe(u);Me(r,d,["DATA-ID","LANGUAGE","VALUE","URI"]);const f=d["DATA-ID"];f&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[f]=d);break}case"SESSION-KEY":{const d=vl(u,t,r);d.encrypted&&d.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(d)):L.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${u}"`);break}case"DEFINE":{{const d=new pe(u);Me(r,d,["NAME","VALUE","QUERYPARAM"]),gl(r,d,t)}break}case"CONTENT-STEERING":{const d=new pe(u);Me(r,d,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:tt.resolve(d["SERVER-URI"],t),pathwayId:d["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=bl(u);break}}}const l=i.length>0&&i.length<r.levels.length;return r.levels=l?i:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,s){let r;const i={},a=s.levels,o={AUDIO:a.map(c=>({id:c.attrs.AUDIO,audioCodec:c.audioCodec})),SUBTITLES:a.map(c=>({id:c.attrs.SUBTITLES,textCodec:c.textCodec})),"CLOSED-CAPTIONS":[]};let l=0;for(Tl.lastIndex=0;(r=Tl.exec(e))!==null;){const c=new pe(r[1]),u=c.TYPE;if(u){const d=o[u],f=i[u]||[];i[u]=f,Me(s,c,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const g=c.LANGUAGE,h=c["ASSOC-LANGUAGE"],m=c.CHANNELS,p=c.CHARACTERISTICS,E=c["INSTREAM-ID"],x={attrs:c,bitrate:0,id:l++,groupId:c["GROUP-ID"]||"",name:c.NAME||g||"",type:u,default:c.bool("DEFAULT"),autoselect:c.bool("AUTOSELECT"),forced:c.bool("FORCED"),lang:g,url:c.URI?tt.resolve(c.URI,t):""};if(h&&(x.assocLang=h),m&&(x.channels=m),p&&(x.characteristics=p),E&&(x.instreamId=E),d!=null&&d.length){const v=tt.findGroup(d,x.groupId)||d[0];Cl(x,v,"audioCodec"),Cl(x,v,"textCodec")}f.push(x)}}return i}static parseLevelPlaylist(e,t,s,r,i,a){const o=new Gh(t),l=o.fragments;let c=null,u=0,d=0,f=0,g=0,h=null,m=new Br(r,t),p,E,x,v=-1,w=!1,b=null;for(xl.lastIndex=0,o.m3u8=e,o.hasVariableRefs=pl(e);(p=xl.exec(e))!==null;){w&&(w=!1,m=new Br(r,t),m.start=f,m.sn=u,m.cc=g,m.level=s,c&&(m.initSegment=c,m.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null,b&&(m.setByteRange(b),b=null)));const U=p[1];if(U){m.duration=parseFloat(U);const O=(" "+p[2]).slice(1);m.title=O||null,m.tagList.push(O?["INF",U,O]:["INF",U])}else if(p[3]){if(H(m.duration)){m.start=f,x&&Al(m,x,o),m.sn=u,m.level=s,m.cc=g,l.push(m);const O=(" "+p[3]).slice(1);m.relurl=Yr(o,O),wl(m,h),h=m,f+=m.duration,u++,d=0,w=!0}}else if(p[4]){const O=(" "+p[4]).slice(1);h?m.setByteRange(O,h):m.setByteRange(O)}else if(p[5])m.rawProgramDateTime=(" "+p[5]).slice(1),m.tagList.push(["PROGRAM-DATE-TIME",m.rawProgramDateTime]),v===-1&&(v=l.length);else{if(p=p[0].match(A2),!p){L.warn("No matches on slow regex match for level playlist!");continue}for(E=1;E<p.length&&!(typeof p[E]<"u");E++);const O=(" "+p[E]).slice(1),B=(" "+p[E+1]).slice(1),Y=p[E+2]?(" "+p[E+2]).slice(1):"";switch(O){case"PLAYLIST-TYPE":o.type=B.toUpperCase();break;case"MEDIA-SEQUENCE":u=o.startSN=parseInt(B);break;case"SKIP":{const $=new pe(B);Me(o,$,["RECENTLY-REMOVED-DATERANGES"]);const j=$.decimalInteger("SKIPPED-SEGMENTS");if(H(j)){o.skippedSegments=j;for(let X=j;X--;)l.unshift(null);u+=j}const Q=$.enumeratedString("RECENTLY-REMOVED-DATERANGES");Q&&(o.recentlyRemovedDateranges=Q.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(B),1);break;case"VERSION":o.version=parseInt(B);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(B||Y)&&m.tagList.push(Y?[B,Y]:[B]);break;case"DISCONTINUITY":g++,m.tagList.push(["DIS"]);break;case"GAP":m.gap=!0,m.tagList.push([O]);break;case"BITRATE":m.tagList.push([O,B]);break;case"DATERANGE":{const $=new pe(B);Me(o,$,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Me(o,$,$.clientAttrs);const j=new Zo($,o.dateRanges[$.ID]);j.isValid||o.skippedSegments?o.dateRanges[j.id]=j:L.warn(`Ignoring invalid DATERANGE tag: "${B}"`),m.tagList.push(["EXT-X-DATERANGE",B]);break}case"DEFINE":{{const $=new pe(B);Me(o,$,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in $?T2(o,$,a):gl(o,$,t)}break}case"DISCONTINUITY-SEQUENCE":g=parseInt(B);break;case"KEY":{const $=vl(B,t,o);if($.isSupported()){if($.method==="NONE"){x=void 0;break}x||(x={}),x[$.keyFormat]&&(x=ye({},x)),x[$.keyFormat]=$}else L.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${B}"`);break}case"START":o.startTimeOffset=bl(B);break;case"MAP":{const $=new pe(B);if(Me(o,$,["BYTERANGE","URI"]),m.duration){const j=new Br(r,t);Ll(j,$,s,x),c=j,m.initSegment=c,c.rawProgramDateTime&&!m.rawProgramDateTime&&(m.rawProgramDateTime=c.rawProgramDateTime)}else{const j=m.byteRangeEndOffset;if(j){const Q=m.byteRangeStartOffset;b=`${j-Q}@${Q}`}else b=null;Ll(m,$,s,x),c=m,w=!0}break}case"SERVER-CONTROL":{const $=new pe(B);o.canBlockReload=$.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=$.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&$.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=$.optionalFloat("PART-HOLD-BACK",0),o.holdBack=$.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const $=new pe(B);o.partTarget=$.decimalFloatingPoint("PART-TARGET");break}case"PART":{let $=o.partList;$||($=o.partList=[]);const j=d>0?$[$.length-1]:void 0,Q=d++,X=new pe(B);Me(o,X,["BYTERANGE","URI"]);const ne=new $h(X,m,t,Q,j);$.push(ne),m.duration+=ne.duration;break}case"PRELOAD-HINT":{const $=new pe(B);Me(o,$,["URI"]),o.preloadHint=$;break}case"RENDITION-REPORT":{const $=new pe(B);Me(o,$,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push($);break}default:L.warn(`line parsed but not handled: ${p}`);break}}}h&&!h.relurl?(l.pop(),f-=h.duration,o.partList&&(o.fragmentHint=h)):o.partList&&(wl(m,h),m.cc=g,o.fragmentHint=m,x&&Al(m,x,o));const I=l.length,A=l[0],F=l[I-1];if(f+=o.skippedSegments*o.targetduration,f>0&&I&&F){o.averagetargetduration=f/I;const U=F.sn;o.endSN=U!=="initSegment"?U:0,o.live||(F.endList=!0),A&&(o.startCC=A.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(f+=o.fragmentHint.duration),o.totalduration=f,o.endCC=g,v>0&&I2(l,v),o}}function vl(n,e,t){var s,r;const i=new pe(n);Me(t,i,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const a=(s=i.METHOD)!=null?s:"",o=i.URI,l=i.hexadecimalInteger("IV"),c=i.KEYFORMATVERSIONS,u=(r=i.KEYFORMAT)!=null?r:"identity";o&&i.IV&&!l&&L.error(`Invalid IV: ${i.IV}`);const d=o?tt.resolve(o,e):"",f=(c||"1").split("/").map(Number).filter(Number.isFinite);return new ys(a,d,u,f,l)}function bl(n){const t=new pe(n).decimalFloatingPoint("TIME-OFFSET");return H(t)?t:null}function D2(n,e){let t=(n||"").split(/[ ,]+/).filter(s=>s);["video","audio","text"].forEach(s=>{const r=t.filter(i=>v2(i,s));r.length&&(e[`${s}Codec`]=r.join(","),t=t.filter(i=>r.indexOf(i)===-1))}),e.unknownCodecs=t}function Cl(n,e,t){const s=e[t];s&&(n[t]=s)}function I2(n,e){let t=n[e];for(let s=e;s--;){const r=n[s];if(!r)return;r.programDateTime=t.programDateTime-r.duration*1e3,t=r}}function wl(n,e){n.rawProgramDateTime?n.programDateTime=Date.parse(n.rawProgramDateTime):e!=null&&e.programDateTime&&(n.programDateTime=e.endProgramDateTime),H(n.programDateTime)||(n.programDateTime=null,n.rawProgramDateTime=null)}function Ll(n,e,t,s){n.relurl=e.URI,e.BYTERANGE&&n.setByteRange(e.BYTERANGE),n.level=t,n.sn="initSegment",s&&(n.levelkeys=s),n.initSegment=null}function Al(n,e,t){n.levelkeys=e;const{encryptedFragments:s}=t;(!s.length||s[s.length-1].levelkeys!==e)&&Object.keys(e).some(r=>e[r].isCommonEncryption)&&s.push(n)}var se={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},q={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Dl(n){const{type:e}=n;switch(e){case se.AUDIO_TRACK:return q.AUDIO;case se.SUBTITLE_TRACK:return q.SUBTITLE;default:return q.MAIN}}function Qr(n,e){let t=n.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class R2{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(y.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(y.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,s=t.pLoader,r=t.loader,i=s||r,a=new i(t);return this.loaders[e.type]=a,a}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:s}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:se.MANIFEST,url:s,deliveryDirectives:null})}onLevelLoading(e,t){const{id:s,level:r,pathwayId:i,url:a,deliveryDirectives:o}=t;this.load({id:s,level:r,pathwayId:i,responseType:"text",type:se.LEVEL,url:a,deliveryDirectives:o})}onAudioTrackLoading(e,t){const{id:s,groupId:r,url:i,deliveryDirectives:a}=t;this.load({id:s,groupId:r,level:null,responseType:"text",type:se.AUDIO_TRACK,url:i,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){const{id:s,groupId:r,url:i,deliveryDirectives:a}=t;this.load({id:s,groupId:r,level:null,responseType:"text",type:se.SUBTITLE_TRACK,url:i,deliveryDirectives:a})}load(e){var t;const s=this.hls.config;let r=this.getInternalLoader(e);if(r){const c=r.context;if(c&&c.url===e.url&&c.level===e.level){L.trace("[playlist-loader]: playlist request ongoing");return}L.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}let i;if(e.type===se.MANIFEST?i=s.manifestLoadPolicy.default:i=ye({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),H((t=e.deliveryDirectives)==null?void 0:t.part)){let c;if(e.type===se.LEVEL&&e.level!==null?c=this.hls.levels[e.level].details:e.type===se.AUDIO_TRACK&&e.id!==null?c=this.hls.audioTracks[e.id].details:e.type===se.SUBTITLE_TRACK&&e.id!==null&&(c=this.hls.subtitleTracks[e.id].details),c){const u=c.partTarget,d=c.targetduration;if(u&&d){const f=Math.max(u*3,d*.8)*1e3;i=ye({},i,{maxTimeToFirstByteMs:Math.min(f,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(f,i.maxTimeToFirstByteMs)})}}}const a=i.errorRetry||i.timeoutRetry||{},o={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(c,u,d,f)=>{const g=this.getInternalLoader(d);this.resetInternalLoader(d.type);const h=c.data;if(h.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(c,d,new Error("no EXTM3U delimiter"),f||null,u);return}u.parsing.start=performance.now(),tt.isMediaPlaylist(h)?this.handleTrackOrLevelPlaylist(c,u,d,f||null,g):this.handleMasterPlaylist(c,u,d,f)},onError:(c,u,d,f)=>{this.handleNetworkError(u,d,!1,c,f)},onTimeout:(c,u,d)=>{this.handleNetworkError(u,d,!0,void 0,c)}};r.load(e,o,l)}handleMasterPlaylist(e,t,s,r){const i=this.hls,a=e.data,o=Qr(e,s),l=tt.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,s,l.playlistParsingError,r,t);return}const{contentSteering:c,levels:u,sessionData:d,sessionKeys:f,startTimeOffset:g,variableList:h}=l;this.variableList=h;const{AUDIO:m=[],SUBTITLES:p,"CLOSED-CAPTIONS":E}=tt.parseMasterPlaylistMedia(a,o,l);m.length&&!m.some(v=>!v.url)&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(L.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new pe({}),bitrate:0,url:""})),i.trigger(y.MANIFEST_LOADED,{levels:u,audioTracks:m,subtitles:p,captions:E,contentSteering:c,url:o,stats:t,networkDetails:r,sessionData:d,sessionKeys:f,startTimeOffset:g,variableList:h})}handleTrackOrLevelPlaylist(e,t,s,r,i){const a=this.hls,{id:o,level:l,type:c}=s,u=Qr(e,s),d=0,f=H(l)?l:H(o)?o:0,g=Dl(s),h=tt.parseLevelPlaylist(e.data,u,f,g,d,this.variableList);if(c===se.MANIFEST){const m={attrs:new pe({}),bitrate:0,details:h,name:"",url:u};a.trigger(y.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:u,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),s.levelDetails=h,this.handlePlaylistLoaded(h,e,t,s,r,i)}handleManifestParsingError(e,t,s,r,i){this.hls.trigger(y.ERROR,{type:Z.NETWORK_ERROR,details:k.MANIFEST_PARSING_ERROR,fatal:t.type===se.MANIFEST,url:e.url,err:s,error:s,reason:s.message,response:e,context:t,networkDetails:r,stats:i})}handleNetworkError(e,t,s=!1,r,i){let a=`A network ${s?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${e.type}`;e.type===se.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===se.AUDIO_TRACK||e.type===se.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(a);L.warn(`[playlist-loader]: ${a}`);let l=k.UNKNOWN,c=!1;const u=this.getInternalLoader(e);switch(e.type){case se.MANIFEST:l=s?k.MANIFEST_LOAD_TIMEOUT:k.MANIFEST_LOAD_ERROR,c=!0;break;case se.LEVEL:l=s?k.LEVEL_LOAD_TIMEOUT:k.LEVEL_LOAD_ERROR,c=!1;break;case se.AUDIO_TRACK:l=s?k.AUDIO_TRACK_LOAD_TIMEOUT:k.AUDIO_TRACK_LOAD_ERROR,c=!1;break;case se.SUBTITLE_TRACK:l=s?k.SUBTITLE_TRACK_LOAD_TIMEOUT:k.SUBTITLE_LOAD_ERROR,c=!1;break}u&&this.resetInternalLoader(e.type);const d={type:Z.NETWORK_ERROR,details:l,fatal:c,url:e.url,loader:u,context:e,error:o,networkDetails:t,stats:i};if(r){const f=(t==null?void 0:t.url)||e.url;d.response=ve({url:f,data:void 0},r)}this.hls.trigger(y.ERROR,d)}handlePlaylistLoaded(e,t,s,r,i,a){const o=this.hls,{type:l,level:c,id:u,groupId:d,deliveryDirectives:f}=r,g=Qr(t,r),h=Dl(r),m=typeof r.level=="number"&&h===q.MAIN?c:void 0;if(!e.fragments.length){const E=new Error("No Segments found in Playlist");o.trigger(y.ERROR,{type:Z.NETWORK_ERROR,details:k.LEVEL_EMPTY_ERROR,fatal:!1,url:g,error:E,reason:E.message,response:t,context:r,level:m,parent:h,networkDetails:i,stats:s});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const p=e.playlistParsingError;if(p){o.trigger(y.ERROR,{type:Z.NETWORK_ERROR,details:k.LEVEL_PARSING_ERROR,fatal:!1,url:g,error:p,reason:p.message,response:t,context:r,level:m,parent:h,networkDetails:i,stats:s});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case se.MANIFEST:case se.LEVEL:o.trigger(y.LEVEL_LOADED,{details:e,level:m||0,id:u||0,stats:s,networkDetails:i,deliveryDirectives:f});break;case se.AUDIO_TRACK:o.trigger(y.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:d||"",stats:s,networkDetails:i,deliveryDirectives:f});break;case se.SUBTITLE_TRACK:o.trigger(y.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:d||"",stats:s,networkDetails:i,deliveryDirectives:f});break}}}function Il(n,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=n,e.dispatchEvent(t)}function Rl(n,e){const t=n.mode;if(t==="disabled"&&(n.mode="hidden"),n.cues&&!n.cues.getCueById(e.id))try{if(n.addCue(e),!n.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(s){L.debug(`[texttrack-utils]: ${s}`);try{const r=new self.TextTrackCue(e.startTime,e.endTime,e.text);r.id=e.id,n.addCue(r)}catch(r){L.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${r}`)}}t==="disabled"&&(n.mode=t)}function jt(n){const e=n.mode;if(e==="disabled"&&(n.mode="hidden"),n.cues)for(let t=n.cues.length;t--;)n.removeCue(n.cues[t]);e==="disabled"&&(n.mode=e)}function Jr(n,e,t,s){const r=n.mode;if(r==="disabled"&&(n.mode="hidden"),n.cues&&n.cues.length>0){const i=P2(n.cues,e,t);for(let a=0;a<i.length;a++)(!s||s(i[a]))&&n.removeCue(i[a])}r==="disabled"&&(n.mode=r)}function k2(n,e){if(e<n[0].startTime)return 0;const t=n.length-1;if(e>n[t].endTime)return-1;let s=0,r=t;for(;s<=r;){const i=Math.floor((r+s)/2);if(e<n[i].startTime)r=i-1;else if(e>n[i].startTime&&s<t)s=i+1;else return i}return n[s].startTime-e<e-n[r].startTime?s:r}function P2(n,e,t){const s=[],r=k2(n,e);if(r>-1)for(let i=r,a=n.length;i<a;i++){const o=n[i];if(o.startTime>=e&&o.endTime<=t)s.push(o);else if(o.startTime>t)return s}return s}function xn(n){const e=[];for(let t=0;t<n.length;t++){const s=n[t];(s.kind==="subtitles"||s.kind==="captions")&&s.label&&e.push(n[t])}return e}var ze={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const _2=.25;function ei(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function kl(n,e,t,s,r){let i=new n(e,t,"");try{i.value=s,r&&(i.type=r)}catch{i=new n(e,t,JSON.stringify(r?ve({type:r},s):s))}return i}const vn=(()=>{const n=ei();try{n&&new n(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function ti(n,e){return n.getTime()/1e3-e}function O2(n){return Uint8Array.from(n.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class F2{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(jt(this.id3Track),this.id3Track=null,this.media=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 s=e[t];if(s.kind==="metadata"&&s.label==="id3")return Il(s,this.media),s}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:s,enableID3MetadataCues:r}}}=this;if(!s&&!r)return;const{samples:i}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=ei();if(a)for(let o=0;o<i.length;o++){const l=i[o].type;if(l===ze.emsg&&!s||!r)continue;const c=nl(i[o].data);if(c){const u=i[o].pts;let d=u+i[o].duration;d>vn&&(d=vn),d-u<=0&&(d=u+_2);for(let g=0;g<c.length;g++){const h=c[g];if(!sl(h)){this.updateId3CueEnds(u,l);const m=kl(a,u,d,h,l);m&&this.id3Track.addCue(m)}}}}}updateId3CueEnds(e,t){var s;const r=(s=this.id3Track)==null?void 0:s.cues;if(r)for(let i=r.length;i--;){const a=r[i];a.type===t&&a.startTime<e&&a.endTime===vn&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:s,type:r}){const{id3Track:i,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(i&&(o||l)){let c;r==="audio"?c=u=>u.type===ze.audioId3&&l:r==="video"?c=u=>u.type===ze.emsg&&o:c=u=>u.type===ze.audioId3&&l||u.type===ze.emsg&&o,Jr(i,t,s,c)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:s,id3Track:r}=this,{dateRanges:i}=t,a=Object.keys(i);if(r){const u=Object.keys(s).filter(d=>!a.includes(d));for(let d=u.length;d--;){const f=u[d];Object.keys(s[f].cues).forEach(g=>{r.removeCue(s[f].cues[g])}),delete s[f]}}const o=t.fragments[t.fragments.length-1];if(a.length===0||!H(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=o.programDateTime/1e3-o.start,c=ei();for(let u=0;u<a.length;u++){const d=a[u],f=i[d],g=ti(f.startDate,l),h=s[d],m=(h==null?void 0:h.cues)||{};let p=(h==null?void 0:h.durationKnown)||!1,E=vn;const x=f.endDate;if(x)E=ti(x,l),p=!0;else if(f.endOnNext&&!p){const w=a.reduce((b,I)=>{if(I!==f.id){const A=i[I];if(A.class===f.class&&A.startDate>f.startDate&&(!b||f.startDate<b.startDate))return A}return b},null);w&&(E=ti(w.startDate,l),p=!0)}const v=Object.keys(f.attr);for(let w=0;w<v.length;w++){const b=v[w];if(!Bh(b))continue;const I=m[b];if(I)p&&!h.durationKnown&&(I.endTime=E);else if(c){let A=f.attr[b];Uh(b)&&(A=O2(A));const F=kl(c,g,E,{key:b,data:A},ze.dateRange);F&&(F.id=d,this.id3Track.addCue(F),m[b]=F)}}s[d]={cues:m,dateRange:f,durationKnown:p}}}}class M2{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(e===null)return null;const{holdBack:t,partHoldBack:s,targetduration:r}=e,{liveSyncDuration:i,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig;let c=o&&s||t;(l.liveSyncDuration||l.liveSyncDurationCount||c===0)&&(c=i!==void 0?i:a*r);const u=r;return c+Math.min(this.stallCount*1,u)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency,s=this.levelDetails;if(e===null||t===null||s===null)return null;const r=s.edge,i=e-t-this.edgeStalled,a=r-s.totalduration,o=r-(this.config.lowLatencyMode&&s.partTarget||s.targetduration);return Math.min(Math.max(a,i),o)}get drift(){const{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e,levelDetails:t}=this;if(!e||!t)return 0;const s=e.buffered.length;return(s?e.buffered.end(s-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(y.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(y.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var s;t.details===k.BUFFER_STALLED_ERROR&&(this.stallCount++,(s=this.levelDetails)!=null&&s.live&&L.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;const s=this.computeLatency();if(s===null)return;this._latency=s;const{lowLatencyMode:r,maxLiveSyncPlaybackRate:i}=this.config;if(!r||i===1||!t.live)return;const a=this.targetLatency;if(a===null)return;const o=s-a,l=Math.min(this.maxLatency,a+t.targetduration);if(o<l&&o>.05&&this.forwardBufferLength>1){const u=Math.min(2,Math.max(1,i)),d=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,d))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}const si=["NONE","TYPE-0","TYPE-1",null];function N2(n){return si.indexOf(n)>-1}const bn=["SDR","PQ","HLG"];function B2(n){return!!n&&bn.indexOf(n)>-1}var Cn={No:"",Yes:"YES",v2:"v2"};function Pl(n){const{canSkipUntil:e,canSkipDateRanges:t,age:s}=n,r=s<e/2;return e&&r?t?Cn.v2:Cn.Yes:Cn.No}class _l{constructor(e,t,s){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=s}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class zt{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>!!t).map(t=>t.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return Ol(this._audioGroups,e)}hasSubtitleGroup(e){return Ol(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let s=this._audioGroups;s||(s=this._audioGroups=[]),s.indexOf(t)===-1&&s.push(t)}else if(e==="text"){let s=this._subtitleGroups;s||(s=this._subtitleGroups=[]),s.indexOf(t)===-1&&s.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(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function Ol(n,e){return!e||!n?!1:n.indexOf(e)!==-1}function ni(n,e){const t=e.startPTS;if(H(t)){let s=0,r;e.sn>n.sn?(s=t-n.start,r=n):(s=n.start-t,r=e),r.duration!==s&&(r.duration=s)}else e.sn>n.sn?n.cc===e.cc&&n.minEndPTS?e.start=n.start+(n.minEndPTS-n.start):e.start=n.start+n.duration:e.start=Math.max(n.start-e.duration,0)}function Fl(n,e,t,s,r,i){s-t<=0&&(L.warn("Fragment should have a positive duration",e),s=t+e.duration,i=r+e.duration);let o=t,l=s;const c=e.startPTS,u=e.endPTS;if(H(c)){const p=Math.abs(c-t);H(e.deltaPTS)?e.deltaPTS=Math.max(p,e.deltaPTS):e.deltaPTS=p,o=Math.max(t,c),t=Math.min(t,c),r=Math.min(r,e.startDTS),l=Math.min(s,u),s=Math.max(s,u),i=Math.max(i,e.endDTS)}const d=t-e.start;e.start!==0&&(e.start=t),e.duration=s-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=r,e.endPTS=s,e.minEndPTS=l,e.endDTS=i;const f=e.sn;if(!n||f<n.startSN||f>n.endSN)return 0;let g;const h=f-n.startSN,m=n.fragments;for(m[h]=e,g=h;g>0;g--)ni(m[g],m[g-1]);for(g=h;g<m.length-1;g++)ni(m[g],m[g+1]);return n.fragmentHint&&ni(m[m.length-1],n.fragmentHint),n.PTSKnown=n.alignedSliding=!0,d}function U2(n,e){let t=null;const s=n.fragments;for(let o=s.length-1;o>=0;o--){const l=s[o].initSegment;if(l){t=l;break}}n.fragmentHint&&delete n.fragmentHint.endPTS;let r;G2(n,e,(o,l,c,u)=>{if(e.skippedSegments&&l.cc!==o.cc){const d=o.cc-l.cc;for(let f=c;f<u.length;f++)u[f].cc+=d}H(o.startPTS)&&H(o.endPTS)&&(l.start=l.startPTS=o.startPTS,l.startDTS=o.startDTS,l.maxStartPTS=o.maxStartPTS,l.endPTS=o.endPTS,l.endDTS=o.endDTS,l.minEndPTS=o.minEndPTS,l.duration=o.endPTS-o.startPTS,l.duration&&(r=l),e.PTSKnown=e.alignedSliding=!0),l.elementaryStreams=o.elementaryStreams,l.loader=o.loader,l.stats=o.stats,o.initSegment&&(l.initSegment=o.initSegment,t=o.initSegment)});const i=e.fragments;if(t&&(e.fragmentHint?i.concat(e.fragmentHint):i).forEach(l=>{var c;l&&(!l.initSegment||l.initSegment.relurl===((c=t)==null?void 0:c.relurl))&&(l.initSegment=t)}),e.skippedSegments){if(e.deltaUpdateFailed=i.some(o=>!o),e.deltaUpdateFailed){L.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let o=e.skippedSegments;o--;)i.shift();e.startSN=i[0].sn}else e.canSkipDateRanges&&(e.dateRanges=$2(n.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));e.startCC=e.fragments[0].cc,e.endCC=i[i.length-1].cc}V2(n.partList,e.partList,(o,l)=>{l.elementaryStreams=o.elementaryStreams,l.stats=o.stats}),r?Fl(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):Ml(n,e),i.length&&(e.totalduration=e.edge-i[0].start),e.driftStartTime=n.driftStartTime,e.driftStart=n.driftStart;const a=e.advancedDateTime;if(e.advanced&&a){const o=e.edge;e.driftStart||(e.driftStartTime=a,e.driftStart=o),e.driftEndTime=a,e.driftEnd=o}else e.driftEndTime=n.driftEndTime,e.driftEnd=n.driftEnd,e.advancedDateTime=n.advancedDateTime}function $2(n,e,t){const s=ye({},n);return t&&t.forEach(r=>{delete s[r]}),Object.keys(e).forEach(r=>{const i=new Zo(e[r].attr,s[r]);i.isValid?s[r]=i:L.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[r].attr)}"`)}),s}function V2(n,e,t){if(n&&e){let s=0;for(let r=0,i=n.length;r<=i;r++){const a=n[r],o=e[r+s];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):s--}}}function G2(n,e,t){const s=e.skippedSegments,r=Math.max(n.startSN,e.startSN)-e.startSN,i=(n.fragmentHint?1:0)+(s?e.endSN:Math.min(n.endSN,e.endSN))-e.startSN,a=e.startSN-n.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments;for(let c=r;c<=i;c++){const u=l[a+c];let d=o[c];s&&!d&&c<s&&(d=e.fragments[c]=u),u&&d&&t(u,d,c,o)}}function Ml(n,e){const t=e.startSN+e.skippedSegments-n.startSN,s=n.fragments;t<0||t>=s.length||ri(e,s[t].start)}function ri(n,e){if(e){const t=n.fragments;for(let s=n.skippedSegments;s<t.length;s++)t[s].start+=e;n.fragmentHint&&(n.fragmentHint.start+=e)}}function H2(n,e=1/0){let t=1e3*n.targetduration;if(n.updated){const s=n.fragments;if(s.length&&t*4>e){const i=s[s.length-1].duration*1e3;i<t&&(t=i)}}else t/=2;return Math.round(t)}function K2(n,e,t){if(!(n!=null&&n.details))return null;const s=n.details;let r=s.fragments[e-s.startSN];return r||(r=s.fragmentHint,r&&r.sn===e)?r:e<s.startSN&&t&&t.sn===e?t:null}function Nl(n,e,t){var s;return n!=null&&n.details?Bl((s=n.details)==null?void 0:s.partList,e,t):null}function Bl(n,e,t){if(n)for(let s=n.length;s--;){const r=n[s];if(r.index===t&&r.fragment.sn===e)return r}return null}function Ul(n){n.forEach((e,t)=>{const{details:s}=e;s!=null&&s.fragments&&s.fragments.forEach(r=>{r.level=t})})}function wn(n){switch(n.details){case k.FRAG_LOAD_TIMEOUT:case k.KEY_LOAD_TIMEOUT:case k.LEVEL_LOAD_TIMEOUT:case k.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function $l(n,e){const t=wn(e);return n.default[`${t?"timeout":"error"}Retry`]}function ii(n,e){const t=n.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*n.retryDelayMs,n.maxRetryDelayMs)}function Vl(n){return ve(ve({},n),{errorRetry:null,timeoutRetry:null})}function Ln(n,e,t,s){if(!n)return!1;const r=s==null?void 0:s.code,i=e<n.maxNumRetry&&(W2(r)||!!t);return n.shouldRetry?n.shouldRetry(n,e,t,s,i):i}function W2(n){return n===0&&navigator.onLine===!1||!!n&&(n<400||n>499)}const Gl={search:function(n,e){let t=0,s=n.length-1,r=null,i=null;for(;t<=s;){r=(t+s)/2|0,i=n[r];const a=e(i);if(a>0)t=r+1;else if(a<0)s=r-1;else return i}return null}};function j2(n,e,t){if(e===null||!Array.isArray(n)||!n.length||!H(e))return null;const s=n[0].programDateTime;if(e<(s||0))return null;const r=n[n.length-1].endProgramDateTime;if(e>=(r||0))return null;t=t||0;for(let i=0;i<n.length;++i){const a=n[i];if(q2(e,t,a))return a}return null}function An(n,e,t=0,s=0,r=.005){let i=null;if(n){i=e[n.sn-e[0].sn+1]||null;const o=n.endDTS-t;o>0&&o<15e-7&&(t+=15e-7)}else t===0&&e[0].start===0&&(i=e[0]);if(i&&((!n||n.level===i.level)&&ai(t,s,i)===0||z2(i,n,Math.min(r,s))))return i;const a=Gl.search(e,ai.bind(null,t,s));return a&&(a!==n||!i)?a:i}function z2(n,e,t){if(e&&e.start===0&&e.level<n.level&&(e.endPTS||0)>0){const s=e.tagList.reduce((r,i)=>(i[0]==="INF"&&(r+=parseFloat(i[1])),r),t);return n.start<=s}return!1}function ai(n=0,e=0,t){if(t.start<=n&&t.start+t.duration>n)return 0;const s=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-s<=n?1:t.start-s>n&&t.start?-1:0}function q2(n,e,t){const s=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-s>n}function Y2(n,e){return Gl.search(n,t=>t.cc<e?1:t.cc>e?-1:0)}var De={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},qe={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class X2{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=L.log.bind(L,"[info]:"),this.warn=L.warn.bind(L,"[warning]:"),this.error=L.error.bind(L,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(y.ERROR,this.onError,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(y.ERROR,this.onError,this),e.off(y.ERROR,this.onErrorOut,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===q.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var s,r;if(t.fatal)return;const i=this.hls,a=t.context;switch(t.details){case k.FRAG_LOAD_ERROR:case k.FRAG_LOAD_TIMEOUT:case k.KEY_LOAD_ERROR:case k.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case k.FRAG_PARSING_ERROR:if((s=t.frag)!=null&&s.gap){t.errorAction={action:De.DoNothing,flags:qe.None};return}case k.FRAG_GAP:case k.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=De.SendAlternateToPenaltyBox;return}case k.LEVEL_EMPTY_ERROR:case k.LEVEL_PARSING_ERROR:{var o,l;const c=t.parent===q.MAIN?t.level:i.loadLevel;t.details===k.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,c):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,c))}return;case k.LEVEL_LOAD_ERROR:case k.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case k.AUDIO_TRACK_LOAD_ERROR:case k.AUDIO_TRACK_LOAD_TIMEOUT:case k.SUBTITLE_LOAD_ERROR:case k.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){const c=i.levels[i.loadLevel];if(c&&(a.type===se.AUDIO_TRACK&&c.hasAudioGroup(a.groupId)||a.type===se.SUBTITLE_TRACK&&c.hasSubtitleGroup(a.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=De.SendAlternateToPenaltyBox,t.errorAction.flags=qe.MoveAllAlternatesMatchingHost;return}}return;case k.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const c=i.levels[i.loadLevel],u=c==null?void 0:c.attrs["HDCP-LEVEL"];u?t.errorAction={action:De.SendAlternateToPenaltyBox,flags:qe.MoveAllAlternatesMatchingHDCP,hdcpLevel:u}:this.keySystemError(t)}return;case k.BUFFER_ADD_CODEC_ERROR:case k.REMUX_ALLOC_ERROR:case k.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(r=t.level)!=null?r:i.loadLevel);return;case k.INTERNAL_EXCEPTION:case k.BUFFER_APPENDING_ERROR:case k.BUFFER_FULL_ERROR:case k.LEVEL_SWITCH_ERROR:case k.BUFFER_STALLED_ERROR:case k.BUFFER_SEEK_OVER_HOLE:case k.BUFFER_NUDGE_ON_STALL:t.errorAction={action:De.DoNothing,flags:qe.None};return}t.type===Z.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){const t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){const s=this.hls,r=$l(s.config.playlistLoadPolicy,e),i=this.playlistError++;if(Ln(r,i,wn(e),e.response))return{action:De.RetryRequest,flags:qe.None,retryConfig:r,retryCount:i};const o=this.getLevelSwitchAction(e,t);return r&&(o.retryConfig=r,o.retryCount=i),o}getFragRetryOrSwitchAction(e){const t=this.hls,s=this.getVariantLevelIndex(e.frag),r=t.levels[s],{fragLoadPolicy:i,keyLoadPolicy:a}=t.config,o=$l(e.details.startsWith("key")?a:i,e),l=t.levels.reduce((u,d)=>u+d.fragmentError,0);if(r&&(e.details!==k.FRAG_GAP&&r.fragmentError++,Ln(o,l,wn(e),e.response)))return{action:De.RetryRequest,flags:qe.None,retryConfig:o,retryCount:l};const c=this.getLevelSwitchAction(e,s);return o&&(c.retryConfig=o,c.retryCount=l),c}getLevelSwitchAction(e,t){const s=this.hls;t==null&&(t=s.loadLevel);const r=this.hls.levels[t];if(r){var i,a;const c=e.details;r.loadError++,c===k.BUFFER_APPEND_ERROR&&r.fragmentError++;let u=-1;const{levels:d,loadLevel:f,minAutoLevel:g,maxAutoLevel:h}=s;s.autoLevelEnabled||(s.loadLevel=-1);const m=(i=e.frag)==null?void 0:i.type,E=(m===q.AUDIO&&c===k.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(c===k.BUFFER_ADD_CODEC_ERROR||c===k.BUFFER_APPEND_ERROR))&&d.some(({audioCodec:I})=>r.audioCodec!==I),v=e.sourceBufferName==="video"&&(c===k.BUFFER_ADD_CODEC_ERROR||c===k.BUFFER_APPEND_ERROR)&&d.some(({codecSet:I,audioCodec:A})=>r.codecSet!==I&&r.audioCodec===A),{type:w,groupId:b}=(a=e.context)!=null?a:{};for(let I=d.length;I--;){const A=(I+f)%d.length;if(A!==f&&A>=g&&A<=h&&d[A].loadError===0){var o,l;const F=d[A];if(c===k.FRAG_GAP&&m===q.MAIN&&e.frag){const U=d[A].details;if(U){const O=An(e.frag,U.fragments,e.frag.start);if(O!=null&&O.gap)continue}}else{if(w===se.AUDIO_TRACK&&F.hasAudioGroup(b)||w===se.SUBTITLE_TRACK&&F.hasSubtitleGroup(b))continue;if(m===q.AUDIO&&(o=r.audioGroups)!=null&&o.some(U=>F.hasAudioGroup(U))||m===q.SUBTITLE&&(l=r.subtitleGroups)!=null&&l.some(U=>F.hasSubtitleGroup(U))||E&&r.audioCodec===F.audioCodec||!E&&r.audioCodec!==F.audioCodec||v&&r.codecSet===F.codecSet)continue}u=A;break}}if(u>-1&&s.loadLevel!==u)return e.levelRetry=!0,this.playlistError=0,{action:De.SendAlternateToPenaltyBox,flags:qe.None,nextAutoLevel:u}}return{action:De.SendAlternateToPenaltyBox,flags:qe.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var s;switch((s=t.errorAction)==null?void 0:s.action){case De.DoNothing:break;case De.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==k.FRAG_GAP?t.fatal=!0:/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());break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,s=e.errorAction;if(!s)return;const{flags:r,hdcpLevel:i,nextAutoLevel:a}=s;switch(r){case qe.None:this.switchLevel(e,a);break;case qe.MoveAllAlternatesMatchingHDCP:i&&(t.maxHdcpLevel=si[si.indexOf(i)-1],s.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}s.resolved||this.switchLevel(e,a)}switchLevel(e,t){t!==void 0&&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)}}class oi{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=L.log.bind(L,`${t}:`),this.warn=L.warn.bind(L,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,s){const r=t==null?void 0:t.renditionReports;if(r){let i=-1;for(let a=0;a<r.length;a++){const o=r[a];let l;try{l=new self.URL(o.URI,t.url).href}catch(c){L.warn(`Could not construct new URL for Rendition Report: ${c}`),l=o.URI||""}if(l===e){i=a;break}else l===e.substring(0,l.length)&&(i=a)}if(i!==-1){const a=r[i],o=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn);let l=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){const u=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&u>t.partTarget&&(l+=1)}const c=s&&Pl(s);return new _l(o,l>=0?l:void 0,c)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,s){const{details:r,stats:i}=t,a=self.performance.now(),o=i.loading.first?Math.max(0,a-i.loading.first):0;if(r.advancedDateTime=Date.now()-o,r.live||s!=null&&s.live){if(r.reloaded(s),s&&this.log(`live playlist ${e} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:r.updated?"UPDATED":"MISSED"}`),s&&r.fragments.length>0&&U2(s,r),!this.canLoad||!r.live)return;let l,c,u;if(r.canBlockReload&&r.endSN&&r.advanced){const p=this.hls.config.lowLatencyMode,E=r.lastPartSn,x=r.endSN,v=r.lastPartIndex,w=v!==-1,b=E===x,I=p?0:v;w?(c=b?x+1:E,u=b?I:v+1):c=x+1;const A=r.age,F=A+r.ageHeader;let U=Math.min(F-r.partTarget,r.targetduration*1.5);if(U>0){if(s&&U>s.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${s.tuneInGoal} to: ${U} with playlist age: ${r.age}`),U=0;else{const O=Math.floor(U/r.targetduration);if(c+=O,u!==void 0){const B=Math.round(U%r.targetduration/r.partTarget);u+=B}this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${A.toFixed(2)}s goal: ${U} skip sn ${O} to part ${u}`)}r.tuneInGoal=U}if(l=this.getDeliveryDirectives(r,t.deliveryDirectives,c,u),p||!b){this.loadPlaylist(l);return}}else(r.canBlockReload||r.canSkipUntil)&&(l=this.getDeliveryDirectives(r,t.deliveryDirectives,c,u));const d=this.hls.mainForwardBufferInfo,f=d?d.end-d.len:0,g=(r.edge-f)*1e3,h=H2(r,g);r.updated&&a>this.requestScheduled+h&&(this.requestScheduled=i.loading.start),c!==void 0&&r.canBlockReload?this.requestScheduled=i.loading.first+h-(r.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+h<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=h);let m=this.requestScheduled-a;m=Math.max(0,m),this.log(`reload live playlist ${e} in ${Math.round(m)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),m)}else this.clearTimer()}getDeliveryDirectives(e,t,s,r){let i=Pl(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(s=t.msn,r=t.part,i=Cn.No),new _l(s,r,i)}checkRetry(e){const t=e.details,s=wn(e),r=e.errorAction,{action:i,retryCount:a=0,retryConfig:o}=r||{},l=!!r&&!!o&&(i===De.RetryRequest||!r.resolved&&i===De.SendAlternateToPenaltyBox);if(l){var c;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(s&&(c=e.context)!=null&&c.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const u=ii(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),u),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${u}ms`)}e.levelRetry=!0,r.resolved=!0}return l}}class qt{constructor(e,t=0,s=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_=s}sample(e,t){const s=Math.pow(this.alpha_,e);this.estimate_=t*(1-s)+s*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 Z2{constructor(e,t,s,r=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_=s,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new qt(e),this.fast_=new qt(t),this.defaultTTFB_=r,this.ttfb_=new qt(e)}update(e,t){const{slow_:s,fast_:r,ttfb_:i}=this;s.halfLife!==e&&(this.slow_=new qt(e,s.getEstimate(),s.getTotalWeight())),r.halfLife!==t&&(this.fast_=new qt(t,r.getEstimate(),r.getTotalWeight())),i.halfLife!==e&&(this.ttfb_=new qt(e,i.getEstimate(),i.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const s=8*t,r=e/1e3,i=s/r;this.fast_.sample(r,i),this.slow_.sample(r,i)}sampleTTFB(e){const t=e/1e3,s=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(s,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}const Hl={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},Kl={};function Q2(n,e,t,s,r,i){const a=n.audioCodec?n.audioGroups:null,o=i==null?void 0:i.audioCodec,l=i==null?void 0:i.channels,c=l?parseInt(l):o?1/0:2;let u=null;if(a!=null&&a.length)try{a.length===1&&a[0]?u=e.groups[a[0]].channels:u=a.reduce((d,f)=>{if(f){const g=e.groups[f];if(!g)throw new Error(`Audio track group ${f} not found`);Object.keys(g.channels).forEach(h=>{d[h]=(d[h]||0)+g.channels[h]})}return d},{2:0})}catch{return!0}return n.videoCodec!==void 0&&(n.width>1920&&n.height>1088||n.height>1920&&n.width>1088||n.frameRate>Math.max(s,30)||n.videoRange!=="SDR"&&n.videoRange!==t||n.bitrate>Math.max(r,8e6))||!!u&&H(c)&&Object.keys(u).some(d=>parseInt(d)>c)}function J2(n,e,t){const s=n.videoCodec,r=n.audioCodec;if(!s||!r||!t)return Promise.resolve(Hl);const i={width:n.width,height:n.height,bitrate:Math.ceil(Math.max(n.bitrate*.9,n.averageBitrate)),framerate:n.frameRate||30},a=n.videoRange;a!=="SDR"&&(i.transferFunction=a.toLowerCase());const o=s.split(",").map(l=>({type:"media-source",video:ve(ve({},i),{},{contentType:Es(l,"video")})}));return r&&n.audioGroups&&n.audioGroups.forEach(l=>{var c;l&&((c=e.groups[l])==null||c.tracks.forEach(u=>{if(u.groupId===l){const d=u.channels||"",f=parseFloat(d);H(f)&&f>2&&o.push.apply(o,r.split(",").map(g=>({type:"media-source",audio:{contentType:Es(g,"audio"),channels:""+f}})))}}))}),Promise.all(o.map(l=>{const c=ep(l);return Kl[c]||(Kl[c]=t.decodingInfo(l))})).then(l=>({supported:!l.some(c=>!c.supported),configurations:o,decodingInfoResults:l})).catch(l=>({supported:!1,configurations:o,decodingInfoResults:[],error:l}))}function ep(n){const{audio:e,video:t}=n,s=t||e;if(s){const r=s.contentType.split('"')[1];if(t)return`r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${r}_${Math.ceil(t.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${r}`}return""}function tp(){if(typeof matchMedia=="function"){const n=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(n.media!==e.media)return n.matches===!0}return!1}function sp(n,e){let t=!1,s=[];return n&&(t=n!=="SDR",s=[n]),e&&(s=e.allowedVideoRanges||bn.slice(0),t=e.preferHDR!==void 0?e.preferHDR:tp(),t?s=s.filter(r=>r!=="SDR"):s=["SDR"]),{preferHDR:t,allowedVideoRanges:s}}function np(n,e,t,s,r){const i=Object.keys(n),a=s==null?void 0:s.channels,o=s==null?void 0:s.audioCodec,l=a&&parseInt(a)===2;let c=!0,u=!1,d=1/0,f=1/0,g=1/0,h=0,m=[];const{preferHDR:p,allowedVideoRanges:E}=sp(e,r);for(let b=i.length;b--;){const I=n[i[b]];c=I.channels[2]>0,d=Math.min(d,I.minHeight),f=Math.min(f,I.minFramerate),g=Math.min(g,I.minBitrate);const A=E.filter(F=>I.videoRanges[F]>0);A.length>0&&(u=!0,m=A)}d=H(d)?d:0,f=H(f)?f:0;const x=Math.max(1080,d),v=Math.max(30,f);return g=H(g)?g:t,t=Math.max(g,t),u||(e=void 0,m=[]),{codecSet:i.reduce((b,I)=>{const A=n[I];if(I===b)return b;if(A.minBitrate>t)return ct(I,`min bitrate of ${A.minBitrate} > current estimate of ${t}`),b;if(!A.hasDefaultAudio)return ct(I,"no renditions with default or auto-select sound found"),b;if(o&&I.indexOf(o.substring(0,4))%5!==0)return ct(I,`audio codec preference "${o}" not found`),b;if(a&&!l){if(!A.channels[a])return ct(I,`no renditions with ${a} channel sound found (channels options: ${Object.keys(A.channels)})`),b}else if((!o||l)&&c&&A.channels[2]===0)return ct(I,"no renditions with stereo sound found"),b;return A.minHeight>x?(ct(I,`min resolution of ${A.minHeight} > maximum of ${x}`),b):A.minFramerate>v?(ct(I,`min framerate of ${A.minFramerate} > maximum of ${v}`),b):m.some(F=>A.videoRanges[F]>0)?A.maxScore<h?(ct(I,`max score of ${A.maxScore} < selected max of ${h}`),b):b&&(Sn(I)>=Sn(b)||A.fragmentError>n[b].fragmentError)?b:(h=A.maxScore,I):(ct(I,`no variants with VIDEO-RANGE of ${JSON.stringify(m)} found`),b)},void 0),videoRanges:m,preferHDR:p,minFramerate:f,minBitrate:g}}function ct(n,e){L.log(`[abr] start candidates with "${n}" ignored because ${e}`)}function rp(n){return n.reduce((e,t)=>{let s=e.groups[t.groupId];s||(s=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),s.tracks.push(t);const r=t.channels||"2";return s.channels[r]=(s.channels[r]||0)+1,s.hasDefault=s.hasDefault||t.default,s.hasAutoSelect=s.hasAutoSelect||t.autoselect,s.hasDefault&&(e.hasDefaultAudio=!0),s.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function ip(n,e,t,s){return n.slice(t,s+1).reduce((r,i)=>{if(!i.codecSet)return r;const a=i.audioGroups;let o=r[i.codecSet];o||(r[i.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,i.bitrate);const l=Math.min(i.height,i.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,i.frameRate),o.maxScore=Math.max(o.maxScore,i.score),o.fragmentError+=i.fragmentError,o.videoRanges[i.videoRange]=(o.videoRanges[i.videoRange]||0)+1,a&&a.forEach(c=>{if(!c)return;const u=e.groups[c];u&&(o.hasDefaultAudio=o.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(d=>{o.channels[d]=(o.channels[d]||0)+u.channels[d]}))}),r},{})}function st(n,e,t){if("attrs"in n){const s=e.indexOf(n);if(s!==-1)return s}for(let s=0;s<e.length;s++){const r=e[s];if(Ot(n,r,t))return s}return-1}function Ot(n,e,t){const{groupId:s,name:r,lang:i,assocLang:a,default:o}=n,l=n.forced;return(s===void 0||e.groupId===s)&&(r===void 0||e.name===r)&&(i===void 0||e.lang===i)&&(i===void 0||e.assocLang===a)&&(o===void 0||e.default===o)&&(l===void 0||e.forced===l)&&(!("characteristics"in n)||ap(n.characteristics||"",e.characteristics))&&(t===void 0||t(n,e))}function ap(n,e=""){const t=n.split(","),s=e.split(",");return t.length===s.length&&!t.some(r=>s.indexOf(r)===-1)}function Ft(n,e){const{audioCodec:t,channels:s}=n;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(s===void 0||s===(e.channels||"2"))}function op(n,e,t,s,r){const i=e[s],o=e.reduce((f,g,h)=>{const m=g.uri;return(f[m]||(f[m]=[])).push(h),f},{})[i.uri];o.length>1&&(s=Math.max.apply(Math,o));const l=i.videoRange,c=i.frameRate,u=i.codecSet.substring(0,4),d=Wl(e,s,f=>{if(f.videoRange!==l||f.frameRate!==c||f.codecSet.substring(0,4)!==u)return!1;const g=f.audioGroups,h=t.filter(m=>!g||g.indexOf(m.groupId)!==-1);return st(n,h,r)>-1});return d>-1?d:Wl(e,s,f=>{const g=f.audioGroups,h=t.filter(m=>!g||g.indexOf(m.groupId)!==-1);return st(n,h,r)>-1})}function Wl(n,e,t){for(let s=e;s>-1;s--)if(t(n[s]))return s;for(let s=e+1;s<n.length;s++)if(t(n[s]))return s;return-1}class lp{constructor(e){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.bwEstimator=void 0,this._abandonRulesCheck=()=>{const{fragCurrent:t,partCurrent:s,hls:r}=this,{autoLevelEnabled:i,media:a}=r;if(!t||!a)return;const o=performance.now(),l=s?s.stats:t.stats,c=s?s.duration:t.duration,u=o-l.loading.start,d=r.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||t.level<=d){this.clearTimer(),this._nextAutoLevel=-1;return}if(!i||a.paused||!a.playbackRate||!a.readyState)return;const f=r.mainForwardBufferInfo;if(f===null)return;const g=this.bwEstimator.getEstimateTTFB(),h=Math.abs(a.playbackRate);if(u<=Math.max(g,1e3*(c/(h*2))))return;const m=f.len/h,p=l.loading.first?l.loading.first-l.loading.start:-1,E=l.loaded&&p>-1,x=this.getBwEstimate(),v=r.levels,w=v[t.level],b=l.total||Math.max(l.loaded,Math.round(c*w.averageBitrate/8));let I=E?u-p:u;I<1&&E&&(I=Math.min(u,l.loaded*8/x));const A=E?l.loaded*1e3/I:0,F=A?(b-l.loaded)/A:b*8/x+g/1e3;if(F<=m)return;const U=A?A*8:x;let O=Number.POSITIVE_INFINITY,B;for(B=t.level-1;B>d;B--){const $=v[B].maxBitrate;if(O=this.getTimeToLoadFrag(g/1e3,U,c*$,!v[B].details),O<m)break}if(O>=F||O>c*10)return;r.nextLoadLevel=r.nextAutoLevel=B,E?this.bwEstimator.sample(u-Math.min(g,p),l.loaded):this.bwEstimator.sampleTTFB(u);const Y=v[B].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>Y&&this.resetEstimator(Y),this.clearTimer(),L.warn(`[abr] Fragment ${t.sn}${s?" part "+s.index:""} of level ${t.level} is loading too slowly;
|
|
40
|
+
Time to underbuffer: ${m.toFixed(3)} s
|
|
41
|
+
Estimated load time for current fragment: ${F.toFixed(3)} s
|
|
42
|
+
Estimated load time for down switch fragment: ${O.toFixed(3)} s
|
|
43
|
+
TTFB estimate: ${p|0} ms
|
|
44
|
+
Current BW estimate: ${H(x)?x|0:"Unknown"} bps
|
|
45
|
+
New BW estimate: ${this.getBwEstimate()|0} bps
|
|
46
|
+
Switching to level ${B} @ ${Y|0} bps`),r.trigger(y.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:s,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(L.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 Z2(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(y.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const s=t.frag;if(!this.ignoreFragment(s)){if(!s.bitrateTest){var r;this.fragCurrent=s,this.partCurrent=(r=t.part)!=null?r: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 k.BUFFER_ADD_CODEC_ERROR:case k.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case k.FRAG_LOAD_TIMEOUT:{const s=t.frag,{fragCurrent:r,partCurrent:i}=this;if(s&&r&&s.sn===r.sn&&s.level===r.level){const a=performance.now(),o=i?i.stats:s.stats,l=a-o.loading.start,c=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&c>-1){const d=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(d,c),o.loaded)}else this.bwEstimator.sampleTTFB(l)}break}}}getTimeToLoadFrag(e,t,s,r){const i=e+s/t,a=r?this.lastLevelLoadSec:0;return i+a}onLevelLoaded(e,t){const s=this.hls.config,{loading:r}=t.stats,i=r.end-r.start;H(i)&&(this.lastLevelLoadSec=i/1e3),t.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)}onFragLoaded(e,{frag:t,part:s}){const r=s?s.stats:t.stats;if(t.type===q.MAIN&&this.bwEstimator.sampleTTFB(r.loading.first-r.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const i=s?s.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+r.loaded,l=(a.loaded?a.loaded.duration:0)+i;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){const i={stats:r,frag:t,part:s,id:t.type};this.onFragBuffered(y.FRAG_BUFFERED,i),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:s,part:r}=t,i=r!=null&&r.stats.loaded?r.stats:s.stats;if(i.aborted||this.ignoreFragment(s))return;const a=i.parsing.end-i.loading.start-Math.min(i.loading.first-i.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,i.loaded),i.bwEstimate=this.getBwEstimate(),s.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==q.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,s=this.getBwEstimate(),r=this.hls.config.maxStarvationDelay,i=this.findBestLevel(s,t,e,0,r,1,1);if(i>-1)return i;const a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return L.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,s=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(e!==-1&&(!s||!r||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const i=s&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const a=this.hls.levels;if(a.length>Math.max(e,i)&&a[e].loadError<=a[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:s}=this,{maxAutoLevel:r,config:i,minAutoLevel:a}=s,o=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),c=this.getStarvationDelay();let u=i.abrBandWidthFactor,d=i.abrBandWidthUpFactor;if(c){const p=this.findBestLevel(l,a,r,c,0,u,d);if(p>=0)return p}let f=o?Math.min(o,i.maxStarvationDelay):i.maxStarvationDelay;if(!c){const p=this.bitrateTestDelay;p&&(f=(o?Math.min(o,i.maxLoadingDelay):i.maxLoadingDelay)-p,L.info(`[abr] bitrate test took ${Math.round(1e3*p)}ms, set first fragment max fetchDuration to ${Math.round(1e3*f)} ms`),u=d=1)}const g=this.findBestLevel(l,a,r,c,f,u,d);if(L.info(`[abr] ${c?"rebuffering expected":"buffer is empty"}, optimal quality level ${g}`),g>-1)return g;const h=s.levels[a],m=s.levels[s.loadLevel];return(h==null?void 0:h.bitrate)<(m==null?void 0:m.bitrate)?a:s.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const s=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,r=e.mainForwardBufferInfo;return(r?r.len:0)/s}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,s,r,i,a,o){var l;const c=r+i,u=this.lastLoadedFragLevel,d=u===-1?this.hls.firstLevel:u,{fragCurrent:f,partCurrent:g}=this,{levels:h,allAudioTracks:m,loadLevel:p,config:E}=this.hls;if(h.length===1)return 0;const x=h[d],v=!!(x!=null&&(l=x.details)!=null&&l.live),w=p===-1||u===-1;let b,I="SDR",A=(x==null?void 0:x.frameRate)||0;const{audioPreference:F,videoPreference:U}=E,O=this.audioTracksByGroup||(this.audioTracksByGroup=rp(m));if(w){if(this.firstSelection!==-1)return this.firstSelection;const Q=this.codecTiers||(this.codecTiers=ip(h,O,t,s)),X=np(Q,I,e,F,U),{codecSet:ne,videoRanges:ue,minFramerate:W,minBitrate:G,preferHDR:ie}=X;b=ne,I=ie?ue[ue.length-1]:ue[0],A=W,e=Math.max(e,G),L.log(`[abr] picked start tier ${JSON.stringify(X)}`)}else b=x==null?void 0:x.codecSet,I=x==null?void 0:x.videoRange;const B=g?g.duration:f?f.duration:0,Y=this.bwEstimator.getEstimateTTFB()/1e3,$=[];for(let Q=s;Q>=t;Q--){var j;const X=h[Q],ne=Q>d;if(!X)continue;if(E.useMediaCapabilities&&!X.supportedResult&&!X.supportedPromise){const Ee=navigator.mediaCapabilities;typeof(Ee==null?void 0:Ee.decodingInfo)=="function"&&Q2(X,O,I,A,e,F)?(X.supportedPromise=J2(X,O,Ee),X.supportedPromise.then(we=>{if(!this.hls)return;X.supportedResult=we;const Ie=this.hls.levels,We=Ie.indexOf(X);we.error?L.warn(`[abr] MediaCapabilities decodingInfo error: "${we.error}" for level ${We} ${JSON.stringify(we)}`):we.supported||(L.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${We} ${JSON.stringify(we)}`),We>-1&&Ie.length>1&&(L.log(`[abr] Removing unsupported level ${We}`),this.hls.removeLevel(We)))})):X.supportedResult=Hl}if(b&&X.codecSet!==b||I&&X.videoRange!==I||ne&&A>X.frameRate||!ne&&A>0&&A<X.frameRate||X.supportedResult&&!((j=X.supportedResult.decodingInfoResults)!=null&&j[0].smooth)){$.push(Q);continue}const ue=X.details,W=(g?ue==null?void 0:ue.partTarget:ue==null?void 0:ue.averagetargetduration)||B;let G;ne?G=o*e:G=a*e;const ie=B&&r>=B*2&&i===0?h[Q].averageBitrate:h[Q].maxBitrate,te=this.getTimeToLoadFrag(Y,G,ie*W,ue===void 0);if(G>=ie&&(Q===u||X.loadError===0&&X.fragmentError===0)&&(te<=Y||!H(te)||v&&!this.bitrateTestDelay||te<c)){const Ee=this.forcedAutoLevel;return Q!==p&&(Ee===-1||Ee!==p)&&($.length&&L.trace(`[abr] Skipped level(s) ${$.join(",")} of ${s} max with CODECS and VIDEO-RANGE:"${h[$[0]].codecs}" ${h[$[0]].videoRange}; not compatible with "${x.codecs}" ${I}`),L.info(`[abr] switch candidate:${d}->${Q} adjustedbw(${Math.round(G)})-bitrate=${Math.round(G-ie)} ttfb:${Y.toFixed(1)} avgDuration:${W.toFixed(1)} maxFetchDuration:${c.toFixed(1)} fetchDuration:${te.toFixed(1)} firstSelection:${w} codecSet:${b} videoRange:${I} hls.loadLevel:${p}`)),w&&(this.firstSelection=Q),Q}}return-1}set nextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:s}=this.hls,r=Math.min(Math.max(e,s),t);this._nextAutoLevel!==r&&(this.nextAutoLevelKey="",this._nextAutoLevel=r)}}class cp{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}var be={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class up{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(y.BUFFER_APPENDED,this.onBufferAppended,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(y.BUFFER_APPENDED,this.onBufferAppended,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const s=this.activePartLists[t];if(s)for(let r=s.length;r--;){const i=s[r];if(!i)break;const a=i.end;if(i.start<=e&&a!==null&&e<=a)return i}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:s}=this,r=Object.keys(s);for(let i=r.length;i--;){const a=s[r[i]];if((a==null?void 0:a.body.type)===t&&a.buffered){const o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,s,r){this.timeRanges&&(this.timeRanges[e]=t);const i=(r==null?void 0:r.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o||i>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===s&&this.removeFragment(o.body);return}const l=o.range[e];l&&l.time.some(c=>{const u=!this.isTimeBuffered(c.startPTS,c.endPTS,t);return u&&this.removeFragment(o.body),u})})}detectPartialFragments(e){const t=this.timeRanges,{frag:s,part:r}=e;if(!t||s.sn==="initSegment")return;const i=Yt(s),a=this.fragments[i];if(!a||a.buffered&&s.gap)return;const o=!s.relurl;Object.keys(t).forEach(l=>{const c=s.elementaryStreams[l];if(!c)return;const u=t[l],d=o||c.partial===!0;a.range[l]=this.getBufferedTimes(s,r,d,u)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=s.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),Dn(a)||this.removeParts(s.sn-1,s.type)):this.removeFragment(a.body)}removeParts(e,t){const s=this.activePartLists[t];s&&(this.activePartLists[t]=s.filter(r=>r.fragment.sn>=e))}fragBuffered(e,t){const s=Yt(e);let r=this.fragments[s];!r&&t&&(r=this.fragments[s]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,r.buffered=!0)}getBufferedTimes(e,t,s,r){const i={time:[],partial:s},a=e.start,o=e.end,l=e.minEndPTS||o,c=e.maxStartPTS||a;for(let u=0;u<r.length;u++){const d=r.start(u)-this.bufferPadding,f=r.end(u)+this.bufferPadding;if(c>=d&&l<=f){i.time.push({startPTS:Math.max(a,r.start(u)),endPTS:Math.min(o,r.end(u))});break}else if(a<f&&o>d){const g=Math.max(a,r.start(u)),h=Math.min(o,r.end(u));h>g&&(i.partial=!0,i.time.push({startPTS:g,endPTS:h}))}else if(o<=d)break}return i}getPartialFragment(e){let t=null,s,r,i,a=0;const{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(c=>{const u=l[c];u&&Dn(u)&&(r=u.body.start-o,i=u.body.end+o,e>=r&&e<=i&&(s=Math.min(e-r,i-e),a<=s&&(t=u.body,a=s)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||Dn(t))}getState(e){const t=Yt(e),s=this.fragments[t];return s?s.buffered?Dn(s)?be.PARTIAL:be.OK:be.APPENDING:be.NOT_LOADED}isTimeBuffered(e,t,s){let r,i;for(let a=0;a<s.length;a++){if(r=s.start(a)-this.bufferPadding,i=s.end(a)+this.bufferPadding,e>=r&&t<=i)return!0;if(t<=r)return!1}return!1}onFragLoaded(e,t){const{frag:s,part:r}=t;if(s.sn==="initSegment"||s.bitrateTest)return;const i=r?null:t,a=Yt(s);this.fragments[a]={body:s,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:s,part:r,timeRanges:i}=t;if(s.sn==="initSegment")return;const a=s.type;if(r){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(r)}this.timeRanges=i,Object.keys(i).forEach(o=>{const l=i[o];this.detectEvictedFragments(o,l,a,r)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=Yt(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,s,r,i){r&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o)return;const l=o.body;l.type!==s||r&&!l.gap||l.start<t&&l.end>e&&(o.buffered||i)&&this.removeFragment(l)})}removeFragment(e){const t=Yt(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const s=this.activePartLists[e.type];if(s){const r=e.sn;this.activePartLists[e.type]=s.filter(i=>i.fragment.sn!==r)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Dn(n){var e,t,s;return n.buffered&&(n.body.gap||((e=n.range.video)==null?void 0:e.partial)||((t=n.range.audio)==null?void 0:t.partial)||((s=n.range.audiovideo)==null?void 0:s.partial))}function Yt(n){return`${n.type}_${n.level}_${n.sn}`}const dp={length:0,start:()=>0,end:()=>0};class de{static isBuffered(e,t){try{if(e){const s=de.getBuffered(e);for(let r=0;r<s.length;r++)if(t>=s.start(r)&&t<=s.end(r))return!0}}catch{}return!1}static bufferInfo(e,t,s){try{if(e){const r=de.getBuffered(e),i=[];let a;for(a=0;a<r.length;a++)i.push({start:r.start(a),end:r.end(a)});return this.bufferedInfo(i,t,s)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,s){t=Math.max(0,t),e.sort(function(c,u){const d=c.start-u.start;return d||u.end-c.end});let r=[];if(s)for(let c=0;c<e.length;c++){const u=r.length;if(u){const d=r[u-1].end;e[c].start-d<s?e[c].end>d&&(r[u-1].end=e[c].end):r.push(e[c])}else r.push(e[c])}else r=e;let i=0,a,o=t,l=t;for(let c=0;c<r.length;c++){const u=r[c].start,d=r[c].end;if(t+s>=u&&t<d)o=u,l=d,i=l-t;else if(t+s<u){a=u;break}}return{len:i,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return L.log("failed to get media.buffered",t),dp}}}class li{constructor(e,t,s,r=0,i=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=In(),this.buffering={audio:In(),video:In(),audiovideo:In()},this.level=e,this.sn=t,this.id=s,this.size=r,this.part=i,this.partial=a}}function In(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Rn(n,e){for(let s=0,r=n.length;s<r;s++){var t;if(((t=n[s])==null?void 0:t.cc)===e)return n[s]}return null}function fp(n,e,t){return!!(e&&(t.endCC>t.startCC||n&&n.cc<t.startCC))}function hp(n,e){const t=n.fragments,s=e.fragments;if(!s.length||!t.length){L.log("No fragments to align");return}const r=Rn(t,s[0].cc);if(!r||r&&!r.startPTS){L.log("No frag in previous level to align on");return}return r}function jl(n,e){if(n){const t=n.start+e;n.start=n.startPTS=t,n.endPTS=t+n.duration}}function zl(n,e){const t=e.fragments;for(let s=0,r=t.length;s<r;s++)jl(t[s],n);e.fragmentHint&&jl(e.fragmentHint,n),e.alignedSliding=!0}function pp(n,e,t){e&&(gp(n,t,e),!t.alignedSliding&&e&&kn(t,e),!t.alignedSliding&&e&&!t.skippedSegments&&Ml(e,t))}function gp(n,e,t){if(fp(n,t,e)){const s=hp(t,e);s&&H(s.start)&&(L.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),zl(s.start,e))}}function kn(n,e){if(!n.hasProgramDateTime||!e.hasProgramDateTime)return;const t=n.fragments,s=e.fragments;if(!t.length||!s.length)return;let r,i;const a=Math.min(e.endCC,n.endCC);e.startCC<a&&n.startCC<a&&(r=Rn(s,a),i=Rn(t,a)),(!r||!i)&&(r=s[Math.floor(s.length/2)],i=Rn(t,r.cc)||t[Math.floor(t.length/2)]);const o=r.programDateTime,l=i.programDateTime;if(!o||!l)return;const c=(l-o)/1e3-(i.start-r.start);zl(c,n)}const ql=Math.pow(2,17);class mp{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 s=e.url;if(!s)return Promise.reject(new ut({type:Z.NETWORK_ERROR,details:k.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${s?"part list":"url"}`),networkDetails:null}));this.abort();const r=this.config,i=r.fLoader,a=r.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(g=>g[0]==="GAP")){l(Xl(e));return}else e.gap=!1;const c=this.loader=e.loader=i?new i(r):new a(r),u=Yl(e),d=Vl(r.fragLoadPolicy.default),f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:ql};e.stats=c.stats,c.load(u,f,{onSuccess:(g,h,m,p)=>{this.resetLoader(e,c);let E=g.data;m.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(E.slice(0,16)),E=E.slice(16)),o({frag:e,part:null,payload:E,networkDetails:p})},onError:(g,h,m,p)=>{this.resetLoader(e,c),l(new ut({type:Z.NETWORK_ERROR,details:k.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:ve({url:s,data:void 0},g),error:new Error(`HTTP Error ${g.code} ${g.text}`),networkDetails:m,stats:p}))},onAbort:(g,h,m)=>{this.resetLoader(e,c),l(new ut({type:Z.NETWORK_ERROR,details:k.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:m,stats:g}))},onTimeout:(g,h,m)=>{this.resetLoader(e,c),l(new ut({type:Z.NETWORK_ERROR,details:k.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${f.timeout}ms`),networkDetails:m,stats:g}))},onProgress:(g,h,m,p)=>{t&&t({frag:e,part:null,payload:m,networkDetails:p})}})})}loadPart(e,t,s){this.abort();const r=this.config,i=r.fLoader,a=r.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(Xl(e,t));return}const c=this.loader=e.loader=i?new i(r):new a(r),u=Yl(e,t),d=Vl(r.fragLoadPolicy.default),f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:ql};t.stats=c.stats,c.load(u,f,{onSuccess:(g,h,m,p)=>{this.resetLoader(e,c),this.updateStatsFromPart(e,t);const E={frag:e,part:t,payload:g.data,networkDetails:p};s(E),o(E)},onError:(g,h,m,p)=>{this.resetLoader(e,c),l(new ut({type:Z.NETWORK_ERROR,details:k.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:ve({url:u.url,data:void 0},g),error:new Error(`HTTP Error ${g.code} ${g.text}`),networkDetails:m,stats:p}))},onAbort:(g,h,m)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,c),l(new ut({type:Z.NETWORK_ERROR,details:k.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:m,stats:g}))},onTimeout:(g,h,m)=>{this.resetLoader(e,c),l(new ut({type:Z.NETWORK_ERROR,details:k.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${f.timeout}ms`),networkDetails:m,stats:g}))}})})}updateStatsFromPart(e,t){const s=e.stats,r=t.stats,i=r.total;if(s.loaded+=r.loaded,i){const l=Math.round(e.duration/t.duration),c=Math.min(Math.round(s.loaded/i),l),d=(l-c)*Math.round(s.loaded/c);s.total=s.loaded+d}else s.total=Math.max(s.loaded,s.total);const a=s.loading,o=r.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function Yl(n,e=null){const t=e||n,s={frag:n,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},r=t.byteRangeStartOffset,i=t.byteRangeEndOffset;if(H(r)&&H(i)){var a;let o=r,l=i;if(n.sn==="initSegment"&&((a=n.decryptdata)==null?void 0:a.method)==="AES-128"){const c=i-r;c%16&&(l=i+(16-c%16)),r!==0&&(s.resetIV=!0,o=r-16)}s.rangeStart=o,s.rangeEnd=l}return s}function Xl(n,e){const t=new Error(`GAP ${n.gap?"tag":"attribute"} found`),s={type:Z.MEDIA_ERROR,details:k.FRAG_GAP,fatal:!1,frag:n,error:t,networkDetails:null};return e&&(s.part=e),(e||n).stats.aborted=!0,new ut(s)}class ut extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class yp{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class Ep{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function Sp(n){const e=n.byteLength,t=e&&new DataView(n.buffer).getUint8(e-1);return t?Pt(n,0,e-t):n}class Tp{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),s=new Uint32Array(4);for(let r=0;r<4;r++)s[r]=t.getUint32(r*4);return s}initTable(){const e=this.sBox,t=this.invSBox,s=this.subMix,r=s[0],i=s[1],a=s[2],o=s[3],l=this.invSubMix,c=l[0],u=l[1],d=l[2],f=l[3],g=new Uint32Array(256);let h=0,m=0,p=0;for(p=0;p<256;p++)p<128?g[p]=p<<1:g[p]=p<<1^283;for(p=0;p<256;p++){let E=m^m<<1^m<<2^m<<3^m<<4;E=E>>>8^E&255^99,e[h]=E,t[E]=h;const x=g[h],v=g[x],w=g[v];let b=g[E]*257^E*16843008;r[h]=b<<24|b>>>8,i[h]=b<<16|b>>>16,a[h]=b<<8|b>>>24,o[h]=b,b=w*16843009^v*65537^x*257^h*16843008,c[E]=b<<24|b>>>8,u[E]=b<<16|b>>>16,d[E]=b<<8|b>>>24,f[E]=b,h?(h=x^g[g[g[w^x]]],m^=g[g[m]]):h=m=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let s=!0,r=0;for(;r<t.length&&s;)s=t[r]===this.key[r],r++;if(s)return;this.key=t;const i=this.keySize=t.length;if(i!==4&&i!==6&&i!==8)throw new Error("Invalid aes key size="+i);const a=this.ksRows=(i+6+1)*4;let o,l;const c=this.keySchedule=new Uint32Array(a),u=this.invKeySchedule=new Uint32Array(a),d=this.sBox,f=this.rcon,g=this.invSubMix,h=g[0],m=g[1],p=g[2],E=g[3];let x,v;for(o=0;o<a;o++){if(o<i){x=c[o]=t[o];continue}v=x,o%i===0?(v=v<<8|v>>>24,v=d[v>>>24]<<24|d[v>>>16&255]<<16|d[v>>>8&255]<<8|d[v&255],v^=f[o/i|0]<<24):i>6&&o%i===4&&(v=d[v>>>24]<<24|d[v>>>16&255]<<16|d[v>>>8&255]<<8|d[v&255]),c[o]=x=(c[o-i]^v)>>>0}for(l=0;l<a;l++)o=a-l,l&3?v=c[o]:v=c[o-4],l<4||o<=4?u[l]=v:u[l]=h[d[v>>>24]]^m[d[v>>>16&255]]^p[d[v>>>8&255]]^E[d[v&255]],u[l]=u[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,s){const r=this.keySize+6,i=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],c=o[1],u=o[2],d=o[3],f=this.uint8ArrayToUint32Array_(s);let g=f[0],h=f[1],m=f[2],p=f[3];const E=new Int32Array(e),x=new Int32Array(E.length);let v,w,b,I,A,F,U,O,B,Y,$,j,Q,X;const ne=this.networkToHostOrderSwap;for(;t<E.length;){for(B=ne(E[t]),Y=ne(E[t+1]),$=ne(E[t+2]),j=ne(E[t+3]),A=B^i[0],F=j^i[1],U=$^i[2],O=Y^i[3],Q=4,X=1;X<r;X++)v=l[A>>>24]^c[F>>16&255]^u[U>>8&255]^d[O&255]^i[Q],w=l[F>>>24]^c[U>>16&255]^u[O>>8&255]^d[A&255]^i[Q+1],b=l[U>>>24]^c[O>>16&255]^u[A>>8&255]^d[F&255]^i[Q+2],I=l[O>>>24]^c[A>>16&255]^u[F>>8&255]^d[U&255]^i[Q+3],A=v,F=w,U=b,O=I,Q=Q+4;v=a[A>>>24]<<24^a[F>>16&255]<<16^a[U>>8&255]<<8^a[O&255]^i[Q],w=a[F>>>24]<<24^a[U>>16&255]<<16^a[O>>8&255]<<8^a[A&255]^i[Q+1],b=a[U>>>24]<<24^a[O>>16&255]<<16^a[A>>8&255]<<8^a[F&255]^i[Q+2],I=a[O>>>24]<<24^a[A>>16&255]<<16^a[F>>8&255]<<8^a[U&255]^i[Q+3],x[t]=ne(v^g),x[t+1]=ne(I^h),x[t+2]=ne(b^m),x[t+3]=ne(w^p),g=B,h=Y,m=$,p=j,t=t+4}return x.buffer}}const xp=16;class ci{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const s=self.crypto;s&&(this.subtle=s.subtle||s.webkitSubtle)}catch{}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 s=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?Sp(s):s}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,s){return this.useSoftware?new Promise((r,i)=>{this.softwareDecrypt(new Uint8Array(e),t,s);const a=this.flush();a?r(a.buffer):i(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,s)}softwareDecrypt(e,t,s){const{currentIV:r,currentResult:i,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=Ge(a,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;r&&(s=r);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Tp),l.expandKey(t);const c=i;return this.currentResult=l.decrypt(o.buffer,0,s),this.currentIV=Pt(o,-16).buffer,c||null}webCryptoDecrypt(e,t,s){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,s));this.key=t,this.fastAesKey=new Ep(this.subtle,t)}return this.fastAesKey.expandKey().then(r=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new yp(this.subtle,new Uint8Array(s)).decrypt(e.buffer,r)):Promise.reject(new Error("web crypto not initialized"))).catch(r=>(L.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${r.name}: ${r.message}`),this.onWebCryptoError(e,t,s)))}onWebCryptoError(e,t,s){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,s);const r=this.flush();if(r)return r.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;const s=e.length-e.length%xp;return s!==e.length&&(t=Pt(e,0,s),this.remainderData=Pt(e,s)),t}logOnce(e){this.logEnabled&&(L.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const vp={toString:function(n){let e="";const t=n.length;for(let s=0;s<t;s++)e+=`[${n.start(s).toFixed(3)}-${n.end(s).toFixed(3)}]`;return e}},M={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class ui extends cp{constructor(e,t,s,r,i){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=M.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=i,this.logPrefix=r,this.log=L.log.bind(L,`${r}:`),this.warn=L.warn.bind(L,`${r}:`),this.hls=e,this.fragmentLoader=new mp(e.config),this.keyLoader=s,this.fragmentTracker=t,this.config=e.config,this.decrypter=new ci(e.config),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=M.STOPPED}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;const s=t.partList;if(s!=null&&s.length){const i=s[s.length-1];return de.isBuffered(this.media,i.start+i.duration/2)}const r=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(r)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}}onMediaAttached(e,t){const s=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),s.addEventListener("seeking",this.onvseeking),s.addEventListener("ended",this.onvended);const r=this.config;this.levels&&r.autoStartLoad&&this.state===M.STOPPED&&this.startLoad(r.startPosition)}onMediaDetaching(){const e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:s,mediaBuffer:r,state:i}=this,a=s?s.currentTime:0,o=de.bufferInfo(r||s,a,e.maxBufferHole);if(this.log(`media seeking to ${H(a)?a.toFixed(3):a}, state: ${i}`),this.state===M.ENDED)this.resetLoadingState();else if(t){const l=e.maxFragLookUpTolerance,c=t.start-l,u=t.start+t.duration+l;if(!o.len||u<o.start||c>o.end){const d=a>u;(a<c||d)&&(d&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}s&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=M.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,s){this._loadFragForPlayback(e,t,s)}_loadFragForPlayback(e,t,s){const r=i=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${i.part?" p: "+i.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(i)};this._doFragLoad(e,t,s,r).then(i=>{if(!i)return;const a=this.state;if(this.fragContextChanged(e)){(a===M.FRAG_LOADING||!this.fragCurrent&&a===M.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=M.IDLE);return}"payload"in i&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(y.FRAG_LOADED,i)),this._handleFragmentLoadComplete(i)}).catch(i=>{this.state===M.STOPPED||this.state===M.ERROR||(this.warn(`Frag error: ${(i==null?void 0:i.message)||i}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:s}=this;if(s.getState(e)===be.APPENDING){const i=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,i),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),l=this.backtrackFragment;((l?e.sn-l.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&s.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?s.removeAllFragments():s.hasParts(e.type)&&(s.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),s.getState(e)===be.PARTIAL&&s.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)}flushMainBuffer(e,t,s=null){if(!(e-t))return;const r={startOffset:e,endOffset:t,type:s};this.hls.trigger(y.BUFFER_FLUSHING,r)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(s=>{if(!s||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return s}).then(s=>{const{hls:r}=this,{payload:i}=s,a=e.decryptdata;if(i&&i.byteLength>0&&a!=null&&a.key&&a.iv&&a.method==="AES-128"){const o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),a.key.buffer,a.iv.buffer).catch(l=>{throw r.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{const c=self.performance.now();return r.trigger(y.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:c}}),s.payload=l,this.completeInitSegmentLoad(s)})}return this.completeInitSegmentLoad(s)}).catch(s=>{this.state===M.STOPPED||this.state===M.ERROR||(this.warn(s),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const s=e.frag.stats;this.state=M.IDLE,e.frag.data=new Uint8Array(e.payload),s.parsing.start=s.buffering.start=self.performance.now(),s.parsing.end=s.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var s,r,i,a;const o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===q.MAIN?"level":"track"} ${e.level} (frag:[${((s=e.startPTS)!=null?s:NaN).toFixed(3)}-${((r=e.endPTS)!=null?r:NaN).toFixed(3)}] > buffer:${o?vp.toString(de.getBuffered(o)):"(detached)"})`),e.sn!=="initSegment"){var l;if(e.type!==q.SUBTITLE){const u=e.elementaryStreams;if(!Object.keys(u).some(d=>!!u[d])){this.state=M.IDLE;return}}const c=(l=this.levels)==null?void 0:l[e.level];c!=null&&c.fragmentError&&(this.log(`Resetting level fragment error count of ${c.fragmentError} on frag buffered`),c.fragmentError=0)}this.state=M.IDLE,o&&(!this.loadedmetadata&&e.type==q.MAIN&&o.buffered.length&&((i=this.fragCurrent)==null?void 0:i.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:s,part:r,partsLoaded:i}=e,a=!i||i.length===0||i.some(l=>!l),o=new li(s.level,s.sn,s.stats.chunkCount+1,0,r?r.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,s=null,r){var i;const a=t==null?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((i=e.decryptdata)!=null&&i.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=M.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(u=>{if(!this.fragContextChanged(u.frag))return this.hls.trigger(y.KEY_LOADED,u),this.state===M.KEY_LOADING&&(this.state=M.IDLE),u}),this.hls.trigger(y.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),s=Math.max(e.start,s||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){const u=a.partList;if(u&&r){s>e.end&&a.fragmentHint&&(e=a.fragmentHint);const d=this.getNextPart(u,e,s);if(d>-1){const f=u[d];this.log(`Loading part sn: ${e.sn} p: ${f.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${d}-${u.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(s.toFixed(3))}`),this.nextLoadPosition=f.start+f.duration,this.state=M.FRAG_LOADING;let g;return o?g=o.then(h=>!h||this.fragContextChanged(h.frag)?null:this.doFragPartsLoad(e,f,t,r)).catch(h=>this.handleFragLoadError(h)):g=this.doFragPartsLoad(e,f,t,r).catch(h=>this.handleFragLoadError(h)),this.hls.trigger(y.FRAG_LOADING,{frag:e,part:f,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):g}else if(!e.url||this.loadedEndOfParts(u,s))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(s.toFixed(3))}`),H(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=M.FRAG_LOADING;const l=this.config.progressive;let c;return l&&o?c=o.then(u=>!u||this.fragContextChanged(u==null?void 0:u.frag)?null:this.fragmentLoader.load(e,r)).catch(u=>this.handleFragLoadError(u)):c=Promise.all([this.fragmentLoader.load(e,l?r:void 0),o]).then(([u])=>(!l&&u&&r&&r(u),u)).catch(u=>this.handleFragLoadError(u)),this.hls.trigger(y.FRAG_LOADING,{frag:e,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c}doFragPartsLoad(e,t,s,r){return new Promise((i,a)=>{var o;const l=[],c=(o=s.details)==null?void 0:o.partList,u=d=>{this.fragmentLoader.loadPart(e,d,r).then(f=>{l[d.index]=f;const g=f.part;this.hls.trigger(y.FRAG_LOADED,f);const h=Nl(s,e.sn,d.index+1)||Bl(c,e.sn,d.index+1);if(h)u(h);else return i({frag:e,part:g,partsLoaded:l})}).catch(a)};u(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===k.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(y.ERROR,t)}else this.hls.trigger(y.ERROR,{type:Z.OTHER_ERROR,details:k.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==M.PARSING){!this.fragCurrent&&this.state!==M.STOPPED&&this.state!==M.ERROR&&(this.state=M.IDLE);return}const{frag:s,part:r,level:i}=t,a=self.performance.now();s.stats.parsing.end=a,r&&(r.stats.parsing.end=a),this.updateLevelTiming(s,r,i,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:s}=this,{level:r,sn:i,part:a}=e;if(!(t!=null&&t[r]))return this.warn(`Levels object was unset while buffering fragment ${i} of level ${r}. The current chunk will not be buffered.`),null;const o=t[r],l=a>-1?Nl(o,i,a):null,c=l?l.fragment:K2(o,i,s);return c?(s&&s!==c&&(c.stats=s.stats),{frag:c,part:l,level:o}):null}bufferFragmentData(e,t,s,r,i){var a;if(!e||this.state!==M.PARSING)return;const{data1:o,data2:l}=e;let c=o;if(o&&l&&(c=Ge(o,l)),!((a=c)!=null&&a.length))return;const u={type:e.type,frag:t,part:s,chunkMeta:r,parent:t.type,data:c};if(this.hls.trigger(y.BUFFER_APPENDING,u),e.dropped&&e.independent&&!s){if(i)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!de.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const s=t.currentTime,r=de.bufferInfo(t,s,0),i=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,i*.25),o=Math.max(Math.min(e.start-a,r.end-a),s+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){const s=this.getLoadPosition();return H(s)?this.getFwdBufferInfoAtPos(e,s,t):null}getFwdBufferInfoAtPos(e,t,s){const{config:{maxBufferHole:r}}=this,i=de.bufferInfo(e,t,r);if(i.len===0&&i.nextStart!==void 0){const a=this.fragmentTracker.getBufferedFrag(t,s);if(a&&i.nextStart<a.end)return de.bufferInfo(e,t,Math.max(i.nextStart,r))}return i}getMaxBufferLength(e){const{config:t}=this;let s;return e?s=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):s=t.maxBufferLength,Math.min(s,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const s=this.config,r=Math.max(Math.min(e-t,s.maxBufferLength),t),i=Math.max(e-t*3,s.maxMaxBufferLength/2,r);return i>=r?(s.maxMaxBufferLength=i,this.warn(`Reduce max buffer length to ${i}s`),!0):!1}getAppendedFrag(e,t=q.MAIN){const s=this.fragmentTracker.getAppendedFrag(e,q.MAIN);return s&&"fragment"in s?s.fragment:s}getNextFragment(e,t){const s=t.fragments,r=s.length;if(!r)return null;const{config:i}=this,a=s[0].start;let o;if(t.live){const l=i.initialLiveManifestSize;if(r<l)return this.warn(`Not enough fragments to start playback (have: ${r}, need: ${l})`),null;(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a)&&(o=this.getInitialLiveFragment(t,s),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=s[0]);if(!o){const l=i.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){const s=this.fragmentTracker.getState(e);return(s===be.OK||s===be.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,s,r,i){const a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&s.nextStart){const l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,s.nextStart,r);if(l!==null&&s.len+l.len>=i)return this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,s){let r=-1,i=!1,a=!0;for(let o=0,l=e.length;o<l;o++){const c=e[o];if(a=a&&!c.independent,r>-1&&s<c.start)break;const u=c.loaded;u?r=-1:(i||c.independent||a)&&c.fragment===t&&(r=o),i=u}return r}loadedEndOfParts(e,t){const s=e[e.length-1];return s&&t>s.start&&s.loaded}getInitialLiveFragment(e,t){const s=this.fragPrevious;let r=null;if(s){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${s.programDateTime}`),r=j2(t,s.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){const i=s.sn+1;if(i>=e.startSN&&i<=e.endSN){const a=t[i-e.startSN];s.cc===a.cc&&(r=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}r||(r=Y2(t,s.cc),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`))}}else{const i=this.hls.liveSyncPosition;i!==null&&(r=this.getFragmentAtPosition(i,this.bitrateTest?e.fragmentEnd:e.edge,e))}return r}getFragmentAtPosition(e,t,s){const{config:r}=this;let{fragPrevious:i}=this,{fragments:a,endSN:o}=s;const{fragmentHint:l}=s,{maxFragLookUpTolerance:c}=r,u=s.partList,d=!!(r.lowLatencyMode&&u!=null&&u.length&&l);d&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let f;if(e<t){const g=e>t-c?0:c;f=An(i,a,e,g)}else f=a[a.length-1];if(f){const g=f.sn-s.startSN,h=this.fragmentTracker.getState(f);if((h===be.OK||h===be.PARTIAL&&f.gap)&&(i=f),i&&f.sn===i.sn&&(!d||u[0].fragment.sn>f.sn)&&i&&f.level===i.level){const p=a[g+1];f.sn<o&&this.fragmentTracker.getState(p)!==be.OK?f=p:f=null}}return f}synchronizeToLiveEdge(e){const{config:t,media:s}=this;if(!s)return;const r=this.hls.liveSyncPosition,i=s.currentTime,a=e.fragments[0].start,o=e.edge,l=i>=a-t.maxFragLookUpTolerance&&i<=o;if(r!==null&&s.duration>r&&(i<r||!l)){const c=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&s.readyState<4||i<o-c)&&(this.loadedmetadata||(this.nextLoadPosition=r),s.readyState&&(this.warn(`Playback: ${i.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${r.toFixed(3)}`),s.currentTime=r))}}alignPlaylists(e,t,s){const r=e.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;const i=e.fragments[0].start,a=!t,o=e.alignedSliding&&H(i);if(a||!o&&!i){const{fragPrevious:l}=this;pp(l,s,e);const c=e.fragments[0].start;return this.log(`Live playlist sliding: ${c.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${l?l.sn:"na"} fragments: ${r}`),c}return i}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let s=this.startPosition;if(s<t&&(s=-1),s===-1||this.lastCurrentTime===-1){const r=this.startTimeOffset!==null,i=r?this.startTimeOffset:e.startTimeOffset;i!==null&&H(i)?(s=t+i,i<0&&(s+=e.totalduration),s=Math.min(Math.max(t,s),t+e.totalduration),this.log(`Start time offset ${i} found in ${r?"multivariant":"media"} playlist, adjust startPosition to ${s}`),this.startPosition=s):e.live?s=this.hls.liveSyncPosition||t:this.startPosition=s=0,this.lastCurrentTime=s}this.nextLoadPosition=s}getLoadPosition(){const{media:e}=this;let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==M.FRAG_LOADING_WAITING_RETRY)&&(this.state=M.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const u=this.getCurrentContext(t.chunkMeta);u&&(t.frag=u.frag)}const s=t.frag;if(!s||s.type!==e||!this.levels)return;if(this.fragContextChanged(s)){var r;this.warn(`Frag load error must match current frag to retry ${s.url} > ${(r=this.fragCurrent)==null?void 0:r.url}`);return}const i=t.details===k.FRAG_GAP;i&&this.fragmentTracker.fragBuffered(s,!0);const a=t.errorAction,{action:o,retryCount:l=0,retryConfig:c}=a||{};if(a&&o===De.RetryRequest&&c){this.resetStartWhenNotLoaded(this.levelLastLoaded);const u=ii(c,l);this.warn(`Fragment ${s.sn} of ${e} ${s.level} errored with ${t.details}, retrying loading ${l+1}/${c.maxNumRetry} in ${u}ms`),a.resolved=!0,this.retryDate=self.performance.now()+u,this.state=M.FRAG_LOADING_WAITING_RETRY}else if(c&&a)if(this.resetFragmentErrors(e),l<c.maxNumRetry)!i&&o!==De.RemoveAlternatePermanently&&(a.resolved=!0);else{L.warn(`${t.details} reached or exceeded max retry (${l})`);return}else(a==null?void 0:a.action)===De.SendAlternateToPenaltyBox?this.state=M.WAITING_LEVEL:this.state=M.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===M.PARSING||this.state===M.PARSED){const t=e.frag,s=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,s),i=r&&r.len>.5;i&&this.reduceMaxBufferLength(r.len,(t==null?void 0:t.duration)||10);const a=!i;return a&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${s} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===q.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==M.STOPPED&&(this.state=M.IDLE)}afterBufferFlushed(e,t,s){if(!e)return;const r=de.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,s),this.state===M.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=M.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=e?e.details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,s,r){var i;const a=s.details;if(!a){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((l,c)=>{const u=e.elementaryStreams[c];if(u){const d=u.endPTS-u.startPTS;if(d<=0)return this.warn(`Could not parse fragment ${e.sn} ${c} duration reliably (${d})`),l||!1;const f=r?0:Fl(a,e,u.startPTS,u.endPTS,u.startDTS,u.endDTS);return this.hls.trigger(y.LEVEL_PTS_UPDATED,{details:a,level:s,drift:f,type:c,frag:e,start:u.startPTS,end:u.endPTS}),!0}return l},!1)&&((i=this.transmuxer)==null?void 0:i.error)===null){const l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(s.fragmentError===0&&(s.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${s.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=M.PARSED,this.hls.trigger(y.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}class Zl{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let s;if(e.length)e.length===1?s=e[0]:s=bp(e,t);else return new Uint8Array(0);return this.reset(),s}reset(){this.chunks.length=0,this.dataLength=0}}function bp(n,e){const t=new Uint8Array(e);let s=0;for(let r=0;r<n.length;r++){const i=n[r];t.set(i,s),s+=i.length}return t}function Cp(){return typeof __HLS_WORKER_BUNDLE__=="function"}function wp(){const n=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(n);return{worker:new self.Worker(e),objectURL:e}}function Lp(n){const e=new self.URL(n,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function nt(n="",e=9e4){return{type:n,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class di{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,s,r){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,s){}demux(e,t){this.cachedData&&(e=Ge(this.cachedData,e),this.cachedData=null);let s=ms(e,0),r=s?s.length:0,i;const a=this._audioTrack,o=this._id3Track,l=s?Wr(s):void 0,c=e.length;for((this.basePTS===null||this.frameIndex===0&&H(l))&&(this.basePTS=Ap(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),s&&s.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:ze.audioId3,duration:Number.POSITIVE_INFINITY});r<c;){if(this.canParse(e,r)){const u=this.appendFrame(a,e,r);u?(this.frameIndex++,this.lastPTS=u.sample.pts,r+=u.length,i=r):r=c}else qh(e,r)?(s=ms(e,r),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:ze.audioId3,duration:Number.POSITIVE_INFINITY}),r+=s.length,i=r):r++;if(r===c&&i!==c){const u=Pt(e,i);this.cachedData?this.cachedData=Ge(this.cachedData,u):this.cachedData=u}}return{audioTrack:a,videoTrack:nt(),id3Track:o,textTrack:nt()}}demuxSampleAes(e,t,s){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:nt(),id3Track:this._id3Track,textTrack:nt()}}destroy(){}}const Ap=(n,e,t)=>{if(H(n))return n*90;const s=t?t.baseTime*9e4/t.timescale:0;return e*9e4+s};function Dp(n,e,t,s){let r,i,a,o;const l=navigator.userAgent.toLowerCase(),c=s,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((e[t+2]&192)>>>6)+1;const d=(e[t+2]&60)>>>2;if(d>u.length-1){const f=new Error(`invalid ADTS sampling index:${d}`);n.emit(y.ERROR,y.ERROR,{type:Z.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,fatal:!0,error:f,reason:f.message});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,L.log(`manifest codec:${s}, ADTS type:${r}, samplingIndex:${d}`),/firefox/i.test(l)?d>=6?(r=5,o=new Array(4),i=d-3):(r=2,o=new Array(2),i=d):l.indexOf("android")!==-1?(r=2,o=new Array(2),i=d):(r=5,o=new Array(4),s&&(s.indexOf("mp4a.40.29")!==-1||s.indexOf("mp4a.40.5")!==-1)||!s&&d>=6?i=d-3:((s&&s.indexOf("mp4a.40.2")!==-1&&(d>=6&&a===1||/vivaldi/i.test(l))||!s&&a===1)&&(r=2,o=new Array(2)),i=d)),o[0]=r<<3,o[0]|=(d&14)>>1,o[1]|=(d&1)<<7,o[1]|=a<<3,r===5&&(o[1]|=(i&14)>>1,o[2]=(i&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:u[d],channelCount:a,codec:"mp4a.40."+r,manifestCodec:c}}function Ql(n,e){return n[e]===255&&(n[e+1]&246)===240}function Jl(n,e){return n[e+1]&1?7:9}function fi(n,e){return(n[e+3]&3)<<11|n[e+4]<<3|(n[e+5]&224)>>>5}function Ip(n,e){return e+5<n.length}function Pn(n,e){return e+1<n.length&&Ql(n,e)}function Rp(n,e){return Ip(n,e)&&Ql(n,e)&&fi(n,e)<=n.length-e}function kp(n,e){if(Pn(n,e)){const t=Jl(n,e);if(e+t>=n.length)return!1;const s=fi(n,e);if(s<=t)return!1;const r=e+s;return r===n.length||Pn(n,r)}return!1}function ec(n,e,t,s,r){if(!n.samplerate){const i=Dp(e,t,s,r);if(!i)return;n.config=i.config,n.samplerate=i.samplerate,n.channelCount=i.channelCount,n.codec=i.codec,n.manifestCodec=i.manifestCodec,L.log(`parsed codec:${n.codec}, rate:${i.samplerate}, channels:${i.channelCount}`)}}function tc(n){return 1024*9e4/n}function Pp(n,e){const t=Jl(n,e);if(e+t<=n.length){const s=fi(n,e)-t;if(s>0)return{headerLength:t,frameLength:s}}}function sc(n,e,t,s,r){const i=tc(n.samplerate),a=s+r*i,o=Pp(e,t);let l;if(o){const{frameLength:d,headerLength:f}=o,g=f+d,h=Math.max(0,t+g-e.length);h?(l=new Uint8Array(g-f),l.set(e.subarray(t+f,e.length),0)):l=e.subarray(t+f,t+g);const m={unit:l,pts:a};return h||n.samples.push(m),{sample:m,length:g,missing:h}}const c=e.length-t;return l=new Uint8Array(c),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:c,missing:-1}}let _n=null;const _p=[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],Op=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Fp=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Mp=[0,1,1,4];function nc(n,e,t,s,r){if(t+24>e.length)return;const i=rc(e,t);if(i&&t+i.frameLength<=e.length){const a=i.samplesPerFrame*9e4/i.sampleRate,o=s+r*a,l={unit:e.subarray(t,t+i.frameLength),pts:o,dts:o};return n.config=[],n.channelCount=i.channelCount,n.samplerate=i.sampleRate,n.samples.push(l),{sample:l,length:i.frameLength,missing:0}}}function rc(n,e){const t=n[e+1]>>3&3,s=n[e+1]>>1&3,r=n[e+2]>>4&15,i=n[e+2]>>2&3;if(t!==1&&r!==0&&r!==15&&i!==3){const a=n[e+2]>>1&1,o=n[e+3]>>6,l=t===3?3-s:s===3?3:4,c=_p[l*14+r-1]*1e3,d=Op[(t===3?0:t===2?1:2)*3+i],f=o===3?1:2,g=Fp[t][s],h=Mp[s],m=g*8*h,p=Math.floor(g*c/d+a)*h;if(_n===null){const v=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);_n=v?parseInt(v[1]):0}return!!_n&&_n<=87&&s===2&&c>=224e3&&o===0&&(n[e+3]=n[e+3]|128),{sampleRate:d,channelCount:f,frameLength:p,samplesPerFrame:m}}}function hi(n,e){return n[e]===255&&(n[e+1]&224)===224&&(n[e+1]&6)!==0}function ic(n,e){return e+1<n.length&&hi(n,e)}function Np(n,e){return hi(n,e)&&4<=n.length-e}function ac(n,e){if(e+1<n.length&&hi(n,e)){const s=rc(n,e);let r=4;s!=null&&s.frameLength&&(r=s.frameLength);const i=e+r;return i===n.length||ic(n,i)}return!1}class Bp extends di{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,s,r){super.resetInitSegment(e,t,s,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=ms(e,0);let s=(t==null?void 0:t.length)||0;if(ac(e,s))return!1;for(let r=e.length;s<r;s++)if(kp(e,s))return L.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return Rp(e,t)}appendFrame(e,t,s){ec(e,this.observer,t,s,e.manifestCodec);const r=sc(e,t,s,this.basePTS,this.frameIndex);if(r&&r.missing===0)return r}}const Up=/\/emsg[-/]ID3/i;class $p{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,s,r){const i=this.videoTrack=nt("video",1),a=this.audioTrack=nt("audio",1),o=this.txtTrack=nt("text",1);if(this.id3Track=nt("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const l=ll(e);if(l.video){const{id:c,timescale:u,codec:d}=l.video;i.id=c,i.timescale=o.timescale=u,i.codec=d}if(l.audio){const{id:c,timescale:u,codec:d}=l.audio;a.id=c,a.timescale=u,a.codec=d}o.id=rl.text,i.sampleDuration=0,i.duration=a.duration=r}resetContiguity(){this.remainderData=null}static probe(e){return n2(e)}demux(e,t){this.timeOffset=t;let s=e;const r=this.videoTrack,i=this.txtTrack;if(this.config.progressive){this.remainderData&&(s=Ge(this.remainderData,e));const o=d2(s);this.remainderData=o.remainder,r.samples=o.valid||new Uint8Array}else r.samples=s;const a=this.extractID3Track(r,t);return i.samples=ul(t,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,s=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const r=this.extractID3Track(t,this.timeOffset);return s.samples=ul(e,t),{videoTrack:t,audioTrack:nt(),id3Track:r,textTrack:nt()}}extractID3Track(e,t){const s=this.id3Track;if(e.samples.length){const r=J(e.samples,["emsg"]);r&&r.forEach(i=>{const a=p2(i);if(Up.test(a.schemeIdUri)){const o=H(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale;let l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);const c=a.payload;s.samples.push({data:c,len:c.byteLength,dts:o,pts:o,type:ze.emsg,duration:l})}})}return s}demuxSampleAes(e,t,s){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}const oc=(n,e)=>{let t=0,s=5;e+=s;const r=new Uint32Array(1),i=new Uint32Array(1),a=new Uint8Array(1);for(;s>0;){a[0]=n[e];const o=Math.min(s,8),l=8-o;i[0]=4278190080>>>24+l<<l,r[0]=(a[0]&i[0])>>l,t=t?t<<o|r[0]:r[0],e+=1,s-=o}return t};class Vp extends di{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,s,r){super.resetInitSegment(e,t,s,r),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,s){const r=lc(e,t,s,this.basePTS,this.frameIndex);if(r!==-1)return{sample:e.samples[e.samples.length-1],length:r,missing:0}}static probe(e){if(!e)return!1;const t=ms(e,0);if(!t)return!1;const s=t.length;return e[s]===11&&e[s+1]===119&&Wr(t)!==void 0&&oc(e,s)<16}}function lc(n,e,t,s,r){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const i=e[t+4]>>6;if(i>=3)return-1;const o=[48e3,44100,32e3][i],l=e[t+4]&63,u=[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][l*3+i]*2;if(t+u>e.length)return-1;const d=e[t+6]>>5;let f=0;d===2?f+=2:(d&1&&d!==1&&(f+=2),d&4&&(f+=2));const g=(e[t+6]<<8|e[t+7])>>12-f&1,m=[2,1,2,3,3,4,4,5][d]+g,p=e[t+5]>>3,E=e[t+5]&7,x=new Uint8Array([i<<6|p<<1|E>>2,(E&3)<<6|d<<3|g<<2|l>>4,l<<4&224]),v=1536/o*9e4,w=s+r*v,b=e.subarray(t,t+u);return n.config=x,n.channelCount=m,n.samplerate=o,n.samples.push({unit:b,pts:w}),u}class Gp{constructor(){this.VideoSample=null}createVideoSample(e,t,s,r){return{key:e,frame:!1,pts:t,dts:s,units:[],debug:r,length:0}}getLastNalUnit(e){var t;let s=this.VideoSample,r;if((!s||s.units.length===0)&&(s=e[e.length-1]),(t=s)!=null&&t.units){const i=s.units;r=i[i.length-1]}return r}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const s=t.samples,r=s.length;if(r){const i=s[r-1];e.pts=i.pts,e.dts=i.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&L.log(e.pts+"/"+e.dts+":"+e.debug)}}class cc{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,s=e.byteLength-t,r=new Uint8Array(4),i=Math.min(4,t);if(i===0)throw new Error("no bytes available");r.set(e.subarray(s,s+i)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=i*8,this.bytesAvailable-=i}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const s=this.word>>>32-t;if(e>32&&L.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?s<<t|this.readBits(t):s}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 this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,s=8,r;for(let i=0;i<e;i++)s!==0&&(r=this.readEG(),s=(t+r+256)%256),t=s===0?t:s}readSPS(){let e=0,t=0,s=0,r=0,i,a,o;const l=this.readUByte.bind(this),c=this.readBits.bind(this),u=this.readUEG.bind(this),d=this.readBoolean.bind(this),f=this.skipBits.bind(this),g=this.skipEG.bind(this),h=this.skipUEG.bind(this),m=this.skipScalingList.bind(this);l();const p=l();if(c(5),f(3),l(),h(),p===100||p===110||p===122||p===244||p===44||p===83||p===86||p===118||p===128){const I=u();if(I===3&&f(1),h(),h(),f(1),d())for(a=I!==3?8:12,o=0;o<a;o++)d()&&(o<6?m(16):m(64))}h();const E=u();if(E===0)u();else if(E===1)for(f(1),g(),g(),i=u(),o=0;o<i;o++)g();h(),f(1);const x=u(),v=u(),w=c(1);w===0&&f(1),f(1),d()&&(e=u(),t=u(),s=u(),r=u());let b=[1,1];if(d()&&d())switch(l()){case 1:b=[1,1];break;case 2:b=[12,11];break;case 3:b=[10,11];break;case 4:b=[16,11];break;case 5:b=[40,33];break;case 6:b=[24,11];break;case 7:b=[20,11];break;case 8:b=[32,11];break;case 9:b=[80,33];break;case 10:b=[18,11];break;case 11:b=[15,11];break;case 12:b=[64,33];break;case 13:b=[160,99];break;case 14:b=[4,3];break;case 15:b=[3,2];break;case 16:b=[2,1];break;case 255:{b=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((x+1)*16-e*2-t*2),height:(2-w)*(v+1)*16-(w?2:4)*(s+r),pixelRatio:b}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Hp extends Gp{parseAVCPES(e,t,s,r,i){const a=this.parseAVCNALu(e,s.data);let o=this.VideoSample,l,c=!1;s.data=null,o&&a.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts,"")),a.forEach(u=>{var d;switch(u.type){case 1:{let m=!1;l=!0;const p=u.data;if(c&&p.length>4){const E=new cc(p).readSliceType();(E===2||E===4||E===7||E===9)&&(m=!0)}if(m){var f;(f=o)!=null&&f.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts,"")),o.frame=!0,o.key=m;break}case 5:l=!0,(d=o)!=null&&d.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts,"")),o.key=!0,o.frame=!0;break;case 6:{l=!0,dl(u.data,1,s.pts,t.samples);break}case 7:{var g,h;l=!0,c=!0;const m=u.data,E=new cc(m).readSPS();if(!e.sps||e.width!==E.width||e.height!==E.height||((g=e.pixelRatio)==null?void 0:g[0])!==E.pixelRatio[0]||((h=e.pixelRatio)==null?void 0:h[1])!==E.pixelRatio[1]){e.width=E.width,e.height=E.height,e.pixelRatio=E.pixelRatio,e.sps=[m],e.duration=i;const x=m.subarray(1,4);let v="avc1.";for(let w=0;w<3;w++){let b=x[w].toString(16);b.length<2&&(b="0"+b),v+=b}e.codec=v}break}case 8:l=!0,e.pps=[u.data];break;case 9:l=!0,e.audFound=!0,o&&this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts,"");break;case 12:l=!0;break;default:l=!1,o&&(o.debug+="unknown NAL "+u.type+" ");break}o&&l&&o.units.push(u)}),r&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}parseAVCNALu(e,t){const s=t.byteLength;let r=e.naluState||0;const i=r,a=[];let o=0,l,c,u,d=-1,f=0;for(r===-1&&(d=0,f=t[0]&31,r=0,o=1);o<s;){if(l=t[o++],!r){r=l?0:1;continue}if(r===1){r=l?0:2;continue}if(!l)r=3;else if(l===1){if(c=o-r-1,d>=0){const g={data:t.subarray(d,c),type:f};a.push(g)}else{const g=this.getLastNalUnit(e.samples);g&&(i&&o<=4-i&&g.state&&(g.data=g.data.subarray(0,g.data.byteLength-i)),c>0&&(g.data=Ge(g.data,t.subarray(0,c)),g.state=0))}o<s?(u=t[o]&31,d=o,f=u,r=0):r=-1}else r=0}if(d>=0&&r>=0){const g={data:t.subarray(d,s),type:f,state:r};a.push(g)}if(a.length===0){const g=this.getLastNalUnit(e.samples);g&&(g.data=Ge(g.data,t))}return e.naluState=r,a}}class Kp{constructor(e,t,s){this.keyData=void 0,this.decrypter=void 0,this.keyData=s,this.decrypter=new ci(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,s){const r=e[t].unit;if(r.length<=16)return;const i=r.subarray(16,r.length-r.length%16),a=i.buffer.slice(i.byteOffset,i.byteOffset+i.length);this.decryptBuffer(a).then(o=>{const l=new Uint8Array(o);r.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,s)})}decryptAacSamples(e,t,s){for(;;t++){if(t>=e.length){s();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,s),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,s=new Int8Array(t);let r=0;for(let i=32;i<e.length-16;i+=160,r+=16)s.set(e.subarray(i,i+16),r);return s}getAvcDecryptedUnit(e,t){const s=new Uint8Array(t);let r=0;for(let i=32;i<e.length-16;i+=160,r+=16)e.set(s.subarray(r,r+16),i);return e}decryptAvcSample(e,t,s,r,i){const a=fl(i.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{i.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,s+1,r)})}decryptAvcSamples(e,t,s,r){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,s=0){if(t>=e.length){r();return}const i=e[t].units;for(;!(s>=i.length);s++){const a=i[s];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,s,r,a),!this.decrypter.isSync()))return}}}}const Ce=188;class yt{constructor(e,t,s){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=s,this.videoParser=new Hp}static probe(e){const t=yt.syncOffset(e);return t>0&&L.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){const t=e.length;let s=Math.min(Ce*5,t-Ce)+1,r=0;for(;r<s;){let i=!1,a=-1,o=0;for(let l=r;l<t;l+=Ce)if(e[l]===71&&(t-l===Ce||e[l+Ce]===71)){if(o++,a===-1&&(a=l,a!==0&&(s=Math.min(a+Ce*99,e.length-Ce)+1)),i||(i=pi(e,l)===0),i&&o>1&&(a===0&&o>2||l+Ce>s))return a}else{if(o)return-1;break}r++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:rl[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,s,r){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=yt.createTrack("video"),this._audioTrack=yt.createTrack("audio",r),this._id3Track=yt.createTrack("id3"),this._txtTrack=yt.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=s,this._duration=r}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:s}=this;e&&(e.pesData=null),t&&(t.pesData=null),s&&(s.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,s=!1,r=!1){s||(this.sampleAes=null);let i;const a=this._videoTrack,o=this._audioTrack,l=this._id3Track,c=this._txtTrack;let u=a.pid,d=a.pesData,f=o.pid,g=l.pid,h=o.pesData,m=l.pesData,p=null,E=this.pmtParsed,x=this._pmtId,v=e.length;if(this.remainderData&&(e=Ge(this.remainderData,e),v=e.length,this.remainderData=null),v<Ce&&!r)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:c};const w=Math.max(0,yt.syncOffset(e));v-=(v-w)%Ce,v<e.byteLength&&!r&&(this.remainderData=new Uint8Array(e.buffer,v,e.buffer.byteLength-v));let b=0;for(let A=w;A<v;A+=Ce)if(e[A]===71){const F=!!(e[A+1]&64),U=pi(e,A),O=(e[A+3]&48)>>4;let B;if(O>1){if(B=A+5+e[A+4],B===A+Ce)continue}else B=A+4;switch(U){case u:F&&(d&&(i=Xt(d))&&this.videoParser.parseAVCPES(a,c,i,!1,this._duration),d={data:[],size:0}),d&&(d.data.push(e.subarray(B,A+Ce)),d.size+=A+Ce-B);break;case f:if(F){if(h&&(i=Xt(h)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,i);break;case"mp3":this.parseMPEGPES(o,i);break;case"ac3":this.parseAC3PES(o,i);break}h={data:[],size:0}}h&&(h.data.push(e.subarray(B,A+Ce)),h.size+=A+Ce-B);break;case g:F&&(m&&(i=Xt(m))&&this.parseID3PES(l,i),m={data:[],size:0}),m&&(m.data.push(e.subarray(B,A+Ce)),m.size+=A+Ce-B);break;case 0:F&&(B+=e[B]+1),x=this._pmtId=Wp(e,B);break;case x:{F&&(B+=e[B]+1);const Y=jp(e,B,this.typeSupported,s,this.observer);u=Y.videoPid,u>0&&(a.pid=u,a.segmentCodec=Y.segmentVideoCodec),f=Y.audioPid,f>0&&(o.pid=f,o.segmentCodec=Y.segmentAudioCodec),g=Y.id3Pid,g>0&&(l.pid=g),p!==null&&!E&&(L.warn(`MPEG-TS PMT found at ${A} after unknown PID '${p}'. Backtracking to sync byte @${w} to parse all TS packets.`),p=null,A=w-188),E=this.pmtParsed=!0;break}case 17:case 8191:break;default:p=U;break}}else b++;b>0&&On(this.observer,new Error(`Found ${b} TS packet/s that do not start with 0x47`)),a.pesData=d,o.pesData=h,l.pesData=m;const I={audioTrack:o,videoTrack:a,id3Track:l,textTrack:c};return r&&this.extractRemainingSamples(I),I}flush(){const{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={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:s,id3Track:r,textTrack:i}=e,a=s.pesData,o=t.pesData,l=r.pesData;let c;if(a&&(c=Xt(a))?(this.videoParser.parseAVCPES(s,i,c,!0,this._duration),s.pesData=null):s.pesData=a,o&&(c=Xt(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,c);break;case"mp3":this.parseMPEGPES(t,c);break;case"ac3":this.parseAC3PES(t,c);break}t.pesData=null}else o!=null&&o.size&&L.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(c=Xt(l))?(this.parseID3PES(r,c),r.pesData=null):r.pesData=l}demuxSampleAes(e,t,s){const r=this.demux(e,s,!0,!this.config.progressive),i=this.sampleAes=new Kp(this.observer,this.config,t);return this.decrypt(r,i)}decrypt(e,t){return new Promise(s=>{const{audioTrack:r,videoTrack:i}=e;r.samples&&r.segmentCodec==="aac"?t.decryptAacSamples(r.samples,0,()=>{i.samples?t.decryptAvcSamples(i.samples,0,0,()=>{s(e)}):s(e)}):i.samples&&t.decryptAvcSamples(i.samples,0,0,()=>{s(e)})})}destroy(){this._duration=0}parseAACPES(e,t){let s=0;const r=this.aacOverFlow;let i=t.data;if(r){this.aacOverFlow=null;const d=r.missing,f=r.sample.unit.byteLength;if(d===-1)i=Ge(r.sample.unit,i);else{const g=f-d;r.sample.unit.set(i.subarray(0,d),g),e.samples.push(r.sample),s=r.missing}}let a,o;for(a=s,o=i.length;a<o-1&&!Pn(i,a);a++);if(a!==s){let d;const f=a<o-1;if(f?d=`AAC PES did not start with ADTS header,offset:${a}`:d="No ADTS header found in AAC PES",On(this.observer,new Error(d),f),!f)return}ec(e,this.observer,i,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(r){const d=tc(e.samplerate);l=r.sample.pts+d}else{L.warn("[tsdemuxer]: AAC PES unknown PTS");return}let c=0,u;for(;a<o;)if(u=sc(e,i,a,l,c),a+=u.length,u.missing){this.aacOverFlow=u;break}else for(c++;a<o-1&&!Pn(i,a);a++);}parseMPEGPES(e,t){const s=t.data,r=s.length;let i=0,a=0;const o=t.pts;if(o===void 0){L.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<r;)if(ic(s,a)){const l=nc(e,s,a,o,i);if(l)a+=l.length,i++;else break}else a++}parseAC3PES(e,t){{const s=t.data,r=t.pts;if(r===void 0){L.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const i=s.length;let a=0,o=0,l;for(;o<i&&(l=lc(e,s,o,r,a++))>0;)o+=l}}parseID3PES(e,t){if(t.pts===void 0){L.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const s=ye({},t,{type:this._videoTrack?ze.emsg:ze.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(s)}}function pi(n,e){return((n[e+1]&31)<<8)+n[e+2]}function Wp(n,e){return(n[e+10]&31)<<8|n[e+11]}function jp(n,e,t,s,r){const i={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},a=(n[e+1]&15)<<8|n[e+2],o=e+3+a-4,l=(n[e+10]&15)<<8|n[e+11];for(e+=12+l;e<o;){const c=pi(n,e),u=(n[e+3]&15)<<8|n[e+4];switch(n[e]){case 207:if(!s){gi("ADTS AAC");break}case 15:i.audioPid===-1&&(i.audioPid=c);break;case 21:i.id3Pid===-1&&(i.id3Pid=c);break;case 219:if(!s){gi("H.264");break}case 27:i.videoPid===-1&&(i.videoPid=c,i.segmentVideoCodec="avc");break;case 3:case 4:!t.mpeg&&!t.mp3?L.log("MPEG audio found, not supported in this browser"):i.audioPid===-1&&(i.audioPid=c,i.segmentAudioCodec="mp3");break;case 193:if(!s){gi("AC-3");break}case 129:t.ac3?i.audioPid===-1&&(i.audioPid=c,i.segmentAudioCodec="ac3"):L.log("AC-3 audio found, not supported in this browser");break;case 6:if(i.audioPid===-1&&u>0){let d=e+5,f=u;for(;f>2;){switch(n[d]){case 106:t.ac3!==!0?L.log("AC-3 audio found, not supported in this browser for now"):(i.audioPid=c,i.segmentAudioCodec="ac3");break}const h=n[d+1]+2;d+=h,f-=h}}break;case 194:case 135:return On(r,new Error("Unsupported EC-3 in M2TS found")),i;case 36:return On(r,new Error("Unsupported HEVC in M2TS found")),i}e+=u+5}return i}function On(n,e,t){L.warn(`parsing error: ${e.message}`),n.emit(y.ERROR,y.ERROR,{type:Z.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function gi(n){L.log(`${n} with AES-128-CBC encryption found in unencrypted stream`)}function Xt(n){let e=0,t,s,r,i,a;const o=n.data;if(!n||n.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=Ge(o[0],o[1]),o.splice(1,1);if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(s=(t[4]<<8)+t[5],s&&s>n.size-6)return null;const c=t[7];c&192&&(i=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,c&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,i-a>60*9e4&&(L.warn(`${Math.round((i-a)/9e4)}s delta between PTS and DTS, align them`),i=a)):a=i),r=t[8];let u=r+9;if(n.size<=u)return null;n.size-=u;const d=new Uint8Array(n.size);for(let f=0,g=o.length;f<g;f++){t=o[f];let h=t.byteLength;if(u)if(u>h){u-=h;continue}else t=t.subarray(u),h-=u,u=0;d.set(t,e),e+=h}return s&&(s-=r+3),{data:d,pts:i,dts:a,len:s}}return null}class zp extends di{resetInitSegment(e,t,s,r){super.resetInitSegment(e,t,s,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=ms(e,0);let s=(t==null?void 0:t.length)||0;if(t&&e[s]===11&&e[s+1]===119&&Wr(t)!==void 0&&oc(e,s)<=16)return!1;for(let r=e.length;s<r;s++)if(ac(e,s))return L.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return Np(e,t)}appendFrame(e,t,s){if(this.basePTS!==null)return nc(e,t,s,this.basePTS,this.frameIndex)}}class uc{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}const Et=Math.pow(2,32)-1;class D{static init(){D.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in D.types)D.types.hasOwnProperty(e)&&(D.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]),s=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]);D.HDLR_TYPES={video:t,audio:s};const r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);D.STTS=D.STSC=D.STCO=i,D.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),D.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),D.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),D.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);D.FTYP=D.box(D.types.ftyp,a,l,a,o),D.DINF=D.box(D.types.dinf,D.box(D.types.dref,r))}static box(e,...t){let s=8,r=t.length;const i=r;for(;r--;)s+=t[r].byteLength;const a=new Uint8Array(s);for(a[0]=s>>24&255,a[1]=s>>16&255,a[2]=s>>8&255,a[3]=s&255,a.set(e,4),r=0,s=8;r<i;r++)a.set(t[r],s),s+=t[r].byteLength;return a}static hdlr(e){return D.box(D.types.hdlr,D.HDLR_TYPES[e])}static mdat(e){return D.box(D.types.mdat,e)}static mdhd(e,t){t*=e;const s=Math.floor(t/(Et+1)),r=Math.floor(t%(Et+1));return D.box(D.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,s>>24,s>>16&255,s>>8&255,s&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))}static mdia(e){return D.box(D.types.mdia,D.mdhd(e.timescale,e.duration),D.hdlr(e.type),D.minf(e))}static mfhd(e){return D.box(D.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?D.box(D.types.minf,D.box(D.types.smhd,D.SMHD),D.DINF,D.stbl(e)):D.box(D.types.minf,D.box(D.types.vmhd,D.VMHD),D.DINF,D.stbl(e))}static moof(e,t,s){return D.box(D.types.moof,D.mfhd(e),D.traf(s,t))}static moov(e){let t=e.length;const s=[];for(;t--;)s[t]=D.trak(e[t]);return D.box.apply(null,[D.types.moov,D.mvhd(e[0].timescale,e[0].duration)].concat(s).concat(D.mvex(e)))}static mvex(e){let t=e.length;const s=[];for(;t--;)s[t]=D.trex(e[t]);return D.box.apply(null,[D.types.mvex,...s])}static mvhd(e,t){t*=e;const s=Math.floor(t/(Et+1)),r=Math.floor(t%(Et+1)),i=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,e&255,s>>24,s>>16&255,s>>8&255,s&255,r>>24,r>>16&255,r>>8&255,r&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return D.box(D.types.mvhd,i)}static sdtp(e){const t=e.samples||[],s=new Uint8Array(4+t.length);let r,i;for(r=0;r<t.length;r++)i=t[r].flags,s[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return D.box(D.types.sdtp,s)}static stbl(e){return D.box(D.types.stbl,D.stsd(e),D.box(D.types.stts,D.STTS),D.box(D.types.stsc,D.STSC),D.box(D.types.stsz,D.STSZ),D.box(D.types.stco,D.STCO))}static avc1(e){let t=[],s=[],r,i,a;for(r=0;r<e.sps.length;r++)i=e.sps[r],a=i.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(i));for(r=0;r<e.pps.length;r++)i=e.pps[r],a=i.byteLength,s.push(a>>>8&255),s.push(a&255),s=s.concat(Array.prototype.slice.call(i));const o=D.box(D.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(s))),l=e.width,c=e.height,u=e.pixelRatio[0],d=e.pixelRatio[1];return D.box(D.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,l&255,c>>8&255,c&255,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,D.box(D.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),D.box(D.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,d>>24,d>>16&255,d>>8&255,d&255])))}static esds(e){const t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){const t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return D.box(D.types.mp4a,D.audioStsd(e),D.box(D.types.esds,D.esds(e)))}static mp3(e){return D.box(D.types[".mp3"],D.audioStsd(e))}static ac3(e){return D.box(D.types["ac-3"],D.audioStsd(e),D.box(D.types.dac3,e.config))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?D.box(D.types.stsd,D.STSD,D.mp3(e)):e.segmentCodec==="ac3"?D.box(D.types.stsd,D.STSD,D.ac3(e)):D.box(D.types.stsd,D.STSD,D.mp4a(e)):D.box(D.types.stsd,D.STSD,D.avc1(e))}static tkhd(e){const t=e.id,s=e.duration*e.timescale,r=e.width,i=e.height,a=Math.floor(s/(Et+1)),o=Math.floor(s%(Et+1));return D.box(D.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,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,r>>8&255,r&255,0,0,i>>8&255,i&255,0,0]))}static traf(e,t){const s=D.sdtp(e),r=e.id,i=Math.floor(t/(Et+1)),a=Math.floor(t%(Et+1));return D.box(D.types.traf,D.box(D.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),D.box(D.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,i&255,a>>24,a>>16&255,a>>8&255,a&255])),D.trun(e,s.length+16+20+8+16+8+8),s)}static trak(e){return e.duration=e.duration||4294967295,D.box(D.types.trak,D.tkhd(e),D.mdia(e))}static trex(e){const t=e.id;return D.box(D.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const s=e.samples||[],r=s.length,i=12+16*r,a=new Uint8Array(i);let o,l,c,u,d,f;for(t+=8+i,a.set([e.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<r;o++)l=s[o],c=l.duration,u=l.size,d=l.flags,f=l.cts,a.set([c>>>24&255,c>>>16&255,c>>>8&255,c&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,d.isLeading<<2|d.dependsOn,d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|d.isNonSync,d.degradPrio&61440,d.degradPrio&15,f>>>24&255,f>>>16&255,f>>>8&255,f&255],12+16*o);return D.box(D.types.trun,a)}static initSegment(e){D.types||D.init();const t=D.moov(e);return Ge(D.FTYP,t)}}D.types=void 0,D.HDLR_TYPES=void 0,D.STTS=void 0,D.STSC=void 0,D.STCO=void 0,D.STSZ=void 0,D.VMHD=void 0,D.SMHD=void 0,D.STSD=void 0,D.FTYP=void 0,D.DINF=void 0;const dc=9e4;function mi(n,e,t=1,s=!1){const r=n*e*t;return s?Math.round(r):r}function qp(n,e,t=1,s=!1){return mi(n,e,1/t,s)}function Ss(n,e=!1){return mi(n,1e3,1/dc,e)}function Yp(n,e=1){return mi(n,dc,1/e)}const Xp=10*1e3,fc=1024,Zp=1152,Qp=1536;let Zt=null,yi=null;class Fn{constructor(e,t,s,r=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=s,this.ISGenerated=!1,Zt===null){const a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Zt=a?parseInt(a[1]):0}if(yi===null){const i=navigator.userAgent.match(/Safari\/(\d+)/i);yi=i?parseInt(i[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){L.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){L.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){L.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const s=e[0].pts,r=e.reduce((i,a)=>{let o=a.pts,l=o-i;return l<-4294967296&&(t=!0,o=He(o,s),l=o-i),l>0?i:o},s);return t&&L.debug("PTS rollover detected"),r}remux(e,t,s,r,i,a,o,l){let c,u,d,f,g,h,m=i,p=i;const E=e.pid>-1,x=t.pid>-1,v=t.samples.length,w=e.samples.length>0,b=o&&v>0||v>1;if((!E||w)&&(!x||b)||this.ISGenerated||o){if(this.ISGenerated){var A,F,U,O;const j=this.videoTrackConfig;j&&(t.width!==j.width||t.height!==j.height||((A=t.pixelRatio)==null?void 0:A[0])!==((F=j.pixelRatio)==null?void 0:F[0])||((U=t.pixelRatio)==null?void 0:U[1])!==((O=j.pixelRatio)==null?void 0:O[1]))&&this.resetInitSegment()}else d=this.generateIS(e,t,i,a);const B=this.isVideoContiguous;let Y=-1,$;if(b&&(Y=Jp(t.samples),!B&&this.config.forceKeyFrameOnDiscontinuity))if(h=!0,Y>0){L.warn(`[mp4-remuxer]: Dropped ${Y} out of ${v} video samples due to a missing keyframe`);const j=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(Y),t.dropped+=Y,p+=(t.samples[0].pts-j)/t.inputTimeScale,$=p}else Y===-1&&(L.warn(`[mp4-remuxer]: No keyframe found out of ${v} video samples`),h=!1);if(this.ISGenerated){if(w&&b){const j=this.getVideoStartPts(t.samples),X=(He(e.samples[0].pts,j)-j)/t.inputTimeScale;m+=Math.max(0,X),p+=Math.max(0,-X)}if(w){if(e.samplerate||(L.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(e,t,i,a)),u=this.remuxAudio(e,m,this.isAudioContiguous,a,x||b||l===q.AUDIO?p:void 0),b){const j=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(L.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(e,t,i,a)),c=this.remuxVideo(t,p,B,j)}}else b&&(c=this.remuxVideo(t,p,B,0));c&&(c.firstKeyFrame=Y,c.independent=Y!==-1,c.firstKeyFramePTS=$)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(s.samples.length&&(g=hc(s,i,this._initPTS,this._initDTS)),r.samples.length&&(f=pc(r,i,this._initPTS))),{audio:u,video:c,initSegment:d,independent:h,text:f,id3:g}}generateIS(e,t,s,r){const i=e.samples,a=t.samples,o=this.typeSupported,l={},c=this._initPTS;let u=!c||r,d="audio/mp4",f,g,h;if(u&&(f=g=1/0),e.config&&i.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(d="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}l.audio={id:"audio",container:d,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):D.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(h=e.inputTimeScale,!c||h!==c.timescale?f=g=i[0].pts-Math.round(h*s):u=!1)}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:D.initSegment([t]),metadata:{width:t.width,height:t.height}},u)if(h=t.inputTimeScale,!c||h!==c.timescale){const m=this.getVideoStartPts(a),p=Math.round(h*s);g=Math.min(g,He(a[0].dts,m)-p),f=Math.min(f,m-p)}else u=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(l).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:f,timescale:h},this._initDTS={baseTime:g,timescale:h}):f=h=void 0,{tracks:l,initPTS:f,timescale:h}}remuxVideo(e,t,s,r){const i=e.inputTimeScale,a=e.samples,o=[],l=a.length,c=this._initPTS;let u=this.nextAvcDts,d=8,f=this.videoSampleDuration,g,h,m=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,E=!1;if(!s||u===null){const W=t*i,G=a[0].pts-He(a[0].dts,a[0].pts);Zt&&u!==null&&Math.abs(W-G-u)<15e3?s=!0:u=W-G}const x=c.baseTime*i/c.timescale;for(let W=0;W<l;W++){const G=a[W];G.pts=He(G.pts-x,u),G.dts=He(G.dts-x,u),G.dts<a[W>0?W-1:W].dts&&(E=!0)}E&&a.sort(function(W,G){const ie=W.dts-G.dts,te=W.pts-G.pts;return ie||te}),g=a[0].dts,h=a[a.length-1].dts;const v=h-g,w=v?Math.round(v/(l-1)):f||e.inputTimeScale/30;if(s){const W=g-u,G=W>w,ie=W<-1;if((G||ie)&&(G?L.warn(`AVC: ${Ss(W,!0)} ms (${W}dts) hole between fragments detected at ${t.toFixed(3)}`):L.warn(`AVC: ${Ss(-W,!0)} ms (${W}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!ie||u>=a[0].pts||Zt)){g=u;const te=a[0].pts-W;if(G)a[0].dts=g,a[0].pts=te;else for(let ce=0;ce<a.length&&!(a[ce].dts>te);ce++)a[ce].dts-=W,a[ce].pts-=W;L.log(`Video: Initial PTS/DTS adjusted: ${Ss(te,!0)}/${Ss(g,!0)}, delta: ${Ss(W,!0)} ms`)}}g=Math.max(0,g);let b=0,I=0,A=g;for(let W=0;W<l;W++){const G=a[W],ie=G.units,te=ie.length;let ce=0;for(let Ee=0;Ee<te;Ee++)ce+=ie[Ee].data.length;I+=ce,b+=te,G.length=ce,G.dts<A?(G.dts=A,A+=w/4|0||1):A=G.dts,m=Math.min(G.pts,m),p=Math.max(G.pts,p)}h=a[l-1].dts;const F=I+4*b+8;let U;try{U=new Uint8Array(F)}catch(W){this.observer.emit(y.ERROR,y.ERROR,{type:Z.MUX_ERROR,details:k.REMUX_ALLOC_ERROR,fatal:!1,error:W,bytes:F,reason:`fail allocating video mdat ${F}`});return}const O=new DataView(U.buffer);O.setUint32(0,F),U.set(D.types.mdat,4);let B=!1,Y=Number.POSITIVE_INFINITY,$=Number.POSITIVE_INFINITY,j=Number.NEGATIVE_INFINITY,Q=Number.NEGATIVE_INFINITY;for(let W=0;W<l;W++){const G=a[W],ie=G.units;let te=0;for(let we=0,Ie=ie.length;we<Ie;we++){const We=ie[we],Cs=We.data,Vi=We.data.byteLength;O.setUint32(d,Vi),d+=4,U.set(Cs,d),d+=Vi,te+=4+Vi}let ce;if(W<l-1)f=a[W+1].dts-G.dts,ce=a[W+1].pts-G.pts;else{const we=this.config,Ie=W>0?G.dts-a[W-1].dts:w;if(ce=W>0?G.pts-a[W-1].pts:w,we.stretchShortVideoTrack&&this.nextAudioPts!==null){const We=Math.floor(we.maxBufferHole*i),Cs=(r?m+r*i:this.nextAudioPts)-G.pts;Cs>We?(f=Cs-Ie,f<0?f=Ie:B=!0,L.log(`[mp4-remuxer]: It is approximately ${Cs/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=Ie}else f=Ie}const Ee=Math.round(G.pts-G.dts);Y=Math.min(Y,f),j=Math.max(j,f),$=Math.min($,ce),Q=Math.max(Q,ce),o.push(new gc(G.key,f,te,Ee))}if(o.length){if(Zt){if(Zt<70){const W=o[0].flags;W.dependsOn=2,W.isNonSync=0}}else if(yi&&Q-$<j-Y&&w/j<.025&&o[0].cts===0){L.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let W=g;for(let G=0,ie=o.length;G<ie;G++){const te=W+o[G].duration,ce=W+o[G].cts;if(G<ie-1){const Ee=te+o[G+1].cts;o[G].duration=Ee-ce}else o[G].duration=G?o[G-1].duration:w;o[G].cts=0,W=te}}}f=B||!f?w:f,this.nextAvcDts=u=h+f,this.videoSampleDuration=f,this.isVideoContiguous=!0;const ue={data1:D.moof(e.sequenceNumber++,g,ye({},e,{samples:o})),data2:U,startPTS:m/i,endPTS:(p+f)/i,startDTS:g/i,endDTS:u/i,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ue}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return Zp;case"ac3":return Qp;default:return fc}}remuxAudio(e,t,s,r,i){const a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,c=this.getSamplesPerFrame(e),u=c*l,d=this._initPTS,f=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,g=[],h=i!==void 0;let m=e.samples,p=f?0:8,E=this.nextAudioPts||-1;const x=t*a,v=d.baseTime*a/d.timescale;if(this.isAudioContiguous=s=s||m.length&&E>0&&(r&&Math.abs(x-E)<9e3||Math.abs(He(m[0].pts-v,x)-E)<20*u),m.forEach(function(X){X.pts=He(X.pts-v,x)}),!s||E<0){if(m=m.filter(X=>X.pts>=0),!m.length)return;i===0?E=0:r&&!h?E=Math.max(0,x):E=m[0].pts}if(e.segmentCodec==="aac"){const X=this.config.maxAudioFramesDrift;for(let ne=0,ue=E;ne<m.length;ne++){const W=m[ne],G=W.pts,ie=G-ue,te=Math.abs(1e3*ie/a);if(ie<=-X*u&&h)ne===0&&(L.warn(`Audio frame @ ${(G/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*ie/a)} ms.`),this.nextAudioPts=E=ue=G);else if(ie>=X*u&&te<Xp&&h){let ce=Math.round(ie/u);ue=G-ce*u,ue<0&&(ce--,ue+=u),ne===0&&(this.nextAudioPts=E=ue),L.warn(`[mp4-remuxer]: Injecting ${ce} audio frame @ ${(ue/a).toFixed(3)}s due to ${Math.round(1e3*ie/a)} ms gap.`);for(let Ee=0;Ee<ce;Ee++){const we=Math.max(ue,0);let Ie=uc.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Ie||(L.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Ie=W.unit.subarray()),m.splice(ne,0,{unit:Ie,pts:we}),ue+=u,ne++}}W.pts=ue,ue+=u}}let w=null,b=null,I,A=0,F=m.length;for(;F--;)A+=m[F].unit.byteLength;for(let X=0,ne=m.length;X<ne;X++){const ue=m[X],W=ue.unit;let G=ue.pts;if(b!==null){const te=g[X-1];te.duration=Math.round((G-b)/l)}else if(s&&e.segmentCodec==="aac"&&(G=E),w=G,A>0){A+=p;try{I=new Uint8Array(A)}catch(te){this.observer.emit(y.ERROR,y.ERROR,{type:Z.MUX_ERROR,details:k.REMUX_ALLOC_ERROR,fatal:!1,error:te,bytes:A,reason:`fail allocating audio mdat ${A}`});return}f||(new DataView(I.buffer).setUint32(0,A),I.set(D.types.mdat,4))}else return;I.set(W,p);const ie=W.byteLength;p+=ie,g.push(new gc(!0,c,ie,0)),b=G}const U=g.length;if(!U)return;const O=g[g.length-1];this.nextAudioPts=E=b+l*O.duration;const B=f?new Uint8Array(0):D.moof(e.sequenceNumber++,w/l,ye({},e,{samples:g}));e.samples=[];const Y=w/a,$=E/a,Q={data1:B,data2:I,startPTS:Y,endPTS:$,startDTS:Y,endDTS:$,type:"audio",hasAudio:!0,hasVideo:!1,nb:U};return this.isAudioContiguous=!0,Q}remuxEmptyAudio(e,t,s,r){const i=e.inputTimeScale,a=e.samplerate?e.samplerate:i,o=i/a,l=this.nextAudioPts,c=this._initDTS,u=c.baseTime*9e4/c.timescale,d=(l!==null?l:r.startDTS*i)+u,f=r.endDTS*i+u,g=o*fc,h=Math.ceil((f-d)/g),m=uc.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(L.warn("[mp4-remuxer]: remux empty Audio"),!m){L.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const p=[];for(let E=0;E<h;E++){const x=d+E*g;p.push({unit:m,pts:x,dts:x})}return e.samples=p,this.remuxAudio(e,t,s,!1)}}function He(n,e){let t;if(e===null)return n;for(e<n?t=-8589934592:t=8589934592;Math.abs(n-e)>4294967296;)n+=t;return n}function Jp(n){for(let e=0;e<n.length;e++)if(n[e].key)return e;return-1}function hc(n,e,t,s){const r=n.samples.length;if(!r)return;const i=n.inputTimeScale;for(let o=0;o<r;o++){const l=n.samples[o];l.pts=He(l.pts-t.baseTime*i/t.timescale,e*i)/i,l.dts=He(l.dts-s.baseTime*i/s.timescale,e*i)/i}const a=n.samples;return n.samples=[],{samples:a}}function pc(n,e,t){const s=n.samples.length;if(!s)return;const r=n.inputTimeScale;for(let a=0;a<s;a++){const o=n.samples[a];o.pts=He(o.pts-t.baseTime*r/t.timescale,e*r)/r}n.samples.sort((a,o)=>a.pts-o.pts);const i=n.samples;return n.samples=[],{samples:i}}class gc{constructor(e,t,s,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=s,this.cts=r,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}class e1{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,s,r){this.audioCodec=t,this.videoCodec=s,this.generateInitSegment(a2(e,r)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:s}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const r=this.initData=ll(e);r.audio&&(t=mc(r.audio,le.AUDIO)),r.video&&(s=mc(r.video,le.VIDEO));const i={};r.audio&&r.video?i.audiovideo={container:"video/mp4",codec:t+","+s,initSegment:e,id:"main"}:r.audio?i.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:r.video?i.video={container:"video/mp4",codec:s,initSegment:e,id:"main"}:L.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=i}remux(e,t,s,r,i,a){var o,l;let{initPTS:c,lastEndTime:u}=this;const d={audio:void 0,video:void 0,text:r,id3:s,initSegment:void 0};H(u)||(u=this.lastEndTime=i||0);const f=t.samples;if(!(f!=null&&f.length))return d;const g={initPTS:void 0,timescale:1};let h=this.initData;if((o=h)!=null&&o.length||(this.generateInitSegment(f),h=this.initData),!((l=h)!=null&&l.length))return L.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(g.tracks=this.initTracks,this.emitInitSegment=!1);const m=l2(f,h),p=o2(h,f),E=p===null?i:p;(t1(c,E,i,m)||g.timescale!==c.timescale&&a)&&(g.initPTS=E-i,c&&c.timescale===1&&L.warn(`Adjusting initPTS by ${g.initPTS-c.baseTime}`),this.initPTS=c={baseTime:g.initPTS,timescale:1});const x=e?E-c.baseTime/c.timescale:u,v=x+m;u2(h,f,c.baseTime/c.timescale),m>0?this.lastEndTime=v:(L.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const w=!!h.audio,b=!!h.video;let I="";w&&(I+="audio"),b&&(I+="video");const A={data1:f,startPTS:x,startDTS:x,endPTS:v,endDTS:v,type:I,hasAudio:w,hasVideo:b,nb:1,dropped:0};return d.audio=A.type==="audio"?A:void 0,d.video=A.type!=="audio"?A:void 0,d.initSegment=g,d.id3=hc(s,i,c,c),r.samples.length&&(d.text=pc(r,i,c)),d}}function t1(n,e,t,s){if(n===null)return!0;const r=Math.max(s,1),i=e-n.baseTime/n.timescale;return Math.abs(i-t)>r}function mc(n,e){const t=n==null?void 0:n.codec;if(t&&t.length>4)return t;if(e===le.AUDIO){if(t==="ec-3"||t==="ac-3"||t==="alac")return t;if(t==="fLaC"||t==="Opus")return Tn(t,!1);const s="mp4a.40.5";return L.info(`Parsed audio codec "${t}" or audio object type not handled. Using "${s}"`),s}return L.warn(`Unhandled video codec "${t}"`),t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":"avc1.42e01e"}let dt;try{dt=self.performance.now.bind(self.performance)}catch{L.debug("Unable to use Performance API on this environment"),dt=Wt==null?void 0:Wt.Date.now}const Mn=[{demux:$p,remux:e1},{demux:yt,remux:Fn},{demux:Bp,remux:Fn},{demux:zp,remux:Fn}];Mn.splice(2,0,{demux:Vp,remux:Fn});class yc{constructor(e,t,s,r,i){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=s,this.vendor=r,this.id=i}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,s,r){const i=s.transmuxing;i.executeStart=dt();let a=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:l}=this;r&&(this.currentTransmuxState=r);const{contiguous:c,discontinuity:u,trackSwitch:d,accurateTimeOffset:f,timeOffset:g,initSegmentChange:h}=r||o,{audioCodec:m,videoCodec:p,defaultInitPts:E,duration:x,initSegmentData:v}=l,w=s1(a,t);if(w&&w.method==="AES-128"){const F=this.getDecrypter();if(F.isSync()){let U=F.softwareDecrypt(a,w.key.buffer,w.iv.buffer);if(s.part>-1&&(U=F.flush()),!U)return i.executeEnd=dt(),Ei(s);a=new Uint8Array(U)}else return this.decryptionPromise=F.webCryptoDecrypt(a,w.key.buffer,w.iv.buffer).then(U=>{const O=this.push(U,null,s);return this.decryptionPromise=null,O}),this.decryptionPromise}const b=this.needsProbing(u,d);if(b){const F=this.configureTransmuxer(a);if(F)return L.warn(`[transmuxer] ${F.message}`),this.observer.emit(y.ERROR,y.ERROR,{type:Z.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,fatal:!1,error:F,reason:F.message}),i.executeEnd=dt(),Ei(s)}(u||d||h||b)&&this.resetInitSegment(v,m,p,x,t),(u||h||b)&&this.resetInitialTimestamp(E),c||this.resetContiguity();const I=this.transmux(a,w,g,f,s),A=this.currentTransmuxState;return A.contiguous=!0,A.discontinuity=!1,A.trackSwitch=!1,i.executeEnd=dt(),I}flush(e){const t=e.transmuxing;t.executeStart=dt();const{decrypter:s,currentTransmuxState:r,decryptionPromise:i}=this;if(i)return i.then(()=>this.flush(e));const a=[],{timeOffset:o}=r;if(s){const d=s.flush();d&&a.push(this.push(d,null,e))}const{demuxer:l,remuxer:c}=this;if(!l||!c)return t.executeEnd=dt(),[Ei(e)];const u=l.flush(o);return Nn(u)?u.then(d=>(this.flushRemux(a,d,e),a)):(this.flushRemux(a,u,e),a)}flushRemux(e,t,s){const{audioTrack:r,videoTrack:i,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:c}=this.currentTransmuxState;L.log(`[transmuxer.ts]: Flushed fragment ${s.sn}${s.part>-1?" p: "+s.part:""} of level ${s.level}`);const u=this.remuxer.remux(r,i,a,o,c,l,!0,this.id);e.push({remuxResult:u,chunkMeta:s}),s.transmuxing.executeEnd=dt()}resetInitialTimestamp(e){const{demuxer:t,remuxer:s}=this;!t||!s||(t.resetTimeStamp(e),s.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,s,r,i){const{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,s,r),o.resetInitSegment(e,t,s,i))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,s,r,i){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,s,r,i):a=this.transmuxUnencrypted(e,s,r,i),a}transmuxUnencrypted(e,t,s,r){const{audioTrack:i,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(i,a,o,l,t,s,!1,this.id),chunkMeta:r}}transmuxSampleAes(e,t,s,r,i){return this.demuxer.demuxSampleAes(e,t,s).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,s,r,!1,this.id),chunkMeta:i}))}configureTransmuxer(e){const{config:t,observer:s,typeSupported:r,vendor:i}=this;let a;for(let f=0,g=Mn.length;f<g;f++){var o;if((o=Mn[f].demux)!=null&&o.probe(e)){a=Mn[f];break}}if(!a)return new Error("Failed to find demuxer by probing fragment data");const l=this.demuxer,c=this.remuxer,u=a.remux,d=a.demux;(!c||!(c instanceof u))&&(this.remuxer=new u(s,t,r,i)),(!l||!(l instanceof d))&&(this.demuxer=new d(s,t,r),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 ci(this.config)),e}}function s1(n,e){let t=null;return n.byteLength>0&&(e==null?void 0:e.key)!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const Ei=n=>({remuxResult:{},chunkMeta:n});function Nn(n){return"then"in n&&n.then instanceof Function}class n1{constructor(e,t,s,r,i){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=s,this.duration=r,this.defaultInitPts=i||null}}class r1{constructor(e,t,s,r,i,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=s,this.trackSwitch=r,this.timeOffset=i,this.initSegmentChange=a}}var Ec={exports:{}};(function(n){var e=Object.prototype.hasOwnProperty,t="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(t=!1));function r(l,c,u){this.fn=l,this.context=c,this.once=u||!1}function i(l,c,u,d,f){if(typeof u!="function")throw new TypeError("The listener must be a function");var g=new r(u,d||l,f),h=t?t+c:c;return l._events[h]?l._events[h].fn?l._events[h]=[l._events[h],g]:l._events[h].push(g):(l._events[h]=g,l._eventsCount++),l}function a(l,c){--l._eventsCount===0?l._events=new s:delete l._events[c]}function o(){this._events=new s,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],u,d;if(this._eventsCount===0)return c;for(d in u=this._events)e.call(u,d)&&c.push(t?d.slice(1):d);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},o.prototype.listeners=function(c){var u=t?t+c:c,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var f=0,g=d.length,h=new Array(g);f<g;f++)h[f]=d[f].fn;return h},o.prototype.listenerCount=function(c){var u=t?t+c:c,d=this._events[u];return d?d.fn?1:d.length:0},o.prototype.emit=function(c,u,d,f,g,h){var m=t?t+c:c;if(!this._events[m])return!1;var p=this._events[m],E=arguments.length,x,v;if(p.fn){switch(p.once&&this.removeListener(c,p.fn,void 0,!0),E){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,u),!0;case 3:return p.fn.call(p.context,u,d),!0;case 4:return p.fn.call(p.context,u,d,f),!0;case 5:return p.fn.call(p.context,u,d,f,g),!0;case 6:return p.fn.call(p.context,u,d,f,g,h),!0}for(v=1,x=new Array(E-1);v<E;v++)x[v-1]=arguments[v];p.fn.apply(p.context,x)}else{var w=p.length,b;for(v=0;v<w;v++)switch(p[v].once&&this.removeListener(c,p[v].fn,void 0,!0),E){case 1:p[v].fn.call(p[v].context);break;case 2:p[v].fn.call(p[v].context,u);break;case 3:p[v].fn.call(p[v].context,u,d);break;case 4:p[v].fn.call(p[v].context,u,d,f);break;default:if(!x)for(b=1,x=new Array(E-1);b<E;b++)x[b-1]=arguments[b];p[v].fn.apply(p[v].context,x)}}return!0},o.prototype.on=function(c,u,d){return i(this,c,u,d,!1)},o.prototype.once=function(c,u,d){return i(this,c,u,d,!0)},o.prototype.removeListener=function(c,u,d,f){var g=t?t+c:c;if(!this._events[g])return this;if(!u)return a(this,g),this;var h=this._events[g];if(h.fn)h.fn===u&&(!f||h.once)&&(!d||h.context===d)&&a(this,g);else{for(var m=0,p=[],E=h.length;m<E;m++)(h[m].fn!==u||f&&!h[m].once||d&&h[m].context!==d)&&p.push(h[m]);p.length?this._events[g]=p.length===1?p[0]:p:a(this,g)}return this},o.prototype.removeAllListeners=function(c){var u;return c?(u=t?t+c:c,this._events[u]&&a(this,u)):(this._events=new s,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,n.exports=o})(Ec);var i1=Ec.exports,Si=Dh(i1);class Sc{constructor(e,t,s,r){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const i=e.config;this.hls=e,this.id=t,this.useWorker=!!i.enableWorker,this.onTransmuxComplete=s,this.onFlush=r;const a=(c,u)=>{u=u||{},u.frag=this.frag,u.id=this.id,c===y.ERROR&&(this.error=u.error),this.hls.trigger(c,u)};this.observer=new Si,this.observer.on(y.FRAG_DECRYPTED,a),this.observer.on(y.ERROR,a);const o=_t(i.preferManagedMediaSource)||{isTypeSupported:()=>!1},l={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:o.isTypeSupported('audio/mp4; codecs="ac-3"')};if(this.useWorker&&typeof Worker<"u"&&(i.workerPath||Cp())){try{i.workerPath?(L.log(`loading Web Worker ${i.workerPath} for "${t}"`),this.workerContext=Lp(i.workerPath)):(L.log(`injecting Web Worker for "${t}"`),this.workerContext=wp()),this.onwmsg=d=>this.onWorkerMessage(d);const{worker:u}=this.workerContext;u.addEventListener("message",this.onwmsg),u.onerror=d=>{const f=new Error(`${d.message} (${d.filename}:${d.lineno})`);i.enableWorker=!1,L.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(y.ERROR,{type:Z.OTHER_ERROR,details:k.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:f})},u.postMessage({cmd:"init",typeSupported:l,vendor:"",id:t,config:JSON.stringify(i)})}catch(u){L.warn(`Error setting up "${t}" Web Worker, fallback to inline`,u),this.resetWorker(),this.error=null,this.transmuxer=new yc(this.observer,l,i,"",t)}return}this.transmuxer=new yc(this.observer,l,i,"",t)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,s,r,i,a,o,l,c,u){var d,f;c.transmuxing.start=self.performance.now();const{transmuxer:g}=this,h=a?a.start:i.start,m=i.decryptdata,p=this.frag,E=!(p&&i.cc===p.cc),x=!(p&&c.level===p.level),v=p?c.sn-p.sn:-1,w=this.part?c.part-this.part.index:-1,b=v===0&&c.id>1&&c.id===(p==null?void 0:p.stats.chunkCount),I=!x&&(v===1||v===0&&(w===1||b&&w<=0)),A=self.performance.now();(x||v||i.stats.parsing.start===0)&&(i.stats.parsing.start=A),a&&(w||!I)&&(a.stats.parsing.start=A);const F=!(p&&((d=i.initSegment)==null?void 0:d.url)===((f=p.initSegment)==null?void 0:f.url)),U=new r1(E,I,l,x,h,F);if(!I||E||F){L.log(`[transmuxer-interface, ${i.type}]: Starting new transmux session for sn: ${c.sn} p: ${c.part} level: ${c.level} id: ${c.id}
|
|
47
|
+
discontinuity: ${E}
|
|
48
|
+
trackSwitch: ${x}
|
|
49
|
+
contiguous: ${I}
|
|
50
|
+
accurateTimeOffset: ${l}
|
|
51
|
+
timeOffset: ${h}
|
|
52
|
+
initSegmentChange: ${F}`);const O=new n1(s,r,t,o,u);this.configureTransmuxer(O)}if(this.frag=i,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:m,chunkMeta:c,state:U},e instanceof ArrayBuffer?[e]:[]);else if(g){const O=g.push(e,m,c,U);Nn(O)?(g.async=!0,O.then(B=>{this.handleTransmuxComplete(B)}).catch(B=>{this.transmuxerError(B,c,"transmuxer-interface push error")})):(g.async=!1,this.handleTransmuxComplete(O))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let s=t.flush(e);Nn(s)||t.async?(Nn(s)||(s=Promise.resolve(s)),s.then(i=>{this.handleFlushResult(i,e)}).catch(i=>{this.transmuxerError(i,e,"transmuxer-interface flush error")})):this.handleFlushResult(s,e)}}transmuxerError(e,t,s){this.hls&&(this.error=e,this.hls.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:s}))}handleFlushResult(e,t){e.forEach(s=>{this.handleTransmuxComplete(s)}),this.onFlush(t)}onWorkerMessage(e){const t=e.data;if(!(t!=null&&t.event)){L.warn(`worker message received with no ${t?"event name":"data"}`);return}const s=this.hls;if(this.hls)switch(t.event){case"init":{var r;const i=(r=this.workerContext)==null?void 0:r.objectURL;i&&self.URL.revokeObjectURL(i);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":L[t.data.logType]&&L[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,s.trigger(t.event,t.data);break}}}configureTransmuxer(e){const{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const Tc=100;class a1 extends ui{constructor(e,t,s){super(e,t,s,"[audio-stream-controller]",q.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(y.ERROR,this.onError,this),e.on(y.BUFFER_RESET,this.onBufferReset,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(y.ERROR,this.onError,this),e.off(y.BUFFER_RESET,this.onBufferReset,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:s,initPTS:r,timescale:i}){if(s==="main"){const a=t.cc;this.initPTS[t.cc]={baseTime:r,timescale:i},this.log(`InitPTS for cc: ${a} found from main: ${r}`),this.videoTrackCC=a,this.state===M.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=M.STOPPED;return}const t=this.lastCurrentTime;this.stopLoad(),this.setInterval(Tc),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=M.IDLE):(this.loadedmetadata=!1,this.state=M.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case M.IDLE:this.doTickIdle();break;case M.WAITING_TRACK:{var e;const{levels:s,trackId:r}=this,i=s==null||(e=s[r])==null?void 0:e.details;if(i){if(this.waitForCdnTuneIn(i))break;this.state=M.WAITING_INIT_PTS}break}case M.FRAG_LOADING_WAITING_RETRY:{var t;const s=performance.now(),r=this.retryDate;if(!r||s>=r||(t=this.media)!=null&&t.seeking){const{levels:i,trackId:a}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((i==null?void 0:i[a])||null),this.state=M.IDLE}break}case M.WAITING_INIT_PTS:{const s=this.waitingData;if(s){const{frag:r,part:i,cache:a,complete:o}=s;if(this.initPTS[r.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=M.FRAG_LOADING;const l=a.flush(),c={frag:r,part:i,payload:l,networkDetails:null};this._handleFragmentLoadProgress(c),o&&super._handleFragmentLoadComplete(c)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${r.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const l=this.getLoadPosition(),c=de.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);ai(c.end,this.config.maxFragLookUpTolerance,r)<0&&(this.log(`Waiting fragment cc (${r.cc}) @ ${r.start} cancelled because another fragment at ${c.end} is needed`),this.clearWaitingFragment())}}else this.state=M.IDLE}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=M.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:e,levels:t,media:s,trackId:r}=this,i=e.config;if(!this.buffering||!s&&(this.startFragRequested||!i.startFragPrefetch)||!(t!=null&&t[r]))return;const a=t[r],o=a.details;if(!o||o.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(o)){this.state=M.WAITING_TRACK;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,le.AUDIO,q.AUDIO));const c=this.getFwdBufferInfo(l,q.AUDIO);if(c===null)return;if(!this.switchingTrack&&this._streamEnded(c,o)){e.trigger(y.BUFFER_EOS,{type:"audio"}),this.state=M.ENDED;return}const u=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,q.MAIN),d=c.len,f=this.getMaxBufferLength(u==null?void 0:u.len),g=o.fragments,h=g[0].start,m=this.getLoadPosition(),p=this.flushing?m:c.end;if(this.switchingTrack&&s){const w=m;o.PTSKnown&&w<h&&(c.end>h||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=h+.05)}if(d>=f&&!this.switchingTrack&&p<g[g.length-1].start)return;let E=this.getNextFragment(p,o),x=!1;if(E&&this.isLoopLoading(E,p)&&(x=!!E.gap,E=this.getNextFragmentLoopLoading(E,o,c,q.MAIN,f)),!E){this.bufferFlushed=!0;return}const v=u&&E.start>u.end+o.targetduration;if(v||!(u!=null&&u.len)&&c.len){const w=this.getAppendedFrag(E.start,q.MAIN);if(w===null||(x||(x=!!w.gap||!!v&&u.len===0),v&&!x||x&&c.nextStart&&c.nextStart<w.end))return}this.loadFragment(E,a,p)}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(s=>new zt(s))}onAudioTrackSwitching(e,t){const s=!!t.url;this.trackId=t.id;const{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),s?this.setInterval(Tc):this.resetTransmuxer(),s?(this.switchingTrack=t,this.state=M.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=M.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(y.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var s;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}const{levels:r}=this,{details:i,id:a}=t;if(!r){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Audio track ${a} loaded [${i.startSN},${i.endSN}]${i.lastPartSn?`[part-${i.lastPartSn}-${i.lastPartIndex}]`:""},duration:${i.totalduration}`);const o=r[a];let l=0;if(i.live||(s=o.details)!=null&&s.live){this.checkLiveUpdate(i);const u=this.mainDetails;if(i.deltaUpdateFailed||!u)return;if(!o.details&&i.hasProgramDateTime&&u.hasProgramDateTime)kn(i,u),l=i.fragments[0].start;else{var c;l=this.alignPlaylists(i,o.details,(c=this.levelLastLoaded)==null?void 0:c.details)}}o.details=i,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!i.live)&&this.setStartPosition(this.mainDetails||i,l),this.state===M.WAITING_TRACK&&!this.waitForCdnTuneIn(i)&&(this.state=M.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:s,part:r,payload:i}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);return}const c=l[o];if(!c){this.warn("Audio track is undefined on fragment load progress");return}const u=c.details;if(!u){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(s.start);return}const d=a.defaultAudioCodec||c.audioCodec||"mp4a.40.2";let f=this.transmuxer;f||(f=this.transmuxer=new Sc(this.hls,q.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const g=this.initPTS[s.cc],h=(t=s.initSegment)==null?void 0:t.data;if(g!==void 0){const p=r?r.index:-1,E=p!==-1,x=new li(s.level,s.sn,s.stats.chunkCount,i.byteLength,p,E);f.push(i,h,d,"",s,r,u.totalduration,!1,x,g)}else{this.log(`Unknown video PTS for cc ${s.cc}, waiting for video PTS before demuxing audio frag ${s.sn} of [${u.startSN} ,${u.endSN}],track ${o}`);const{cache:m}=this.waitingData=this.waitingData||{frag:s,part:r,cache:new Zl,complete:!1};m.push(new Uint8Array(i)),this.waitingVideoCC=this.videoTrackCC,this.state=M.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){const s=t.tracks.audio;s&&(this.mediaBuffer=s.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){const{frag:s,part:r}=t;if(s.type!==q.AUDIO){if(!this.loadedmetadata&&s.type===q.MAIN){const i=this.videoBuffer||this.media;i&&de.getBuffered(i).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(s)){this.warn(`Fragment ${s.sn}${r?" p: "+r.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(s.sn!=="initSegment"){this.fragPrevious=s;const i=this.switchingTrack;i&&(this.bufferedTrack=i,this.switchingTrack=null,this.hls.trigger(y.AUDIO_TRACK_SWITCHED,ve({},i)))}this.fragBufferedComplete(s,r)}onError(e,t){var s;if(t.fatal){this.state=M.ERROR;return}switch(t.details){case k.FRAG_GAP:case k.FRAG_PARSING_ERROR:case k.FRAG_DECRYPT_ERROR:case k.FRAG_LOAD_ERROR:case k.FRAG_LOAD_TIMEOUT:case k.KEY_LOAD_ERROR:case k.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(q.AUDIO,t);break;case k.AUDIO_TRACK_LOAD_ERROR:case k.AUDIO_TRACK_LOAD_TIMEOUT:case k.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===M.WAITING_TRACK&&((s=t.context)==null?void 0:s.type)===se.AUDIO_TRACK&&(this.state=M.IDLE);break;case k.BUFFER_APPEND_ERROR:case k.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;if(t.details===k.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case k.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==le.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==le.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===M.ENDED&&(this.state=M.IDLE);const s=this.mediaBuffer||this.media;s&&(this.afterBufferFlushed(s,t,q.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const s="audio",{hls:r}=this,{remuxResult:i,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:c,level:u}=o,{details:d}=u,{audio:f,text:g,id3:h,initSegment:m}=i;if(this.fragContextChanged(l)||!d){this.fragmentTracker.removeFragment(l);return}if(this.state=M.PARSING,this.switchingTrack&&f&&this.completeAudioSwitch(this.switchingTrack),m!=null&&m.tracks){const p=l.initSegment||l;this._bufferInitSegment(u,m.tracks,p,a),r.trigger(y.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:s,tracks:m.tracks})}if(f){const{startPTS:p,endPTS:E,startDTS:x,endDTS:v}=f;c&&(c.elementaryStreams[le.AUDIO]={startPTS:p,endPTS:E,startDTS:x,endDTS:v}),l.setElementaryStreamInfo(le.AUDIO,p,E,x,v),this.bufferFragmentData(f,l,c,a)}if(h!=null&&(t=h.samples)!=null&&t.length){const p=ye({id:s,frag:l,details:d},h);r.trigger(y.FRAG_PARSING_METADATA,p)}if(g){const p=ye({id:s,frag:l,details:d},g);r.trigger(y.FRAG_PARSING_USERDATA,p)}}_bufferInitSegment(e,t,s,r){if(this.state!==M.PARSING)return;t.video&&delete t.video;const i=t.audio;if(!i)return;i.id="audio";const a=e.audioCodec;this.log(`Init audio buffer, container:${i.container}, codecs[level/parsed]=[${a}/${i.codec}]`),a&&a.split(",").length===1&&(i.levelCodec=a),this.hls.trigger(y.BUFFER_CODECS,t);const o=i.initSegment;if(o!=null&&o.byteLength){const l={type:"audio",frag:s,part:null,chunkMeta:r,parent:s.type,data:o};this.hls.trigger(y.BUFFER_APPENDING,l)}this.tickImmediate()}loadFragment(e,t,s){const r=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||r===be.NOT_LOADED||r===be.PARTIAL){var i;if(e.sn==="initSegment")this._loadInitSegment(e,t);else if((i=t.details)!=null&&i.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=M.WAITING_INIT_PTS;const a=this.mainDetails;a&&a.fragments[0].start!==t.details.fragments[0].start&&kn(t.details,a)}else this.startFragRequested=!0,super.loadFragment(e,t,s)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){const{name:t,lang:s,assocLang:r,characteristics:i,audioCodec:a,channels:o}=this.bufferedTrack;Ot({name:t,lang:s,assocLang:r,characteristics:i,audioCodec:a,channels:o},e,Ft)||(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(y.AUDIO_TRACK_SWITCHED,ve({},e))}}function xc(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!Ts(n[t].attrs,e[t].attrs))return!1;return!0}function Ts(n,e,t){const s=n["STABLE-RENDITION-ID"];return s&&!t?s===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(r=>n[r]!==e[r])}function Ti(n,e){return e.label.toLowerCase()===n.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(n.lang||"").toLowerCase())}class o1 extends oi{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(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(y.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:s,groupId:r,details:i}=t,a=this.tracksInGroup[s];if(!a||a.groupId!==r){this.warn(`Audio track with id:${s} and group:${r} not found in active group ${a==null?void 0:a.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Audio track ${s} "${a.name}" lang:${a.lang} group:${r} loaded [${i.startSN}-${i.endSN}]`),s===this.trackId&&this.playlistLoaded(s,t,o)}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 s=t.audioGroups||null,r=this.groupIds;let i=this.currentTrack;if(!s||(r==null?void 0:r.length)!==(s==null?void 0:s.length)||s!=null&&s.some(o=>(r==null?void 0:r.indexOf(o))===-1)){this.groupIds=s,this.trackId=-1,this.currentTrack=null;const o=this.tracks.filter(f=>!s||s.indexOf(f.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(f=>f.default)&&(this.selectDefaultTrack=!1),o.forEach((f,g)=>{f.id=g});else if(!i&&!this.tracksInGroup.length)return;this.tracksInGroup=o;const l=this.hls.config.audioPreference;if(!i&&l){const f=st(l,o,Ft);if(f>-1)i=o[f];else{const g=st(l,this.tracks);i=this.tracks[g]}}let c=this.findTrackId(i);c===-1&&i&&(c=this.findTrackId(null));const u={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${s==null?void 0:s.join(",")}`),this.hls.trigger(y.AUDIO_TRACKS_UPDATED,u);const d=this.trackId;if(c!==-1&&d===-1)this.setAudioTrack(c);else if(o.length&&d===-1){var a;const f=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(f.message),this.hls.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:f})}}else this.shouldReloadPlaylist(i)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===se.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&(this.requestScheduled=-1,this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const s=this.allAudioTracks;if(this.selectDefaultTrack=!1,s.length){const r=this.currentTrack;if(r&&Ot(e,r,Ft))return r;const i=st(e,this.tracksInGroup,Ft);if(i>-1){const a=this.tracksInGroup[i];return this.setAudioTrack(i),a}else if(r){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);const o=op(e,t.levels,s,a,Ft);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){const a=st(e,s);if(a>-1)return s[a]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;const s=this.currentTrack,r=t[e],i=r.details&&!r.details.live;if(e===this.trackId&&r===s&&i||(this.log(`Switching to audio-track ${e} "${r.name}" lang:${r.lang} group:${r.groupId} channels:${r.channels}`),this.trackId=e,this.currentTrack=r,this.hls.trigger(y.AUDIO_TRACK_SWITCHING,ve({},r)),i))return;const a=this.switchParams(r.url,s==null?void 0:s.details,r.details);this.loadPlaylist(a)}findTrackId(e){const t=this.tracksInGroup;for(let s=0;s<t.length;s++){const r=t[s];if(!(this.selectDefaultTrack&&!r.default)&&(!e||Ot(e,r,Ft)))return s}if(e){const{name:s,lang:r,assocLang:i,characteristics:a,audioCodec:o,channels:l}=e;for(let c=0;c<t.length;c++){const u=t[c];if(Ot({name:s,lang:r,assocLang:i,characteristics:a,audioCodec:o,channels:l},u,Ft))return c}for(let c=0;c<t.length;c++){const u=t[c];if(Ts(e.attrs,u.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return c}for(let c=0;c<t.length;c++){const u=t[c];if(Ts(e.attrs,u.attrs,["LANGUAGE"]))return c}}return-1}loadPlaylist(e){const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();const s=t.id,r=t.groupId;let i=t.url;if(e)try{i=e.addDirectives(i)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${s} "${t.name}" lang:${t.lang} group:${r}`),this.clearTimer(),this.hls.trigger(y.AUDIO_TRACK_LOADING,{url:i,id:s,groupId:r,deliveryDirectives:e||null})}}}const vc=500;class l1 extends ui{constructor(e,t,s){super(e,t,s,"[subtitle-stream-controller]",q.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.ERROR,this.onError,this),e.on(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(y.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.ERROR,this.onError,this),e.off(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(y.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=M.IDLE,this.setInterval(vc),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:s,success:r}=t;if(this.fragPrevious=s,this.state=M.IDLE,!r)return;const i=this.tracksBuffered[this.currentTrackId];if(!i)return;let a;const o=s.start;for(let c=0;c<i.length;c++)if(o>=i[c].start&&o<=i[c].end){a=i[c];break}const l=s.start+s.duration;a?a.end=l:(a={start:o,end:l},i.push(a)),this.fragmentTracker.fragBuffered(s),this.fragBufferedComplete(s,null)}onBufferFlushing(e,t){const{startOffset:s,endOffset:r}=t;if(s===0&&r!==Number.POSITIVE_INFINITY){const i=r-1;if(i<=0)return;t.endOffsetSubtitles=Math.max(0,i),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=i){a.shift();continue}else if(a[o].start<i)a[o].start=i;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(s,i,q.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===q.MAIN){var s;(s=this.media)!=null&&s.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){const s=t.frag;(s==null?void 0:s.type)===q.SUBTITLE&&(t.details===k.FRAG_GAP&&this.fragmentTracker.fragBuffered(s,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==M.STOPPED&&(this.state=M.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&xc(this.levels,t)){this.levels=t.map(s=>new zt(s));return}this.tracksBuffered=[],this.levels=t.map(s=>{const r=new zt(s);return this.tracksBuffered[r.id]=[],r}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,q.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var s;if(this.currentTrackId=t.id,!((s=this.levels)!=null&&s.length)||this.currentTrackId===-1){this.clearInterval();return}const r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(vc)}onSubtitleTrackLoaded(e,t){var s;const{currentTrackId:r,levels:i}=this,{details:a,id:o}=t;if(!i){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}const l=i[o];if(o>=i.length||!l)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let c=0;if(a.live||(s=l.details)!=null&&s.live){const d=this.mainDetails;if(a.deltaUpdateFailed||!d)return;const f=d.fragments[0];if(!l.details)a.hasProgramDateTime&&d.hasProgramDateTime?(kn(a,d),c=a.fragments[0].start):f&&(c=f.start,ri(a,c));else{var u;c=this.alignPlaylists(a,l.details,(u=this.levelLastLoaded)==null?void 0:u.details),c===0&&f&&(c=f.start,ri(a,c))}}l.details=a,this.levelLastLoaded=l,o===r&&(!this.startFragRequested&&(this.mainDetails||!a.live)&&this.setStartPosition(this.mainDetails||a,c),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===M.IDLE&&(An(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0)))}_handleFragmentLoadComplete(e){const{frag:t,payload:s}=e,r=t.decryptdata,i=this.hls;if(!this.fragContextChanged(t)&&s&&s.byteLength>0&&r!=null&&r.key&&r.iv&&r.method==="AES-128"){const a=performance.now();this.decrypter.decrypt(new Uint8Array(s),r.key.buffer,r.iv.buffer).catch(o=>{throw i.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{const l=performance.now();i.trigger(y.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=M.IDLE})}}doTick(){if(!this.media){this.state=M.IDLE;return}if(this.state===M.IDLE){const{currentTrackId:e,levels:t}=this,s=t==null?void 0:t[e];if(!s||!t.length||!s.details)return;const{config:r}=this,i=this.getLoadPosition(),a=de.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],i,r.maxBufferHole),{end:o,len:l}=a,c=this.getFwdBufferInfo(this.media,q.MAIN),u=s.details,d=this.getMaxBufferLength(c==null?void 0:c.len)+u.levelTargetDuration;if(l>d)return;const f=u.fragments,g=f.length,h=u.edge;let m=null;const p=this.fragPrevious;if(o<h){const E=r.maxFragLookUpTolerance,x=o>h-E?0:E;m=An(p,f,Math.max(f[0].start,o),x),!m&&p&&p.start<f[0].start&&(m=f[0])}else m=f[g-1];if(!m)return;if(m=this.mapToInitFragWhenRequired(m),m.sn!=="initSegment"){const E=m.sn-u.startSN,x=f[E-1];x&&x.cc===m.cc&&this.fragmentTracker.getState(x)===be.NOT_LOADED&&(m=x)}this.fragmentTracker.getState(m)===be.NOT_LOADED&&this.loadFragment(m,s,o)}}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,s){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,s))}get mediaBufferTimeRanges(){return new c1(this.tracksBuffered[this.currentTrackId]||[])}}class c1{constructor(e){this.buffered=void 0;const t=(s,r,i)=>{if(r=r>>>0,r>i-1)throw new DOMException(`Failed to execute '${s}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${i})`);return e[r][s]};this.buffered={get length(){return e.length},end(s){return t("end",s,e.length)},start(s){return t("start",s,e.length)}}}}class u1 extends oi{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const s=xn(this.media.textTracks);for(let i=0;i<s.length;i++)if(s[i].mode==="hidden")t=s[i];else if(s[i].mode==="showing"){t=s[i];break}const r=this.findTrackForTextTrack(t);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(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(y.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(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),xn(this.media.textTracks).forEach(t=>{jt(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:s,groupId:r,details:i}=t,a=this.tracksInGroup[s];if(!a||a.groupId!==r){this.warn(`Subtitle track with id:${s} and group:${r} not found in active group ${a==null?void 0:a.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Subtitle track ${s} "${a.name}" lang:${a.lang} group:${r} loaded [${i.startSN}-${i.endSN}]`),s===this.trackId&&this.playlistLoaded(s,t,o)}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 s=t.subtitleGroups||null,r=this.groupIds;let i=this.currentTrack;if(!s||(r==null?void 0:r.length)!==(s==null?void 0:s.length)||s!=null&&s.some(a=>(r==null?void 0:r.indexOf(a))===-1)){this.groupIds=s,this.trackId=-1,this.currentTrack=null;const a=this.tracks.filter(u=>!s||s.indexOf(u.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(u=>u.default)&&(this.selectDefaultTrack=!1),a.forEach((u,d)=>{u.id=d});else if(!i&&!this.tracksInGroup.length)return;this.tracksInGroup=a;const o=this.hls.config.subtitlePreference;if(!i&&o){this.selectDefaultTrack=!1;const u=st(o,a);if(u>-1)i=a[u];else{const d=st(o,this.tracks);i=this.tracks[d]}}let l=this.findTrackId(i);l===-1&&i&&(l=this.findTrackId(null));const c={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${s==null?void 0:s.join(",")}" group-id`),this.hls.trigger(y.SUBTITLE_TRACKS_UPDATED,c),l!==-1&&this.trackId===-1&&this.setSubtitleTrack(l)}else this.shouldReloadPlaylist(i)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){const t=this.tracksInGroup,s=this.selectDefaultTrack;for(let r=0;r<t.length;r++){const i=t[r];if(!(s&&!i.default||!s&&!e)&&(!e||Ot(i,e)))return r}if(e){for(let r=0;r<t.length;r++){const i=t[r];if(Ts(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const i=t[r];if(Ts(e.attrs,i.attrs,["LANGUAGE"]))return r}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let s=0;s<t.length;s++){const r=t[s];if(Ti(r,e))return s}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===se.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&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){const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const s=this.currentTrack;if(s&&Ot(e,s))return s;const r=st(e,this.tracksInGroup);if(r>-1){const i=this.tracksInGroup[r];return this.setSubtitleTrack(r),i}else{if(s)return null;{const i=st(e,t);if(i>-1)return t[i]}}}}return null}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){const s=t.id,r=t.groupId;let i=t.url;if(e)try{i=e.addDirectives(i)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${s}`),this.hls.trigger(y.SUBTITLE_TRACK_LOADING,{url:i,id:s,groupId:r,deliveryDirectives:e||null})}}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=xn(e.textTracks),s=this.currentTrack;let r;if(s&&(r=t.filter(i=>Ti(s,i))[0],r||this.warn(`Unable to find subtitle TextTrack with name "${s.name}" and language "${s.lang}"`)),[].slice.call(t).forEach(i=>{i.mode!=="disabled"&&i!==r&&(i.mode="disabled")}),r){const i=this.subtitleDisplay?"showing":"hidden";r.mode!==i&&(r.mode=i)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!H(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;const s=this.currentTrack,r=t[e]||null;if(this.trackId=e,this.currentTrack=r,this.toggleTrackModes(),!r){this.hls.trigger(y.SUBTITLE_TRACK_SWITCH,{id:e});return}const i=!!r.details&&!r.details.live;if(e===this.trackId&&r===s&&i)return;this.log(`Switching to subtitle-track ${e}`+(r?` "${r.name}" lang:${r.lang} group:${r.groupId}`:""));const{id:a,groupId:o="",name:l,type:c,url:u}=r;this.hls.trigger(y.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:c,url:u});const d=this.switchParams(r.url,s==null?void 0:s.details,r.details);this.loadPlaylist(d)}}class d1{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,s){const r=this.queues[t];r.push(e),r.length===1&&!s&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t;const s=new Promise(i=>{t=i}),r={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(r,e),s}executeNext(e){const t=this.queues[e];if(t.length){const s=t[0];try{s.execute()}catch(r){L.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${r}`),s.onError(r);const i=this.buffers[e];i!=null&&i.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const bc=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;class f1{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=s=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=s=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{const{media:s,mediaSource:r}=this;this.log("Media source opened"),s&&(s.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(y.MEDIA_ATTACHED,{media:s,mediaSource:r})),r&&r.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:s,_objectUrl:r}=this;s!==r&&L.error(`Media element src was set while attaching MediaSource (${r} > ${s})`)},this.hls=e;const t="[buffer-controller]";this.appendSource=x2(_t(e.config.preferManagedMediaSource)),this.log=L.log.bind(L,t),this.warn=L.warn.bind(L,t),this.error=L.error.bind(L,t),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.BUFFER_RESET,this.onBufferReset,this),e.on(y.BUFFER_APPENDING,this.onBufferAppending,this),e.on(y.BUFFER_CODECS,this.onBufferCodecs,this),e.on(y.BUFFER_EOS,this.onBufferEos,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.FRAG_PARSED,this.onFragParsed,this),e.on(y.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.BUFFER_RESET,this.onBufferReset,this),e.off(y.BUFFER_APPENDING,this.onBufferAppending,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.BUFFER_EOS,this.onBufferEos,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.FRAG_PARSED,this.onFragParsed,this),e.off(y.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new d1(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let s=2;(t.audio&&!t.video||!t.altAudio)&&(s=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=s,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){const s=this.media=t.media,r=_t(this.appendSource);if(s&&r){var i;const a=this.mediaSource=new r;this.log(`created media source: ${(i=a.constructor)==null?void 0:i.name}`),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));const o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{s.removeAttribute("src");const l=self.ManagedMediaSource;s.disableRemotePlayback=s.disableRemotePlayback||l&&a instanceof l,Cc(s),h1(s,o),s.load()}catch{s.src=o}else s.src=o;s.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:e,mediaSource:t,_objectUrl:s}=this;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(r){this.warn(`onMediaDetaching: ${r.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),s&&self.URL.revokeObjectURL(s),this.mediaSrc===s?(e.removeAttribute("src"),this.appendSource&&Cc(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(y.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e)}),this._initSourceBuffer(),this.hls.resumeBuffering()}resetBuffer(e){const t=this.sourceBuffer[e];try{if(t){var s;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(s=this.mediaSource)!=null&&s.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(r){this.warn(`onBufferReset ${e}`,r)}}onBufferCodecs(e,t){const s=this.getSourceBufferTypes().length,r=Object.keys(t);if(r.forEach(a=>{if(s){const l=this.tracks[a];if(l&&typeof l.buffer.changeType=="function"){var o;const{id:c,codec:u,levelCodec:d,container:f,metadata:g}=t[a],h=El(l.codec,l.levelCodec),m=h==null?void 0:h.replace(bc,"$1");let p=El(u,d);const E=(o=p)==null?void 0:o.replace(bc,"$1");if(p&&m!==E){a.slice(0,5)==="audio"&&(p=Tn(p,this.appendSource));const x=`${f};codecs=${p}`;this.appendChangeType(a,x),this.log(`switching codec ${h} to ${p}`),this.tracks[a]={buffer:l.buffer,codec:u,container:f,levelCodec:d,metadata:g,id:c}}}}else this.pendingTracks[a]=t[a]}),s)return;const i=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==i&&(this.log(`${i} bufferCodec event(s) expected ${r.join(",")}`),this.bufferCodecEventsExpected=i),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}appendChangeType(e,t){const{operationQueue:s}=this,r={execute:()=>{const i=this.sourceBuffer[e];i&&(this.log(`changing ${e} sourceBuffer type to ${t}`),i.changeType(t)),s.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:i=>{this.warn(`Failed to change ${e} SourceBuffer type`,i)}};s.append(r,e,!!this.pendingTracks[e])}onBufferAppending(e,t){const{hls:s,operationQueue:r,tracks:i}=this,{data:a,type:o,frag:l,part:c,chunkMeta:u}=t,d=u.buffering[o],f=self.performance.now();d.start=f;const g=l.stats.buffering,h=c?c.stats.buffering:null;g.start===0&&(g.start=f),h&&h.start===0&&(h.start=f);const m=i.audio;let p=!1;o==="audio"&&(m==null?void 0:m.container)==="audio/mpeg"&&(p=!this.lastMpegAudioChunk||u.id===1||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);const E=l.start,x={execute:()=>{if(d.executeStart=self.performance.now(),p){const v=this.sourceBuffer[o];if(v){const w=E-v.timestampOffset;Math.abs(w)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${E} (delta: ${w}) sn: ${l.sn})`),v.timestampOffset=E)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{const v=self.performance.now();d.executeEnd=d.end=v,g.first===0&&(g.first=v),h&&h.first===0&&(h.first=v);const{sourceBuffer:w}=this,b={};for(const I in w)b[I]=de.getBuffered(w[I]);this.appendErrors[o]=0,o==="audio"||o==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(y.BUFFER_APPENDED,{type:o,frag:l,part:c,chunkMeta:u,parent:l.type,timeRanges:b})},onError:v=>{const w={type:Z.MEDIA_ERROR,parent:l.type,details:k.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:c,chunkMeta:u,error:v,err:v,fatal:!1};if(v.code===DOMException.QUOTA_EXCEEDED_ERR)w.details=k.BUFFER_FULL_ERROR;else{const b=++this.appendErrors[o];w.details=k.BUFFER_APPEND_ERROR,this.warn(`Failed ${b}/${s.config.appendErrorMaxRetry} times to append segment in "${o}" sourceBuffer`),b>=s.config.appendErrorMaxRetry&&(w.fatal=!0)}s.trigger(y.ERROR,w)}};r.append(x,o,!!this.pendingTracks[o])}onBufferFlushing(e,t){const{operationQueue:s}=this,r=i=>({execute:this.removeExecutor.bind(this,i,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(y.BUFFER_FLUSHED,{type:i})},onError:a=>{this.warn(`Failed to remove from ${i} SourceBuffer`,a)}});t.type?s.append(r(t.type),t.type):this.getSourceBufferTypes().forEach(i=>{s.append(r(i),i)})}onFragParsed(e,t){const{frag:s,part:r}=t,i=[],a=r?r.elementaryStreams:s.elementaryStreams;a[le.AUDIOVIDEO]?i.push("audiovideo"):(a[le.AUDIO]&&i.push("audio"),a[le.VIDEO]&&i.push("video"));const o=()=>{const l=self.performance.now();s.stats.buffering.end=l,r&&(r.stats.buffering.end=l);const c=r?r.stats:s.stats;this.hls.trigger(y.FRAG_BUFFERED,{frag:s,part:r,stats:c,id:s.type})};i.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${s.type} level: ${s.level} sn: ${s.sn}`),this.blockBuffers(o,i)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((r,i)=>{const a=this.sourceBuffer[i];return a&&(!t.type||t.type===i)&&(a.ending=!0,a.ended||(a.ended=!0,this.log(`${i} sourceBuffer now EOS`))),r&&!!(!a||a.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(i=>{const a=this.sourceBuffer[i];a&&(a.ending=!1)});const{mediaSource:r}=this;if(!r||r.readyState!=="open"){r&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${r.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),r.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){const{hls:e,details:t,media:s}=this;if(!s||t===null||!this.getSourceBufferTypes().length)return;const i=e.config,a=s.currentTime,o=t.levelTargetDuration,l=t.live&&i.liveBackBufferLength!==null?i.liveBackBufferLength:i.backBufferLength;if(H(l)&&l>0){const c=Math.max(l,o),u=Math.floor(a/o)*o-c;this.flushBackBuffer(a,o,u)}if(H(i.frontBufferFlushThreshold)&&i.frontBufferFlushThreshold>0){const c=Math.max(i.maxBufferLength,i.frontBufferFlushThreshold),u=Math.max(c,o),d=Math.floor(a/o)*o+u;this.flushFrontBuffer(a,o,d)}}flushBackBuffer(e,t,s){const{details:r,sourceBuffer:i}=this;this.getSourceBufferTypes().forEach(o=>{const l=i[o];if(l){const c=de.getBuffered(l);if(c.length>0&&s>c.start(0)){if(this.hls.trigger(y.BACK_BUFFER_REACHED,{bufferEnd:s}),r!=null&&r.live)this.hls.trigger(y.LIVE_BACK_BUFFER_REACHED,{bufferEnd:s});else if(l.ended&&c.end(c.length-1)-e<t*2){this.log(`Cannot flush ${o} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(y.BUFFER_FLUSHING,{startOffset:0,endOffset:s,type:o})}}})}flushFrontBuffer(e,t,s){const{sourceBuffer:r}=this;this.getSourceBufferTypes().forEach(a=>{const o=r[a];if(o){const l=de.getBuffered(o),c=l.length;if(c<2)return;const u=l.start(c-1),d=l.end(c-1);if(s>u||e>=u&&e<=d)return;if(o.ended&&e-d<2*t){this.log(`Cannot flush ${a} front buffer while SourceBuffer is in ended state`);return}this.hls.trigger(y.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:a})}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:e,hls:t,media:s,mediaSource:r}=this,i=e.fragments[0].start+e.totalduration,a=s.duration,o=H(r.duration)?r.duration:0;e.live&&t.config.liveDurationInfinity?(r.duration=1/0,this.updateSeekableRange(e)):(i>o&&i>a||!H(a))&&(this.log(`Updating Media Source duration to ${i.toFixed(3)}`),r.duration=i)}updateSeekableRange(e){const t=this.mediaSource,s=e.fragments;if(s.length&&e.live&&t!=null&&t.setLiveSeekableRange){const i=Math.max(0,s[0].start),a=Math.max(i,i+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${i}-${a}.`),t.setLiveSeekableRange(i,a)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:s}=this,r=Object.keys(s).length;if(r&&(!e||r===2||"audiovideo"in s)){this.createSourceBuffers(s),this.pendingTracks={};const i=this.getSourceBufferTypes();if(i.length)this.hls.trigger(y.BUFFER_CREATED,{tracks:this.tracks}),i.forEach(a=>{t.executeNext(a)});else{const a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){const{sourceBuffer:t,mediaSource:s}=this;if(!s)throw Error("createSourceBuffers called when mediaSource was null");for(const i in e)if(!t[i]){var r;const a=e[i];if(!a)throw Error(`source buffer exists for track ${i}, however track does not`);let o=((r=a.levelCodec)==null?void 0:r.indexOf(","))===-1?a.levelCodec:a.codec;o&&i.slice(0,5)==="audio"&&(o=Tn(o,this.appendSource));const l=`${a.container};codecs=${o}`;this.log(`creating sourceBuffer(${l})`);try{const c=t[i]=s.addSourceBuffer(l),u=i;this.addBufferListener(u,"updatestart",this._onSBUpdateStart),this.addBufferListener(u,"updateend",this._onSBUpdateEnd),this.addBufferListener(u,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(u,"bufferedchange",(d,f)=>{const g=f.removedRanges;g!=null&&g.length&&this.hls.trigger(y.BUFFER_FLUSHED,{type:i})}),this.tracks[i]={buffer:c,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(c){this.error(`error while trying to add sourceBuffer: ${c.message}`),this.hls.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:c,sourceBufferName:i,mimeType:l})}}}get mediaSrc(){var e,t;const s=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return s==null?void 0:s.src}_onSBUpdateStart(e){const{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const{operationQueue:s}=this;s.current(e).onComplete(),s.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var s;const r=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(s=this.mediaSource)==null?void 0:s.readyState}`);this.error(`${r}`,t),this.hls.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:r,fatal:!1});const i=this.operationQueue.current(e);i&&i.onError(r)}removeExecutor(e,t,s){const{media:r,mediaSource:i,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!r||!i||!l){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}const c=H(r.duration)?r.duration:1/0,u=H(i.duration)?i.duration:1/0,d=Math.max(0,t),f=Math.min(s,c,u);f>d&&(!l.ending||l.ended)?(l.ended=!1,this.log(`Removing [${d},${f}] from the ${e} SourceBuffer`),l.remove(d,f)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){const s=this.sourceBuffer[t];if(!s){if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);return}s.ended=!1,s.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}const{operationQueue:s}=this,r=t.map(i=>s.appendBlocker(i));Promise.all(r).then(()=>{e(),t.forEach(i=>{const a=this.sourceBuffer[i];a!=null&&a.updating||s.shiftAndExecuteNext(i)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,s){const r=this.sourceBuffer[e];if(!r)return;const i=s.bind(this,e);this.listeners[e].push({event:t,listener:i}),r.addEventListener(t,i)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(s=>{t.removeEventListener(s.event,s.listener)})}}function Cc(n){const e=n.querySelectorAll("source");[].slice.call(e).forEach(t=>{n.removeChild(t)})}function h1(n,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,n.appendChild(t)}const p1={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},wc=n=>String.fromCharCode(p1[n]||n),Ye=15,ft=100,g1={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},m1={17:2,18:4,21:6,22:8,23:10,19:13,20:15},y1={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},E1={25:2,26:4,29:6,30:8,31:10,27:13,28:15},S1=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class T1{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const s=typeof t=="function"?t():t;L.log(`${this.time} [${e}] ${s}`)}}}const Mt=function(e){const t=[];for(let s=0;s<e.length;s++)t.push(e[s].toString(16));return t};class Lc{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 s=0;s<t.length;s++){const r=t[s];e.hasOwnProperty(r)&&(this[r]=e[r])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!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 x1{constructor(){this.uchar=" ",this.penState=new Lc}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 v1{constructor(e){this.chars=[],this.pos=0,this.currPenState=new Lc,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<ft;t++)this.chars.push(new x1);this.logger=e}equals(e){for(let t=0;t<ft;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<ft;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<ft;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>ft&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ft)}moveCursor(e){const t=this.pos+e;if(e>1)for(let s=this.pos+1;s<t+1;s++)this.chars[s].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=wc(e);if(this.pos>=ft){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<ft;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 s=0;s<ft;s++){const r=this.chars[s].uchar;r!==" "&&(t=!1),e.push(r)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class xi{constructor(e){this.rows=[],this.currRow=Ye-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Ye;t++)this.rows.push(new v1(e));this.logger=e}reset(){for(let e=0;e<Ye;e++)this.rows[e].clear();this.currRow=Ye-1}equals(e){let t=!0;for(let s=0;s<Ye;s++)if(!this.rows[s].equals(e.rows[s])){t=!1;break}return t}copy(e){for(let t=0;t<Ye;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Ye;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<Ye;o++)this.rows[o].clear();const i=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){const o=a.rows[i].cueStartTime,l=this.logger.time;if(o!==null&&l!==null&&o<l)for(let c=0;c<this.nrRollUpRows;c++)this.rows[t-this.nrRollUpRows+c+1].copy(a.rows[i+c])}}this.currRow=t;const s=this.rows[this.currRow];if(e.indent!==null){const i=e.indent,a=Math.max(i-1,0);s.setCursor(e.indent),e.color=s.chars[a].penState.foreground}const r={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(r)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}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 s="",r=-1;for(let i=0;i<Ye;i++){const a=this.rows[i].getTextString();a&&(r=i+1,e?t.push("Row "+r+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?s="["+t.join(" | ")+"]":s=t.join(`
|
|
53
|
+
`)),s}getTextAndFormat(){return this.rows}}class Ac{constructor(e,t,s){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 xi(s),this.nonDisplayedMemory=new xi(s),this.lastOutputScreen=new xi(s),this.currRollUpRow=this.displayedMemory.rows[Ye-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=s}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[Ye-1],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),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let s=0;s<e.length;s++)this.writeScreen.insertChar(e[s]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(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"),this.mode!=="MODE_TEXT"&&(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"),this.mode==="MODE_POP-ON"){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 s=Math.floor(e/2)-16,r=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=r[s]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t: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.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 Dc{constructor(e,t,s){this.channels=void 0,this.currentChannel=0,this.cmdHistory=C1(),this.logger=void 0;const r=this.logger=new T1;this.channels=[null,new Ac(e,t,r),new Ac(e+1,s,r)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let s=0;s<t.length;s+=2){const r=t[s]&127,i=t[s+1]&127;let a=!1,o=null;if(r===0&&i===0)continue;this.logger.log(3,()=>"["+Mt([t[s],t[s+1]])+"] -> ("+Mt([r,i])+")");const l=this.cmdHistory;if(r>=16&&r<=31){if(b1(r,i,l)){Bn(null,null,l),this.logger.log(3,()=>"Repeated command ("+Mt([r,i])+") is dropped");continue}Bn(r,i,this.cmdHistory),a=this.parseCmd(r,i),a||(a=this.parseMidrow(r,i)),a||(a=this.parsePAC(r,i)),a||(a=this.parseBackgroundAttributes(r,i))}else Bn(null,null,l);if(!a&&(o=this.parseChars(r,i),o)){const u=this.currentChannel;u&&u>0?this.channels[u].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+Mt([r,i])+" orig: "+Mt([t[s],t[s+1]]))}}parseCmd(e,t){const s=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=33&&t<=35;if(!(s||r))return!1;const i=e===20||e===21||e===23?1:2,a=this.channels[i];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),this.currentChannel=i,!0}parseMidrow(e,t){let s=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?s=1:s=2,s!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const r=this.channels[s];return r?(r.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+Mt([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let s;const r=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,i=(e===16||e===24)&&t>=64&&t<=95;if(!(r||i))return!1;const a=e<=23?1:2;t>=64&&t<=95?s=a===1?g1[e]:y1[e]:s=a===1?m1[e]:E1[e];const o=this.channels[a];return o?(o.setPAC(this.interpretPAC(s,t)),this.currentChannel=a,!0):!1}interpretPAC(e,t){let s;const r={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?s=t-96:s=t-64,r.underline=(s&1)===1,s<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(s/2)]:s<=15?(r.italics=!0,r.color="white"):r.indent=Math.floor((s-16)/2)*4,r}parseChars(e,t){let s,r=null,i=null;if(e>=25?(s=2,i=e-8):(s=1,i=e),i>=17&&i<=19){let a;i===17?a=t+80:i===18?a=t+112:a=t+144,this.logger.log(2,()=>"Special char '"+wc(a)+"' in channel "+s),r=[a]}else e>=32&&e<=127&&(r=t===0?[e]:[e,t]);return r&&this.logger.log(3,()=>"Char codes = "+Mt(r).join(",")),r}parseBackgroundAttributes(e,t){const s=(e===16||e===24)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=45&&t<=47;if(!(s||r))return!1;let i;const a={};e===16||e===24?(i=Math.floor((t-32)/2),a.background=S1[i],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));const o=e<=23?1:2;return this.channels[o].setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}Bn(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const s=this.channels[t];s&&s.cueSplitAtTime(e)}}}function Bn(n,e,t){t.a=n,t.b=e}function b1(n,e,t){return t.a===n&&t.b===e}function C1(){return{a:null,b:null}}class Un{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(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,s){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=s,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var vi=function(){if(Wt!=null&&Wt.VTTCue)return self.VTTCue;const n=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;const c=l.toLowerCase();return~o.indexOf(c)?c:!1}function s(o){return t(n,o)}function r(o){return t(e,o)}function i(o,...l){let c=1;for(;c<arguments.length;c++){const u=arguments[c];for(const d in u)o[d]=u[d]}return o}function a(o,l,c){const u=this,d={enumerable:!0};u.hasBeenReset=!1;let f="",g=!1,h=o,m=l,p=c,E=null,x="",v=!0,w="auto",b="start",I=50,A="middle",F=50,U="middle";Object.defineProperty(u,"id",i({},d,{get:function(){return f},set:function(O){f=""+O}})),Object.defineProperty(u,"pauseOnExit",i({},d,{get:function(){return g},set:function(O){g=!!O}})),Object.defineProperty(u,"startTime",i({},d,{get:function(){return h},set:function(O){if(typeof O!="number")throw new TypeError("Start time must be set to a number.");h=O,this.hasBeenReset=!0}})),Object.defineProperty(u,"endTime",i({},d,{get:function(){return m},set:function(O){if(typeof O!="number")throw new TypeError("End time must be set to a number.");m=O,this.hasBeenReset=!0}})),Object.defineProperty(u,"text",i({},d,{get:function(){return p},set:function(O){p=""+O,this.hasBeenReset=!0}})),Object.defineProperty(u,"region",i({},d,{get:function(){return E},set:function(O){E=O,this.hasBeenReset=!0}})),Object.defineProperty(u,"vertical",i({},d,{get:function(){return x},set:function(O){const B=s(O);if(B===!1)throw new SyntaxError("An invalid or illegal string was specified.");x=B,this.hasBeenReset=!0}})),Object.defineProperty(u,"snapToLines",i({},d,{get:function(){return v},set:function(O){v=!!O,this.hasBeenReset=!0}})),Object.defineProperty(u,"line",i({},d,{get:function(){return w},set:function(O){if(typeof O!="number"&&O!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");w=O,this.hasBeenReset=!0}})),Object.defineProperty(u,"lineAlign",i({},d,{get:function(){return b},set:function(O){const B=r(O);if(!B)throw new SyntaxError("An invalid or illegal string was specified.");b=B,this.hasBeenReset=!0}})),Object.defineProperty(u,"position",i({},d,{get:function(){return I},set:function(O){if(O<0||O>100)throw new Error("Position must be between 0 and 100.");I=O,this.hasBeenReset=!0}})),Object.defineProperty(u,"positionAlign",i({},d,{get:function(){return A},set:function(O){const B=r(O);if(!B)throw new SyntaxError("An invalid or illegal string was specified.");A=B,this.hasBeenReset=!0}})),Object.defineProperty(u,"size",i({},d,{get:function(){return F},set:function(O){if(O<0||O>100)throw new Error("Size must be between 0 and 100.");F=O,this.hasBeenReset=!0}})),Object.defineProperty(u,"align",i({},d,{get:function(){return U},set:function(O){const B=r(O);if(!B)throw new SyntaxError("An invalid or illegal string was specified.");U=B,this.hasBeenReset=!0}})),u.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}();class w1{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function Ic(n){function e(s,r,i,a){return(s|0)*3600+(r|0)*60+(i|0)+parseFloat(a||0)}const t=n.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}let L1=class{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,s){return s?this.has(e)?this.values[e]:t[s]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,s){for(let r=0;r<s.length;++r)if(t===s[r]){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 s=parseFloat(t);if(s>=0&&s<=100)return this.set(e,s),!0}return!1}};function Rc(n,e,t,s){const r=s?n.split(s):[n];for(const i in r){if(typeof r[i]!="string")continue;const a=r[i].split(t);if(a.length!==2)continue;const o=a[0],l=a[1];e(o,l)}}const bi=new vi(0,0,""),$n=bi.align==="middle"?"middle":"center";function A1(n,e,t){const s=n;function r(){const o=Ic(n);if(o===null)throw new Error("Malformed timestamp: "+s);return n=n.replace(/^[^\sa-zA-Z-]+/,""),o}function i(o,l){const c=new L1;Rc(o,function(f,g){let h;switch(f){case"region":for(let m=t.length-1;m>=0;m--)if(t[m].id===g){c.set(f,t[m].region);break}break;case"vertical":c.alt(f,g,["rl","lr"]);break;case"line":h=g.split(","),c.integer(f,h[0]),c.percent(f,h[0])&&c.set("snapToLines",!1),c.alt(f,h[0],["auto"]),h.length===2&&c.alt("lineAlign",h[1],["start",$n,"end"]);break;case"position":h=g.split(","),c.percent(f,h[0]),h.length===2&&c.alt("positionAlign",h[1],["start",$n,"end","line-left","line-right","auto"]);break;case"size":c.percent(f,g);break;case"align":c.alt(f,g,["start",$n,"end","left","right"]);break}},/:/,/\s/),l.region=c.get("region",null),l.vertical=c.get("vertical","");let u=c.get("line","auto");u==="auto"&&bi.line===-1&&(u=-1),l.line=u,l.lineAlign=c.get("lineAlign","start"),l.snapToLines=c.get("snapToLines",!0),l.size=c.get("size",100),l.align=c.get("align",$n);let d=c.get("position","auto");d==="auto"&&bi.position===50&&(d=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=d}function a(){n=n.replace(/^\s+/,"")}if(a(),e.startTime=r(),a(),n.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+s);n=n.slice(3),a(),e.endTime=r(),a(),i(n,e)}function kc(n){return n.replace(/<br(?: \/)?>/gi,`
|
|
54
|
+
`)}class D1{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new w1,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function s(){let i=t.buffer,a=0;for(i=kc(i);a<i.length&&i[a]!=="\r"&&i[a]!==`
|
|
55
|
+
`;)++a;const o=i.slice(0,a);return i[a]==="\r"&&++a,i[a]===`
|
|
56
|
+
`&&++a,t.buffer=i.slice(a),o}function r(i){Rc(i,function(a,o){},/:/)}try{let i="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;i=s();const o=i.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:i=s(),t.state){case"HEADER":/:/.test(i)?r(i):i||(t.state="ID");continue;case"NOTE":i||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(i)){t.state="NOTE";break}if(!i)continue;if(t.cue=new vi(0,0,""),t.state="CUE",i.indexOf("-->")===-1){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{A1(i,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const o=i.indexOf("-->")!==-1;if(!i||o&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
|
|
57
|
+
`),t.cue.text+=i}continue;case"BADCUE":i||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
|
|
58
|
+
|
|
59
|
+
`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const I1=/\r\n|\n\r|\n|\r/g,Ci=function(e,t,s=0){return e.slice(s,s+t.length)===t},R1=function(e){let t=parseInt(e.slice(-3));const s=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),i=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!H(t)||!H(s)||!H(r)||!H(i))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*s,t+=60*1e3*r,t+=60*60*1e3*i,t},wi=function(e){let t=5381,s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return(t>>>0).toString()};function Li(n,e,t){return wi(n.toString())+wi(e.toString())+wi(t)}const k1=function(e,t,s){let r=e[t],i=e[r.prevCC];if(!i||!i.new&&r.new){e.ccOffset=e.presentationOffset=r.start,r.new=!1;return}for(;(a=i)!=null&&a.new;){var a;e.ccOffset+=r.start-i.start,r.new=!1,r=i,i=e[r.prevCC]}e.presentationOffset=s};function P1(n,e,t,s,r,i,a){const o=new D1,l=Qe(new Uint8Array(n)).trim().replace(I1,`
|
|
60
|
+
`).split(`
|
|
61
|
+
`),c=[],u=e?Yp(e.baseTime,e.timescale):0;let d="00:00.000",f=0,g=0,h,m=!0;o.oncue=function(p){const E=t[s];let x=t.ccOffset;const v=(f-u)/9e4;if(E!=null&&E.new&&(g!==void 0?x=t.ccOffset=E.start:k1(t,s,v)),v){if(!e){h=new Error("Missing initPTS for VTT MPEGTS");return}x=v-t.presentationOffset}const w=p.endTime-p.startTime,b=He((p.startTime+x-g)*9e4,r*9e4)/9e4;p.startTime=Math.max(b,0),p.endTime=Math.max(b+w,0);const I=p.text.trim();p.text=decodeURIComponent(encodeURIComponent(I)),p.id||(p.id=Li(p.startTime,p.endTime,I)),p.endTime>0&&c.push(p)},o.onparsingerror=function(p){h=p},o.onflush=function(){if(h){a(h);return}i(c)},l.forEach(p=>{if(m)if(Ci(p,"X-TIMESTAMP-MAP=")){m=!1,p.slice(16).split(",").forEach(E=>{Ci(E,"LOCAL:")?d=E.slice(6):Ci(E,"MPEGTS:")&&(f=parseInt(E.slice(7)))});try{g=R1(d)/1e3}catch(E){h=E}return}else p===""&&(m=!1);o.parse(p+`
|
|
62
|
+
`)}),o.flush()}const Ai="stpp.ttml.im1t",Pc=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,_c=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,_1={left:"start",center:"center",right:"end",start:"start",end:"end"};function Oc(n,e,t,s){const r=J(new Uint8Array(n),["mdat"]);if(r.length===0){s(new Error("Could not parse IMSC1 mdat"));return}const i=r.map(o=>Qe(o)),a=qp(e.baseTime,1,e.timescale);try{i.forEach(o=>t(O1(o,a)))}catch(o){s(o)}}function O1(n,e){const r=new DOMParser().parseFromString(n,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");const i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(i).reduce((d,f)=>(d[f]=r.getAttribute(`ttp:${f}`)||i[f],d),{}),o=r.getAttribute("xml:space")!=="preserve",l=Fc(Di(r,"styling","style")),c=Fc(Di(r,"layout","region")),u=Di(r,"body","[begin]");return[].map.call(u,d=>{const f=Mc(d,o);if(!f||!d.hasAttribute("begin"))return null;const g=Ri(d.getAttribute("begin"),a),h=Ri(d.getAttribute("dur"),a);let m=Ri(d.getAttribute("end"),a);if(g===null)throw Nc(d);if(m===null){if(h===null)throw Nc(d);m=g+h}const p=new vi(g-e,m-e,f);p.id=Li(p.startTime,p.endTime,p.text);const E=c[d.getAttribute("region")],x=l[d.getAttribute("style")],v=F1(E,x,l),{textAlign:w}=v;if(w){const b=_1[w];b&&(p.lineAlign=b),p.align=w}return ye(p,v),p}).filter(d=>d!==null)}function Di(n,e,t){const s=n.getElementsByTagName(e)[0];return s?[].slice.call(s.querySelectorAll(t)):[]}function Fc(n){return n.reduce((e,t)=>{const s=t.getAttribute("xml:id");return s&&(e[s]=t),e},{})}function Mc(n,e){return[].slice.call(n.childNodes).reduce((t,s,r)=>{var i;return s.nodeName==="br"&&r?t+`
|
|
63
|
+
`:(i=s.childNodes)!=null&&i.length?Mc(s,e):e?t+s.textContent.trim().replace(/\s+/g," "):t+s.textContent},"")}function F1(n,e,t){const s="http://www.w3.org/ns/ttml#styling";let r=null;const i=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=n!=null&&n.hasAttribute("style")?n.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(r=t[a]),i.reduce((o,l)=>{const c=Ii(e,s,l)||Ii(n,s,l)||Ii(r,s,l);return c&&(o[l]=c),o},{})}function Ii(n,e,t){return n&&n.hasAttributeNS(e,t)?n.getAttributeNS(e,t):null}function Nc(n){return new Error(`Could not parse ttml timestamp ${n}`)}function Ri(n,e){if(!n)return null;let t=Ic(n);return t===null&&(Pc.test(n)?t=M1(n,e):_c.test(n)&&(t=N1(n,e))),t}function M1(n,e){const t=Pc.exec(n),s=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+s/e.frameRate}function N1(n,e){const t=_c.exec(n),s=Number(t[1]);switch(t[2]){case"h":return s*3600;case"m":return s*60;case"ms":return s*1e3;case"f":return s/e.frameRate;case"t":return s/e.tickRate}return s}class B1{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=$c(),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(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this),e.on(y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this),e.off(y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){const e=new Un(this,"textTrack1"),t=new Un(this,"textTrack2"),s=new Un(this,"textTrack3"),r=new Un(this,"textTrack4");this.cea608Parser1=new Dc(1,e,t),this.cea608Parser2=new Dc(3,s,r)}}addCues(e,t,s,r,i){let a=!1;for(let o=i.length;o--;){const l=i[o],c=U1(l[0],l[1],t,s);if(c>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],s),a=!0,c/(s-t)>.5))return}if(a||i.push([t,s]),this.config.renderTextTracksNatively){const o=this.captionsTracks[e];this.Cues.newCue(o,t,s,r)}else{const o=this.Cues.newCue(null,t,s,r);this.hls.trigger(y.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:s,initPTS:r,timescale:i}){const{unparsedVttFrags:a}=this;s==="main"&&(this.initPTS[t.cc]={baseTime:r,timescale:i}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(y.FRAG_LOADED,o)}))}getExistingTrack(e,t){const{media:s}=this;if(s)for(let r=0;r<s.textTracks.length;r++){const i=s.textTracks[r];if(Uc(i,{name:e,lang:t,attrs:{}}))return i}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:s,media:r}=this,{label:i,languageCode:a}=t[e],o=this.getExistingTrack(i,a);if(o)s[e]=o,jt(s[e]),Il(s[e],r);else{const l=this.createTextTrack("captions",i,a);l&&(l[e]=!0,s[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const s=t.label,r={_id:e,label:s,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}createTextTrack(e,t,s){const r=this.media;if(r)return r.addTextTrack(e,t,s)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach(t=>{jt(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=$c(),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 s=0;s<t.length;s++)jt(t[s])}onSubtitleTracksUpdated(e,t){const s=t.subtitleTracks||[],r=s.some(i=>i.textCodec===Ai);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(xc(this.tracks,s)){this.tracks=s;return}if(this.textTracks=[],this.tracks=s,this.config.renderTextTracksNatively){const a=this.media,o=a?xn(a.textTracks):null;if(this.tracks.forEach((l,c)=>{let u;if(o){let d=null;for(let f=0;f<o.length;f++)if(o[f]&&Uc(o[f],l)){d=o[f],o[f]=null;break}d&&(u=d)}if(u)jt(u);else{const d=Bc(l);u=this.createTextTrack(d,l.name,l.lang),u&&(u.mode="disabled")}u&&this.textTracks.push(u)}),o!=null&&o.length){const l=o.filter(c=>c!==null).map(c=>c.label);l.length&&L.warn(`Media element contains unused subtitle tracks: ${l.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(s=>{const r=/(?:CC|SERVICE)([1-4])/.exec(s.instreamId);if(!r)return;const i=`textTrack${r[1]}`,a=this.captionsProperties[i];a&&(a.label=s.name,s.lang&&(a.languageCode=s.lang),a.media=s)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===q.MAIN){var s,r;const{cea608Parser1:i,cea608Parser2:a,lastSn:o}=this,{cc:l,sn:c}=t.frag,u=(s=(r=t.part)==null?void 0:r.index)!=null?s:-1;i&&a&&(c!==o+1||c===o&&u!==this.lastPartIndex+1||l!==this.lastCc)&&(i.reset(),a.reset()),this.lastCc=l,this.lastSn=c,this.lastPartIndex=u}}onFragLoaded(e,t){const{frag:s,payload:r}=t;if(s.type===q.SUBTITLE)if(r.byteLength){const i=s.decryptdata,a="stats"in t;if(i==null||!i.encrypted||a){const o=this.tracks[s.level],l=this.vttCCs;l[s.cc]||(l[s.cc]={start:s.start,prevCC:this.prevCC,new:!0},this.prevCC=s.cc),o&&o.textCodec===Ai?this._parseIMSC1(s,r):this._parseVTTs(t)}}else this.hls.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const s=this.hls;Oc(t,this.initPTS[e.cc],r=>{this._appendCues(r,e.level),s.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},r=>{L.log(`Failed to parse IMSC1: ${r}`),s.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:r})})}_parseVTTs(e){var t;const{frag:s,payload:r}=e,{initPTS:i,unparsedVttFrags:a}=this,o=i.length-1;if(!i[s.cc]&&o===-1){a.push(e);return}const l=this.hls,c=(t=s.initSegment)!=null&&t.data?Ge(s.initSegment.data,new Uint8Array(r)):r;P1(c,this.initPTS[s.cc],this.vttCCs,s.cc,s.start,u=>{this._appendCues(u,s.level),l.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:s})},u=>{const d=u.message==="Missing initPTS for VTT MPEGTS";d?a.push(e):this._fallbackToIMSC1(s,r),L.log(`Failed to parse VTT cue: ${u}`),!(d&&o>s.cc)&&l.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:u})})}_fallbackToIMSC1(e,t){const s=this.tracks[e.level];s.textCodec||Oc(t,this.initPTS[e.cc],()=>{s.textCodec=Ai,this._parseIMSC1(e,t)},()=>{s.textCodec="wvtt"})}_appendCues(e,t){const s=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];if(!r||r.mode==="disabled")return;e.forEach(i=>Rl(r,i))}else{const r=this.tracks[t];if(!r)return;const i=r.default?"default":"subtitles"+t;s.trigger(y.CUES_PARSED,{type:"subtitles",cues:e,track:i})}}onFragDecrypted(e,t){const{frag:s}=t;s.type===q.SUBTITLE&&this.onFragLoaded(y.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();const{cea608Parser1:s,cea608Parser2:r}=this;if(!this.enabled||!s||!r)return;const{frag:i,samples:a}=t;if(!(i.type===q.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let o=0;o<a.length;o++){const l=a[o].bytes;if(l){const c=this.extractCea608Data(l);s.addData(a[o].pts,c[0]),r.addData(a[o].pts,c[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:s,endOffsetSubtitles:r,type:i}){const{media:a}=this;if(!(!a||a.currentTime<s)){if(!i||i==="video"){const{captionsTracks:o}=this;Object.keys(o).forEach(l=>Jr(o[l],t,s))}if(this.config.renderTextTracksNatively&&t===0&&r!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(l=>Jr(o[l],t,r))}}}extractCea608Data(e){const t=[[],[]],s=e[0]&31;let r=2;for(let i=0;i<s;i++){const a=e[r++],o=127&e[r++],l=127&e[r++];if(o===0&&l===0)continue;if((4&a)!==0){const u=3&a;(u===0||u===1)&&(t[u].push(o),t[u].push(l))}}return t}}function Bc(n){return n.characteristics&&/transcribes-spoken-dialog/gi.test(n.characteristics)&&/describes-music-and-sound/gi.test(n.characteristics)?"captions":"subtitles"}function Uc(n,e){return!!n&&n.kind===Bc(e)&&Ti(e,n)}function U1(n,e,t,s){return Math.min(e,s)-Math.max(n,t)}function $c(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class ki{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(y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.BUFFER_CODECS,this.onBufferCodecs,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const s=this.hls.levels[t.droppedLevel];this.isLevelAllowed(s)&&this.restrictedLevels.push({bitrate:s.bitrate,height:s.height,width:s.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 s=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,s.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&H(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}const e=this.hls.levels;if(e.length){const t=this.hls,s=this.getMaxLevel(e.length-1);s!==this.autoLevelCapping&&L.log(`Setting autoLevelCapping to ${s}: ${e[s].height}p@${e[s].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=s,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 s=t.filter((r,i)=>this.isLevelAllowed(r)&&i<=e);return this.clientRect=null,ki.getMaxLevelByMediaSize(s,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 s=e.getBoundingClientRect();t.width=s.width,t.height=s.height,!t.width&&!t.height&&(t.width=s.right-s.left||e.width||0,t.height=s.bottom-s.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{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(s=>e.bitrate===s.bitrate&&e.width===s.width&&e.height===s.height)}static getMaxLevelByMediaSize(e,t,s){if(!(e!=null&&e.length))return-1;const r=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0;let i=e.length-1;const a=Math.max(t,s);for(let o=0;o<e.length;o+=1){const l=e[o];if((l.width>=a||l.height>=a)&&r(l,e[o+1])){i=o;break}}return i}}class $1{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(y.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const s=this.hls.config;if(s.capLevelOnFPSDrop){const r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),s.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,s){const r=performance.now();if(t){if(this.lastTime){const i=r-this.lastTime,a=s-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/i,c=this.hls;if(c.trigger(y.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:s}),l>0&&a>c.config.fpsDroppedMonitoringThreshold*o){let u=c.currentLevel;L.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(c.autoLevelCapping===-1||c.autoLevelCapping>=u)&&(u=u-1,c.trigger(y.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:c.currentLevel}),c.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=s,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)}}const Vn="[eme]";class Qt{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=Qt.CDMCleanupPromise?[Qt.CDMCleanupPromise]:[],this.debug=L.debug.bind(L,Vn),this.log=L.log.bind(L,Vn),this.warn=L.warn.bind(L,Vn),this.error=L.error.bind(L,Vn),this.onMediaEncrypted=t=>{const{initDataType:s,initData:r}=t,i=`"${t.type}" event: init data type: "${s}"`;if(this.debug(i),r!==null){if(!this.keyFormatPromise){let a=Object.keys(this.keySystemAccessPromises);a.length||(a=hn(this.config));const o=a.map(Hr).filter(l=>!!l);this.keyFormatPromise=this.getKeyFormatPromise(o)}this.keyFormatPromise.then(a=>{const o=Vr(a);let l,c;if(s==="sinf"){if(o!==ae.FAIRPLAY){this.warn(`Ignoring unexpected "${t.type}" event with init data type: "${s}" for selected key-system ${o}`);return}const h=Te(new Uint8Array(r));try{const m=Ur(JSON.parse(h).sinf),p=cl(m);if(!p)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");l=p.subarray(8,24),c=ae.FAIRPLAY}catch(m){this.warn(`${i} Failed to parse sinf: ${m}`);return}}else{if(o!==ae.WIDEVINE&&o!==ae.PLAYREADY){this.warn(`Ignoring unexpected "${t.type}" event with init data type: "${s}" for selected key-system ${o}`);return}const h=y2(r),m=h.filter(E=>!!E.systemId&&Gr(E.systemId)===o);m.length>1&&this.warn(`${i} Using first of ${m.length} pssh found for selected key-system ${o}`);const p=m[0];if(!p){h.length===0||h.some(E=>!E.systemId)?this.warn(`${i} contains incomplete or invalid pssh data`):this.log(`ignoring ${i} for ${h.map(E=>Gr(E.systemId)).join(",")} pssh data in favor of playlist keys`);return}if(c=Gr(p.systemId),p.version===0&&p.data)if(c===ae.WIDEVINE){const E=p.data.length-22;l=p.data.subarray(E,E+16)}else c===ae.PLAYREADY&&(l=el(p.data))}if(!c||!l){this.log(`Unable to handle ${i} with key-system ${o}`);return}const u=Je.hexDump(l),{keyIdToKeySessionPromise:d,mediaKeySessions:f}=this;let g=d[u];for(let h=0;h<f.length;h++){const m=f[h],p=m.decryptdata;if(!p.keyId)continue;const E=Je.hexDump(p.keyId);if(u===E||p.uri.replace(/-/g,"").indexOf(u)!==-1){if(g=d[E],p.pssh)break;delete d[E],p.pssh=new Uint8Array(r),p.keyId=l,g=d[u]=g.then(()=>this.generateRequestWithPreferredKeySession(m,s,r,"encrypted-event-key-match")),g.catch(x=>this.handleError(x));break}}if(!g){if(c!==o){this.log(`Ignoring "${i}" with ${c} init data for selected key-system ${o}`);return}g=d[u]=this.getKeySystemSelectionPromise([c]).then(({keySystem:h,mediaKeys:m})=>{var p;this.throwIfDestroyed();const E=new ys("ISO-23001-7",u,(p=Hr(h))!=null?p:"");return E.pssh=new Uint8Array(r),E.keyId=l,this.attemptSetMediaKeys(h,m).then(()=>{this.throwIfDestroyed();const x=this.createMediaKeySessionContext({decryptdata:E,keySystem:h,mediaKeys:m});return this.generateRequestWithPreferredKeySession(x,s,r,"encrypted-event-no-match")})}),g.catch(h=>this.handleError(h))}})}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),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(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(y.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(y.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:s}=this.config,r=t[e];if(r)return r.licenseUrl;if(e===ae.WIDEVINE&&s)return s}getLicenseServerUrlOrThrow(e){const t=this.getLicenseServerUrl(e);if(t===void 0)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){const{drmSystems:t}=this.config,s=t[e];if(s)return s.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,s=(a,o,l)=>!!a&&l.indexOf(a)===o,r=t.map(a=>a.audioCodec).filter(s),i=t.map(a=>a.videoCodec).filter(s);return r.length+i.length===0&&i.push("avc1.42e01e"),new Promise((a,o)=>{const l=c=>{const u=c.shift();this.getMediaKeysPromise(u,r,i).then(d=>a({keySystem:u,mediaKeys:d})).catch(d=>{c.length?l(c):d instanceof Ke?o(d):o(new Ke({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_NO_ACCESS,error:d,fatal:!0},d.message))})};l(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:s}=this.config;if(typeof s!="function"){let r=`Configured requestMediaKeySystemAccess is not a function ${s}`;return Jo===null&&self.location.protocol==="http:"&&(r=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(r))}return s(e,t)}getMediaKeysPromise(e,t,s){const r=jh(e,t,s,this.config.drmSystemOptions),i=this.keySystemAccessPromises[e];let a=i==null?void 0:i.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(r)}`),a=this.requestMediaKeySystemAccess(e,r);const o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);const c=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(u=>(this.log(`Media-keys created for "${e}"`),c.then(d=>d?this.setMediaKeysServerCertificate(u,e,d):u))),o.mediaKeys.catch(u=>{this.error(`Failed to create media-keys for "${e}"}: ${u}`)}),o.mediaKeys})}return a.then(()=>i.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:s}){this.log(`Creating key-system session "${t}" keyId: ${Je.hexDump(e.keyId||[])}`);const r=s.createSession(),i={decryptdata:e,keySystem:t,mediaKeys:s,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(i),i}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const s=this.createMediaKeySessionContext(e),r=this.getKeyIdString(t),i="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(s,i,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Je.hexDump(e.keyId)}updateKeySession(e,t){var s;const r=e.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyID ${Je.hexDump(((s=e.decryptdata)==null?void 0:s.keyId)||[])}
|
|
64
|
+
} (data length: ${t&&t.byteLength})`),r.update(t)}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){return new Promise((t,s)=>{const r=hn(this.config),i=e.map(Vr).filter(a=>!!a&&r.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(i).then(({keySystem:a})=>{const o=Hr(a);o?t(o):s(new Error(`Unable to find format for key-system "${a}"`))}).catch(s)})}loadKey(e){const t=e.keyInfo.decryptdata,s=this.getKeyIdString(t),r=`(keyId: ${s} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);let i=this.keyIdToKeySessionPromise[s];return i||(i=this.keyIdToKeySessionPromise[s]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();const l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t});return this.generateRequestWithPreferredKeySession(l,"cenc",t.pssh,"playlist-key")}))),i.catch(a=>this.handleError(a))),i}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof Ke?this.hls.trigger(y.ERROR,e.data):this.hls.trigger(y.ERROR,{type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),s=this.keyIdToKeySessionPromise[t];if(!s){const r=Vr(e.keyFormat),i=r?[r]:hn(this.config);return this.attemptKeySystemAccess(i)}return s}getKeySystemSelectionPromise(e){if(e.length||(e=hn(this.config)),e.length===0)throw new Ke({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){const s=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const r=Promise.all(s).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),s.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(i=>s.indexOf(i)===-1)})}generateRequestWithPreferredKeySession(e,t,s,r){var i,a;const o=(i=this.config.drmSystems)==null||(a=i[e.keySystem])==null?void 0:a.generateRequest;if(o)try{const h=o.call(this.hls,t,s,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");t=h.initDataType,s=e.decryptdata.pssh=h.initData?new Uint8Array(h.initData):null}catch(h){var l;if(this.warn(h.message),(l=this.hls)!=null&&l.config.debug)throw h}if(s===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(e);const c=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${r}": ${c} (init data type: ${t} length: ${s?s.byteLength:null})`);const u=new Si,d=e._onmessage=h=>{const m=e.mediaKeysSession;if(!m){u.emit("error",new Error("invalid state"));return}const{messageType:p,message:E}=h;this.log(`"${p}" message event for session "${m.sessionId}" message size: ${E.byteLength}`),p==="license-request"||p==="license-renewal"?this.renewLicense(e,E).catch(x=>{this.handleError(x),u.emit("error",x)}):p==="license-release"?e.keySystem===ae.FAIRPLAY&&(this.updateKeySession(e,$r("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${p}"`)},f=e._onkeystatuseschange=h=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);const p=e.keyStatus;u.emit("keyStatus",p),p==="expired"&&(this.warn(`${e.keySystem} expired for key ${c}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",d),e.mediaKeysSession.addEventListener("keystatuseschange",f);const g=new Promise((h,m)=>{u.on("error",m),u.on("keyStatus",p=>{p.startsWith("usable")?h():p==="output-restricted"?m(new Ke({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):p==="internal-error"?m(new Ke({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${p}"`)):p==="expired"?m(new Error("key expired while generating request")):this.warn(`unhandled key status change "${p}"`)})});return e.mediaKeysSession.generateRequest(t,s).then(()=>{var h;this.log(`Request generated for key-session "${(h=e.mediaKeysSession)==null?void 0:h.sessionId}" keyId: ${c}`)}).catch(h=>{throw new Ke({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_NO_SESSION,error:h,fatal:!1},`Error generating key-session request: ${h}`)}).then(()=>g).catch(h=>{throw u.removeAllListeners(),this.removeSession(e),h}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,s)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Je.hexDump("buffer"in s?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s))} session keyId: ${Je.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,s=t.loader,r=new s(t),i=this.getServerCertificateUrl(e);return i?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{const l={responseType:"arraybuffer",url:i},c=t.certLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(f,g,h,m)=>{a(f.data)},onError:(f,g,h,m)=>{o(new Ke({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:h,response:ve({url:l.url,data:void 0},f)},`"${e}" certificate request failed (${i}). Status: ${f.code} (${f.text})`))},onTimeout:(f,g,h)=>{o(new Ke({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:h,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(f,g,h)=>{o(new Error("aborted"))}};r.load(l,u,d)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,s){return new Promise((r,i)=>{e.setServerCertificate(s).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${s==null?void 0:s.byteLength}) on "${t}"`),r(e)}).catch(a=>{i(new Ke({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(s=>this.updateKeySession(e,new Uint8Array(s)).catch(r=>{throw new Ke({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:r,fatal:!0},r.message)}))}unpackPlayReadyKeyMessage(e,t){const s=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!s.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const r=new DOMParser().parseFromString(s,"application/xml"),i=r.querySelectorAll("HttpHeader");if(i.length>0){let u;for(let d=0,f=i.length;d<f;d++){var a,o;u=i[d];const g=(a=u.querySelector("name"))==null?void 0:a.textContent,h=(o=u.querySelector("value"))==null?void 0:o.textContent;g&&h&&e.setRequestHeader(g,h)}}const l=r.querySelector("Challenge"),c=l==null?void 0:l.textContent;if(!c)throw new Error("Cannot find <Challenge> in key message");return $r(atob(c))}setupLicenseXHR(e,t,s,r){const i=this.config.licenseXhrSetup;return i?Promise.resolve().then(()=>{if(!s.decryptdata)throw new Error("Key removed");return i.call(this.hls,e,t,s,r)}).catch(a=>{if(!s.decryptdata)throw a;return e.open("POST",t,!0),i.call(this.hls,e,t,s,r)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||r})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))}requestLicense(e,t){const s=this.config.keyLoadPolicy.default;return new Promise((r,i)=>{const a=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${a}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return i(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);const c=this.config.licenseResponseCallback;if(c)try{l=c.call(this.hls,o,a,e)}catch(u){this.error(u)}r(l)}else{const l=s.errorRetry,c=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>c||o.status>=400&&o.status<500)i(new Ke({type:Z.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{const u=c-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} attempts left`),this.requestLicense(e,t).then(r,i)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:c})=>{e.keySystem==ae.PLAYREADY&&(c=this.unpackPlayReadyKeyMessage(l,c)),l.send(c)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const s=t.media;this.media=s,s.removeEventListener("encrypted",this.onMediaEncrypted),s.removeEventListener("waitingforkey",this.onWaitingForKey),s.addEventListener("encrypted",this.onMediaEncrypted),s.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},ys.clearKeyUriToKeyIdMap();const s=t.length;Qt.CDMCleanupPromise=Promise.all(t.map(r=>this.removeSession(r)).concat(e==null?void 0:e.setMediaKeys(null).catch(r=>{this.log(`Could not clear media keys: ${r}`)}))).then(()=>{s&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(r=>{this.log(`Could not close sessions and clear media keys: ${r}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const s=t.reduce((r,i)=>(r.indexOf(i.keyFormat)===-1&&r.push(i.keyFormat),r),[]);this.log(`Selecting key-system from session-keys ${s.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(s)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:s}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),s&&s.readyState!==XMLHttpRequest.DONE&&s.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(e);return r>-1&&this.mediaKeySessions.splice(r,1),t.remove().catch(i=>{this.log(`Could not remove session: ${i}`)}).then(()=>t.close()).catch(i=>{this.log(`Could not close session: ${i}`)})}}}Qt.CDMCleanupPromise=void 0;class Ke 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}}var ke;(function(n){n.MANIFEST="m",n.AUDIO="a",n.VIDEO="v",n.MUXED="av",n.INIT="i",n.CAPTION="c",n.TIMED_TEXT="tt",n.KEY="k",n.OTHER="o"})(ke||(ke={}));var Pi;(function(n){n.DASH="d",n.HLS="h",n.SMOOTH="s",n.OTHER="o"})(Pi||(Pi={}));var Nt;(function(n){n.OBJECT="CMCD-Object",n.REQUEST="CMCD-Request",n.SESSION="CMCD-Session",n.STATUS="CMCD-Status"})(Nt||(Nt={}));const V1={[Nt.OBJECT]:["br","d","ot","tb"],[Nt.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[Nt.SESSION]:["cid","pr","sf","sid","st","v"],[Nt.STATUS]:["bs","rtp"]};class Jt{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(s=>s instanceof Jt?s:new Jt(s))),this.value=e,this.params=t}}class Vc{constructor(e){this.description=void 0,this.description=e}}const G1="Dict";function H1(n){return Array.isArray(n)?JSON.stringify(n):n instanceof Map?"Map{}":n instanceof Set?"Set{}":typeof n=="object"?JSON.stringify(n):String(n)}function K1(n,e,t,s){return new Error(`failed to ${n} "${H1(e)}" as ${t}`,{cause:s})}const Gc="Bare Item",W1="Boolean",j1="Byte Sequence",z1="Decimal",q1="Integer";function Y1(n){return n<-999999999999999||999999999999999<n}const X1=/[\x00-\x1f\x7f]+/,Z1="Token",Q1="Key";function rt(n,e,t){return K1("serialize",n,e,t)}function J1(n){if(typeof n!="boolean")throw rt(n,W1);return n?"?1":"?0"}function eg(n){return btoa(String.fromCharCode(...n))}function tg(n){if(ArrayBuffer.isView(n)===!1)throw rt(n,j1);return`:${eg(n)}:`}function Hc(n){if(Y1(n))throw rt(n,q1);return n.toString()}function sg(n){return`@${Hc(n.getTime()/1e3)}`}function Kc(n,e){if(n<0)return-Kc(-n,e);const t=Math.pow(10,e);if(Math.abs(n*t%1-.5)<Number.EPSILON){const r=Math.floor(n*t);return(r%2===0?r:r+1)/t}else return Math.round(n*t)/t}function ng(n){const e=Kc(n,3);if(Math.floor(Math.abs(e)).toString().length>12)throw rt(n,z1);const t=e.toString();return t.includes(".")?t:`${t}.0`}const rg="String";function ig(n){if(X1.test(n))throw rt(n,rg);return`"${n.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function ag(n){return n.description||n.toString().slice(7,-1)}function Wc(n){const e=ag(n);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw rt(e,Z1);return e}function _i(n){switch(typeof n){case"number":if(!H(n))throw rt(n,Gc);return Number.isInteger(n)?Hc(n):ng(n);case"string":return ig(n);case"symbol":return Wc(n);case"boolean":return J1(n);case"object":if(n instanceof Date)return sg(n);if(n instanceof Uint8Array)return tg(n);if(n instanceof Vc)return Wc(n);default:throw rt(n,Gc)}}function Oi(n){if(/^[a-z*][a-z0-9\-_.*]*$/.test(n)===!1)throw rt(n,Q1);return n}function Fi(n){return n==null?"":Object.entries(n).map(([e,t])=>t===!0?`;${Oi(e)}`:`;${Oi(e)}=${_i(t)}`).join("")}function jc(n){return n instanceof Jt?`${_i(n.value)}${Fi(n.params)}`:_i(n)}function og(n){return`(${n.value.map(jc).join(" ")})${Fi(n.params)}`}function lg(n,e={whitespace:!0}){if(typeof n!="object")throw rt(n,G1);const t=n instanceof Map?n.entries():Object.entries(n),s=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([r,i])=>{i instanceof Jt||(i=new Jt(i));let a=Oi(r);return i.value===!0?a+=Fi(i.params):(a+="=",Array.isArray(i.value)?a+=og(i):a+=jc(i)),a}).join(`,${s}`)}function cg(n,e){return lg(n,e)}const ug=n=>n==="ot"||n==="sf"||n==="st",dg=n=>typeof n=="number"?H(n):n!=null&&n!==""&&n!==!1;function fg(n,e){const t=new URL(n),s=new URL(e);if(t.origin!==s.origin)return n;const r=t.pathname.split("/").slice(1),i=s.pathname.split("/").slice(1,-1);for(;r[0]===i[0];)r.shift(),i.shift();for(;i.length;)i.shift(),r.unshift("..");return r.join("/")}function hg(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const i=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(r=="x"?i:i&3|8).toString(16)})}}}const Gn=n=>Math.round(n),pg=(n,e)=>(e!=null&&e.baseUrl&&(n=fg(n,e.baseUrl)),encodeURIComponent(n)),Hn=n=>Gn(n/100)*100,gg={br:Gn,d:Gn,bl:Hn,dl:Hn,mtp:Hn,nor:pg,rtp:Hn,tb:Gn};function mg(n,e){const t={};if(n==null||typeof n!="object")return t;const s=Object.keys(n).sort(),r=ye({},gg,e==null?void 0:e.formatters),i=e==null?void 0:e.filter;return s.forEach(a=>{if(i!=null&&i(a))return;let o=n[a];const l=r[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||dg(o)&&(ug(a)&&typeof o=="string"&&(o=new Vc(o)),t[a]=o))}),t}function zc(n,e={}){return n?cg(mg(n,e),ye({whitespace:!1},e)):""}function yg(n,e={}){if(!n)return{};const t=Object.entries(n),s=Object.entries(V1).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),r=t.reduce((i,a)=>{var o,l;const[c,u]=a,d=((o=s.find(f=>f[1].includes(c)))==null?void 0:o[0])||Nt.REQUEST;return(l=i[d])!=null||(i[d]={}),i[d][c]=u,i},{});return Object.entries(r).reduce((i,[a,o])=>(i[a]=zc(o,e),i),{})}function Eg(n,e,t){return ye(n,yg(e,t))}const Sg="CMCD";function Tg(n,e={}){if(!n)return"";const t=zc(n,e);return`${Sg}=${encodeURIComponent(t)}`}const qc=/CMCD=[^&#]+/;function xg(n,e,t){const s=Tg(e,t);if(!s)return n;if(qc.test(n))return n.replace(qc,s);const r=n.includes("?")?"&":"?";return`${n}${r}${s}`}class vg{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=r=>{try{this.apply(r,{ot:ke.MANIFEST,su:!this.initialized})}catch(i){L.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=r=>{try{const i=r.frag,a=this.hls.levels[i.level],o=this.getObjectType(i),l={d:i.duration*1e3,ot:o};(o===ke.VIDEO||o===ke.AUDIO||o==ke.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(r,l)}catch(i){L.warn("Could not generate segment CMCD data.",i)}},this.hls=e;const t=this.config=e.config,{cmcd:s}=t;s!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=s.sessionId||hg(),this.cid=s.contentId,this.useHeaders=s.useHeaders===!0,this.includeKeys=s.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHED,this.onMediaDetached,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHED,this.onMediaDetached,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var s,r;this.audioBuffer=(s=t.tracks.audio)==null?void 0:s.buffer,this.videoBuffer=(r=t.tracks.video)==null?void 0:r.buffer}createData(){var e;return{v:1,sf:Pi.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){ye(t,this.createData());const s=t.ot===ke.INIT||t.ot===ke.VIDEO||t.ot===ke.MUXED;this.starved&&s&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:r}=this;r&&(t=Object.keys(t).reduce((i,a)=>(r.includes(a)&&(i[a]=t[a]),i),{})),this.useHeaders?(e.headers||(e.headers={}),Eg(e.headers,t)):e.url=xg(e.url,t)}getObjectType(e){const{type:t}=e;if(t==="subtitle")return ke.TIMED_TEXT;if(e.sn==="initSegment")return ke.INIT;if(t==="audio")return ke.AUDIO;if(t==="main")return this.hls.audioTracks.length?ke.VIDEO:ke.MUXED}getTopBandwidth(e){let t=0,s;const r=this.hls;if(e===ke.AUDIO)s=r.audioTracks;else{const i=r.maxAutoLevel,a=i>-1?i+1:r.levels.length;s=r.levels.slice(0,a)}for(const i of s)i.bitrate>t&&(t=i.bitrate);return t>0?t:NaN}getBufferLength(e){const t=this.hls.media,s=e===ke.AUDIO?this.audioBuffer:this.videoBuffer;return!s||!t?NaN:de.bufferInfo(s,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,s=e||this.config.loader;return class{constructor(i){this.loader=void 0,this.loader=new s(i)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(i,a,o){t(i),this.loader.load(i,a,o)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,s=e||this.config.loader;return class{constructor(i){this.loader=void 0,this.loader=new s(i)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(i,a,o){t(i),this.loader.load(i,a,o)}}}}const bg=3e5;class Cg{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=L.log.bind(L,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(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(s=>s!==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:s}=t;s!==null&&(this.pathwayId=s.pathwayId,this.uri=s.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:s}=t;if((s==null?void 0:s.action)===De.SendAlternateToPenaltyBox&&s.flags===qe.MoveAllAlternatesMatchingHost){const r=this.levels;let i=this.pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:o,pathwayId:l,type:c}=t.context;o&&r?a=this.getPathwayForGroupId(o,c,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!i&&r&&(i=r.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),i&&i.length>1&&(this.updatePathwayPriority(i),s.resolved=this.pathwayId!==a),s.resolved||L.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${r&&r.length} priorities: ${JSON.stringify(i)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const s=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${s}"`),t=this.getLevelsForPathway(s),this.pathwayId=s}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t;const s=this.penalizedPathways,r=performance.now();Object.keys(s).forEach(i=>{r-s[i]>bg&&delete s[i]});for(let i=0;i<e.length;i++){const a=e[i];if(a in s)continue;if(a===this.pathwayId)return;const o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,Ul(t),this.hls.trigger(y.LEVELS_UPDATED,{levels:t});const c=this.hls.levels[o];l&&c&&this.levels&&(c.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&c.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${c.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,s){const r=this.getLevelsForPathway(s).concat(this.levels||[]);for(let i=0;i<r.length;i++)if(t===se.AUDIO_TRACK&&r[i].hasAudioGroup(e)||t===se.SUBTITLE_TRACK&&r[i].hasSubtitleGroup(e))return r[i].pathwayId;return s}clonePathways(e){const t=this.levels;if(!t)return;const s={},r={};e.forEach(i=>{const{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=i;if(t.some(u=>u.pathwayId===a))return;const c=this.getLevelsForPathway(o).map(u=>{const d=new pe(u.attrs);d["PATHWAY-ID"]=a;const f=d.AUDIO&&`${d.AUDIO}_clone_${a}`,g=d.SUBTITLES&&`${d.SUBTITLES}_clone_${a}`;f&&(s[d.AUDIO]=f,d.AUDIO=f),g&&(r[d.SUBTITLES]=g,d.SUBTITLES=g);const h=Xc(u.uri,d["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),m=new zt({attrs:d,audioCodec:u.audioCodec,bitrate:u.bitrate,height:u.height,name:u.name,url:h,videoCodec:u.videoCodec,width:u.width});if(u.audioGroups)for(let p=1;p<u.audioGroups.length;p++)m.addGroupId("audio",`${u.audioGroups[p]}_clone_${a}`);if(u.subtitleGroups)for(let p=1;p<u.subtitleGroups.length;p++)m.addGroupId("text",`${u.subtitleGroups[p]}_clone_${a}`);return m});t.push(...c),Yc(this.audioTracks,s,l,a),Yc(this.subtitleTracks,r,l,a)})}loadSteeringManifest(e){const t=this.hls.config,s=t.loader;this.loader&&this.loader.destroy(),this.loader=new s(t);let r;try{r=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(r.protocol!=="data:"){const u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+u)}const i={responseType:"json",url:r.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},c={onSuccess:(u,d,f,g)=>{this.log(`Loaded steering manifest: "${r}"`);const h=u.data;if(h.VERSION!==1){this.log(`Steering VERSION ${h.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=h.TTL;const{"RELOAD-URI":m,"PATHWAY-CLONES":p,"PATHWAY-PRIORITY":E}=h;if(m)try{this.uri=new self.URL(m,r).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${m}`);return}this.scheduleRefresh(this.uri||f.url),p&&this.clonePathways(p);const x={steeringManifest:h,url:r.toString()};this.hls.trigger(y.STEERING_MANIFEST_LOADED,x),E&&this.updatePathwayPriority(E)},onError:(u,d,f,g)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${d.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${d.url} no longer available`);return}let h=this.timeToLoad*1e3;if(u.code===429){const m=this.loader;if(typeof(m==null?void 0:m.getResponseHeader)=="function"){const p=m.getResponseHeader("Retry-After");p&&(h=parseFloat(p)*1e3)}this.log(`Steering manifest ${d.url} rate limited`);return}this.scheduleRefresh(this.uri||d.url,h)},onTimeout:(u,d,f)=>{this.log(`Timeout loading steering manifest (${d.url})`),this.scheduleRefresh(this.uri||d.url)}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(i,l,c)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var s;const r=(s=this.hls)==null?void 0:s.media;if(r&&!r.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function Yc(n,e,t,s){n&&Object.keys(e).forEach(r=>{const i=n.filter(a=>a.groupId===r).map(a=>{const o=ye({},a);return o.details=void 0,o.attrs=new pe(o.attrs),o.url=o.attrs.URI=Xc(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[r],o.attrs["PATHWAY-ID"]=s,o});n.push(...i)})}function Xc(n,e,t,s){const{HOST:r,PARAMS:i,[t]:a}=s;let o;e&&(o=a==null?void 0:a[e],o&&(n=o));const l=new self.URL(n);return r&&!o&&(l.host=r),i&&Object.keys(i).sort().forEach(c=>{c&&l.searchParams.set(c,i[c])}),l.href}const wg=/^age:\s*[\d.]+\s*$/im;class Zc{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 dn,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,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,s){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=s,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const s=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;const i=this.xhrSetup;i?Promise.resolve().then(()=>{if(!(this.loader!==s||this.stats.aborted))return i(s,t.url)}).catch(a=>{if(!(this.loader!==s||this.stats.aborted))return s.open("GET",t.url,!0),i(s,t.url)}).then(()=>{this.loader!==s||this.stats.aborted||this.openAndSendXhr(s,t,e)}).catch(a=>{this.callbacks.onError({code:s.status,text:a.message},t,s,r)}):this.openAndSendXhr(s,t,e)}openAndSendXhr(e,t,s){e.readyState||e.open("GET",t.url,!0);const r=t.headers,{maxTimeToFirstByteMs:i,maxLoadTimeMs:a}=s.loadPolicy;if(r)for(const o in r)e.setRequestHeader(o,r[o]);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),s.timeout=i&&H(i)?i:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:s}=this;if(!e||!t)return;const r=t.readyState,i=this.config;if(!s.aborted&&r>=2&&(s.loading.first===0&&(s.loading.first=Math.max(self.performance.now(),s.loading.start),i.timeout!==i.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),i.timeout=i.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.loadPolicy.maxLoadTimeMs-(s.loading.first-s.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const a=t.status,o=t.responseType==="text"?t.responseText:null;if(a>=200&&a<300){const d=o??t.response;if(d!=null){s.loading.end=Math.max(self.performance.now(),s.loading.first);const f=t.responseType==="arraybuffer"?d.byteLength:d.length;if(s.loaded=s.total=f,s.bwEstimate=s.total*8e3/(s.loading.end-s.loading.first),!this.callbacks)return;const g=this.callbacks.onProgress;if(g&&g(s,e,d,t),!this.callbacks)return;const h={url:t.responseURL,data:d,code:a};this.callbacks.onSuccess(h,s,e,t);return}}const l=i.loadPolicy.errorRetry,c=s.retry,u={url:e.url,data:void 0,code:a};Ln(l,c,!1,u)?this.retry(l):(L.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,s))}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(Ln(e,t,!0))this.retry(e);else{var s;L.warn(`timeout while loading ${(s=this.context)==null?void 0:s.url}`);const r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:s}=this;this.retryDelay=ii(e,s.retry),s.retry++,L.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${s.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&&wg.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}}function Lg(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const Ag=/(\d+)-(\d+)\/(\d+)/;class Qc{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||kg,this.controller=new self.AbortController,this.stats=new dn}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(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,s){const r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();const i=Dg(e,this.controller.signal),a=s.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=s,this.request=this.fetchSetup(e,i),self.clearTimeout(this.requestTimeout),t.timeout=c&&H(c)?c:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),s.onTimeout(r,e,this.response)},t.timeout),self.fetch(this.request).then(d=>{this.response=this.loader=d;const f=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),s.onTimeout(r,e,this.response)},u-(f-r.loading.start)),!d.ok){const{status:g,statusText:h}=d;throw new Pg(h||"fetch, bad network response",g,d)}return r.loading.first=f,r.total=Rg(d.headers)||r.total,a&&H(t.highWaterMark)?this.loadProgressively(d,r,e,t.highWaterMark,a):o?d.arrayBuffer():e.responseType==="json"?d.json():d.text()}).then(d=>{const f=this.response;if(!f)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);const g=d[l];g&&(r.loaded=r.total=g);const h={url:f.url,data:d,code:f.status};a&&!H(t.highWaterMark)&&a(r,e,d,f),s.onSuccess(h,r,e,f)}).catch(d=>{if(self.clearTimeout(this.requestTimeout),r.aborted)return;const f=d&&d.code||0,g=d?d.message:null;s.onError({code:f,text:g},e,d?d.details:null,r)})}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,s,r=0,i){const a=new Zl,o=e.body.getReader(),l=()=>o.read().then(c=>{if(c.done)return a.dataLength&&i(t,s,a.flush(),e),Promise.resolve(new ArrayBuffer(0));const u=c.value,d=u.length;return t.loaded+=d,d<r||a.dataLength?(a.push(u),a.dataLength>=r&&i(t,s,a.flush(),e)):i(t,s,u,e),l()}).catch(()=>Promise.reject());return l()}}function Dg(n,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(ye({},n.headers))};return n.rangeEnd&&t.headers.set("Range","bytes="+n.rangeStart+"-"+String(n.rangeEnd-1)),t}function Ig(n){const e=Ag.exec(n);if(e)return parseInt(e[2])-parseInt(e[1])+1}function Rg(n){const e=n.get("Content-Range");if(e){const s=Ig(e);if(H(s))return s}const t=n.get("Content-Length");if(t)return parseInt(t)}function kg(n,e){return new self.Request(n.url,e)}class Pg extends Error{constructor(e,t,s){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=s}}const _g=/\s/,Og={newCue(n,e,t,s){const r=[];let i,a,o,l,c;const u=self.VTTCue||self.TextTrackCue;for(let f=0;f<s.rows.length;f++)if(i=s.rows[f],o=!0,l=0,c="",!i.isEmpty()){var d;for(let m=0;m<i.chars.length;m++)_g.test(i.chars[m].uchar)&&o?l++:(c+=i.chars[m].uchar,o=!1);i.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;const g=kc(c.trim()),h=Li(e,t,g);n!=null&&(d=n.cues)!=null&&d.getCueById(h)||(a=new u(e,t,g),a.id=h,a.line=f+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),r.push(a))}return n&&r.length&&(r.sort((f,g)=>f.line==="auto"||g.line==="auto"?0:f.line>8&&g.line>8?g.line-f.line:f.line-g.line),r.forEach(f=>Rl(n,f))),r}},Fg={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},Jc=ve(ve({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Zc,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:lp,bufferController:f1,capLevelController:ki,errorController:X2,fpsController:$1,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:Jo,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:Fg},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},Mg()),{},{subtitleStreamController:l1,subtitleTrackController:u1,timelineController:B1,audioStreamController:a1,audioTrackController:o1,emeController:Qt,cmcdController:vg,contentSteeringController:Cg});function Mg(){return{cueHandler:Og,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Ng(n,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const t=Mi(n),s=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return s.forEach(i=>{const a=`${i==="level"?"playlist":i}LoadPolicy`,o=e[a]===void 0,l=[];r.forEach(c=>{const u=`${i}Loading${c}`,d=e[u];if(d!==void 0&&o){l.push(u);const f=t[a].default;switch(e[a]={default:f},c){case"TimeOut":f.maxLoadTimeMs=d,f.maxTimeToFirstByteMs=d;break;case"MaxRetry":f.errorRetry.maxNumRetry=d,f.timeoutRetry.maxNumRetry=d;break;case"RetryDelay":f.errorRetry.retryDelayMs=d,f.timeoutRetry.retryDelayMs=d;break;case"MaxRetryTimeout":f.errorRetry.maxRetryDelayMs=d,f.timeoutRetry.maxRetryDelayMs=d;break}}}),l.length&&L.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),ve(ve({},t),e)}function Mi(n){return n&&typeof n=="object"?Array.isArray(n)?n.map(Mi):Object.keys(n).reduce((e,t)=>(e[t]=Mi(n[t]),e),{}):n}function Bg(n){const e=n.loader;e!==Qc&&e!==Zc?(L.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1):Lg()&&(n.loader=Qc,n.progressive=!0,n.enableSoftwareAES=!0,L.log("[config]: Progressive streaming enabled, using FetchLoader"))}let Ni;class Ug extends oi{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(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.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 s=this.hls.config.preferManagedMediaSource,r=[],i={},a={};let o=!1,l=!1,c=!1;t.levels.forEach(u=>{var d,f;const g=u.attrs;let{audioCodec:h,videoCodec:m}=u;((d=h)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(Ni||(Ni=/chrome|firefox/i.test(navigator.userAgent)),Ni&&(u.audioCodec=h=void 0)),h&&(u.audioCodec=h=Tn(h,s)),((f=m)==null?void 0:f.indexOf("avc1"))===0&&(m=u.videoCodec=w2(m));const{width:p,height:E,unknownCodecs:x}=u;if(o||(o=!!(p&&E)),l||(l=!!m),c||(c=!!h),x!=null&&x.length||h&&!Xr(h,"audio",s)||m&&!Xr(m,"video",s))return;const{CODECS:v,"FRAME-RATE":w,"HDCP-LEVEL":b,"PATHWAY-ID":I,RESOLUTION:A,"VIDEO-RANGE":F}=g,O=`${`${I||"."}-`}${u.bitrate}-${A}-${w}-${v}-${F}-${b}`;if(i[O])if(i[O].uri!==u.url&&!u.attrs["PATHWAY-ID"]){const B=a[O]+=1;u.attrs["PATHWAY-ID"]=new Array(B+1).join(".");const Y=new zt(u);i[O]=Y,r.push(Y)}else i[O].addGroupId("audio",g.AUDIO),i[O].addGroupId("text",g.SUBTITLES);else{const B=new zt(u);i[O]=B,a[O]=1,r.push(B)}}),this.filterAndSortMediaOptions(r,t,o,l,c)}filterAndSortMediaOptions(e,t,s,r,i){let a=[],o=[],l=e;if((s||r)&&i&&(l=l.filter(({videoCodec:h,videoRange:m,width:p,height:E})=>(!!h||!!(p&&E))&&B2(m))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);const h=new Error("no level with compatible codecs found in manifest");this.hls.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:h,reason:h.message})}});return}if(t.audioTracks){const{preferManagedMediaSource:h}=this.hls.config;a=t.audioTracks.filter(m=>!m.audioCodec||Xr(m.audioCodec,"audio",h)),eu(a)}t.subtitles&&(o=t.subtitles,eu(o));const c=l.slice(0);l.sort((h,m)=>{if(h.attrs["HDCP-LEVEL"]!==m.attrs["HDCP-LEVEL"])return(h.attrs["HDCP-LEVEL"]||"")>(m.attrs["HDCP-LEVEL"]||"")?1:-1;if(s&&h.height!==m.height)return h.height-m.height;if(h.frameRate!==m.frameRate)return h.frameRate-m.frameRate;if(h.videoRange!==m.videoRange)return bn.indexOf(h.videoRange)-bn.indexOf(m.videoRange);if(h.videoCodec!==m.videoCodec){const p=yl(h.videoCodec),E=yl(m.videoCodec);if(p!==E)return E-p}if(h.uri===m.uri&&h.codecSet!==m.codecSet){const p=Sn(h.codecSet),E=Sn(m.codecSet);if(p!==E)return E-p}return h.averageBitrate!==m.averageBitrate?h.averageBitrate-m.averageBitrate:0});let u=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==c.length)){for(let h=0;h<c.length;h++)if(c[h].pathwayId===l[0].pathwayId){u=c[h];break}}this._levels=l;for(let h=0;h<l.length;h++)if(l[h]===u){var d;this._firstLevel=h;const m=u.bitrate,p=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${m}`),((d=this.hls.userConfig)==null?void 0:d.abrEwmaDefaultEstimate)===void 0){const E=Math.min(m,this.hls.config.abrEwmaDefaultEstimateMax);E>p&&p===Jc.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=E)}break}const f=i&&!r,g={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:i,video:r,altAudio:!f&&a.some(h=>!!h.url)};this.hls.trigger(y.MANIFEST_PARSED,g),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const u=new Error("invalid level idx"),d=e<0;if(this.hls.trigger(y.ERROR,{type:Z.OTHER_ERROR,details:k.LEVEL_SWITCH_ERROR,level:e,fatal:d,error:u,reason:u.message}),d)return;e=Math.min(e,t.length-1)}const s=this.currentLevelIndex,r=this.currentLevel,i=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,s===e&&a.details&&r&&i===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${s}${i?" with Pathway "+i:""}`);const l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(y.LEVEL_SWITCHING,l);const c=a.details;if(!c||c.live){const u=this.switchParams(a.uri,r==null?void 0:r.details,c);this.loadPlaylist(u)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===se.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===q.MAIN){const s=t.elementaryStreams;if(!Object.keys(s).some(i=>!!s[i]))return;const r=this._levels[t.level];r!=null&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(e,t){var s;const{level:r,details:i}=t,a=this._levels[r];if(!a){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(i.deltaUpdateFailed=!0);return}r===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(r,t,a.details)):(s=t.deliveryDirectives)!=null&&s.skip&&(i.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,s=this.currentLevel;if(s&&this.shouldLoadPlaylist(s)){let r=s.uri;if(e)try{r=e.addDirectives(r)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}const i=s.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${i?" Pathway "+i:""} ${r}`),this.clearTimer(),this.hls.trigger(y.LEVEL_LOADING,{url:r,level:t,pathwayId:s.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;const s=this._levels.filter((r,i)=>i!==e?!0:(this.steering&&this.steering.removeLevel(r),r===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,r.details&&r.details.fragments.forEach(a=>a.level=-1)),!1));Ul(s),this._levels=s,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(y.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:s}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(y.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:s}))}}function eu(n){const e={};n.forEach(t=>{const s=t.groupId||"";t.id=e[s]=e[s]||0,e[s]++})}class $g{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const s in this.keyUriToKeyInfo){const r=this.keyUriToKeyInfo[s].loader;if(r){var t;if(e&&e!==((t=r.context)==null?void 0:t.frag.type))return;r.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=k.KEY_LOAD_ERROR,s,r,i){return new ut({type:Z.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:i,error:s,networkDetails:r})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:s,cc:r}=e;for(let i=0;i<t.length;i++){const a=t[i];if(r<=a.cc&&(s==="initSegment"||a.sn==="initSegment"||s<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}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 s,r;t&&e.setKeyFormat(t);const i=e.decryptdata;if(!i){const c=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,k.KEY_LOAD_ERROR,c))}const a=i.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,k.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((s=o)!=null&&s.decryptdata.key)return i.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((r=o)!=null&&r.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(c=>(i.key=c.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:i,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},i.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return i.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,k.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${i.method}"`)))}}loadKeyEME(e,t){const s={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const r=this.emeController.loadKey(s);if(r)return(e.keyLoadPromise=r.then(i=>(e.mediaKeySessionContext=i,s))).catch(i=>{throw e.keyLoadPromise=null,i})}return Promise.resolve(s)}loadKeyHTTP(e,t){const s=this.config,r=s.loader,i=new r(s);return t.keyLoader=e.loader=i,e.keyLoadPromise=new Promise((a,o)=>{const l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},c=s.keyLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(f,g,h,m)=>{const{frag:p,keyInfo:E,url:x}=h;if(!p.decryptdata||E!==this.keyUriToKeyInfo[x])return o(this.createKeyLoadError(p,k.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),m));E.decryptdata.key=p.decryptdata.key=new Uint8Array(f.data),p.keyLoader=null,E.loader=null,a({frag:p,keyInfo:E})},onError:(f,g,h,m)=>{this.resetLoader(g),o(this.createKeyLoadError(t,k.KEY_LOAD_ERROR,new Error(`HTTP Error ${f.code} loading key ${f.text}`),h,ve({url:l.url,data:void 0},f)))},onTimeout:(f,g,h)=>{this.resetLoader(g),o(this.createKeyLoadError(t,k.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),h))},onAbort:(f,g,h)=>{this.resetLoader(g),o(this.createKeyLoadError(t,k.INTERNAL_ABORTED,new Error("key loading aborted"),h))}};i.load(l,u,d)})}resetLoader(e){const{frag:t,keyInfo:s,url:r}=e,i=s.loader;t.keyLoader===i&&(t.keyLoader=null,s.loader=null),delete this.keyUriToKeyInfo[r],i&&i.destroy()}}function tu(){return self.SourceBuffer||self.WebKitSourceBuffer}function su(){if(!_t())return!1;const e=tu();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function Vg(){if(!su())return!1;const n=_t();return typeof(n==null?void 0:n.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>n.isTypeSupported(Es(e,"video")))||["mp4a.40.2","fLaC"].some(e=>n.isTypeSupported(Es(e,"audio"))))}function Gg(){var n;const e=tu();return typeof(e==null||(n=e.prototype)==null?void 0:n.changeType)=="function"}const Hg=250,Kn=2,Kg=.1,Wg=.05;class jg{constructor(e,t,s,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=s,this.hls=r}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:s,media:r,stalled:i}=this;if(r===null)return;const{currentTime:a,seeking:o}=r,l=this.seeking&&!o,c=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),i!==null){if(this.stallReported){const p=self.performance.now()-i;L.warn(`playback not stuck anymore @${a}, after ${Math.round(p)}ms`),this.stallReported=!1}this.stalled=null}return}if(c||l){this.stalled=null;return}if(r.paused&&!o||r.ended||r.playbackRate===0||!de.getBuffered(r).length){this.nudgeRetry=0;return}const u=de.bufferInfo(r,a,0),d=u.nextStart||0;if(o){const p=u.len>Kn,E=!d||t&&t.start<=a||d-a>Kn&&!this.fragmentTracker.getPartialFragment(a);if(p||E)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var f;if(!(u.len>0)&&!d)return;const E=Math.max(d,u.start||0)-a,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,w=(x==null||(f=x.details)==null?void 0:f.live)?x.details.targetduration*2:Kn,b=this.fragmentTracker.getPartialFragment(a);if(E>0&&(E<=w||b)){r.paused||this._trySkipBufferHole(b);return}}const g=self.performance.now();if(i===null){this.stalled=g;return}const h=g-i;if(!o&&h>=Hg&&(this._reportStall(u),!this.media))return;const m=de.bufferInfo(r,a,s.maxBufferHole);this._tryFixBufferStall(m,h)}_tryFixBufferStall(e,t){const{config:s,fragmentTracker:r,media:i}=this;if(i===null)return;const a=i.currentTime,o=r.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>s.maxBufferHole||e.nextStart&&e.nextStart-a<s.maxBufferHole)&&t>s.highBufferWatchdogPeriod*1e3&&(L.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:s,stallReported:r}=this;if(!r&&s){this.stallReported=!0;const i=new Error(`Playback stalling at @${s.currentTime} due to low buffer (${JSON.stringify(e)})`);L.warn(i.message),t.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:s,media:r}=this;if(r===null)return 0;const i=r.currentTime,a=de.bufferInfo(r,i,0),o=i<a.start?a.start:a.nextStart;if(o){const l=a.len<=t.maxBufferHole,c=a.len>0&&a.len<1&&r.readyState<3,u=o-i;if(u>0&&(l||c)){if(u>t.maxBufferHole){const{fragmentTracker:f}=this;let g=!1;if(i===0){const h=f.getAppendedFrag(0,q.MAIN);h&&o<h.end&&(g=!0)}if(!g){const h=e||f.getAppendedFrag(i,q.MAIN);if(h){let m=!1,p=h.end;for(;p<o;){const E=f.getPartialFragment(p);if(E)p+=E.duration;else{m=!0;break}}if(m)return 0}}}const d=Math.max(o+Wg,i+Kg);if(L.warn(`skipping hole, adjusting currentTime from ${i} to ${d}`),this.moved=!0,this.stalled=null,r.currentTime=d,e&&!e.gap){const f=new Error(`fragment loaded with buffer holes, seeking from ${i} to ${d}`);s.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:f,reason:f.message,frag:e})}return d}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:s,nudgeRetry:r}=this;if(s===null)return;const i=s.currentTime;if(this.nudgeRetry++,r<e.nudgeMaxRetry){const a=i+(r+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${i} to ${a}`);L.warn(o.message),s.currentTime=a,t.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{const a=new Error(`Playhead still not moving while enough data buffered @${i} after ${e.nudgeMaxRetry} nudges`);L.error(a.message),t.trigger(y.ERROR,{type:Z.MEDIA_ERROR,details:k.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}}const zg=100;class qg extends ui{constructor(e,t,s){super(e,t,s,"[stream-controller]",q.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(y.ERROR,this.onError,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(y.ERROR,this.onError,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:s}=this;if(this.stopLoad(),this.setInterval(zg),this.level=-1,!this.startFragRequested){let r=s.startLevel;r===-1&&(s.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=s.firstAutoLevel),s.nextLoadLevel=r,this.level=s.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=M.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=M.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case M.WAITING_LEVEL:{const{levels:t,level:s}=this,r=t==null?void 0:t[s],i=r==null?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(i))break;this.state=M.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=M.IDLE;break}break}case M.FRAG_LOADING_WAITING_RETRY:{var e;const t=self.performance.now(),s=this.retryDate;if(!s||t>=s||(e=this.media)!=null&&e.seeking){const{levels:r,level:i}=this,a=r==null?void 0:r[i];this.resetStartWhenNotLoaded(a||null),this.state=M.IDLE}}break}this.state===M.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:s,media:r}=this;if(t===null||!r&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const i=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(s!=null&&s[i]))return;const a=s[i],o=this.getMainFwdBufferInfo();if(o===null)return;const l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){const m={};this.altAudio&&(m.type="video"),this.hls.trigger(y.BUFFER_EOS,m),this.state=M.ENDED;return}if(!this.buffering)return;e.loadLevel!==i&&e.manualLevel===-1&&this.log(`Adapting to level ${i} from level ${this.level}`),this.level=e.nextLoadLevel=i;const c=a.details;if(!c||this.state===M.WAITING_LEVEL||c.live&&this.levelLastLoaded!==a){this.level=i,this.state=M.WAITING_LEVEL;return}const u=o.len,d=this.getMaxBufferLength(a.maxBitrate);if(u>=d)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const f=this.backtrackFragment?this.backtrackFragment.start:o.end;let g=this.getNextFragment(f,c);if(this.couldBacktrack&&!this.fragPrevious&&g&&g.sn!=="initSegment"&&this.fragmentTracker.getState(g)!==be.OK){var h;const p=((h=this.backtrackFragment)!=null?h:g).sn-c.startSN,E=c.fragments[p-1];E&&g.cc===E.cc&&(g=E,this.fragmentTracker.removeFragment(E))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(g&&this.isLoopLoading(g,f)){if(!g.gap){const p=this.audioOnly&&!this.altAudio?le.AUDIO:le.VIDEO,E=(p===le.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,p,q.MAIN)}g=this.getNextFragmentLoopLoading(g,c,o,q.MAIN,d)}g&&(g.initSegment&&!g.initSegment.data&&!this.bitrateTest&&(g=g.initSegment),this.loadFragment(g,a,f))}loadFragment(e,t,s){const r=this.fragmentTracker.getState(e);this.fragCurrent=e,r===be.NOT_LOADED||r===be.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,s)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,q.MAIN)}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(t!=null&&t.readyState){let s;const r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);const i=this.getLevelDetails();if(i!=null&&i.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<i.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,l=e[o],c=this.fragLastKbps;c&&this.fragCurrent?s=this.fragCurrent.duration*l.maxBitrate/(1e3*c)+1:s=0}else s=0;const a=this.getBufferedFrag(t.currentTime+s);if(a){const o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();const l=o.maxStartPTS?o.maxStartPTS:o.start,c=o.duration,u=Math.max(a.end,l+Math.min(Math.max(c-this.config.maxFragLookUpTolerance,c*(this.couldBacktrack?.5:.125)),c*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(u,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 M.KEY_LOADING:case M.FRAG_LOADING:case M.FRAG_LOADING_WAITING_RETRY:case M.PARSING:case M.PARSED:this.state=M.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const s=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),s.addEventListener("playing",this.onvplaying),s.addEventListener("seeked",this.onvseeked),this.gapController=new jg(this.config,s,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;H(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const s=this.getMainFwdBufferInfo();if(s===null||s.len===0){this.warn(`Main forward buffer length on "seeked" event ${s?s.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(y.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let s=!1,r=!1;t.levels.forEach(i=>{const a=i.audioCodec;a&&(s=s||a.indexOf("mp4a.40.2")!==-1,r=r||a.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=s&&r&&!Gg(),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:s}=this;if(!s||this.state!==M.IDLE)return;const r=s[t.level];(!r.details||r.details.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(r.details))&&(this.state=M.WAITING_LEVEL)}onLevelLoaded(e,t){var s;const{levels:r}=this,i=t.level,a=t.details,o=a.totalduration;if(!r){this.warn(`Levels were reset while loading level ${i}`);return}this.log(`Level ${i} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const l=r[i],c=this.fragCurrent;c&&(this.state===M.FRAG_LOADING||this.state===M.FRAG_LOADING_WAITING_RETRY)&&c.level!==t.level&&c.loader&&this.abortCurrentFrag();let u=0;if(a.live||(s=l.details)!=null&&s.live){var d;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,l.details,(d=this.levelLastLoaded)==null?void 0:d.details)}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(y.LEVEL_UPDATED,{details:a,level:i}),this.state===M.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=M.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:s,part:r,payload:i}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);return}const o=a[s.level],l=o.details;if(!l){this.warn(`Dropping fragment ${s.sn} of level ${s.level} after level details were reset`),this.fragmentTracker.removeFragment(s);return}const c=o.videoCodec,u=l.PTSKnown||!l.live,d=(t=s.initSegment)==null?void 0:t.data,f=this._getAudioCodec(o),g=this.transmuxer=this.transmuxer||new Sc(this.hls,q.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),h=r?r.index:-1,m=h!==-1,p=new li(s.level,s.sn,s.stats.chunkCount,i.byteLength,h,m),E=this.initPTS[s.cc];g.push(i,d,f,c,s,r,l.totalduration,u,p,E)}onAudioTrackSwitching(e,t){const s=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const i=this.hls;s&&(i.trigger(y.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),i.trigger(y.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const s=t.id,r=!!this.hls.audioTracks[s].url;if(r){const i=this.videoBuffer;i&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r,this.tick()}onBufferCreated(e,t){const s=t.tracks;let r,i,a=!1;for(const o in s){const l=s[o];if(l.id==="main"){if(i=o,r=l,o==="video"){const c=s[o];c&&(this.videoBuffer=c.buffer)}}else a=!0}a&&r?(this.log(`Alternate track found, use ${i}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:s,part:r}=t;if(s&&s.type!==q.MAIN)return;if(this.fragContextChanged(s)){this.warn(`Fragment ${s.sn}${r?" p: "+r.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}`),this.state===M.PARSED&&(this.state=M.IDLE);return}const i=r?r.stats:s.stats;this.fragLastKbps=Math.round(8*i.total/(i.buffering.end-i.loading.first)),s.sn!=="initSegment"&&(this.fragPrevious=s),this.fragBufferedComplete(s,r)}onError(e,t){var s;if(t.fatal){this.state=M.ERROR;return}switch(t.details){case k.FRAG_GAP:case k.FRAG_PARSING_ERROR:case k.FRAG_DECRYPT_ERROR:case k.FRAG_LOAD_ERROR:case k.FRAG_LOAD_TIMEOUT:case k.KEY_LOAD_ERROR:case k.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(q.MAIN,t);break;case k.LEVEL_LOAD_ERROR:case k.LEVEL_LOAD_TIMEOUT:case k.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===M.WAITING_LEVEL&&((s=t.context)==null?void 0:s.type)===se.LEVEL&&(this.state=M.IDLE);break;case k.BUFFER_APPEND_ERROR:case k.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===k.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case k.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!de.getBuffered(e).length){const s=this.state!==M.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,s)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=M.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==le.AUDIO||this.audioOnly&&!this.altAudio){const s=(t===le.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(s,t,q.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let s=this.startPosition;if(s>=0&&t<s){if(e.seeking){this.log(`could not seek to ${s}, already seeking at ${t}`);return}const r=de.getBuffered(e),a=(r.length?r.start(0):0)-s;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),s+=a,this.startPosition=s),this.log(`seek to target start position ${s} from current time ${t}`),e.currentTime=s}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(s=>{const{hls:r}=this;if(!s||this.fragContextChanged(e))return;t.fragmentError=0,this.state=M.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const i=e.stats;i.parsing.start=i.parsing.end=i.buffering.start=i.buffering.end=self.performance.now(),r.trigger(y.FRAG_LOADED,s),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const s="main",{hls:r}=this,{remuxResult:i,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:c,level:u}=o,{video:d,text:f,id3:g,initSegment:h}=i,{details:m}=u,p=this.altAudio?void 0:i.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=M.PARSING,h){if(h!=null&&h.tracks){const v=l.initSegment||l;this._bufferInitSegment(u,h.tracks,v,a),r.trigger(y.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:s,tracks:h.tracks})}const E=h.initPTS,x=h.timescale;H(E)&&(this.initPTS[l.cc]={baseTime:E,timescale:x},r.trigger(y.INIT_PTS_FOUND,{frag:l,id:s,initPTS:E,timescale:x}))}if(d&&m&&l.sn!=="initSegment"){const E=m.fragments[l.sn-1-m.startSN],x=l.sn===m.startSN,v=!E||l.cc>E.cc;if(i.independent!==!1){const{startPTS:w,endPTS:b,startDTS:I,endDTS:A}=d;if(c)c.elementaryStreams[d.type]={startPTS:w,endPTS:b,startDTS:I,endDTS:A};else if(d.firstKeyFrame&&d.independent&&a.id===1&&!v&&(this.couldBacktrack=!0),d.dropped&&d.independent){const F=this.getMainFwdBufferInfo(),U=(F?F.end:this.getLoadPosition())+this.config.maxBufferHole,O=d.firstKeyFramePTS?d.firstKeyFramePTS:w;if(!x&&U<O-this.config.maxBufferHole&&!v){this.backtrack(l);return}else v&&(l.gap=!0);l.setElementaryStreamInfo(d.type,l.start,b,l.start,A,!0)}else x&&w>Kn&&(l.gap=!0);l.setElementaryStreamInfo(d.type,w,b,I,A),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(d,l,c,a,x||v)}else if(x||v)l.gap=!0;else{this.backtrack(l);return}}if(p){const{startPTS:E,endPTS:x,startDTS:v,endDTS:w}=p;c&&(c.elementaryStreams[le.AUDIO]={startPTS:E,endPTS:x,startDTS:v,endDTS:w}),l.setElementaryStreamInfo(le.AUDIO,E,x,v,w),this.bufferFragmentData(p,l,c,a)}if(m&&g!=null&&(t=g.samples)!=null&&t.length){const E={id:s,frag:l,details:m,samples:g.samples};r.trigger(y.FRAG_PARSING_METADATA,E)}if(m&&f){const E={id:s,frag:l,details:m,samples:f.samples};r.trigger(y.FRAG_PARSING_USERDATA,E)}}_bufferInitSegment(e,t,s,r){if(this.state!==M.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:i,video:a,audiovideo:o}=t;if(i){let l=e.audioCodec;const c=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5");const u=i.metadata;u&&"channelCount"in u&&(u.channelCount||1)!==1&&c.indexOf("firefox")===-1&&(l="mp4a.40.5")}l&&l.indexOf("mp4a.40.5")!==-1&&c.indexOf("android")!==-1&&i.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),i.levelCodec=l,i.id="main",this.log(`Init audio buffer, container:${i.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${i.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(y.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{const u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(y.BUFFER_APPENDING,{type:l,data:u,frag:s,part:null,chunkMeta:r,parent:s.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,q.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=M.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const s=e.currentTime;if(de.isBuffered(e,s)?t=this.getAppendedFrag(s):de.isBuffered(e,s+.1)&&(t=this.getAppendedFrag(s+.1)),t){this.backtrackFragment=null;const r=this.fragPlaying,i=t.level;(!r||t.sn!==r.sn||r.level!==i)&&(this.fragPlaying=t,this.hls.trigger(y.FRAG_CHANGED,{frag:t}),(!r||r.level!==i)&&this.hls.trigger(y.LEVEL_SWITCHED,{level:i}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,s=this.currentFrag;if(s&&H(t)&&H(s.programDateTime)){const r=s.programDateTime+(t-s.start)*1e3;return new Date(r)}}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 he{static get version(){return"1.5.20"}static isMSESupported(){return su()}static isSupported(){return Vg()}static getMediaSource(){return _t()}static get Events(){return y}static get ErrorTypes(){return Z}static get ErrorDetails(){return k}static get DefaultConfig(){return he.defaultConfig?he.defaultConfig:Jc}static set DefaultConfig(e){he.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new Si,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,Mh(e.debug||!1,"Hls instance");const t=this.config=Ng(he.DefaultConfig,e);this.userConfig=e,t.progressive&&Bg(t);const{abrController:s,bufferController:r,capLevelController:i,errorController:a,fpsController:o}=t,l=new a(this),c=this.abrController=new s(this),u=this.bufferController=new r(this),d=this.capLevelController=new i(this),f=new o(this),g=new R2(this),h=new F2(this),m=t.contentSteeringController,p=m?new m(this):null,E=this.levelController=new Ug(this,p),x=new up(this),v=new $g(this.config),w=this.streamController=new qg(this,x,v);d.setStreamController(w),f.setStreamController(w);const b=[g,E,w];p&&b.splice(1,0,p),this.networkControllers=b;const I=[c,u,d,f,h,x];this.audioTrackController=this.createController(t.audioTrackController,b);const A=t.audioStreamController;A&&b.push(new A(this,x,v)),this.subtitleTrackController=this.createController(t.subtitleTrackController,b);const F=t.subtitleStreamController;F&&b.push(new F(this,x,v)),this.createController(t.timelineController,I),v.emeController=this.emeController=this.createController(t.emeController,I),this.cmcdController=this.createController(t.cmcdController,I),this.latencyController=this.createController(M2,I),this.coreComponents=I,b.push(l);const U=l.onErrorOut;typeof U=="function"&&this.on(y.ERROR,U,l)}createController(e,t){if(e){const s=new e(this);return t&&t.push(s),s}return null}on(e,t,s=this){this._emitter.on(e,t,s)}once(e,t,s=this){this._emitter.once(e,t,s)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,s=this,r){this._emitter.off(e,t,s,r)}listeners(e){return this._emitter.listeners(e)}emit(e,t,s){return this._emitter.emit(e,t,s)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(s){if(L.error("An internal error happened while handling event "+e+'. Error message: "'+s.message+'". Here is a stacktrace:',s),!this.triggeringException){this.triggeringException=!0;const r=e===y.ERROR;this.trigger(y.ERROR,{type:Z.OTHER_ERROR,details:k.INTERNAL_EXCEPTION,fatal:r,event:e,error:s}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){L.log("destroy"),this.trigger(y.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){L.log("attachMedia"),this._media=e,this.trigger(y.MEDIA_ATTACHING,{media:e})}detachMedia(){L.log("detachMedia"),this.trigger(y.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,s=this.url,r=this.url=Mr.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,L.log(`loadSource:${r}`),t&&s&&(s!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(y.MANIFEST_LOADING,{url:e})}startLoad(e=-1){L.log(`startLoad(${e})`),this.started=!0,this.resumeBuffering();for(let t=0;t<this.networkControllers.length&&(this.networkControllers[t].startLoad(e),!(!this.started||!this.networkControllers));t++);}stopLoad(){L.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}resumeBuffering(){L.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()})}pauseBuffering(){L.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()})}swapAudioCodec(){L.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){L.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){L.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){L.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){L.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){L.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){L.log(`set startLevel:${e}`),e!==-1&&(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 ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(L.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){N2(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const s=e.length;for(let r=0;r<s;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:s}=this;let r;if(t===-1&&e!=null&&e.length?r=e.length-1:r=t,s)for(let i=r;i--;){const a=e[i].attrs["HDCP-LEVEL"];if(a&&a<=s)return i}return r}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||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:!1}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}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}he.defaultConfig=void 0;const Wn=n=>{n.preventDefault();let e=(N()||Ve()).error;if(e)switch(e.code){case e.MEDIA_ERR_ABORTED:lt({type:"videoTagError",message:"You aborted the video playback."});break;case e.MEDIA_ERR_NETWORK:lt({type:"videoTagError",message:"A network error caused the video download to fail part-way."});break;case e.MEDIA_ERR_DECODE:lt({type:"videoTagError",message:"The video playback was aborted due to a corruption problem or because the video used features your browser did not support."});break;case e.MEDIA_ERR_SRC_NOT_SUPPORTED:lt({type:"videoTagError",message:"The video could not be loaded, either because the server or network failed or because the format is not supported."});break;default:lt({type:"videoTagError",message:"An unknown error occurred."});break}else lt({type:"videoTagError",message:"An error occurred, but the error object is not available."})},nu=()=>{const n=R.dispatch,{params:e}=R.getState().videoData,t=s=>{s.requestFullScreen?s.requestFullScreen():s.mozRequestFullScreen?s.mozRequestFullScreen():s.webkitRequestFullScreen&&s.webkitRequestFullScreen()};n(Ks()),t(document.documentElement),n(rs(e.fullscreen==="true"))},ru=()=>{let n=".ts",e=XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open=function(){arguments[1].endsWith(n)&&(arguments[1]=arguments[1]+"?uuid="+ot()),e.apply(this,arguments)}},Yg=(n,e)=>{const t=R.dispatch;e.current=setInterval(()=>{const r=n.target.buffered.end(0)/N().duration*100;t(ka(r))},500)},Xg=()=>{const n=Wa("mainPlayer");return{xhrSetup:(e,t)=>{t.split("m3u8")[1]||(t=`${t}${n}`),e.open("GET",t,!0)},startLevel:-1,debug:!1,enableWorker:!0,abrBandWidthUpFactor:.7,abrBandWidthFactor:.95,backBufferLength:1/0,maxBufferLength:30,maxMaxBufferLength:60,manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4},errorRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4},errorRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4},errorRetry:{maxNumRetry:10,retryDelayMs:5e3,maxRetryDelayMs:1e4}}}}},Zg=()=>{const n=Wa("miniPlayer");return{xhrSetup:(e,t)=>{t=`${t}${n}`,e.open("GET",t,!0)},startLevel:1,debug:!1,maxMaxBufferLength:60,playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1e3,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1e3,retryDelayMs:1e3,maxRetryDelayMs:1e3}}}}},iu=n=>{const e=R.dispatch;let t=[],s=[];n.levels.map(r=>{t.push(r.attrs.RESOLUTION.split("x")[1].trim()),s.push(r.attrs.RESOLUTION)}),n.autoLevelCapping=Ya(s,window.innerWidth,window.innerHeight),e(a0(t)),["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","msfullscreenchange"].forEach(r=>document.addEventListener(r,()=>{C(T.isAutoQuality)&&(n.autoLevelCapping=Ya(s,window.innerWidth,window.innerHeight),n.nextLevel=-1)},!1))},au=(n,e)=>{const{details:t}=R.getState().videoData;let s=t.stream_link;e.loadSource(s),e.on(n.Events.MANIFEST_PARSED,()=>iu(e))},ou=(n,e,t)=>{if(e.frag.type!=="audio"){const s=R.dispatch,{settings:r}=R.getState().user,{qualityLevels:i,manualQuality:a,autoQuality:o}=R.getState().controller;C(T.isAutoQuality)?C(T.isAutoQuality)&&o===void 0?(n.nextLevel=-1,t(i[e.frag.level]),s(Bs(e.frag.level))):C(T.isAutoQuality)&&(t(i[e.frag.level]),o!==e.frag.level&&s(Bs(e.frag.level))):(e.frag.level!==a&&(n.nextLevel=i[r.quality]?r.quality:-1),i[r.quality]?(s(o0(r.quality)),s(Bs(void 0))):(t(i[e.frag.level]),s(Bs(e.frag.level)),s(at({...r,quality:-1}))))}},lu=n=>{var r;const e=R.dispatch,s=((r=n.mainForwardBufferInfo)==null?void 0:r.end)/N().duration*100;e(ka(s))},cu=(n,e,t)=>{const{params:s}=R.getState().videoData;s.type&&ou(n,e,t)},uu=(n,e,t)=>{const{type:s}=R.getState().videoData.params;s&&ou(n,e,t)},du=n=>{if(n.event!=="hlsAudioTrackLoading")return{type:"HLS_"+n.type,message:n.error.message}},fu=(n,e)=>{const t=R.dispatch;n.preventDefault(),e.current=Date.now(),t(Vt(!0))},Qg=(n,e)=>{const t=R.dispatch;n.preventDefault(),e.current=0,t(Vt(!0))},Jg=(n,e)=>{const t=R.dispatch,{videoSettings:s}=R.getState().user,{params:r}=R.getState().videoData;n.preventDefault(),e.current=Date.now(),t(Xe(!0)),C(T.hasOnPlayParams)&&r.onPlay(),C(T.isFirstPlay)&&(C(T.hasCurrentTimeParams)||(N().currentTime=s.time,t($t(s.time))),C(T.hasFullScreenParams)&&nu(),C(T.isFullScreen)&&Fr(),t(Us([Math.floor(N().currentTime)]))),oe(Vo(!0)),t(is(""))},em=(n,e,t,s,r,i,a,o)=>{const l=R.dispatch,{autoQuality:c,canPlayVideo:u,firstPlay:d,qualityLevels:f}=R.getState().controller,{settings:g}=R.getState().user,h=g.quality===-1&&c?f[c]:f[g.quality];let m=0;a.current&&(m=Date.now()-a.current),d&&N().played&&oe(Go(e.current,Date.now()-t.current,s.current-t.current,Date.now()-r.current,r)),l(fr(!1)),u&&m>0&&h!==void 0&&(i.current=m,a.current=0,oe(ph(m,h,r,n,o.current)),n.current=n.current+1,r.current=Date.now())},hu=n=>{const e=R.dispatch,{params:t}=R.getState().videoData;n.preventDefault(),oe(Vo(!1)),e(Xe(!1)),C(T.hasOnPauseParams)&&t.onPause()},tm=n=>{const e=R.dispatch,{selectedSubtitle:t}=R.getState().videoData;n.preventDefault(),e($t(n.target.currentTime)),C(T.hasActiveCue)&&e(is(t.activeCues[0].text))},pu=n=>{const e=R.dispatch,{settings:t}=R.getState().user;if(n.preventDefault(),e(Vt(!1)),e(_a(!0)),N().volume=t.volume/100,e(Ra(n.target.duration)),C(T.isIOS)){const s=Object.values(n.target.textTracks);s&&s.length&&e($s(Object.values(s[0]).length?s:[]))}else e($s(Object.values(n.target.textTracks)))},sm=n=>{const e=R.dispatch,{params:t}=R.getState().videoData;n.preventDefault(),e(pr(!0)),e(Se(!0)),hs(N().duration),C(T.hasOnFinishedParams)&&t.onFinished()},nm=(n,e)=>{const t=R.dispatch;n.preventDefault(),e.current=Date.now(),t(fr(!1))},rm=()=>{const n=R.dispatch;n(Vt(!1))},im=n=>{const e=R.dispatch;n.preventDefault(),e($t(n.target.currentTime))},am=()=>{const n=R.dispatch,{params:e}=R.getState().videoData;n(pr(!0)),n(Se(!0)),C(T.hasOnFinishedParams)&&e.onFinished()},om=n=>{const e=R.dispatch;n.preventDefault(),e(Xe(!1))},lm=(n,e)=>{const t=R.dispatch;n.preventDefault(),t(Xe(!0)),e.current=Date.now(),t(is("")),C(T.isFirstPlay)&&C(T.hasFullScreenParams)&&(nu(),C(T.isFullScreen)&&Fr())},cm=(n,e,t)=>{const s=R.dispatch,{firstPlay:r}=R.getState().controller;s(Vt(!1)),r&&N().played&&oe(Go(Math.round(n.current),Date.now()-e.current,0,Date.now()-t.current,t)),s(fr(!1))},um=n=>{const e=R.dispatch,{selectedSubtitle:t}=R.getState().videoData;n.preventDefault(),e($t(n.target.currentTime)),e(Ra(n.target.duration)),C(T.hasActiveCue)&&e(is(t.activeCues[0].text))},dm=n=>{const e=R.dispatch;if(n.preventDefault(),e(Vt(!1)),e(_a(!0)),C(T.isIOS)){const t=Object.values(n.target.textTracks);t&&t.length&&e($s(Object.values(t[0]).length?t:[]))}else e($s(Object.values(n.target.textTracks)))},fm=(n,e)=>{n.preventDefault(),Yg(n,e)},gu=async n=>{const{stream_link:e}=R.getState().miniPlayer.details;n.loadSource(e)},mu=()=>{hs(N().currentTime)},hm=()=>{const n=xe(),e=V(s=>s.miniPlayer.details),t=V(s=>s.miniPlayer.params);return P.useEffect(()=>{let s=new he(Zg());return he.isSupported()?(s.attachMedia(document.getElementById("mini-player-video-tag")),s.on(he.Events.MEDIA_ATTACHED,()=>gu(s))):N().canPlayType("application/vnd.apple.mpegurl")&&(N().src=e.stream_link,ru()),()=>{n(v0()),s.detachMedia(),s.off(he.Events.MEDIA_ATTACHED,()=>gu(s))}},[]),P.useEffect(()=>{t.currentTime&&(n(gt(!0)),Ve().currentTime=t.currentTime,n(Xe(!1)),N().pause())},[t.currentTime]),S.jsx(S.Fragment,{children:S.jsx("video",{onPlay:()=>n(gt(!0)),onEnded:()=>n(gt(!1)),onError:Wn,poster:t.banner?t.banner:e.banner,id:"mini-player-video-tag",className:"pl-absolute pl-h-full pl-w-full pl-bg-black",autoPlay:!0,muted:!0})})},pm=()=>{const n=xe(),e=V(t=>t.miniPlayer.params);return P.useEffect(()=>{e.currentTime&&(n(gt(!0)),Ve().currentTime=e.currentTime,n(Xe(!1)),N().pause())},[e.currentTime]),S.jsx("video",{poster:e.banner,onPlay:()=>n(gt(!0)),onEnded:()=>n(gt(!1)),onError:Wn,src:e.id,id:"mini-player-video-tag",className:"pl-absolute pl-h-full pl-w-full pl-bg-black",autoPlay:!0})},gm=()=>{const n=V(e=>e.miniPlayer.params.type);return S.jsx(S.Fragment,{children:n===Tt.static?S.jsx(pm,{}):S.jsx(hm,{})})},mm=({params:n})=>{const e=xe(),t=V(a=>a.miniPlayer.details),s=V(a=>a.miniPlayer.params);V(a=>a.miniPlayer.play);const r=V(a=>a.videoData.params);P.useEffect(()=>{e(T0(n))},[]);const i=async()=>await jo(n.id);return P.useEffect(()=>{n.id&&n.type==="vod"&&i()},[n.id]),S.jsx(S.Fragment,{children:t.stream_link||s.type==="static"&&s.id?S.jsxs("div",{id:"miniPlayer-video-area",style:{zIndex:Pe.miniPlayer},className:"pl-relative pl-h-full pl-w-full",children:[S.jsx("div",{className:`pl-absolute pl-right-3 pl-top-3 pl-z-[1000000] pl-cursor-pointer ${C(T.isActiveElements)?"animate__fadeIn pl-pointer-events-auto":"animate__fadeOut pl-pointer-events-none"}`,onClick:()=>{r.id===s.id&&(N().currentTime=Ve().currentTime,e($t(Ve().currentTime))),localStorage.setItem("close-miniPlayer","true"),n.onClose()},children:S.jsx("img",{className:"pl-size-4 pl-cursor-pointer",src:re.closeSquare,alt:"close-square"})}),S.jsx("div",{className:`animate__animated animate__faster pl-absolute pl-bottom-0 pl-z-[1000000] pl-w-full ${C(T.isActiveElements)&&!C(T.isLoading)?"animate__fadeIn pl-pointer-events-auto":"animate__fadeOut pl-pointer-events-none"}`,children:S.jsx("div",{className:"pl-flex pl-w-full pl-justify-center",children:S.jsx(Ah,{})})}),S.jsx(gm,{})]}):S.jsx("div",{className:"pl-h-full pl-w-full pl-bg-white"})})},ym=({params:n})=>S.jsx(zi,{store:R,children:S.jsx(zo,{children:S.jsx(mm,{params:n})})}),Em=()=>{const{details:n,params:e}=V(({videoData:{details:t,params:s}})=>({details:t,params:s}),K);return S.jsx("div",{className:`animate__animated animate__faster pl-ml-4 pl-w-full pl-max-w-[80%] pl-self-start pl-truncate pl-break-words pl-text-left pl-text-[16px] pl-font-normal pl-text-white ${C(T.isActiveElements)?"animate__fadeIn pl-opacity-100":"animate__fadeOut pl-opacity-0"}`,children:C(T.hasTitle)?n.title:e.id})},Sm=()=>S.jsxs("div",{className:`animate__animated animate__faster pl-relative ${C(T.isActiveElements)?"animate__fadeIn pl-pointer-events-auto":"animate__fadeOut pl-pointer-events-none"}`,children:[S.jsx("img",{src:re.lock,alt:"lock-icon",width:20,height:20,onClick:()=>Ko("unlock")}),!localStorage.getItem("unlock-click")&&S.jsx("p",{className:"pl-absolute pl-left-0 pl-w-max pl-rounded-[8px] pl-bg-[#F7F7F7] pl-px-4 pl-py-3 pl-text-[10px] pl-text-black/[0.87]",children:"برای باز کردن قفل، کلیک کنید"})]}),Tm=()=>(V(({controller:{lock:n,activeElements:e}})=>({lock:n,activeElements:e}),K),S.jsxs("div",{className:`pl-mx-4 pl-mt-5 pl-flex pl-items-start pl-justify-end ${C(T.isTouchScreenPortrait)?"pl-h-[16px]":"pl-h-[60px]"}`,children:[C(T.showTitle)&&S.jsx(Em,{}),C(T.isLock)&&S.jsx(Sm,{})]}));function xm(n,e=300,t={}){const s=P.useRef(null),r=P.useCallback(i=>{s.current?(clearTimeout(s.current),s.current=null,n&&n(i)):s.current=setTimeout(()=>{t.onSingleTap&&t.onSingleTap(i),s.current=null},e)},[n,e,t.onSingleTap]);return n?{onClick:r}:{}}const yu=1e3,Bi=({type:n,isRightDoubleTouched:e,isLeftDoubleTouched:t,setIsRightDoubleTouched:s,setIsLeftDoubleTouched:r})=>{const[i,a]=P.useState(15),[o,l]=P.useState(!1),c=P.useRef(i),u=xe(),{duration:d}=V(({controller:{currentTime:E,duration:x}})=>({currentTime:E,duration:x}),K),{videoElementSizeInfo:f}=V(({videoData:{videoElementSizeInfo:E,params:x}})=>({videoElementSizeInfo:E,params:x}),K),g=P.useRef(null);P.useEffect(()=>{c.current=i},[i]);let h;h=xm(E=>{["touchBackward","touchForward"].includes(n)&&(E.stopPropagation(),n==="touchBackward"&&r?r(!0):n==="touchForward"&&s&&s(!0),clearTimeout(g.current),g.current=setTimeout(()=>l(!0),yu))},200),P.useEffect(()=>{o&&(l(!1),u(Se(!1)),e&&s?(s(!1),N().duration-N().currentTime<=c.current?It(n,N().duration):It(n,c.current),a(15)):t&&r&&(r(!1),N().currentTime<=c.current?It(n,0):It(n,c.current),a(15)))},[o]);const m=E=>{a(x=>x+15),C(T.isTouchScreenLandscape)&&D0(E,n),clearTimeout(g.current),g.current=setTimeout(()=>l(!0),yu)};let p;return["backward","forward"].includes(n)?p=S.jsx("div",{className:`${C(T.isTouchScreen)?"pl-flex pl-size-8 pl-items-center pl-justify-center pl-rounded-full pl-bg-black/50":"hover:pl-scale-125"} pl-cursor-pointer pl-transition-transform pl-ease-in-out ${n==="backward"&&(N().currentTime>=15?"pl-opacity-100":"pl-cursor-default pl-opacity-30 hover:pl-scale-100")} ${n==="forward"&&(d-N().currentTime>=15?"pl-opacity-100":"pl-cursor-default pl-opacity-30 hover:pl-scale-100")}}`,onContextMenu:E=>E.preventDefault(),children:S.jsx("img",{alt:n==="backward"?"backward-icon":"forward-icon",src:n==="backward"?re.backward15:re.forward15,onClick:()=>It(n,i),onDoubleClick:E=>E.stopPropagation(),className:"pl-size-6"})}):["touchBackward","touchForward"].includes(n)&&(p=S.jsx("div",{id:n,className:`pl-relative pl-flex pl-flex-col pl-items-center pl-justify-center pl-gap-2 pl-overflow-hidden ${n==="touchBackward"?"pl-rounded-r-full":"pl-rounded-l-full"}`,style:{width:f.width,height:f.width},...h,children:(e||t)&&S.jsxs("div",{className:"pl-flex pl-h-full pl-w-full pl-flex-col pl-items-center pl-justify-center pl-gap-2 pl-bg-secondary-100/[0.3] pl-p-5",onTouchStart:m,children:[S.jsxs("div",{className:`${n==="touchBackward"?"pl-arrow-left":"pl-arrow-right pl-gap-2"} pl-flex pl-items-center pl-justify-center`,children:[S.jsx("img",{alt:"arrow-left-icon",src:re.arrowLeft,className:`pl-size-6 ${n==="touchForward"&&"pl-rotate-180"}`}),S.jsx("img",{alt:"arrow-left-icon",src:re.arrowLeft,className:`pl-size-6 ${n==="touchForward"&&"pl-rotate-180"}`}),S.jsx("img",{alt:"arrow-left-icon",src:re.arrowLeft,className:`pl-size-6 ${n==="touchForward"&&"pl-rotate-180"}`})]}),S.jsxs("p",{className:"pl-text-center pl-text-[14px] pl-font-normal pl-text-white",children:[i," ثانیه"]})]})})),S.jsx(S.Fragment,{children:p})},vm=Object.freeze(Object.defineProperty({__proto__:null,default:Bi},Symbol.toStringTag,{value:"Module"})),bm=()=>(V(({controller:{play:n}})=>({play:n}),K),V(({videoData:{videoElementSizeInfo:n,params:e}})=>({videoElementSizeInfo:n,params:e}),K),S.jsx("div",{className:`${C(T.isTouchScreen)?"pl-flex pl-size-14 pl-items-center pl-justify-center pl-rounded-full pl-bg-black/50":"hover:pl-scale-125"} pl-cursor-pointer pl-transition-transform pl-ease-in-out`,onContextMenu:n=>n.preventDefault(),children:S.jsx("img",{alt:C(T.isPlay)?"pause":"play",src:C(T.isPlay)?re.bigPause:re.bigPlay,onClick:n=>_r(n),onDoubleClick:n=>n.stopPropagation(),className:`pl-size-8 desktop:pl-size-10 ${C(T.isPlay)?"pl-big-play-icon":"pl-big-pause-icon"}`})})),Cm=()=>S.jsxs("div",{className:"loader-spinner pl-absolute pl-left-[50%] pl-top-[50%] pl-ml-[-42px] pl-mt-[-50px] pl-h-full pl-w-screen pl-overflow-hidden",children:[S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"}),S.jsx("div",{className:"pl-bg-white"})]}),xs=1e3,wm=3e3,Lm=6e4,Am=()=>{const[n,e]=P.useState(!1),[t,s]=P.useState(!1);V(({controller:{lock:a,firstPlay:o}})=>({lock:a,firstPlay:o}),K);const{activeElements:r,isLoading:i}=V(({controller:{activeElements:a,isLoading:o}})=>({activeElements:a,isLoading:o}),K);return P.useEffect(()=>{let a=null;return C(T.isFirstPlay)||C(T.isActiveElements)?a=setTimeout(()=>s(!0),100):s(!1),()=>clearTimeout(a)},[r]),P.useEffect(()=>{let a;return C(T.isLoading)?a=setTimeout(()=>e(!0),C(T.isFirstPlay)?0:wm):e(!1),()=>{clearTimeout(a),e(!1)}},[i]),S.jsx("main",{className:"pl-mt-1 pl-flex-1",children:n?S.jsx(Cm,{}):S.jsx(S.Fragment,{children:t&&!C(T.isLock)&&S.jsx("div",{id:"main-content",className:`pl-relative pl-flex pl-h-full pl-items-center pl-justify-center pl-text-center ${C(T.isActiveElements)?"pl-pointer-events-auto":"pl-pointer-events-none"}`,children:S.jsxs("div",{className:"pl-flex pl-w-max pl-items-center pl-justify-center pl-gap-8",style:{zIndex:Pe.mainIcons},children:[!C(T.isFirstPlay)&&S.jsx(Bi,{type:"forward"}),S.jsx(bm,{}),!C(T.isFirstPlay)&&S.jsx(Bi,{type:"backward"})]})})})})},Ui=n=>{const{videoElementSizeInfo:e}=R.getState().videoData,{duration:t}=R.getState().controller,s=n.clientX!==void 0?n.clientX:n.touches[0].clientX;if(s<=e.right&&s>0)return(s-e.left)/e.width*t},Bt=n=>{const{videoElementSizeInfo:e}=R.getState().videoData,t=n.clientX!==void 0?n.clientX:n.touches[0].clientX;if(t<=e.right&&t>0)return t-e.left},Dm=n=>{const{duration:e}=R.getState().controller;return n*qs()/e},jn=n=>{n&&(n.style.opacity="0.0",n.style.pointerEvents="none",n.style.zIndex=Pe.vttDisable)},Im=n=>{n.style.display="block",n.style.zIndex=Pe.vtt,n.style.opacity=R.getState().videoData.details.vtt?"1.0":"0.6",n.style.pointerEvents="auto",n.style.transition="opacity 1s ease-out"},Rm=(n,e)=>{const{videoElementSizeInfo:t}=R.getState().videoData,s=document.getElementsByClassName("pl-progressTooltip")[0],r=document.getElementById("parent-player");s&&r&&(Bt(n)>s.getBoundingClientRect().width/2&&Bt(n)<t.right-t.left-s.getBoundingClientRect().width/2?e.style.left=`${Bt(n)-s.offsetWidth/2}px`:Bt(n)<(r.offsetLeft===0?s.offsetWidth:r.offsetLeft)?e.style.left="0px":N().offsetLeft+N().offsetWidth<Bt(n)+s.offsetWidth&&(e.style.left=`${N().offsetWidth-s.offsetWidth}px`))},km=(n,e,t)=>{e&&Im(e),R.getState().videoData.details.vtt?Rm(n,e):e.style.left=`${Bt(n)-30}px`,R.dispatch(c0(Number(Ui(n)))),t.textContent=`${js(Ui(n))}`},zn=(n,e=!1)=>{const{videoElementSizeInfo:t}=R.getState().videoData,s=document.querySelector(".pl-progressTooltip"),r=document.querySelector(".pl-progressTimeTooltip"),i=n.clientX!==void 0?n.clientX:n.touches[0].clientX;s&&r&&i<=t.right&&i>t.left?(km(n,s,r),e&&setTimeout(()=>jn(s),2e3)):jn(s)},Eu=n=>{const e=n.clientX!==void 0?n.clientX:n.touches[0].clientX;mt()&&(e<=n.view.innerWidth&&e>0?mt().style.width=`${Bt(n)}px`:e<=n.view.innerWidth?mt().style.width=0:e>0&&(mt().style.width="100%"))},Pm=(n,e,t)=>{n.preventDefault(),n.stopPropagation(),t(!0);const s=R.dispatch,r=n.clientX!==void 0?n.clientX:n.touches[0].clientX;r<=n.view.innerWidth&&r>0&&(s(Pa(!0)),s(hr(!0)),sessionStorage.setItem("previousVideoTime",String(N().currentTime)),n.target.setPointerCapture(n.pointerId),e.length>0&&e.map(i=>clearTimeout(i)))},Su=n=>{n.preventDefault(),n.stopPropagation();const e=R.dispatch,{activePointerProgressBar:t}=R.getState().controller,{left:s}=R.getState().videoData.videoElementSizeInfo,r=n.clientX!==void 0?n.clientX:n.touches[0].clientX,i=document.querySelector(".pl-progressTooltip");r>s?(i&&(i.style.display="block !important",i.style.pointerEvents="auto"),t&&(e(hr(!0)),zn(n),Eu(n),N().pause())):i&&(i.style.display="none !important",i.style.pointerEvents="none")},_m=(n,e,t,s)=>{s(!1),n.preventDefault(),n.stopPropagation();const r=R.dispatch,{duration:i}=R.getState().controller,{left:a,right:o}=R.getState().videoData.videoElementSizeInfo;n.target.removeEventListener("pointermove",Su);const l=n.clientX!==void 0?n.clientX:n.touches[0].clientX;let c=0;l>a&&l<o?c=Ui(n):l<a?c=0:l>0&&(c=i),C(T.isStaticFormat)||hs(N().currentTime,c),N().currentTime=c,R.getState().controller.activePointerProgressBar&&(r(Pa(!1)),r(hr(!1)),N().play(),zn(n,!0),sessionStorage.setItem("current-time",String(c)),Eu(n),Om(n,r,e,t))},Om=(n,e,t,s)=>{const r=s;let i=setTimeout(()=>{const{settingPopover:a}=R.getState().popovers,{delayTurnOffControlbar:o}=R.getState().controller;n.pointerType==="touch"&&!a&&o&&e(Se(!1))},xs);r.push(i),t(r)},Fm=()=>{const n=Date.now();N().play().then(()=>oe(oh(Date.now()-n)))},Mm=n=>zn(n),Nm=()=>{const n=document.querySelector(".pl-progressTooltip");jn(n)},Bm=n=>{const e=n.split("."),s=e[0].split(":");return{milliseconds:parseInt(e[1],10)||0,seconds:parseInt(s.pop(),10)||0,minutes:parseInt(s.pop(),10)||0,hours:parseInt(s.pop(),10)||0}},Tu=n=>{const e=Bm(n);return parseInt(e.hours*(60*60)+e.minutes*60+e.seconds+e.milliseconds/1e3,10)},Um=n=>{const e=n.split(/#xywh=/i),t=e[0],r=e[1].match(/[0-9]+/gi);return{x:r[0],y:r[1],w:r[2],h:r[3],image:t}},$m=(n,e)=>n.indexOf("//")>=0?n:e.indexOf("//")===0?[e.replace(/\/$/gi,""),n.trim()].join("/"):e.indexOf("//")>0?[e.trim(),n.trim()].join("/"):n,Vm=(n,e)=>{const t={};let s=e.split(/\/\w+\.vtt\s?/)[0];if(n=$m(n,s),!n.match(/#xywh=/i))return t.background='url("'+n+e.split(/\/\w+\.vtt\s?/)[1]+'")',t;const r=Um(n);return t.background='url("'+r.image+e.split(/\/\w+\.vtt\s?/)[1]+'") no-repeat -'+r.x+"px -"+r.y+"px",t.width=r.w+"px",t.height=r.h+"px",t.url=r.image,t},Gm=(n,e)=>{fetch(n).then(t=>{if(!t.ok)throw R.dispatch(Fa({...R.getState().videoData.details,vtt:void 0,vtt_mobile:void 0})),new Error("Network response was not ok");return t.text()}).then(t=>{const s=[];t.split(/[\r\n][\r\n]/i).forEach(i=>{if(i.match(/([0-9]{2}:)?([0-9]{2}:)?[0-9]{2}(.[0-9]{3})?( ?--> ?)([0-9]{2}:)?([0-9]{2}:)?[0-9]{2}(.[0-9]{3}).*/gi)){const a=i.split(/[\r\n]/i),l=a[0].split(/ ?--> ?/i),c=l[0],u=l[1],d=a[1],f=Vm(d,n);s.push({start:Tu(c),end:Tu(u),css:f})}}),e(s)}).catch(t=>{console.error("Error fetching file:",t)})},Hm=(n,e,t)=>{for(let s=0;s<e.length;++s){const r=e[s];if(n>=r.start&&n<r.end){if(r.css.url&&!t[r.css.url]){const i={background:r.css.background,width:r.css.width,height:r.css.height};return t[r.css.url]=i,i}else if(r.css.url)return t[r.css.url]}}},Km=()=>{const{details:n}=V(({videoData:{details:o}})=>({details:o}),K),{tooltipTime:e}=V(({controller:{tooltipTime:o,activeElements:l,isFullScreen:c}})=>({tooltipTime:o,activeElements:l,isFullScreen:c}),K),t={},[s,r]=P.useState(void 0),[i,a]=P.useState(C(T.isTouchScreen)?n.vtt_mobile:n.vtt);return P.useEffect(()=>{a(n.vtt_mobile)},[n.vtt_mobile]),P.useEffect(()=>{i&&Gm(n.vtt_mobile,r)},[i]),C(T.isActiveElements)?S.jsxs("div",{className:`pl-progressTooltip pl-absolute pl-bottom-[calc(100%+10px)] pl-mr-[-25px] pl-flex pl-flex-col pl-px-[10px] pl-pt-[5px] pl-text-[14px] pl-text-white ${i&&s?"":"pl-bg-z-gray-700"} pl-rounded-[6px] pl-opacity-0`,children:[i&&!!s&&S.jsx("div",{className:"pl-mb-2 pl-flex-1 pl-rounded-[8px] pl-border pl-border-white",children:S.jsx("div",{className:"pl-rounded-[8px]",style:Hm(e,s,t)})}),S.jsx("div",{className:"pl-progressTimeTooltip pl-flex pl-items-center pl-justify-center pl-text-white !pl-opacity-100"})]}):S.jsx(S.Fragment,{})},Wm=P.memo(Km),vs=(n,e)=>{P.useEffect(()=>{const t=s=>{!n.current||n.current.contains(s.target)||e(s)};return document.addEventListener("mousedown",t),document.addEventListener("touchstart",t),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t)}},[n,e])},$i=({name:n,className:e,dataMarker:t})=>S.jsx("img",{"data-marker":t,src:`${rh()}/${n}.png`,alt:n,className:e}),jm=()=>{const{duration:n,activeElements:e}=V(({controller:{duration:p,activeElements:E,isFullScreen:x}})=>({duration:p,activeElements:E,isFullScreen:x}),K),{markers:t}=V(({videoData:{markers:p,videoElementSizeInfo:E}})=>({markers:p,videoElementSizeInfo:E}),K),[s,r]=P.useState(void 0),[i,a]=P.useState([]),[o,l]=P.useState({}),[c,u]=P.useState(!1),d=p=>n?qs()*p/n:0,f=(p,E,x,v,w,b,I,A)=>{p.stopPropagation();const U=24*E/(qs()+5);let O=[],B=0;A.map(Y=>{Y.time>E-U&&Y.time<E+U&&(O.push(Y),B+=Y.time)}),O.length>1?a(O):(O=[],a([]),g(p,E,x,v,w,b,I))},g=(p,E,x,v,w,b,I)=>{p.stopPropagation(),zn(p,I),hs(N().currentTime,E),N().currentTime=E,mt()&&(mt().style.width=d(E)),oe(Ho(x,E,v,w,b))};P.useEffect(()=>{C(T.isActiveElements)||a([])},[e]);const h=P.useRef(null);vs(h,()=>a([])),P.useEffect(()=>{if(i.length>0){const p=k0(document.getElementsByClassName("pl-overlapMarkers")[0]);if(p==="inViewport")return u(!0),l({left:d(i[0].time)});if(p==="OutViewPortFromLeft")return u(!1),l({left:0});if(p==="OutViewPortFromRight")return u(!1),l({right:0})}},[i,document.getElementsByClassName("pl-overlapMarkers")[0]]);const m=p=>{p.preventDefault(),C(T.isTouchScreen)&&r(Number(p.target.getAttribute("data-marker")))};return S.jsxs(S.Fragment,{children:[t.map(p=>S.jsx("div",{onContextMenu:m,"data-marker":p.time,onClick:E=>f(E,p.time,p.id,p.title,p.description,p.sticker,!0,t),onDoubleClick:E=>E.stopPropagation(),children:S.jsxs("div",{className:`pl-emoji-image pl-absolute pl-bottom-[200%] pl-rounded-[6px] pl-bg-z-gray-700/[0.4] pl-p-1 ${C(T.isTouchScreenPortrait),"pl-mb-5"} pl-ml-[-12px] pl-cursor-pointer`,style:{left:d(p.time),zIndex:Pe.markers},"data-marker":p.time,children:[p.isPersonal!==null&&p.isPersonal!==void 0&&S.jsx("div",{className:"pl-bg-main pl-absolute pl-right-[-1px] pl-top-[-2px] pl-h-2 pl-w-2 pl-rounded-full"}),S.jsx($i,{dataMarker:p.time,name:p.sticker,className:"pl-h-[16px] pl-w-[16px] !pl-max-w-max"})]})},p.id)),i.length>0&&S.jsx("div",{className:`pl-overlapMarkers ${c?"pl-overlayMarkersInViewport":"pl-overlayMarkersOutViewport"} animate__animated animate__fadeInUp pl-absolute pl-bottom-[45px] pl-ml-[-10px] pl-flex pl-flex-row-reverse pl-justify-end pl-gap-3 pl-rounded-[6px] pl-bg-z-gray-700/[0.4] pl-px-1 pl-py-2 pl-opacity-100`,ref:h,style:o,children:i.map(p=>S.jsx("div",{className:"pl-emoji-image pl-cursor-pointer pl-rounded-[6px]","data-marker":p.time,onClick:E=>g(E,p.time,p.id,p.title,p.description,p.sticker,!0),onDoubleClick:E=>E.stopPropagation(),children:S.jsx($i,{dataMarker:p.time,name:p.sticker,className:"pl-h-[24px] pl-w-[24px] !pl-max-w-max"})},p.id))})]})},zm=P.memo(jm),qm=()=>{const[n,e]=P.useState(!1);P.useEffect(()=>{jn(document.querySelector(".progressTooltip"))},[]);const{duration:t,currentTime:s,bufferedTimeWidth:r}=V(({controller:{duration:o,currentTime:l,bufferedTimeWidth:c}})=>({duration:o,currentTime:l,bufferedTimeWidth:c}),K);V(({videoData:{params:o,videoElementSizeInfo:l}})=>({params:o,videoElementSizeInfo:l}),K);const[i,a]=P.useState([]);return S.jsxs("div",{className:"pl-relative",children:[S.jsxs("div",{className:"pl-relative",children:[S.jsx(Wm,{}),S.jsx(zm,{})]}),S.jsx("div",{className:"pl-flex pl-w-full pl-items-end",onPointerDown:o=>Pm(o,i,e),onPointerMove:Su,onPointerUp:o=>_m(o,a,i,e),onMouseMove:Mm,onMouseOut:Nm,onClick:Fm,onDoubleClick:o=>o.stopPropagation(),children:S.jsxs("div",{id:"progress-area",className:"pl-absolute pl-w-full",children:[S.jsx("div",{className:"pl-h-[40px] pl-w-full"}),S.jsxs("div",{id:"time-progress-area",className:"pl-m-auto !pl-h-[5px] !pl-w-full pl-cursor-pointer pl-rounded !pl-bg-gray-highLight pl-transition-transform pl-duration-300",style:{transform:n?"scaleY(1.8)":"unset"},children:[S.jsx("div",{id:"time-progress-buffer",className:"pl-absolute pl-h-[5px] pl-rounded pl-bg-z-gray-400/[0.7]",style:{width:`${r}%`}}),S.jsx("div",{id:"time-progress-bar",className:`pl-relative pl-h-[5px] pl-cursor-pointer pl-rounded pl-bg-primary before:pl-inline-block before:pl-h-4 before:pl-w-4 before:pl-bg-primary ${n&&"before:pl-h-3 before:pl-w-7"}`,style:{width:`${s/t*qs()}px`}})]})]})})]})},St=({title:n,className:e})=>S.jsx("span",{className:`pl-absolute pl-w-max pl-bg-paper pl-text-white/[0.9] ${C(T.isFullScreen)?"pl-bottom-[300%]":"pl-bottom-[270%]"} pl-rounded-[8px] pl-px-4 pl-py-[13px] pl-text-[10px] pl-font-normal ${e}`,children:n}),Ym=()=>{const{isFullScreen:n}=V(({controller:{firstPlay:r,isFullScreen:i}})=>({firstPlay:r,isFullScreen:i}),K),[e,t]=P.useState(!1),s=xe();return P.useEffect(()=>{C(T.isFirstPlay)||s(Se(!1))},[n]),S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",children:[S.jsx("img",{src:C(T.isFullScreen)?re.nonFullScreen:re.fullScreen,alt:"fullScreen-icon",className:"pl-size-5 pl-cursor-pointer",onMouseOver:()=>!C(T.isTouchScreen)&&t(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&t(!1),onClick:()=>{Or(),Fr()}}),e&&S.jsx(St,{title:`${C(T.isFullScreen)?"خروج از":""} تمام صفحه`})]})},Xm=()=>{const[n,e]=P.useState(!1);return S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",children:[S.jsx("img",{alt:"pictureInPicture",onMouseOver:()=>!C(T.isTouchScreen)&&e(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&e(!1),src:re.pictureInPicture,className:"pl-flex pl-size-5 pl-cursor-pointer",onClick:()=>N().requestPictureInPicture()}),n&&S.jsx(St,{title:"تصویر در تصویر"})]})},Zm=()=>{const[n,e]=P.useState(!1),t=xe(),{settings:s}=V(({user:{settings:o}})=>({settings:o}),K),r=P.useRef(s.volume),i=()=>{if(r.current!==s.volume){const{settings:o}=R.getState().user;oe(on(r.current,o.volume)),r.current=o.volume,t(at({...o,volume:o.volume}))}},a=o=>{const{settings:l}=R.getState().user;o==="mute"?(cn(0),oe(on(l.volume,0))):(oe(on(l.volume,100)),cn(100))};return S.jsxs("div",{className:"pl-sound-icon pl-relative pl-inline-flex pl-items-center pl-gap-2",children:[!C(T.isTouchScreen)&&S.jsx("input",{onMouseUp:i,type:"range",min:"0",max:"100",value:s.volume,onChange:o=>cn(+o.target.value),className:"pl-soundVolume rounded-full pl-cursor-pointer",style:{background:`linear-gradient(to right, white ${s.volume}%, rgba(255,255,255,0.3) 0)`}}),S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",children:[S.jsx("img",{src:C(T.hasSound)?re.unMute:re.mute,alt:C(T.hasSound)?"unmute-icon":"mute-icon",className:"pl-flex pl-size-5 pl-cursor-pointer pl-items-center",onClick:()=>C(T.hasSound)?a("mute"):a("unmute"),onDoubleClick:o=>o.stopPropagation(),onMouseOver:()=>!C(T.isTouchScreen)&&e(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&e(!1)}),n&&S.jsx(St,{className:"pl-left-0",title:"صدا"})]})]})},Qm=({className:n,onClick:e})=>S.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,onClick:e,children:[S.jsx("path",{d:"M6 6L18.7742 18.7742",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),S.jsx("path",{d:"M6 18.7744L18.7742 6.00022",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),bs=P.forwardRef(({children:n,status:e,onClose:t,type:s,classNames:r,parentClassNames:i,styles:a,isBlurBackground:o,isFullHeight:l=!1,isHeader:c,isHasCatchUpLineOnTop:u=!1,animation:d,scrollbar:f=!1,isFocusOnInput:g=!1,headerTitle:h="",customHeader:m,headerClassName:p,showCloseIcon:E=!0},x)=>{const[v,w]=P.useState(e),[b,I]=P.useState(0),[A,F]=P.useState(0),{videoElementSizeInfo:U}=V(({videoData:{videoElementSizeInfo:j}})=>({videoElementSizeInfo:j}),K),O=P.useRef(0);P.useEffect(()=>{let j;return e?w(!0):j=setTimeout(()=>{t(!1),I(0),w(!1)},500),()=>clearTimeout(j)},[e]);const B=j=>{const Q=document.getElementById("popover-content");O.current||(O.current=window.innerHeight-U.top-(Q==null?void 0:Q.getBoundingClientRect().top)),j.stopPropagation(),window.innerHeight-U.top-j.touches[0].clientY<O.current&&I(window.innerHeight-j.touches[0].clientY),F(Pe.maxPopover)},Y=()=>{t()},$=S.jsxs(S.Fragment,{children:[o&&S.jsx("div",{className:`animate__animated animate__faster pl-fixed pl-right-0 pl-top-0 pl-h-screen pl-w-screen pl-bg-black/[0.5] ${e?"animate__fadeIn":"animate__fadeOut"}`,style:{zIndex:Pe.popoverBlurBackground}}),S.jsx("div",{className:`${s==="modal"&&"pl-fixed pl-left-0 pl-top-0 pl-flex pl-h-full pl-w-full pl-items-end pl-justify-center sm:pl-items-center"} ${i}`,style:{zIndex:l&&!g?A:Pe.popoverContent},children:S.jsx("div",{className:`animate__animated animate__faster pl-flex pl-flex-col pl-rounded-lg pl-bg-new-net_1-9 pl-text-white ${l&&"pl-h-full"} ${d||(window.innerWidth>768&&s==="modal"?e?"animate__fadeIn":"animate__fadeOut":e?"animate__fadeInUp":"animate__fadeOutDown")} ${C(T.isTouchScreenPortrait)?"!pl-fixed !pl-bottom-0 !pl-left-0 !pl-right-0 !pl-mb-0 !pl-w-full pl-rounded-[12px] !pl-rounded-b-none !pl-bg-bg-primary":"before:pl-hidden"} ${s!=="modal"&&"no-scrollbar pl-absolute pl-bottom-[130%] pl-overflow-auto"} ${r} `,style:{height:b||"max-content",maxHeight:"80vh",zIndex:Pe.popoverContent,...a},ref:x,id:"popover-content",children:S.jsxs(S.Fragment,{children:[c&&S.jsxs("div",{onTouchMove:u?B:()=>{},onTouchEndCapture:u?Y:()=>{},className:"pl-flex pl-flex-col pl-pt-4",children:[u&&S.jsx("div",{className:"pl-absolute pl-mb-4 pl-h-1 pl-w-8 pl-self-center pl-rounded-[20px] pl-bg-new-net_1-7"}),S.jsx("div",{className:`pl-mx-4 pl-mb-4 ${p}`,children:m||S.jsxs("div",{className:"pl-flex pl-items-center pl-justify-between pl-py-[19px]",children:[S.jsx("p",{className:"pl-text-[18px] pl-font-bold pl-text-black dark:pl-text-white",children:h}),E&&S.jsx(Qm,{className:"pl-stroke-secondary-400 dark:pl-stroke-dark-5 pl-cursor-pointer",onClick:t})]})})]}),S.jsx("div",{className:`pl-h-full pl-w-full pl-overflow-y-auto ${!f&&"no-scrollbar"}`,onTouchMove:j=>j.stopPropagation(),children:n})]})})})]});return S.jsx(S.Fragment,{children:v&&S.jsx(S.Fragment,{children:s==="modal"?Iu.createPortal(S.jsx(S.Fragment,{children:$}),document.getElementById("dialog-react-root-videoPlayer")):S.jsx("div",{children:$})})})});bs.displayName="popover";const Jm=({className:n,onClick:e,onMouseOver:t,onMouseLeave:s})=>S.jsxs("svg",{width:"18",height:"15",viewBox:"0 0 18 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,onClick:e,onMouseOver:t,onMouseLeave:s,children:[S.jsx("path",{d:"M10.5488 1.53559C8.20532 1.02852 5.66339 1.68608 3.84359 3.50588C1.15649 6.19298 1.00481 10.4572 3.39041 13.3215C3.55135 13.5148 3.8176 13.6347 4.13036 13.6347H13.8687C14.1816 13.6347 14.4476 13.5149 14.6085 13.3217C16.0815 11.5533 16.5884 9.25027 16.1258 7.11249C16.0528 6.77512 16.2671 6.44245 16.6045 6.36945C16.9418 6.29645 17.2745 6.51077 17.3475 6.84814C17.8886 9.34866 17.2968 12.0474 15.569 14.1217C15.1326 14.6455 14.489 14.8847 13.8687 14.8847H4.13036C3.50995 14.8847 2.86616 14.6453 2.42991 14.1215C-0.36559 10.765 -0.188583 5.77029 2.95971 2.622C5.09241 0.489299 8.07189 -0.279272 10.8132 0.31386C11.1505 0.386857 11.3648 0.719527 11.2918 1.0569C11.2188 1.39427 10.8862 1.60859 10.5488 1.53559Z"}),S.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M14.9976 2.66523C15.2417 2.9093 15.2417 3.30503 14.9976 3.54911L10.7129 7.83399C10.8469 8.09798 10.9225 8.39667 10.9225 8.713C10.9225 9.78688 10.0519 10.6574 8.97805 10.6574C7.90417 10.6574 7.03362 9.78688 7.03362 8.713C7.03362 7.63912 7.90417 6.76856 8.97805 6.76856C9.27953 6.76856 9.56498 6.83718 9.81965 6.95963C9.82222 6.95697 9.82483 6.95432 9.82746 6.95168L14.1137 2.66525C14.3578 2.42116 14.7535 2.42115 14.9976 2.66523ZM9.67249 8.713C9.67249 9.09652 9.36158 9.40743 8.97805 9.40743C8.59453 9.40743 8.28362 9.09652 8.28362 8.713C8.28362 8.32947 8.59453 8.01856 8.97805 8.01856C9.36158 8.01856 9.67249 8.32947 9.67249 8.713Z"})]}),ey=[.5,1,1.5,2],ty=({setSection:n,showSpeedIcon:e})=>{const t=xe();V(({videoData:{videoElementSizeInfo:c,params:u}})=>({videoElementSizeInfo:c,params:u}),K);const{speedPopover:s}=V(({popovers:{speedPopover:c}})=>({speedPopover:c}),K),{settings:r}=V(({user:{settings:c}})=>({settings:c}),K),i=P.useRef(null),[a,o]=P.useState(!1);vs(i,()=>t(Vs(!1))),P.useEffect(()=>{N()&&(N().playbackRate=r.speed)},[]);const l=S.jsxs("div",{id:me.speed,className:"animate__animated animate__fadeIn pl-flex pl-flex-col pl-gap-4 pl-pb-4 pl-text-white",children:[S.jsxs("div",{className:"pl-flex pl-items-center pl-gap-3 pl-px-4",children:[S.jsx("img",{src:re.chevronRight,alt:"chevronRight",onClick:()=>{n&&n(me.main)},className:"pl-size-4 pl-cursor-pointer"}),S.jsx("p",{className:"pl-text-[15px] pl-font-medium",children:"سرعت پخش"})]}),S.jsx("ul",{className:"pl-flex pl-flex-col pl-gap-2",children:ey.map((c,u)=>S.jsxs("li",{className:`pl-relative pl-flex pl-cursor-pointer pl-items-center pl-gap-4 pl-rounded-[4px] pl-px-4 pl-text-sm pl-font-medium desktop:pl-gap-3 ${r.speed===c&&"!pl-cursor-default pl-bg-primary"} ${C(T.isTouchScreen)?"pl-py-1.5":"pl-py-[9.5px]"}`,onClick:r.speed===c?()=>{}:()=>{C(T.isStaticFormat)||oe(ih(c)),t(Se(!1)),t(wt(!1)),t(Vs(!1)),t(at({...r,speed:c})),N().playbackRate=c,n&&n(me.main)},children:[S.jsx("img",{src:re.tick,alt:"tick",className:`pl-h-auto pl-w-[15px] pl-opacity-0 ${r.speed===c&&"pl-opacity-100"}`}),S.jsxs("p",{className:"pl-flex pl-w-full pl-items-center pl-gap-1",children:[c===1?"معمولی":c," ",c!==1&&S.jsx("img",{src:re.close,alt:"x",className:"pl-size-[14px]"})]})]},u))})]});return S.jsx(S.Fragment,{children:e?S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",ref:i,children:[S.jsx(Jm,{className:"size-5 pl-size-5 pl-cursor-pointer pl-fill-white",onClick:()=>t(Vs(!s)),onMouseOver:()=>!C(T.isTouchScreen)&&!C(T.showSpeedPopover)&&o(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&o(!1)}),a&&S.jsx(St,{title:"سرعت"}),S.jsx(bs,{classNames:`!pl-p-0 pl-overflow-hidden !pl-bg-white ${C(T.isTouchScreen)?"!pl-fixed !pl-bottom-0 !pl-rounded-t-[20px] pl-rounded-b-none":"!pl-w-[230px] pl-right-0 pl-mb-[33px] !pl-rounded-[12px]"} ${C(T.isTouchScreenPortrait)&&"!pl-w-screen tablet:!pl-max-w-[440px] tablet:!pl-mx-auto"} ${C(T.isTouchScreenLandscape)&&"pl-w-full pl-max-w-[440px]"}`,status:s,onClose:()=>t(Vs(!1)),type:C(T.isTouchScreen)?"modal":"popover",isBlurBackground:C(T.isTouchScreenPortrait),ref:C(T.isTouchScreenPortrait)?i:void 0,isHeader:C(T.isTouchScreen),customHeader:S.jsx(S.Fragment,{}),isHasCatchUpLineOnTop:C(T.isTouchScreen),children:l})]}):S.jsx(S.Fragment,{children:l})})},sy=({enabled:n,setEnabled:e})=>S.jsx("div",{className:`pl-relative pl-h-[22px] pl-w-[37px] pl-cursor-pointer pl-rounded-[15px] pl-transition-colors pl-duration-150 pl-ease-linear ${n?"pl-border pl-border-transparent pl-bg-primary":"pl-border pl-border-gray-highLight pl-bg-secondary-200"}`,onClick:e,children:S.jsx("div",{className:`pl-absolute pl-left-1 pl-top-[2px] pl-h-[16px] pl-w-[16px] pl-rounded-full pl-transition-transform pl-duration-150 pl-ease-linear ${n?"pl-translate-x-[13px] pl-bg-white":"-pl-translate-x-0.5 pl-bg-black/[0.16]"}`})}),ny=({setSection:n})=>{const e=xe(),{subtitles:t,selectedSubtitle:s}=V(({videoData:{subtitles:r,selectedSubtitle:i}})=>({subtitles:r,selectedSubtitle:i}),K);return S.jsx("div",{id:me.subtitles,className:"animate__animated animate__fadeIn pl-p-[14px]",children:S.jsxs("ul",{className:"pl-m-0 pl-flex pl-flex-col pl-p-0",children:[S.jsx("li",{className:`hover:pl-bg-main/[0.1] pl-relative pl-flex pl-cursor-pointer pl-items-center pl-rounded-[4px] pl-p-1 pl-pr-2 pl-text-[14px] pl-leading-6 hover:dark:pl-bg-white/[0.25] ${!s&&"pl-bg-main-light hover:!pl-bg-main-light pl-text-dark-5"}`,onClick:()=>{e(Se(!1)),e(wt(!1)),e(as(void 0)),n(me.main);const r=Object.values(N().textTracks).find(i=>i.mode==="showing");r&&(r.mode="disabled"),e(is("")),oe(fs("empty"))},children:"بدون زیرنویس"}),t.map((r,i)=>S.jsx("li",{className:`hover:pl-bg-main/[0.1] pl-relative pl-flex pl-cursor-pointer pl-items-center pl-rounded-[4px] pl-p-1 pl-pr-2 pl-text-[14px] pl-leading-6 hover:dark:pl-bg-white/[0.25] ${s&&s.language===r.language&&"pl-bg-main-light hover:!pl-bg-main-light pl-text-dark-5"}`,onClick:()=>{e(Se(!1)),e(wt(!1)),e(as(r)),N().textTracks[i].mode="showing",n(me.main),oe(fs(r.language))},children:S.jsx("span",{children:r.label})},i))]})})},ry=P.memo(ny),iy=({setSection:n,showQualityLevelsIcon:e})=>{const t=xe();let{qualityLevels:s}=V(({controller:{qualityLevels:d,manualQuality:f,autoQuality:g}})=>({qualityLevels:d,manualQuality:f,autoQuality:g}),K);const{settings:r}=V(({user:{settings:d}})=>({settings:d}),K),{qualityLevelsPopover:i}=V(({popovers:{qualityLevelsPopover:d}})=>({qualityLevelsPopover:d}),K);V(({videoData:{params:d,videoElementSizeInfo:f}})=>({params:d,videoElementSizeInfo:f}),K);const[a,o]=P.useState(!1);s=[-1,...s];const l=(d,f)=>C(T.isAutoQuality)&&f===-1?!0:!C(T.isAutoQuality)&&r.quality===d,c=P.useRef(null);vs(c,()=>t(Gs(!1)));const u=S.jsx("div",{id:me.qualityLevels,className:"animate__animated animate__fadeIn pl-py-2",children:S.jsx("ul",{className:"pl-flex pl-flex-col pl-gap-2",children:s.map((d,f)=>S.jsxs("li",{className:`pl-relative pl-flex pl-cursor-pointer pl-items-center pl-rounded-[4px] pl-ps-[24.2px] pl-text-[14px] pl-font-medium ${l(f-1,d)&&"!pl-cursor-default pl-bg-primary/[0.12]"} ${C(T.isTouchScreen)?"pl-py-[13.5px]":"pl-py-[9.5px]"}`,onClick:l(f-1,d)?()=>{}:()=>{oe(ah(d===-1?"auto":`${d}P`)),t(Se(!1)),t(wt(!1)),t(Gs(!1)),t(at({...r,quality:d===-1?-1:f-1})),n&&n(me.main)},children:[!C(T.isTouchScreen)&&l(f-1,d)&&S.jsx("div",{className:"pl-absolute pl-right-[11.8px]",children:S.jsx("img",{src:re.tick,alt:"",width:12,height:9})}),C(T.isTouchScreen)&&S.jsx("div",{className:`pl-h-5 pl-w-5 pl-rounded-full pl-border pl-border-black/[0.5] pl-p-0.5 ${l(f-1,d)&&"pl-border-primary"}`,children:l(f-1,d)&&S.jsx("div",{className:"pl-h-full pl-w-full pl-rounded-full pl-bg-primary"})}),S.jsx("span",{className:`pl-w-full pl-text-[14px] pl-text-black/[0.87] ${C(T.isTouchScreen)?"pl-pr-[21px]":"pl-pr-[10px]"}`,children:d===-1?S.jsxs("span",{children:[S.jsx("span",{children:"خودکار "}),S.jsx("span",{className:"pl-text-[10px] pl-font-normal pl-text-black/[0.5]",children:"(بر اساس سرعت اینترنت شما)"})]}):`${d}p`})]},f))})});return S.jsx(S.Fragment,{children:e?S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",ref:c,children:[S.jsx("img",{src:re.qualitySetting1,alt:"speed-icon",onClick:()=>t(Gs(!i)),onMouseOver:()=>!C(T.isTouchScreen)&&!C(T.showQualityLevelsPopover)&&o(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&o(!1),className:"pl-size-5 pl-cursor-pointer"}),a&&S.jsx(St,{title:"کیفیت"}),S.jsx(bs,{classNames:`!pl-p-0 pl-overflow-hidden !pl-bg-white ${C(T.isTouchScreen)?"!pl-fixed !pl-bottom-0 !pl-rounded-t-[20px] pl-rounded-b-none":"pl-right-0 pl-mb-[33px] !pl-rounded-[12px] pl-w-[230px]"} ${C(T.isTouchScreenPortrait)&&"!pl-w-screen tablet:pl-max-w-[440px]"} ${C(T.isTouchScreenLandscape)&&"pl-w-full pl-max-w-[440px]"}`,status:i,onClose:()=>t(Gs(!1)),type:C(T.isTouchScreen)?"modal":"popover",isBlurBackground:C(T.isTouchScreenPortrait),ref:C(T.isTouchScreenPortrait)?c:void 0,isHeader:C(T.isTouchScreen),customHeader:S.jsx(S.Fragment,{}),isHasCatchUpLineOnTop:C(T.isTouchScreen),children:u})]}):S.jsx(S.Fragment,{children:u})})},xu=P.memo(iy),ay=()=>{const n=xe(),{selectedSubtitle:e}=V(({videoData:{params:l,subtitles:c,selectedSubtitle:u}})=>({params:l,subtitles:c,selectedSubtitle:u}),K),{settingPopover:t}=V(({popovers:{settingPopover:l}})=>({settingPopover:l}),K);V(({user:{settings:l}})=>({settings:l}),K);const[s,r]=P.useState(me.main),[i,a]=P.useState(!1),o=P.useRef(null);return vs(o,()=>{n(wt(!1)),setTimeout(()=>r(me.main),500)}),S.jsxs("div",{className:`pl-inline-flex ${C(T.isLandscape)&&"pl-relative"}`,ref:o,children:[S.jsxs("div",{className:"pl-relative pl-flex pl-cursor-pointer pl-items-center",onClick:()=>n(wt(!t)),onMouseOver:()=>!C(T.isTouchScreen)&&!C(T.showSettingPopover)&&a(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&a(!1),children:[S.jsx("img",{src:re.settings,alt:"settings",className:"pl-size-5"}),i&&S.jsx(St,{title:"تنظیمات"})]}),S.jsx(bs,{classNames:`!pl-p-0 pl-overflow-hidden ${C(T.isTouchScreen)?"!pl-fixed !pl-bottom-0 !pl-rounded-t-[28px] pl-rounded-b-none":"!pl-w-[230px] pl-right-0 pl-mb-[33px]"} ${C(T.isTouchScreenPortrait)&&"!pl-w-screen tablet:!pl-max-w-[285px] tablet:!pl-mx-auto"} ${C(T.isTouchScreenLandscape)&&"pl-w-full pl-max-w-[285px]"}`,status:t,onClose:()=>{n(wt(!1)),setTimeout(()=>r(me.main),500)},type:C(T.isTouchScreen)?"modal":"popover",isBlurBackground:C(T.isTouchScreenPortrait),ref:C(T.isTouchScreenPortrait)?o:void 0,isHeader:C(T.isTouchScreen),customHeader:S.jsx(S.Fragment,{}),isHasCatchUpLineOnTop:C(T.isTouchScreen),children:S.jsxs(S.Fragment,{children:[s===me.main&&S.jsxs("div",{id:me.main,className:"animate__animated animate__fadeIn pl-flex pl-flex-col pl-gap-5 pl-rounded-[10px] pl-p-4 pl-pt-0",children:[!C(T.isStaticFormat)&&S.jsx(S.Fragment,{children:S.jsxs("div",{className:"pl-flex pl-cursor-pointer pl-items-center pl-gap-[10px]",onClick:()=>r(me.qualityLevels),children:[S.jsx("img",{src:re.qualitySetting,alt:"qualitySetting",width:16,height:16}),S.jsx("p",{className:"pl-ml-auto pl-text-[12px] pl-font-medium pl-text-black/[0.87]",children:"کیفیت پخش"}),S.jsx("img",{src:re.chevronRight,alt:"chevronRight",className:"pl-size-4"})]})}),C(T.hasNoSpeed)&&S.jsxs("div",{className:"pl-flex pl-cursor-pointer pl-items-center pl-justify-between pl-gap-[10px] pl-text-white",onClick:()=>r(me.speed),children:[S.jsx("p",{className:"pl-text-sm pl-font-medium",children:"سرعت پخش"}),S.jsx("img",{src:re.chevronRight,alt:"chevronRight",onClick:()=>{r&&r(me.main)},className:"pl-size-4 pl-rotate-180 pl-cursor-pointer"})]}),C(T.hasSubtitles)&&C(T.isTouchScreenPortrait)&&S.jsxs("div",{className:"pl-flex pl-cursor-pointer pl-items-center pl-gap-[10px]",children:[S.jsx("img",{src:re.subtitleOutlineGray,alt:"subtitle-icon",className:"pl-size-5"}),S.jsx("p",{className:"pl-ml-auto pl-text-[12px] pl-font-medium pl-text-black/[0.87]",children:"زیرنویس"}),S.jsx(sy,{enabled:!!e,setEnabled:un})]})]}),s===me.qualityLevels&&S.jsx(xu,{setSection:r}),s===me.speed&&S.jsx(ty,{setSection:r}),s===me.subtitles&&S.jsx(ry,{setSection:r})]})})]})},oy=P.memo(ay),vu=()=>{const{duration:n,currentTime:e}=V(({controller:{duration:t,currentTime:s}})=>({duration:t,currentTime:s}),K);return V(({videoData:{videoElementSizeInfo:t,params:s}})=>({videoElementSizeInfo:t,params:s}),K),S.jsx(S.Fragment,{children:S.jsxs("div",{className:`pl-mr-auto pl-w-full pl-max-w-max pl-text-[12px] pl-font-bold !pl-text-white ${C(T.isFullScreen)?"pl-ml-8":"pl-ml-4"} ${C(T.isTouchScreenPortrait)?"!pl-ml-0":"pl-absolute pl-bottom-full pl-left-0 pl-mb-[33px]"}`,children:[S.jsx("span",{children:js(n)}),S.jsx("span",{children:" / "}),S.jsx("span",{children:js(e)})]})})},ly=()=>S.jsx("img",{src:re.unlock,alt:"unlock-icon",onClick:()=>Ko("lock"),className:"pl-size-5"}),cy=()=>{const[n,e]=P.useState(!1);return V(({videoData:{selectedSubtitle:t,videoElementSizeInfo:s,params:r}})=>({selectedSubtitle:t,videoElementSizeInfo:s,params:r}),K),S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",children:[S.jsx("img",{alt:"subtitle-icon",src:C(T.isSelectedSubtitle)?re.subtitleFill:re.subtitleOutline,className:"pl-size-5 pl-cursor-pointer",onClick:un,onDoubleClick:t=>t.stopPropagation(),onMouseOver:()=>!C(T.isTouchScreen)&&e(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&e(!1)}),n&&S.jsx(St,{title:"زیرنویس"})]})},uy=n=>(V(({videoData:{videoElementSizeInfo:e,params:t}})=>({videoElementSizeInfo:e,params:t}),K),S.jsxs("svg",{width:20,height:20,viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:[S.jsx("rect",{x:"3",y:"3",width:"4",height:"4",rx:"1.5"}),S.jsx("rect",{x:"3",y:"9",width:"4",height:"4",rx:"1.5"}),S.jsx("rect",{x:"3",y:"15",width:"4",height:"4",rx:"1.5"}),S.jsx("rect",{x:"8",y:"16",width:"11",height:"2",rx:"1"}),S.jsx("rect",{x:"8",y:"10",width:"11",height:"2",rx:"1"}),S.jsx("rect",{x:"8",y:"4",width:"11",height:"2",rx:"1"})]})),dy=()=>{const[n,e]=P.useState(!1),{markers:t}=V(({videoData:{markers:l,params:c,videoElementSizeInfo:u}})=>({markers:l,params:c,videoElementSizeInfo:u}),K),{markersListPopover:s}=V(({popovers:{markersListPopover:l}})=>({markersListPopover:l}),K),r=P.useRef(null),i=xe();vs(r,()=>i(Hs(!1)));const a=(l,c,u,d,f)=>{mt()&&(mt().style.width=`${Dm(l)}px`),hs(N().currentTime,l),N().currentTime=l,i(Hs(!1)),oe(Ho(c,l,u,d,f))},o=()=>{i(Hs(!s))};return S.jsxs("div",{className:`pl-relative pl-flex pl-items-center pl-p-1 ${C(T.showMarkerListPopover)&&"pl-bg-secondary-50/[0.4] pl-rounded-[4px]"}`,ref:r,children:[S.jsx(uy,{className:"pl-fill-dark-5 pl-cursor-pointer",onClick:o,onMouseOver:()=>!C(T.isTouchScreen)&&e(!0),onMouseLeave:()=>!C(T.isTouchScreen)&&e(!1)}),n&&S.jsx(St,{title:"لیست نشانگرها (e)",className:"!pl-bottom-[180%] !pl-right-[-48px]"}),S.jsx(bs,{classNames:"!pl-p-0 pl-left-0 !pl-bg-white dark:!pl-bg-dark-13 !pl-rounded-[4px] pl-mb-[33px]",status:C(T.showMarkerListPopover),onClose:()=>{i(Hs(!1))},headerTitle:"نشانگرها",isHeader:!0,type:"popover",children:S.jsx("div",{className:"pl-mx-2 pl-mt-2 pl-flex pl-flex-col pl-gap-6",children:S.jsx("div",{className:"pl-flex pl-flex-col pl-gap-2 pl-pb-2",children:t.map(l=>S.jsx("div",{onClick:()=>a(l.time,l.id,l.title,l.description,l.sticker),className:"odd:pl-bg-main/[0.1] hover:pl-bg-main/[0.1] hover:dark:bg-white/[0.25] pl-rounded-[8px] odd:dark:pl-bg-dark-1",children:S.jsxs("div",{className:"pl-item-center pl-relative pl-mx-2 pl-flex pl-cursor-pointer pl-gap-2 pl-rounded-[4px] pl-p-2",children:[l.banner||!l.sticker?S.jsx("img",{src:l.banner?l.banner:"IMAGES.defaultMarkersListItemIcon",width:40,height:40,alt:l.title}):S.jsx("div",{className:"pl-bg-secondary dark:pl-bg-secondary-50 pl-flex pl-h-[40px] pl-w-[40px] pl-items-center pl-rounded-[6px]",children:S.jsx($i,{name:l.sticker,className:"pl-mx-auto pl-h-[20px] pl-w-[20px]"})}),S.jsxs("div",{className:"pl-text-gray-800 dark:pl-text-white",children:[S.jsx("p",{className:"pl-mb-1 pl-flex pl-w-[130px] pl-items-center pl-overflow-hidden pl-text-ellipsis pl-whitespace-nowrap pl-text-[14px] pl-font-bold",children:S.jsx("div",{children:l.title})}),S.jsx("p",{className:"pl-w-[200px] pl-overflow-hidden pl-text-ellipsis pl-whitespace-nowrap pl-text-[13px] pl-font-normal",children:l.description})]}),S.jsx("span",{className:"pl-bg-secondary/[0.3] dark:pl-bg-secondary/[0.6] pl-absolute pl-left-9 pl-top-2 pl-rounded-[4px] pl-p-[3px] pl-text-[12px] pl-font-bold pl-text-gray-800 dark:pl-text-white",children:js(l.time)})]})},l.id))})})})]})},fy=()=>{V(({controller:{isFullScreen:e}})=>({isFullScreen:e}),K),V(({videoData:{videoElementSizeInfo:e,params:t}})=>({videoElementSizeInfo:e,params:t}),K);let n="";return C(T.isTouchScreen)?C(T.isFullScreen)&&(n="pl-mx-6"):C(T.isFullScreen)?n="pl-mx-8":n="pl-mx-4",S.jsxs("div",{id:"player-controllbar",className:`pl-flex pl-items-center pl-justify-between ${n}`,children:[S.jsxs("div",{className:"pl-flex pl-items-center pl-gap-4",children:[S.jsx(Ym,{}),C(T.isTouchScreenLandscape)&&S.jsx(ly,{}),C(T.showPictureInPicture)&&S.jsx(Xm,{}),C(T.showSettingIcon)&&S.jsx(oy,{}),C(T.isFullScreen)&&!C(T.isStaticFormat)&&S.jsx(xu,{showQualityLevelsIcon:!0}),C(T.hasSubtitles)&&!C(T.isTouchScreenPortrait)&&S.jsx(cy,{})]}),S.jsxs("div",{className:"pl-flex pl-items-center pl-gap-4",children:[C(T.isTouchScreenPortrait)&&S.jsx(vu,{}),!C(T.isIOS)&&S.jsx(Zm,{}),C(T.hasMarkers)&&S.jsx(dy,{})]})]})},hy=P.memo(fy),py=()=>{const{subtitleText:n}=V(({videoData:{subtitleText:t,selectedSubtitle:s}})=>({subtitleText:t,selectedSubtitle:s}),K);V(({controller:{isFullScreen:t}})=>({isFullScreen:t}),K);const e=()=>{let t="";return C(T.isLock)?t="pl-bottom-3":C(T.isActiveElements)?C(T.isTouchScreenPortrait)?t="pl-bottom-[45px]":C(T.isFullScreen)?t="pl-bottom-[120px]":t="pl-bottom-[85px]":C(T.isActiveElements)||(t="pl-bottom-3"),t};return S.jsx("div",{id:"subtitle-id",style:{direction:"ltr"},className:`pl-absolute pl-w-full pl-px-6 pl-text-center pl-text-[14px] ${C(T.isFullScreen)&&"pl-text-[16px]"} pl-font-normal pl-text-white ${e()}`,children:R0(n).map((t,s)=>S.jsx("p",{className:"pl-mx-auto",style:{textShadow:"0 0 4px #000000"},children:P0(t)},s))})},gy=()=>{V(({controller:{lock:e,isFullScreen:t,isLoading:s,activeElements:r}})=>({lock:e,isFullScreen:t,isLoading:s,activeElements:r}),K),V(({videoData:{subtitles:e,selectedSubtitle:t}})=>({subtitles:e,selectedSubtitle:t}),K);let n="";return C(T.isTouchScreen)?C(T.isFullScreen)?n="pl-gap-6 pl-mb-6":n="pl-gap-3 pl-mb-0":C(T.isFullScreen)?n="pl-gap-6 pl-mb-8":n="pl-gap-4 pl-mb-3",S.jsx("div",{id:"footer",className:"pl-relative",style:{zIndex:Pe.footer},children:S.jsxs(S.Fragment,{children:[C(T.showSubtitle)&&S.jsx(py,{}),!C(T.isLock)&&S.jsx(S.Fragment,{children:S.jsxs("div",{className:`animate__animated animate__faster pl-mx-auto pl-flex pl-w-full pl-flex-col pl-px-4 pl-py-3 desktop:pl-px-0 desktop:pl-py-0 ${n} ${C(T.isActiveElements)&&!C(T.isLoading)?"animate__fadeIn pl-pointer-events-auto":"animate__fadeOut pl-pointer-events-none"}`,children:[!C(T.isTouchScreenPortrait)&&S.jsx(vu,{}),C(T.showProgressbar)&&S.jsx(qm,{}),S.jsx(hy,{})]})})]})})},my=P.lazy(()=>Promise.resolve().then(()=>Py)),yy=P.lazy(()=>Promise.resolve().then(()=>My)),Ey=()=>S.jsx(P.Suspense,{fallback:"",children:C(T.isStaticFormat)?S.jsx(my,{}):S.jsx(yy,{})}),Sy=()=>{const n=xe();V(({videoData:{params:e}})=>({params:e}),K),P.useEffect(()=>{const e=()=>{document.fullscreenElement?n(rs(!0)):(n(rs(!1)),Wo(),oe(Pr("exitFullScreen")))};document.addEventListener&&(document.addEventListener("webkitfullscreenchange",e,!1),document.addEventListener("mozfullscreenchange",e,!1),document.addEventListener("fullscreenchange",e,!1),document.addEventListener("MSFullscreenChange",e,!1))},[])},Ty=(n,e)=>{const t=xe(),{activeElements:s}=V(({controller:{activeElements:o}})=>({activeElements:o}),K),r=P.useRef(null),i=P.useRef(n),a=P.useRef(e);P.useEffect(()=>{i.current=n},[n]),P.useEffect(()=>{a.current=e},[e]),P.useEffect(()=>{let o=!1;const l=d=>{const{activeElements:f,isEnded:g}=R.getState().controller;g?t(Se(!0)):d.pointerType==="mouse"&&(clearTimeout(r.current),f?["player-tag","main-content","player-controllbar","video-opacity","playerElements","touchBackward","touchForward"].includes(d.target.id)&&(o=!0):t(Se(!0)),r.current=setTimeout(()=>{const{settingPopover:h,speedPopover:m,qualityLevelsPopover:p}=R.getState().popovers,{play:E}=R.getState().controller;!h&&!m&&!p&&E&&o&&t(Se(!1))},xs))},c=d=>{setTimeout(()=>{const{activeElements:f,isEnded:g,firstPlay:h}=R.getState().controller;if(clearTimeout(r.current),g)return t(Se(!0));Gt()&&!h&&!i.current&&!a.current&&(["player-tag","main-content","video-opacity","touchBackward","touchForward"].includes(d.target.id)||gr(d,"playerElements")?(t(Se(!f)),r.current=setTimeout(()=>{const{settingPopover:m,speedPopover:p,qualityLevelsPopover:E}=R.getState().popovers;!m&&!p&&!E&&t(Se(!1))},xs)):r.current=setTimeout(()=>{const{settingPopover:m,speedPopover:p,qualityLevelsPopover:E}=R.getState().popovers;!m&&!p&&!E&&t(Se(!1))},xs))},200)},u=()=>{clearTimeout(r.current),r.current=setTimeout(()=>{const{activeElements:d,isEnded:f}=R.getState().controller,{settingPopover:g,speedPopover:h,qualityLevelsPopover:m}=R.getState().popovers;f?t(Se(!0)):!g&&!h&&!m&&d&&!f&&t(Se(!d))},xs)};return document.getElementById("video-area").addEventListener("touchstart",c),document.getElementById("video-area").addEventListener("touchmove",u),document.getElementById("video-area").addEventListener("pointermove",l),()=>{const d=document.getElementById("video-area");d&&(d.removeEventListener("touchstart",c),d.removeEventListener("touchmove",u),d.removeEventListener("pointermove",l))}},[s,n,e])},xy=()=>{const{firstPlay:n,isFullScreen:e}=V(({controller:{firstPlay:t,isFullScreen:s}})=>({firstPlay:t,isFullScreen:s}),K);P.useEffect(()=>{if(N()){let t;const s=()=>{t=setTimeout(()=>{Wo()},Gt()?0:300)};return s(),window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s),clearTimeout(t)}}},[n,e,N()])},vy=()=>{const{firstPlay:n}=V(({controller:{firstPlay:e}})=>({firstPlay:e}),K);V(({videoData:{details:e}})=>({details:e}),K),P.useEffect(()=>{C(T.setSubtitleFirstPlay)&&un()},[n])},by=P.lazy(()=>Promise.resolve().then(()=>Uy)),bu=P.lazy(()=>Promise.resolve().then(()=>vm)),Cu=()=>{const[n,e]=P.useState(!1),[t,s]=P.useState(!1);return V(({videoData:{details:r,params:i,videoElementSizeInfo:a}})=>({details:r,params:i,videoElementSizeInfo:a}),K),V(({controller:{firstPlay:r,isFullScreen:i,isLoading:a,canPlayVideo:o}})=>({firstPlay:r,isFullScreen:i,isLoading:a,canPlayVideo:o}),K),Sy(),xy(),Ty(n,t),vy(),S.jsx(S.Fragment,{children:S.jsxs("div",{id:"video-area",style:{zIndex:C(T.isFullScreen)?Pe.videoPlayerInFullScreen:"unset"},onClick:r=>C(T.isFirstPlay)&&_r(r),onDoubleClick:r=>yh(r),className:`pl-flex pl-h-full pl-max-h-screen pl-items-center pl-bg-black !pl-bg-contain !pl-bg-center !pl-bg-no-repeat desktop:pl-aspect-video ${!C(T.isTouchScreen)&&!C(T.isFullScreen)&&"!pl-rounded-[12px]"} ${C(T.isFullScreen)&&"dvh !pl-fixed !pl-w-screen"} pl-relative pl-w-full ${!C(T.isActiveElements)&&"pl-cursor-none"}`,children:[S.jsx("div",{id:"video-opacity",className:`pl-absolute pl-h-full pl-w-full pl-bg-black pl-transition-all pl-duration-500 desktop:pl-aspect-video ${!C(T.isTouchScreen)&&!C(T.isFullScreen)&&"!pl-rounded-[12px]"} ${C(T.isActiveElements)?"pl-bg-opacity-50":"pl-bg-opacity-0"}`}),S.jsx(P.Suspense,{fallback:"",children:C(T.showTouchVolumeBrightness)&&S.jsx(by,{})}),C(T.showBackwardForward)&&S.jsx(P.Suspense,{fallback:"",children:S.jsxs("div",{className:"pl-absolute pl-right-0 pl-top-0 pl-flex pl-h-full pl-w-full pl-items-center pl-overflow-hidden",style:{zIndex:t||n?Pe.backwardForwardActive:Pe.backwardForwardInActive},children:[S.jsx(bu,{type:"touchForward",isRightDoubleTouched:n,setIsRightDoubleTouched:e}),S.jsx(bu,{type:"touchBackward",isLeftDoubleTouched:t,setIsLeftDoubleTouched:s})]})}),S.jsx(Ey,{}),S.jsx("div",{id:"playerElements",className:"pl-absolute pl-right-0 pl-top-0 pl-h-full pl-w-full",children:S.jsxs("div",{className:"pl-flex pl-h-full pl-w-full pl-flex-col pl-justify-between",children:[C(T.showHeader)&&S.jsx(Tm,{}),C(T.showMain)&&S.jsx(Am,{}),C(T.showFooter)&&S.jsx(gy,{})]})})]})})},Cy=Object.freeze(Object.defineProperty({__proto__:null,default:Cu},Symbol.toStringTag,{value:"Module"})),wy=Object.freeze(Object.defineProperty({__proto__:null,default:()=>S.jsx("div",{className:`pl-h-full pl-w-full desktop:pl-aspect-video ${!C(T.isTouchScreen)&&!C(T.isFullScreen)&&"!pl-rounded-[12px]"}`,children:S.jsx(Cu,{})})},Symbol.toStringTag,{value:"Module"})),Ly=()=>{const{params:n}=V(({videoData:{params:e}})=>({params:e}),K);V(({controller:{isEnded:e}})=>({isEnded:e}),K),P.useEffect(()=>{C(T.getDetails)&&jo()},[n.id,n.type])},Ay=()=>{Ly()},wu=()=>{const{params:n}=R.getState().videoData,e=N().currentTime;if(e!==0){const t=N().duration,s={video_id:+n.id,video_type:2,time:e===t?0:Math.floor(N().currentTime)};let r=localStorage.getItem("viewedVideos");if(r){let i=JSON.parse(r);i=i.filter(a=>a.video_id!==s.video_id||a.video_type!==s.video_type),i.length<10||i.shift(),i.push(s),localStorage.setItem("viewedVideos",JSON.stringify(i))}else localStorage.setItem("viewedVideos",JSON.stringify([s]))}},Dy=()=>{const n=R.dispatch,{params:e}=R.getState().videoData;let t=localStorage.getItem("viewedVideos");if(t){const r=JSON.parse(t).find(i=>i.video_id===Number(e.id)&&i.video_type===2);r&&n(y0({time:r.time}))}},Iy=P.lazy(()=>Promise.resolve().then(()=>Cy)),Ry=P.lazy(()=>Promise.resolve().then(()=>$y)),ky=Object.freeze(Object.defineProperty({__proto__:null,default:()=>(V(({videoData:{params:n,details:e,isFetchDetails:t,isValidAddress:s}})=>({params:n,details:e,isFetchDetails:t,isValidAddress:s}),K),Ay(),Dy(),S.jsx(S.Fragment,{children:C(T.isFetchDetails)?C(T.isValidAddress)?S.jsx(P.Suspense,{fallback:"",children:S.jsx("div",{className:`pl-max-h-[100dvh] pl-bg-dark-1 ${!C(T.isTouchScreen)&&!C(T.isFullScreen)&&"!pl-rounded-[12px]"}`,children:S.jsx(Iy,{})})}):S.jsx(P.Suspense,{fallback:"",children:S.jsx("div",{className:"pl-aspect-video pl-w-full",children:S.jsx(Ry,{})})}):S.jsx("div",{className:"pl-flex pl-aspect-video pl-w-full pl-items-center pl-justify-center"})}))},Symbol.toStringTag,{value:"Module"})),Lu=()=>{const n=xe(),{params:e}=V(({videoData:{params:t}})=>({params:t}),K);P.useEffect(()=>{C(T.hasCurrentTimeParams)&&(N().currentTime=e.currentTime,n($t(e.currentTime)))},[e.currentTime])},Au=()=>{const{details:n}=V(({videoData:{details:e}})=>({details:e}),K);P.useEffect(()=>{const e=N().getElementsByTagName("track");for(let t=0;t<e.length;t++)e[t].addEventListener("cuechange",s=>{const r=s.target.track;let i;r.activeCues&&(i=r.activeCues[0]),i&&(setTimeout(()=>{const a=document.getElementById("subtitle-id");a&&(a.style.display="block")},300),i.onexit=()=>{const a=document.getElementById("subtitle-id");a&&(a.style.display="none")})})},[n.subtitles])},Py=Object.freeze(Object.defineProperty({__proto__:null,default:()=>{const n=xe(),{params:e}=V(({videoData:{params:a}})=>({params:a}),K);V(({controller:{firstPlay:a}})=>({firstPlay:a}),K);const t=P.useRef(0),s=P.useRef(0),r=P.useRef(null),i=P.useRef(null);return P.useEffect(()=>{qa(t),s.current=Date.now()},[]),P.useEffect(()=>{const a=()=>{var l;const o=(l=N())==null?void 0:l.getBoundingClientRect();o&&n(Ma(o))};return C(T.isFirstPlay)&&a(),window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a),clearInterval(i.current)}},[e.id]),Au(),Lu(),S.jsxs("video",{poster:e.banner?e.banner:void 0,preload:"metadata",autoPlay:C(T.hasAutoPlay),id:"player-tag",crossOrigin:"anonymous",className:"pl-h-full pl-w-full pl-flex-1 pl-items-center",onCanPlay:dm,onPause:om,onPlay:a=>lm(a,r),onPlaying:()=>cm(t,s,r),onTimeUpdate:um,onLoadedData:a=>fm(a,i),onError:Wn,playsInline:!0,"aria-label":e.bannerAlt?e.bannerAlt:"بنر ویدیو پلیر کافه ویدیو",children:[S.jsx("source",{src:e.id}),C(T.hasSubtitlesInParams)&&Za(e.subtitles).map(a=>S.jsx("track",{id:`player-tracker-${a.lang}`,src:a.url,label:Qa(a.lang),kind:"subtitles",srcLang:a.lang},a.id))]})}},Symbol.toStringTag,{value:"Module"})),_y=()=>{let n=null;const{isEnded:e}=V(({controller:{isEnded:t}})=>({isEnded:t}),K);P.useEffect(()=>(n=setInterval(()=>wu(),Lm),()=>clearInterval(n)),[]),P.useEffect(()=>{C(T.isEnded)&&clearInterval(n)},[e])},Oy=n=>{const[e,t]=P.useState([]),[s,r]=P.useState(0),{qualityLevels:i}=V(({controller:{qualityLevels:a}})=>({qualityLevels:a}),K);P.useEffect(()=>{if(n){let a=[];switch(e.length){case 0:a=[n];break;case 1:a=[n,...e];break;case 2:a=[n,...e],oe($o(`${a[0]}P`,`${a[1]}P`,i.indexOf(a[0])-i.indexOf(a[1])));break;default:a=[n,e[0],e[1]],a[1]!==a[2]&&oe($o(`${a[1]}P`,`${a[2]}P`,i.indexOf(a[1])-i.indexOf(a[2])));break}t(a)}},[n]),P.useEffect(()=>{e.length===3&&e[0]===e[2]?(oe(hh(s,e)),t([]),r(0)):r(new Date().getTime())},[e])},Fy=()=>{P.useEffect(()=>{const n=()=>{wu()};return window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n)},[])},My=Object.freeze(Object.defineProperty({__proto__:null,default:()=>{const[n,e]=P.useState(void 0),t=xe(),{params:s,details:r,videoElementSizeInfo:i}=V(({videoData:{params:p,details:E,videoElementSizeInfo:x}})=>({params:p,details:E,videoElementSizeInfo:x}),K),{currentTime:a,duration:o}=V(({controller:{currentTime:p,duration:E,isEnded:x,firstPlay:v}})=>({currentTime:p,duration:E,isEnded:x,firstPlay:v}),K),l=P.useRef(null),c=P.useRef(0),u=P.useRef(0),d=P.useRef(0),f=P.useRef(0),g=P.useRef(0),h=P.useRef(1),m=P.useRef(N()?N().currentTime:0);return _y(),Fy(),P.useLayoutEffect(()=>{let p=new he(Xg());return qa(g),d.current=Date.now(),he.isSupported()?(p.attachMedia(N()),p.on(he.Events.MEDIA_ATTACHED,()=>au(he,p)),p.on(he.Events.FRAG_BUFFERED,()=>lu(p)),p.on(he.Events.FRAG_CHANGED,(E,x)=>cu(p,x,e)),p.on(he.Events.FRAG_PARSED,(E,x)=>uu(p,x,e)),p.on(he.Events.ERROR,(E,x)=>lt(du(x))),N().addEventListener("waiting",E=>fu(E,u)),N().addEventListener("seeking",E=>Qg(E,u)),N().addEventListener("play",E=>Jg(E,l)),N().addEventListener("playing",()=>em(h,g,d,f,l,c,u,m)),N().addEventListener("pause",hu),N().addEventListener("timeupdate",tm),N().addEventListener("canplay",pu),N().addEventListener("ended",sm),N().addEventListener("error",Wn),document.addEventListener("visibilitychange",mu)):N().canPlayType("application/vnd.apple.mpegurl")&&(N().src=r.stream_link,N().addEventListener("waiting",E=>fu(E,u)),N().addEventListener("play",E=>nm(E,l)),N().addEventListener("playing",rm),N().addEventListener("canplay",pu),N().addEventListener("timeupdate",im),N().addEventListener("ended",am),N().addEventListener("pause",hu),ru()),()=>{gh(),p.detachMedia(),p.off(he.Events.MEDIA_ATTACHED,()=>au(he,p)),p.off(he.Events.FRAG_BUFFERED,()=>lu(p)),p.off(he.Events.FRAG_CHANGED,(E,x)=>cu(p,x,e)),p.off(he.Events.FRAG_PARSED,(E,x)=>uu(p,x,e)),p.off(he.Events.ERROR,(E,x)=>du(x)),p.off(he.Events.MANIFEST_PARSED,()=>iu(p)),document.removeEventListener("visibilitychange",mu)}},[r.stream_link]),P.useEffect(()=>{a<o&&C(T.isEnded)&&t(pr(!1))},[a]),P.useEffect(()=>{C(T.hasPlayStatusParams)&&(s.playStatus?N().play():N().pause())},[s.playStatus]),Oy(n),Au(),Lu(),S.jsx(S.Fragment,{children:S.jsxs("video",{poster:s.banner?s.banner:r.banner,preload:"metadata",crossOrigin:"anonymous",id:"player-tag",playsInline:!0,className:"pl-h-full pl-flex-1 pl-items-center",style:{width:"100%",height:"100%",maxWidth:i.width?i.width:"100%",maxHeight:i.width?i.width<i.height?i.width*9/16:i.width*16/9:"100%"},autoPlay:C(T.hasAutoPlay),children:[S.jsx("img",{onLoad:()=>f.current=Date.now(),src:s.banner?s.banner:r.banner,alt:s.bannerAlt?s.bannerAlt:C(T.isStaticFormat)?"بنر ویدیو پلیر کافه ویدیو":r.title,className:"pl-size-full"}),C(T.hasSubtitlesInDetails)&&Za(r.subtitles).map(p=>S.jsx("track",{id:`player-tracker-${p.lang}`,src:p.url,label:Qa(p.lang),kind:"subtitles",srcLang:p.lang},p.id))]})})}},Symbol.toStringTag,{value:"Module"})),Ny=({className:n,onClick:e})=>S.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,onClick:e,children:S.jsxs("g",{opacity:"0.7",children:[S.jsx("path",{d:"M11.6997 10.7997C12.2247 10.2747 13.1247 10.6497 13.1247 11.3914V13.833C13.1247 15.2664 12.6081 16.3414 11.6831 16.858C11.3081 17.0664 10.8914 17.1664 10.4581 17.1664C9.79141 17.1664 9.07474 16.9414 8.34141 16.483L7.80807 16.1497C7.35807 15.8664 7.28307 15.233 7.65807 14.858L11.6997 10.7997Z"}),S.jsx("path",{d:"M18.141 1.85742C17.891 1.60742 17.4827 1.60742 17.2327 1.85742L13.1077 5.98242C13.0577 4.64909 12.5577 3.64909 11.6743 3.15742C10.741 2.64076 9.54935 2.77409 8.33268 3.53242L5.90768 5.04909C5.74102 5.14909 5.54935 5.20742 5.35768 5.20742H4.58268H4.16602C2.14935 5.20742 1.04102 6.31575 1.04102 8.33242V11.6658C1.04102 13.6824 2.14935 14.7908 4.16602 14.7908H4.29935L1.84935 17.2408C1.59935 17.4908 1.59935 17.8991 1.84935 18.1491C1.98268 18.2658 2.14102 18.3324 2.30768 18.3324C2.47435 18.3324 2.63268 18.2658 2.75768 18.1408L18.141 2.75742C18.3994 2.50742 18.3994 2.10742 18.141 1.85742Z"})]})}),By=({className:n,onClick:e})=>S.jsx("svg",{width:"13",height:"16",viewBox:"0 0 13 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:n,onClick:e,children:S.jsx("path",{d:"M10.6827 1.14944C9.74935 0.632778 8.55768 0.766111 7.34102 1.52444L4.90768 3.04944C4.74102 3.14944 4.54935 3.20778 4.35768 3.20778H3.58268H3.16602C1.14935 3.20778 0.0410156 4.31611 0.0410156 6.33278V9.66611C0.0410156 11.6828 1.14935 12.7911 3.16602 12.7911H3.58268H4.35768C4.54935 12.7911 4.74102 12.8494 4.90768 12.9494L7.34102 14.4744C8.07435 14.9328 8.79102 15.1578 9.45768 15.1578C9.89102 15.1578 10.3077 15.0578 10.6827 14.8494C11.6077 14.3328 12.1243 13.2578 12.1243 11.8244V4.17444C12.1243 2.74111 11.6077 1.66611 10.6827 1.14944Z"})}),Uy=Object.freeze(Object.defineProperty({__proto__:null,default:()=>{const[n,e]=P.useState(""),t=xe(),{settings:s}=V(({user:{settings:l}})=>({settings:l}),K),r=P.useRef(s.brightness),i=P.useRef(s.volume),a=P.useRef(n);P.useEffect(()=>{a.current=n},[n]),P.useEffect(()=>{let l=0;const c=f=>{C(T.hidePopovers)&&!gr(f,"progress-area")&&(l=f.touches[0].clientY)},u=f=>{C(T.hidePopovers)&&!gr(f,"progress-area")&&(f.stopPropagation(),f.touches[0].clientX>window.innerWidth/2?o(f,"volume",l,window.innerHeight):f.touches[0].clientX<window.innerWidth/2&&o(f,"brightness",l,window.innerHeight))},d=()=>{const{settings:f}=R.getState().user;a.current==="brightness"&&r.current!==f.brightness?(oe(ch(r.current,f.brightness)),r.current=f.brightness):a.current==="volume"&&i.current!==f.volume&&(oe(on(i.current,f.volume)),i.current=f.volume),setTimeout(()=>e(""),500)};return document.addEventListener("touchstart",f=>c(f)),document.addEventListener("touchmove",f=>u(f)),document.addEventListener("touchend",()=>d()),()=>{document.removeEventListener("touchstart",f=>c(f)),document.removeEventListener("touchmove",f=>u(f)),document.removeEventListener("touchend",()=>d())}},[]),P.useEffect(()=>{s.volume===0&&!n&&(i.current=0)},[s.volume]);const o=(l,c,u,d)=>{const{settings:f}=R.getState().user,{activePointerProgressBar:g}=R.getState().controller;try{g||t(Se(!1)),l.stopPropagation(),e(c);const{height:h}=document.getElementsByClassName("pl-bar")[0].getBoundingClientRect();if(c==="volume"){const m=f.volume+(u-l.touches[0].clientY)/40*h/d;let p;m>100?p=100:m<0?p=0:p=Math.ceil(Math.abs(m)),t(at({...f,volume:p})),N().volume=p/100}else if(c==="brightness"){const m=f.brightness+(u-l.touches[0].clientY)/40*h/d;m>100?t(at({...f,brightness:100})):m<0?t(at({...f,brightness:0})):t(at({...f,brightness:Math.ceil(Math.abs(m))}))}}catch{return!1}};return S.jsxs("div",{id:"volume-brightness",children:[S.jsx("div",{className:"pl-fixed pl-right-0 pl-top-0 pl-h-screen pl-w-screen pl-bg-black",style:{opacity:s.brightness<10?.9:1-s.brightness/100}}),S.jsxs("div",{className:"pl-absolute pl-right-0 pl-top-0 pl-flex pl-h-full pl-w-full pl-items-center pl-justify-between",children:[S.jsx("div",{className:"pl-flex pl-h-full pl-flex-1 pl-items-center pl-pr-6",children:S.jsx("div",{id:"volume-progressbar",className:`pl-bar pl-relative pl-h-[200px] pl-w-6 ${n==="volume"&&"pl-bg-gray-300"} pl-flex pl-max-h-[80vh] pl-items-end pl-justify-end pl-overflow-hidden pl-rounded-[50px]`,children:n==="volume"&&S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"pl-absolute pl-w-full pl-rounded-b-[50px] pl-bg-secondary-600",style:{height:`${s.volume}%`}}),S.jsxs("div",{className:"pl-mb-[7px] pl-ml-0.5 pl-flex pl-items-center pl-gap-1",children:[S.jsxs("div",{className:"pl-relative pl-flex pl-items-center",children:[s.volume>0&&S.jsx("div",{className:"pl-absolute pl-right-[2px] pl-flex pl-h-2 pl-w-2 pl-items-center pl-justify-center pl-rounded-full pl-border-2 pl-border-r-2 pl-border-transparent pl-border-r-z-yellow-light"}),s.volume>33&&S.jsx("div",{className:"pl-absolute pl-right-[-1px] pl-flex pl-h-3 pl-w-3 pl-items-center pl-justify-center pl-rounded-full pl-border-2 pl-border-r-2 pl-border-transparent pl-border-r-z-yellow-light"}),s.volume>66&&S.jsx("div",{className:"pl-absolute pl-right-[-4px] pl-flex pl-h-4 pl-w-4 pl-items-center pl-justify-center pl-rounded-full pl-border-2 pl-border-r-2 pl-border-transparent pl-border-r-z-yellow-light"})]}),s.volume===0?S.jsx(Ny,{className:"pl-z-[1] pl-h-[13px] pl-w-[13px] pl-fill-dark-7"}):S.jsx(By,{className:"pl-z-[1] pl-h-[13px] pl-w-[13px] pl-fill-dark-7"})]})]})})}),n&&S.jsx("div",{className:"pl-flex pl-h-[54px] pl-w-[54px] pl-items-center pl-justify-center pl-rounded-full pl-bg-secondary-700/[0.8] pl-text-[32px] pl-font-normal pl-text-white",children:n==="volume"?s.volume:s.brightness}),S.jsx("div",{className:"pl-flex pl-h-full pl-flex-1 pl-items-center pl-justify-end pl-pl-6",children:S.jsx("div",{id:"brightness-progressbar",className:`pl-bar pl-relative pl-h-[200px] pl-w-6 ${n==="brightness"&&"pl-bg-gray-300"} pl-flex pl-max-h-[80vh] pl-items-end pl-justify-end pl-overflow-hidden pl-rounded-[50px]`,children:n==="brightness"&&S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"pl-absolute pl-w-full pl-rounded-b-[50px] pl-bg-primary-600",style:{height:`${s.brightness}%`}}),S.jsx("div",{className:"pl-mb-[7px] pl-ml-0.5 pl-flex pl-items-center pl-gap-1",style:{opacity:s.brightness/100},children:S.jsx("img",{alt:"",src:re.sun,className:"pl-size-5 pl-flex-1"})})]})})})]})]})}},Symbol.toStringTag,{value:"Module"})),$y=Object.freeze(Object.defineProperty({__proto__:null,default:()=>S.jsxs("div",{className:"pl-flex pl-h-full pl-w-full pl-flex-col pl-items-center pl-justify-center pl-rounded-2xl",children:[S.jsx("div",{className:"pl-flex pl-justify-center",children:S.jsx("img",{src:re.notFound,alt:"",width:120,height:70})}),S.jsx("h1",{className:"pl-mb-2 pl-mt-4 pl-text-[12px] pl-font-medium pl-text-black/[0.87]",children:"ویدیویی برای نمایش وجود نداره"}),S.jsx("p",{className:"pl-text-[12px] pl-font-medium pl-text-black/[0.50]",children:"میتونید ویدیوهای مشابه با اون رو مشاهده کنید."})]})},Symbol.toStringTag,{value:"Module"}));Le.FeatureExcept=qn,Le.MiniPlayerLibrary=ym,Le.VideoPlayerLibrary=Lh,Object.defineProperty(Le,Symbol.toStringTag,{value:"Module"})});
|