1import{m as $o,C as Ut,d as Le,B as Xh,c as Qh,A as Sl,a as Xt,b as Jh}from"./vendor-C1rVTjBw.js";import{s as Jt,u as Zh,i as vl,r as Vo,d as Tl,a as ir,t as ef}from"./lodash-C3EpVO28.js";import{V as nr,C as Zt,m as rr,r as tf}from"./vue-7tAPG9--.js";import{g as sf}from"./uuid-DPhIvVwf.js";const es=$o.default||$o,nf=30,rf=24,of=60,af=60,lf=1e3,en=["month","day","hour","minute","second","millisecond"],cf=[nf,rf,of,af,lf,1],ts=(t="millisecond")=>(e=0,s="month")=>{s.endsWith("s")&&(s=s.slice(0,-1));let i=en.indexOf(s),n=en.indexOf(t);if([i,n].some(o=>o===-1))throw new Error(`Invalid unit of time is provided. Valid units are: ${en.join(", ")}. Both singular and plural.`);const r=n<i;if(r){const o=i;i=n,n=o}return e*cf.slice(i,n).reduce((o,a)=>o*a,1)**(r?-1:1)},Dt=es(ts("millisecond")),kt=es(ts("second"));es(ts("minute"));const df=es(ts("hour")),Ai=es(ts("day"));es(ts("month"));const uf=t=>{if(!t)return"";t=Number(t);const e=Math.floor(t/3600),s=Math.floor(t%3600/60),i=e>0?`${e} %h%`:"",n=s>0?`${s} %m%`:"",r=t>0&&t<60?`${Math.floor(t)} %s%`:"";return`${i} ${n} ${r}`},hf=(t,e)=>t>e?1:t<e?-1:0,H_=(t,e,s,i)=>{if(e>=t.length)return t.valueOf();const n=t.split("");let r;for(r=0;r<=n.length;r++)n[r]&&r>=e&&r<=s&&(n[r]="");return n[e]=i,n.join("")},ff=(t,e)=>t.padStart(e,"0"),K_=t=>t&&t.split(".")?.[0]||"",W_=(t,e,s)=>s?t.replace(e,`${s}`):t,gf=t=>typeof t=="string"?t.replaceAll(/['`()\\|~^*@<>$]/gi,""):"";class Ii{store;constructor(){this.store=null}set(e,s,i){return this.store.setItem(e,JSON.stringify(s)),s}get(e){const s=this.store.getItem(e);if(typeof s!="string")return null;try{return JSON.parse(s)}catch{return s}}getWithDefault(e,s){const i=this.get(e);return i==null?s:typeof s=="string"?i:typeof i=="string"?s:i}remove(e,s){this.store.removeItem(e)}removeAll(){this.store.clear()}getAll(){const e={};for(let s=0;s<this.store.length;s++){const i=this.store.key(s);if(!i)continue;const n=i.toString();e[n]=this.get(n)}return e}}class pf extends Ii{constructor(){super(),this.store=window.localStorage}}class mf extends Ii{constructor(){super(),this.store=window.sessionStorage}}const yf=t=>{if(t.substring(0,1)==="{")try{return JSON.parse(gf(t))}catch{return t}return t!=="undefined"?decodeURIComponent(t):null};class Sf extends Ii{set(e,s,i={}){const{expires:r=new Date(Date.now()+Dt(120,"months")),path:o="/",secure:a=!1}=i,l={expires:r,path:o,secure:a,sameSite:"lax"},c=s!==void 0&&typeof s=="object"?JSON.stringify(s):s;return Ut.set(e,c,l),s}get(e){const s=Ut.get(e);return s?yf(s):null}getAll(){const e={},s=Ut.get();for(const i in s)Object.getOwnPropertyDescriptor(s,i)&&(e[i]=this.get(i));return e}remove(e,s){const i={};return s&&(i.path=s),Ut.remove(e,i),null}removeAll(){const e=Ut.get();for(const s in e)Object.getOwnPropertyDescriptor(e,s)&&Ut.remove(s)}}class vf extends Ii{set(e,s,i){return s}get(e){return null}remove(e){}removeAll(){}getAll(){return{}}}const Go=t=>{const e=window[t];try{const s="__storage_test__";return e.setItem(s,s),e.removeItem(s),!0}catch(s){const i={nonFf:22,ff:1024},n={nonFf:"QuotaExceededError",ff:"NS_ERROR_DOM_QUOTA_REACHED"},r=s.code===i.nonFf||s.code===i.ff||s.name===n.nonFf||s.name===n.ff;return s instanceof DOMException&&r&&e?.length!==0}},Tf=()=>{if(!navigator.cookieEnabled)return!1;document.cookie="cookietest=1";const t=document.cookie.indexOf("cookietest=")!==-1;return document.cookie="cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT",t},Li=new vf;let Ce=Li,Ef=Li,me=Li,kn=Li;typeof window<"u"&&(Tf()&&(me=new Sf,kn=me),Go("localStorage")&&(Ce=new pf,kn=Ce),Go("sessionStorage")&&(Ef=new mf));const bf={error:"red",warn:"yellow",notice:"green",info:"green",debug:"blue",trace:"blue"},xf={blue:"#4b88ff"},Af=["info","debug","trace"],If={error:"log",warn:"log",notice:"log",info:"log",debug:"log",trace:"debug"},Bt=(t,e)=>{const s=bf[t];if(!Ce.get("debug")&&Af.includes(t))return Function();{const i=If[t]||"log",n=xf[s]||s;return Function.prototype.bind.call(console[i],console,`%c[${e}]`,`color: ${n}; font-weight: bold;`)}},H=t=>({error:Bt("error",t),warn:Bt("warn",t),notice:Bt("notice",t),info:Bt("info",t),debug:Bt("debug",t),trace:Bt("trace",t)});var Ho={};class q_{error;warn;info;status=0;ctx=void 0;errorDetails;constructor(e){["error","warn","info"].forEach(i=>
1{Ho.LOG_FORMAT==="loki"?this[i]=this.logLoki(i,e):this[i]=this.logDefault(i,e)})}setStatus(e){return this.status=e,this}setCtx(e){return this.ctx=e,this}setErrorDetails(e){this.errorDetails=e}reset(){this.status=0,this.ctx=void 0,this.errorDetails=void 0}logLoki(e,s){return(...i)=>{console.log(JSON.stringify({severity:e,date:Le().format("YYYY-MM-DD HH:mm:ss:SSS"),message:i.join(" "),errorDetails:this.errorDetails,context:s,ip:this.ctx?.ip||"",method:this.ctx?.method||"",url:this.ctx?.originalUrl||"",status:this.status,pid:Ho.pm_id||""})),this.reset()}}logDefault(e,s){return(...i)=>{const n=[];this.ctx&&n.push(`${this.ctx?.method} ${this.ctx?.originalUrl} - ${this.status}`),this.errorDetails&&n.push(this.errorDetails),H(s)[e](...n,...i),this.reset()}}}const ds={safari:"Safari",chrome:"Chrome",firefox:"Firefox",ie:"Internet Explorer",edge:"Microsoft Edge",yandex:"Yandex Browser"},Ko={ios:"ios",macos:"macos"},Wo={mobile:"mobile",tablet:"tablet"},Lf=/HUAWEI|HMS|ALP-|AMN-|ANA-|ANE-|ANG-|AQM-|ARS-|ART-|ATU-|BAC-|BLA-|BRQ-|CAG-|CAM-|CAN-|CAZ-|CDL-|CDY-|CLT-|CRO-|CUN-|DIG-|DRA-|DUA-|DUB-|DVC-|ELE-|ELS-|EML-|EVA-|EVR-|FIG-|FLA-|FRL-|GLK-|HMA-|HW-|HWI-|INE-|JAT-|JEF-|JER-|JKM-|JNY-|JSC-|LDN-|LIO-|LON-|LUA-|LYA-|LYO-|MAR-|MED-|MHA-|MLA-|MRD-|MYA-|NCE-|NEO-|NOH-|NOP-|OCE-|PAR-|PIC-|POT-|PPA-|PRA-|RNE-|SEA-|SLA-|SNE-|SPN-|STK-|TAH-|TAS-|TET-|TRT-|VCE-|VIE-|VKY-|VNS-|VOG-|VTR-|WAS-|WLZ-|WKG-|MLD-|RTE-|NAM-|NEN-|BAL-|JAD-|JLN-|YAL|MRA/i,Ri=t=>Xh.getParser(t),Rf=t=>Ri(t).getPlatformType(!0),Cf=t=>Ri(t).getBrowserVersion(),_f=t=>Ri(t).getOSName(!0),El=t=>Ri(t).getBrowserName(),wf=t=>{const e={artel:/Artel/i.test(t),huawei:Lf.test(t),oppo:/OPPO/i.test(t),vivo:/vivo/i.test(t)};return Object.keys(e).find(i=>e[i])||""},bl=t=>{const e={ipad:/iPad/i.test(t),ipod:/iPod/i.test(t),iphone:/iPhone/i.test(t),android:/Android/i.test(t),winphone:/Windows Phone/i.test(t),dune:/arora/i.test(t)||/dune/i.test(t),eltex:/eltex/i.test(t),mag:/mag/i.test(t),netcast:/netcast/i.test(t)||/LG SimpleSmart/i.test(t),samsung:/smart-tv/i.test(t),tizen:/Tizen/i.test(t),webos:/Web0S/i.test(t),pc:/Opera/i.test(t)||/Mozilla/i.test(t)};return Object.keys(e).find(i=>e[i])||""},or=t=>{const e=bl(t),s=wf(t),i=Rf(t),n=typeof window>"u";return{isAndroid:e==="android",isAndroidWithoutGooglePlay:["artel","huawei","oppo","vivo","winphone"].indexOf(s)!==-1,isIphone:e==="iphone",isArtel:s==="artel",isHuawei:s==="huawei",isOppo:s==="oppo",isVivo:s==="vivo",isWinphone:e==="winphone",isMobile:i===Wo.mobile,isTablet:i===Wo.tablet,isiPadPro:n?!1:navigator.userAgent.match(/Mac/)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2,isSmartTv:["netcast","webos","samsung","tizen"].indexOf(e)!==-1,isStb:["dune","eltex","mag"].indexOf(e)!==-1,isPc:e==="pc"||!e}},Df=t=>{const e=_f(t);return{isIos:e===Ko.ios,isMacos:e===Ko.macos}},qo=t=>{const e=El(t);return{isMicrosoft:[ds.ie,ds.edge].includes(e),isSafari:e===ds.safari,isEdge:e===ds.edge,isYandex:e===ds.yandex}},Yo=t=>{const e=or(t);return e.isMobile?"phone":e.isTablet?"tablet":e.isiPadPro?"iPadPro":e.isSmartTv||e.isStb?"smarttv":"pc"},Y_=t=>t.includes("wv")&&or(t).isAndroid,ss=t=>window.navigator.userAgent,kf={currentStep:"",stepsHistory:[],nextStep:"",pinAction:"",isShown:!1},xl={checkboxes:[],phoneMask:{use:!1,phoneCode:"+7 (999) 999 - 9999"},loginMask:"",textBelowLoginButtonId:"",textBelowRegButtonId:"",registration:{checkboxes:[],contentBlock:{},contentBlockId:"",show:!1,usePhoneRegistration:!1},contentBlock:{},contentBlockId:"",eula:{},eulaId:"",image:{},imageId:"",password:{min:1,max:30},regAcquiring:{disclaimerBlockId:"",advertisementTextBlockId:"",controlSubscriptionsOnlyOnSmotreshkaBlockId:"",disclaimerInChannelsListBlockId:"",disclaimer:{},advertisementText:{},controlSubscriptionsOnlyOnSmotreshka:{},disclaimerInChannelsList:{}},regTrials:{activeTrialId:"",enabled:!1},reportProblem:{},reportProblemId:"",restorePassword:{show:!0,contentBlock:{},contentBlockId:""},showPhoneUnlinkPage:!0,showRegCaptcha:!0,showRegPage:!0,showRestorePwdPage:!0,showRegistrationButton:!0,registrationButtonUrl:"",phone:"",usePromoCodes:!1,usePlusInPhoneMethods:{auth:!1,registration:!1,restorePassword:!1,phoneInfo:!1},recaptchaId:"",termsOfUse:[],methodAuth:"",isVercontServerEnabled:!0,staticProviderId:"",individualPage:!0,logoId:"",trial:{},isNewProviderSelected:!1,useContactVerifyV2:!0,isVercontCaptchaImageEnabled:!1,promoCodeABExperiment:{optionB:"",optionC:""},loginMethods:[],autoLoginData:{}},Pf={bodyScrollLockCount:0,isHeaderTransparent:!1,isHeaderAboveContent:!1,isHttps:!0,isOffline:!1,isProfileConfirmationOverlayVisible:!1,isPromoCodeOfferSkipVisible:!1,isSmartAppBannerVisible:!1,localTime:Date.now(),needServerTimeSync:!1,serverTime:Date.now()},Of={items:{}},Mf={params:{},scrollPosition:0,title:"",visibility:{adultOnboarding:!1,byRoute:!1,dvrError:!1,dvrWarning:!1,feSettings:!1,mobileAp
1ps:!1,offerDetails:!1,offerExitConfirmation:!1,offerGift:!1,personalData:!1,phoneVerification:!1,playerHelp:!1,popupNotice:!1,profileAction:!1,profileProtected:!1,qs:!1,qsQr:!1,skipPromoOffers:!1,subscriptionConfirmation:!1,subscriptionShop:!1,subscriptionV2:!1,trialGift:!1,unsubscriptionRetentionOfferDetails:!1,verificationSubscription:!1,welcomeScreen:!1}},Nf={simple:[],complex:{adultOnboarding:{isVisible:!1,title:"",message:"",withButton:!1},authAndReg:{isVisible:!1,returnUrl:""},autologinMegafon:{isVisible:!1},dvrRestriction:{isVisible:!1},dvrRestrictionWithButton:{isVisible:!1},playerError:{isVisible:!1},providerContactInfo:{isVisible:!1,title:"",message:""},retry:{isVisible:!1},review:{isVisible:!1},subscriptionPaymentError:{isVisible:!1},subscriptionProlongationError:{isVisible:!1,message:""},unavailableContent:{isVisible:!1,image:null,sourceId:"",titleId:"",titleText:""}},queue:[]},Ff={items:[]},Al={tv:{items:[]},vod:{hasMorePausesToLoad:!1,loading:!1,loaded:!1,items:[]}},Uf={method:null,yakassaSubscriptions:[],currentSubscriptions:[]},Bf={alert:"",dvrWarningOverlay:{channelId:null,message:""},error:null,fastForwarding:!1,isDateTimeVisible:!0,isEpgVisible:!1,isFullscreenMenuVisible:!1,isScrollLocked:!1,isSettingsMenuVisible:!1,loading:!1,minimized:!1,nextProgram:null,rewinding:!1,timeline:{isBalloonFollowingMouse:!0,isBalloonVisible:!1},touchedTimes:0,type:"",video:{fps50:!0,isFullscreen:!1,hasSubtitles:!1,scaled:!1,src:"",subtitleDisplay:!1,wasLanguageChanged:!1,wasPlayingBeforeOffline:!1},visible:!1,volumeSlider:{isMounted:!1,hideTimeoutId:null,visible:!1}},$f={elements:[],currentElement:null,showTimeoutId:null,showTimeMs:0,contextToken:"",sendTimeoutStatId:null},Vf={currentAction:"",isProfileLoading:!1,isProfileLoaded:!0,profileIdToDelete:"",profileSelected:{}},Gf={items:{},isBannersDataLoaded:!1,isBannersDataLoading:!1},Hf=null,Kf={existingSubscriptions:null,allAvailableSubscriptions:null,availableSubscriptions:null,shopSubscriptions:null,allSubscriptions:null,promoCodeSubscriptions:null,channel:null,confirmationUrl:"",currentSourceId:"",currentStepIndex:0,paymentRetry:!1,phone:"",qrPayment:{isPaid:!1,isError:!1,title:"",expiresAt:""},qsTransactionId:"",serverError:{code:"",message:""},sourceType:"",subscriptionDetails:null,subscriptionsBySource:{},tempSubscription:null,toPrevStep:!1,usePm:!0,vod:null,loading:!1,loadingId:"",availableSubscriptionDetails:null,activeSubscriptionDetails:null,subscriptionShop:{isLoading:!1,loadingId:""},additionalActions:{currentStepIndex:0},isOtherSubscriptionVisible:!1},Wf={currentOfferId:"",confirmationUrl:"",vodCaption:"ÐиноÑеаÑÑÑ: ivi, Megogo, AMEDIATEKA, START",createSubscriptionError:"",disableTrials:!1,autoTrialStatus:null,autoTrialDuration:0},Il={title:"",meta:[],breadcrumbs:[],breadcrumbTelevisionChannel:null,breadcrumbProduct:null},qf={onAir:{isLoading:!1,isLoaded:!1,schedules:{},relevantInterval:void 0,updateDuringInterval:void 0},full:{schedules:{},isLoading:!1}},Yf="Googlebot|YandexBot|YandexMobileBot",x={account:"/v2/account",login:"/v2/login",qrLogin:"/v2/login/qr",logout:"/logout",genres:"/genres",channels:"/channels",channelsV2:t=>`/tv/v2/channels?tv-asset-token=${t}`,medias:t=>`/tv/v2/medias?tv-asset-token=${t}`,channel:t=>`/channels/${t}`,epg:{onAir:"/epg/v2/on-air",schedules:{index:t=>`/epg/v2/schedules/${t}/index`,spread:t=>`/epg/v2/schedules/${t}/spread`}},profileRestrictions:"/v2/settings/profile/restrictions",recommendedChannels:"/channels-recommendations/v1",recentAndFavChannels:"/walls/1",channelsNotForPurchase:"/subscription-options/tv/channels-not-for-purchase/v2",playbackInfo:t=>`/playback-info/${t}`,playbackInfoMedia:t=>`/playback-info-media/${t}`,dvrAvailability:t=>`/playback-info/${t}/dvr-availability`,appInfo:"/app-info",speedTests:"/app-info/speed-tests/v2",favorites:"/favorites",profile:"/account/profile",managingLogin:"/v2/managing-login",managingLogout:"/v2/managing-logout",managingLoginWithVerifiedContacts:"/v2/managing-login/with-verified-contacts",managingLoginMethods:"/v2/managing-login/methods",currentSubscriptions:"/account/v3/current-subscriptions",changeProfile:"/account/change-profile",changeProfileV2:"/v2/account/change-profile",createProfile:"/v2/account/profile",changePassword:"/account/change-password",updateProfile:t=>`/v2/account/profile/${t}`,deleteProfile:t=>`/v2/account/profile/${t}`,getProfile:t=>`/v2/account/profile/${t}`,vod:{sources:"/vod/v2/",favorites:"/vod-list/v1",categories:t=>`/vod/v2/${t}/categories`,collections:t=>`/vod/v2/${t}/collections`,collectionTitles:(t,e)=>`/vod/v2/${t}/collections/${e}/titles`,similarities:(t,e,s)=>`/vod/v2/${t}/titles/${e}/similarities?audience-token=${s}`,titles:t=>`/vod/v2/${t}/titles`,titlesMeta:t=>`/vod/v2/${t}/titles-meta`,searchTitles:t=>`/vod/v2/${t}/search-titles`,title:(t,e)=>`/vod/v2/${t}/titles/${e}`,season:(t,e,s)=>`/vod/v2/${t}/titles/${e}/seasons/${s}`,seasonEpisodes:(t,e,s)=>`/vod/v2/${t}/titles/${e}/seasons/${s}/episodes`,allEpisodes:(t,e)=>`/vod/v2/${t}/titles/${e}/episodes`,playback:t=>`/playback/vod/v2/${t}`,playbackUpdate:(t,e)=>`/playback-updates/vod/v1?pbs_id=${t}&close_pbs=${e}`,playbackLsHls:t=>`/playback/ls-hls-video/v1/${t}`,ivi:{lightServer:"https://api.ivi.ru/light",lightServerMock:"http://localhost:8081/ivi",session:t=>`/v2/account/services/ivi?session=${t}`,playback:t=>`/playback/vod/ivi/${t}`},amedia:{playback:t=>`/playback/vod/amedia2/v1/${t}`},megogo:{playback:t=>`/playback/vod/megogo/v1/${t}`}},providerInfo:t=>`/providers/v1/internal-providers/${t}/info`,providerInfoV2:"/providers/v2/internal-provider-info",registration:{byPhone:"/account/register"},restorePassword:"/v2/account/restore-password",restorePasswordByLink:(t,e)=>`/account/restore-password/${e}/${t}`,contactsVerification:{methods:"/contacts-verification/v1/methods",startWithAccountSession:"/contacts-verification/v1/start-with-account-session",start:"/contacts-verification/v1/start",startRecaptcha:"/contacts-verification/v1/start-recaptcha",retry:"/contacts-verification/v1/retry",verify:"/contacts-verification/v1/verify",verifyV2:"/contacts-verification/v1/verify/v2",unlinkPhone:"/user/v1/detach-phone-with-verified-cd",setPhone:"/user/v1/set-phone-with-verified-cd",techSim:"/contacts-verification/v1/verify-with-password/tech-sim",captchaData:"/contacts-verification/v1/captcha-data",captchaImage:t=>`/contacts-verification/v1/captcha-image/${t}/image.png`},assetTokens:"/user/v1/asset-tokens",assetTokensV2:"/user/v1/asset-tokens/v2",availableLogins:"/auth/v1/with-verified-contacts/available-logins",register:"/registration/v1/with-verified-contacts/smotreshka/v3",registerMobile:"/registration/v1/with-verified-contacts/mobile",loginWithVerifiedContacts:"/v2/login/methods/with-verified-contacts",loginMethods:"/v2/login/methods",autologin:"/autologin/v2/login",sendPassword:"/change-password/v1/with-verified-contacts/methods/send-password",promoCodeCheck:"/promocode/check-value/v1",registerWithPromoCode:"/registration/v1/with-verified-contacts/smotreshka-with-promocode/v2",registerWithPromoCodeMobile:"/registration/v1/with-verified-contacts/mobile-with-promocode",registerSimPassword:"/registration/v1/login-password/mobile-with-promocode",contactsVerificationSimPassword:"/contacts-verification/v1/verify-with-password/tech-sim",regions:"/providers/v1/regions",providers:"/providers/v1/providers",statistics:"/send-stats/channel-playing",trialRegistrationStatus:"/trial/registration/v1/status",quickSubscribe:{allAvailableSubscriptionOptions:"/subscription-options/all-available/v2",vodSubscriptionOptions:"/subscription-options/vod/v2",vodSubscriptionOptionsV3:"/subscription-options/vod/v3",tvSubscriptionOptions:t=>`/subscription-options/tv/v2/${t}`,tvSubscriptionOptionsV3:t=>`/subscription-options/tv/v3/${t}`,createSubscriptionWithVerifiedPhone:"/account/v3/create-subscription/with-verified-phone",createSubscription:"/v2/account/subscriptions",createSubscriptionUpsale:"/account/v3/create-subscription/upsale/v1",createSubscriptionUpsaleV2:"/account/v3/create-subscription/upsale/v2",currentSubscriptions:"/current-subscriptions/v2",enableAutoRenew:t=>`/generic-subscriptions/enable-auto-renew/v1/${t}`,disableAutoRenew:t=>`/generic-subscriptions/disable-auto-renew/v1/${t}`,autoRenew:t=>`/generic-subscriptions/renew/v1/${t}`,offersSet:t=>`/subscription-options/offers-set/v1/${t}`,subscriptionShop:t=>`/subscription-options/subscriptions-shop-promo/v1?audience-token=${t}`},unsubscriptionRetention:{begin:"/unsubscription-retention/begin/v1",end:"/unsubscription-retention/end/v1",subscriptionOptions:"/subscription-options/unsubscription-retention/v1"},yakassa:{paymentMethod:"/yakassa/v1/payment-method",removePaymentMethod:"/yakassa/v1/payment-method/remove",archivedSubscriptions:"/yakassa/v1/archived-subscriptions",subscriptions:"/yakassa/v1/subscriptions",subscription:t=>`/yakassa/v1/subscriptions/${t}`,subscriptionPayments:t=>`/yakassa/v1/subscriptions/${t}/payments`,activateSubscription:t=>`/yakassa/v1/subscriptions/${t}/activate`,cancelSubscription:t=>`/yakassa/v1/subscriptions/${t}/cancel`,renewSubscriptionWithExistedPm:t=>`/yakassa/v1/subscriptions/${t}/renew-with-existed-pm`,renewSubscriptionWithNewPm:t=>`/yakassa/v1/subscriptions/${t}/renew-with-new-pm`,offer:t=>`/yakassa/v1/offers/${t}`,lastPaymentFromKassa:t=>`/yakassa/v1/subscriptions/${t}/last-payment-from-kassa`,createSubscription:"/yakassa/v1/create-subscription/v2"},offers:{listOfOffers:"/offers/v3/",offer:t=>`/offers/v3/${t}`,offerAllChannels:t=>`/offers/v3/${t}/all-channels`,offerShowcaseChannels:t=>`/offers/v3/${t}/showcase-channels`},phoneInfoV1:"/phone-info/v1",phoneInfoV2:"/phone-info/v2",bow:{proxy:"/buy-on-website/proxy",tokenData:"/buy-on-website/token-data",qsStateForTransaction:t=>`/account/v3/qs-state-for-transaction/${t}`},pauses:{vod:{titles:"/pause/vod/v1/titles",title:(t,e)=>`/pause/vod/v1/titles/${t}/${e}`,delete:(t,e)=>`/pause/vod/v1/titles/${t}/${e}/forget`},tv:"/pauses"}
1,home:{banners:"/banners/v1/home-carousel",vodCollectionsV2:t=>`/vod/home/collections/v2?audience-token=${t}`,vodCollectionsV3:t=>`/vod/home/collections/v3?audience-token=${t}`},promoElements:t=>`/promo/v2/elements?audience-token=${t}`,mtsby:{captcha:"/captcha",auth:"/v2/login/methods/mts-bel-sms-auth"},kt:{captcha:"/contacts-verification/v1/captcha"},uztel:{auth:"/v2/login/methods/uztelecom-ip"},megafon:{auth_18p:"/v2/login/methods/megafon-18p-token",auth:"/v2/login/methods/megafon-token"},diagnostics:{ip:{m9:"https://plbl.m9.lfstrm.tv/api/my-ip",uz:"https://plbl.uz.lfstrm.tv/api/my-ip"}},evictedSession:"/evicted-session/v1",appSections:t=>`/app-sections?audience-token=${t}`,oldSmotreshkaPremiumPage:"https://old.smotreshka.tv/api/connection_premium_request",brandingMethods:"/brandingMethodList",premiumPageProviderBySlug:t=>`/premium-page/providers-enhancement/${t}`,seoRules:"/seo-rules",redirects:"/redirects",homeScreenConfig:"/home-screen-config-list",headCustomCode:"/head-custom-code",premiumTwo:"/premiumtwo",ssrPath:"/ssr",favicon:"/favicon.svg",externalPlayer:{tvSettings:"/external-player/tv-settings/v1",vod:{hboMax:t=>`/external-player/vod/amedia2/hbo-max-url/v1/${t}`}},popupNotices:{elements:t=>`/promo/v2/notices?audience-token=${t}`,whatToShow:"/notices/what-to-show/v1",reportAction:"/notices/report-action/v1"},marketingExternalCodes:"/marketing/external-codes",searchHistory:{start:"/search-history/v1/search-started",finish:"/search-history/v1/search-finished",useTvChannel:"/search-history/v1/tv-channel-used",useVodTitle:"/search-history/v1/vod-title-used",getHistory:"/search-history/v1/history",report:"/search-history/v2/report-search",useTvChannelV2:"/search-history/v2/tv-channel-used",useVodTitleV2:"/search-history/v2/vod-title-used"},searchV2:"/search/v2",clientAnalytics:"/client-analytics/unified-events/v1",backgroundJobsFiles:"/background-jobs/files"},jf={player:{mute:"player_mute",volume:"player_volume",audioTrackTv:"player_tv_audio_track",audioTrackAmedia:"player_vod_audio_track_amedia",audioTrackMegogo:"player_vod_audio_track_megogo",channelsSettings:"player_tv_channel_settings"},vod:{genreIds:"vod_genreIds",ivi:{uid:"vod_ivi_uid"}}},j_={changeProfile:"CHANGE_PROFILE",player:{play:"PLAYER_PLAY",pause:"PLAYER_PAUSE",reloadStream:"PLAYER_RELOAD_STREAM",changeLanguage:"PLAYER_CHANGE_LANGUAGE",fastForward:{start:"PLAYER_FAST_FORWARD_START",stop:"PLAYER_FAST_FORWARD_STOP"},rewind:{start:"PLAYER_REWIND_START",stop:"PLAYER_REWIND_STOP"},seek:"PLAYER_SEEK",changeLevel:"PLAYER_CHANGE_LEVEL",loadFrag:"LOAD_FRAG",manifestLoaded:"MANIFEST_LOADED"},qs:{handleClose:"handleClose"}},zf=96,Ll={id:"",profiles:[],users:[],provider:void 0,next_provider:void 0,anonymous:!0,delete_reason:"",is_phone_verified:!1,profile:void 0,user:void 0,IVI:void 0},Ze={adultOnboarding:"adultOnboarding",phoneVerification:"phoneVerification",skipPromoOffers:"skipPromoOffers",subscriptionShop:"subscriptionShop",trialGift:"trialGift",verificationSubscription:"verificationSubscription"},Xf={amedia2V1:"amedia2_v1",iviTwoSteps:"ivi_two_steps",iviWithIntegrationParams:"ivi_with_integration_params",megogoV1:"megogo_v1",smotreshkaPlaybackInfo:"smotreshka-playback-info",smotreshkaVodV2:"smotreshka_vod_v2"},z_=Object.values(Xf),Rl={tv:{hideOverlayAfterMilliseconds:3e3,shortJumpSeconds:10,seekStep:{normal:10,medium:30,fast:60},seekLengthToSwitchToMedium:20,seekLengthToSwitchToFast:40,channelSwitchDelay:300},subscribes:{dateUTCMultiplier:1e3},searchDelay:500},X_=6,Te={advCake:"advcake_track_id",analyticsToken:"analytics_token",audienceToken:"audience_token",deviceUuid:"ua_uuid",feCookie:"feCookie",hideRetryAlert:"hide_retry_alert",languageCode:"languageCode",profileConfirmationPeriod:"profile_confirmation_period",profileConfirmed:"profileConfirmed",promoCode:"promo_code",retryBlockForCard:"retry_block_for_card",tvAssetToken:"tv_asset_token",welcomeScreenConfirmed:"welcomeScreenConfirmed"},Lt={archivedSubs:"archivedSubs",feBaseUrl:"feBaseUrl",isSmartAppBannerClosedByUser:"isSmartAppBannerClosedByUser",reviewsDisabled:"reviewsDisabled",userLastItemKey:"userMenuLastItem",utmParameters:"utmParameters",unsubscriptionRetention:"unsubscriptionRetention",lfstrmPartner:"lfstrm_partner",lfstrmPartnerTs:"lfstrm_partner_ts"},fe={all:"",recommended:"__RECOMMENDED__",favourite:"__FAVOURITE__",recentlyWatched:"__LAST_WATCHED__",available:"__AVAILABLE__"},$s={ascendingNumber:"ascendingNumber",descendingNumber:"descendingNumber",ascendingName:"ascendingName",desce
1ndingName:"descendingName"},jo={recommendationPriority:"recommendationPriority",keyNumber:"keyNumber"},Q_={CREATE:"create",CHANGE:"change",UPDATE:"update",DELETE:"delete"},Qf={COMMON:"2",ADULT:"adult"},J_=3,Z_=7,Jf=180,Cl="YYYY-MM-DD",ew=100;Dt(20,"second");const ge={OK:200,NOT_MODIFIED:304,BAD_REQUEST:400,FORBIDDEN:403,NOT_FOUND:404,NOT_ALLOWED:405,CONFLICT:409,GONE:410,PRECONDITION_FAILED:412,NOT_ALLOWED_FOR_LOCATION:451,IVI_NOT_ALLOWED_FOR_LOCATION:4501,SERVER_ERROR:500,SERVICE_UNAVAILABLE:503,IVI_UNAVAILABLE_ON_SITE:4520,IVI_NOT_PURCHASED:4514,IVI_NOT_PAID:4516,EXISTING_LOGIN:4091},tw=[ge.NOT_FOUND,ge.GONE,ge.BAD_REQUEST,ge.SERVER_ERROR],sw=[ge.IVI_NOT_PAID,ge.IVI_NOT_PURCHASED,ge.IVI_UNAVAILABLE_ON_SITE],iw=4,nw=5,rw=30,ow=4,aw=10,lw=6e5,cw=.8,dw=250,uw=.21,hw=.06,Zf=2,eg=5e3,ar=1e4,fw=6,gw=3e3,pw=18,vs=42,mw=12,tg=599,yw=600,Sw=959,vw=960,Tw=1279,Ew=12,bw=8,xw=4,rt={PENDING:"pending",CANCELED:"canceled",WAITING_FOR_CAPTURE:"waiting_for_capture",SUCCEEDED:"succeeded",ACTIVE:"active",IN_RETRY:"in_retry"},Aw={CANCELED_BY_MERCHANT:"canceled_by_merchant"},Iw={SUBSCRIPTION_ALREADY_EXISTS:"yakassa.subscription_already_exists",NO_VERIFIED_PHONE:"yakassa.no_verified_phone_number"},Lw=4031,Rw=4032,Cw=4033,sg=9991,Vs={SELECT_VERIFICATION:"SelectVerificationSubscription",PASSWORD_VERIFICATION:"PasswordVerificationSubscription",PHONE_VERIFICATION:"PhoneVerificationSubscription",DETAIL:"SubscriptionDetails"},_w=[Vs.SELECT_VERIFICATION,Vs.PASSWORD_VERIFICATION,Vs.PHONE_VERIFICATION,Vs.DETAIL],ww=350,Dw={SUPPORTED:"SUPPORTED",UNSUPPORTED:"UNSUPPORTED",TECHSIM:"TECHSIM"},kw="techSimPassword",_l={COMMON:"common",PROVIDER_ERROR:"provider-error",INTERNAL:"internal"},Pw={PHONE_WITH_ACCOUNT_SESSION:"phone-with-account-session"},Qt={unknown:"unknown",processStarted:"process_started",created:"trial_is_created"},Ow=3e3,_e={AUTHENTICATED:"authenticated",PHONE_COLLECT_INSTANT:"sub20-phone-collect-instant",PHONE_COLLECT_DELAYED:"sub20-phone-collect-delayed",UPSALE:"sub20-upsale-v1",UPSALE_V2:"sub20-upsale-v2",UPSALE_V21:"sub20-upsale-v21",PROMO_OFFER:"qs22-promo-offer",SUB21_YAKASSA:"sub21-yakassa",SUB20_YAKASSA_MVP:"sub20-yakassa-mvp"},Mw=[_e.SUB20_YAKASSA_MVP,_e.SUB21_YAKASSA],oi={BILLING_PERIOD:"qs21-billing-period-option",OPERATOR_CONTACT_INFO:"operator-contact-info",SUBSCRIPTION_SHOP:"qs-subscription-shop",SUBSCRIPTION_SHOP_ADJUSTED:"qs-subscription-shop-adjusted"},wl={YAKASSA:"mm-yakassa-v1",AUTO_RENEWABLE:"mm-autorenewable-v1",UNSUB_INFO:"mm-unsub-info-v1"},ig=Object.values(wl),Nw={backspace:8,enter:13},Fw="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",ng=["qs10-legacy-default","qs20-yakassa-v2","qs22-promo-offer","qs22-unsub-retention-offer"],zo={start:"start",captcha:"captcha",checkCode:"checkCode",provider:"provider",finish:"finish",multipleLogins:"multipleLogins",phoneFoundBeforeReset:"phoneFoundBeforeReset",phoneFoundAfterReset:"phoneFoundAfterReset",retryTrialStatus:"retryTrialStatus",error:"error",outdated:"outdated",phoneNotFound:"phoneNotFound",unlinkLogin:"unlinkLogin",success:"success",fail:"fail",unlinkOneOfMultipleLogins:"unlinkOneOfMultipleLogins",emailFinish:"emailFinish",auth:"auth",authMts:"authMts",phoneIsNotAttached:"phoneIsNotAttached",phoneUnsupported:"phoneUnsupported",promoCode:"promoCode",promoCodeNotFound:"promoCodeNotFound",promoCodeUserExist:"promoCodeUserExist",promoCodeSuccess:"promoCodeSuccess",simPassword:"simPassword",autoLoginFailed:"autoLoginFailed",recommendProvider:"recommendProvider",skipProvider:"skipProvider",confirmProvider:"confirmProvider",promoOffers:"promoOffers",promoOffersAB:"promoOffersAB",subscriptionSuccess:"subscriptionSuccess",subscriptionFailed:"subscriptionFailed",promoCodeError:"promoCodeError",autoLoginMegafonFailed:"autoLoginMegafonFailed",evictedDevices:"evictedDevices"},Uw={offer:"offer",gift:"gift"},Bw=[zo.error,zo.outdated],$w={defaultReg:"/reg",defaultLogin:"/login",defaultLoginSmotreshka:"/login/smotreshka",defaultLoginSms:"/login/sms",defaultLoginN3:"/login/n3",defaultLoginPasswd:"/login/passwd",defaultReset:"/reset",defaultCode:"/code",defaultRestore:"/restore-password",qrLogin:"/qr-login",qrSuccess:"/qr-success",autoLogin:"/login/autologin"},rg={autoLogin18p:"login-mf",autoLogin:"login-mf-main"},Vw={sms:"sms",smsAndPasswd:"smsAndPasswd",n3:"n3",smotreshka:"smotreshka"},Gw=12,qe="-1",og="-1",Hw={amedia:"series",ivi:"14",megogo:"16",moretv:"4",newbasevod:"series",premier:"novinki",start:"mov
1ies",vipplay:"movies"},Kw=600*1e3,Ww=20,qw=1e3,Yw={playing:"playing",paused:"paused",stopped:"stopped"},jw={start:"start",timeline:"timeline",displayMode:"displayMode",continue:"continue",stop:"stop"},zw={audioOnly:"audio-only",fullscreen:"fullscreen",windowed:"windowed"},ag={preview:void 0,details:void 0,pauses:[],loaded:!1,loading:!1},Xw=1440,Qw=576,Jw={showIcon:"showIcon",showLegal:"showLegal"},lg="default",Zw={EnterPin:"EnterPin",VerifySession:"VerifySession",NoProfile:"NoProfile",OneProfile:"OneProfile",SetPin:"SetPin",StartStep:"StartStep",YourPin:"YourPin"},eD={create:"create"},tD=3500,sD=3,iD="6481a2afc9e80accd93d5dda",nD={"5aead51021887f04724d177e":{title:"Barely Legal",logo:"https://megafon.server-img.lfstrm.tv/image/aHR0cDovL2ltZy5iNjEyLnRpZ2h0dmlkZW8uY29tL2NoYW5uZWxzL2JhcmVseV9sZWdhbF9uZXcucG5n"},"59ac8dcf21887f680800fc71":{title:"Blue Hustler HD",logo:"https://megafon.server-img.lfstrm.tv/image/aHR0cDovL2ltZy5iNjEyLnRpZ2h0dmlkZW8uY29tL2NoYW5uZWxzL2JsdWVfaHVzdGxlci5wbmc="},"5a3a31c121887fb740dc5969":{title:"Erox",logo:"https://megafon.server-img.lfstrm.tv/image/aHR0cDovL2ltZy5iNjEyLnRpZ2h0dmlkZW8uY29tL2NoYW5uZWxzL2Vyb3gucG5n"},"58bdcf5021887f26e6d9b432":{title:"Ð-лÑ-лÑ",logo:"https://megafon.server-img.lfstrm.tv/image/aHR0cDovL2ltZy5iNjEyLnRpZ2h0dmlkZW8uY29tL2NoYW5uZWxzL29sYWxhLnBuZw=="},"62e406074b4b5eba1d6cf609":{title:"Red Lips HD",logo:"https://megafon.server-img.lfstrm.tv/image/aHR0cHM6Ly9pbWcuYjYxMi50aWdodHZpZGVvLmNvbS9jaGFubmVscy9yZWRfbGlwcy5wbmc="},"57a5a3ca8daaa84636062cde":{title:"Ð ÑÑÑÐºÐ°Ñ Ð½Ð¾ÑÑ HD",logo:"https://megafon.server-img.lfstrm.tv/image/aHR0cDovL2ltZy5iNjEyLnRpZ2h0dmlkZW8uY29tL2NoYW5uZWxzL3J1c3NrYXlhLW5vY2gucG5n"},"5a65d08921887ff2831c1e99":{title:"ШалÑн HD",logo:"https://megafon.server-img.lfstrm.tv/image/aHR0cDovL2ltZy5iNjEyLnRpZ2h0dmlkZW8uY29tL2NoYW5uZWxzL3NoYWx1bi5wbmc="},"6405daef652c7818e3e76fa6":{title:"Brazzers TV Europe",logo:"https://megafon.server-img.lfstrm.tv/image/aHR0cDovL2ltZy5iNjEyLnRpZ2h0dmlkZW8uY29tL2NoYW5uZWxzL2JyYXp6ZXJzLnBuZw=="},"641d94056bda72612718db63":{title:"Playboy",logo:"https://megafon.server-img.lfstrm.tv/image/aHR0cDovL2ltZy5iNjEyLnRpZ2h0dmlkZW8uY29tL2NoYW5uZWxzL3BsYXlib3kucG5n"}},gs={fairplay:"fairplay",playready:"playready",widevine:"widevine"},rD={MAIN_BUTTON:0},oD={password:"password",widthVerifiedContacts:"with-verified-contacts"},aD={fixedProvider:"fixedProvider",recommendProvider:"recommendProvider",selectProvider:"selectProvider"},cg="qs21-billing-period-option",dg="qs21-yakassa",lD="https://[email protected]/38",cD=5e3,dD={registration:"registration"},Dl=["home-banners","home-history","home-suggested-channels","home-recent-channels","home-channel-collections","home-vod-tiles","home-vod-mega-collections","home-vod-collections"],ug=[...Dl],uD=["home-vod-tiles","home-vod-mega-collections","home-vod-collections"],hD=["home-vod-tiles","plain-image-16x9","home-vod-collections"],jt={defaultPopup:"default-popup",windowBgPopup:"window-bg-popup"},fD={[jt.defaultPopup]:"default-1x1",[`${jt.windowBgPopup}-regular`]:"window-bg-2x1",[`${jt.windowBgPopup}-mobile`]:"window-bg-1x2"},hg=Object.values(jt),fg={plainImage:"plain-image"},lr={contentBanner:"content-banner",promoBanner:"promo-banner"},gg={plainImage1x1:"plain-image-1x1",plainImage16x9:"plain-image-16x9",plainPoster:"plain-poster"},pg={textButton:"text-button"},qt={...fg,...gg,...lr,...pg},mg=Object.values(qt),Ci={adultOnboarding:"adult-onboarding",externalUrl:"external-url",internalRef:"internal-ref",internalRefV2:"internal-ref-v2",internalRefV3:"internal-ref-v3",internalRefV4:"internal-ref-v4",internalRefV6:"internal-ref-v6",qsOffersSetV1:"qs-offers-set-v1",noAction:"no-action"},ai={default:"default",home:"home",homeCarouselV2:"home-carousel-v2"},yg=Object.values(Ci).filter(t=>t.startsWith("internal-ref")),gD=[...yg,Ci.qsOffersSetV1],Sg={verticalBlockV1:"vertical-blocks-v1"},kl=Object.values(Ci),oe={tvContentWall:{id:"tv-content-wall",path:t=>`/channels/${t}/about`},tvStartPlayback:{id:"tv-start-playback",path:t=>`/channels/now/${t}/watch`},vodContentWall:{id:"vod-content-wall",path:t=>t==="archive"?"/archive":`/vod/${t}`}
1,vodCollectionPage:{id:"vod-collection-page",path:(t,e)=>`/collection/${t}/${e}`},vodTitlePage:{id:"vod-title-page",path:(t,e)=>t==="archive"?`/archive/${e}`:`/vod/${t}/${e}`},vodStartPlayback:{id:"vod-start-playback",path:(t,e,s)=>t==="archive"?`/archive/${e}`:`/vod/${t}/${e}/${s?s+"/":""}watch`},appSections:{id:"app-section",path:t=>`/s/${t}`},searchPage:{id:"global-search",path:t=>`/search?q=${t}`},subscriptionShopSubscribe:{id:"subscription-shop-subscribe",path:t=>{let e="/personal/subscriptions";const s={};return t?.subscribeOnly&&(s.subscribe_only="true"),t?.scrollToSection&&(s.scroll_to=t?.scrollToSection),Object.keys(s).length&&(e+="?",e+=new URLSearchParams(s)),e}},subscriptionShopManage:{id:"subscription-shop-manage",path:"/personal/subscriptions?t=1"}},pD=3e3,Pn={CONFIRMED:"TrialConfirmed",ERROR:"Error"},Pl={VOD:"vod",CHANNEL:"channel"},mD={passwordVerification:"passwordVerification",phoneVerification:"phoneVerification",selectVerification:"selectVerification"},yD={phoneSending:"phoneSending",verificationError:"verificationError"},vg={phoneSending:0,verificationCode:1,verificationError:2,passwordVerification:0,phoneVerification:1,selectVerification:2},_i="scroll-container",SD=12,Xo=168,vD="searchpage-text",TD="searchpage-banners",ED={advantages:"advantages",question:"question",offer:"offer"},Tg=["unsubscription_retention_v1"],bD={error:"error",completed:"completed",retained:"retained"},xD={declined:"declined",error:"error",subscribed:"subscribed",unfinished:"unfinished",unoffered:"unoffered",unsupported:"unsupported"},AD="autoRenewDisableError",Eg="all",ID={Welcome:"Welcome",SetPin:"SetPin",EnterPin:"EnterPin",Verification:"Verification",SuccessPin:"SuccessPin"},LD={Start:"Start",DisablePin:"DisablePin",SetPin:"SetPin",Verification:"Verification"};var bg=(t=>(t.MANUAL="manual",t.SEARCH_HISTORY="search-history",t.VOICE_INPUT="voice-input",t.CLIPBOARD="clipboard",t.DEEPLINK="deeplink",t))(bg||{}),On=(t=>(t.accent="color-accent-primary",t.brand="color-brand-primary",t.error="color-error",t.success="color-success",t.warning="color-warning",t))(On||{});const xg={defaultV1:"default-v1"},RD=Object.values(xg),CD=50,_D={startup:["start-reg","start-reg-sms","start-login","start-login-sms","start-login-password","start-reg-sms-promocode"],"phone-registration":["checkCode-reg","skipProvider-reg","provider-reg","confirmProvider-reg","outdated-reg","error-reg"],"verify-phone":["phoneFoundBeforeReset-reg","simPassword-login","multipleLogins-login","checkCode-login","multipleLogins-reset","outdated-login","error-login"],"promocode-input":["promoCode-reg","start-reg-promoCode","start-reg-sms-promoCode","promoCode-reg-promoCode","promoCodeNotFound-reg","promoCodeUserExist-reg-promoCode","checkCode-reg-promoCode","promoCodeSuccess-reg-promoCode-provider"],"password-recovery":["start-reset","start-reset-sms","checkCode-reset","start-reset-password","emailFinish-reset","phoneFoundAfterReset-reset"]},wD={auth_reg_start_login:["start-reg","start-reg-sms"],reg_auth_phone_code_input:["checkCode-reg"],reg_phone_confirmed:["skipProvider-reg"],reg_provider_region_select:["provider-reg"],reg_provider_confirmed:["confirmProvider-reg"],reg_unsuccess_reg_error:["outdated-reg","error-reg"],auth_unsuccess_auth_error:["outdated-login","error-login"],reg_account_exist_error:["phoneFoundBeforeReset-reg"],reg_promocode_input:["promoCode-reg","promoCode-reg-promoCode"],reg_promocode_success:["start-reg-promoCode","start-reg-sms-promoCode","start-reg-password-promoCode"],reg_promocode_provider_success:["promoCodeSuccess-reg-promoCode-provider"],reg_promocode_invalid_error:["promoCodeNotFound-reg"],reg_promocode_account_exist_error:["promoCodeSuccess-reg-promoCode-provider"],auth_login_login_input:["start-login-password"],auth_phone_login_input:["start-login","start-login-sms"],auth_phone_code_input:["checkCode-login"],reg_techsim_password_input:["simPassword-login"],auth_account_select:["multipleLogins-login"],recovery_login_sms:["start-reset-sms","start-reset"],recovery_login_code_from_sms:["checkCode-reset"],recovery_login_
1input:["start-reset-password"],recovery_login_success:["emailFinish-reset"],recovery_login_success_by_sms:["phoneFoundAfterReset-reset"],recovery_login_account_select:["multipleLogins-reset"],reg_promocode_success_code_sms:["checkCode-reg-promoCode"]},Ag="amedia-hbo-max",DD="reg_checkbox_ads_agreement",kD="autologin-v2",Ig={channelsNotForPurchase:{},currentGenre:fe.recommended,favorites:{},genres:[],isChannelsCatalogNowOpen:!0,loaded:!1,loading:!1,list:{},listWithOnAirPrograms:[],recentAndFavLoaded:!1,recentAndFavLoading:!1,recentlyWatched:{},recommended:{},searchQuery:"",clientPlatform:"",settings:{},isSettingsLoading:!1},Lg={loaded:!1,loading:!1,analyticsToken:"",audienceToken:"",tvAssetToken:"",expiresAt:""},Rg={loaded:!1,loading:!1,timeout:null,assetTokens:void 0,contextToken:"",regularUpdate:{etag:"",intervalSec:0}},Cg={favorites:[],similarities:[],states:{favoritesLoaded:!1,favoritesLoading:!1,recommendationsLoaded:!1,sourcesLoading:!1,sourcesLoaded:!1,isSourceCollectionLoading:!1,isSourceCollectionLoaded:!1,isAnyHomeCollectionLoaded:!1,isAnyHomeCollectionLoading:!1},homeCollections:[],sourceCollections:[],searchQuery:"",sources:{},sourcesFe:[],sourcesBe:[],sorting:"",sortings:[]},_g=null,wg={sections:[]},Dg={settings:null,isOverlayVisible:!1,subscriptionOptions:null,currentSubscription:null,currentReasonId:null,returnUrlParams:{},hasUnsupportedSubscriptionOptions:!1},kg={items:{}},PD={returnRoute:"",returnMetaTitle:"",premiumPage:{loaded:!1,provider:void 0},personalArea:void 0,adultOnboarding:kf,authAndReg:xl,common:Pf,fileRecords:Of,modals:Mf,notifications:Nf,packages:Ff,payment:Uf,player:Bf,profiles:Vf,qs:Kf,pauses:Al,popupNotices:$f,appSections:wg,contentBlocks:kg,branding2:null,providerInfo:Hf,providerInfoV2:null,registration:Wf,registrationResult:null,seo:Il,seoRules:void 0,tokensV1:Lg,tokensV2:Rg,tvChannels:Ig,tvEpgV2:qf,utmLabels:_g,vod:Cg,theme:"light",styles:"",header:void 0,footer:void 0,cmsPages:[],filePages:{},feSessionId:"",profileRestrictions:[],profileSubscriptions:[],account:{anonymous:!0,delete_reason:"",id:"",is_phone_verified:!1,IVI:void 0,next_provider:void 0,profile:{favorites:[],age_rating:0,name:"anonymous",id:"",is_master:!1,recent_views:[],restriction:"",pin_required:!1},profiles:[],provider:void 0,user:{id:"",is_master:!1,login:"anonymous",email:"",phone:"",session:""},users:[]},appInfo:null,page:null,pages:[],pageFolders:[],defaultLanguageCode:"",languageCode:"",languages:[],translations:{},components:{},flags:{isSigningOut:!1,tvDataState:{loading:!1,loaded:!1}},siteConfig:null,contactsVerification:null,verificationResult:null,availableLogins:null,isPhoneMode:!0,secretSanta:!1,modalCallback:!1,incompletePhone:null,incompletePhoneInitialFlag:!0,page404:null,qsConfig:null,brandingMethods:[],gaParams:{},homeScreenConfig:{config_list:[],options:{}},promoElements:Gf,unsubscriptionRetention:Dg},Pg=t=>{switch(t){case"sm":return"smotreshka";case"galam":case"glm":return"galamtv";case"o":return"otv";case"mts":return"mtstv"}return t},Be=()=>{let t,e,s,i,n,r;{t=window.FE_BASE_URL||"",e=window.BE_BASE_URL||"",s=window.WL_APP_ID||"",i=window.SEQUOIA_HOSTNAME||"",r=!!window.ENABLE_CLIENT_SIGNATURES;try{n=JSON.parse(window.MOCKS||"")}catch{}}if(s=Pg(s),!t)throw new Error("feBaseUrl is not defined!");if(!e)throw new Error("beBaseUrl is not defined!");if(!s)throw new Error("wlAppId is not defined!");return{beBaseUrl:e,feBaseUrl:t,wlAppId:s,sequoiaHostname:i,enableClientSignatures:r,mocks:n}},OD=()=>!!window.FE_BASE_URL?.replace("%feBaseUrl%","")&&!!window.BE_BASE_URL?.replace("%beBaseUrl%","")&&!!window.WL_APP_ID?.replace("%wlAppId%",""),Qo=kn,le=()=>{const{wlAppId:t}=Be();return{isAkado:t==="akado",isAltel:t==="altel",isGalam:t==="galamtv",isIns:t==="ins",isIntersv:t==="intersv",isKcell:t==="kcell",isKt:t==="kt",isMegacom:t==="megacom",isMegafon:t==="megafon",isMftv:t==="mftv",isMtr:t==="mtr",isMts:t==="mtsby",isOtv:t==="otv",isOyna:t==="oyna",isN3:t==="n3",isRumo:t==="rumotv",isRzd:t==="rzd",isSanta:t==="santa",isSevensky:t==="sevensky",isSmotreshka:t.startsWith("sm"),isTele2:t==="tele2",isTtk:t==="ttk",isUcell:t==="ucell",isUztel:t==="uztel"}},Og=t=>new Promise(e=>setTimeout(e,t)),MD=()=>window.hasAdBlock,ND=()=>le().isUztel,si=(t="",e=!0)=>{const s=String(t).trim().replace(/\D/g,"");return le().isUztel?s.slice(3):(e?"+":"")+s},FD=(t="")=>{const e=String(t).trim().replace(/\D/g,"");if(e.length!==11)return e;{const s=(i,n)=>e.substring(i,n);return`+${e[0]} (${s(1,4)}) ${s(4,7)}-${s(7,9)}-${s(9,11)}`}},is=t=>t.account,Ee=t=>!!is(t)?.anonymous,cr=t=>is(t)?.provider?.provider,Mn=t=>cr(t)?.id||"",Mg=t=>
1cr(t)?.name||"",dr=t=>is(t)?.user,Nn=t=>is(t)?.id||"",Ng=t=>dr(t)?.email||"",Fg=t=>dr(t)?.login||"",Ug=t=>is(t)?.profiles||[],Bg=t=>si(t.account?.user?.phone,t.authAndReg.usePlusInPhoneMethods.registration),$g=Object.freeze(Object.defineProperty({__proto__:null,accountSelector:is,cleanupPhoneSelector:Bg,isAnonymousSelector:Ee,profilesSelector:Ug,providerIdSelector:Mn,providerNameSelector:Mg,providerSelector:cr,userEmailSelector:Ng,userIdSelector:Nn,userLoginSelector:Fg,userSelector:dr},Symbol.toStringTag,{value:"Module"})),Vg=t=>t.adultOnboarding.currentStep,Gg=t=>t.adultOnboarding.nextStep,Hg=t=>t.adultOnboarding.stepsHistory,Kg=t=>t.adultOnboarding.pinAction,Wg=t=>(t.account?.profiles?.filter(e=>e.restriction===Qf.ADULT)||[])[0],qg=Object.freeze(Object.defineProperty({__proto__:null,adultProfileSelector:Wg,currentStepSelector:Vg,nextStepSelector:Gg,pinActionSelector:Kg,stepsHistorySelector:Hg},Symbol.toStringTag,{value:"Module"})),Ol=t=>t.appInfo?.currentTime||0,Yg=t=>t.common?.serverTime||0,jg=t=>{const e=Ol(t);return e?Dt(e,"second"):0},zg=Object.freeze(Object.defineProperty({__proto__:null,commonServerTimeSelector:Yg,serverTimeMsSelector:jg,serverTimeSelector:Ol},Symbol.toStringTag,{value:"Module"})),Ml=t=>t.authAndReg?.isVercontCaptchaImageEnabled===!0,Xg=Object.freeze(Object.defineProperty({__proto__:null,isVercontCaptchaImageEnabledSelector:Ml},Symbol.toStringTag,{value:"Module"})),Qg=t=>t.brandingMethods,Jg=Object.freeze(Object.defineProperty({__proto__:null,brandingMethodsSelector:Qg},Symbol.toStringTag,{value:"Module"})),Zg=(t,e,s)=>`${t}?width=${e}&height=${s}`,ep=(t,e,s,i)=>{let n=t,r=e;return s<i?n=Math.round(s*r/i):r=Math.round(i*n/s),{width:n,height:r}},tp=(t,e,s)=>{const i=Math.min(t,s),n=t>s?i*e/t:e;return{width:i,height:n}},sp=(t,e,s,i,n,r)=>{try{const o=new URL(t),l=tp(e,s,3e3);return o.searchParams.set("width",l.width.toString()),o.searchParams.set("height",l.height.toString()),o.searchParams.set("quality","93"),typeof n<"u"&&o.searchParams.set("crop",n.toString()),typeof r<"u"&&o.searchParams.set("axis",r),i&&o.searchParams.set("format","png"),o.toString()}catch{return t}},UD=(t,e,s,i="imageserver",n=!1,r,o)=>{if(!(e&&s))return t;switch(i){case"plain":case"start":return t;case"ivi":case"ivi.ru":return`${t}/${e}x${s}/`;case"megogo":return`${t}/pt/r${e}x${s}`;default:return sp(t,e,s,n,r,o)}},Nl=t=>{let e="",s=!1;const i=t.split(` 2`);for(let n=0;n<=i.length-1;n++){if(i[n]===""||i[n]==="\r")continue;let r=i[n];if(r=r.replace(/[#]{6}(.+)/g,"<h6>$1</h6>"),r=r.replace(/[#]{5}(.+)/g,"<h5>$1</h5>"),r=r.replace(/[#]{4}(.+)/g,"<h4>$1</h4>"),r=r.replace(/[#]{3}(.+)/g,"<h3>$1</h3>"),r=r.replace(/[#]{2}(.+)/g,"<h2>$1</h2>"),r=r.replace(/[#]{1}(.+)/g,"<h1>$1</h1>"),r.trim().startsWith("-")||r.trim().startsWith("+")){const o=r[0];r=r.replace(/^-(.+|-)/gm,"<li>$1</li>"),s||(s=!0,r="<ul>"+r),i[n+1]&&!i[n+1].trim().startsWith(o)&&(r=r+"</ul>")}else s&&(s=!1);r=r.replace(/^\s*(\n)?(.+)/gm,o=>/<(\/)?(h\d|ul|ol|li)/.test(o)?o:"<p>"+o+"</p>"),r=r.replace(/(\[([^\]]+)])\(([^)]+)\)/g,'<a href="$3">$2</a>'),r=r.replace(/(<a [^>]*)(target="[^"]*")([^>]*>)/gi,"$1$3"),r=r.replace(/(<a [^>]*)(>)/gi,'$1 target="_blank" class="link nav-hidden"$2'),r=r.replace(/[*_]{2}([^*_]+)[*_]{2}/g,"<b>$1</b>"),r=r.replace(/[*_]{1}([^*_]+)[*[^"]_]{1}/g,"<i>$1</i>"),r=r.replace(/[~]{2}([^~]+)[~]{2}/g,"<del>$1</del>"),e=e+r}return e},ip=H("utils-channels"),gt=t=>t?t.title:(ip.warn("getChannelTitle: channel was not provided"),""),ze=t=>(t?.keyNumber||"").toString(),BD=t=>ff(ze(t),3),$D=t=>Nl(t?.description||""),VD=t=>t?.relevantGenres,Fl=t=>t?.relevantGenres?.map(e=>e.genreId)||t?.info?.metaInfo?.genres||[],ur=t=>t?.medias?.find(e=>e.isLocked),wi=t=>t?.logoUrl||t?.info?.mediaInfo?.thumbnails?.[0]?.url||"",np=(t,e=zf,s)=>{const i=wi(t);return i?(s||(s=Math.round(e*16/9)),Zg(i,s,e)):""},rp=t=>t.medias?.[0],GD=t=>
2rp(t)?.scheduleId||"",op=t=>({...t,genres:Fl(t),image:np(t,140,248),name:gt(t)}),HD=t=>typeof t=="string"&&!/[^a-z0-9.\-+_\s;\\:%=]+/i.test(t),KD=t=>kt(Math.min(t?.medias?.[0]?.dvrDepthLimitHours||Xo,t?.dvrDepthLimitHours||Xo),"hour"),ap=(t,e)=>t[e],tn=(t,e)=>Object.entries(t).reduce((s,[i,n])=>e(s,i,n),{}),Ts=(t,e)=>e.reduce((s,i)=>{const n=t[i.id];return n&&(s[n.id]={...n,priority:i.priority}),s},{}),WD=(t,e)=>{switch(e){case $s.ascendingNumber:case jo.keyNumber:return t.sort((s,i)=>parseInt(ze(s))-parseInt(ze(i)));case $s.descendingNumber:return t.sort((s,i)=>parseInt(ze(i))-parseInt(ze(s)));case $s.ascendingName:return t.sort((s,i)=>gt(s).localeCompare(gt(i)));case $s.descendingName:return t.sort((s,i)=>gt(i).localeCompare(gt(s)));case jo.recommendationPriority:return t.sort((s,i)=>(s?.priority||0)-(i?.priority||0))}return t},qD=t=>{try{new URL(t)}catch{return!1}return!0},lp=()=>new URL(window.location.href),YD=(t,e)=>e?cp(t):t,cp=t=>{try{return(t||"").replace("http://","https://")}catch{return t}},jD=t=>{const e=t.split("/"),s=e[2].split(":");return e[2]=s[0],e.join("/")},zD=t=>t?new RegExp("^(?:[a-z]+:)?//","i").test(t):void 0,li=(t,e,s="",i="")=>(t==="archive"?["/archive",e,s,i]:["/vod",t,e,s]).filter(n=>n).join("/"),XD=(t,e,s)=>(t==="archive"?["/archive",e,`season${s}`]:["/vod",t,e,`season${s}`]).filter(i=>i).join("/"),QD=t=>`/my/${t}`,JD=(t,e,s="",i="")=>`${li(t,e,s,i)}/watch`,dp=(t,e="")=>{const s=le().isRzd?"list":"now";return`/channels/${e||s}/${t}`},ZD=t=>`/channels/${t}/about`,ek=(t,e="")=>`${dp(t,e)}/watch`,tk=t=>{const e=document.createElement("a");return e.href=t,e},ci=(t,e)=>{const s=t.languageCode,i=t.languages.find(o=>o.isDefault)?.code||"ru",n=s===i;let r="";if(e.startsWith("http")){const o=new URL(e);r=o.origin,e=o.pathname}return n?`${r}${e===""?"/":e}`:`${r}/${s}${e}`},up=(t,e)=>e.replace(/<a\s+(?:[^>]*?\s+)?href=(["'])(.*?)\1/g,(s,i,n)=>{const r=ci(t,n);return`<a href=${i}${r}${i}`}),sk=t=>/['"`()\\|~^*@!<>$]/i.test(t),Fn=()=>{try{throw new Error}catch(t){return t.stack}},Jo=H("language"),hp=t=>{const e=lp(),s=e.pathname.split("/")[1],i=t.map(o=>o.code),n=t.find(o=>o.isDefault)?.code||"ru",r=e.pathname==="/promo"&&Be().wlAppId==="kt"?"kk":i.includes(s)?s:n;if(i.indexOf(r)!==-1)return r;if(i.indexOf(window.navigator.language)!==-1)return window.navigator.language;for(const o of t)if(!(!Array.isArray(o.navigatorLanguages)||!o.navigatorLanguages.length)&&o.navigatorLanguages.indexOf(window.navigator.language)>-1)return o.code;return i[0]||"ru"},Je=(t,e,s)=>!t||typeof t!="object"?null:Object.keys(t).length?e?t[e]||t[s]||null:(Jo.error("getByLanguage: languageCode was not provided. It must be provided",Fn()),null):(Jo.warn("getByLanguage: translations are empty",Fn()),null),ik=t=>t?Qh.fromEn(t):"",fp=t=>{const e={а:"a",б:"b",в:"v",г:"g",д:"d",е:"e",Ñ:"e",ж:"j",з:"z",и:"i",к:"k",л:"l",м:"m",н:"n",о:"o",п:"p",Ñ:"r",Ñ:"s",Ñ:"t",Ñ:"u",Ñ:"f",Ñ
:"h",Ñ:"c",Ñ:"ch",Ñ:"sh",Ñ:"shch",Ñ:"y",Ñ:"e",Ñ:"u",Ñ:"ya",h:"h",d:"d"};return t.toLowerCase().trim().split("").map(s=>e[s]||"").join("")},ae=t=>t.languageCode,gp=t=>t.languages.find(e=>
2e.code===ae(t)),pp=t=>t.languages.find(e=>e.isDefault),mp=t=>t.languages.find(e=>e.isDefault)?.code,yp=t=>t.common.isOffline,Un=t=>t.common.bodyScrollLockCount,Sp=t=>t.common.isHeaderTransparent,vp=t=>t.common.isHeaderAboveContent,Tp=t=>{const e=t.authAndReg?.password?.min;return Number(e)||4},Ep=t=>{const e=t.authAndReg?.password?.max;return Number(e)||32},bp=t=>t.authAndReg?.regTrials?.activeTrialId,xp=Object.freeze(Object.defineProperty({__proto__:null,activeTrialIdFromAdminSelector:bp,authAndRegPasswordMaxSelector:Ep,authAndRegPasswordMinSelector:Tp,bodyScrollLockCountSelector:Un,currentLanguageSelector:gp,defaultLanguageCodeSelector:mp,defaultLanguageSelector:pp,isHeaderAboveContentSelector:vp,isHeaderTransparentSelector:Sp,isOfflineSelector:yp,languageCodeSelector:ae},Symbol.toStringTag,{value:"Module"})),Ap=[{placeholder:/%h%/g,translationId:"h"},{placeholder:/%m%/g,translationId:"m"},{placeholder:/%s%/g,translationId:"s"}],Q=(t,e)=>{if(!e)return"";const s=t.translations[e],i=`{${e}}`;return s&&Je(s,ae(t),t.defaultLanguageCode)||i},Ul=(t,e)=>!!e&&!!t.translations[e],hr=(t,e)=>{const s=uf(e);return Ap.reduce((i,{placeholder:n,translationId:r})=>{const o=Ul(t,r)?Q(t,r):`{${r}}`;return i.replace(n,o)},s)},Ip=Object.freeze(Object.defineProperty({__proto__:null,hasTranslationIdSelector:Ul,secondsToHMSelector:hr,translationSelector:Q},Symbol.toStringTag,{value:"Module"})),fr=(t,e)=>typeof t!="string"||!t?{}:e[t]||{},Bl=t=>typeof t=="object"&&!!t,ks=t=>!Bl(t)||Object.keys(t).length===0,Ie=t=>Jt(t,"priority"),$l=(t,e,s="")=>{let i={};for(const n in t)Object.getOwnPropertyDescriptor(t,n)&&(typeof t[n]!="object"?i[`${s}${n}`]=t[n]:i={...i,...$l(t[n],e,`${n}${e}`)});return i},Lp=(t,e=".")=>$l(t,e),Rp=(t,e)=>{for(const s in e)~s.indexOf(t)&&delete e[s]},Vl=(t,e)=>fr(e,t.fileRecords.items),Di=(t,e)=>{const s=Vl(t,e);return s&&!ks(s)&&Je(s,t.languageCode,t.defaultLanguageCode)?.url||""},Cp=Object.freeze(Object.defineProperty({__proto__:null,fileRecordSelector:Vl,fileRecordUrlSelector:Di},Symbol.toStringTag,{value:"Module"})),Gl=t=>t.tvChannels.loaded,Hl=t=>t.tvChannels.loading,Kl=t=>t.tvChannels.recentAndFavLoaded,Wl=t=>t.tvChannels.recentAndFavLoading,Ps=t=>{const e=t.tvChannels?.channelsNotForPurchase||{};return Object.keys(e).length?Object.entries(t.tvChannels.list).reduce((s,[i,n])=>(typeof e[i]>"u"?s[i]=n:ur(n)||(s[i]=n),s),{}):t.tvChannels.list},ql=(t,e=t.tvChannels.currentGenre,s=!1)=>{let i={...Ps(t)};if(e){const n=yr(t);switch(e){case fe.favourite:i=Ts(i,Yl(t));break;case fe.recommended:i=Object.values(n).length?n:i;break;case fe.recentlyWatched:i=Ts(i,Object.values(pr(t)));break;case fe.available:i=tn(i,(r,o,a)=>(gr(t,a)&&(r[o]=a),r));break;default:i=tn(i,(r,o,a)=>{const l=a?.relevantGenres?.find(d=>t.tvChannels.genres.find(u=>u?.id===d?.genreId)?.title===e),c=(a.info?.metaInfo?.genres||[]).findIndex(d=>d===e)!==-1;return(a?.keyNumber&&l||c)&&(r[o]=a),r})}}if(!s&&t.tvChannels.searchQuery){const n=t.tvChannels.searchQuery.toLocaleLowerCase();i=tn(i,(r,o,a)=>{const l=gt(a).toLocaleLowerCase()||"",c=ze(a);return(l.indexOf(n)!==-1||c.indexOf(n)!==-1)&&(r[o]=a),r})}return i},_p=(t,e)=>(typeof e.name=="string"&&(e.name.includes("channels-now")||e.name.includes("channels-list"))&&(t.tvChannels.isChannelsCatalogNowOpen=e.name.includes("channels-now")),t.tvChannels.isChannelsCatalogNowOpen),gr=(t,e)=>!ur(e)||!!Sr(t,e.id),wp=(t,e)=>!gr(t,e),pr=t=>Ts(t.tvChannels.list,Object.values(t.tvChannels.recentlyWatched||{})),mr=t=>Ts(Ps(t),Object.values(t.tvChannels.favorites||{})),Yl=t=>Object.values(mr(t)),yr=t=>Ts(Ps(t),Object.values(t.tvChannels.recommended||{})),Dp=t=>Object.values(yr(t)),ki=(t,e)=>t.tvChannels.list[e],kp=(t,e)=>(e?.keyNumber?t.tvChannels.genres.find(i=>i.id===e?.relevantGenres?.[0]?.genreId)?.title:e?.info?.metaInfo?.genres?.[0])||"",Sr=(t,e)=>
2t.tvChannels.settings?.[e]||null,jl=(t,e)=>!!Sr(t,e)?.iframeUrl,Pp=t=>t.tvChannels.genres,zl=t=>t.tvChannels.currentGenre,vr=(t,e)=>{switch(e){case fe.all:return Q(t,"all_channels");case fe.available:return Q(t,"available");case fe.recommended:return Q(t,"recommended");case fe.favourite:return Q(t,"favourite");case fe.recentlyWatched:return Q(t,"recentlyWatched");default:return e}},Op=t=>vr(t,zl(t)),Mp=(t,e)=>{const s=vr(t,e.title),i=t.siteConfig?.genreIcons?.find(n=>Q(t,n.translationId)===s||n.id!==""&&n.id===e.id);return Di(t,i?.imageId||t.siteConfig?.genreIconDefault?.imageId||"")},Np=t=>t.tvChannels.clientPlatform,Fp=Object.freeze(Object.defineProperty({__proto__:null,allChannelsSelector:Ps,channelByIdSelector:ki,channelFirstGenreTitleSelector:kp,channelVitrinaSelector:Sr,channelsLoadedSelector:Gl,channelsLoadingSelector:Hl,channelsRecentAndFavLoadedSelector:Kl,channelsRecentAndFavLoadingSelector:Wl,clientPlatformSelector:Np,currentGenreNameSelector:Op,currentGenreSelector:zl,favoritesArraySelector:Yl,favoritesSelector:mr,filteredChannelsSelector:ql,genreIconSelector:Mp,genreTitleSelector:vr,genresSelector:Pp,hasVitrinaSelector:jl,isChannelBoughtSelector:gr,isChannelLockedSelector:wp,isChannelsCatalogNowOpen:_p,recentlyWatchedSelector:pr,recommendedArraySelector:Dp,recommendedSelector:yr},Symbol.toStringTag,{value:"Module"})),Xl=t=>t.siteConfig?.channelCollections||[],Up=t=>Xl(t)?.filter(e=>e.showOnMain&&e.slug&&Tr(t,e).length)||[],Tr=(t,e)=>Object.values(ql(t)).filter(n=>{const r=Fl(n);return r.includes(e.genreId)||r.includes(Q(t,e.genre))}).sort((n,r)=>parseInt(ze(n))-parseInt(ze(r)))||[],Bp=(t,e)=>Tr(t,e)?.map(s=>wi(s))||[],$p=Object.freeze(Object.defineProperty({__proto__:null,channelCollectionsSelector:Xl,channelCollectionsToShowOnMainSelector:Up,channelsFromCollectionSelector:Tr,channelsImagesFromCollectionSelector:Bp},Symbol.toStringTag,{value:"Module"})),Vp=t=>t.modals.params,Gp=t=>t.modals.scrollPosition,Hp=t=>t.modals.title,Er=t=>t.modals.visibility,Ql=t=>Object.values(t.modals.visibility).includes(!0),Kp=t=>t.modals.visibility.adultOnboarding,Wp=t=>t.modals.visibility.byRoute,qp=t=>t.modals.visibility.dvrError,Yp=t=>t.modals.visibility.dvrWarning,jp=t=>t.modals.visibility.feSettings,zp=t=>t.modals.visibility.mobileApps,Xp=t=>t.modals.visibility.offerDetails,Qp=t=>t.modals.visibility.offerExitConfirmation,Jp=t=>t.modals.visibility.offerGift,Zp=t=>t.modals.visibility.personalData,em=t=>t.modals.visibility.phoneVerification,tm=t=>t.modals.visibility.playerHelp,sm=t=>t.modals.visibility.profileAction,im=t=>t.modals.visibility.profileProtected,nm=t=>t.modals.visibility.skipPromoOffers,rm=t=>t.modals.visibility.qs,om=t=>t.modals.visibility.subscriptionConfirmation,am=t=>t.modals.visibility.subscriptionShop,lm=t=>t.modals.visibility.subscriptionV2,cm=t=>t.modals.visibility.trialGift,dm=t=>t.modals.visibility.unsubscriptionRetentionOfferDetails,um=t=>t.modals.visibility.verificationSubscription,hm=t=>t.modals.visibility.welcomeScreen,fm=Object.freeze(Object.defineProperty({__proto__:null,isAdultOnboardingOpenSelector:Kp,isAnyModalOpenSelector:Ql,isByRouteOpenSelector:Wp,isDvrErrorOpenSelector:qp,isDvrWarningOpenSelector:Yp,isFeSettingsOpenSelector:jp,isMobileAppsOpenSelector:zp,isOfferDetailsOpenSelector:Xp,isOfferExitConfirmationOpenSelector:Qp,isOfferGiftOpenSelector:Jp,isPersonalDataOpenSelector:Zp,isPhoneVerificationOpenSelector:em,isPlayerHelpOpenSelector:tm,isProfileActionOpenSelector:sm,isProfileProtectedOpenSelector:im,isPromoOfferSkippedOpenSelector:nm,isQsOpenSelector:rm,isSubscriptionConfirmationOpenSelector:om,isSubscriptionShopOpenSelector:am,isSubscriptionV2OpenSelector:lm,isTrialGiftOpenSelector:cm,isUnsubscriptionRetentionOfferDetailsOpenSelector:dm,isVerificationSubscriptionOpenSelector:um,isWelcomeScreenOpenSelector:hm,modalsParamsSelector:Vp,modalsScrollPositionSelector:Gp,modalsTitleSelector:Hp,modalsVisibilitySelector:Er},Symbol.toStringTag,{value:"Module"})),br=t=>t.notifications,Es=t=>br(t).queue,De=(t,e)=>Es(t).indexOf(e)===0,Jl=t=>!!Object.values(t.notifications.complex).find(({isVisible:e})=>e),gm=t=>
2t.notifications.complex.adultOnboarding,pm=t=>De(t,"adultOnboarding"),mm=t=>t.notifications.complex.authAndReg.isVisible,ym=t=>De(t,"authAndReg"),Sm=t=>t.notifications.complex.autologinMegafon.isVisible,vm=t=>De(t,"autologinMegafon"),Tm=t=>t.notifications.complex.dvrRestriction.isVisible,Em=t=>De(t,"dvrRestriction"),bm=t=>t.notifications.complex.dvrRestrictionWithButton.isVisible,xm=t=>De(t,"dvrRestrictionWithButton"),Am=t=>t.notifications.complex.playerError.isVisible,Im=t=>De(t,"playerError"),Lm=t=>t.notifications.complex.providerContactInfo.isVisible,Rm=t=>De(t,"providerContactInfo"),Cm=t=>t.notifications.complex.retry.isVisible,_m=t=>De(t,"retry"),Zl=t=>t.notifications.complex.review.isVisible,wm=t=>De(t,"review"),Dm=t=>t.notifications.complex.subscriptionPaymentError.isVisible,km=t=>De(t,"subscriptionPaymentError"),Pm=t=>t.notifications.complex.subscriptionProlongationError,Om=t=>De(t,"subscriptionProlongationError"),ns=t=>t.notifications.complex.unavailableContent,Mm=t=>ns(t).image,Nm=t=>ns(t).isVisible,Fm=t=>ns(t).sourceId,Um=t=>ns(t).titleId,Bm=t=>ns(t).titleText,$m=t=>De(t,"unavailableContent"),Vm=t=>t.notifications.simple,Gm=t=>t.notifications.simple.filter(e=>e.type==="autoRenew"),Hm=t=>t.notifications.simple.filter(e=>e.type==="diagnosticsStatus"),Km=t=>t.notifications.simple.filter(e=>e.type==="error"),Wm=t=>t.notifications.simple.filter(e=>e.type==="favorite"),qm=t=>t.notifications.simple.filter(e=>e.type==="loginSuccess"),Ym=t=>t.notifications.simple.filter(e=>e.type==="pauseRemoved"),jm=t=>t.notifications.simple.filter(e=>e.type==="profile"),zm=t=>t.notifications.simple.filter(e=>e.type==="qs"),Xm=Object.freeze(Object.defineProperty({__proto__:null,adultOnboardingSelector:gm,isAdultOnboardingFromQueueVisible:pm,isAnyComplexNotificationVisibleSelector:Jl,isAuthAndRegFromQueueVisible:ym,isAuthAndRegVisibleSelector:mm,isAutologinMegafonFromQueueVisible:vm,isDvrRestrictionFromQueueVisible:Em,isDvrRestrictionVisibleSelector:Tm,isDvrRestrictionWithButtonFromQueueVisible:xm,isDvrRestrictionWithButtonVisibleSelector:bm,isFirstInQueue:De,isPlayerErrorFromQueueVisible:Im,isPlayerErrorVisibleSelector:Am,isProviderContactInfoFromQueueVisible:Rm,isProviderInfoVisibleSelector:Lm,isRetryFromQueueVisible:_m,isRetryVisibleSelector:Cm,isReviewFromQueueVisible:wm,isReviewVisibleSelector:Zl,isSubscriptionPaymentErrorFromQueueVisible:km,isSubscriptionPaymentErrorVisibleSelector:Dm,isSubscriptionProlongationErrorFromQueueVisible:Om,isUnavailableContentFromQueueVisible:$m,isUnavailableContentVisible:Nm,notificationAutoLoginMegafonSelector:Sm,notificationsAutoRenew:Gm,notificationsDiagnosticsStatusSelector:Hm,notificationsErrorSelector:Km,notificationsFavoriteSelector:Wm,notificationsLoginSuccessSelector:qm,notificationsPauseRemovedSelector:Ym,notificationsProfileSelector:jm,notificationsQsSelector:zm,notificationsSelector:br,notificationsSimpleSelector:Vm,queueSelector:Es,subscriptionProlongationErrorSelector:Pm,unavailableContentImageSelector:Mm,unavailableContentSelector:ns,unavailableContentSourceIdSelector:Fm,unavailableContentTitleIdSelector:Um,unavailableContentTitleTextSelector:Bm},Symbol.toStringTag,{value:"Module"})),ec=(t,e)=>t.promoElements.items[e]||[],tc=t=>t.promoElements.isBannersDataLoaded,sc=t=>t.promoElements.isBannersDataLoading,Qm=(t,e,s)=>Object.values(t.promoElements.items).reduce((i,n)=>i||n.find(r=>{const o=r.internalReference?.vodContent,a=o?.source,l=o?.contentId,c=(r.renderingMethods||[]).find(u=>Object.values(lr).includes(u.method)),d=r?.mediaItems?.length;return a===e&&l===s&&c&&d})?.mediaItems?.[0]?.playbackMethods?.[0]?.params?.find(r=>r.key==="mediaId")?.value||"",""),Jm=Object.freeze(Object.defineProperty({__proto__:null,isBannersDataLoadedSelector:tc,isBannersDataLoadingSelector:sc,itemsSelector:ec,mediaIdSelector:Qm},Symbol.toStringTag,{value:"Module"})),Zm=t=>Object.values(t.reduce((e,s)=>{const i=(s.renderingMethods||[]).sort((n,r)=>(n.priority||0)-(r.priority||0))[0]?.method||"";return i&&(e[i]=i),e},{})),e0=t=>(t.homeScreenConfig?.config_list?.length?t.homeScreenConfig.config_list:ug.map((s,i)=>({key:s,sort:i,active:!0}))).reduce((s,i)=>{let n;["home-suggested-channels","home-recent-channels"].includes(i.key)&&(n={showCurrentTVProgram:!0});const r=i.key;
2if(Dl.includes(i.key)||i.key===ai.homeCarouselV2){const o=i.key;s.push({...i,renderingMethods:[o],placementId:r,blockSettings:n})}else{const o=ec(t,r);Zm(o).forEach(l=>{s.push({...i,renderingMethods:[l],blockSettings:{showCurrentTVProgram:!0},placementId:r})})}return s},[]),t0=Object.freeze(Object.defineProperty({__proto__:null,componentsListSelector:e0},Symbol.toStringTag,{value:"Module"})),Pi=t=>t.gaParams,s0=Object.freeze(Object.defineProperty({__proto__:null,gaParamsSelector:Pi},Symbol.toStringTag,{value:"Module"})),i0=t=>t.packages.items.sort((e,s)=>e.sorting-s.sorting),n0=Object.freeze(Object.defineProperty({__proto__:null,packagesSelector:i0},Symbol.toStringTag,{value:"Module"}));const ic=t=>{const e={session:""};try{const s=me.get(Te.feCookie);return s||e}catch{return e}},r0=({session:t},e)=>{const s={session:t};me.set(Te.feCookie,JSON.stringify(s))},nc=()=>me.remove(Te.feCookie),nk=t=>me.get(Te.promoCode),rk=t=>me.get(Te.profileConfirmed),ok=t=>me.get(Te.profileConfirmationPeriod),ak=t=>me.get(Te.welcomeScreenConfirmed),o0=t=>Df(t).isIos&&!qo(t).isSafari?"":qo(t).isSafari?gs.fairplay:gs.widevine,xr=t=>{switch(o0(t)){case gs.fairplay:return"fp";case gs.playready:return"prdsh";case gs.widevine:return"wvm"}return""},a0=t=>{const e=ss(),s={app:{version:"3.10.3",hash:"c8861909",buildDate:"1785230421000",id:"sequoia",buildType:"portal",whitelabel:Be().wlAppId,hostname:"",env:""},device:{type:Yo(e)==="iPadPro"?"tablet":Yo(e),brand:bl(e)||"none",model:"none",uuid:sf()}};t?.script&&(s.app.script=t?.script);const i=xr(e);return i&&(s.device.drm=i),s},Ar=t=>Lp(a0(t));class l0 extends Sl{get reqUrl(){if(!this.config)return"";let e=`${this.config.baseURL}${this.config.url}`;return ks(this.config.params)||(e+=`?${new URLSearchParams(this.config.params).toString()}`),e}get reqInfo(){if(!this.config)return"";let e=`${this.config.method?.toUpperCase()} ${this.reqUrl}`;return this.resMessage&&(e+=` - ${this.resMessage}`),e}get resStatus(){return this.response?.status}get resMessage(){const e=this?.code==="ECONNABORTED";let s="";return e?(s="Request timeout",this.config?.timeout&&(s+=` after ${this.config?.timeout}ms`)):this?.response?.status&&(s=`${this.response?.status} -> ${this.message}`),s}}const c0=t=>{if(t.response?.status!==ge.NOT_MODIFIED){let e=t.response?.data?.message||t.response?.data?.msg||t.message;const s=t.config;let i,n;if(s){i={timeout:s.timeout,headers:s.headers,withCredentials:s.withCredentials,url:s.url,method:s.method,params:s.params,data:s.data,baseURL:s.baseURL};let r="";s.method&&(r+=`${s.method.toUpperCase()} `),r+=`${s.baseURL}${s.url}`}throw t.response&&(n={status:t.response.status,data:t.response.data,statusText:t.response.statusText,headers:t.response.headers}),new l0(e,t.code,i,void 0,n)}};var d0={};const fs=H("api"),Oi=(t,e={})=>({get:$t(t,"get",e),head:$t(t,"head",e),delete:$t(t,"delete",e),post:$t(t,"post",e),put:$t(t,"put",e),patch:$t(t,"patch",e),sendBeacon:u0(e)}),rc=(t,e,s,i)=>{s.formUrlEncoded&&!i.jsonData&&(i.data=new URLSearchParams(i.data).toString()),i.headers=i.headers||{},i.headers["Accept-Language"]=i.languageCode,i.jsonData&&(i.headers["content-type"]="application/json");const n={url:t,method:e,params:{},data:{},...s,...i};if(s.isFe?n.baseURL=Be().feBaseUrl:s.isBe&&(n.baseURL=Be().beBaseUrl),!n.bowProxyDisabled&&n.params.token)n.url=x.bow.proxy+t;else if(n.withSession){const o=ic(i.ctx);n.params.session=o?.session||void 0}n.withAppVersion&&(n.params={...n.params,...Ar(i.ctx)});const r=Be().mocks;if(r?.length){const o=Xt.getUri(n),a=r.find(l=>e===l.method&&o.startsWith(l.endpointUrl));if(a){n.baseURL=void 0,n.url=a.mockUrl;const l=Xt.getUri(n);fs.info(`Mock ${o} -> `,l)}}return n},$t=(t,e,s)=>async(i,n)=>{const r=rc(i,e,s,n),o=r.onResponse?r.onResponse:()=>{},a=r.onError?r.onError:()=>{},{session:l,...c}=r.params;try{const d=await t(r),u=T0(d,r);return ks(c)?fs.debug(u):fs.debug(u,c),fs.trace(Fn().split(` 3`)[3]),o(d,r),d.data}catch(d){return d.code==="ERR_CANCELED"?(fs.notice("Request was canceled:",i),null):(d instanceof Sl&&(a(d,r),c0(d)),null)}},u0=t=>(e,s)=>{const i=rc(e,"post",t,s),n=new URLSearchParams(Object.entries(i.params)),r=new
3URL(`${e}?${n}`,i.baseURL),o={type:"application/x-www-form-urlencoded"},a=new Blob([i.data],o);navigator.sendBeacon(r,a)},Os=t=>Xt.create(t),Mi=1e4,h0=7e3,f0=2e4,g0=typeof window>"u"?`http://127.0.0.1:${d0.PORT}`:window.location.origin;Os({baseURL:g0,timeout:Mi,withCredentials:!0});const p0=Os({timeout:typeof window>"u"?h0:f0,withCredentials:!0}),b=Oi(p0,{isFe:!0,formUrlEncoded:!0,withSession:!0,withAppVersion:!0}),m0=Os({timeout:Mi,withCredentials:!0}),W=Oi(m0,{isBe:!0}),y0=Os({baseURL:x.vod.ivi.lightServer,timeout:Mi,withCredentials:!1}),Zo=Oi(y0),S0=Os({baseURL:x.oldSmotreshkaPremiumPage,timeout:Mi,withCredentials:!1}),v0=Oi(S0,{formUrlEncoded:!0}),T0=(t,e)=>`${(t?.config?.method||e.method||"").toUpperCase()} ${Xt.getUri(e)} - ${t?.status||0}`,E0=t=>b.get(x.appInfo,t),lk=async t=>await b.get(x.speedTests,t)||{speedTests:[]},b0=async(t="",e)=>b.get(x.appSections(t),e),x0=async t=>b.post(x.login,t),A0=async t=>b.post(x.qrLogin,t),I0=async t=>b.get(x.logout,t),oc=async t=>b.get(x.account,t),ck=async t=>b.post(x.registration.byPhone,t),dk=async t=>t?.params?.captchaid?b.post(x.restorePassword,t):(t.withAppVersion=!0,W.post(x.restorePassword,t)),uk=async({id:t,accountId:e},s)=>b.put(x.restorePasswordByLink(t,e),s),di={async getMethods(t){return(await b.get(x.contactsVerification.methods,t))?.methods||[]},startWithAccountSession:t=>b.post(x.contactsVerification.startWithAccountSession,t),start:t=>t?.params?.captchaid?b.post(x.contactsVerification.start,t):(t.withAppVersion=!0,W.post(x.contactsVerification.start,t)),startRecaptcha:t=>b.post(x.contactsVerification.startRecaptcha,t),verify:t=>b.post(x.contactsVerification.verify,t),verifyV2:t=>b.post(x.contactsVerification.verifyV2,t),retry:t=>b.post(x.contactsVerification.retry,t),setPhone:t=>b.post(x.contactsVerification.setPhone,t),unlinkPhone:t=>b.post(x.contactsVerification.unlinkPhone,t)},L0=t=>b.get(x.availableLogins,t),R0=t=>b.post(x.loginWithVerifiedContacts,t),C0=t=>b.post(x.sendPassword,t),_0=t=>b.post(x.register,t),w0=t=>b.post(x.registerMobile,t),hk=t=>b.post(x.phoneInfoV1,t),fk=t=>b.get(x.phoneInfoV2,t),gk=t=>b.get(x.promoCodeCheck,t),pk=t=>b.post(x.registerWithPromoCode,t),D0=t=>b.post(x.uztel.auth,t),mk=async t=>(await b.post(x.registerWithPromoCodeMobile,t))?.message||"",yk=t=>b.post(x.registerSimPassword,t),Sk=t=>b.post(x.contactsVerificationSimPassword,t),k0=t=>b.post(x.megafon.auth_18p,t),P0=t=>b.post(x.megafon.auth,t),vk=t=>b.get(x.evictedSession,t),Tk=t=>b.get(x.loginMethods,t),Ek=t=>b.post(x.autologin,t),bk=async t=>b.get(x.bow.tokenData,t),xk=async(t,e)=>b.get(x.bow.qsStateForTransaction(t),e),mt=H("actions-tv-channels"),O0=async(t,e)=>b.post(`${x.favorites}/${t}`,e),M0=async(t,e)=>b.delete(`${x.favorites}/${t}`,e),Ak=async(t,e)=>b.get(x.dvrAvailability(t),e),N0=t=>t.map(e=>{const s=!!e?.keyNumber,i=e?.info?.metaInfo?.title||e?.title||"",n=3,r=s?{...e}:{...e,title:i,name:s?i:i.slice(n+1),strNumber:e?.keyNumber||i.slice(0,n)};if(e.info){const{socialInfo:o,updateInfo:a,...l}=e.info;r.info=l}return r}).sort((e,s)=>parseInt(ze(e))-parseInt(ze(s))).reduce((e,s)=>(e[s.id]=s,e),{}),ac=async t=>{const{tvAssetToken:e,...s}=t||{};if(!e)return;mt.debug("Loading TV API 2.0...");const i=await Promise.all([b.get(x.channelsV2(e),s),b.get(x.medias(e),s)]),[n,{medias:r}]=i;if(!n){mt.warn("TV API 2.0: Could not load channels");return}const{genres:o,channels:a}=n,l={};return r.forEach(c=>{const d=a.find(u=>u.id===c.channelId);d&&(l[d.id]=l[d.id]||d,l[d.id].medias=l[d.id].medias||[],l[d.id].medias.push(c))}),mt.info("TV API 2.0 was loaded!"),{channels:N0(Object.values(l)),genres:o}},lc=async t=>{let e=[],s=[];try{const i=await b.get(x.recentAndFavChannels,t);e=i?.favouriteChannels||[],s=i?.recentlyWatchedChannels||[]}catch(i){mt.error("getRecentAndFavChannels",i)}return{favouriteChannels:e.reverse().reduce((i,n)=>(i[n.id]=n,i),{})||{},recentlyWatchedChannels:s.reduce((i,n)=>(i[n.id]=n,i),{})||{}}},F0=async t=>{try{const e=await b.get(x.recommendedChannels,t);return e?.channelRecommendations?Jt(e.channelRecommendations.map(i=>({id:i.channelId,priority:i.priority})),"priority").reduce((i,n)=>(i[n.id]=n,i),{}):{}}catch(e){return mt.error("Recommended channels were not loaded",e),{}}},U0=async t=>{const e=Date.now();let s;try{t.params=t.params||{},t.params.timeout=5e3,s=await b.get(`${x.channelsNotForPurchase}`,t)}catch(n){mt.error(n),s={channelsNotForPurchase:[]}}const i=s?.channelsNotForPurchase||[];return mt.info(`tvData [channelsNotForPurchase]: ${Date.now()-e}ms`),i.reduce((n,r)=>(n[r]=r,n),{})},B0=async(t,e,s)=>{let i={},n=[];try{const r=await ac({tvAssetToken:s,languageCode:t,ctx:e});i=r?.channels||{},n=r?.genres||[]}catch(r){mt.error(r)}return{genresResponse:n,channelsResponse:i}},$0=async t=>b.get(x.externalPlayer.tvSettings,t),we=H("api-cms"),V0=async()=>{const t={languageCode:"ru",ctx:void 0};return(await W.get("/component",t))?.components||null},G0=async()=>{const t={languageCode:"ru",ctx:void 0};return(await W.get("/cleanContentBlock",t))?.contentBlocks||null},H0=(t,e)=>`${Be().beBaseUrl}${t}/${e}`,K0=(t,e)=>Object.entries(t).reduce((s,[i,n])=>(s[i]={...n,url:H0(e,n.name)},s),{}),ea=(t,e)=>Object.entries(t).reduce((s,[i,n])=>(s[i]=K0(n,e),s),{}),W0=async()=>{const t={languageCode:"ru",ctx:void 0};try{const e=await W.get("/file-records",t);return e?.fileRecords&&e?.filesPath?ea(e.fileRecords,e.filesPath):(we.error("invalid response from /file-records",e),{})}catch(e){if(e.response?.status===ge.NOT_FOUND)try{const s=await W.get("/cleanFileRecord",t);return s?ea(s.files,"/upload"):{}}catch(s){return we.error(`/cleanFileRecord was not loaded: ${s}`),{}}else we.error(`/file-records were not loaded: ${e}`);return{}}},q0=async()=>{try{const t={languageCode:"ru",ctx:void 0}
3,e=await W.get("/page",t);return{pages:e?.pages||[],pageFolders:e?.pageFolders||[]}}catch{return{pages:[],pageFolders:[]}}},Y0=(t,e)=>t.reduce((s,i)=>(s[i._id]=`${Be().beBaseUrl}${e}/${i.folderName}`,s),{}),j0=t=>t.reduce((e,s)=>(e[s._id]=`${Be().beBaseUrl}/${s.folderUrl}`,e),{}),z0=async()=>{const t={languageCode:"ru",ctx:void 0};try{const e=await W.get("/archives",t);return e?.archives&&e?.archivesPath?Y0(e.archives,e.archivesPath):(we.error("invalid response from /archives",e),{})}catch(e){if(e.response?.status===ge.NOT_FOUND)try{const s=await W.get("/archive",t);return s?j0(s.archives):{}}catch(s){return we.error(`legacy-archives were not loaded: ${s}`),{}}else we.error(`archives were not loaded: ${e}`);return{}}},X0=async()=>{const t={languageCode:"ru",ctx:void 0};try{const e=await W.get("/translations",t);return e?.translations?e?.translations||{}:(we.error("invalid response from /translations",e),{})}catch(e){if(e.response?.status===ge.NOT_FOUND||e.response?.status===ge.NOT_ALLOWED)try{return(await W.get("/cleanTranslation",t))?.translations||{}}catch(s){return we.error(`legacy-translations were not loaded: ${s}`),{}}else we.error(`translations were not loaded: ${e}`);return{}}},Q0=async()=>{const t={languageCode:"ru",ctx:void 0};return(await W.get("/authAndReg",t))?.authAndReg||null},J0=async()=>{const t={languageCode:"ru",ctx:void 0};return(await W.get("/siteConfig",t))?.siteConfig||null},Z0=async()=>{const t={languageCode:"ru",ctx:void 0};return(await W.get("/branding2",t))?.branding2||null},ey=async()=>{const t={languageCode:"ru",ctx:void 0};return(await W.get("/header",t))?.header},ty=async()=>{const t={languageCode:"ru",ctx:void 0};return(await W.get("/footer",t))?.footer},sy=async()=>{let t=[];try{t=(await W.get("/languages",{languageCode:"ru",ctx:void 0}))?.languages||[]}catch(e){if(e.response?.status===ge.NOT_FOUND)try{const s=await W.get("/language",{languageCode:"ru",ctx:void 0}),i=s?.defaultLanguage||"ru";t=s?.languages?s.languages.filter(n=>n.isOnSite).map(n=>({code:n.locale,name:n.shortName,navigatorLanguages:n.forWhichLocales,isDefault:n.locale===i})):[]}catch(s){we.error(`/language was not loaded: ${s}`)}else we.error(`/languages were not loaded: ${e}`)}return t},iy=async()=>{const t={languageCode:"ru",ctx:void 0};return(await W.get("/vod",t))?.vod},ny=async()=>{const t={languageCode:"ru",ctx:void 0};return(await W.get("/quickSubscribe",t))?.quickSubscribe},ry=async()=>{try{const t={languageCode:"ru",ctx:void 0},{brandingMethods:e}=await W.get(x.brandingMethods,t);return e||[]}catch{return[]}},oy=async()=>{const t={languageCode:"ru",ctx:void 0};return(await W.get("/personal-area",t))?.personalArea},ay=async()=>{const t={languageCode:"ru",ctx:void 0};return(await W.get("/reviews",t))?.reviews},Ik=async(t="")=>await W.get(x.premiumPageProviderBySlug(t),{languageCode:"",ctx:void 0})||{provider:null},ly=async()=>{const t={languageCode:"ru",ctx:void 0};return(await W.get("/packages",t))?.packages||null},cy=async()=>{const t={languageCode:"ru",ctx:void 0};return((await W.get(x.seoRules,t))?.rules||void 0)?.reduce((s,i)=>(s[i.url]=i,s),{})},dy=async()=>{try{const t={languageCode:"ru",ctx:void 0};return(await W.get(x.redirects,t))?.redirects||null}catch{return null}},uy=async()=>{try{const t={languageCode:"ru",ctx:void 0},e=await W.get(x.homeScreenConfig,t)||null;return e?.config_list&&(e.config_list=e.config_list.sort((s,i)=>s.sort-i.sort)),e}catch{return null}},hy=async()=>{const t={languageCode:"ru",ctx:void 0};let e=await W.get("/theme.css",t)||"";const s=await Promise.all([W.get("/branding.css",t),W.get("/vod.css",t)]);return e+=s.filter(i=>!!i).join(""),e},fy=async()=>{const t={languageCode:"ru",ctx:void 0};try{return await W.get(x.headCustomCode,t)}catch(e){return we.error(e),""}},gy=async t=>{const e={languageCode:"ru",ctx:void 0,params:{"utm-source":t}};try{return(await W.get(x.marketingExternalCodes,e))?.items?.[0]||null}catch(s){return we.error(s),null}},py=t=>b.get(x.epg.onAir,t),Lk=async(t,e)=>{try{const s=await b.get(x.epg.schedules.index(t),e);return{pages:s?.pages||[],regularUpdate:s?.regularUpdate||void 0}}catch{return{pages:[],regularUpdate:void 0}}},Rk=(t,e)=>b.get(x.epg.schedules.spread(t),e),lt=8,sn=(t,e)=>{if(t.length!==e.length)throw new Error(`strxor: string lengths are not equal. a: ${t}. b: ${e}`);return t.split("").map((s,i)=>String.fromCharCode(t.charCodeAt(i)^e.charCodeAt(i))).join("")},Gs=t=>{if(t.length%2!==0)throw new Error("hex string length is not odd");let e="";for(let s=0;s<t.length-1;s+=2){const i=parseInt(t[s]+t[s+1],16);e+=String.fromCharCode(i)}return e},ta=(t,e)=>{let s="";for(let i=0;i<e;i++)s+=t;return s};class my{cipher;k1;k2;constructor(e){this.cipher=new Jh(Gs(e[0])),this.k1=Gs(e[1]),this.k2=Gs(e[2])}calculateSign(e){let s=ta("\0",lt);const i=e.length,n=i%lt===0?i-lt:i-i%lt;for(let a=0;a<n;a+=lt)s=Gs(this.cipher.encrypt(sn(e.slice(a,a+lt),s)));let r=e.slice(n),o;return r.length===lt?o=this.k1:(o=this.k2,r+="Â"+ta("\0",lt-r.length-1)),this.cipher.encrypt(sn(sn(r,s),o)).toLowerCase()}}const yy=()=>{const t=jf.vod.ivi.uid,e=Qo.get(t);if(e)return e;const s=Math.random().toString(10).slice(2);return Qo.set(t,s),s},nn={},Sy=t=>{const e=[t.cmakKey||"",t.cmakK1||"",t.cmakK2||""],s=e.join("_");return nn[s]||(nn[s]=new my(e)),nn[s]},vy=async(t,e,s)=>{const n=(await Zo.post("/",{languageCode:s.languageCode,ctx:s.ctx,data:'{"method":"da.timestamp.get","params":[]}'})).result,r=JSON.stringify(e),a=Sy(t).calculateSign(n+r),l=await Zo.post(`/?app_version=${t.appVersion}&ts=${n}&sign=${a}`,{languageCode:"",ctx:void 0,data:r});if(l.error)throw l.error;return l},Ck=async(t,e)=>{const s={params:[parseInt(t.id||"",10),{uid:yy(),session:t.iviSession||"",app_version:parseInt(t.appVersion||"",10)}],method:"da.content.get"},{result:i}=await vy(t,s,e);return i},Ty=(t,e)=>
3b.get(x.offers.offer(t),e),cc=(t,e)=>b.get(x.offers.offerAllChannels(t),e),dc=(t,e)=>b.get(x.offers.offerShowcaseChannels(t),e),ui=H("pauses-api"),uc=(t,e)=>t.createdAt&&e.createdAt?e.createdAt-t.createdAt:0,hc=t=>{const e=kt(t.totalDurationMsec,"millisecond"),s=Math.ceil(kt(t.msecFromStart,"millisecond"));return{...t,currentProgress:parseFloat((t.msecFromStart/t.totalDurationMsec).toFixed(4)),fromStart:s,duration:e.toString(),timeLeft:s.toString()}},Ey=async t=>{let e=[];const s=x.pauses.vod.titles;try{e=(await b.get(s,t))?.pauses||[]}catch(i){ui.error(`Unable to load ${s}`,i)}return e.map(hc)},by=async(t,e,s)=>{let i=[];const n=x.pauses.vod.title(t,e);try{i=(await b.get(n,s))?.pauses||[],i.length&&i.sort(uc)}catch(r){ui.error(`Unable to load ${n}`,r)}return i.map(hc)},_k=async(t,e,s,i,n,r,o="",a="",l=0)=>{if(n){if(!e||!i||!r||r<=1e3){ui.warn("Could not save pause",{sourceId:e,titleId:s,mediaItemId:i,msecFromStart:n,totalDurationMsec:r});return}try{await b.post(x.pauses.vod.titles,{data:{sourceId:e,titleId:s,mediaItemId:i,msecFromStart:n,totalDurationMsec:r,episodeId:o,seasonId:a,expiresAt:l},...t})}catch(c){ui.error(c)}}},xy=async(t,e,s)=>b.post(x.pauses.vod.delete(t,e),s),wk=async(t,e)=>{const s=await b.get(`${x.pauses.tv}/${t}`,e);return s?.programPauses?.length&&s.programPauses.sort(uc),s?.programPauses||[]},Dk=async t=>b.put(x.pauses.tv,t),kk=async t=>{const e={};return t.region&&(e.region=t.region),e.enable50fps=t.enable50fps===!0,await b.get(x.playbackInfo(t.channelId),{ctx:t.ctx,languageCode:t.languageCode,params:e})},Pk=async t=>{const e={};return t.region&&(e.region=t.region),e.enable50fps=t.enable50fps===!0,await b.get(x.playbackInfoMedia(t.mediaId),{ctx:t.ctx,languageCode:t.languageCode,params:e})},Ay=async(t,e)=>(await b.get(x.popupNotices.elements(t),e))?.elements,Iy=async t=>await b.post(x.popupNotices.whatToShow,{...t,jsonData:!0}),Ly=async t=>await b.post(x.popupNotices.reportAction,t),Ry=t=>{t.data.actionType="exit",b.sendBeacon(x.popupNotices.reportAction,t)},Cy=t=>b.post(le().isSmotreshka?x.changeProfileV2:x.changeProfile,t),Ok=t=>b.post(x.createProfile,t),_y=(t,e)=>b.put(x.updateProfile(t),e),Mk=(t,e)=>b.delete(x.deleteProfile(t),e),Nk=(t,e)=>b.get(x.getProfile(t),e),Fk=t=>b.post(x.managingLogin,t),Uk=t=>b.post(x.managingLogout,t),Bk=t=>b.post(x.managingLoginWithVerifiedContacts,t),wy=async t=>(await b.get(x.profileRestrictions,t))?.restrictions||[],$k=t=>b.post(x.changePassword,t),Vk=(t,e)=>b.post(x.yakassa.activateSubscription(t),e),Gk=(t,e)=>b.post(x.yakassa.cancelSubscription(t),e),Hk=async t=>{const e=await b.get(x.managingLoginMethods,t);return Jt(e?.methods,"priority")||[]},Kk=(t,e)=>b.post(x.quickSubscribe.enableAutoRenew(t),e),Wk=(t,e)=>b.post(x.quickSubscribe.disableAutoRenew(t),e),qk=(t,e)=>b.post(x.quickSubscribe.autoRenew(t),e),Dy=async(t="",e)=>(await b.get(x.promoElements(t),e))?.elements||[],ky=H("quick-subscribe-api"),Py=t=>b.get(x.quickSubscribe.vodSubscriptionOptions,t),Oy=(t,e)=>b.get(x.quickSubscribe.tvSubscriptionOptions(t),e),My=(t,e)=>b.get(x.quickSubscribe.tvSubscriptionOptionsV3(t),e),Ny=t=>b.get(x.quickSubscribe.vodSubscriptionOptionsV3,t),Fy=(t,e)=>b.get(x.quickSubscribe.offersSet(t),e),Uy=t=>b.get(x.yakassa.paymentMethod,t),fc=t=>b.get(x.yakassa.subscriptions,t),By=t=>b.get(x.quickSubscribe.currentSubscriptions,t),$y=(t,e)=>b.get(x.yakassa.subscription(t),e),Yk=(t,e)=>b.post(x.yakassa.renewSubscriptionWithExistedPm(t),e),jk=(t,e)=>b.post(x.yakassa.renewSubscriptionWithNewPm(t),e),Vy=t=>b.post(x.yakassa.removePaymentMethod,t),Gy=t=>b.post(x.yakassa.subscriptions,t),Hy=t=>b.post(x.yakassa.createSubscription,t),Ky=t=>b.post(x.quickSubscribe.createSubscription,t),Wy=t=>b.post(x.quickSubscribe.createSubscriptionWithVerifiedPhone,t),qy=t=>b.post(x.quickSubscribe.createSubscriptionUpsale,t),Yy=t=>b.post(x.quickSubscribe.createSubscriptionUpsaleV2,t),zk=t=>b.get(x.yakassa.archivedSubscriptions,t),jy=(t,e)=>b.get(x.yakassa.lastPaymentFromKassa(t),e),Ms=t=>b.get(x.quickSubscribe.allAvailableSubscriptionOptions,t),zy=(t="",e)=>b.get(x.quickSubscribe.subscriptionShop(t),e),Xy=async(t,e,s=!1,i=1)=>{const r=s?120:5,o=await jy(t,e).catch(l=>{ky.error(l)});if(!o)return{status:""};const a=o.status;return new Promise(l=>{a!==rt.PENDING||i>=r?l(o):setTimeout(async()=>
3{l(await Xy(t,e,s,i+1))},5e3)})},Xk=async(t,e,s,i="")=>{const n=await $y(s,{params:{token:i},ctx:t,languageCode:e}),r=[rt.CANCELED,rt.SUCCEEDED,rt.WAITING_FOR_CAPTURE];return n?.subscription_renew_status==="active"&&r.includes(n.last_payment.status)},Qy=(t,e,s)=>{e.ChannelId&&b.sendBeacon(x.statistics,{ctx:t,languageCode:"ru",params:{externalPlayerPlatform:s},data:e})},Qk=async(t,e)=>{const{data:i}=await Xt.get(t,{params:{timestamp:e,before:200,after:200}});return(i?.images||[]).map(r=>{const o=parseFloat(i.base);return{...r,url:`${i.prefix}${r.u}${i.suffix}`,from:o+r.b,to:o+r.e}})},Jy=H("api-tokens"),Zy=async t=>(t.params={"device.drm":xr(ss(t.ctx))},await b.get(x.assetTokensV2,t)),eS=async(t,e)=>(e.data={contextToken:t},e.params={"device.drm":xr(ss(e.ctx))},b.post(x.assetTokensV2,e)),tS=async t=>{let e;try{e=await b.get(x.assetTokens,t)}catch(o){e=null,Jy.error(o)}if(!e)return null;const s=Le(),i=Le(e?.expiresAt),n=i.diff(s)*.1,r=new Date(i.valueOf()-n);return e.expiresAt=r.toString(),e},dt=H("api-vod"),ue=x.vod,gc=async t=>b.get(ue.sources,t),sS=async(t,e)=>b.get(ue.categories(t),e),iS=async t=>b.get(ue.favorites,t),nS=async(t,e,s)=>b.post(`${ue.favorites}?sourceId=${e}&titleId=${t}`,s),rS=async(t,e,s)=>b.delete(`${ue.favorites}?sourceId=${e}&titleId=${t}`,s),oS=async({sourceId:t,categoryId:e,genreIds:s,limit:i=vs,offset:n=0,sort:r="asc",languageCode:o="",ctx:a=void 0})=>{const l={categoryId:e,genreIds:s,limit:i,offset:n,sort:r};l.categoryId=l.categoryId===qe?l.categoryId="":l.categoryId;let c=[],d=c.length;for(;c.length<i;){const u=await lS(t,{params:l,languageCode:o,ctx:a});if(c=c.concat(u?.titles||[]),c=Zh(c,h=>h.id),l.offset+=c.length,c.length===d||c.length<vs)break;d=c.length}return c.slice(0,i)},aS=async(t,e,s,i)=>b.get(ue.similarities(t,e,s),i),lS=async(t,e)=>b.get(ue.titles(t),e),cS=async(t,e)=>b.get(ue.titlesMeta(t),e),dS=async(t,e)=>b.get(ue.searchTitles(t),e),Jk=async(t,e)=>b.get(x.externalPlayer.vod.hboMax(t),e),pc=async(t,e,s)=>{const i=await b.get(ue.title(t,e),s);if(i){i.preview?.ageRating&&(i.preview.ageRating=i.preview.ageRating.replace(/\D/g,"")+"+");let n=!1;return i.preview?.brandingMethods?.find(r=>r.name===Ag)&&(n=!0),{preview:i.preview,details:{actors:i.details?.actors||[],backgrounds:i.details?.backgrounds||[],brandingMethods:i.details?.brandingMethods||[],description:i.details?.description||"",directors:i.details?.directors||[],episodes:[],isHboMaxBrandingMethod:n,logoTitles:i.details?.logoTitles||[],mediaItems:i.details?.mediaItems||[],screenshots:i.details?.screenshots||[],seasons:i.details?.seasons?.sort((r,o)=>r.number-o.number)||[]},pauses:[],loading:!1,loaded:!0}}else return},uS=async(t,e,s)=>{const i=await b.get(ue.allEpisodes(t,e),s);return Array.isArray(i?.episodes)?i?.episodes:[]},hS=async(t,e,s,i)=>b.get(ue.season(t,e,s),i),fS=async(t,e,s,i)=>b.get(ue.seasonEpisodes(t,e,s),i),gS=async(t,e,s,i=[],n="{without_season}")=>{let r=[],o=i;if(i.length){const c=i.filter(u=>u.id!=="0").map(u=>fS(t,e,u.id,s).catch(h=>dt.error(h)));(await Promise.all(c))?.forEach((u,h)=>{u?.episodes?.forEach(f=>{r.push({details:void 0,preview:{seasonId:o[h]?.id,...f}})})}),dt.info("Episodes for seasons have finished loading")}const a=await uS(t,e,s),l=await Promise.all(a);if(l.length&&(o.push({id:"0",number:0,title:n}),l.forEach(c=>{r?.push({details:void 0,preview:{seasonId:"0",...c}})}),dt.info("Episodes without season have finished loading")),t==="archive"){const c=r.map(u=>pc(t,u.preview?.id||"",s).catch(h=>{dt.error(h)})),d=await Promise.all(c);r=r.map(u=>({...u,details:d.find(h=>h?.preview?.id===u.preview?.id)?.details})),dt.info("Episodes' data for Archive have finished loading")}if(i.length){const c=i.filter(u=>u.id!=="0").map(u=>hS(t,e,u.id,s).catch(h=>dt.error(h))),d=await Promise.all(c);d?.length&&(o=o.map(u=>({...u,description:d.find(h=>h.id===u.id)?.description||""})),dt.info("Seasons' data was successfully updated"))}return{titleEpisodes:r,titleSeasons:o}},pS=async(t,e="")=>b.get(x.vod.collections(e),t),mS=async(t,e=!1,s="")=>b.get(e?x.home.vodCollectionsV3(s):x.home.vodCollectionsV2(s),t),yS=async(t,e=void 0,s,i,n=0,r=vs)=>{const o={limit:r,offset:n};return b.get(ue.collectionTitles(s,i),{params:o,languageCode:t,ctx:e})},SS=async(t,e="",s,i,n)=>{let r=[];try{r=(await aS(i,n,s,{languageCode:e,ctx:t}))?.similarTitlesCollections||[],r=r?.filter(o=>(o.titlesList?.length||0)>=5)||[],r.length=r.length>3?3:r.length,r=r.map(o=>({caption:o.caption,id:o.id,titlesList:o.titlesList?.filter((a,l)=>l<12)}))}catch(o){dt.error(o)}return r||[]},Zk=async(t,e)=>b.get(ue.playback(t),e),eP=async(t,e,s)=>b.post(ue.playbackUpdate(t,e),s),tP=async(t,e)=>b.get(ue.ivi.playback(t),e),sP=async(t,e)=>b.get(ue.amedia.playback(t),e),iP=async(t,e)=>b.get(ue.megogo.playback(t),e),nP=async(t,e)=>b.get(x.vod.playbackLsHls(e),t),vS=t=>b.post(x.unsubscriptionRetention.begin,t),TS=t=>b.post(x.unsubscriptionRetention.end,t),ES=t=>b.get(x.unsubscriptionRetention.subscriptionOptions,t),rP=async(t,e)=>b.post(x.searchHistory.start,{...t,data:e,jsonData:!0}),oP=async(t,e)=>b.post(x.searchHistory.finish,{...t,data:e,jsonData:!0}),aP=async(t,e)=>b.post(x.searchHistory.useTvChannel,{...t,data:e,jsonData:!0}),lP=async(t,e)=>b.post(x.searchHistory.useTvChannelV2,{...t,data:e,jsonData:!0}),cP=async(t,e)=>b.post(x.searchHistory.useVodTitle,{...t,data:e,jsonData:!0}),dP=async(t,e)=>b.post(x.searchHistory.useVodTitleV2,{...t,data:e,jsonData:!0}),uP=async t=>b.get(x.searchHistory.getHistory,t),hP=async(t,e)=>b.post(x.searchHistory.report,{...t,data:e,jsonData:!0}),fP=t=>b.get(x.regions,t),gP=t=>b.get(x.providers,t),pP=t=>b.get(x.contactsVerification.captchaData,{...t,jsonData:!0}),mP=async(t,e)=>{const s=new URLSearchParams(Ar(e.ctx)).toString(),i=await b.get(`${x.contactsVerification.captchaImage(t)}?${s}`,{...e,responseType:"blob",withCredentials:!0});return URL.createObjectURL(i)},yP=async(t,e,s,i)=>{const n=new URLSearchParams(Ar(i.ctx)).toString(),r=`t=${t}&${n}`,o=e?"reload=$true":"",a=s?`${Be().beBaseUrl}/contacts-verification/v1/captcha?${r}`:`${Be().beBaseUrl}/captcha?${o}&${r}`,l=await Xt.request({url:a,method:"get",responseType:"blob",withCredentials:!0});return{url:URL.createObjectURL(l.data),cookieHeaders:l.headers["cookie-custom"]?JSON.parse(l.headers["cookie-custom"]).reduce((c,d)=>`${c}${d.name}=${d.value};`,""):""}},SP=t=>b.post(x.clientAnalytics,t),vP=async t=>b.get(x.searchV2,t);var Ir=(t=>(t.ACTIVE="ACTIVE",t.CANCELED_BY_USER="CANCELED_BY_USER",t.CANCELED_BY_PAYMENT="CANCELED_BY_PAYMENT",t.CANCELED_BY_REMOVING_PAYMENT_METHOD="CANCELED_BY_REMOVING_PAYMENT_METHOD",t.IN_RETRY="IN_RETRY",t.UNRECOGNIZED="UNRECOGNIZED",t))(Ir||{}),bs=(t=>(t.Yakassa="Yakassa",t.Apple="Apple",t.Android="Android",t.Smartpay="Smartpay",t.Uztelecom="Uztelecom",t.Megafon="Megafon",t.UNRECOGNIZED="UNRECOGNIZED",t))(bs||{});const bS=(t,e)=>{t.adultOnboarding.currentStep=e},xS=(t,e)=>{t.adultOnboarding.nextStep=e},AS=t=>{t.adultOnboarding.stepsHistory.length=0,t.adultOnboarding.stepsHistory=[]},IS=(t,e)=>{t.adultOnboarding.stepsHistory.push(e)},LS=t=>{t.adultOnboarding.stepsHistory.pop()},RS=(t,e)=>{t.adultOnboarding.pinAction=e},CS=Object.freeze(Object.defineProperty({__proto__:null,addToStepsHistory:IS,removeFromStepsHistory:LS,resetStepsHistory:AS,setCurrentStep:bS,setNextStep:xS,setPinAction:RS},Symbol.toStringTag,{value:"Module"})),_S={ru:"ru_Ru"},Hs=(t,e)=>Je(fr(e,t.fileRecords.items),t.languageCode,t.defaultLanguageCode)?.url||"",TP=(t,e,s)=>ee.translations.translationSelector(t,t.seoRules?.[e]?.metaTitle)||s,wS=(t,e,s,i)=>{const n=[{name:"og:type",content:"website"},{name:"og:site_name",content:ee.translations.translationSelector(t,"smotreshka")},{name:"og:locale",content:_S[t.languageCode]},{name:"twitter:card",content:"summary_large_image"}];let r={};
3s&&(r=s.reduce((u,h)=>(h?.name&&(u[h.name]=h.content),u),{}));let o=ee.translations.translationSelector(t,t.siteConfig?.common.title);e?.metaTitle?o=ee.translations.translationSelector(t,e?.metaTitle):i&&(o=i),o&&n.push({property:"og:title",content:o});let a=ee.translations.translationSelector(t,t.siteConfig?.common.description);e?.metaDescription?a=ee.translations.translationSelector(t,e?.metaDescription):r?.description&&(a=r?.description),a.trim()&&(n.push({property:"og:description",content:a}),n.push({name:"description",content:a}));let l=ee.translations.translationSelector(t,t.siteConfig?.common.description);e?.metaKeywords?l=ee.translations.translationSelector(t,e?.metaKeywords):r?.keywords&&(l=r?.keywords),l.trim()&&(n.push({property:"og:keywords",content:l}),n.push({name:"keywords",content:l}));let c=Hs(t,t.siteConfig?.socialMeta.og);e?.imageOg?c=Hs(t,e?.imageOg):r?.image&&(c=r?.image),c&&(n.push({property:"og:image",content:c}),n.push({property:"twitter:image",content:c}));let d=Hs(t,t.siteConfig?.socialMeta.vk);return e?.imageVk?d=Hs(t,e?.imageVk):r?.image&&(d=r?.image),d&&n.push({property:"vk:image",content:d}),n},DS=t=>{t.seo=Il},Ni=(t,e="")=>{t.seo.title=e||Q(t,"default_meta_title")||"",typeof document<"u"&&(document.title=e)},mc=(t,e)=>{t.seo.meta=e},kS=(t,e)=>t.seo.breadcrumbs=e,PS=(t,e)=>t.seo.breadcrumbTelevisionChannel=e,OS=(t,e)=>t.seo.breadcrumbProduct=e,MS=(t,{title:e,meta:s})=>{e&&Ni(t,e),mc(t,s)},NS=(t,e)=>{const s=t.seoRules?.[e];vt.seo.setMeta(t,wS(t,s))},FS=Object.freeze(Object.defineProperty({__proto__:null,addBreadcrumbProduct:OS,addBreadcrumbTelevisionChannel:PS,addBreadcrumbs:kS,initMeta:MS,initMetaTags:NS,reset:DS,setMeta:mc,setMetaTitle:Ni},Symbol.toStringTag,{value:"Module"})),US=t=>t.siteConfig?.globalSearch?.usefulLinks||[],BS=t=>t.siteConfig?.globalSearch?.popularQueries||[],yc=t=>t.siteConfig?.popupNotices?.displayInCenter,$S=t=>t.siteConfig?.popupNotices?.interval,Lr=t=>t.siteConfig?.popupNotices?.enabled,VS=t=>{const e=t.siteConfig?.imageServer?.isCropSupported;return e||typeof e>"u"},Sc=t=>{const e=t.siteConfig?.myPage?.enabled;return e||typeof e>"u"},vc=t=>{const e=t.siteConfig?.vodCollections?.hasVodHomeCollectionsV3;return e||typeof e>"u"},GS=t=>t.siteConfig?.globalSearch?.placementBlocks,HS=t=>t.siteConfig?.subscriptionShop?.enabled,Nt=t=>t.siteConfig?.tokens?.hasTokensV2,KS=t=>t.siteConfig?.evictedSession?.enabled,WS=t=>t.siteConfig?.clientAnalytics?.enabled,qS=Object.freeze(Object.defineProperty({__proto__:null,globalSearchPopularQueriesSelector:BS,globalSearchUsefulLinksSelector:US,hasTokensV2Selector:Nt,hasVodHomeCollectionsV3Selector:vc,isClientAnalyticsEnabled:WS,isCropSupportedSelector:VS,isEvictedSessionEnabled:KS,myPageEnabledSelector:Sc,popupNoticesDisplayInCenterSelector:yc,popupNoticesEnabledSelector:Lr,popupNoticesIntervalSelector:$S,searchPlacementBlocksSelector:GS,subscriptionShopEnabledSelector:HS},Symbol.toStringTag,{value:"Module"})),Tc=t=>t.tokensV1.analyticsToken,Ec=t=>t.tokensV1.audienceToken,bc=t=>t.tokensV1.tvAssetToken,YS=t=>t.tokensV1.expiresAt,jS=Object.freeze(Object.defineProperty({__proto__:null,analyticsTokenV1Selector:Tc,audienceTokenV1Selector:Ec,expiresAtTokenV1Selector:YS,tvAssetTokenV1Selector:bc},Symbol.toStringTag,{value:"Module"})),zS=t=>Nt(t)?Ic(t):Tc(t),$e=t=>Nt(t)?xc(t):Ec(t),Pt=t=>Nt(t)?Ac(t):bc(t),xc=t=>t.tokensV2.assetTokens?.audienceToken||"",Ac=t=>t.tokensV2.assetTokens?.tvAssetToken||"",Ic=t=>t.tokensV2.assetTokens?.analyticsToken||"",XS=t=>t.tokensV2.assetTokens?.searchAssetToken||"",Lc=t=>t.tokensV2.contextToken,QS=t=>t.tokensV2.regularUpdate,Rc=t=>t.tokensV2.regularUpdate?.etag,Rr=t=>t.tokensV2.regularUpdate?.intervalSec,Cc=t=>t.tokensV2.loaded,_c=t=>t.tokensV2.loading,JS=t=>t.tokensV2.timeout,ZS=Object.freeze(Object.defineProperty({__proto__:null,analyticsTokenSelector:zS,analyticsTokenV2Selector:Ic,audienceTokenSelector:$e,audienceTokenV2Selector:xc,contextTokenSelector:Lc,etagSelector:Rc,intervalSecSelector:Rr,loadedSelector:Cc,loadingSelector:_c,regularUpdateSelector:QS,searchAssetTokenV2Selector:XS,timeoutSelector:JS,tvAssetTokenSelector:Pt,tvAssetTokenV2Selector:Ac},Symbol.toStringTag,{value:"Module"})),rn=H("tokens-v1-actions"),wc=async(t,e)=>{if(t.tokensV1.loaded)return rn.info("Asset Tokens v1 were already loaded"),null;if(t.tokensV1.loading)return rn.info("Asset Tokens v1 are already loading right now"),null;t.tokensV1.loading=!0;let s;try{s=await tS(e),t.tokensV1.loaded=!0}catch{s=null,t.tokensV1.loaded=!1}finally{t.tokensV1.loading=!1}
3s!==null&&(Object.entries(s).forEach(([i,n])=>{["analyticsToken","audienceToken","tvAssetToken"].includes(i)&&s?.expiresAt&&me.set(Te[i],n,{expires:new Date(s.expiresAt)})}),t.tokensV1.analyticsToken=s.analyticsToken,t.tokensV1.audienceToken=s.audienceToken,t.tokensV1.tvAssetToken=s.tvAssetToken,t.tokensV1.expiresAt=s.expiresAt,rn.info("Asset Tokens v1 were successfully loaded"))},ev=Object.freeze(Object.defineProperty({__proto__:null,loadAssetTokensV1:wc},Symbol.toStringTag,{value:"Module"})),Ot=t=>t.vod.sources,Dc=(t,e)=>Ot(t)[e],tv=t=>t.vod.sources?Object.values(t.vod.sources).filter(e=>e.id!=="archive").reduce((e,s)=>({...e,[s.id]:s}),{}):{},kc=t=>t.vod.sources?Object.values(t.vod.sources).filter(s=>s.isUsed).map(s=>s.id):[],Tt=t=>t.vod.sources?Object.values(t.vod.sources).map(e=>e.id):[],sv=(t,e)=>{const s=Ot(t);return Tt(t).reduce((n,r)=>{const o=s[r],a=o?.slug||o?.id||r;return n[a]=r,n},{})[e]||e},iv=(t,e)=>{const i=Ot(t)[e];return i.slug||i.id},xs=t=>t.vod.states.sourcesLoaded,hi=t=>t.vod.states.sourcesLoading,Fi=t=>t.vod.favorites||[],nv=t=>Fi(t).filter(e=>e.source&&e.titleId&&Tt(t).includes(e.source)),Pc=(t,e)=>!!Fi(t).find(s=>s.id===e||s.titleId===e),Oc=t=>t.vod.states.favoritesLoaded,Mc=t=>t.vod.states.favoritesLoading,Cr=(t,e)=>Dc(t,e)?.categories||{},rv=(t,e)=>{const s=Cr(t,e);return s?Object.values(s)?.sort((i,n)=>(i.priority||0)-(n.priority||0)):[]},Nc=(t,e)=>t.vod.sources?.[e]?.categoriesLoaded,Fc=(t,e)=>t.vod.sources?.[e]?.categoriesLoading,Uc=(t,e)=>t.vod?.sources?.[e]?.currentCategoryId||"",ov=(t,e)=>{const s=Uc(t,e);return s?t.vod?.sources?.[e]?.categories?.[s]:void 0},av=(t,e,s)=>{const i=e?.preview?.categories,n=Cr(t,s);return!i||!n?"":i[0]?.id?i[0].id:Object.values(n||{}).find(r=>r.title===i[0]?.title)?.id||""},Bc=t=>t.vod.states.isAnyHomeCollectionLoading,$c=t=>t.vod.states.isAnyHomeCollectionLoaded,lv=t=>t.vod.states.isSourceCollectionLoading,cv=t=>t.vod.states.isSourceCollectionLoaded,Vc=(t,e)=>t.vod.sourceCollections.find(s=>s.id===e),dv=(t,e)=>Vc(t,e)?.hasMoreTitlesToLoad,uv=t=>t.homeScreenConfig?.options?.showVodCollections!==void 0?t.homeScreenConfig?.options?.showVodCollections:!0,_r=t=>t.vod.homeCollections||[],Gc=t=>t.vod.sourceCollections||[],hv=(t,e)=>_r(t)?.filter(({placementBlocks:s})=>s?.find(({blockId:i})=>e?.includes(i))),fv=(t,e)=>Gc(t).find(s=>s.id===e)||_r(t).find(s=>s.id===e||s.vodCollectionId===e),wr=t=>t.siteConfig?.vodMegaCollections||[],Hc=t=>wr(t).filter(e=>e.slug&&Kc(t,e).length),gv=t=>Hc(t).filter(e=>e.showOnMain),Kc=(t,e)=>t.vod.homeCollections?.filter(({placementBlocks:s})=>s?.find(({blockId:i})=>e.placementBlocksString?.includes(i))),pv=(t,e)=>wr(t).find(s=>s.slug&&s.slug===e),Dr=t=>t.vod.sorting,mv=t=>t.vod.sortings,yv=t=>t.siteConfig?.archiveCatalog?.posterProportions?.width||16,Sv=t=>t.siteConfig?.archiveCatalog?.posterProportions?.height||9,Wc=(t,e)=>e==="archive"?t.siteConfig?.archiveCatalog?.posterProportions?.width||16:t.vod.sources[e]?.posterProportions?.width||2,qc=(t,e)=>e==="archive"?t.siteConfig?.archiveCatalog?.posterProportions?.height||9:t.vod.sources[e]?.posterProportions?.height||3,kr=(t,e,s)=>{const n=(s||t.theme)==="light"?t.vod.sources[e]?.logoTilePoster:t.vod.sources[e]?.logoTilePosterDark;return Di(t,n)},vv=(t,e,s)=>{const i=e.availableOnTvChannels,n=i&&i.length?i[0].channelId:"",r=ki(t,n);return r?wi(r):s.logo},Ui=(t,e,s)=>t.vod.sources[e]?.titlesEnhanced?.[s],Yc=(t,e,s)=>Ui(t,e,s)?.loaded,jc=(t,e,s)=>Ui(t,e,s)?.loading,Tv=(t,e,s)=>Ui(t,e,s)?.details?.seasons||[],zc=(t,e,s=-1)=>{if(!e?.preview?.title)return"";let i="";switch(s){case-1:break;case 0:i=` (${Je(t.translations.without_season,ae(t),t.defaultLanguageCode)?.toLowerCase()})`;break;default:i=` (${Je(t.translations.season,ae(t),t.defaultLanguageCode)?.toLowerCase()} ${s})`;break}return`${e?.preview?.title}${i}`},Ev=(t,e,s,i)=>{const n=i&&i>0,r=t.vod?.sources?.[e],o=r?.titlesEnhanced[s],a=o?.preview,l=a?.categories?.[0],c=!n&&l?.title?Q(t,`category_${fp(l.title)}_singular`):"",h=`${e==="archive"?"archive":"vod"}_meta_title${n?"_with_season":""}`,f=n?`${Je(t.translations.series,ae(t),t.defaultLanguageCode)} ${zc(t,o,i)}`:a?.title||"";if(!f)return Q(t,"title_unavailable");const g=n?"":a?.years?.[0],m=r?.customTitleId?Q(t,r.customTitleId):"";return Q(t,h).replace(/%titleName%/g,f).replace(/%titleType%/g,c).replace(/%year%/g,g?`${g}`:"").replace(/%vodName%/g,m)},bv=Object.freeze(Object.defineProperty({__proto__:null,archivePosterHeightProportionSelector:Sv,archivePosterWidthProportionSelector:yv,categoryIdFromTitleSelector:av,collectionSelector:fv,collectionsFromMegaCollectionSelector:Kc,currentCategoryIdSelector:Uc,currentCategorySelector:ov,currentMegaCollectionSelector:pv,favoritesFilteredSelector:nv,favoritesLoadedSelector:Oc,favoritesLoadingSelector:Mc,favoritesSelector:Fi,hasMoreTitlesToLoadSelector:dv,homeCollectionsFilteredByPlacementBlocksSelector:hv,homeCollectionsSelector:_r,isAnyHomeCollectionLoadedSelector:$c,isAnyHomeCollectionLoadingSelector:Bc,isAnyVodHomeCollectionVisibleSelector:uv,isInFavoritesSelector:Pc,isSourceCollectionLoadedSelector:cv,isSourceCollectionLoadingSelector:lv,listOfAllSourceIdsSelector:Tt,listOfSourceIdsWithoutArchiveSelector:kc,megaCollectionsAvailableSelector:Hc,megaCollectionsInSlidersSelector:gv,megaCollectionsSelector:wr,metaTitleSelector:Ev,posterHeightProportionSelector:qc,posterWidthProportionSelector:Wc,slugBySourceIdSelector:iv,sortingSelector:Dr,sortingsSelector:mv,sourceCategoriesLoadedSelector:Nc,sourceCategoriesLoadingSelector:Fc,sourceCategoriesSelector:Cr,sourceCategoriesSortedSelector:rv,sourceCollectionSelector:Vc,sourceCollectionsSelector:Gc,sourceIdBySlugSelector:sv,sourceLogoUrlSelector:kr,sourceSelector:Dc,sourcesLoadedSelector:xs,sourcesLoadingSelector:hi,sourcesSelector:Ot,sourcesWithoutArchiveSelector:tv,titleEnhancedLoadedSelector:Yc,titleEnhancedLoadingSelector:jc,titleEnhancedSelector:Ui,titleH1Selector:zc,titleLogoSelector:vv,titleSeasonsSelector:Tv},Symbol.toStringTag,{value:"Module"})),xv=t=>t!==null&&t.tagName==="IFRAME",Xc=H("metrics"),sa={},Av={acquiring_type:null,action:null,banner_id:null,button_text:null,category:null,category_filtering:null,channel_name:null,collection_name:null,content_category:null,control_type:null,error_text:null,fullscreen:null,genre_filtering:null,link_text:null,offer_category:null,offer_category_id:null,offer_id:null,offer_location:null,offer_title:null,offers_count:null,page_path:null,player_type:null,profile:null,provider_id:null,query:null,
3season_num:null,sorting:null,strip_name:null,title_id:null,trial_available:null,user_id:null,vod_name:null},yt=(t,e)=>{if(typeof window>"u"||!t?.action)return;const s=location.pathname;if(Nn(e)&&(t.user_id=Nn(e)),Mn(e)&&(t.provider_id=Mn(e)),window.location.hostname==="localhost")return Xc.info("log instead of sending to GA",{...t,event:"event-to-ga",page_path:s});const i={acquiring_type:null,action:null,banner_id:null,button_text:null,category:null,category_filtering:null,channel_name:null,collection_name:null,content_category:null,control_type:null,error_text:null,fullscreen:null,genre_filtering:null,link_text:null,offer_category:null,offer_category_id:null,offer_id:null,offer_location:null,offer_title:null,offers_count:null,page_path:null,player_type:null,profile:null,provider_id:null,query:null,season_num:null,sorting:null,strip_name:null,title_id:null,trial_available:null,user_id:null,vod_name:null,...t,event:"event-to-ga",page_path:s},n=document.getElementById("iframe-with-external-js");if(xv(n)&&n.contentWindow&&n.c
3ontentWindow.postMessage(JSON.stringify({type:"gtm-data-layer-push",dataLayerItem:i}),"*"),!!e.siteConfig?.counters?.gtm&&!e.siteConfig?.counters?.iframeDomain&&window.dataLayer)window.dataLayer.push(i);else{const o={...Av,...t,page_path:s},a=t.category||"unknown";typeof window.gtag=="function"&&window.gtag("event",a,o)}},Iv=(t,e)=>{const s=JSON.stringify(t);sa[s]||(yt(t,e),sa[s]=!0)},Lv=t=>{const e=`yaCounter${window.ymCounter}`;try{window[e]?.reachGoal(t)}catch(s){Xc.info("metrika","instead of sending to Yandex.Metrika",s)}},Qc=t=>t.providerInfo?.url||"",Jc=t=>t.providerInfo?.sales_phone||null,Rv=t=>t.providerInfo?.support_email,Cv=t=>t.providerInfoV2?.supportInfo.supportEmail,_v=t=>t.providerInfo?.support_url_short,wv=t=>t.providerInfoV2?.supportInfo.supportUrl.originalValue,Zc=t=>{const e=Jc(t);return e&&(e.country_code||e.region_code||e.number)?`${e.country_code} (${e.region_code}) ${e.number}`:""},Dv=Object.freeze(Object.defineProperty({__proto__:null,salesPhoneFormattedSelector:Zc,salesPhoneSelector:Jc,supportEmailSelector:Rv,supportEmailV2Selector:Cv,supportURLSelector:_v,supportURLV2Selector:wv,urlSelector:Qc},Symbol.toStringTag,{value:"Module"})),Pr=async(t,e)=>{t.providerInfoV2=await b.get(x.providerInfoV2,{languageCode:t.languageCode,ctx:e,params:{providerId:t.account?.provider?.provider?.id}}).catch(()=>null),t.providerInfo||(t.providerInfo=await b.get(x.providerInfo(t.account?.provider?.provider?.id||"default"),{ctx:e,languageCode:ae(t)}).catch(()=>null))},kv=Object.freeze(Object.defineProperty({__proto__:null,loadProviderInfo:Pr},Symbol.toStringTag,{value:"Module"})),ot=(t,e,s,i,n=!1,r=eg,o)=>{s==="loginSuccess"&&Ce.set("showLoginSuccessNotification",!0);const a=n?setTimeout(()=>{t.notifications.simple.shift(),s==="loginSuccess"&&Ce.set("showLoginSuccessNotification",!1)},r):null;if(t.notifications.simple.length>=3){const l=t.notifications.simple[0];l.timeout&&clearTimeout(l.timeout),t.notifications.simple.shift()}t.notifications.simple.push({text:e,icon:i,type:s,timeout:a,iconColorClass:o})},Or=(t,e)=>{ot(t,e,"error","error-circle")},Mr=t=>{const e=t.notifications.simple.findIndex(s=>s.type==="error");t.notifications.simple.splice(e,1)},Pv=(t,e,s)=>{ot(t,s,"diagnosticsStatus",e?"error-circle":"done-circle")},Ov=t=>{const e=t.notifications.simple.findIndex(s=>s.type==="diagnosticsStatus");t.notifications.simple.splice(e,1)},fi=async(t,e="tv",s=!0,i)=>{const n=e==="tv",r=n?"channel":"title",o=n?/%channelName%/g:/%titleName%/g;let a,l="favorite-on";s?a=`${r}_added_to_fav`:(a=`${r}_removed_from_fav`,l="favorite-off");const c=`<span>${Q(t,a).replace(o,`«${i}»`)}</span>`;ot(t,c,"favorite",l,!0)},Mv=t=>{const e=Q(t,"you_are_logged_in")||"";ot(t,e,"loginSuccess","done-circle",!0,ar)},ed=(t,e)=>{const i=`<span>${Q(t,"title_deleted_from_watch_history").replace(/%titleName%/g,`«${e}»`)}</span>`;ot(t,i,"pauseRemoved","delete",!0)},Nv=(t,e,s="done-circle")=>{ot(t,e,"profile",s,!0)},td=(t,e)=>{ot(t,e,"qs",void 0,!0,ar)},Fv=(t,e,s)=>{ot(t,e,"autoRenew","renew",!0,ar,s==="enable"?On.success:On.error)},sd=t=>{const e=br(t).complex;Object.keys(e).forEach(s=>{e[s].isVisible=!1})},ke=(t,e)=>{Es(t).indexOf(e)===-1&&Es(t).push(e)},Pe=(t,e)=>{const s=Es(t),i=s.indexOf(e);i>-1&&s.splice(i,1)},Uv=(t,e,s,i)=>{t.notifications.complex.adultOnboarding.isVisible=!0,t.notifications.complex.adultOnboarding.title=e,t.notifications.complex.adultOnboarding.message=s,t.notifications.complex.adultOnboarding.withButton=i,ke(t,"adultOnboarding")},Bv=t=>{t.notifications.complex.adultOnboarding.isVisible=!1,t.notifications.complex.adultOnboarding.title="",t.notifications.complex.adultOnboarding.message="",t.notifications.complex.adultOnboarding.withButton=!1,Pe(t,"adultOnboarding")},$v=(t,e="")=>{Nr(t),setTimeout(()=>{t.notifications.complex.authAndReg.isVisible=!0,t.notifications.complex.authAndReg.returnUrl=e,ke(t,"authAndReg")},0)},Nr=(t,e=!0)=>{t.notifications.complex.authAndReg.isVisible=!1,e&&(t.notifications.complex.authAndReg.returnUrl=""),Pe(t,"authAndReg")},Vv=t=>{t.notifications.complex.autologinMegafon.isVisible=!0,ke(t,"autologinMegafon")},Gv=t=>{t.notifications.complex.autologinMegafon.isVisible=!1,Pe(t,"autologinMegafon")},Hv=t=>{t.notifications.complex.dvrRestriction.isVisible=!0,ke(t,"dvrRestriction")},Kv=t=>{t.notifications.complex.dvrRestriction.isVisible=!1,Pe(t,"dvrRestriction")},Wv=t=>{t.notifications.complex.dvrRestrictionWithButton.isVisible=!0,ke(t,"dvrRestrictionWithButton")},qv=t=>{t.notifications.complex.dvrRestrictionWithButton.isVisible=!1,Pe(t,"dvrRestrictionWithButton")},id=t=>{t.notifications.complex.playerError.isVisible=!0,ke(t,"playerError")},Yv=t=>{t.notifications.complex.playerError.isVisible=!1,Pe(t,"playerError")},jv=t=>{t.notifications.complex.providerContactInfo.isVisible=!0,ke(t,"providerContactInfo")},zv=t=>{t.notifications.complex.providerContactInfo.isVisible=!1,Pe(t,"providerContactInfo")},Xv=t=>{t.notifications.complex.retry.isVisible=!0,ke(t,"retry")},Qv=t=>{t.notifications.complex.retry.isVisible=!1,Pe(t,"retry")},Jv=t=>{t.notifications.complex.review.isVisible=!0,ke(t,"review")},nd=t=>{t.notifications.complex.review.isVisible=!1,Pe(t,"review")},Zv=t=>{t.notifications.complex.subscriptionPaymentError.isVisible=!0,ke(t,"subscriptionPaymentError")},eT=t=>{t.notifications.complex.subscriptionPaymentError.isVisible=!1,Pe(t,"subscriptionPaymentError")},tT=(t,e)=>{t.notifications.complex.subscriptionProlongationError.message=e,t.notifications.complex.subscriptionProlongationError.isVisible=!0,ke(t,"subscriptionProlongationError")},sT=t=>{t.notifications.complex.subscriptionProlongationError.message="",t.notifications.complex.subscriptionProlongationError.isVisible=!1,Pe(t,"subscriptionProlongationError")},iT=(t,e,s,i,n)=>{rd(t),setTimeout(()=>{nd(t),t.notifications.complex.unavailableContent.isVisible=!0,t.notifications.complex.unavailableContent.image=n,t.notifications.complex.unavailableContent.sourceId=e,t.notifications.complex.unavailableContent.titleId=s,t.notifications.complex.unavailableContent.titleText=i,ke(t,"unavailableContent")},0)},rd=t=>{t.notifications.complex.unavailableContent.isVisible=!1,t.notifications.complex.unavailableContent.sourceId="",t.notifications.complex.unavailableContent.titleId="",t.notifications.complex.unavailableContent.titleText="",t.notifications.complex.unavailableContent.image=null,Pe(t,"unavailableContent")},nT=Object.freeze(Object.defineProperty({__proto__:null,addNotificationToQueueByName:ke,addNotificationToStack:ot,hideAdultOnboardingNotification:Bv,hideAllComplexNotifications:sd,hideAuthAndRegNotification:Nr,hideAutologinMegafonNotification:Gv,hideDiagnosticsStatusNotification:Ov,hideDvrRestrictionNotification:Kv,hideDvrRestrictionWithButtonVisibleSelector:qv,hideErrorNotification:Mr,hidePaymentErrorRetry:Qv,hidePlayerErrorNotification:Yv,hideProviderInfoNotification:zv,hideReviewNotification:nd,hideSubscriptionPaymentErrorNotification:eT,hideSubscriptionProlongationErrorNotification:sT,hideUnavailableContentNotification:rd,removeNotificationFromQueueByName:Pe,showAdultOnboardingNotification:Uv,showAuthAndRegNotification:$v,showAutoRenewNotification:Fv,showAutologinMegafonNotification:Vv,showDiagnosticsStatusNotification:Pv,showDvrRestrictionNotification:Hv,showDvrRestrictionWithButtonVisibleSelector:Wv,showErrorNotification:Or,showFavoriteNotification:fi,showLoginSuccessNotification:Mv,showPau
3seRemovedNotification:ed,showPaymentErrorRetry:Xv,showPlayerErrorNotification:id,showProfileNotification:Nv,showProviderInfoNotification:jv,showQsNotification:td,showReviewNotification:Jv,showSubscriptionPaymentErrorNotification:Zv,showSubscriptionProlongationErrorNotification:tT,showUnavailableContentNotification:iT},Symbol.toStringTag,{value:"Module"})),G=H("vod-actions"),rT=async(t,e)=>{if(xs(t)||hi(t))return;G.info("Do you need to load VOD-sources?",!xs(t)&&!hi(t)),t.vod.states.sourcesLoading=!0;let s=!1;try{t.vod.sourcesFe=(await gc({languageCode:ae(t),ctx:e}))?.sources||[],G.info("VOD FE sources have been loaded & set to store")}catch(i){G.error("api.vod.getSources ->",i),s=!0,t.vod.sourcesFe={sources:[]}}finally{t.vod.states.sourcesLoading=!1}if(!t.vod.sourcesFe.length){t.vod.states.sourcesLoaded=!s;return}Fr(t),t.vod.states.sourcesLoaded=!s,G.info("VOD BE + FE sources have been set to store")},od=async(t,e)=>{if(!(xs(t)||hi(t))){t.vod.states.sourcesLoading=!0;try{const[s,i]=await Promise.all([gc({languageCode:ae(t),ctx:e}),iy()]);if(!s?.sources?.length){t.vod.states.sourcesLoaded=!1,t.vod.sourcesFe={sources:[]};return}t.vod.sourcesFe=s.sources,t.vod.sourcesBe=i.sources,Fr(t),t.vod.states.sourcesLoaded=!0}catch(s){G.error("actions.vod.loadSources ->",s)}finally{t.vod.states.sourcesLoading=!1}}},Fr=t=>{const e={};t.vod.sourcesFe.filter(s=>s.id==="archive"||t.vod.sourcesBe.find(i=>i.id===s.id)?.isUsed||le().isSanta).sort((s,i)=>s?.priority-i?.priority).forEach(s=>{s.titlesEnhanced={};let i;const n=t.vod.sourcesBe.findIndex(r=>
3r.id===s.id);s.id!=="archive"?i={...s,color:t.vod.sourcesBe[n]?.color||"",customTitleId:t.vod.sourcesBe[n]?.customTitleId||"",imageTileVod:t.vod.sourcesBe[n]?.imageTileVod||"",isUsed:t.vod.sourcesBe[n]?.isUsed||le().isSanta,logo:t.vod.sourcesBe[n]?.logo||"",logoId:t.vod.sourcesBe[n]?.logoId||"",logoTilePoster:t.vod.sourcesBe[n]?.logoTilePoster||"",logoTilePosterDark:t.vod.sourcesBe[n]?.logoTilePosterDark||"",posterProportions:{height:t.vod.sourcesBe[n]?.posterProportions.height||3,width:t.vod.sourcesBe[n]?.posterProportions.width||2},slug:t.vod.sourcesBe[n].slug||"",titlesEnhanced:{}}:i={...s},e[s.id]=i}),t.vod.sources=e},Bn=t=>{t.vod.sources={},t.vod.sourcesFe={},t.vod.states.sourcesLoaded=!1},ad=t=>({id:qe,description:"",genres:[],priority:-1,slug:"",title:Q(t,"vod_filter_all_categories")}),ld=t=>({id:og,priority:999,slug:"",title:Q(t,"vod_filter_all_genres")}),oT=(t,e)=>(e.priority||0)-(t.priority||0)||hf(t.title||"",e.title||""),ia=t=>{const e=new Map;for(const s of t)!s?.id||e.has(s.id)||e.set(s.id,s);return[...e.values()].sort(oT)},cd=(t,e)=>{const s=t.vod.sources[e];s&&(s.categories||(s.categories={}),!s.categories[qe]&&(s.categories[qe]={...ad(t),genres:[ld(t)],titles:[],titlesEnhanced:{}}))},aT=async(t,e,s)=>{const i=await sS(e,s),n=ld(t),r=new Map,o=i?.categories||[],l=[ad(t),...o].map(c=>{const d=ia([n,...c.genres||[]]),u={...c,genres:d,titles:[],titlesEnhanced:{}};for(const h of d)r.has(h.id)||r.set(h.id,h);return u}).reduce((c,d)=>(c[d.id]=d,c),{});return l[qe]&&(l[qe].genres=ia([n,...r.values()])),{categories:l}},lT=async(t,e,s)=>{const i=t.vod.sources[s];if(Nc(t,s)||Fc(t,s)||!i)return;i.categoriesLoading=!0,cd(t,s);const n=i.categories?.[qe]?.titles||[],{categories:r}=await aT(t,s,{languageCode:ae(t),ctx:e}).catch(a=>(G.error(a),{categories:{}}));if(Object.keys(r).length>0){i.categories=r;const a=i.categories;n.length&&a?.[qe]&&(a[qe].titles=n)}const o=i.categories;(!o||Object.keys(o).length===0&&Bl(o))&&G.error(`Categories for sourceId = ${s} are absent.`),i.categoriesLoaded=!0,i.categoriesLoading=!1,G.info(`Categories data has loaded for sourceId = ${s}`)},dd=t=>{for(const e of kc(t))t.vod.sources[e]&&(t.vod.sources[e].currentCategoryId=qe)},ud=(t,e,s="")=>{t.vod.sources[e]&&(t.vod.sources[e].currentCategoryId=s)},hd=async(t,e)=>{if(Ee(t)||!Sc(t))return;if(Mc(t)){G.info("VOD Favorites are already being loaded right now");return}if(Oc(t)&&Fi(t).length){G.info("VOD Favorites have already been loaded before");return}t.vod.states.favoritesLoading=!0;const s=(await iS({languageCode:ae(t),ctx:e}).catch(i=>{G.error("getFavorites:",i),t.vod.states.favoritesLoading=!1,t.vod.states.favoritesLoaded=!0}))?.shortData||[];s.length?(t.vod.favorites=s,G.info("VOD Favorites have been successfully loaded")):G.info("VOD Favorites are empty"),t.vod.states.favoritesLoading=!1,t.vod.states.favoritesLoaded=!0},fd=t=>{t.vod.states.favoritesLoaded=!1,t.vod.states.favoritesLoading=!1,t.vod.favorites=[]},cT=async(t,e,s,i,n,r)=>{const o=Pc(t,i);if(o){await rS(i,s,{languageCode:t.languageCode,ctx:e});const a=t.vod.favorites.findIndex(l=>l.titleId===i);t.vod.favorites.splice(a,1),await fi(t,"vod",!o,n)}else await nS(i,s,{languageCode:t.languageCode,ctx:e}).then(()=>{t.vod.states.favoritesLoaded=!1,hd(t,e),fi(t,"vod",!o,n)}).catch(a=>{G.error("addToFavorites",a);const d=(a.response?.data?.message||a.response?.data).includes("excess")?"vod_favorites_limit_was_reached":"unknown_error",u=Q(t,d)||`{${d}}`;Or(t,u),setTimeout(()=>{Mr(t)},3e3)});yt({...Pi(t),action:o?"УдалиÑÑ Ð¸Ð· избÑанного":"ÐобавиÑÑ Ð² избÑанное",title_id:i,control_type:"mouse",category:"vod",vod_name:s},t)},gd=(t,e)=>{t.vod.sorting=e},pd=(t,e)=>{t.vod.sortings=e},dT=t=>{t.vod.sorting=""},md=async(t,e,s)=>{if(!s||s==="archive"||Dr(t))return;const i=(await cS(s,{languageCode:ae(t),ctx:e}).catch(n=>G.error(n)))?.sortings;if(!i?.length){G.info(`Sortings are not available for sourceID=${s}`);return}pd(t,i),gd(t,i[0]?.name||"")},yd=(t,e,s)=>{t.vod.sources[e].titlesEnhanced?.[s]&&(t.vod.sources[e].titlesEnhanced[s].loading=!0)},Sd=(t,e,s)=>{t.vod.sources[e].titlesEnhanced?.[s]&&(t.vod.sources[e].titlesEnhanced[s].loading=!1)},vd=(t,e,s)=>{t.vod.sources[e].titlesEnhanced[s].loaded=!0},uT=(t,e,s)=>{t.vod.sources[e].titlesEnhanced[s].loaded=!1},hT=(t,e,s)=>{{const i=s?t.vod?.sources[e].categories?.[s]:null;i?i.titles=[]:t.vod.sources[e].titles=[]}},fT=async(t,e)=>{const{sourceId:s}=e;let{categoryId:i}=e;if(!s)return G.error("sourceId was not passed"),[];if(!i)return G.error("categoryId was not passed"),[];const n=t.vod.sources[s].categories;n?.[i]||(G.error(`categoryId = ${i} does not exists in categories`,n),i=n?.[qe]?.id||n?.[Object.keys(n||{})[0]]?.id||"",i?(e.categoryId=i,ud(t,s,i),G.info(`using the 1st available categoryId = ${i} instead`)):G.error("Cannot set current category ID because categoryId = undefined"));const r=n?.[i]?.titles||[];e.offset=e.offset||r.length,await md(t,e.ctx,s),e.sort||(e.sort=Dr(t));const o=await oS(e),a=t.vod.sources[s].categories?.[i];return a&&t.vod.sources[s]&&n?.[i]&&(a.titles=r.concat(o),G.info(`Titles have been loaded & set to store for categoryId = ${i}`)),o},gT=async(t,e,s)=>{const{limit:i,offset:n,searchQuery:r,sourceId:o}=s;if(!o)throw new Error("searchTitles action: sourceId was not passed");if(!r)throw new Error("searchTitles action: VOD searchQuery was not passed");let a=null;try{a=await dS(o,{languageCode:t.languageCode,ctx:e,params:{query:r,limit:i,offset:n||0}})}catch(l){G.error(l)}t.vod.sources[o].titles=a?.titles||[]},pT=async(t,e,s,i,n)=>{if(!s){G.error("sourceId was not passed to loadTitleVod");return}if(!i){G.error("titleId was not passed to loadTitleVod");return}if(!t.vod.sources[s]){G.warn(`current sourceid=[${s}] is absent from sources=[${[Object.keys(t.vod.sources)].join(", ")}]`);return}if(Yc(t,s,i)){G.debug(`Title ${i} has already been loaded`);return}if(jc(t,s,i)){G.debug(`Title ${i} is already loading`);return}t.vod.sources[s].titlesEnhanced[i]={...ag};try{yd(t,s,i),G.debug(`Title ${i} is loading...`);const r=t.vod.sources[s].titlesEnhanced[i],o=await pc(s,i,{languageCode:ae(t),ctx:e});if(o){if(G.info(`Title ${i}
3 has been loaded!`),o?.preview?.hasSeries){const{titleSeasons:a,titleEpisodes:l}=await gS(s,i,{ctx:e,languageCode:ae(t)},o.details?.seasons,Q(t,"without_season"));o.details&&(o.details.seasons=a,o.details.episodes=l)}if(t.vod.sources[s]){if(t.siteConfig?.seoExperiment?.isEnabled){const l=t.siteConfig?.seoExperiment?.titles||[],c=n?.name,d=c==="vod-title"||c==="archive-title",u=c==="vod-title-season"||c==="archive-title-season",h=d||u;l.forEach(f=>{const g=f.variationId==="var_1_entire_card",m=f.variationId==="var_2_seasons_only",y=f.variationId==="var_3_main_page_only",S=!g&&(m&&!u||y&&u);h&&f.experimentId&&f.experimentId!=="type2_hide_google"&&o.details&&f.titleId===o.preview?.id&&!S&&(o.details.description="")})}t.vod.sources[s].titlesEnhanced[i]={...r,...o}}}}catch(r){G.error(r)}finally{Sd(t,s,i),vd(t,s,i)}await Td(t,e,s,i)},Td=async(t,e,s,i)=>{if(!Ee(t))if(t.vod.sources[s]?.titlesEnhanced?.[i]){const n=await by(s,i,{ctx:e,languageCode:ae(t)});t.vod.sources[s].titlesEnhanced[i].pauses=n,G.info(`VOD pauses have been loaded for title = ${i}`,n)}else G.warn(`Unable to load pauses for title = ${i}, title should be loaded first`)},mT=async(t,e,s,i)=>{t.vod.similarities=await SS(e,ae(t),$e(t)||"",s,i)},yT=async(t,e,s)=>{await Pr(t,e),s.phone=Zc(t),s.url=Qc(t),Ee(t)?yt({category:"blocked_content_click",action:"ÐоÑвление оÑибки - ÐÑ Ð½Ðµ авÑоÑизованÑ"},t):s.phone||s.url?yt({category:"blocked_content_click",action:"ÐÐµÑ Ð¿Ð¾Ð´Ð¿Ð¸Ñки Ñ ÐºÐ¾Ð½ÑакÑами пÑовайдеÑа"},t):yt({category:"blocked_content_click",action:"ÐÐµÑ Ð¿Ð¾Ð´Ð¿Ð¸Ñки без конÑакÑов пÑовайдеÑа"},t)},Bi=t=>{t.vod.states.isAnyHomeCollectionLoaded=!1,t.vod.states.isAnyHomeCollectionLoading=!1,t.vod.states.isSourceCollectionLoaded=!1,t.vod.states.isSourceCollectionLoading=!1,t.vod.homeCollections=[],t.vod.sourceCollections=[]},$i=async(t,e)=>{const s=Object.keys(Ot(t));let i=[];if(!xs(t)){G.warn("VOD-sources were not loaded yet");return}if(!Tt(t).length){G.warn("There are 0 VOD-sources. Skip loading Home VOD-collections");return}if(Bc(t)){G.info("Home VOD-collections have already started loading");return}if(!(t.vod.homeCollections?.length&&$c(t))){t.vod.states.isAnyHomeCollectionLoading=!0,$e(t)||await tt(t,e);try{const n=await mS({languageCode:t.languageCode,ctx:e},vc(t),$e(t)||"");if(n&&(i=n.vodCollections||[]),!i?.length){t.vod.states.isAnyHomeCollectionLoaded=!0,t.vod.states.isAnyHomeCollectionLoading=!1;return}i=i.filter(r=>r.titlesList?.length&&(r.vodSource==="archive"||s.includes(r.vodSource))),i=Jt(ST(t,i),"priority"),await vT(t,i),G.info("Home VOD-collections have been loaded"),t.vod.states.isAnyHomeCollectionLoaded=!0}catch(n){G.error("Home VOD-collections did not load:",n)}finally{t.vod.states.isAnyHomeCollectionLoading=!1}}},ST=(t,e)=>e.length?e.map(s=>({caption:s.caption,logo:s.vodSource!=="archive"?kr(t,s.vodSource):void 0,titlesList:s.titlesList,vodSource:s.vodSource,vodCollectionId:s.vodCollectionId,id:s.id,priority:s.priority,brandingMethods:[],placementBlocks:s.placementBlocks})):[],vT=async(t,e)=>{let s=[];s=e.flatMap(i=>Tt(t).includes(i.vodSource)?TT(t,i):[]),t.vod.homeCollections=s},$n=(t,e,s)=>s.map(i=>({...i,widthProportion:Wc(t,e),heightProportion:qc(t,e),link:li(e,i.id)})),TT=(t,e)=>({...e,titlesList:$n(t,e.vodSource,e.titlesList||[])}),ET=async(t,e,s,i)=>{if(!s){G.info("sourceId was not provided");return}if(!i){G.info("collectionId was not provided");return}if(t.vod.states.isSourceCollectionLoading){G.info(`collection ${i} is already loading`);return}t.vod.states.isSourceCollectionLoading=!0;const r=t.vod.sourceCollections.find(l=>l.id===i)?.titlesList?.length||0,o=(await yS(ae(t),e,s,i,r).catch(l=>{G.error(l),t.vod.states.isSourceCollectionLoading=!1}))?.titles;if(o?.length){const l=(await pS({ctx:e,languageCode:ae(t)},s).catch(d=>{G.error(d)}))?.collections||[];let c="";l?.length&&(c=l?.find(d=>d.id===i)?.title||""),Ed(t,s,i,o,c)}t.vod.states.isSourceCollectionLoading=!1;const a=t.vod.sourceCollections.findIndex(l=>l.id===i);a>=0&&(t.vod.sourceCollections[a].hasMoreTitlesToLoad=o?.length===vs)},Ed=(t,e,s,i,n)=>{if(n=n||t.vod.homeCollections.find(r=>r?.vodCollectionId===s||r?.id===s)?.caption||"",!t.vod.sourceCollections.find(r=>r.id===s))t.vod.sourceCollections.push({brandingMethods:[],caption:n,id:s,logo:e!=="archive"?kr(t,e):void 0,placementBlocks:[],priority:0,titlesList:$n(t,e,i),vodCollectionId:"",vodSource:e});else{const r=t.vod.sourceCollections.findIndex(a=>a.id===s),o=t.vod.sourceCollections[r].titlesList||[];o.push(...$n(t,e,i)),t.vod.sourceCollections[r].titlesList=o}},bT=Object.freeze(Object.defineProperty({__proto__:null,addTitlesToSourceCollection:Ed,checkForProviderWithCountryCode:yT,flushTitles:hT,initializeCategoryAll:cd,loadFavorites:hd,loadHomeCollections:$i,loadSimilarities:mT,loadSortings:md,loadSourceCategories:lT,loadSources:od,loadSourcesFe:rT,loadTitleVod:pT,loadTitleVodPause:Td,loadTitles:fT,loadTitlesForSourceCollection:ET,prepareSources:Fr,resetCollections:Bi,resetCurrentCategoryId:dd,resetFavorites:fd,resetLoadedTitle:uT,resetSorting:dT,resetSources:Bn,searchTitles:gT,setCurrentCategoryId:ud,setLoadedTitle:vd,setSorting:gd,setSortings:pd,startLoadingTitle:yd,stopLoadingTitle:Sd,toggleTitleFavorite:cT},Symbol.toStringTag,{value:"Module"})),Vi=t=>t.player.type,xT=t=>Vi(t)==="tv",AT=t=>Vi(t)==="vod",IT=t=>Vi(t)==="archive",LT=t=>t.player.isDateTimeVisible,RT=t=>t.player.loading,CT=t=>t.player.alert,_T=t=>t.player.dvrWarningOverlay,Ur=t=>{const e=t.player.error;return e&&!e.message&&(e.code=_l.COMMON,e.message=Q(t,"error_empty_response")),e},wT=t=>Ur(t)?.code,DT=t=>!!Ur(t),kT=t=>t.player.isEpgVisible,PT=t=>$r(t)&&t.player.isFullscreenMenuVisible,OT=t=>t.player.isSettingsMenuVisible,MT=t=>t.player.volumeSlider.visible,NT=t=>t.player.rewinding,FT=t=>t.player.fastForwarding,UT=t=>t.player.timeline.isBalloonVisible,BT=t=>t.player.timeline.isBalloonFollowingMouse,Br=t=>t.player.minimized,bd=t=>t.player.visible,$T=t=>t.player.isScrollLocked,VT=t=>t.player.video.wasPlayingBeforeOffline,$r=t=>t.player.video.isFullscreen,GT=t=>t.player.video.subtitleDisplay,HT=t=>t.player.video.fps50,KT=t=>t.player.video.hasSubtitles,WT=Object.freeze(Object.defineProperty({__proto__:null,alertSelector:CT,dvrWarningOverlaySelector:_T,errorCodeSelector:wT,errorSelector:Ur,fps50Selector:HT,hasErrorSelector:DT,hasSubtitlesSelector:KT,isArchiveSelector:IT,isBalloonVisibleSelector:UT,isDateTimeVisibleSelector:LT,isEpgInfoVisibleSelector:kT,isFastForwardingSelector:FT,isFullscreenMenuVisibleSelector:PT,isFullscreenSelector:$r,isLoadingSelector:RT,isMinimizedSelector:Br,isRewindingSelector:NT,isScrollLockedSelector:$T,isSettingsMenuVisibleSelector:OT,isTimelineBalloonFollowingMouseSelector:BT,isTvSelector:xT,isVisibleSelector:bd,isVodSelector:AT,isVolumeSliderVisibleSelector:MT,subt
3itleDisplaySelector:GT,typeSelector:Vi,wasPlayingBeforeOfflineSelector:VT},Symbol.toStringTag,{value:"Module"})),EP=()=>document.fullscreenEnabled||document.webkitFullscreenEnabled||document.webkitEnterFullscreen,Vr=()=>!!document.fullscreenElement||!!document.webkitFullscreenElement,bP=t=>{Vr()||(t.requestFullscreen?t.requestFullscreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.webkitEnterFullscreen&&t.webkitEnterFullscreen())},qT=()=>{Vr()&&(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen&&document.webkitExitFullscreen())},YT=(t,e)=>{t.modals.params=e},jT=(t,e)=>{t.modals.scrollPosition=e},zT=t=>{t.modals.scrollPosition=0},XT=(t,e)=>{t.modals.title=e},xd=t=>{t.modals.title=""},rs=(t,e)=>{Er(t)[e]||(t.returnMetaTitle=document.querySelector("title")?.innerText||"",t.modals.visibility[e]=!0)},os=(t,e)=>{t.modals.visibility[e]=!1,xd(t)},QT=t=>{Object.keys(Er(t)).forEach(e=>{t.modals.visibility[e]=!1}),xd(t)},JT=t=>{rs(t,Ze.adultOnboarding)},ZT=t=>{os(t,Ze.adultOnboarding)},eE=t=>{t.modals.visibility.byRoute=!0},tE=t=>{t.modals.visibility.byRoute=!1},sE=t=>{t.modals.visibility.dvrError=!0},iE=t=>{t.modals.visibility.dvrError=!1},Ad=t=>{t.modals.visibility.dvrWarning=!0},Id=t=>{t.modals.visibility.dvrWarning=!1},nE=t=>{t.modals.visibility.feSettings=!0},rE=t=>{t.modals.visibility.feSettings=!1},oE=t=>{t.modals.visibility.mobileApps=!0},aE=t=>{t.modals.visibility.mobileApps=!1},lE=t=>{t.modals.visibility.offerDetails=!0},cE=t=>{t.modals.visibility.offerDetails=!1},dE=t=>{t.modals.visibility.offerGift=!0},uE=t=>{t.modals.visibility.offerGift=!1},hE=t=>{t.modals.visibility.offerExitConfirmation=!0},fE=t=>{t.modals.visibility.offerExitConfirmation=!1},gE=t=>{t.modals.visibility.personalData=!0},pE=t=>{t.modals.visibility.personalData=!1},mE=t=>{rs(t,Ze.phoneVerification)},yE=t=>{os(t,Ze.phoneVerification)},Ld=t=>{t.modals.visibility.popupNotice=!0},Rd=t=>{t.modals.visibility.popupNotice=!1},SE=t=>{t.modals.visibility.profileAction=!0},Cd=t=>{t.modals.visibility.profileAction=!1},vE=t=>{t.modals.visibility.profileProtected=!0},TE=t=>{t.modals.visibility.profileProtected=!1},_d=t=>{t.modals.visibility.qs=!0},EE=t=>{t.modals.visibility.qs=!1},bE=t=>{t.modals.visibility.qsQr=!0},xE=t=>{t.modals.visibility.skipPromoOffers=!0},AE=t=>{t.modals.visibility.skipPromoOffers=!1},IE=t=>{t.modals.visibility.subscriptionConfirmation=!0},LE=t=>{t.modals.visibility.subscriptionConfirmation=!1},RE=t=>{rs(t,Ze.subscriptionShop)},CE=t=>{os(t,Ze.subscriptionShop)},_E=t=>{t.modals.visibility.subscriptionV2=!0},wE=t=>{t.modals.visibility.subscriptionV2=!1},DE=t=>{rs(t,Ze.trialGift)},kE=t=>{os(t,Ze.trialGift)},PE=t=>{t.modals.visibility.unsubscriptionRetentionOfferDetails=!0},OE=t=>{t.modals.visibility.unsubscriptionRetentionOfferDetails=!1},ME=t=>{rs(t,Ze.verificationSubscription)},NE=t=>{os(t,Ze.verificationSubscription)},FE=t=>{t.siteConfig?.welcomeScreen?.enabled&&(t.modals.visibility.welcomeScreen=!0)},UE=t=>{t.modals.visibility.welcomeScreen=!1},BE=Object.freeze(Object.defineProperty({__proto__:null,hideAdultOnboarding:ZT,hideAllModals:QT,hideByRoute:tE,hideDvrError:iE,hideDvrWarning:Id,hideFeSettings:rE,hideMobileApps:aE,hideModal:os,hideOfferDetails:cE,hideOfferExitConfirmation:fE,hideOfferGift:uE,hidePersonalData:pE,hidePhoneVerification:yE,hidePopupNoticeModal:Rd,hideProfileAction:Cd,hideProfileProtected:TE,hideQs:EE,hideSkipPromoOffers:AE,hideSubscriptionConfirmation:LE,hideSubscriptionShop:CE,hideSubscriptionV2:wE,hideTrialGift:kE,hideUnsubscriptionRetentionOfferDetails:OE,hideVerificationSubscription:NE,hideWelcomeScreen:UE,resetModalScrollPosition:zT,setModalParams:YT,setModalScrollPosition:jT,setModalTitle:XT,showAdultOnboarding:JT,showByRoute:eE,showDvrError:sE,showDvrWarning:Ad,showFeSettings:nE,showMobileApps:oE,showModal:rs,showOfferDetails:lE,showOfferExitConfirmation:hE,showOfferGift:dE,showPersonalData:gE,showPhoneVerification:mE,showPopupNoticeModal:Ld,showProfileAction:SE,showProfileProtected:vE,showQs:_d,showQsQr:bE,showSkipPromoOffers:xE,showSubscriptionConfirmation:IE,showSubscriptionShop:RE,showSubscriptionV2:_E,showTrialGift:DE,showUnsubscriptionRetentionOfferDetails:PE,showVerificationSubscription:ME,showWelcomeScreen:FE},Symbol.toStringTag,{value:"Module"})),as=H("player"),$E=(t,e="")=>{t.player.type=e},VE=t=>{t.player.loading||(as.info("startLoading"),t.player.loading=!0)},Gr=t=>{t.player.loading&&(as.info("stopLoading"),t.player.loading=!1)},GE=t=>{t.player.minimized=!0},HE=t=>{t.player.minimized=!1},KE=t=>{t.player.visible=!0},wd=t=>{t.player.visible=!1},Dd=t=>{t.player.isScrollLocked=!0},WE=t=>{t.player.isScrollLocked=!1},kd=t=>{Od(t),Gr(t),Nd(t,!1),wd(t)},qE=(t,e,s)=>{if(typeof window>"u"||typeof document>"u"){as.error("exitFullscreenOnAndroid is to be used on client-side only");return}const i=ss();window.innerHeight<window.innerWidth&&or(i).isAndroid&&s&&Hr(t)},Pd=(t,e,s="",i,n={})=>{as.error("setError",{errorCode:e,errorMessage:s,status:i}),Gr(t),t.player.error={code:e,message:s,options:n,status:i},Br(t)||document.documentElement?.clientWidth<=tg?id(t):Dd(t),$r(t)&&Hr(t)},Od=t=>{t.player.error!==null&&(as.info("clearError"),t.player.error=null)},YE=(t,e)=>{as.info("setAlert",e),t.player.alert=e},jE=t=>{t.player.alert=""},zE=t=>{Id(t),t.player.isFullscreenMenuVisible=!0},Md=t=>{t.player.isFullscreenMenuVisible=!1},XE=t=>{t.player.isSettingsMenuVisible=!0},QE=t=>{t.player.isSettingsMenuVisible=!1},Nd=(t,e)=>{t.player.video.hasSubtitles=e},JE=t=>{t.player.video.isFullscreen=!t.player.video.isFullscreen},ZE=t=>{t.player.video.isFullscreen=!0},Hr=t=>{qT(),Md(t),t.player.video.isFullscreen=!1},eb=(t,e)=>t.player.video.wasPlayingBeforeOffline=e,tb=(t,e,s)=>{t.player.dvrWarningOverlay.channelId=e,t.player.dvrWarningOverlay.message=s,Ad(t)},sb=(t,e)=>{t.player.timeline.isBalloonFollowingMouse=e},ib=Object.freeze(Object.defineProperty({__proto__:null,clearAlert:jE,clearError:Od,exitFullscreen:Hr,exitFullscreenOnAndroid:qE,expandPlayer:HE,goFullscreen:ZE,hideFullscreenMenu:Md,hidePlayer:wd,hideSettingsMenu:QE,lockScroll:Dd,minimizePlayer:GE,reset:kd,setAlert:YE,setDvrWarningOverlayData:tb,setError:Pd,setHasSubtitles:Nd,setPlayerType:$E,setTimelineBalloonFollowingMouse:sb,setWasPlayingBeforeOffline:eb,showFullscreenMenu:zE,showPlayer:KE,showSettingsMenu:XE,startLoading:VE,stopLoading:Gr,toggleFullscreen:JE,unlockScroll:WE},Symbol.toStringTag,{value:"Module"})),gi=H("payment-actions"),Ks=5,nb=1e3,Fd=async(t,e,s,i=!1)=>
3{if(!t.payment.method||i){const n={languageCode:t.languageCode,ctx:e};s&&(n.params={token:s}),t.payment.method=await Uy(n)}},rb=async(t,e)=>{await Vy({languageCode:t.languageCode,ctx:e}),t.payment.method=null},Ud=async(t,e,s)=>{const i={languageCode:t.languageCode,ctx:e};s&&(i.params={token:s}),t.payment.yakassaSubscriptions=await fc(i)||[]},ob=async(t,e,s="",i)=>{let n;for(let r=1;r<=Ks;r++){if(gi.warn(`Trying to load a subscription that has expires_at. Subscription id = ${s}, attempt ${r} / ${Ks}`),await Ud(t,e,i),n=t.payment.yakassaSubscriptions.find(o=>o?.id===s),n?.expires_at)return n;r<Ks?await Og(nb):gi.error(`expires_at is missing from the subscription with id = ${s} after ${Ks} attempts.`)}return n},Kr=async(t,e)=>{try{const s=await By({languageCode:t.languageCode,ctx:e});if(!s?.subscriptions)return;const i=[];for(const n of s.subscriptions){let r={},o=[];try{r=JSON.parse(n.mainOffer?.renderingDataJson||"{}");const l=n.mainOffer||n.temporaryOffer?.offer;l&&(o=(await cc(l.offerId,{ctx:e,languageCode:t.languageCode}))?.channels?.filter(d=>t.tvChannels.list[d.channelId])||[])}catch(l){gi.error(l)}const a={...n,showcaseChannels:o,renderingData:r,managementMethods:Ie((n.managementMethods||[]).filter(l=>ig.includes(l.name)))};n.mainOffer&&(a.mainOffer={...n.mainOffer,renderingMethods:n.mainOffer?.renderingMethods?.filter(l=>Cs[l.name]||l.name===cg)}),i.push(a)}i?.length&&(t.payment.currentSubscriptions=i,i.some(n=>n.managementMethods?.find(r=>r.name===wl.YAKASSA))&&await vt.payment.loadYakassaSubscriptions(t,e))}catch(s){gi.warn("loadCurrentSubscriptions failed",s)}},ab=Object.freeze(Object.defineProperty({__proto__:null,loadCurrentSubscriptions:Kr,loadPaymentMethod:Fd,loadYakassaSubscriptions:Ud,loadYakassaSubscriptionsUntilExpiresAtPresent:ob,removePaymentMethod:rb},Symbol.toStringTag,{value:"Module"})),ls=t=>t.utmLabels?.reduce((e,s)=>({...e,[`utm_${s.name}`]:s.value}),{}),lb=Object.freeze(Object.defineProperty({__proto__:null,utmLabelsSelector:ls},Symbol.toStringTag,{value:"Module"})),at=H("qs"),cb=t=>{Bd(t),t.qs.toPrevStep=!0},pi=(t,e)=>{t.resStatus===ge.FORBIDDEN&&td(e,t.message)},db=async(t,e,s)=>{if(t.qs.currentSourceId=s.id||"",!(Ee(t)||jl(t,s.id)||!ur(s)||le().isSanta||t.secretSanta)){try{await Yd(t,e,s.id)}catch(i){if(pi(i,t),[void 0,ge.NOT_FOUND].includes(i.resStatus))try{await qd(t,e,s.id)}catch(n){pi(n,t),[void 0,ge.NOT_FOUND].includes(n.resStatus)||Pd(t,_l.COMMON,n.message,n.resStatus)}}await Gi(t,e,Pl.CHANNEL,!0,s)}},ub=async(t,e,s,i,n)=>{if(!(t.secretSanta||le().isSanta)){t.qs.currentSourceId=s;try{await Wd(t,e,{params:{sourceId:s}})}catch(r){if(pi(r,t),[void 0,ge.NOT_FOUND].includes(r.resStatus))try{await Hd(t,e,{params:{sourceId:s}})}catch(o){pi(o,t)}}await Gi(t,e,Pl.VOD,!1,null,s,i,n)}},hb=async(t,e,s)=>{if(t.secretSanta||le().isSanta)return;if(Ee(t)){vt.notifications.showAuthAndRegNotification(t);return}const i=`offer-set-${s}`;t.qs.currentSourceId=i;try{await Kd(t,e,s,i)}catch{}await Gi(t,e,"promo",!1,null),vt.utmLabels.resetUtmLabels(t)},Gi=async(t,e,s,i,n,r,o,a)=>
3{if(Vu(t)){const l=To(t);try{await Fd(t,e)}catch(d){at.error("onLoadPaymentMethod",d)}t.qs.sourceType=s,i?t.qs.channel=n:r&&o&&a&&(t.qs.vod={name:o?.preview?.title||"",sourceId:r,episodeId:a}),_d(t);const c={...Pi(t),category:"acquiring",action:"Ðоказ диалога оплаÑÑ",trial_available:`${l?.trialAvailable}`,acquiring_type:"qs"};i?c.channel_name=n?.title||"":(c.vod_name=r||"",c.title_name=o?.preview?.title||""),yt(c,t)}},Wr=(t,e)=>{t.qs.currentSourceId&&t.qs?.subscriptionsBySource[t.qs.currentSourceId]?.steps[e]&&(t.qs.currentStepIndex=e)},qr=(t,e=!0)=>{const s=So(t);if(s){const i=e?"next":"prev",n=s[i]?vo(t,s[i]||""):t.qs.currentStepIndex+(e?1:-1);Wr(t,n||0)}},fb=(t,e)=>{if(e)return Wr(t,vo(t,e)||0)},gb=t=>qr(t,!0),Bd=t=>qr(t,!1),cs=(t,e={})=>(t.qs.qsTransactionId&&(e.qs_transaction_id=t.qs.qsTransactionId),e),pb=async(t,e)=>(et(t),e.params=cs(t,e.params),await Gy(e)),$d=async(t,e)=>(et(t),e.params=cs(t,e.params),await Hy(e)),mb=async(t,e)=>(et(t),e.params=cs(t,e.params),await Ky(e)),yb=async(t,e)=>(et(t),e.params=cs(t,e.params),await Wy(e)),Sb=async(t,e)=>(et(t),e.params=cs(t,e.params),await qy(e)),vb=async(t,e)=>(et(t),e.params=cs(t,e.params),await Yy(e)),Vd=async(t,e,s,i=!1)=>{if(s.offerId)try{const n=await dc(s.offerId,{ctx:e,languageCode:ae(t)});if(!n)return;const{channels:r}=n,o=vl(Object.values(t.tvChannels.list),r||[],(a,l)=>a.id===l?.channelId);s.channels=Jt(o,"strNumber"),s.channelsIds=r?.map(a=>a.channelId)||[],s.trialAvailable&&s.trial&&!i&&await Vd(t,e,s.trial,!0)}catch(n){at.error(n)}},Ft=async(t,e,s,i)=>{if(!s){at.warn("data was not provided, data:",s);return}return t.qs.paymentRetry=s.existingSubscriptions?.[0]?.subscriptionStatus===Ir.IN_RETRY.toLowerCase()||s.existingSubscriptions?.[0]?.paymentSystemType===bs.Uztelecom,Fu(t,e,s,i)},Gd=(t=[],e,s)=>{const i=[];for(const n of t){let r={},o={};try{r=JSON.parse(n.renderingDataJson||"{}"),n.trialAvailable&&n.trial&&(o=JSON.parse(n.trial.renderingDataJson))}catch(l){at.error(l)}const a={...n,showcaseChannels:e[n.offerId],renderingData:r};n.trial&&(a.trial={...n.trial,renderingData:o}),a.shopSettings?.section==="additional"&&s&&(a.shopSettings.categories=a.shopSettings.categories||[],a.shopSettings.categories.unshift({id:Eg,name:"ÐÑе"})),a.renderingMethods=Ie(a.renderingMethods||[]),a.renderingMethod=a.renderingMethods[0],i.push(a)}return i.filter(n=>(n.renderingMethods||[]).find(r=>r.name===oi.SUBSCRIPTION_SHOP||r.name===oi.SUBSCRIPTION_SHOP_ADJUSTED))},Hd=async(t,e,s)=>{const i=s.params.sourceId;if(t.qs.subscriptionsBySource[i])return;s.params={...s.params,...ls(t)};const n=await Py({...s,languageCode:t.languageCode,ctx:e});n&&(t.qs.subscriptionsBySource[i]=await Ft(t,e,n))},Kd=async(t,e,s,i)=>{t.qs.subscriptionsBySource[i]||(t.qs.subscriptionsBySource[i]=await Ft(t,e,await Fy(s,{ctx:e,languageCode:t.languageCode,params:{sourceId:i,...ls(t)}})||void 0))},Wd=async(t,e,s)=>{const i=s.params.sourceId;t.qs.subscriptionsBySource[i]||(s.params={...s.params,...ls(t)},t.qs.subscriptionsBySource[i]=await Ft(t,e,await Ny({...s,languageCode:t.languageCode,ctx:e})||void 0))},qd=async(t,e,s,i)=>{if(t.qs.subscriptionsBySource[s])return;const n={languageCode:t.languageCode,ctx:e};i&&(n.params={token:i}),n.params={...n.params,...ls(t)},t.qs.subscriptionsBySource[s]=await Ft(t,e,await Oy(s,n)||void 0)},Yd=async(t,e,s,i)=>{const n={languageCode:t.languageCode,ctx:e};i&&(n.params={token:i}),n.params={...n.params,...ls(t)},t.qs.subscriptionsBySource[s]=await Ft(t,e,await My(s,n)||void 0)},jd=async(t,e)=>{const s=await Ms(e);if(!s){at.warn("data was not provided, data:",s);return}s.subscriptionOptions=s.subscriptionOptions?.filter(({type:n})=>n==="base");const i=await Ft(t,e.ctx,s);t.qs.allSubscriptions=i},zd=async(t,e)=>{const s=await Ms(e);if(!s)return at.warn("data was not provided, data:",s),[];s.subscriptionOptions=s.subscriptionOptions?.filter(({renderingMethods:n})=>(n||[]).find(r=>r.name===_e.PROMO_OFFER));const i=await Ft(t,e.ctx,s,{withPromoCode:!0});t.qs.promoCodeSubscriptions=i},Vn=(t,e,s,i)=>e?([{name:"%trialPeriod%",replacement:i?Math.round(Ai(i,"second")):void 0},{name:"%sourceName%",replacement:t.qs.sourceType!=="vod"?t.qs?.channel?.name:""},{name:"%channelCount%",replacement:s}
3].forEach(r=>{r.replacement!==void 0&&(e=e?.replace(r.name,r.replacement))}),e):void 0,Xd=async(t,e,s=[])=>{const i=s.map(o=>cc(o.offerId,{ctx:e,languageCode:t.languageCode})),n=await Promise.all(i),r={};return s.forEach((o,a)=>{const l=n[a];l&&(r[o.offerId]=(l.channels||[]).filter(c=>t.tvChannels.list[c.channelId]))}),r},Yr=async(t,e)=>{const s=await zy($e(t),{languageCode:t.languageCode,ctx:e});if(!s){at.warn("loadShopSubscriptionOptions failed");return}const{subscriptionOptions:i}=s,n=await Xd(t,e,i||[]);t.qs.shopSubscriptions=Ie(Gd(i||[],n,!1))},Qd=async(t,e)=>{const s=await Ms({languageCode:t.languageCode,ctx:e});if(!s){at.warn("loadAvailableSubscriptionsOptions failed");return}const{subscriptionOptions:i}=s,n=await Xd(t,e,i||[]);t.qs.availableSubscriptions=Ie(Gd(i||[],n,!0))},Tb=async(t,e)=>{const s=await Ms({languageCode:t.languageCode,ctx:e});if(!s){at.warn("loadAllAvailableSubscriptionOptions failed");return}const{existingSubscriptions:i,subscriptionOptions:n}=s;t.qs.existingSubscriptions=i||null,t.qs.allAvailableSubscriptions=n||null},Eb=(t,e)=>{t.qs.loading=!0,t.qs.loadingId=e||""},bb=t=>{t.qs.loading=!1,t.qs.loadingId="",t.qs.subscriptionShop.loadingId=""},xb=(t,e="")=>{t.qs.subscriptionShop.loadingId=e},Jd=(t,e)=>{t.qs.additionalActions.currentStepIndex=e},Ab=t=>{t.qs.additionalActions.currentStepIndex++},Ib=t=>{t.qs.additionalActions.currentStepIndex--},Lb=(t,e)=>{Jd(t,vg[e])},Rb=Object.freeze(Object.defineProperty({__proto__:null,addChannelsToOffer:Vd,additionalActionsGoToNextStep:Ab,additionalActionsGoToPreviousStep:Ib,additionalActionsGoToStepByName:Lb,createSubscription:mb,createSubscriptionUpsale:Sb,createSubscriptionUpsaleV2:vb,createSubscriptionWithVerifiedPhone:yb,createYakassaSubscription:pb,createYakassaSubscriptionV2:$d,getAllSubscriptionOptions:jd,getOffersSetSubscriptionOptions:Kd,getPromoCodeSubscriptionOptions:zd,getQsStringWithReplacedVariables:Vn,getTvSubscriptionOptions:qd,getTvV3SubscriptionOptions:Yd,getVodSubscriptionOptions:Hd,getVodV3SubscriptionOptions:Wd,goToNextOrPreviousStep:qr,goToNextStep:gb,goToPrevStep:Bd,goToStepByName:fb,handleForTv:db,handleForVod:ub,handleModalStepBack:cb,handleOffersSet:hb,loadAllAvailableSubscriptionOptions:Tb,loadAvailableSubscriptionOptions:Qd,loadPaymentMethodAndShowModal:Gi,loadShopSubscriptionOptions:Yr,setAdditionalActionsCurrentStepIndex:Jd,setCurrentStepByIndex:Wr,setSubscriptionShopLoadingId:xb,startLoading:Eb,stopLoading:bb},Symbol.toStringTag,{value:"Module"})),na=H("tv-epg-v2");let Ws;const jr=async(t,e)=>{Ws&&(clearTimeout(Ws),Ws=void 0);const s=180*1e3,i=360*1e3;let n=i;if(!t.tvEpgV2.onAir.isLoaded){const r=await py({languageCode:t.languageCode,ctx:e,params:{"tv-asset-token":Pt(t)}}).catch(o=>{na.error(o)}).finally(()=>{t.tvEpgV2.onAir.isLoading=!1});if(!r)return;if(t.tvEpgV2.onAir.schedules=r.schedules?.reduce((o,a)=>(o[a.scheduleId]=a.events||[],o),{}),t.tvEpgV2.onAir.relevantInterval=r.relevantInterval,t.tvEpgV2.onAir.updateDuringInterval=r.updateDuringInterval,r.updateDuringInterval){const o=Le(r.updateDuringInterval.begin).unix(),a=Le(r.updateDuringInterval.end).unix(),l=(o-t.common.serverTime)*1e3,c=(a-t.common.serverTime)*1e3;n=Vo(l,c),a*1e3<=Date.now()+s&&(n=Vo(s,i))}t.tvEpgV2.onAir.isLoaded=!0}na.info("epg-on-air was loaded, next update in ~",Math.round(n/1e3/60),"minutes"),Ws=setTimeout(()=>{t.tvEpgV2.onAir.isLoaded=!1,jr(t,e)},n)},Cb=Object.freeze(Object.defineProperty({__proto__:null,loadEpgOnAir:jr},Symbol.toStringTag,{value:"Module"})),_b=H("app-sections"),zr=async(t,e)=>{const s=$e(t);try{const i=await b0(s,{languageCode:t.languageCode,ctx:e}).catch(()=>null);t.appSections.sections=i?.customSections?.filter(n=>n.renderingMethods.includes(Sg.verticalBlockV1)).map(n=>({...n,blocks:n?.blocks?.map(r=>({...r,blockSettings:JSON.parse(r.blockSettingsJson)})),sectionSettings:JSON.parse(n.sectionSettingsJson)}))||[]}catch(i){_b.error(i)}},wb=Object.freeze(Object.defineProperty({__proto__:null,loadAppSections:zr},Symbol.toStringTag,{value:"Module"})),ra=H("promo-elements"),Xr=t=>{let e="";if(t.actionMethods&&(e=Jt(t.actionMethods,"priority").find(({method:s})=>kl.includes(s))?.method||""),e||ra.debug("Supported action methods were not found in:",t),t.internalReference?.screenId)switch(t.internalReference?.screenId){case oe.vodContentWall.i
3d:{const s=t.internalReference.vodContent?.source||"";if(s)return oe.vodContentWall.path(s);break}case oe.vodCollectionPage.id:{const s=t.internalReference.vodContent?.source,i=t.internalReference.vodContent?.collectionId?.trim();if(i&&s)return oe.vodCollectionPage.path(s,i);break}case oe.vodTitlePage.id:if(t.internalReference.vodContent){const{source:s,contentId:i}=t.internalReference.vodContent;if(s&&i)return oe.vodTitlePage.path(s,i)}break;case oe.vodStartPlayback.id:if(t.internalReference.vodContent){const{source:s,contentId:i,episodeId:n}=t.internalReference.vodContent;if(s&&i)return oe.vodStartPlayback.path(s,i,n)}break;case oe.tvContentWall.id:if(t.internalReference.tvContent?.channelId)return oe.tvContentWall.path(t.internalReference.tvContent.channelId);break;case oe.tvStartPlayback.id:if(t.internalReference.tvContent?.channelId)return oe.tvStartPlayback.path(t.internalReference.tvContent?.channelId);break;case oe.appSections.id:if(t.internalReference.appSectionId)return oe.appSections.path(t.internalReference.appSectionId);break;case oe.searchPage.id:if(t.internalReference.searchString)return oe.searchPage.path(t.internalReference.searchString);break;case oe.subscriptionShopSubscribe.id:return oe.subscriptionShopSubscribe.path(t.internalReference.subscriptionShop);case oe.subscriptionShopManage.id:return oe.subscriptionShopManage.path;default:ra.debug("Unsupported internal reference:",t.internalReference)}return""},Db=t=>t.map(e=>({...e,internalUrl:Xr(e)})),oa=H("promo-elements"),kb=(t,e)=>{let s=e.filter(l=>!!(l.renderingMethods||[]).find(({method:c})=>mg.includes(c)));s=s.map(l=>{const c=(l.actionMethods||[]).filter(d=>{const u=l.internalReference?.vodContent;return d.method===Ci.internalRef&&u?Tt(t).includes(u.source)&&l.internalReference?.screenId?.startsWith("vod-"):!0});return{...Pb(l),renderingMethods:Ie(l.renderingMethods||[]),actionMethods:Ie(c||[]),internalUrl:Xr(l)}}),s=s.filter(l=>(l.actionMethods||[]).length);const i=l=>!!l.renderingDataJson&&(l.renderingMethods||[]).find(c=>Object.values(lr).includes(c.method)),n=l=>(l.renderingMethods||[]).find(c=>qt.plainImage===c.method),r=l=>{const c=(l.renderingMethods||[]).sort((d,u)=>(d.priority||0)-(u.priority||0))[0]?.method;return[qt.plainImage1x1,qt.plainImage16x9,qt.plainPoster].includes(c)},o=l=>(l.renderingMethods||[]).find(c=>qt.textButton===c.method);s=Db(s);const a=s.reduce((l,c)=>{let d=ai.default;return c.placementBlocks?c.placementBlocks.forEach(({blockId:u,priority:h})=>{(i(c)||n(c)||r(c)||o(c))&&(d=u,c.priority=h,l[d]=l[d]||[],l[d].push(c))}):(l[d]=l[d]||[],l[d].push(c)),l},{});return Object.entries(a).reduce((l,[c,d])=>(l[c]=d.sort((u,h)=>(u.priority||0)-(h.priority||0)),l),{})},Pb=t=>{const e={...t};return t.images?.forEach(s=>{switch(s.imageType){case"plain-1x1":e.plainImage1x1=s.imageURL;break;case"plain-16x9":e.plainImage16x9=s.imageURL;break;case"plain-16x4":e.plainImage16x4=s.imageURL;break;case"background-16x9":e.background16x9=s.imageURL;break;case"poster-7x10":e.plainPoster=s.imageURL;break;case"title-logo-15x4":e.titleLogo15x4=s.imageURL;break;case"source-icon-3x2":e.sourceIcon3x2=s.imageURL;break}}),e},Ob=async(t,e)=>{$e(t)||await tt(t,e);const s=$e(t),i=await Dy(s,{languageCode:t.languageCode,ctx:e}),n=i.length;if(!n){oa.info("Promo elements loaded: 0"),t.promoElements.isBannersDataLoaded=!0;return}t.promoElements.items=kb(t,i),t.promoElements.isBannersDataLoaded=!0,oa.info("Promo elements loaded:",n)},aa=H("home-actions"),Qr=async(t,e)=>{if(sc(t)){aa.info("Banners are already loading...");return}if(tc(t)){aa.debug("Banners have already been loaded");return}t.promoElements.isBannersDataLoading=!0,await Ob(t,e),t.promoElements.isBannersDataLoading=!1},Mb=Object.freeze(Object.defineProperty({__proto__:null,loadBanners:Qr},Symbol.toStringTag,{value:"Module"})),Zd=t=>t.popupNotices.elements.map(e=>e.id),eu=t=>t.popupNotices.contextToken,Jr=t=>t.popupNotices.currentElement,Zr=t=>t.popupNotices.currentElement?.renderingMethods?.[0]?.method,Nb=t=>t.popupNotices.currentElement?.actionMethods?.[0]?.method,tu=t=>!!Jr(t)&&Zr(t)===jt.defaultPopup&&!!yc(t),su=t=>!!Jr(t)&&Zr(t)===jt.windowBgPopup,Fb=t=>t.popupNotices.showTimeMs,Ub=Object.freeze(Object.defineProperty({__proto__:null,contextTokenSelector:eu,currentElementActionMethodSelector:Nb,currentElementRenderingMethodSelector:Zr,currentElementSelector:Jr,elementsSelector:Zd,isPopupNoticeImageModalVisible:su,isPopupNoticeRegularModalVisibleSelector:tu,startTimeSelector:Fb},Symbol.toStringTag,{value:"Module"})),iu=H("utm-labels-actions"),Bb=(t,e)=>{iu.debug("utmLabels",e),t.utmLabels=e},eo=t=>{iu.debug("resetUtmLabels"),t.utmLabels=null},$b=Object.freeze(Object.defineProperty({__proto__:null,resetUtmLabels:eo,setUtmLabels:Bb},Symbol.toStringTag,{value:"Module"})),St=H("notices-actions"),Hi=async(t,e)=>{if(Lr(t)===!1)return;let s=$e(t);s||(await tt(t,e),s=$e(t));const i=await Ay(s||"",{ctx:e,languageCode:t.languageCode});i&&(t.popupNotices.elements=i.map(n=>({...n,renderingMethods:Ie((n.renderingMethods||[]).filter(r=>hg.includes(r.method))),actionMethods:Ie((n.actionMethods||[]).filter(r=>kl.includes(r.method)))}
3)).filter(n=>n.renderingMethods.length&&!!n.placementBlocks?.find(({blockId:r})=>r==="default")))},Vb=async(t,e)=>{if(Lr(t)===!1)return;const s=Ql(t),i=Jl(t),n=location.href.includes("/watch"),r=location.href.includes("/adult"),o=Br(t),a=Zl(t),l=bd(t),c=!t.popupNotices.showTimeoutId&&!Ee(t)&&!s&&!i&&(!n||n&&o)&&(!l||l&&o)&&!r&&!t.popupNotices.currentElement&&!a;if(Ee(t)||(St.info("tryToShow",{readyToShow:c}),St.debug("tryToShow",{showTimeout:t.popupNotices.showTimeoutId,isAnyModalOpen:s,isAnyComplexNotificationVisible:i,isAnyNoticeOpen:!!t.popupNotices.currentElement,isWatch:n,isAdult:r,isPlayerVisible:l,isPlayerMinimized:o,isReviewVisible:a})),c)try{const{promoElement:d,contextToken:u}=await nu(t,e);t.popupNotices.contextToken=u,d&&(t.popupNotices.currentElement=d,(tu(t)||su(t))&&Ld(t),await Gn(t,e,"show"),t.popupNotices.sendTimeoutStatId&&clearTimeout(t.popupNotices.sendTimeoutStatId),t.popupNotices.sendTimeoutStatId=setTimeout(async()=>{await Gn(t,e,"timeout"),to(t),eo(t)},18e5))}catch(d){St.error(d)}},to=t=>{t.popupNotices.currentElement=null,Rd(t),t.popupNotices.sendTimeoutStatId&&clearTimeout(t.popupNotices.sendTimeoutStatId),ru(t),t.siteConfig?.popupNotices?.interval?St.info(`close, next show will be in ${t.siteConfig.popupNotices.interval} minutes`):St.warn("the time period for blocking Popup Notices was not set in admin")},nu=async(t,e)=>{if(t.popupNotices.elements.length||await Hi(t,e).catch(()=>{}),St.debug("Total popup notices:",t.popupNotices.elements.length),t.popupNotices.elements.length){const s=Zd(t),i=await Iy({ctx:e,languageCode:t.languageCode,data:{id:s,contextToken:eu(t)}});if(St.debug("Filtered popup notices:",s.length,"to show:",i),i&&!i.noNoticesToShow){const n=t.popupNotices.elements.find(r=>r.id===i?.promoElementId);if(n)return n.renderingData=JSON.parse(n.renderingDataJson),n.renderingData.footerTextMd&&(n.renderingData.footerText=Nl(n.renderingData.footerTextMd)),{promoElement:n,contextToken:i.contextToken}}}return{promoElement:null,contextToken:""}},Gn=async(t,e,s)=>{t.popupNotices.currentElement&&await Ly({ctx:e,languageCode:t.languageCode,data:{actionType:s,promoElementId:t.popupNotices.currentElement.id,onscreenTimeMs:Date.now()-t.popupNotices.showTimeMs,contextToken:t.popupNotices.contextToken}})},Gb=(t,e)=>{t.popupNotices.currentElement&&Ry({ctx:e,languageCode:t.languageCode,data:{actionType:"exit",promoElementId:t.popupNotices.currentElement.id,onscreenTimeMs:Date.now()-t.popupNotices.showTimeMs,contextToken:t.popupNotices.contextToken}})},ru=t=>{t.popupNotices.showTimeoutId=setTimeout(()=>{t.popupNotices.showTimeoutId=null,St.info("Popup Notices are unlocked")},Dt(t.siteConfig?.popupNotices?.interval,"minute"))},Hb=(t,e)=>{t.popupNotices.showTimeMs=e},Kb=async(t,e,s,i,n)=>{const r=Ee(t),o=Xr(n);if(o&&n.internalReference?.screenId){const l=[oe.tvStartPlayback.id,oe.vodStartPlayback.id].includes(n.internalReference.screenId);r&&l?(t.notifications.complex.authAndReg.returnUrl=o||"",vt.notifications.showAuthAndRegNotification(t)):await s.push(o),l||eo(t)}},Wb=Object.freeze(Object.defineProperty({__proto__:null,close:to,findPromoElementToShow:nu,handleInternalRef:Kb,loadPopupNotices:Hi,reportAction:Gn,reportExitAction:Gb,setShowTimeMs:Hb,startShowTimeout:ru,tryToShow:Vb},Symbol.toStringTag,{value:"Module"})),_t=H("tokens-v2-actions"),ou=t=>{const e=Rr(t);t.tokensV2?.regularUpdate&&e&&(t.tokensV2.regularUpdate.intervalSec=e<=0?1:e)},Ki=t=>{t.tokensV2.timeout&&(clearTimeout(t.tokensV2.timeout),t.tokensV2.timeout=null)},so=(t,e)=>{if(ou(t),!t.tokensV2?.regularUpdate?.intervalSec){_t.warn("Cannot set timeout for Tokens v2: regularUpdate.intervalSec is not set");return}Ki(t);const s=Rr(t)||1,i=Math.floor(Math.random()*(s*2-s)+s);t.tokensV2.timeout=setTimeout(async()=>{t.tokensV2.loaded=!1,t.tokensV2.loading=!1,await au(t,e)},i*1e3),_t.info("Asset Tokens will be updated in",i,"seconds")},et=t=>{Nt(t)?(Ki(t),t.tokensV2.contextToken="",t.tokensV2.assetTokens=void 0,t.tokensV2.loaded=!1,t.tokensV2.loading=!1):(t.tokensV1.expiresAt="",me.remove(Te.analyticsToken),t.tokensV1.analyticsToken="",me.remove(Te.audie
3nceToken),t.tokensV1.audienceToken="",me.remove(Te.tvAssetToken),t.tokensV1.tvAssetToken="",t.tokensV1.loaded=!1,t.tokensV1.loading=!1)},tt=async(t,e)=>{const s={ctx:e,languageCode:t.languageCode};Nt(t)?await mi(t,s):await wc(t,s)},mi=async(t,e)=>{if(Cc(t))return _t.info("Asset Tokens v2 were already loaded"),null;if(_c(t))return _t.info("Asset Tokens v2 are already loading right now"),null;t.tokensV2.loading=!0;let s;try{s=await Zy(e),t.tokensV2.loaded=!0}catch{s=null,t.tokensV2.loaded=!1}finally{t.tokensV2.loading=!1}s===null||!s?.regularUpdate?.intervalSec||(t.tokensV2.assetTokens=s.assetTokens,t.tokensV2.contextToken=s.contextToken,t.tokensV2.regularUpdate=s.regularUpdate,_t.info("Asset Tokens v2 were successfully loaded"),so(t,e))},au=async(t,e)=>{if(!Nt(t))return null;const s=Lc(t);if(!s){await mi(t,e);return}t.tokensV2.loading=!0;let i;try{i=await eS(s,e),t.tokensV2.loaded=!0}catch(n){if(i=null,t.tokensV2.loaded=!1,n.code===ge.BAD_REQUEST){t.tokensV2.loading=!1,t.tokensV2.contextToken="",Ki(t),await mi(t,e);return}}finally{t.tokensV2.loading=!1}if(i){const n=i?.contextToken,r=i?.regularUpdate?.etag;if(n&&n!==s&&r&&r!==Rc(t)){const o={...t.tokensV2.assetTokens};t.tokensV2.assetTokens=i.assetTokens,t.tokensV2.contextToken=i.contextToken,t.tokensV2.regularUpdate=i.regularUpdate;const a=[];o?.audienceToken!==i.assetTokens?.audienceToken&&a.push(Yb(t,e.ctx)),o?.tvAssetToken!==i.assetTokens?.tvAssetToken&&a.push(qb(t,e.ctx));try{await Promise.all(a)}catch(l){_t.error(l)}}else _t.info("contextToken or etag did not change, no need to update tokens' data")}so(t,e)},qb=async(t,e)=>{ro(t),ao(t),t.flags.tvDataState.loaded=!1;const s=[no(t,e),jr(t,e),qi(t,e),oo(t,e)];await Promise.all(s)},Yb=async(t,e)=>{t.promoElements.items={},t.promoElements.isBannersDataLoaded=!1,t.popupNotices.elements=[],t.appSections.sections=[],t.vod.states.isAnyHomeCollectionLoaded=!1,t.vod.states.isAnyHomeCollectionLoading=!1,t.vod.homeCollections=[],t.vod.sourceCollections=[];const s=[$i(t,e),qi(t,e),zr(t,e),Qr(t,e),Hi(t,e)];ee.siteConfig.subscriptionShopEnabledSelector(t)&&(t.qs.shopSubscriptions=[],s.push(Yr(t,e))),await Promise.all(s)},jb=Object.freeze(Object.defineProperty({__proto__:null,clearTokensTimeout:Ki,loadAssetTokens:tt,loadAssetTokensV2:mi,removeAssetTokens:et,setTokensTimeout:so,updateAssetTokensV2:au,updateIntervalSec:ou},Symbol.toStringTag,{value:"Module"})),Xe=H("tv-channels"),lu=[{id:"",title:fe.all},{id:"",title:fe.available},{id:"",title:fe.favourite},{id:"",title:fe.recentlyWatched},{id:"",title:fe.recommended}],cu=async(t,e)=>{Ee(t)||(t.tvChannels.channelsNotForPurchase=await U0({languageCode:t.languageCode,ctx:e}))},Wi=(t,e)=>{t.tvChannels.loaded=e},As=(t,e)=>{t.tvChannels.loading=e},io=(t,e)=>{t.tvChannels.recentAndFavLoaded=e},yi=(t,e)=>{t.tvChannels.recentAndFavLoading=e},no=async(t,e)=>{if(t.flags.tvDataState.loaded){Xe.debug("TV data has already been loaded");return}if(t.flags.tvDataState.loading){Xe.warn("TV data is already loading right now...");return}const s=Date.now();t.flags.tvDataState.loading=!0,As(t,!0),Pt(t)||await tt(t,e);const{genresResponse:i,channelsResponse:n}=await B0(t.languageCode,e,Pt(t));t.tvChannels.genres=[...lu,...i],t.tvChannels.list=n,t.flags.tvDataState.loading=!1,t.flags.tvDataState.loaded=!0,As(t,!1),Wi(t,!0),Xe.info(`All TV data has been loaded - ${Date.now()-s}ms`)},du=async(t,e,s="")=>{if(Gl(t)||Hl(t))return;As(t,!0),!Pt(t)&&le().isSmotreshka&&await tt(t,e);const i=await ac({languageCode:t.languageCode,ctx:e,params:{session:s},tvAssetToken:Pt(t)}).then(n=>(Wi(t,!0),n)).catch(n=>(Xe.error(n),{channels:{},genres:[]})).finally(()=>{As(t,!1)});t.tvChannels.list=i?.channels||[],Xe.info("TV channels have been loaded"),i?.genres.length&&(t.tvChannels.genres=[...i.genres,...lu],Xe.info("TV genres have been loaded"))},ro=t=>{t.tvChannels.list={}},oo=async(t,e)=>{if(Kl(t)||Wl(t))return;yi(t,!0);const s=await lc({languageCode:t.languageCode,ctx:e});t.tvChannels.favorites=s?.favouriteChannels||{},t.tvChannels.recentlyWatched=s?.recentlyWatchedChannels||{},yi(t,!1),io(t,!0),Xe.info("Recent and favorite channels were loaded")},ao=t=>{io(t,!1),yi(t,!1),t.tvChannels.favorites={},t.tvChannels.recentlyWatched={}},zb=async(t,e)=>{ks(t.tvChannels.recommended)&&(t.tvChannels.recommended=await F0({languageCode:t.languageCode,ctx:e}))},uu=t=>{t.tvChannels.recommended={}},Xb=Tl((t,e)=>{const s=pr(t);s[e]&&(Rp(e,s),t.tvChannels.recentlyWatched=s),t.tvChannels.recentlyWatched={[e]:ap(Ps(t),e),...s}},Rl.tv.channelSwitchDelay,{leading:!1,trailing:!0}),hu=(t,e)=>{t.tvChannels.currentGenre=e,Xe.info("selectGenre",e)},fu=t=>{hu(t,fe.recommended),Ce.set("genre",fe.recommended),Xe.info("resetGenre to DEFAULT = __RECOMMENDED__")},Qb=async(t,e,s)=>{const i=!!mr(t)[s];i?await M0(s,{languageCode:t.languageCode,ctx:e}):await O0(s,{languageCode:t.languageCode,ctx:e}),yt({...Pi(t),action:i?"УдалиÑÑ Ð¸Ð· избÑанного":"ÐобавиÑÑ Ð² избÑанное",channel_name:s,control_type:"mouse"},t);const{favouriteChannels:n}=await lc({languageCode:t.languageCode,ctx:e});t.tvChannels.favorites=n||[],await fi(t,"tv",!i,gt(ki(t,s||"")))},Jb=(t,e,s=!0)=>{Ni(t,gu(t,e,s))},gu=(t,e,s=!0)=>{const i=`channel_${s?"about":"epg"}_meta_title`;return(Je(t.translations[i],t.languageCode,t.defaultLanguageCode)||i).replace(/%channelName%/g,gt(ki(t,e))||"")},Zb=(t,e)=>{Ni(t,pu(t,e))},pu=(t,e)=>{const s=`tv_${e?"now":"list"}_meta_title`;return Je(t.translations[s],t.languageCode,t.defaultLanguageCode)||s},qi=async(t,e)=>{if(t.tvChannels.isSettingsLoading)return;$e(t)||await tt(t,e);const s=$e(t),i=Pt(t);t.tvChannels.isSettingsLoading=!0;try{const n=await $0({languageCode:t.languageCode,ctx:e,params:{"audience-token":s,"tv-asset-token":i}});n&&(t.tvChannels.clientPlatform=n.clientPlatform,t.tvChannels.settings=n.channels?.reduce((r,o)=>(r[o.channelId]=o.playerParams.reduce((a,l)=>(a[l.name]=l.value,a),{}),r),{})||{})}catch(n){Xe.error(n)}finally{t.tvChannels.isSettingsLoading=!1}},ex=Object.freeze(Object.defineProperty({__proto__:null,buildChannelMetaTitle:gu,buildChannelsCatalogMetaTitle:pu,getChannelsNotForPurchase:cu,loadChannelsAndGenres:du,loadExternalPlayerSettings:qi,loadRecentAndFavChannels:oo,loadRecommendedChannels:zb,loadTvData:no,resetChannels:ro,resetGenre:fu,resetRecentAndFavChannels:ao,resetRecommendedChannels:uu,selectGenre:hu,setChannelMetaTitle:Jb,setChannelsCatalogMetaTitle:Zb,setChannelsLoaded:Wi,setChannelsLoading:As,setChannelsRecentAndFavLoaded:io,setChannelsRecentAndFavLoading:yi,toggleChannelFavorite:Qb,updateRecentlyWatched:Xb},Symbol.toStringTag,{value:"Module"})),tx=t=>t.pauses.vod.loaded,mu=t=>t.pauses.vod.loading,sx=t=>t.pauses.vod.hasMorePausesToLoad,lo=t=>t.pauses.vod.items,ix=t=>lo(t).filter(e=>vu(t,e)).map(e=>
3Tu(t,e)),nx=Object.freeze(Object.defineProperty({__proto__:null,pausesVodHasMorePausesToLoadSelector:sx,pausesVodItemsFilteredSelector:ix,pausesVodItemsSelector:lo,pausesVodLoadedSelector:tx,pausesVodLoadingSelector:mu},Symbol.toStringTag,{value:"Module"})),ii=H("pauses"),yu=async(t,e,s=!1,i=vs)=>{if(Ee(t))return;if(mu(t)){ii.info("VOD Pauses are already loading...");return}const n=s?0:lo(t).length;try{t.pauses.vod.loading=!0;const r=await Ey({languageCode:t.languageCode,ctx:e,params:{limit:i,offset:n}});s&&(t.pauses.vod.items.length=0),t.pauses.vod.items=[...t.pauses.vod.items,...r],t.pauses.vod.hasMorePausesToLoad=r.length===i,t.pauses.vod.loaded=!0}catch(r){ii.error(r)}finally{ii.info("VOD pauses have been loaded, count:",t.pauses.vod.items.length),t.pauses.vod.loading=!1}},Su=t=>{t.pauses=Al,t.pauses.vod.items.length=0},vu=(t,{sourceId:e})=>Tt(t).includes(e),Tu=(t,e)=>{const s=rx(e),i=e.sourceId==="archive"?li("archive",e.titleId,e.episodeId,e.mediaItemId):li(e.sourceId,e.titleId,e.episodeId);let n="",r=0;return e.totalDurationMsec&&(n=hr(t,kt(e.totalDurationMsec,"millisecond")),e.msecFromStart&&(r=Math.max(e.msecFromStart/e.totalDurationMsec,0))),{id:e.id,title:e.shortData?.title||"",link:i,image:s,duration:n,timelinePosition:r,sourceId:e.sourceId,titleId:e.titleId,episodeId:e.episodeId,mediaItemId:e.mediaItemId,msecFromStart:e.msecFromStart}},rx=t=>{let e="",r=0,o=0,a="",l="portrait";const c=t.shortData?.image;if(!c)return{src:e,width:r,height:o,type:a,orientation:l};if(t.sourceId==="archive"&&(l="landscape",c?.aspectRatio)){const d=c.aspectRatio.split(":").map(h=>parseInt(h,10)),u=ep(180,132,d[0],d[1]);r=u.width,o=u.height}return c&&(e=c.path,a=c.type,!r&&!o&&(l==="portrait"?(r=Math.round(132*.7),o=132):(r=180,o=132))),{src:e,width:r,height:o,type:a,orientation:l}},ox=async(t,e,s,i)=>{try{await xy(s,i,{languageCode:t.languageCode,ctx:e});const n=t.pauses.vod.items.findIndex(o=>o.titleId===i),r=t.pauses.vod.items[n];t.pauses.vod.items.splice(n,1),ed(t,r.shortData?.title||"")}catch(n){ii.error("deleteVodPause",n);const r="error_during_vod_pause_delete",o=Q(t,r)||`{${r}}`;Or(t,o),setTimeout(()=>{Mr(t)},3e3)}},ax=Object.freeze(Object.defineProperty({__proto__:null,deleteVodPause:ox,filterPausesVod:vu,loadVodPauses:yu,preparePauseVodWithPoster:Tu,resetPauses:Su},Symbol.toStringTag,{value:"Module"})),lx=H("auth"),Ns=async(t,e,s)=>{uo(t),await dx(t,e,s),Nr(t),await zi(t,e),await $i(t,e),await Kr(t,e)},cx=(t,e=!0,s="")=>{if(!le().isSmotreshka)return;if(!t){lx.warn("Could not set Adv.Cake data; userId is undefined");return}const i=e?"авÑоÑизаÑиÑ":"ÑегиÑÑÑаÑиÑ";window.advcake_data=window.advcake_data||[],window.advcake_data.push({pageType:6,user:{email:t,type:""},leadInfo:{id:me.get(Te.advCake),name:i,totalPrice:"0",coupon:s}})},dx=async(t,e,s)=>{r0(s),await Yi(t,e),Bi(t),et(t)},Yi=async(t,e,s)=>{const i={languageCode:t.languageCode,ctx:e};
3s&&(i.params={token:s});const n=await oc(i);n&&(t.account=n)},ux=async(t,e)=>{const{languageCode:s}=t,i=await oc({languageCode:s,ctx:e}),n=i?.id;n&&n!==t.account?.id?t.account=i:!n&&t.account&&t.feSessionId&&Eu(t)},hx=async(t,e,s,i)=>{const{languageCode:n}=t,o=await x0({ctx:e,languageCode:n,data:{email:s,password:i}});o&&await Ns(t,e,o)},fx=async(t,e,s)=>{const{languageCode:i}=t;Bi(t),et(t),await A0({ctx:e,languageCode:i,data:{code:s}}),await tt(t,e)},gx=async(t,e)=>{Eu(t);const{languageCode:s}=t;await I0({ctx:e,languageCode:s}),window.location.href=ci(t,"/")},Eu=t=>{sd(t),to(t),kd(t),localStorage.removeItem("tab"),me.set(Te.profileConfirmed,"0"),me.set(Te.welcomeScreenConfirmed,"0"),me.remove(Te.profileConfirmationPeriod),nc(),t.account=Ll},px=async(t,e)=>{const{languageCode:s}=t;t.availableLogins=await L0({ctx:e,languageCode:s,params:{"contacts-session-token":t.verificationResult.sessionToken}})},mx=async(t,e,s)=>{const{languageCode:i}=t,n=await R0({ctx:e,languageCode:i,params:{"contacts-session-token":t.verificationResult.sessionToken},data:{login:s},timeout:3e4});await Pr(t,e),n&&await Ns(t,e,n)},yx=async(t,e,s)=>{const{languageCode:i}=t;await C0({ctx:e,languageCode:i,params:{"contacts-session-token":t.verificationResult.sessionToken},data:{login:s}})},Sx=async(t,e)=>{const{languageCode:s}=t,i=await D0({languageCode:s,ctx:e});i&&await Ns(t,e,i)},vx=async(t,e,s,i)=>{const{languageCode:n}=t,r={data:{token:i},ctx:e,languageCode:n},o=s===rg.autoLogin18p?await k0(r):await P0(r);o&&await Ns(t,e,o)},Tx=Object.freeze(Object.defineProperty({__proto__:null,autoLoginMegafon:vx,getAccount:Yi,getAvailableLogins:px,login:hx,loginWithVerifiedContacts:mx,logout:gx,qrLogin:fx,recheckAuthState:ux,reloadDataAfterLogin:Ns,sendPassword:yx,setAdvCakeData:cx,uztelAuth:Sx},Symbol.toStringTag,{value:"Module"})),ji=H("profile"),Ex=(t,e)=>{t.profiles.currentAction=e},bx=(t,e)=>{t.profiles.profileIdToDelete=e},Is=(t,e)=>{ji.info("isProfileLoading",e),t.profiles.isProfileLoading=e},Ls=(t,e)=>{ji.info("isProfileLoaded",e),t.profiles.isProfileLoaded=e},xx=(t,e)=>{t.profiles.profileSelected=e},bu=async(t,e)=>{if(t.qs.subscriptionShop.isLoading=!0,Cd(t),uo(t),await zi(t,e),await $i(t,e),!Ee(t)){if(await Yi(t,e),await Kr(t,e),await oo(t,e),ee.siteConfig.subscriptionShopEnabledSelector(t))try{await Yr(t,e),await Qd(t,e)}catch(s){ji.error(s)}await yu(t,e)}await tt(t,e),t.qs.subscriptionShop.isLoading=!1},xu=async(t,e,s)=>{Is(t,!0),Ls(t,!1);try{await Cy({languageCode:t.languageCode,ctx:e,...s}),await bu(t,e),t.account.profile=(t.account.profiles||[]).find(i=>i.id===s?.data.Id),ho(t)}finally{Ls(t,!0),Is(t,!1)}},Ax=async(t,e,s,i)=>{Ls(t,!1),Is(t,!0);try{await _y(s,{languageCode:t.languageCode,ctx:e,...i}),s===t.account?.profile?.id&&t.account?.profile?.restriction!==i?.data["Restriction.Id"]&&(await bu(t,e),ho(t))}catch(n){throw ji.error(n),n}finally{Ls(t,!0),Is(t,!1)}},Au=async(t,e)=>{t.profileRestrictions=await wy({languageCode:t.languageCode,ctx:e})},Ix=async(t,e,s)=>{await xu(t,e,{data:{Id:s.id,Pin:""}})},Lx=Object.freeze(Object.defineProperty({__proto__:null,change:xu,changeProfileWithoutPin:Ix,getProfileRestrictions:Au,setCurrentAction:Ex,setIdToDlete:bx,setIsProfileLoaded:Ls,setIsProfileLoading:Is,setProfileSelected:xx,update:Ax},Symbol.toStringTag,{value:"Module"})),Rx=H("server-utils");function Cx(t){const e={};for(const s of t){const{type:i,componentName:n}=s;if(!i||!n){Rx.error("Cannot proceed preparing the component. Invalid (empty) type or componentName",s);continue}const r=ir(s.content);e[s.componentName]={...s,content:r}}return e}const _x=t=>t.reduce((e,s)=>{const i={from:s.from,to:s.to};return s.regexp?e.regexp.push(i):e.fromPath[s.from]=i,e},{regexp:[],fromPath:{}});function wx(t){return t.map(e=>{const{_id:s,content:i,...n}=e;return{path:e.path,component:{name:`page__${s}`,exact:e.path==="/",template:i},dataObject:{appContainer:null,page:n}}})}const Dx=(t,e)=>{if(!t?.length)return;const s={};return t.filter(i=>i.shouldBeFile).forEach(i=>{s[i.path]=fr(i.fileKey,e)}),s},kx=async t=>t&&(t.appStores||(t.appStores={links:{android:"",ios:"",default:""}
3,patha:"",scheme:""}),t),Px=t=>{const e={...t};return t.trial&&(e.trial=Object.entries(t.trial).reduce((s,[i,n])=>(s[i]=typeof n=="string"?{translationId:n}:n,s),{})),e},Ox=async t=>{t.fileRecords={items:await W0()}},Iu=async t=>{t.contentBlocks.items=await G0()},Mx=Object.freeze(Object.defineProperty({__proto__:null,loadContentBlocks:Iu},Symbol.toStringTag,{value:"Module"})),co=H("common-actions"),Nx=t=>{t.common.localTime=Date.now()},Lu=(t,e)=>{t.common.needServerTimeSync=e},Fx=(t,e)=>{t.common.isOffline=e},Ux=(t,e)=>{t.common.isHeaderAboveContent=e},Bx=t=>{t.common.isHeaderTransparent=!0},$x=t=>{t.common.isHeaderTransparent=!1},Ru=async t=>{t.translations=await X0()},Cu=async t=>{const e=await J0();t.siteConfig=await kx(e)},Vx=async t=>{const e=await q0();e?.pages&&(t.cmsPages=wx(e?.pages),t.pageFolders=e.pageFolders,t.filePages=Dx(e.pages,t.fileRecords.items)||{})},Gx=async t=>{const e=await V0();t.components=e?Cx(e):{}},Hx=async t=>{const e=await cy();t.seoRules=e||{}},Kx=async(t,e,s="")=>{if(e?.baseUrl==="/provider"||s==="/provider")return;const i=Date.now();await _u(t,e,s),co.debug(`preloadData - ${Date.now()-i}ms`)},_u=async(t,e,s="")=>{ic(e)?.session===""&&!Ee(t)&&(nc(),t.account=Ll),await Cu(t);const n=[Yi(t,e),new Promise(r=>{r(Iu(t))}),new Promise(r=>{r(Ox(t))}),new Promise(r=>{r(Ru(t))}),new Promise(r=>{r(Hx(t))}),new Promise(r=>{r(Gx(t))}),zi(t,e,s==="/provider"),new Promise(r=>{r(Vx(t))})];await Promise.all(n)},zi=async(t,e,s=!1)=>{const i=[tt(t,e),wu(t,e),od(t,e),Au(t,e)];await Promise.all(i);const n=[no(t,e),qi(t,e),cu(t,e)];s||(n.push(Qr(t,e).catch(r=>{co.error(r)})),Ee(t)||n.push(Hi(t,e).catch(()=>{})),n.push(zr(t,e))),await Promise.all(n)},uo=t=>{co.info("resetAllData was triggered"),t.promoElements.items={},t.promoElements.isBannersDataLoaded=!1,t.vod.states.recommendationsLoaded=!1,t.qs.shopSubscriptions=[],t.qs.availableSubscriptions=[],t.tvEpgV2.onAir.isLoaded=!1,t.flags.tvDataState.loaded=!1,ro(t),Bn(t),Bi(t),et(t),Wi(t,!1),t.account.profile=void 0,fd(t),fu(t),Bn(t),Su(t),dd(t),ao(t),uu(t)},Wx=t=>{t.common.bodyScrollLockCount=0,document?.body?.classList.remove("locked-scroll")},qx=t=>{t.common.bodyScrollLockCount++,document?.body?.classList.contains("locked-scroll")||document?.body?.classList.add("locked-scroll")},ho=t=>{Un(t)>0&&t.common.bodyScrollLockCount--,Un(t)<=0&&document?.body?.classList.remove("locked-scroll")},Yx=async t=>{const e=await sy();t.languages=e,t.languageCode=hp(e),t.defaultLanguageCode=e.find(s=>s.isDefault)?.code||""},jx=async t=>{const e=await Promise.all([z0(),Z0(),Q0(),ey(),ty(),ny(),ry(),oy(),ay(),dy(),uy(),hy(),fy()]),[s,i,n,r,o,a,l,c,d,u,h,f,g]=e;return t.branding2=i,t.theme=t.branding2?.colorPalette2?.darkTheme?"dark":"light",t.header=r,t.footer=o,t.authAndReg=Px(n||xl),t.qsConfig=a,t.brandingMethods=l,t.homeScreenConfig=h,t.personalArea=c,t.reviews=d,t.styles=f,{archives:s,headCustomCode:g,redirects:_x(u||[])}},zx=Object.freeze(Object.defineProperty({__proto__:null,actualizeLocalTime:Nx,loadCmsDataNoSsr:jx,loadData:_u,loadLanguages:Yx,loadSiteConfig:Cu,loadTranslations:Ru,lockBodyScroll:qx,makeHeaderOpaque:$x,makeHeaderTransparent:Bx,preloadData:Kx,preloadDataFe:zi,resetAllData:uo,resetHowManyTimesBodyScrollWasLocked:Wx,setHeaderAboveContent:Ux,setIsOffline:Fx,setNeedServerTimeSync:Lu,unlockBodyScroll:ho},Symbol.toStringTag,{value:"Module"})),wu=async(t,e)=>{try{t.appInfo=await E0({languageCode:t.languageCode,ctx:e}),t.appInfo?.currentTime&&(t.common.serverTime=t.appInfo.currentTime)}catch{}},Xx=t=>{if(t.appInfo?.currentTime){const e=Date.now()-t.common.localTime,i=Le().unix()-t.common.serverTime;(e<0||e>Dt(10,"minute"))&&Lu(t,!0),t.common.localTime+=e,t.appInfo.currentTime+=Math.round(kt(e,"millisecond")),i>=60&&(t.common.serverTime=t.appInfo.currentTime)}},Qx=Object.freeze(Object.defineProperty({__proto__:null,incrementServerTime:Xx,loadAppInfo:wu},Symbol.toStringTag,{value:"Module"})),Jx=(t,e)=>{const s=e.sort((n,r)=>n?.priority-r?.priority)[0]?.name,i=t.brandingMethods?.find(n=>n.customId===lg);if(!s)return i?.options;if(s&&t.brandingMethods&&t.brandingMethods.length>0){const n=t.brandingMethods?.find(r=>r.customId===s);return n?n?.options:i?.options}return[]},Zx=Object.freeze(Object.defineProperty({__proto__:null,getCurrentBrandingMethods:Jx},Symbol.toStringTag,{value:"Module"})),eA=(t,e)=>{t.gaParams={...t.gaParams,...e}},tA=Object.freeze(Object.defineProperty({__proto__:null,setGaParams:eA},Symbol.toStringTag,{value:"Module"})),la=H("packages"),sA=async(t,e,s)=>{if(!t.packages.items.length){const i=await ly()||{items:[]};t.packages.items=await Promise.all(i.items.filter(n=>n.page===s).map(async n=>{const o=(await dc(n.id,{ctx:e,languageCode:t.languageCode}).catch(c=>{la.error("getOfferChannels:",c)}))?.channels,l=(await Ty(n.id,{ctx:e,languageCode:t.languageCode}).catch(c=>{la.error("getOffer:",c)}))?.preview?.price||"";return{...n,price:!l||l==="0"?"":l,channels:o||[]}}))}},iA=Object.freeze(Object.defineProperty({__proto__:null,loadPackages:sA},Symbol.toStringTag,{value:"Module"})),nA=t=>{const e=Bu(t);return e&&e.length>0&&!Ou(t)&&!po(t)&&!go(t)},Fs=t=>{const e=["qs21-yakassa","qs20-tv-default","qs10-legacy-default"],s=yo(t);if(!s?.subscriptionOptions)return[];const i=s.subscriptionOptions.filter(({renderingMethods:n})=>!!(n||[]).find(r=>e.includes(r.name)));return ku(i,t)},Du=t=>{const e=Uu(t);return e?.subscriptionOptions?ku(e.subscriptionOptions,t):[]},ku=(t,e)=>t.map(s=>{let i=s.channels||[];return!i.length&&s.channelsIds?.length&&(i=vl(Object.values(e.tvChannels.list),s.channelsIds,(n,r)=>n.id===r),s.channels=i),{...s,trialAvailable:e.registration.disableTrials?!1:s.trialAvailable,channels:i.map(op),channelsIds:i.map(n=>n.id),trialDays:Ai(s.trialDurationSeconds,"second"),trialChannels:s.trial?.channels||[],id:s.offerId}}),rA=t=>Fs(t)?.find(i=>
3i.trialAvailable)&&!go(t)&&!po(t),fo=t=>t.registration.currentOfferId,Pu=t=>{const e=Fs(t),s=fo(t);return e?.find(i=>i.id===s)},oA=t=>t.registration.confirmationUrl,Rs=t=>t.registration.autoTrialStatus,aA=t=>Ai(t.registration.autoTrialDuration,"second"),go=t=>Rs(t)===Qt.created,Ou=t=>Rs(t)===Qt.unknown||Rs(t)===null,po=t=>Rs(t)===Qt.processStarted,Us=(t,e,s,i)=>{const n=t.authAndReg?.trial?.[e];if(!n)return"";let r=n.translationId?Q(t,n.translationId):"";return s&&n.variables?.forEach(o=>{if(s[o])if(o==="vodAvailable"){const a=Tt(t),c=Fs(t)?.find(h=>h.id===i),d=c?.renderingData?.[o]||"",u=c?.vodSources?.filter(h=>a.indexOf(h)>=0)?.map(h=>Q(t,h)).join(", ");r=`${d.split(":")[0]}`,u&&(r=`${r}: ${u}`)}else r=r.replace(`@${o}@`,s[o]);else r=""}),r},lA=(t,e)=>Us(t,"badge",e),cA=(t,e)=>Us(t,"offerTitle",e),dA=(t,e)=>Us(t,"offerPrice",e),uA=(t,e)=>Us(t,"offerChannelCount",e),hA=(t,e,s)=>Us(t,"offerVodSources",s,e),fA=Object.freeze(Object.defineProperty({__proto__:null,autoTrialDurationSelector:aA,autoTrialStatusSelector:Rs,confirmationUrlSelector:oA,currentOfferIdSelector:fo,currentOfferSelector:Pu,hasAcquiringSelector:nA,hasApplicableTrialsSelector:rA,isAutoTrialStatusProcessStartedSelector:po,isAutoTrialStatusUnknownSelector:Ou,offersSelector:Fs,promoOffersSelector:Du,trialOfferBadgeTextSelector:lA,trialOfferChannelCountsSelector:uA,trialOfferPriceSelector:dA,trialOfferTitleSelector:cA,trialOfferVodSourcesSelector:hA,wasAutoTrialCreatedSelector:go},Symbol.toStringTag,{value:"Module"})),gA=t=>b.get(x.trialRegistrationStatus,t),pA=async(t,e)=>{t.contactsVerification=await di.retry(e)},mA=async(t,e)=>{if(t.authAndReg.useContactVerifyV2&&!e.params?.token&&t.contactsVerification){const s={code:e.data.code,id:t.contactsVerification.id};t.verificationResult=await di.verifyV2({...e,data:s})}else t.verificationResult=await di.verify(e);return t.verificationResult},yA=async(t,e,s,i,n,r={},o=!1,a="",l="")=>{const c=typeof i=="string";let d="startWithAccountSession",u={type:"phone",contacts:si(s,t.authAndReg.usePlusInPhoneMethods.registration),reason:n};o?(d="startRecaptcha",u={type:"phone",contacts:si(s,t.authAndReg.usePlusInPhoneMethods.registration),"g-recaptcha-response":i,reason:n}):c&&(d="start",u={type:"phone",contacts:si(s,t.authAndReg.usePlusInPhoneMethods.registration),captcha:i,reason:n},Ml(t)&&l?r.captchaid=l:u.cookies=a),t.contactsVerification=await di[d]({languageCode:t.languageCode,ctx:e,data:u,params:r})},SA=async(t,e)=>{const s=await _0(e);return t.registrationResult=s,s},vA=async(t,e)=>{const s=await w0(e);return t.registrationResult=s,s},TA=async(t,e,s=!1)=>{t.flags.tvDataState.loaded||await du(t,e);let i=[];s?(await zd(t,{ctx:e,languageCode:ae(t)}),i=Du(t)):(await jd(t,{ctx:e,languageCode:ae(t)}),i=Fs(t)),i[0]&&Mu(t,i[0].id)},Mu=(t,e)=>{t.registration.currentOfferId=e},EA=async(t,e,s="")=>{const i=fo(t),n=Pu(t);if(!n){t.registration.createSubscriptionError="ÐÑÑÐµÑ Ð½Ðµ доÑÑÑпен";return}let r;const o=s?`${location.origin}${ci(t,"/acquiring-status")}?${s}`:`${location.origin}${ci(t,"/acquiring-status")}`,a=await $d(t,{languageCode:t.languageCode,ctx:e,data:{offer_id:i,return_url:o},params:{create_subscription_token:n.createSubscriptionToken}}).catch(async l=>{const d=(await fc({ctx:e,languageCode:ae(t)}))?.find(u=>u.offer.id===i);d?r=d.last_payment.confirmation.confirmation_url:t.registration.createSubscriptionError=l.toString()});a&&(r=a.last_payment.confirmation.confirmation_url),r&&(t.registration.confirmationUrl=r)},bA=t=>{t.registration.disableTrials=!0},ca=t=>{t.registration.autoTrialStatus=Qt.unknown},Nu=async(t,e,s=0,i,n)=>{const r=await gA({languageCode:t.languageCode,ctx:e}).catch(()=>{});if(!r){ca(t);return}if(t.registration.autoTrialStatus=r.status,t.registration.autoTrialDuration=r.duration,r.status===Qt.processStarted)return new Promise((o,a)=>{const l=i||o,c=n||a;t.registration.autoTrialStatus!==Qt.processStarted?l(!0):s>4?(ca(t),c({code:sg})):setTimeout(async()=>{await Nu(t,e,s+1,l,c)},5e3)})},xA=Object.freeze(Object.defineProperty({__proto__:null,createSubscription:EA,disableTrials:bA,loadSubscriptionOptions:TA,loadTrialStatusAfterRegistration:Nu,registerMobileWithToken:vA,registerWithToken:SA,retry:pA,setCurrentOfferId:Mu,verify:mA,verifyContacts:yA},Symbol.toStringTag,{value:"Module"})),mo=H("unsubscription-retention-actions"),AA=(t,e)=>{t.unsubscriptionRetention.isOverlayVisible=!0,t.unsubscriptionRetention.currentSubscription=e,vt.modals.hideAllModals(t)},IA=async(t,e)=>{const s=t.unsubscriptionRetention.currentSubscription,i=await ES({languageCode:t.languageCode,ctx:e,params:{subscriptionId:s?.id,offerId:s?.mainOffer?.offerId,unsubscriptionReasonId:t.unsubscriptionRetention.currentReasonId,unsubscriptionContextToken:t.unsubscriptionRetention.settings?.unsubscriptionContextToken}});if(!i){mo.warn("loadSubscriptionOptions failed");return}t.qs.qsTransactionId=i.qsTransactionId,t.unsubscriptionRetention.hasUnsupportedSubscriptionOptions=!!i.subscriptionOptions?.length,t.unsubscriptionRetention.subscriptionOptions=(await Fu(t,e,i,{hasUnsubscriptionRetention:!0}
3)).subscriptionOptions},LA=async(t,e)=>{const s=t.unsubscriptionRetention.currentSubscription,i=s?.managementMethods?.[0]?.managementContextToken,n={subscriptionId:s?.id,offerId:s?.mainOffer?.offerId,managementMethod:s?.managementMethods?.[0]?.name};if(n.subscriptionId&&n.offerId&&n.managementMethod&&i){const r=await vS({languageCode:t.languageCode,ctx:e,params:n,data:{managementContextToken:i}});if(!r){mo.warn("unsubscriptionRetentionBegin failed");return}r.retentionMethods&&(r.retentionMethods=r.retentionMethods.filter(o=>Tg.includes(o))),t.unsubscriptionRetention.settings=r}else{for(const r in n)if(typeof n[r]>"u")throw new Error(`Required param "${r}" is not set`);throw new Error('"managementContextToken" is not set')}},RA=async(t,e,s,i)=>{const n=t.unsubscriptionRetention.currentSubscription,r=t.unsubscriptionRetention.currentReasonId,o=t.unsubscriptionRetention.settings?.retentionMethods?.[0],a=t.unsubscriptionRetention.settings?.unsubscriptionContextToken;try{await TS({languageCode:t.languageCode,ctx:e,data:{unsubscriptionContextToken:a},params:{subscriptionId:n?.id,offerId:n?.mainOffer?.offerId,retentionMethod:o,unsubscriptionReasonId:r,unsubscriptionResult:s,retentionOfferResult:i}}),Ce.remove(Lt.unsubscriptionRetention)}catch(l){mo.error("unsubscriptionRetentionEnd",l)}},CA=(t,e)=>{t.unsubscriptionRetention.currentSubscription=e.currentSubscription||null,t.unsubscriptionRetention.settings=e.settings||null,t.unsubscriptionRetention.subscriptionOptions=e.subscriptionOptions||null},_A=Object.freeze(Object.defineProperty({__proto__:null,begin:LA,end:RA,loadSubscriptionOptions:IA,setData:CA,start:AA},Symbol.toStringTag,{value:"Module"})),vt={adultOnboarding:CS,appInfo:Qx,appSections:wb,authAndReg:Tx,brandingMethods:Zx,common:zx,contentBlocks:Mx,home:Mb,metrics:tA,modals:BE,notifications:nT,packages:iA,payment:ab,pauses:ax,player:ib,popupNotices:Wb,profiles:Lx,providerInfo:kv,qs:Rb,registration:xA,seo:FS,tokensV1:ev,tokensV2:jb,tvChannels:ex,tvEpgV2:Cb,unsubscriptionRetention:_A,utmLabels:$b,vod:bT},on=H("quick-subscribe"),da=[{name:"TrialAbout"},{name:Pn.CONFIRMED},{name:Pn.ERROR}],ua={component:"TrialQs",steps(t){return{authenticated:[{name:"TrialAbout"},{name:"TrialConfirmed"}],"sub20-phone-collect-instant":da,"sub20-phone-collect-delayed":da}[t.subscriptionMethod?.name||""]},availableSubscriptionMethods:["authenticated","sub20-phone-collect-instant","sub20-phone-collect-delayed"]},xt=[{name:"AboutSubscription",prev:"PaymentRetry"},{name:"SubscriptionDetails"},{name:Pn.ERROR},{name:"PaymentRetry"}],Vt={component:"AcquiringQs",steps(t){return{authenticated:xt,"sub20-yakassa-mvp":xt,"sub20-phone-collect-instant":xt,"sub21-yakassa":xt,[_e.UPSALE]:xt,[_e.UPSALE_V2]:xt,[_e.UPSALE_V21]:xt}[t.subscriptionMethod?.name||""]},availableSubscriptionMethods:["authenticated","sub20-phone-collect-instant","sub20-yakassa-mvp","sub21-yakassa",_e.UPSALE,_e.UPSALE_V2,_e.UPSALE_V21]},Cs={"qs20-yakassa-v2":Vt,"qs21-yakassa":Vt,"qs10-legacy-default":Vt,"qs20-vod-trial":ua,"qs20-tv-trial":ua,"qs20-tv-default":Vt,"qs20-vod-default":Vt,"qs22-promo-offer":Vt,"buy-on-website":{component:"QsFallback"}},wA={"qs22-unsub-retention-offer":{component:"",availableSubscriptionMethods:["authenticated","sub20-phone-collect-instant","sub20-yakassa-mvp","sub21-yakassa",_e.UPSALE,_e.UPSALE_V2,_e.UPSALE_V21]}},DA=(t,e)=>{const s=t.renderingMethod?.name||"";return e[s]?.steps?e[s].steps(t):[]},Fu=async(t,e,s,i)=>{const n=Ie(s.subscriptionOptions||[]),r=i?.hasUnsubscriptionRetention?wA:Cs;let o=[];if(n?.length){if(s.existingSubscriptions?.[0]?.paymentSystemType===bs.Uztelecom){const l=n.find(c=>c.offerId===s.existingSubscriptions?.[0]?.offerId);l&&(l.priority=0)}for(const l of n){const c=ir(l),d=Ie(c.renderingMethods||[]),u=Ie(c.subscriptionMethods||[]);for(const h of d){const f=r[h.name];if(f)for(const g of u){const m=g.name;if(f.availableSubscriptionMethods?.includes(m)){c.renderingMethod=h,c.subscriptionMethod=g;break}}if(c.renderingMethod)break}if(c.renderingMethod&&c.subscriptionMethod){try{const h=JSON.parse(c.renderingDataJson);if(c.renderingData={...h,...ee.qs.renderingDataEnhancedSelector(t,c.renderingMethod.name,h,c.showcaseChannelsCount,c.vodSources,c.trialDurationSeconds)},c.trialAvailable&&c.trial){const f=JSON.parse(c.trial.renderingDataJson);c.trial.renderingData={...f,...ee.qs.renderingDataEnhancedSelector(t,c.renderingMethod.name,f,c.trial.showcaseChannelsCount,c.trial.vodSources,c.trial.trialDurationSeconds)}}}catch(h){on.error(h)}if(!c.trialAvailable){const h=n.filter(f=>{const g=(f.renderingMethods||[]).filter(m=>m.name===oi.BILLING_PERIOD);return c.title===f.title&&g.length});
3h?.length&&(h.forEach(f=>{f.hasDifferentPeriod=!0;try{f.renderingData=JSON.parse(f.renderingDataJson)}catch(g){on.error(g)}}),c.differentPeriods=[c,...h])}await vt.qs.addChannelsToOffer(t,e,c),o.push(c)}}if(!i?.withPromoCode){const l=o?.[0]?.subscriptionMethod?.name||"";o=o.filter(c=>c.subscriptionMethod?.name===l)}}const a=s.fallback;if(!o.length&&!i?.withPromoCode&&a&&!i?.hasUnsubscriptionRetention){a.renderingMethods=Ie((a.renderingMethods||[]).filter(c=>Cs[c.name]));const l=a.renderingMethods;if(l.length){const c={androidInApp:void 0,appleInApp:void 0,createSubscriptionToken:"",images:[],offerId:"",priority:0,shopSettings:void 0,showcaseChannelsCount:0,subscriptionMethods:[],title:"",trial:void 0,trialAvailable:!1,trialDurationSeconds:0,type:"",vodSources:[],...a};try{const d=JSON.parse(c.renderingDataJson);c.renderingData={...d,...ee.qs.renderingDataEnhancedSelector(t,l[0].name,d,c.showcaseChannelsCount,c.vodSources,c.trialDurationSeconds)}}catch(d){on.error(d)}c.renderingMethod=l[0],o.push(c)}else l[0]?.name===oi.OPERATOR_CONTACT_INFO&&vt.notifications.showProviderInfoNotification(t)}return{existingSubscriptions:s.existingSubscriptions,subscriptionOptions:o,steps:o[0]?DA(o[0],r):[],qsTransactionId:s.qsTransactionId,fallback:void 0}},xP=t=>t===rt.WAITING_FOR_CAPTURE||t===rt.SUCCEEDED,AP=async(t,e)=>{if(!t)return"promo_code_offer_id_was_not_set";const s=await Ms(e);if(!s)return"";const i=s?.subscriptionOptions?.find(l=>l.offerId===t);if(!i)return"promo_code_offer_was_not_found";const n=Ie(i.renderingMethods||[]),r=Ie(i.subscriptionMethods||[]);if(!n?.length)return"rendering_methods_were_not_found";if(!n.filter(l=>l.name===_e.PROMO_OFFER).length)return"promo_rendering_method_was_not_found";if(!r?.length)return"subscription_methods_were_not_found";let a=!1;for(const l of n){const c=Cs[l.name];if(c)for(const d of r)c.availableSubscriptionMethods?.includes(d.name)&&(a=!0)}if(!a)return"supported_rendering_method_was_not_found"},kA=(t,e)=>{if(ks(t.contentBlocks.items||void 0))return"";const s=t.contentBlocks.items?.[e];return Je(s,t.languageCode,t.defaultLanguageCode)||""},PA=H("quick-subscribe"),Et=t=>{if(t.qs.currentSourceId)return t.qs?.subscriptionsBySource?.[t.qs?.currentSourceId]},yo=t=>t.qs.allSubscriptions,Uu=t=>t.qs.promoCodeSubscriptions,OA=t=>t.qs.allAvailableSubscriptions,MA=t=>t.qs.availableSubscriptions||[],NA=t=>t.qs.shopSubscriptions||[],FA=t=>t.qs.existingSubscriptions,Bu=t=>yo(t)?.subscriptionOptions?.filter(e=>e.type==="base"&&!!e.subscriptionMethods?.find(s=>s.name==="sub20-yakassa-mvp")),So=t=>Et(t)?.steps[t.qs.currentStepIndex],UA=t=>So(t)?.name,vo=(t,e)=>Et(t)?.steps?.findIndex(s=>s.name===e),$u=t=>{const s=To(t)?.renderingMethod;return s&&s.name?Cs[s.name]:{component:null}},Vu=t=>$u(t)?.component,To=t=>Et(t)?.subscriptionOptions?.[0],BA=t=>Et(t)?.subscriptionOptions?.slice(1),Gu=t=>Et(t)?.subscriptionOptions||[],$A=t=>{const s=Et(t)?.existingSubscriptions?.map(i=>i.offerId);return Gu(t)?.filter(i=>!s?.includes(i.offerId))},Hu=t=>{const e=Et(t)?.existingSubscriptions?.filter(s=>s.paymentSystemType===bs.Yakassa.toLowerCase()&&s.subscriptionStatus===Ir.IN_RETRY.toLowerCase()||s.paymentSystemType===bs.Uztelecom)||[];return e.length?e[0]:null},VA=t=>t.qs.paymentRetry,GA=t=>t.qs.loading,HA=t=>t.qs.loadingId,KA=t=>t.qs.subscriptionShop.loadingId,WA=t=>t.qs.additionalActions.currentStepIndex,qA=t=>Di(t,t.qsConfig?.qsTvBackground?.imageId||""),YA=(t,e,s,i,n,r)=>{if(!e||!t.qsConfig||!s)return PA.info("Subscription option was not provided"),{};const a=ng.includes(e)?dg:e,l=ir(t.qsConfig.methods[a]),c={};for(const d in l){const u=l[d].translationId,h=l[d].contentBlockId;u&&(c[d]=Vn(t,Q(t,u),i,r)?.trim()||`{${u}}`),h&&(c[d]=Vn(t,kA(t,h),i,r)?.trim()||`{${h}}
3`),l[d].variables.forEach(f=>{let g=s[f]||"";if(f==="vodAvailable"){const y=[...i?["archive"]:[],...n||[]].filter(S=>Ot(t)[S])?.map(S=>Ot(t)[S].title).join(", ");y&&(g=y)}c[d]=c[d].replaceAll(`@${f}@`,g)})}return{...s,...c}},jA=Object.freeze(Object.defineProperty({__proto__:null,additionalActionsCurrentStepIndex:WA,allAvailableSubscriptionsSelector:OA,allSubscriptionOptionsSelector:Gu,allSubscriptionsOptionsTypeBaseSelector:Bu,allSubscriptionsSelector:yo,availableSubscriptionsSelector:MA,currentSourceSubscriptionsSelector:Et,currentStepComponentNameSelector:UA,currentStepSelector:So,currentTemplateComponentSelector:Vu,currentTemplateSelector:$u,existingSubscriptionInRetrySelector:Hu,existingSubscriptionsSelector:FA,getStepIndexByName:vo,loadingIdSelector:HA,loadingSelector:GA,otherSubscriptionsSelector:BA,paymentRetrySelector:VA,prioritySubscriptionSelector:To,promoCodeSubscriptionsSelector:Uu,renderingDataEnhancedSelector:YA,shopSubscriptionsSelector:NA,subscriptionOptionsWithoutExistingSelector:$A,subscriptionShopLoadingIdSelector:KA,tvBackgroundImageUrlSelector:qA},Symbol.toStringTag,{value:"Module"})),zA=t=>t.payment?.method?.saved&&!t.payment?.method?.is_cancelled||!1,Eo=t=>t.payment.yakassaSubscriptions,Ku=t=>t.payment.currentSubscriptions.filter(e=>{const s=t.payment.yakassaSubscriptions.find(i=>i.id===e.id);return e.managementMethods?.length&&s?s.last_payment?.status!==rt.PENDING||s.subscription_renew_status===rt.IN_RETRY:!0}),XA=t=>Ku(t).length,bo=t=>t.payment?.method?.card,QA=t=>bo(t)?.card_type||"",JA=t=>bo(t)?.last4||"",ZA=t=>Eo(t).filter(e=>e.subscription_renew_status===rt.IN_RETRY),eI=t=>{const e=Hu(t);return e?Eo(t).find(s=>s.id===e.subscriptionId):null},tI=Object.freeze(Object.defineProperty({__proto__:null,cardLast4Selector:JA,cardSelector:bo,cardTypeSelector:QA,currentSubscriptionsSelectorV2:Ku,existingSubscriptionInRetrySelector:eI,hasActiveSubscriptionsSelector:XA,paymentMethodAvailableSelector:zA,subscriptionsInRetrySelector:ZA,yakassaSubscriptionsSelector:Eo},Symbol.toStringTag,{value:"Module"})),sI=t=>t.personalArea||{},iI=Object.freeze(Object.defineProperty({__proto__:null,personalSettingsSelector:sI},Symbol.toStringTag,{value:"Module"})),nI=t=>t.profiles.currentAction,rI=t=>t.profiles.profileIdToDelete,oI=t=>t.profiles.isProfileLoading,aI=t=>t.profiles.isProfileLoaded,lI=t=>t.profiles.profileSelected,cI=Object.freeze(Object.defineProperty({__proto__:null,currentActionSelector:nI,isProfileLoadedSelector:aI,isProfileLoadingSelector:oI,profileIdToDeleteSelector:rI,profileSelectedSelector:lI},Symbol.toStringTag,{value:"Module"})),dI=t=>t.reviews||{},uI=Object.freeze(Object.defineProperty({__proto__:null,reviewsSettingsSelector:dI},Symbol.toStringTag,{value:"Module"})),hI=(t,e)=>{const s=t.siteConfig?.searchBots?.uaRegExp||Yf,i=ss()||"unknown";return new RegExp(s,"i").test(i)},fI=t=>t.seo.title,gI=t=>t.seo.meta,pI=t=>t.seo.breadcrumbs,mI=t=>t.seo.breadcrumbTelevisionChannel,yI=t=>t.seo.breadcrumbProduct,SI=Object.freeze(Object.defineProperty({__proto__:null,breadcrumbProductSelector:yI,breadcrumbTelevisionChannelSelector:mI,breadcrumbsSelector:pI,isSeoBotSelector:hI,metaSelector:gI,titleSelector:fI},Symbol.toStringTag,{value:"Module"})),vI=t=>({begin:Le(t.begin),end:Le(t.end)}),ha=t=>"actuallyStartedAt"in t&&t.actuallyStartedAt?Le(t.actuallyStartedAt):void 0,TI=(t,e)=>{let s;const i=ha(t);if(i){const n=e?ha(e):void 0;s={begin:i,end:n,isValidForTimeline:!!n&&n.unix()-i.unix()>Jf}}return s},EI=(t,e)=>{if(!t.scheduledFor)return null;const s=vI(t.scheduledFor);let i=s.end.unix()-s.begin.unix();const n=TI(t,e);return n?.isValidForTimeline&&n?.end&&(i=n.end.unix()-n.begin.unix()),{...t,scheduledFor:s,description:"eventDescriptionMedium"in t?t.eventDescriptionMedium:"",duration:i,actuallyScheduledFor:n}},bI=t=>t.reduce((e,s,i)=>{const n=t[i+1],r=EI(s,n);return r&&e.push(r),e},[]),fa=t=>t?.format("HH:mm")||"",IP=t=>Le(t,Cl),LP=()=>Le().format(Cl),xo=(t,e)=>{const s=e?.medias?.[0]?.scheduleId||"",i=t.tvEpgV2.onAir.schedules?.[s]||[];return bI(i)},Wu=(t,e)=>{const s=xo(t,e);if(!s.length)return-1;const i=Le().unix();return s.findIndex(n=>n.scheduledFor.begin.unix()<=i&&n.scheduledFor.end.unix()>i)},xI=(t,e)=>{const s=Wu(t,e);return s<0?void 0:xo(t,e)[s]},AI=(t,e)=>{const s=xo(t,e),i=Wu(t,e);if(i<0)return;const n=s[i+1];if(!n)return;const r=Le(),o=(n.scheduledFor.begin||r).unix(),a=t?.common?.serverTime?t.common.serverTime:r.unix();return{title:n.title,scheduledFor:n.scheduledFor,startsIn:hr(t,o-a)}},II=Object.freeze(Object.defineProperty({__proto__:null,onAirLiveProgramSelector:xI,onAirNextProgramSelector:AI},Symbol.toStringTag,{value:"Module"})),LI=t=>t.siteConfig?.unsubscriptionRetention?.enabled,RI=Object.freeze(Object.defineProperty({__proto__:null,isEnabledSelector:LI},Symbol.toStringTag,{value:"Module"})),ee={account:$g,adultOnboarding:qg,appInfo:zg,authAndReg:Xg,brandingMethods:Jg,channelCollections:$p,common:xp,fileRecords:Cp,home:t0,metrics:s0,modals:fm,notifications:Xm,packages:n0,pauses:nx,payment:tI,personal:iI,player:WT,popupNotices:Ub,profiles:cI,promoElements:Jm,providerInfo:Dv,qs:jA,registration:fA,reviews:uI,seo:SI,siteConfig:qS,tokensV1:jS,tokensV2:ZS,translations:Ip,tvChannels:Fp,tvEpgV2:II,unsubscriptionRetention:RI,utmLabels:lb,vod:bv},qu=H("router-utils"),Yu=(t,e)=>{const s=kI(e);return s?t.getRoutes().filter(i=>Bs(i.name).endsWith(`-from-${s}`)&&i.components?.default):[]},ju=(t,e)=>({name:t.name,path:t.path,component:t.components.default,props:t.props?.default,meta:t.meta,sensitive:e}),CI=(t,e)=>{t.addRoute(ju(e,!0))},_I=(t,e)=>{t.addRoute(ju(e,!1))},Bs=t=>(t||"").toString(),wI=t=>Bs(t).includes("modal")||!1,DI=t=>Bs(t).includes("with-player")||!1,RP=t=>t.endsWith("/watch"),CP=t=>Bs(t).match(/-season/),_P=t=>!!t.matched[0]?.props?.default?.hasCustomLayout,kI=t=>{const e=Bs(t);
3return wI(e)?e.split("-modal-from-")[1]:DI(e)?e.replace("-with-player",""):e},wP=(t,e)=>`${t}-modal-from-${e}`,DP=t=>`${t}-with-player`,kP=(t,e)=>{const s=Yu(t,e);s.length&&qu.info("prioritize routes",s.map(i=>i.name)),s.forEach(i=>{CI(t,i)})},PP=(t,e)=>{const s=Yu(t,e);s.length&&qu.info("deprioritize routes",s.map(i=>i.name)),s.forEach(i=>{_I(t,i)})},PI=t=>{switch(t.name){case"app-sections":return t.params.sectionId?t.params.sectionId?.toString():"";case"vod":return"cinema_screen";case"search":return"search_screen";case"home":case"adult":return"home_screen";default:return""}},OP=(t,e)=>{const s=PI(t),i=e.appSections.sections.find(l=>l.sectionId===s),n=s==="home_screen"&&!i&&!!e.homeScreenConfig?.config_list?.find(({key:l})=>l===ai.homeCarouselV2)&&!!e.promoElements.items[ai.homeCarouselV2]?.length,r=i?.blocks.find(l=>l.renderingMethods.includes("promo-carousel-v2")),o=r&&!!e.promoElements.items[r.placementId]?.length;return n||!!r&&!!o};var OI=Object.getOwnPropertyDescriptor,MI=(t,e,s,i)=>{for(var n=i>1?void 0:i?OI(e,s):e,r=t.length-1,o;r>=0;r--)(o=t[r])&&(n=o(n)||n);return n};let Hn=class extends nr{get languageCode(){return ee.common.languageCodeSelector(this.$store)}get isAnonymous(){return ee.account.isAnonymousSelector(this.$store)}get theme(){return this.$store.theme}get isWelcomeScreenVisible(){return!this.isAnonymous&&ee.modals.isWelcomeScreenOpenSelector(this.$store)&&this.$route.name!=="reg"&&this.$route.name!=="qr-success"}get isKt(){return le().isKt}get isSanta(){return le().isSanta}get isSmotreshka(){return le().isSmotreshka}get isTele2(){return le().isTele2}get isRzd(){return le().isRzd}getByLanguage(t){return Je(t,this.languageCode,this.$store.defaultLanguageCode)}getTranslation(t){return ee.translations.translationSelector(this.$store,t)}getTranslationWithLink(t){return up(this.$store,ee.translations.translationSelector(this.$store,t))}hasTranslation(t){return ee.translations.hasTranslationIdSelector(this.$store,t)&&!!this.getTranslation(t)}getSendCodeAgainText(t){return`${this.getTranslation("send_code_again_in")}: ${t} ${this.getTranslation("sec")}.`}};Hn=MI([Zt],Hn);var NI=Object.getOwnPropertyDescriptor,FI=(t,e,s,i)=>{for(var n=i>1?void 0:i?NI(e,s):e,r=t.length-1,o;r>=0;r--)(o=t[r])&&(n=o(n)||n);return n};let Kn=class extends nr{gaEvent(t){yt(t,this.$store)}gaEventOnce(t){Iv(t,this.$store)}yaMetrikaGoal=Lv};Kn=FI([Zt],Kn);var UI=Object.getOwnPropertyDescriptor,BI=(t,e,s,i)=>{for(var n=i>1?void 0:i?UI(e,s):e,r=t.length-1,o;r>=0;r--)(o=t[r])&&(n=o(n)||n);return n};let Wn=class extends rr(Hn,Kn){};Wn=BI([Zt],Wn);const $I=1024;function ga(t){return t*8}const MP=t=>(t/$I).toFixed(2)+" KB";function pa(t){return t/1e3}function ma(t){return t/1e6}function ya(t){return t.toFixed(2)}const VI=t=>typeof t=="number"&&!isNaN(t),NP=(t,e)=>VI(t)?t:e,FP=(t,e,s)=>e<t?t:e>s?s:e,GI=(t,e=0)=>{const s=t.details?.seasons||[];return t.details?.episodes?.filter(i=>!s.length||i.preview?.seasonId===s[e]?.id)||[]};var HI=(t=>(t.pageImpression="page_impression",t.pageUpdate="page_update",t.itemFocus="item_focus",t.itemClick="item_click",t))(HI||{});const UP=t=>(t.params||[]).reduce((e,s)=>(e[s.key]=s.value,e),{}),KI={ru:["ÑнваÑÑ","ÑевÑалÑ","маÑÑа","апÑелÑ","маÑ","иÑнÑ","иÑлÑ","авгÑÑÑа","ÑенÑÑбÑÑ","окÑÑбÑÑ","ноÑбÑÑ","декабÑÑ"]},an=60,At=2;class ft{static timestamp(){return Math.round(kt(Date.now(),"millisecond"))}static getHM(e=new Date){const s=`${e.getHours()}`,i=`${e.getMinutes()}`;return s.padStart(At,"0")+":"+i.padStart(At,"0")}
3static getUTCHMFromEpoch(e=ft.timestamp()){return ft.getHM(new Date(Dt(e,"second")))}static getDMonth(e=new Date){const s=String(e.getDate()),i=`${e.getMonth()+1}`;return`${s.padStart(At,"0")}.${i.padStart(At,"0")}`}static getDFullMonth(e=new Date){return`${e.getDate()} ${KI.ru[e.getMonth()]}`}static getEpochDay(){return Math.floor(Ai(Date.now(),"millisecond"))}static fromEpochDay(e=ft.getEpochDay()){const s=new Date(Dt(e,"day"));return s.setHours(0),s}static prettyTimeHMS(e,s){const i=Math.floor(Math.max(e,0)),n=Math.floor(df(i,"second")),r=Math.floor(i/an)%an,o=i%an;return(s||n?`${String(n).padStart(At,"0")}:`:"")+`${String(r).padStart(At,"0")}:${String(o).padStart(At,"0")}`}static prettifyPlayerTime(e,s){return ft.prettyTimeHMS(e,s>kt(1,"hour"))+" / "+ft.prettyTimeHMS(s)}}const BP=t=>Le().add(t,"day").format("DD.MM.YYYY"),$P=t=>{if(!t)return"";const e=new Date(t*Rl.subscribes.dateUTCMultiplier);return t>0?`${ft.getDMonth(e)}.${e.getFullYear()}`:`${ft.getDMonth(new Date)}.${new Date().getFullYear()}`},VP=(t,e="yakassaPopup",s=500,i=600)=>{const n=window.screenLeft!==void 0?window.screenLeft:window.screenX,r=window.screenTop!==void 0?window.screenTop:window.screenY,o=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,a=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height,l=o/window.screen.availWidth,c=(o-s)/2/l+n,d=(a-i)/2/l+r,u=window.open(t,e,` 4 popup 5 scrollbars=yes, 6 width=${s/l}, 7 height=${i/l}, 8 top=${d}, 9 left=${c} 10 `);return u?.focus(),u},GP=t=>{let e="";for(let s=0;s<t.length;s++)e+=String.fromCharCode(Number(t[s]));return btoa(e)},WI=t=>t.length===0?void 0:t.reduce((e,s)=>e+s,0);function ps(t){if(t.length!==0)return t.reduce((e,s)=>e+s,0)/t.length}function pt(t){if(t.length!==0)return Math.min.apply(null,t)}function ms(t){if(t.length!==0)return Math.max.apply(null,t)}function qI(t){return new Array(t).fill(0)}function ni(t){let e=[];return t.forEach(s=>{Array.isArray(s)?e=e.concat(ni(s)):e.push(s)}),e}const HP=t=>{const e=[];for(let s=0;s<t.length;s++){const i=t.charCodeAt(s);i<128?e.push(i):i<2048?(e.push(192|i>>6),e.push(128|i&63)):(e.push(224|i>>12),e.push(128|i>>6&63),e.push(128|i&63))}return e},KP=(t=!1)=>{setTimeout(()=>{const e=document.querySelector(".modal"),s=document.querySelector(".scroll-container");t?window.scrollTo(0,0):e?e.scrollTo(0,0):s&&s.scrollTo(0,0)},0)},YI=H("utils"),zu=typeof window<"u",Sa=()=>{},jI=()=>{if(!zu)return;let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("test",Sa,e),window.removeEventListener("test",Sa)}catch(e){YI.error(e)}return t},ln=(t,e)=>typeof getComputedStyle<"u"?getComputedStyle(t,null).getPropertyValue(e):t.style[e],zI=t=>ln(t,"overflow")+ln(t,"overflow-y")+ln(t,"overflow-x"),WP=t=>{if(!zu)return;if(!(t instanceof HTMLElement))return window;let e=t;for(;e&&!(e===document.body||e===document.documentElement||!e.parentNode);){if(/(scroll|auto)/.test(zI(e)))return e;e=e.parentNode}return window},va=["scroll","wheel","mousewheel","resize","animationend","transitionend","touchmove"];class XI{images=[];cached=tf(new Set);findVisibleImagesToLoad;listeningTargets=[];listeningTargetsIndex=0;constructor(){this.findVisibleImagesToLoad=ef(this._findVisibleImagesToRender.bind(this),200)}findImageByEl(e){return this.images.find(s=>s.el===e)}addToQueue(e){this.images.push(e),this.addListenerTarget(window),e.parent&&this.addListenerTarget(e.parent),this.findVisibleImagesToLoad()}removeFromQueue(e){const s=this.images.findIndex(i=>i.el===e);if(s>-1){const i=this.images[s];i.parent&&this.removeListenerTarget(i.parent),this.removeListenerTarget(window),this.images.splice(s,1)}}addListenerTarget(e){if(!e)return;let s=this.listeningTargets.find(i=>i.el===e);return s?s.childrenCount++:(s={el:e,id:++this.listeningTargetsIndex,childrenCount:1,listened:!0},this.bindEvents(s.el),this.listeningTargets.push(s)),this.listeningTargetsIndex}
10removeListenerTarget(e){this.listeningTargets.forEach((s,i)=>{s.el===e&&(s.childrenCount--,s.childrenCount||(this.unbindEvents(s.el),this.listeningTargets.splice(i,1)))})}bindEvents(e){va.forEach(s=>{const i=jI()?{passive:!0}:void 0;e.addEventListener(s,this.findVisibleImagesToLoad,i)})}unbindEvents(e){va.forEach(s=>{e.removeEventListener(s,this.findVisibleImagesToLoad)})}_findVisibleImagesToRender(){const e=[];this.images.forEach(s=>{if(!s.el||!s.el.parentNode){e.push(s.el);return}s.checkInView()&&(this.cached.add(s.src),e.push(s.el))}),e.forEach(s=>{const i=this.images.findIndex(n=>n.el===s);i>-1&&this.images.splice(i,1)})}}const qP=new XI,Ta=1,QI=0;let YP=class{el;src="";parent;constructor({el:e,src:s}){this.src=s,this.el=e}setParent(e){this.parent=e}checkInView(){const e=this.el.getBoundingClientRect();return e.top<window.innerHeight*Ta&&e.bottom>QI&&e.left<window.innerWidth*Ta&&e.right>0}update(e){this.src=e}};const zP=(t=_i)=>document.getElementById(t)?.scrollTop||document.documentElement.scrollTop||0,XP=(t,e=_i)=>{const s=document.getElementById(e);s&&(s.scrollTop=t)},QP=(t,e=_i)=>{document.addEventListener("scroll",t),document.getElementById(e)?.addEventListener("scroll",t)},JP=(t,e=_i)=>{document.removeEventListener("scroll",t),document.getElementById(e)?.removeEventListener("scroll",t)},JI=t=>{if(!t?.pauses?.[0]?.id)return!1;if(!t.preview?.hasSeries)return!0;if(GI(t).length)return!!Xu},Xu=t=>{const e=t?.pauses?.[0];return e?t.details?.episodes?.find(s=>s?.preview?.id===e?.episodeId):void 0},ZI=t=>{const e=t.pauses?.[0],s=t.details?.seasons||[];return e?.seasonId?s.find(i=>i?.id===e.seasonId):e?.episodeId?s.find(i=>i?.id===t.details?.episodes?.find(n=>n?.preview?.id===e.episodeId)?.preview?.seasonId):void 0},ZP=(t,e,s)=>{const i=[],n=t?.pauses?.[0],r=t?.details?.episodes||[];if(!JI(t)||!t.preview?.hasSeries)return"";const o=ZI(t)?.number,a=o?`${e} ${o}`:"";if(a){i.push(a);const l=r.findIndex(h=>h.preview?.id===n?.episodeId),c=r[l]?.preview?.episodeNumber,d=r[l]?.preview?.title||Xu(t)?.preview?.title;if(!d&&!c)return"";const u=d||(c?`${s} ${c}`:"");i.push(u)}else{const l=r.find(c=>c.preview?.id===n?.episodeId);if(!l)return"";i.push(l?.preview?.title||"")}return i.join(". ")},eO=t=>typeof t=="string"&&!/[^a-z0-9.\-_]+/i.test(t),tO=t=>typeof t=="string"&&!/[^a-z0-9.\-+_\s;\\:%=]+/i.test(t),sO=t=>typeof t=="string"&&!/[^0-9]+/.test(t),iO=t=>typeof t=="string"&&!/[^a-z0-9.\-_]+/i.test(t),nO=t=>typeof t=="string"&&!/[^a-z0-9.\-_]+/i.test(t),rO=t=>t?.path||"",oO=t=>t?.type||"",aO=t=>{const[e]=t?.split(":")||[],{wlAppId:s}=Be();if(e){if(e.includes("localhost")||e.includes("127.0.0.1")||eL(e))return"development";if(e.includes("test.seq.lfstrm.tv"))return"staging"}else return"unknown";return`production-${s}`},eL=t=>{const e=t.split(".");return e[0]==="10"||e[0]==="172"&&parseInt(e[1],10)>=16&&parseInt(e[1],10)<=31||e[0]==="192"&&e[1]==="168"},lO=()=>{const t=le().isSmotreshka||le().isN3||le().isRzd?"/reg":"/login";return le().isKt?`${t}?type=reg`:t};class Qu{opts={stability:8,sensitivity:50,tolerance:1.1,delay:50};lastUpDeltas;lastDownDeltas;deltasTimestamp;constructor(e={}){this.opts={...this.opts,...e},this.lastUpDeltas=new Array(this.opts.stability*2).fill(null),this.lastDownDeltas=new Array(this.opts.stability*2).fill(null),this.deltasTimestamp=new Array(this.opts.stability*2).fill(null)}static extractWheelDelta(e){let s=0;return e.deltaY!=null?s=e.deltaY*-40:(e.detail!=null||e.detail===0)&&(s=e.detail*-40),s}handleEvent(e){const s=Qu.extractWheelDelta(e);return this.deltasTimestamp.push(Date.now()),this.deltasTimestamp.shift(),s>0?(this.lastUpDeltas.push(s),this.lastUpDeltas.shift(),this.isInertia(1)):(this.lastDownDeltas.push(s),this.lastDownDeltas.shift(),this.isInertia(-1))}isInertia(e){const s=e===-1?this.lastDownDeltas:this.lastUpDeltas;if(s[0]===null)return e;if(this.deltasTimestamp[this.opts.stability*2-2]+this.opts.delay>Date.now()&&s[0]===s[this.opts.stability*2-1])return!1;const i=s.slice(0,this.opts.stability),n=s.slice(this.opts.stability,this.opts.stability*2),r=i.reduce((c,d)=>c+d),o=n.reduce((c,d)=>c+d),a=r/i.length,l=o/n.length;return Math.abs(a)<Math.abs(l*this.opts.tolerance)&&this.opts.sensitivity<Math.abs(l)?e:!1}showLastUpDeltas(){return this.lastUpDeltas}showLastDownDeltas(){return this.lastDownDeltas}}var tL=Object.getOwnPropertyDescriptor,sL=(t,e,s,i)=>{for(var n=i>
101?void 0:i?tL(e,s):e,r=t.length-1,o;r>=0;r--)(o=t[r])&&(n=o(n)||n);return n};let qn=class extends nr{windowWidth=document.documentElement.clientWidth;isLoaded=!1;actualizeWindowWidth(){Tl(()=>{this.windowWidth=document.documentElement.clientWidth,this.isLoaded=!0},200)()}};qn=sL([Zt],qn);var iL=Object.getOwnPropertyDescriptor,nL=(t,e,s,i)=>{for(var n=i>1?void 0:i?iL(e,s):e,r=t.length-1,o;r>=0;r--)(o=t[r])&&(n=o(n)||n);return n};let Ea=class extends rr(qn){async mounted(){this.actualizeWindowWidth(),window.addEventListener("resize",this.actualizeWindowWidth)}beforeUnmount(){window.removeEventListener("resize",this.actualizeWindowWidth)}};Ea=nL([Zt],Ea);function rL(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ju={exports:{}};(function(t,e){(function(s){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,o=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(l,c,d){if(d=d||{},l=l.trim(),c=c.trim(),!c){if(!d.alwaysNormalize)return l;var u=a.parseURL(l);if(!u)throw new Error("Error trying to parse base URL.");return u.path=a.normalizePath(u.path),a.buildURLFromParts(u)}var h=a.parseURL(c);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return d.alwaysNormalize?(h.path=a.normalizePath(h.path),a.buildURLFromParts(h)):c;var f=a.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var g=n.exec(f.path);f.netLoc=g[1],f.path=g[2]}f.netLoc&&!f.path&&(f.path="/");var m={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(m.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)m.path=f.path,h.params||(m.params=f.params,h.query||(m.query=f.query));else{var y=f.path,S=y.substring(0,y.lastIndexOf("/")+1)+h.path;m.path=a.normalizePath(S)}return m.path===null&&(m.path=d.alwaysNormalize?a.normalizePath(h.path):h.path),a.buildURLFromParts(m)},parseURL:function(l){var c=i.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(r,"");l.length!==(l=l.replace(o,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};t.exports=a})()})(Ju);var Ao=Ju.exports;function ba(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,i)}return s}function Re(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?ba(Object(s),!0).forEach(function(i){oL(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):ba(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}function oL(t,e,s){return e=lL(e),e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function de(){return de=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},de.apply(this,arguments)}function aL(t,e){if(typeof t!="object"||t===null)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var i=s.call(t,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function lL(t){var e=aL(t,"string");return typeof e=="symbol"?e:String(e)}const N=Number.isFinite||function(t){return typeof t=="number"&&isFinite(t)};
10let p=(function(t){return t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached",t})({}),B=(function(t){return t.NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError",t})({}),L=(function(t){return t.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",t.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",t.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",t.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_PARSING_ERROR="levelParsingError",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.FRAG_GAP="fragGap",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown",t})({});const Rt=function(){},Yn={trace:Rt,debug:Rt,log:Rt,warn:Rt,info:Rt,error:Rt};let ys=Yn;function cL(t){const e=self.console[t];return e?e.bind(self.console,`[${t}] >`):Rt}function dL(t,...e){e.forEach(function(s){ys[s]=t[s]?t[s].bind(t):cL(s)})}function uL(t,e){if(self.console&&t===!0||typeof t=="object"){dL(t,"debug","log","info","warn","error");try{ys.log(`Debug logs enabled for "${e}
10" in hls.js version 1.4.10`)}catch{ys=Yn}}else ys=Yn}const v=ys,hL=/^(\d+)x(\d+)$/,xa=/(.+?)=(".*?"|.*?)(?:,|$)/g;class ie{constructor(e){typeof e=="string"&&(e=ie.parseAttrList(e));for(const s in e)e.hasOwnProperty(s)&&(s.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(s)),this[s]=e[s])}decimalInteger(e){const s=parseInt(this[e],10);return s>Number.MAX_SAFE_INTEGER?1/0:s}hexadecimalInteger(e){if(this[e]){let s=(this[e]||"0x").slice(2);s=(s.length&1?"0":"")+s;const i=new Uint8Array(s.length/2);for(let n=0;n<s.length/2;n++)i[n]=parseInt(s.slice(n*2,n*2+2),16);return i}else return null}hexadecimalIntegerAsNumber(e){const s=parseInt(this[e],16);return s>Number.MAX_SAFE_INTEGER?1/0:s}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,s){const i=this[e];return i?parseFloat(i):s}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){const s=hL.exec(this[e]);if(s!==null)return{width:parseInt(s[1],10),height:parseInt(s[2],10)}}static parseAttrList(e){let s;const i={};for(xa.lastIndex=0;(s=xa.exec(e))!==null;){let r=s[2];r.indexOf('"')===0&&r.lastIndexOf('"')===r.length-1&&(r=r.slice(1,-1));const o=s[1].trim();i[o]=r}return i}}function fL(t){return t!=="ID"&&t!=="CLASS"&&t!=="START-DATE"&&t!=="DURATION"&&t!=="END-DATE"&&t!=="END-ON-NEXT"}function gL(t){return t==="SCTE35-OUT"||t==="SCTE35-IN"}class Zu{constructor(e,s){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,s){const i=s.attr;for(const n in i)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==i[n]){v.warn(`DATERANGE tag attribute: "${n}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=n;break}e=de(new ie({}),i,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const i=new Date(this.attr["END-DATE"]);N(i.getTime())&&(this._endDate=i)}}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(N(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&&N(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Xi{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 j={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class eh{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[j.AUDIO]:null,[j.VIDEO]:null,[j.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,s){const i=e.split("@",2),n=[];i.length===1?n[0]=s?s.byteRangeEndOffset:0:n[0]=parseInt(i[1]),n[1]=parseInt(i[0])+n[0],this._byteRange=n}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=Ao.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class cn extends eh{constructor(e,s){super(s),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 Xi,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 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 s=this.levelkeys.identity;if(s)this._decryptdata=s.getDecryptData(this.sn);else{const i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!N(this.programDateTime))return null;const e=N(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;
vendor: 12,529 bytes, line 10
10if(this.levelkeys){const s=Object.keys(this.levelkeys),i=s.length;if(i>1||i===1&&this.levelkeys[s[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const s=this.levelkeys[e];s&&!this._decryptdata&&(this._decryptdata=s.getDecryptData(this.sn))}}abortRequests(){var e,s;(e=this.loader)==null||e.abort(),(s=this.keyLoader)==null||s.abort()}setElementaryStreamInfo(e,s,i,n,r,o=!1){const{elementaryStreams:a}=this,l=a[e];if(!l){a[e]={startPTS:s,endPTS:i,startDTS:n,endDTS:r,partial:o};return}l.startPTS=Math.min(l.startPTS,s),l.endPTS=Math.max(l.endPTS,i),l.startDTS=Math.min(l.startDTS,n),l.endDTS=Math.max(l.endDTS,r)}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[j.AUDIO]=null,e[j.VIDEO]=null,e[j.AUDIOVIDEO]=null}}class pL extends eh{constructor(e,s,i,n,r){super(i),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 Xi,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=s,this.index=n;const o=e.enumeratedString("BYTERANGE");o&&this.setByteRange(o,r),r&&(this.fragOffset=r.fragOffset+r.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 mL=10;class yL{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 s=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!s,this.advanced=this.endSN>e.endSN||s>0||s===0&&i>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?N(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||mL}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 Io(t){return Uint8Array.from(atob(t),e=>e.charCodeAt(0))}function SL(t){const e=th(t).subarray(0,16),s=new Uint8Array(16);return s.set(e,16-e.length),s}function vL(t){const e=function(i,n,r){const o=i[n];i[n]=i[r],i[r]=o};e(t,0,3),e(t,1,2),e(t,4,5),e(t,6,7)}function TL(t){const e=t.split(":");let s=null;if(e[0]==="data"&&e.length===2){const i=e[1].split(";"),n=i[i.length-1].split(",");if(n.length===2){const r=n[0]==="base64",o=n[1];r?(i.splice(-1,1),s=Io(o)):s=SL(o)}}return s}function th(t){return Uint8Array.from(unescape(encodeURIComponent(t)),e=>e.charCodeAt(0))}var ne={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Ae={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Aa(t){switch(t){case Ae.FAIRPLAY:return ne.FAIRPLAY;case Ae.PLAYREADY:return ne.PLAYREADY;case Ae.WIDEVINE:return ne.WIDEVINE;case Ae.CLEARKEY:return ne.CLEARKEY}}var sh={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function EL(t){if(t===sh.WIDEVINE)return ne.WIDEVINE}function Ia(t){switch(t){case ne.FAIRPLAY:return Ae.FAIRPLAY;case ne.PLAYREADY:return Ae.PLAYREADY;case ne.WIDEVINE:return Ae.WIDEVINE;case ne.CLEARKEY:return Ae.CLEARKEY}}function dn(t){const{drmSystems:e,widevineLicenseUrl:s}=t,i=e?[ne.FAIRPLAY,ne.WIDEVINE,ne.PLAYREADY,ne.CLEARKEY].filter(n=>!!e[n]):[];return!i[ne.WIDEVINE]&&s&&i.push(ne.WIDEVINE),i}const ih=(function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null})();function bL(t,e,s,i){let n;switch(t){case ne.FAIRPLAY:n=["cenc","sinf"];break;case ne.WIDEVINE:case ne.PLAYREADY:n=["cenc"];break;case ne.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${t}`)}return xL(n,e,s,i)}function xL(t,e,s,i){return[{initDataTypes:t,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(r=>({contentType:`audio/mp4; codecs="${r}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:s.map(r=>({contentType:`video/mp4; codecs="${r}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function wt(t,e,s){return Uint8Array.prototype.slice?t.slice(e,s):new Uint8Array(Array.prototype.slice.call(t,e,s))}const Lo=(t,e)=>e+10<=t.length&&t[e]===73&&t[e+1]===68&&t[e+2]===51&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128,nh=(t,e)=>e+10<=t.length&&t[e]===51&&t[e+1]===68&&t[e+2]===73&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128,Si=(t,e)=>{const s=e;let i=0;for(;Lo(t,e);){i+=10;const n=Qi(t,e+6);i+=n,nh(t,e+10)&&(i+=10),e+=i}if(i>0)return t.subarray(s,s+i)},Qi=(t,e)=>{let s=0;return s=(t[e]&127)<<21,s|=(t[e+1]&127)<<14,s|=(t[e+2]&127)<<7,s|=t[e+3]&127,s},AL=(t,e)=>Lo(t,e)&&Qi(t,e+6)+10<=t.length-e,IL=t=>{const e=oh(t);for(let s=0;s<e.length;s++){const i=e[s];if(rh(i))return DL(i)}},rh=t=>t&&t.key==="PRIV"&&t.info==="com.apple.streaming.transportStreamTimestamp",LL=t=>{const e=String.fromCharCode(t[0],t[1],t[2],t[3]),s=Qi(t,4),i=10;return{type:e,size:s,data:t.subarray(i,i+s)}},oh=t=>{let e=0;const s=[];for(;Lo(t,e);){const i=Qi(t,e+6);e+=10;const n=e+i;for(;e+8<n;){const r=LL(t.subarray(e)),o=RL(r);o&&s.push(o),e+=r.size+10}nh(t,e)&&(e+=10)}return s},RL=t=>t.type==="PRIV"?CL(t):t.type[0]==="W"?wL(t):_L(t),CL=t=>{if(t.size<2)return;const e=Qe(t.data,!0),s=new Uint8Array(t.data.subarray(e.length+1));return{key:t.type,info:e,data:s.buffer}},_L=t=>{if(t.size<2)return;if(t.type==="TXXX"){let s=1;const i=Qe(t.data.subarray(s),!0);s+=i.length+1;const n=Qe(t.data.subarray(s));return{key:t.type,info:i,data:n}}const e=Qe(t.data.subarray(1));return{key:t.type,data:e}},wL=t=>{if(t.type==="WXXX"){if(t.size<2)return;let s=1;const i=Qe(t.data.subarray(s),!0);s+=i.length+1;const n=Qe(t.data.subarray(s));return{key:t.type,info:i,data:n}}const e=Qe(t.data);return{key:t.type,data:e}},DL=t=>{if(t.data.byteLength===8){const e=new Uint8Array(t.data),s=e[3]&1;let i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,s&&(i+=4772185884e-2),Math.round(i)}},Qe=(t,e=!1)=>{const s=kL();if(s){const c=s.decode(t);if(e){const d=c.indexOf("\0");return d!==-1?c.substring(0,d):c}return c.replace(/\0/g,"")}const i=t.length;let n,r,o,a="",l=0;for(;l<i;){if(n=t[l++],n===0&&e)return a;if(n===0||n===3)continue;switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(n);break;case 12:case 13:r=t[l++],a+=String.fromCharCode((n&31)<<6|r&63);break;case 14:r=t[l++],o=t[l++],a+=String.fromCharCode((n&15)<<12|(r&63)<<6|(o&63)<<0);break}}return a};let un;function kL(){return!un&&typeof self.TextDecoder<"u"&&(un=new self.TextDecoder("utf-8")),un}const Ye={hexDump:function(t){let e="";for(let s=0;s<t.length;s++){let i=t[s].toString(16);i.length<2&&(i="0"+i),e+=i}return e}},vi=Math.pow(2,32)-1,PL=[].push,ah={video:1,audio:2,id3:3,text:4};function pe(t){return String.fromCharCode.apply(null,t)}function lh(t,e){const s=t[e]<<8|t[e+1];return s<0?65536+s:s}function V(t,e){const s=ch(t,e);return s<0?4294967296+s:s}function ch(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function hn(t,e,s){t[e]=s>>24,t[e+1]=s>>16&255,t[e+2]=s>>8&255,t[e+3]=s&255}function K(t,e){const s=[];if(!e.length)return s;const i=t.byteLength;for(let n=0;n<i;){const r=V(t,n),o=pe(t.subarray(n+4,n+8)),a=r>1?n+r:i;if(o===e[0])if(e.length===1)s.push(t.subarray(n+8,a));else{const l=K(t.subarray(n+8,a),e.slice(1));l.length&&PL.apply(s,l)}n=a}return s}function OL(t){const e=[],s=t[0];let i=8;const n=V(t,i);i+=4;const r=0,o=0;s===0?i+=8:i+=16,i+=2;let a=t.length+o;const l=lh(t,i);i+=2;for(let c=0;c<l;c++){let d=i;const u=V(t,d);d+=4;const h=u&2147483647;if((u&2147483648)>>>31===1)return v.warn("SIDX has hierarchical references (not supported)"),null;const g=V(t,d);d+=4,e.push({referenceSize:h,subsegmentDuration:g,info:{duration:g/n,start:a,end:a+h-1}}),a+=h,d+=4,i=d}return{earliestPresentationTime:r,timescale:n,version:s,referencesCount:l,references:e}}function dh(t){const e=[],s=K(t,["moov","trak"]);for(let n=0;n<s.length;n++){const r=s[n],o=K(r,["tkhd"])[0];if(o){let a=o[0],l=a===0?12:20;const c=V(o,l),d=K(r,["mdia","mdhd"])[0];if(d){a=d[0],l=a===0?12:20;const u=V(d,l),h=K(r,["mdia","hdlr"])[0];if(h){const f=pe(h.subarray(8,12)),g={soun:j.AUDIO,vide:j.VIDEO}[f];if(g){const m=K(r,["mdia","minf","stbl","stsd"])[0];let y;m&&(y=pe(m.subarray(12,16))),e[c]={timescale:u,type:g},e[g]={timescale:u,id:c,codec:y}}}}}}return K(t,["moov","mvex","trex"]).forEach(n=>{const r=V(n,4),o=e[r];o&&(o.default={duration:V(n,12),flags:V(n,20)})}),e}function ML(t,e){if(!t||!e)return t;const s=e.keyId;return s&&e.isCommonEncryption&&K(t,["moov","trak"]).forEach(n=>{const o=K(n,["mdia","minf","stbl","stsd"])[0].subarray(8);let a=K(o,["enca"]);const l=a.length>0;l||(a=K(o,["encv"])),a.forEach(c=>{const d=l?c.subarray(28):c.subarray(78);K(d,["sinf"]).forEach(h=>{const f=uh(h);if(f){const g=f.subarray(8,24);g.some(m=>m!==0)||(v.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Ye.hexDump(g)} -> ${Ye.hexDump(s)}`),f.set(s,8))}})})}),t}function uh(t){const e=K(t,["schm"])[0];if(e){const s=pe(e.subarray(4,8));if(s==="cbcs"||s==="cenc")return K(t,["schi","tenc"])[0]}return v.error("[eme] missing 'schm' box"),null}function NL(t,e){return K(e,["moof","traf"]).reduce((s,i)=>{const n=K(i,["tfdt"])[0],r=n[0],o=K(i,["tfhd"]).reduce((a,l)=>{const c=V(l,4),d=t[c];if(d){let u=V(n,4);if(r===1){if(u===vi)return v.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),a;u*=vi+1,u+=V(n,8)}const h=d.timescale||9e4,f=u/h;if(isFinite(f)&&(a===null||f<a))return f}return a},null);return o!==null&&isFinite(o)&&(s===null||o<s)?o:s},null)}function FL(t,e){let s=0,i=0,n=0;const r=K(t,["moof","traf"]);for(let o=0;o<r.length;o++){const a=r[o],l=K(a,["tfhd"])[0],c=V(l,4),d=e[c];if(!d)continue;const u=d.default,h=V(l,0)|u?.flags;let f=u?.duration;h&8&&(h&2?f=V(l,12):f=V(l,8));const g=d.timescale||9e4,m=K(a,["trun"]);for(let y=0;y<m.length;y++){if(s=UL(m[y]),!s&&f){const S=V(m[y],4);s=f*S}d.type===j.VIDEO?i+=s/g:d.type===j.AUDIO&&(n+=s/g)}}if(i===0&&n===0){let o=0;const a=K(t,["sidx"]);for(let l=0;l<a.length;l++){const c=OL(a[l]);c!=null&&c.references&&(o+=c.references.reduce((d,u)=>d+u.info.duration||0,0))}return o}return i||n}function UL(t){const e=V(t,0);let s=8;e&1&&(s+=4),e&4&&(s+=4);let i=0;const n=V(t,4);for(let r=0;r<n;r++){if(e&256){const o=V(t,s);i+=o,s+=4}e&512&&(s+=4),e&1024&&(s+=4),e&2048&&(s+=4)}return i}
10function BL(t,e,s){K(e,["moof","traf"]).forEach(i=>{K(i,["tfhd"]).forEach(n=>{const r=V(n,4),o=t[r];if(!o)return;const a=o.timescale||9e4;K(i,["tfdt"]).forEach(l=>{const c=l[0];let d=V(l,4);if(c===0)d-=s*a,d=Math.max(d,0),hn(l,4,d);else{d*=Math.pow(2,32),d+=V(l,8),d-=s*a,d=Math.max(d,0);const u=Math.floor(d/(vi+1)),h=Math.floor(d%(vi+1));hn(l,4,u),hn(l,8,h)}})})})}function $L(t){const e={valid:null,remainder:null},s=K(t,["moof"]);if(s){if(s.length<2)return e.remainder=t,e}else return e;const i=s[s.length-1];return e.valid=wt(t,0,i.byteOffset-8),e.remainder=wt(t,i.byteOffset-8),e}function Mt(t,e){const s=new Uint8Array(t.length+e.length);return s.set(t),s.set(e,t.length),s}function La(t,e){const s=[],i=e.samples,n=e.timescale,r=e.id;let o=!1;return K(i,["moof"]).map(l=>{const c=l.byteOffset-8;K(l,["traf"]).map(u=>{const h=K(u,["tfdt"]).map(f=>{const g=f[0];let m=V(f,4);return g===1&&(m*=Math.pow(2,32),m+=V(f,8)),m/n})[0];return h!==void 0&&(t=h),K(u,["tfhd"]).map(f=>{const g=V(f,4),m=V(f,0)&16777215,y=(m&1)!==0,S=(m&2)!==0,E=(m&8)!==0;let T=0;const R=(m&16)!==0;let I=0;const k=(m&32)!==0;let w=8;g===r&&(y&&(w+=8),S&&(w+=4),E&&(T=V(f,w),w+=4),R&&(I=V(f,w),w+=4),k&&(w+=4),e.type==="video"&&(o=VL(e.codec)),K(u,["trun"]).map(D=>{const P=D[0],C=V(D,0)&16777215,F=(C&1)!==0;let O=0;const z=(C&4)!==0,ve=(C&256)!==0;let se=0;const re=(C&512)!==0;let te=0;const M=(C&1024)!==0,U=(C&2048)!==0;let X=0;const J=V(D,4);let Y=8;F&&(O=V(D,Y),Y+=4),z&&(Y+=4);let ce=O+c;for(let Oe=0;Oe<J;Oe++){if(ve?(se=V(D,Y),Y+=4):se=T,re?(te=V(D,Y),Y+=4):te=I,M&&(Y+=4),U&&(P===0?X=V(D,Y):X=ch(D,Y),Y+=4),e.type===j.VIDEO){let Ve=0;for(;Ve<te;){const Me=V(i,ce);if(ce+=4,GL(o,i[ce])){const bt=i.subarray(ce,ce+Me);hh(bt,o?2:1,t+X/n,s)}ce+=Me,Ve+=Me+4}}t+=se/n}}))})})}),s}function VL(t){if(!t)return!1;const e=t.indexOf("."),s=e<0?t:t.substring(0,e);return s==="hvc1"||s==="hev1"||s==="dvh1"||s==="dvhe"}function GL(t,e){if(t){const s=e>>1&63;return s===39||s===40}else return(e&31)===6}function hh(t,e,s,i){const n=fh(t);let r=0;r+=e;let o=0,a=0,l=!1,c=0;for(;r<n.length;){o=0;do{if(r>=n.length)break;c=n[r++],o+=c}while(c===255);a=0;do{if(r>=n.length)break;c=n[r++],a+=c}while(c===255);const d=n.length-r;if(!l&&o===4&&r<n.length){if(l=!0,n[r++]===181){const h=lh(n,r);if(r+=2,h===49){const f=V(n,r);if(r+=4,f===1195456820){const g=n[r++];if(g===3){const m=n[r++],y=31&m,S=64&m,E=S?2+y*3:0,T=new Uint8Array(E);if(S){T[0]=m;for(let R=1;R<E;R++)T[R]=n[r++]}i.push({type:g,payloadType:o,pts:s,bytes:T})}}}}}else if(o===5&&a<d){if(l=!0,a>16){const u=[];for(let g=0;g<16;g++){const m=n[r++].toString(16);u.push(m.length==1?"0"+m:m),(g===3||g===5||g===7||g===9)&&u.push("-")}const h=a-16,f=new Uint8Array(h);for(let g=0;g<h;g++)f[g]=n[r++];i.push({payloadType:o,pts:s,uuid:u.join(""),userData:Qe(f),userDataBytes:f})}}else if(a<d)r+=a;else if(a>d)break}}function fh(t){const e=t.byteLength,s=[];let i=1;for(;i<e-2;)t[i]===0&&t[i+1]===0&&t[i+2]===3?(s.push(i+2),i+=2):i++;if(s.length===0)return t;const n=e-s.length,r=new Uint8Array(n);let o=0;for(i=0;i<n;o++,i++)o===s[0]&&(o++,s.shift()),r[i]=t[o];return r}function HL(t){const e=t[0];let s="",i="",n=0,r=0,o=0,a=0,l=0,c=0;if(e===0){for(;pe(t.subarray(c,c+1))!=="\0";)s+=pe(t.subarray(c,c+1)),c+=1;for(s+=pe(t.subarray(c,c+1)),c+=1;pe(t.subarray(c,c+1))!=="\0";)i+=pe(t.subarray(c,c+1)),c+=1;i+=pe(t.subarray(c,c+1)),c+=1,n=V(t,12),r=V(t,16),a=V(t,20),l=V(t,24),c=28}else if(e===1){c+=4,n=V(t,c),c+=4;const u=V(t,c);c+=4;const h=V(t,c);for(c+=4,o=2**32*u+h,Number.isSafeInteger(o)||(o=Number.MAX_SAFE_INTEGER,v.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),a=V(t,c),c+=4,l=V(t,c),c+=4;pe(t.subarray(c,c+1))!=="\0";)s+=pe(t.subarray(c,c+1)),c+=1;for(s+=pe(t.subarray(c,c+1)),c+=1;pe(t.subarray(c,c+1))!=="\0";)i+=pe(t.subarray(c,c+1)),c+=1;i+=pe(t.subarray(c,c+1)),c+=1}const d=t.subarray(c,t.byteLength);return{schemeIdUri:s,value:i,timeScale:n,presentationTime:o,presentationTimeDelta:r,eventDuration:a,id:l,payload:d}}function KL(t,...e){const s=e.length;let i=8,n=s;for(;n--;)i+=e[n].byteLength;
vendor: 5,320 bytes, line 10
10const r=new Uint8Array(i);for(r[0]=i>>24&255,r[1]=i>>16&255,r[2]=i>>8&255,r[3]=i&255,r.set(t,4),n=0,i=8;n<s;n++)r.set(e[n],i),i+=e[n].byteLength;return r}function WL(t,e,s){if(t.byteLength!==16)throw new RangeError("Invalid system id");let i,n;i=0,n=new Uint8Array;let r;i>0?(r=new Uint8Array(4),e.length>0&&new DataView(r.buffer).setUint32(0,e.length,!1)):r=new Uint8Array;const o=new Uint8Array(4);return s&&s.byteLength>0&&new DataView(o.buffer).setUint32(0,s.byteLength,!1),KL([112,115,115,104],new Uint8Array([i,0,0,0]),t,r,n,o,s||new Uint8Array)}function qL(t){if(!(t instanceof ArrayBuffer)||t.byteLength<32)return null;const e={version:0,systemId:"",kids:null,data:null},s=new DataView(t),i=s.getUint32(0);if(t.byteLength!==i&&i>44||s.getUint32(4)!==1886614376||(e.version=s.getUint32(8)>>>24,e.version>1))return null;e.systemId=Ye.hexDump(new Uint8Array(t,12,16));const r=s.getUint32(28);if(e.version===0){if(i-32<r)return null;e.data=new Uint8Array(t,32,r)}else if(e.version===1){e.kids=[];for(let o=0;o<r;o++)e.kids.push(new Uint8Array(t,32+o*16,16))}return e}let qs={};class _s{static clearKeyUriToKeyIdMap(){qs={}}constructor(e,s,i,n=[1],r=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=s,this.keyFormat=i,this.keyFormatVersions=n,this.iv=r,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 Ae.FAIRPLAY:case Ae.WIDEVINE:case Ae.PLAYREADY:case Ae.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&&v.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const i=YL(e);return new _s(this.method,this.uri,"identity",this.keyFormatVersions,i)}const s=TL(this.uri);if(s)switch(this.keyFormat){case Ae.WIDEVINE:this.pssh=s,s.length>=22&&(this.keyId=s.subarray(s.length-22,s.length-6));break;case Ae.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=WL(i,null,s);const n=new Uint16Array(s.buffer,s.byteOffset,s.byteLength/2),r=String.fromCharCode.apply(null,Array.from(n)),o=r.substring(r.indexOf("<"),r.length),c=new DOMParser().parseFromString(o,"text/xml").getElementsByTagName("KID")[0];if(c){const d=c.childNodes[0]?c.childNodes[0].nodeValue:c.getAttribute("VALUE");if(d){const u=Io(d).subarray(0,16);vL(u),this.keyId=u}}break}default:{let i=s.subarray(0,16);if(i.length!==16){const n=new Uint8Array(16);n.set(i,16-i.length),i=n}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=qs[this.uri];if(!i){const n=Object.keys(qs).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,n),qs[this.uri]=i}this.keyId=i}return this}}function YL(t){const e=new Uint8Array(16);for(let s=12;s<16;s++)e[s]=t>>8*(15-s)&255;return e}const gh=/\{\$([a-zA-Z0-9-_]+)\}/g;function Ra(t){return gh.test(t)}function xe(t,e,s){if(t.variableList!==null||t.hasVariableRefs)for(let i=s.length;i--;){const n=s[i],r=e[n];r&&(e[n]=jn(t,r))}}function jn(t,e){if(t.variableList!==null||t.hasVariableRefs){const s=t.variableList;return e.replace(gh,i=>{const n=i.substring(2,i.length-1),r=s?.[n];return r===void 0?(t.playlistParsingError||(t.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),i):r})}return e}function Ca(t,e,s){let i=t.variableList;i||(t.variableList=i={});let n,r;if("QUERYPARAM"in e){n=e.QUERYPARAM;try{const o=new self.URL(s).searchParams;if(o.has(n))r=o.get(n);else throw new Error(`"${n}" does not match any query parameter in URI: "${s}"`)}catch(o){t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${o.message}`))}}else n=e.NAME,r=e.VALUE;n in i?t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):i[n]=r||""}function jL(t,e,s){const i=e.IMPORT;if(s&&i in s){let n=t.variableList;n||(t.variableList=n={}),n[i]=s[i]}else t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function Ji(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const zL={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},_a=Ji();function XL(t,e){const s=zL[e];return!!s&&s[t.slice(0,4)]===!0}function fn(t,e){var s;
10return(s=_a?.isTypeSupported(`${e||"video"}/mp4;codecs="${t}"`))!=null?s:!1}const wa=/#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,Da=/#EXT-X-MEDIA:(.*)/g,QL=/^#EXT(?:INF|-X-TARGETDURATION):/m,ka=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),JL=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class We{static findGroup(e,s){for(let i=0;i<e.length;i++){const n=e[i];if(n.id===s)return n}}static convertAVC1ToAVCOTI(e){const s=e.split(".");if(s.length>2){let i=s.shift()+".";return i+=parseInt(s.shift()).toString(16),i+=("000"+parseInt(s.shift()).toString(16)).slice(-4),i}return e}static resolve(e,s){return Ao.buildAbsoluteURL(s,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return QL.test(e)}static parseMasterPlaylist(e,s){const i=Ra(e),n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},r=[];wa.lastIndex=0;let o;for(;(o=wa.exec(e))!=null;)if(o[1]){var a;const c=new ie(o[1]);xe(n,c,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const d=jn(n,o[2]),u={attrs:c,bitrate:c.decimalInteger("AVERAGE-BANDWIDTH")||c.decimalInteger("BANDWIDTH"),name:c.NAME,url:We.resolve(d,s)},h=c.decimalResolution("RESOLUTION");h&&(u.width=h.width,u.height=h.height),ZL((c.CODECS||"").split(/[ ,]+/).filter(f=>f),u),u.videoCodec&&u.videoCodec.indexOf("avc1")!==-1&&(u.videoCodec=We.convertAVC1ToAVCOTI(u.videoCodec)),(a=u.unknownCodecs)!=null&&a.length||r.push(u),n.levels.push(u)}else if(o[3]){const c=o[3],d=o[4];switch(c){case"SESSION-DATA":{const u=new ie(d);xe(n,u,["DATA-ID","LANGUAGE","VALUE","URI"]);const h=u["DATA-ID"];h&&(n.sessionData===null&&(n.sessionData={}),n.sessionData[h]=u);break}case"SESSION-KEY":{const u=Pa(d,s,n);u.encrypted&&u.isSupported()?(n.sessionKeys===null&&(n.sessionKeys=[]),n.sessionKeys.push(u)):v.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${d}"`);break}case"DEFINE":{{const u=new ie(d);xe(n,u,["NAME","VALUE","QUERYPARAM"]),Ca(n,u,s)}break}case"CONTENT-STEERING":{const u=new ie(d);xe(n,u,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:We.resolve(u["SERVER-URI"],s),pathwayId:u["PATHWAY-ID"]||"."};break}case"START":{n.startTimeOffset=Oa(d);break}}}const l=r.length>0&&r.length<n.levels.length;return n.levels=l?r:n.levels,n.levels.length===0&&(n.playlistParsingError=new Error("no levels found in manifest")),n}static parseMasterPlaylistMedia(e,s,i){let n;const r={},o=i.levels,a={AUDIO:o.map(c=>({id:c.attrs.AUDIO,audioCodec:c.audioCodec})),SUBTITLES:o.map(c=>({id:c.attrs.SUBTITLES,textCodec:c.textCodec})),"CLOSED-CAPTIONS":[]};let l=0;for(Da.lastIndex=0;(n=Da.exec(e))!==null;){const c=new ie(n[1]),d=c.TYPE;if(d){const u=a[d],h=r[d]||[];r[d]=h,xe(i,c,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const f={attrs:c,bitrate:0,id:l++,groupId:c["GROUP-ID"]||"",instreamId:c["INSTREAM-ID"],name:c.NAME||c.LANGUAGE||"",type:d,default:c.bool("DEFAULT"),autoselect:c.bool("AUTOSELECT"),forced:c.bool("FORCED"),lang:c.LANGUAGE,url:c.URI?We.resolve(c.URI,s):""};if(u!=null&&u.length){const g=We.findGroup(u,f.groupId)||u[0];Ma(f,g,"audioCodec"),Ma(f,g,"textCodec")}h.push(f)}}return r}static parseLevelPlaylist(e,s,i,n,r,o){const a=new yL(s),l=a.fragments;let c=null,d=0,u=0,h=0,f=0,g=null,m=new cn(n,s),y,S,E,T=-1,R=!1;for(ka.lastIndex=0,a.m3u8=e,a.hasVariableRefs=Ra(e);(y=ka.exec(e))!==null;){R&&(R=!1,m=new cn(n,s),m.start=h,m.sn=d,m.cc=f,m.level=i,c&&(m.initSegment=c,m.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null));const D=y[1];if(D){m.duration=parseFloat(D);const P=(" "+y[2]).slice(1);m.title=P||null,m.tagList.push(P?["INF",D,P]:["INF",D])}else if(y[3]){if(N(m.duration)){m.start=h,E&&Ua(m,E,a),m.sn=d,m.level=i,m.cc=f,m.urlId=r,l.push(m);const P=(" "+y[3]).slice(1);m.relurl=jn(a,P),Na(m,g),g=m,h+=m.duration,d++,u=0,R=!0}}else if(y[4]){const P=(" "+y[4]).slice(1);g?m.setByteRange(P,g):m.setByteRange(P)}else if(y[5])m.rawProgramDateTime=(" "+y[5]).slice(1),m.tagList.push(["PROGRAM-DATE-TIME",m.rawProgramDateTime]),T===-1&&(T=l.length);
vendor: 14,601 bytes, line 10
10else{if(y=y[0].match(JL),!y){v.warn("No matches on slow regex match for level playlist!");continue}for(S=1;S<y.length&&!(typeof y[S]<"u");S++);const P=(" "+y[S]).slice(1),C=(" "+y[S+1]).slice(1),F=y[S+2]?(" "+y[S+2]).slice(1):"";switch(P){case"PLAYLIST-TYPE":a.type=C.toUpperCase();break;case"MEDIA-SEQUENCE":d=a.startSN=parseInt(C);break;case"SKIP":{const O=new ie(C);xe(a,O,["RECENTLY-REMOVED-DATERANGES"]);const z=O.decimalInteger("SKIPPED-SEGMENTS");if(N(z)){a.skippedSegments=z;for(let se=z;se--;)l.unshift(null);d+=z}const ve=O.enumeratedString("RECENTLY-REMOVED-DATERANGES");ve&&(a.recentlyRemovedDateranges=ve.split(" "));break}case"TARGETDURATION":a.targetduration=Math.max(parseInt(C),1);break;case"VERSION":a.version=parseInt(C);break;case"EXTM3U":break;case"ENDLIST":a.live=!1;break;case"#":(C||F)&&m.tagList.push(F?[C,F]:[C]);break;case"DISCONTINUITY":f++,m.tagList.push(["DIS"]);break;case"GAP":m.gap=!0,m.tagList.push([P]);break;case"BITRATE":m.tagList.push([P,C]);break;case"DATERANGE":{const O=new ie(C);xe(a,O,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),xe(a,O,O.clientAttrs);const z=new Zu(O,a.dateRanges[O.ID]);z.isValid||a.skippedSegments?a.dateRanges[z.id]=z:v.warn(`Ignoring invalid DATERANGE tag: "${C}"`),m.tagList.push(["EXT-X-DATERANGE",C]);break}case"DEFINE":{{const O=new ie(C);xe(a,O,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in O?jL(a,O,o):Ca(a,O,s)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(C);break;case"KEY":{const O=Pa(C,s,a);if(O.isSupported()){if(O.method==="NONE"){E=void 0;break}E||(E={}),E[O.keyFormat]&&(E=de({},E)),E[O.keyFormat]=O}else v.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${C}"`);break}case"START":a.startTimeOffset=Oa(C);break;case"MAP":{const O=new ie(C);if(xe(a,O,["BYTERANGE","URI"]),m.duration){const z=new cn(n,s);Fa(z,O,i,E),c=z,m.initSegment=c,c.rawProgramDateTime&&!m.rawProgramDateTime&&(m.rawProgramDateTime=c.rawProgramDateTime)}else Fa(m,O,i,E),c=m,R=!0;break}case"SERVER-CONTROL":{const O=new ie(C);a.canBlockReload=O.bool("CAN-BLOCK-RELOAD"),a.canSkipUntil=O.optionalFloat("CAN-SKIP-UNTIL",0),a.canSkipDateRanges=a.canSkipUntil>0&&O.bool("CAN-SKIP-DATERANGES"),a.partHoldBack=O.optionalFloat("PART-HOLD-BACK",0),a.holdBack=O.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const O=new ie(C);a.partTarget=O.decimalFloatingPoint("PART-TARGET");break}case"PART":{let O=a.partList;O||(O=a.partList=[]);const z=u>0?O[O.length-1]:void 0,ve=u++,se=new ie(C);xe(a,se,["BYTERANGE","URI"]);const re=new pL(se,m,s,ve,z);O.push(re),m.duration+=re.duration;break}case"PRELOAD-HINT":{const O=new ie(C);xe(a,O,["URI"]),a.preloadHint=O;break}case"RENDITION-REPORT":{const O=new ie(C);xe(a,O,["URI"]),a.renditionReports=a.renditionReports||[],a.renditionReports.push(O);break}default:v.warn(`line parsed but not handled: ${y}`);break}}}g&&!g.relurl?(l.pop(),h-=g.duration,a.partList&&(a.fragmentHint=g)):a.partList&&(Na(m,g),m.cc=f,a.fragmentHint=m,E&&Ua(m,E,a));const I=l.length,k=l[0],w=l[I-1];if(h+=a.skippedSegments*a.targetduration,h>0&&I&&w){a.averagetargetduration=h/I;const D=w.sn;a.endSN=D!=="initSegment"?D:0,a.live||(w.endList=!0),k&&(a.startCC=k.cc)}else a.endSN=0,a.startCC=0;return a.fragmentHint&&(h+=a.fragmentHint.duration),a.totalduration=h,a.endCC=f,T>0&&eR(l,T),a}}function Pa(t,e,s){var i,n;const r=new ie(t);xe(s,r,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const o=(i=r.METHOD)!=null?i:"",a=r.URI,l=r.hexadecimalInteger("IV"),c=r.KEYFORMATVERSIONS,d=(n=r.KEYFORMAT)!=null?n:"identity";a&&r.IV&&!l&&v.error(`Invalid IV: ${r.IV}`);const u=a?We.resolve(a,e):"",h=(c||"1").split("/").map(Number).filter(Number.isFinite);return new _s(o,u,d,h,l)}function Oa(t){const s=new ie(t).decimalFloatingPoint("TIME-OFFSET");return N(s)?s:null}function ZL(t,e){["video","audio","text"].forEach(s=>{const i=t.filter(n=>XL(n,s));if(i.length){const n=i.filter(r=>r.lastIndexOf("avc1",0)===0||r.lastIndexOf("mp4a",0)===0);e[`${s}Codec`]=n.length>0?n[0]:i[0],t=t.filter(r=>i.indexOf(r)===-1)}}),e.unknownCodecs=t}function Ma(t,e,s){const i=e[s];i&&(t[s]=i)}function eR(t,e){let s=t[e];for(let i=e;i--;){const n=t[i];if(!n)return;n.programDateTime=s.programDateTime-n.duration*1e3,s=n}}function Na(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):e!=null&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),N(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function Fa(t,e,s,i){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=s,t.sn="initSegment",i&&(t.levelkeys=i),t.initSegment=null}function Ua(t,e,s){t.levelkeys=e;const{encryptedFragments:i}=s;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(n=>e[n].isCommonEncryption)&&i.push(t)}var q={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},$={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Ba(t){const{type:e}=t;switch(e){case q.AUDIO_TRACK:return $.AUDIO;case q.SUBTITLE_TRACK:return $.SUBTITLE;default:return $.MAIN}}function gn(t,e){let s=t.url;return(s===void 0||s.indexOf("data:")===0)&&(s=e.url),s}class tR{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(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(p.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(p.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const s=this.hls.config,i=s.pLoader,n=s.loader,r=i||n,o=new r(s);return this.loaders[e.type]=o,o}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const s=this.loaders[e];s&&s.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,s){const{url:i}=s;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:q.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(e,s){const{id:i,level:n,url:r,deliveryDirectives:o}=s;this.load({id:i,level:n,responseType:"text",type:q.LEVEL,url:r,deliveryDirectives:o})}onAudioTrackLoading(e,s){const{id:i,groupId:n,url:r,deliveryDirectives:o}=s;this.load({id:i,groupId:n,level:null,responseType:"text",type:q.AUDIO_TRACK,url:r,deliveryDirectives:o})}onSubtitleTrackLoading(e,s){const{id:i,groupId:n,url:r,deliveryDirectives:o}=s;this.load({id:i,groupId:n,level:null,responseType:"text",type:q.SUBTITLE_TRACK,url:r,deliveryDirectives:o})}load(e){var s;const i=this.hls.config;let n=this.getInternalLoader(e);if(n){const c=n.context;if(c&&c.url===e.url){v.trace("[playlist-loader]: playlist request ongoing");return}v.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),n.abort()}let r;if(e.type===q.MANIFEST?r=i.manifestLoadPolicy.default:r=de({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(e),(s=e.deliveryDirectives)!=null&&s.part){let c;if(e.type===q.LEVEL&&e.level!==null?c=this.hls.levels[e.level].details:e.type===q.AUDIO_TRACK&&e.id!==null?c=this.hls.audioTracks[e.id].details:e.type===q.SUBTITLE_TRACK&&e.id!==null&&(c=this.hls.subtitleTracks[e.id].details),c){const d=c.partTarget,u=c.targetduration;if(d&&u){const h=Math.max(d*3,u*.8)*1e3;r=de({},r,{maxTimeToFirstByteMs:Math.min(h,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,r.maxTimeToFirstByteMs)})}}}const o=r.errorRetry||r.timeoutRetry||{},a={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},l={onSuccess:(c,d,u,h)=>{const f=this.getInternalLoader(u);this.resetInternalLoader(u.type);const g=c.data;if(g.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(c,u,new Error("no EXTM3U delimiter"),h||null,d);return}d.parsing.start=performance.now(),We.isMediaPlaylist(g)?this.handleTrackOrLevelPlaylist(c,d,u,h||null,f):this.handleMasterPlaylist(c,d,u,h)},onError:(c,d,u,h)=>{this.handleNetworkError(d,u,!1,c,h)},onTimeout:(c,d,u)=>{this.handleNetworkError(d,u,!0,void 0,c)}};n.load(e,a,l)}handleMasterPlaylist(e,s,i,n){const r=this.hls,o=e.data,a=gn(e,i),l=We.parseMasterPlaylist(o,a);if(l.playlistParsingError){this.handleManifestParsingError(e,i,l.playlistParsingError,n,s);return}const{contentSteering:c,levels:d,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:g}=l;this.variableList=g;const{AUDIO:m=[],SUBTITLES:y,"CLOSED-CAPTIONS":S}=We.parseMasterPlaylistMedia(o,a,l);m.length&&!m.some(T=>!T.url)&&d[0].audioCodec&&!d[0].attrs.AUDIO&&(v.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 ie({}),bitrate:0,url:""})),r.trigger(p.MANIFEST_LOADED,{levels:d,audioTracks:m,subtitles:y,captions:S,contentSteering:c,url:a,stats:s,networkDetails:n,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:g})}handleTrackOrLevelPlaylist(e,s,i,n,r){const o=this.hls,{id:a,level:l,type:c}=i,d=gn(e,i),u=N(a)?a:0,h=N(l)?l:u,f=Ba(i),g=We.parseLevelPlaylist(e.data,d,h,f,u,this.variableList);if(c===q.MANIFEST){const m={attrs:new ie({}),bitrate:0,details:g,name:"",url:d};o.trigger(p.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:d,stats:s,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}s.parsing.end=performance.now(),i.levelDetails=g,this.handlePlaylistLoaded(g,e,s,i,n,r)}handleManifestParsingError(e,s,i,n,r){this.hls.trigger(p.ERROR,{type:B.NETWORK_ERROR,details:L.MANIFEST_PARSING_ERROR,fatal:s.type===q.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:s,networkDetails:n,stats:r})}handleNetworkError(e,s,i=!1,n,r){let o=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${e.type}`;e.type===q.LEVEL?o+=`: ${e.level} id: ${e.id}`:(e.type===q.AUDIO_TRACK||e.type===q.SUBTITLE_TRACK)&&(o+=` id: ${e.id} group-id: "${e.groupId}"`);const a=new Error(o);v.warn(`[playlist-loader]: ${o}`);let l=L.UNKNOWN,c=!1;const d=this.getInternalLoader(e);switch(e.type){case q.MANIFEST:l=i?L.MANIFEST_LOAD_TIMEOUT:L.MANIFEST_LOAD_ERROR,c=!0;break;case q.LEVEL:l=i?L.LEVEL_LOAD_TIMEOUT:L.LEVEL_LOAD_ERROR,c=!1;break;case q.AUDIO_TRACK:l=i?L.AUDIO_TRACK_LOAD_TIMEOUT:L.AUDIO_TRACK_LOAD_ERROR,c=!1;break;case q.SUBTITLE_TRACK:l=i?L.SUBTITLE_TRACK_LOAD_TIMEOUT:L.SUBTITLE_LOAD_ERROR,c=!1;break}d&&this.resetInternalLoader(e.type);const u={type:B.NETWORK_ERROR,details:l,fatal:c,url:e.url,loader:d,context:e,error:a,networkDetails:s,stats:r};if(n){const h=s?.url||e.url;u.response=Re({url:h,data:void 0},n)}this.hls.trigger(p.ERROR,u)}handlePlaylistLoaded(e,s,i,n,r,o){const a=this.hls,{type:l,level:c,id:d,groupId:u,deliveryDirectives:h}=n,f=gn(s,n),g=Ba(n),m=typeof n.level=="number"&&g===$.MAIN?c:void 0;if(!e.fragments.length){const S=new Error("No Segments found in Playlist");a.trigger(p.ERROR,{type:B.NETWORK_ERROR,details:L.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:S,reason:S.message,response:s,context:n,level:m,parent:g,networkDetails:r,stats:i});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const y=e.playlistParsingError;if(y){a.trigger(p.ERROR,{type:B.NETWORK_ERROR,details:L.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:y,reason:y.message,response:s,context:n,level:m,parent:g,networkDetails:r,stats:i});return}switch(e.live&&o&&(o.getCacheAge&&(e.ageHeader=o.getCacheAge()||0),(!o.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case q.MANIFEST:case q.LEVEL:a.trigger(p.LEVEL_LOADED,{details:e,level:m||0,id:d||0,stats:i,networkDetails:r,deliveryDirectives:h});break;case q.AUDIO_TRACK:a.trigger(p.AUDIO_TRACK_LOADED,{details:e,id:d||0,groupId:u||"",stats:i,networkDetails:r,deliveryDirectives:h});break;case q.SUBTITLE_TRACK:a.trigger(p.SUBTITLE_TRACK_LOADED,{details:e,id:d||0,groupId:u||"",stats:i,networkDetails:r,deliveryDirectives:h});break}}}function ph(t,e){let s;try{s=new Event("addtrack")}catch{s=document.createEvent("Event"),s.initEvent("addtrack",!1,!1)}s.track=t,e.dispatchEvent(s)}function mh(t,e){const s=t.mode;if(s==="disabled"&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){v.debug(`[texttrack-utils]: ${i}`);try{const n=new self.TextTrackCue(e.startTime,e.endTime,e.text);n.id=e.id,t.addCue(n)}catch(n){v.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${n}`)}}s==="disabled"&&(t.mode=s)}function Yt(t){const e=t.mode;if(e==="disabled"&&(t.mode="hidden"),t.cues)for(let s=t.cues.length;s--;)t.removeCue(t.cues[s]);e==="disabled"&&(t.mode=e)}function zn(t,e,s,i){const n=t.mode;if(n==="disabled"&&(t.mode="hidden"),t.cues&&t.cues.length>0){const r=iR(t.cues,e,s);for(let o=0;o<r.length;o++)(!i||i(r[o]))&&t.removeCue(r[o])}n==="disabled"&&(t.mode=n)}function sR(t,e){if(e<t[0].startTime)return 0;const s=t.length-1;if(e>t[s].endTime)return-1;let i=0,n=s;for(;i<=n;){const r=Math.floor((n+i)/2);if(e<t[r].startTime)n=r-1;else if(e>t[r].startTime&&i<s)i=r+1;else return r}return t[i].startTime-e<e-t[n].startTime?i:n}function iR(t,e,s){const i=[],n=sR(t,e);if(n>-1)for(let r=n,o=t.length;r<o;r++){const a=t[r];if(a.startTime>=e&&a.endTime<=s)i.push(a);else if(a.startTime>s)return i}return i}var Ke={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const nR=.25;function Xn(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const Ys=(()=>{const t=Xn();try{new t(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function pn(t,e){return t.getTime()/1e3-e}function rR(t){return Uint8Array.from(t.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class oR{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;
10e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,s){this.media=s.media}onMediaDetaching(){this.id3Track&&(Yt(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const s=this.getID3Track(e.textTracks);return s.mode="hidden",s}getID3Track(e){if(this.media){for(let s=0;s<e.length;s++){const i=e[s];if(i.kind==="metadata"&&i.label==="id3")return ph(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,s){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:n}}}=this;if(!i&&!n)return;const{samples:r}=s;this.id3Track||(this.id3Track=this.createTrack(this.media));const o=Xn();for(let a=0;a<r.length;a++){const l=r[a].type;if(l===Ke.emsg&&!i||!n)continue;const c=oh(r[a].data);if(c){const d=r[a].pts;let u=d+r[a].duration;u>Ys&&(u=Ys),u-d<=0&&(u=d+nR);for(let f=0;f<c.length;f++){const g=c[f];if(!rh(g)){this.updateId3CueEnds(d,l);const m=new o(d,u,"");m.value=g,l&&(m.type=l),this.id3Track.addCue(m)}}}}}updateId3CueEnds(e,s){var i;const n=(i=this.id3Track)==null?void 0:i.cues;if(n)for(let r=n.length;r--;){const o=n[r];o.type===s&&o.startTime<e&&o.endTime===Ys&&(o.endTime=e)}}onBufferFlushing(e,{startOffset:s,endOffset:i,type:n}){const{id3Track:r,hls:o}=this;if(!o)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:l}}=o;if(r&&(a||l)){let c;n==="audio"?c=d=>d.type===Ke.audioId3&&l:n==="video"?c=d=>d.type===Ke.emsg&&a:c=d=>d.type===Ke.audioId3&&l||d.type===Ke.emsg&&a,zn(r,s,i,c)}}onLevelUpdated(e,{details:s}){if(!this.media||!s.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:n}=this,{dateRanges:r}=s,o=Object.keys(r);if(n){const d=Object.keys(i).filter(u=>!o.includes(u));for(let u=d.length;u--;){const h=d[u];Object.keys(i[h].cues).forEach(f=>{n.removeCue(i[h].cues[f])}),delete i[h]}}const a=s.fragments[s.fragments.length-1];if(o.length===0||!N(a?.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=a.programDateTime/1e3-a.start,c=Xn();for(let d=0;d<o.length;d++){const u=o[d],h=r[u],f=i[u],g=f?.cues||{};let m=f?.durationKnown||!1;const y=pn(h.startDate,l);let S=Ys;const E=h.endDate;if(E)S=pn(E,l),m=!0;else if(h.endOnNext&&!m){const R=o.reduce((I,k)=>{const w=r[k];return w.class===h.class&&w.id!==k&&w.startDate>h.startDate&&I.push(w),I},[]).sort((I,k)=>I.startDate.getTime()-k.startDate.getTime())[0];R&&(S=pn(R.startDate,l),m=!0)}const T=Object.keys(h.attr);for(let R=0;R<T.length;R++){const I=T[R];if(!fL(I))continue;let k=g[I];if(k)m&&!f.durationKnown&&(k.endTime=S);else{let w=h.attr[I];k=new c(y,S,""),gL(I)&&(w=rR(w)),k.value={key:I,data:w},k.type=Ke.dateRange,k.id=u,this.id3Track.addCue(k),g[I]=k}}i[u]={cues:g,dateRange:h,durationKnown:m}}}}class aR{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:s}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:s?e.liveMaxLatencyDurationCount*s.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(e===null)return null;const{holdBack:s,partHoldBack:i,targetduration:n}=e,{liveSyncDuration:r,liveSyncDurationCount:o,lowLatencyMode:a}=this.config,l=this.hls.userConfig;let c=a&&i||s;(l.liveSyncDuration||l.liveSyncDurationCount||c===0)&&(c=r!==void 0?r:o*n);const d=n;return c+Math.min(this.stallCount*1,d)}get liveSyncPosition(){const e=this.estimateLiveEdge(),s=this.targetLatency,i=this.levelDetails;if(e===null||s===null||i===null)return null;const n=i.edge,r=e-s-this.edgeStalled,o=n-i.totalduration,a=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(o,r),a)}get drift(){const{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(e===null)return 0;const s=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-s,0)}get forwardBufferLength(){const{media:e,levelDetails:s}=this;if(!e||!s)return 0;const i=e.buffered.length;return(i?e.buffered.end(i-1):s.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}
10registerListeners(){this.hls.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(p.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(p.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(p.ERROR,this.onError,this)}onMediaAttached(e,s){this.media=s.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:s}){this.levelDetails=s,s.advanced&&this.timeupdate(),!s.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,s){var i;s.details===L.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&v.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:s}=this;if(!e||!s)return;this.currentTime=e.currentTime;const i=this.computeLatency();if(i===null)return;this._latency=i;const{lowLatencyMode:n,maxLiveSyncPlaybackRate:r}=this.config;if(!n||r===1)return;const o=this.targetLatency;if(o===null)return;const a=i-o,l=Math.min(this.maxLatency,o+s.targetduration),c=a<l;if(s.live&&c&&a>.05&&this.forwardBufferLength>1){const d=Math.min(2,Math.max(1,r)),u=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20;e.playbackRate=Math.min(d,Math.max(1,u))}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 Qn=["NONE","TYPE-0","TYPE-1",null];var Ss={No:"",Yes:"YES",v2:"v2"};function lR(t,e){const{canSkipUntil:s,canSkipDateRanges:i,endSN:n}=t,r=e!==void 0?e-n:0;return s&&r<s?i?Ss.v2:Ss.Yes:Ss.No}class $a{constructor(e,s,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=s,this.skip=i}addDirectives(e){const s=new self.URL(e);return this.msn!==void 0&&s.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&s.searchParams.set("_HLS_part",this.part.toString()),this.skip&&s.searchParams.set("_HLS_skip",this.skip),s.href}}class ws{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[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.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter(s=>s).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(e){const s=e%this.url.length;this._urlId!==s&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=s)}get audioGroupId(){var e;return(e=this.audioGroupIds)==null?void 0:e[this.urlId]}get textGroupId(){var e;return(e=this.textGroupIds)==null?void 0:e[this.urlId]}addFallback(e){this.url.push(e.url),this._attrs.push(e.attrs)}}function mn(t,e){const s=e.startPTS;if(N(s)){let i=0,n;e.sn>t.sn?(i=s-t.start,n=t):(i=t.start-s,n=e),n.duration!==i&&(n.duration=i)}else e.sn>t.sn?t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration:e.start=Math.max(t.start-e.duration,0)}function yh(t,e,s,i,n,r){i-s<=0&&(v.warn("Fragment should have a positive duration",e),i=s+e.duration,r=n+e.duration);let a=s,l=i;const c=e.startPTS,d=e.endPTS;if(N(c)){const y=Math.abs(c-s);N(e.deltaPTS)?e.deltaPTS=Math.max(y,e.deltaPTS):e.deltaPTS=y,a=Math.max(s,c),s=Math.min(s,c),n=Math.min(n,e.startDTS),l=Math.min(i,d),i=Math.max(i,d),r=Math.max(r,e.endDTS)}const u=s-e.start;e.start!==0&&(e.start=s),e.duration=i-e.start,e.startPTS=s,e.maxStartPTS=a,e.startDTS=n,e.endPTS=i,e.minEndPTS=l,e.endDTS=r;const h=e.sn;if(!t||h<t.startSN||h>t.endSN)return 0;let f;const g=h-t.startSN,m=t.fragments;for(m[g]=e,f=g;f>0;f--)mn(m[f],m[f-1]);for(f=g;f<m.length-1;f++)mn(m[f],m[f+1]);return t.fragmentHint&&mn(m[m.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,u}function cR(t,e){let s=null;const i=t.fragments;for(let l=i.length-1;l>=0;l--){const c=i[l].initSegment;if(c){s=c;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;let n=0,r;if(hR(t,e,(l,c)=>{l.relurl&&(n=l.cc-c.cc),N(l.startPTS)&&N(l.endPTS)&&(c.start=c.startPTS=l.startPTS,c.startDTS=l.startDTS,c.maxStartPTS=l.maxStartPTS,c.endPTS=l.endPTS,c.endDTS=l.endDTS,c.minEndPTS=l.minEndPTS,c.duration=l.endPTS-l.startPTS,c.duration&&(r=c),e.PTSKnown=e.alignedSliding=!0),c.elementaryStreams=l.elementaryStreams,c.loader=l.loader,c.stats=l.stats,c.urlId=l.urlId,l.initSegment&&(c.initSegment=l.initSegment,s=l.initSegment)}),s&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEac
vendor: 4,369 bytes, line 10
10h(c=>{var d;(!c.initSegment||c.initSegment.relurl===((d=s)==null?void 0:d.relurl))&&(c.initSegment=s)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){v.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=dR(t.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const o=e.fragments;if(n){v.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<o.length;l++)o[l].cc+=n}e.skippedSegments&&(e.startCC=e.fragments[0].cc),uR(t.partList,e.partList,(l,c)=>{c.elementaryStreams=l.elementaryStreams,c.stats=l.stats}),r?yh(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):Sh(t,e),o.length&&(e.totalduration=e.edge-o[0].start),e.driftStartTime=t.driftStartTime,e.driftStart=t.driftStart;const a=e.advancedDateTime;if(e.advanced&&a){const l=e.edge;e.driftStart||(e.driftStartTime=a,e.driftStart=l),e.driftEndTime=a,e.driftEnd=l}else e.driftEndTime=t.driftEndTime,e.driftEnd=t.driftEnd,e.advancedDateTime=t.advancedDateTime}function dR(t,e,s){const i=de({},t);return s&&s.forEach(n=>{delete i[n]}),Object.keys(e).forEach(n=>{const r=new Zu(e[n].attr,i[n]);r.isValid?i[n]=r:v.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[n].attr)}"`)}),i}function uR(t,e,s){if(t&&e){let i=0;for(let n=0,r=t.length;n<=r;n++){const o=t[n],a=e[n+i];o&&a&&o.index===a.index&&o.fragment.sn===a.fragment.sn?s(o,a):i--}}}function hR(t,e,s){const i=e.skippedSegments,n=Math.max(t.startSN,e.startSN)-e.startSN,r=(t.fragmentHint?1:0)+(i?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,o=e.startSN-t.startSN,a=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;for(let c=n;c<=r;c++){const d=l[o+c];let u=a[c];i&&!u&&c<i&&(u=e.fragments[c]=d),d&&u&&s(d,u)}}function Sh(t,e){const s=e.startSN+e.skippedSegments-t.startSN,i=t.fragments;s<0||s>=i.length||Jn(e,i[s].start)}function Jn(t,e){if(e){const s=t.fragments;for(let i=t.skippedSegments;i<s.length;i++)s[i].start+=e;t.fragmentHint&&(t.fragmentHint.start+=e)}}function fR(t,e=1/0){let s=1e3*t.targetduration;if(t.updated){const i=t.fragments;if(i.length&&s*4>e){const r=i[i.length-1].duration*1e3;r<s&&(s=r)}}else s/=2;return Math.round(s)}function gR(t,e,s){if(!(t!=null&&t.details))return null;const i=t.details;let n=i.fragments[e-i.startSN];return n||(n=i.fragmentHint,n&&n.sn===e)?n:e<i.startSN&&s&&s.sn===e?s:null}function Va(t,e,s){var i;return t!=null&&t.details?vh((i=t.details)==null?void 0:i.partList,e,s):null}function vh(t,e,s){if(t)for(let i=t.length;i--;){const n=t[i];if(n.index===s&&n.fragment.sn===e)return n}return null}function Ti(t){switch(t.details){case L.FRAG_LOAD_TIMEOUT:case L.KEY_LOAD_TIMEOUT:case L.LEVEL_LOAD_TIMEOUT:case L.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Ga(t,e){const s=Ti(e);return t.default[`${s?"timeout":"error"}Retry`]}function Ro(t,e){const s=t.backoff==="linear"?1:Math.pow(2,e);return Math.min(s*t.retryDelayMs,t.maxRetryDelayMs)}function Ha(t){return Re(Re({},t),{errorRetry:null,timeoutRetry:null})}function Ei(t,e,s,i){return!!t&&e<t.maxNumRetry&&(pR(i)||!!s)}function pR(t){return t===0&&navigator.onLine===!1||!!t&&(t<400||t>499)}const Th={search:function(t,e){let s=0,i=t.length-1,n=null,r=null;for(;s<=i;){n=(s+i)/2|0,r=t[n];const o=e(r);if(o>0)s=n+1;else if(o<0)i=n-1;else return r}return null}};function mR(t,e,s){if(e===null||!Array.isArray(t)||!t.length||!N(e))return null;const i=t[0].programDateTime;if(e<(i||0))return null;const n=t[t.length-1].endProgramDateTime;if(e>=(n||0))return null;s=s||0;for(let r=0;r<t.length;++r){const o=t[r];if(yR(e,s,o))return o}return null}function Ds(t,e,s=0,i=0){let n=null;if(t?n=e[t.sn-e[0].sn+1]||null:s===0&&e[0].start===0&&(n=e[0]),n&&Zn(s,i,n)===0)return n;const r=Th.search(e,Zn.bind(null,s,i));return r&&(r!==t||!n)?r:n}function Zn(t=0,e=0,s){if(s.start<=t&&s.start+s.duration>t)return 0;const i=Math.min(e,s.duration+(s.deltaPTS?s.deltaPTS:0));return s.start+s.duration-i<=t?1:s.start-i>t&&s.start?-1:0}function yR(t,e,s){const i=Math.min(e,s.duration+(s.deltaPTS?s.deltaPTS:0))*1e3;return(s.endProgramDateTime||0)-i>t}function SR(t,e){return Th.search(t,s=>s.cc<e?1:s.cc>e?-1:0)}const vR=3e5;
10var Se={DoNothing:0,SendAlternateToPenaltyBox:2,RetryRequest:5},Fe={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2};class TR{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=v.log.bind(v,"[info]:"),this.warn=v.warn.bind(v,"[warning]:"),this.error=v.error.bind(v,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(p.ERROR,this.onError,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(p.ERROR,this.onError,this),e.off(p.ERROR,this.onErrorOut,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){this.playlistError=0}stopLoad(){}getVariantLevelIndex(e){return e?.type===$.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,s){var i,n;if(s.fatal)return;const r=this.hls,o=s.context;switch(s.details){case L.FRAG_LOAD_ERROR:case L.FRAG_LOAD_TIMEOUT:case L.KEY_LOAD_ERROR:case L.KEY_LOAD_TIMEOUT:s.errorAction=this.getFragRetryOrSwitchAction(s);return;case L.FRAG_PARSING_ERROR:if((i=s.frag)!=null&&i.gap){s.errorAction={action:Se.DoNothing,flags:Fe.None};return}case L.FRAG_GAP:case L.FRAG_DECRYPT_ERROR:{s.errorAction=this.getFragRetryOrSwitchAction(s),s.errorAction.action=Se.SendAlternateToPenaltyBox;return}case L.LEVEL_EMPTY_ERROR:case L.LEVEL_PARSING_ERROR:{var a,l;const c=s.parent===$.MAIN?s.level:r.loadLevel;s.details===L.LEVEL_EMPTY_ERROR&&((a=s.context)!=null&&(l=a.levelDetails)!=null&&l.live)?s.errorAction=this.getPlaylistRetryOrSwitchAction(s,c):(s.levelRetry=!1,s.errorAction=this.getLevelSwitchAction(s,c))}return;case L.LEVEL_LOAD_ERROR:case L.LEVEL_LOAD_TIMEOUT:typeof o?.level=="number"&&(s.errorAction=this.getPlaylistRetryOrSwitchAction(s,o.level));return;case L.AUDIO_TRACK_LOAD_ERROR:case L.AUDIO_TRACK_LOAD_TIMEOUT:case L.SUBTITLE_LOAD_ERROR:case L.SUBTITLE_TRACK_LOAD_TIMEOUT:if(o){const c=r.levels[r.loadLevel];if(c&&(o.type===q.AUDIO_TRACK&&o.groupId===c.audioGroupId||o.type===q.SUBTITLE_TRACK&&o.groupId===c.textGroupId)){s.errorAction=this.getPlaylistRetryOrSwitchAction(s,r.loadLevel),s.errorAction.action=Se.SendAlternateToPenaltyBox,s.errorAction.flags=Fe.MoveAllAlternatesMatchingHost;return}}return;case L.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const c=r.levels[r.loadLevel],d=c?.attrs["HDCP-LEVEL"];d&&(s.errorAction={action:Se.SendAlternateToPenaltyBox,flags:Fe.MoveAllAlternatesMatchingHDCP,hdcpLevel:d})}return;case L.BUFFER_ADD_CODEC_ERROR:case L.REMUX_ALLOC_ERROR:s.errorAction=this.getLevelSwitchAction(s,(n=s.level)!=null?n:r.loadLevel);return;case L.INTERNAL_EXCEPTION:case L.BUFFER_APPENDING_ERROR:case L.BUFFER_APPEND_ERROR:case L.BUFFER_FULL_ERROR:case L.LEVEL_SWITCH_ERROR:case L.BUFFER_STALLED_ERROR:case L.BUFFER_SEEK_OVER_HOLE:case L.BUFFER_NUDGE_ON_STALL:s.errorAction={action:Se.DoNothing,flags:Fe.None};return}if(s.type===B.KEY_SYSTEM_ERROR){const c=this.getVariantLevelIndex(s.frag);s.levelRetry=!1,s.errorAction=this.getLevelSwitchAction(s,c);return}}getPlaylistRetryOrSwitchAction(e,s){var i;const n=this.hls,r=Ga(n.config.playlistLoadPolicy,e),o=this.playlistError++,a=(i=e.response)==null?void 0:i.code;if(Ei(r,o,Ti(e),a))return{action:Se.RetryRequest,flags:Fe.None,retryConfig:r,retryCount:o};const c=this.getLevelSwitchAction(e,s);return r&&(c.retryConfig=r,c.retryCount=o),c}getFragRetryOrSwitchAction(e){const s=this.hls,i=this.getVariantLevelIndex(e.frag),n=s.levels[i],{fragLoadPolicy:r,keyLoadPolicy:o}=s.config,a=Ga(e.details.startsWith("key")?o:r,e),l=s.levels.reduce((u,h)=>u+h.fragmentError,0);if(n){var c;e.details!==L.FRAG_GAP&&n.fragmentError++;const u=(c=e.response)==null?void 0:c.code;if(Ei(a,l,Ti(e),u))return{action:Se.RetryRequest,flags:Fe.None,retryConfig:a,retryCount:l}}const d=this.getLevelSwitchAction(e,i);return a&&(d.retryConfig=a,d.retryCount=l),d}getLevelSwitchAction(e,s){const i=this.hls;s==null&&(s=i.loadLevel);const n=this.hls.levels[s];if(n&&(n.loadError++,i.autoLevelEnabled)){var r,o;let a=-1;const{levels:l,loadLevel:c,minAutoLevel:d,maxAutoLevel:u}=i,h=(r=e.frag)==null?void 0:r.type,{type:f,groupId:g}=(o=e.context)!=null?o:{};for(let m=l.length;m--;){const y=(m+c)%l.length;if(y!==c&&y>=d&&y<=u&&l[y].loadError===0){const S=l[y];if(e.details===L.FRAG_GAP&&e.frag){const E=l[y].details;if(E){const T=Ds(e.frag,E.fragments,e.frag.start);if(T!=null&&T.gap)continue}}else{if(f===q.AUDIO_TRACK&&g===S.audioGroupId||f===q.SUBTITLE_TRACK&&g===S.textGroupId)continue;if(h===$.AUDIO&&n.audioGroupId===S.audioGroupId||h===$.SUBTITLE&&n.textGroupId===S.textGroupId)continue}a=y;break}}if(a>-1&&i.loadLevel!==a)return e.levelRetry=!0,this.playlistError=0,{action:Se.SendAlternateToPenaltyBox,flags:Fe.None,nextAutoLevel:a}}return{action:Se.SendAlternateToPenaltyBox,flags:Fe.MoveAllAlternatesMatchingHost}}onErrorOut(e,s){var i;switch((i=s.errorAction)==null?void 0:i.action){case Se.DoNothing:break;case Se.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(s),!s.errorAction.resolved&&s.details!==L.FRAG_GAP&&(s.fatal=!0);break}if(s.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const s=this.hls,i=e.errorAction;if(!i)return;const{flags:n,hdcpLevel:r,nextAutoLevel:o}=i;switch(n){case Fe.None:this.switchLevel(e,o);break;case Fe.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(e));break;case Fe.MoveAllAlternatesMatchingHDCP:r&&(s.maxHdcpLevel=Qn[Qn.indexOf(r)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${s.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(e,o)}switchLevel(e,s){s!==void 0&&e.errorAction&&(this.warn(`switching to level ${s} after ${e.details}`),this.hls.nextAutoLevel=s,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(e){const{hls:s,penalizedRenditions:i}=this,n=e.parent===$.MAIN?e.level:s.loadLevel,r=s.levels[n],o=r.url.length,a=e.frag?e.frag.urlId:r.urlId;r.urlId===a&&(!e.frag||r.details)&&this.penalizeRendition(r,e);for(let l=1;l<o;l++){const c=(a+l)%o,d=i[c];if(!d||ER(d,e,i[a]))return this.warn(`Switching to Redundant Stream ${c+1}/${o}: "${r.url[c]}" after ${e.details}
10`),this.playlistError=0,s.levels.forEach(u=>{u.urlId=c}),s.nextLoadLevel=n,!0}return!1}penalizeRendition(e,s){const{penalizedRenditions:i}=this,n=i[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};n.lastErrorPerfMs=performance.now(),n.errors.push(s),n.details=e.details,i[e.urlId]=n}}function ER(t,e,s){if(performance.now()-t.lastErrorPerfMs>vR)return!0;const i=t.details;if(e.details===L.FRAG_GAP&&i&&e.frag){const n=e.frag.start,r=Ds(null,i.fragments,n);if(r&&!r.gap)return!0}if(s&&t.errors.length<s.errors.length){const n=t.errors[t.errors.length-1];if(i&&n.frag&&e.frag&&Math.abs(n.frag.start-e.frag.start)>i.targetduration*3)return!0}return!1}class Co{constructor(e,s){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=v.log.bind(v,`${s}:`),this.warn=v.warn.bind(v,`${s}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,s){const i=s?.renditionReports;if(i){let n=-1;for(let r=0;r<i.length;r++){const o=i[r];let a;try{a=new self.URL(o.URI,s.url).href}catch(l){v.warn(`Could not construct new URL for Rendition Report: ${l}`),a=o.URI||""}if(a===e){n=r;break}else a===e.substring(0,a.length)&&(n=r)}if(n!==-1){const r=i[n],o=parseInt(r["LAST-MSN"])||s?.lastPartSn;let a=parseInt(r["LAST-PART"])||s?.lastPartIndex;if(this.hls.config.lowLatencyMode){const l=Math.min(s.age-s.partTarget,s.targetduration);a>=0&&l>s.partTarget&&(a+=1)}return new $a(o,a>=0?a:void 0,Ss.No)}}}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,s,i){const{details:n,stats:r}=s,o=self.performance.now(),a=r.loading.first?Math.max(0,o-r.loading.first):0;if(n.advancedDateTime=Date.now()-a,n.live||i!=null&&i.live){if(n.reloaded(i),i&&this.log(`live playlist ${e} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:"MISSED"}`),i&&n.fragments.length>0&&cR(i,n),!this.canLoad||!n.live)return;let l,c,d;if(n.canBlockReload&&n.endSN&&n.advanced){const y=this.hls.config.lowLatencyMode,S=n.lastPartSn,E=n.endSN,T=n.lastPartIndex,R=T!==-1,I=S===E,k=y?0:T;R?(c=I?E+1:S,d=I?k:T+1):c=E+1;const w=n.age,D=w+n.ageHeader;let P=Math.min(D-n.partTarget,n.targetduration*1.5);if(P>0){if(i&&P>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${P} with playlist age: ${n.age}`),P=0;else{const C=Math.floor(P/n.targetduration);if(c+=C,d!==void 0){const F=Math.round(P%n.targetduration/n.partTarget);d+=F}this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${w.toFixed(2)}s goal: ${P} skip sn ${C} to part ${d}`)}n.tuneInGoal=P}if(l=this.getDeliveryDirectives(n,s.deliveryDirectives,c,d),y||!I){this.loadPlaylist(l);return}}else n.canBlockReload&&(l=this.getDeliveryDirectives(n,s.deliveryDirectives,c,d));const u=this.hls.mainForwardBufferInfo,h=u?u.end-u.len:0,f=(n.edge-h)*1e3,g=fR(n,f);n.updated&&o>this.requestScheduled+g&&(this.requestScheduled=r.loading.start),c!==void 0&&n.canBlockReload?this.requestScheduled=r.loading.first+g-(n.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+g<o?this.requestScheduled=o:this.requestScheduled-o<=0&&(this.requestScheduled+=g);let m=this.requestScheduled-o;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,s,i,n){let r=lR(e,i);return s!=null&&s.skip&&e.deltaUpdateFailed&&(i=s.msn,n=s.part,r=Ss.No),new $a(i,n,r)}checkRetry(e){const s=e.details,i=Ti(e),n=e.errorAction,{action:r,retryCount:o=0,retryConfig:a}=n||{},l=!!n&&!!a&&(r===Se.RetryRequest||!n.resolved&&r===Se.SendAlternateToPenaltyBox);if(l){var c;if(this.requestScheduled=-1,o>=a.maxNumRetry)return!1;if(i&&(c=e.context)!=null&&c.deliveryDirectives)this.warn(`Retrying playlist loading ${o+1}/${a.maxNumRetry} after "${s}" without delivery-directives`),this.loadPlaylist();else{const d=Ro(a,o);this.timer=self.setTimeout(()=>this.loadPlaylist(),d),this.warn(`Retrying playlist loading ${o+1}/${a.maxNumRetry} after "${s}" in ${d}ms`)}e.levelRetry=!0,n.resolved=!0}return l}}let yn;class bR extends Co{constructor(e,s){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=s,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this),e.on(p.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this),e.off(p.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}
10startLoad(){this._levels.forEach(s=>{s.loadError=0,s.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(e,s){this.resetLevels()}onManifestLoaded(e,s){const i=[],n={};let r;s.levels.forEach(o=>{var a;const l=o.attrs;((a=o.audioCodec)==null?void 0:a.indexOf("mp4a.40.34"))!==-1&&(yn||(yn=/chrome|firefox/i.test(navigator.userAgent)),yn&&(o.audioCodec=void 0));const{AUDIO:c,CODECS:d,"FRAME-RATE":u,"PATHWAY-ID":h,RESOLUTION:f,SUBTITLES:g}=l,y=`${`${h||"."}-`}${o.bitrate}-${f}-${u}-${d}`;r=n[y],r?r.addFallback(o):(r=new ws(o),n[y]=r,i.push(r)),bi(r,"audio",c),bi(r,"text",g)}),this.filterAndSortMediaOptions(i,s)}filterAndSortMediaOptions(e,s){let i=[],n=[],r=!1,o=!1,a=!1,l=e.filter(({audioCodec:f,videoCodec:g,width:m,height:y,unknownCodecs:S})=>(r||(r=!!(m&&y)),o||(o=!!g),a||(a=!!f),!(S!=null&&S.length)&&(!f||fn(f,"audio"))&&(!g||fn(g,"video"))));if((r||o)&&a&&(l=l.filter(({videoCodec:f,width:g,height:m})=>!!f||!!(g&&m))),l.length===0){Promise.resolve().then(()=>{if(this.hls){const f=new Error("no level with compatible codecs found in manifest");this.hls.trigger(p.ERROR,{type:B.MEDIA_ERROR,details:L.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:s.url,error:f,reason:f.message})}});return}s.audioTracks&&(i=s.audioTracks.filter(f=>!f.audioCodec||fn(f.audioCodec,"audio")),Ka(i)),s.subtitles&&(n=s.subtitles,Ka(n));const c=l.slice(0);l.sort((f,g)=>f.attrs["HDCP-LEVEL"]!==g.attrs["HDCP-LEVEL"]?(f.attrs["HDCP-LEVEL"]||"")>(g.attrs["HDCP-LEVEL"]||"")?1:-1:f.bitrate!==g.bitrate?f.bitrate-g.bitrate:f.attrs["FRAME-RATE"]!==g.attrs["FRAME-RATE"]?f.attrs.decimalFloatingPoint("FRAME-RATE")-g.attrs.decimalFloatingPoint("FRAME-RATE"):f.attrs.SCORE!==g.attrs.SCORE?f.attrs.decimalFloatingPoint("SCORE")-g.attrs.decimalFloatingPoint("SCORE"):r&&f.height!==g.height?f.height-g.height:0);let d=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==c.length)){for(let f=0;f<c.length;f++)if(c[f].pathwayId===l[0].pathwayId){d=c[f];break}}this._levels=l;for(let f=0;f<l.length;f++)if(l[f]===d){this._firstLevel=f,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${d.bitrate}`);break}const u=a&&!o,h={levels:l,audioTracks:i,subtitleTracks:n,sessionData:s.sessionData,sessionKeys:s.sessionKeys,firstLevel:this._firstLevel,stats:s.stats,audio:a,video:o,altAudio:!u&&i.some(f=>!!f.url)};this.hls.trigger(p.MANIFEST_PARSED,h),(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 s=this._levels;if(s.length===0)return;if(e<0||e>=s.length){const d=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(p.ERROR,{type:B.OTHER_ERROR,details:L.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:d,reason:d.message}),u)return;e=Math.min(e,s.length-1)}const i=this.currentLevelIndex,n=this.currentLevel,r=n?n.attrs["PATHWAY-ID"]:void 0,o=s[e],a=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=o,i===e&&o.details&&n&&r===a)return;this.log(`Switching to level ${e}${a?" with Pathway "+a:""} from level ${i}${r?" with Pathway "+r:""}`);const l=de({},o,{level:e,maxBitrate:o.maxBitrate,attrs:o.attrs,uri:o.uri,urlId:o.urlId});delete l._attrs,delete l._urlId,this.hls.trigger(p.LEVEL_SWITCHING,l);const c=o.details;if(!c||c.live){const d=this.switchParams(o.uri,n?.details);this.loadPlaylist(d)}}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._firstLevel}else return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,s){s.fatal||!s.context||s.context.type===q.LEVEL&&s.context.level===this.level&&this.checkRetry(s)}onFragLoaded(e,{frag:s}){if(s!==void 0&&s.type===$.MAIN){const i=this._levels[s.level];i!==void 0&&(i.loadError=0)}}onLevelLoaded(e,s){var i;const{level:n,details:r}=s,o=this._levels[n];if(!o){var a;this.warn(`Invalid level index ${n}
10`),(a=s.deliveryDirectives)!=null&&a.skip&&(r.deltaUpdateFailed=!0);return}n===this.currentLevelIndex?(o.fragmentError===0&&(o.loadError=0),this.playlistLoaded(n,s,o.details)):(i=s.deliveryDirectives)!=null&&i.skip&&(r.deltaUpdateFailed=!0)}onAudioTrackSwitched(e,s){const i=this.currentLevel;if(!i)return;const n=this.hls.audioTracks[s.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==n){let r=-1;for(let o=0;o<i.audioGroupIds.length;o++)if(i.audioGroupIds[o]===n){r=o;break}r!==-1&&r!==i.urlId&&(i.urlId=r,this.canLoad&&this.startLoad())}}loadPlaylist(e){super.loadPlaylist();const s=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){const n=i.urlId;let r=i.uri;if(e)try{r=e.addDirectives(r)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}const o=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${s}${e?.msn!==void 0?" at sn "+e.msn+" part "+e.part:""} with${o?" Pathway "+o:""} URI ${n+1}/${i.url.length} ${r}`),this.clearTimer(),this.hls.trigger(p.LEVEL_LOADING,{url:r,level:s,id:n,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,s){const i=(r,o)=>o!==s,n=this._levels.filter((r,o)=>o!==e?!0:r.url.length>1&&s!==void 0?(r.url=r.url.filter(i),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(i)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(i)),r.urlId=0,!0):(this.steering&&this.steering.removeLevel(r),!1));this.hls.trigger(p.LEVELS_UPDATED,{levels:n})}onLevelsUpdated(e,{levels:s}){s.forEach((i,n)=>{const{details:r}=i;r!=null&&r.fragments&&r.fragments.forEach(o=>{o.level=n})}),this._levels=s}}function bi(t,e,s){s&&(e==="audio"?(t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds[t.url.length-1]=s):e==="text"&&(t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds[t.url.length-1]=s))}function Ka(t){const e={};t.forEach(s=>{const i=s.groupId||"";s.id=e[i]=e[i]||0,e[i]++})}var he={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class xR{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(p.BUFFER_APPENDED,this.onBufferAppended,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(p.BUFFER_APPENDED,this.onBufferAppended,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,s){const i=this.activePartLists[s];if(i)for(let n=i.length;n--;){const r=i[n];if(!r)break;const o=r.end;if(r.start<=e&&o!==null&&e<=o)return r}return this.getBufferedFrag(e,s)}getBufferedFrag(e,s){const{fragments:i}=this,n=Object.keys(i);for(let r=n.length;r--;){const o=i[n[r]];if(o?.body.type===s&&o.buffered){const a=o.body;if(a.start<=e&&e<=a.end)return a}}return null}detectEvictedFragments(e,s,i,n){this.timeRanges&&(this.timeRanges[e]=s);const r=n?.fragment.sn||-1;Object.keys(this.fragments).forEach(o=>{const a=this.fragments[o];if(!a||r>=a.body.sn)return;if(!a.buffered&&!a.loaded){a.body.type===i&&this.removeFragment(a.body);return}const l=a.range[e];l&&l.time.some(c=>{const d=!this.isTimeBuffered(c.startPTS,c.endPTS,s);return d&&this.removeFragment(a.body),d})})}detectPartialFragments(e){const s=this.timeRanges,{frag:i,part:n}=e;if(!s||i.sn==="initSegment")return;const r=Gt(i),o=this.fragments[r];if(!o||o.buffered&&i.gap)return;const a=!i.relurl;Object.keys(s).forEach(l=>{const c=i.elementaryStreams[l];if(!c)return;const d=s[l],u=a||c.partial===!0;o.range[l]=this.getBufferedTimes(i,n,u,d)}),o.loaded=null,Object.keys(o.range).length?(o.buffered=!0,o.body.endList&&(this.endListFragments[o.body.type]=o),js(o)||this.removeParts(i.sn-1,i.type)):this.removeFragment(o.body)}removeParts(e,s){const i=this.activePartLists[s];i&&(this.activePartLists[s]=i.filter(n=>n.fragment.sn>=e))}fragBuffered(e,s){const i=Gt(e);let n=this.fragments[i];!n&&s&&(n=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,n.buffered=!0)}getBufferedTimes(e,s,i,n){const r={time:[],partial:i},o=e.start,a=e.end,l=e.minEndPTS||a,c=e.maxStartPTS||o;for(let d=0;d<n.length;d++){const u=n.start(d)-this.bufferPadding,h=n.end(d)+this.bufferPadding;if(c>
vendor: 4,695 bytes, line 10
10=u&&l<=h){r.time.push({startPTS:Math.max(o,n.start(d)),endPTS:Math.min(a,n.end(d))});break}else if(o<h&&a>u)r.partial=!0,r.time.push({startPTS:Math.max(o,n.start(d)),endPTS:Math.min(a,n.end(d))});else if(a<=u)break}return r}getPartialFragment(e){let s=null,i,n,r,o=0;const{bufferPadding:a,fragments:l}=this;return Object.keys(l).forEach(c=>{const d=l[c];d&&js(d)&&(n=d.body.start-a,r=d.body.end+a,e>=n&&e<=r&&(i=Math.min(e-n,r-e),o<=i&&(s=d.body,o=i)))}),s}isEndListAppended(e){const s=this.endListFragments[e];return s!==void 0&&(s.buffered||js(s))}getState(e){const s=Gt(e),i=this.fragments[s];return i?i.buffered?js(i)?he.PARTIAL:he.OK:he.APPENDING:he.NOT_LOADED}isTimeBuffered(e,s,i){let n,r;for(let o=0;o<i.length;o++){if(n=i.start(o)-this.bufferPadding,r=i.end(o)+this.bufferPadding,e>=n&&s<=r)return!0;if(s<=n)return!1}return!1}onFragLoaded(e,s){const{frag:i,part:n}=s;if(i.sn==="initSegment"||i.bitrateTest)return;const r=n?null:s,o=Gt(i);this.fragments[o]={body:i,appendedPTS:null,loaded:r,buffered:!1,range:Object.create(null)}}onBufferAppended(e,s){const{frag:i,part:n,timeRanges:r}=s;if(i.sn==="initSegment")return;const o=i.type;if(n){let a=this.activePartLists[o];a||(this.activePartLists[o]=a=[]),a.push(n)}this.timeRanges=r,Object.keys(r).forEach(a=>{const l=r[a];this.detectEvictedFragments(a,l,o,n)})}onFragBuffered(e,s){this.detectPartialFragments(s)}hasFragment(e){const s=Gt(e);return!!this.fragments[s]}hasParts(e){var s;return!!((s=this.activePartLists[e])!=null&&s.length)}removeFragmentsInRange(e,s,i,n,r){n&&!this.hasGaps||Object.keys(this.fragments).forEach(o=>{const a=this.fragments[o];if(!a)return;const l=a.body;l.type!==i||n&&!l.gap||l.start<s&&l.end>e&&(a.buffered||r)&&this.removeFragment(l)})}removeFragment(e){const s=Gt(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const n=e.sn;this.activePartLists[e.type]=i.filter(r=>r.fragment.sn!==n)}delete this.fragments[s],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 js(t){var e,s,i;return t.buffered&&(t.body.gap||((e=t.range.video)==null?void 0:e.partial)||((s=t.range.audio)==null?void 0:s.partial)||((i=t.range.audiovideo)==null?void 0:i.partial))}function Gt(t){return`${t.type}_${t.level}_${t.urlId}_${t.sn}`}const Wa=Math.pow(2,17);class AR{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,s){const i=e.url;if(!i)return Promise.reject(new it({type:B.NETWORK_ERROR,details:L.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const n=this.config,r=n.fLoader,o=n.loader;return new Promise((a,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(Ya(e));return}else e.gap=!1;const c=this.loader=e.loader=r?new r(n):new o(n),d=qa(e),u=Ha(n.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Wa};e.stats=c.stats,c.load(d,h,{onSuccess:(f,g,m,y)=>{this.resetLoader(e,c);let S=f.data;m.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(S.slice(0,16)),S=S.slice(16)),a({frag:e,part:null,payload:S,networkDetails:y})},onError:(f,g,m,y)=>{this.resetLoader(e,c),l(new it({type:B.NETWORK_ERROR,details:L.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Re({url:i,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:m,stats:y}))},onAbort:(f,g,m)=>{this.resetLoader(e,c),l(new it({type:B.NETWORK_ERROR,details:L.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:m,stats:f}))},onTimeout:(f,g,m)=>{this.resetLoader(e,c),l(new it({type:B.NETWORK_ERROR,details:L.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:m,stats:f}))},onProgress:(f,g,m,y)=>{s&&s({frag:e,part:null,payload:m,networkDetails:y})}})})}loadPart(e,s,i){this.abort();const n=this.config,r=n.fLoader,o=n.loader;return new Promise((a,l)=>{if(this.loader&&this.loader.destroy(),e.gap||s.gap){l(Ya(e,s));return}const c=this.loader=e.loader=r?new r(n):new o(n),d=qa(e,s),u=Ha(n.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Wa};s.stats=c.stats,c.load(d,h,{onSuccess:(f,g,m,y)=>{this.resetLoader(e,c),this.updateStatsFromPart(e,s);const S={frag:e,part:s,payload:f.data,networkDetails:y};i(S),a(S)},onError:(f,g,m,y)=>
vendor: 4,326 bytes, line 10
10{this.resetLoader(e,c),l(new it({type:B.NETWORK_ERROR,details:L.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:s,response:Re({url:d.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:m,stats:y}))},onAbort:(f,g,m)=>{e.stats.aborted=s.stats.aborted,this.resetLoader(e,c),l(new it({type:B.NETWORK_ERROR,details:L.INTERNAL_ABORTED,fatal:!1,frag:e,part:s,error:new Error("Aborted"),networkDetails:m,stats:f}))},onTimeout:(f,g,m)=>{this.resetLoader(e,c),l(new it({type:B.NETWORK_ERROR,details:L.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:s,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:m,stats:f}))}})})}updateStatsFromPart(e,s){const i=e.stats,n=s.stats,r=n.total;if(i.loaded+=n.loaded,r){const l=Math.round(e.duration/s.duration),c=Math.min(Math.round(i.loaded/r),l),u=(l-c)*Math.round(i.loaded/c);i.total=i.loaded+u}else i.total=Math.max(i.loaded,i.total);const o=i.loading,a=n.loading;o.start?o.first+=a.first-a.start:(o.start=a.start,o.first=a.first),o.end=a.end}resetLoader(e,s){e.loader=null,this.loader===s&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),s.destroy()}}function qa(t,e=null){const s=e||t,i={frag:t,part:e,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},n=s.byteRangeStartOffset,r=s.byteRangeEndOffset;if(N(n)&&N(r)){var o;let a=n,l=r;if(t.sn==="initSegment"&&((o=t.decryptdata)==null?void 0:o.method)==="AES-128"){const c=r-n;c%16&&(l=r+(16-c%16)),n!==0&&(i.resetIV=!0,a=n-16)}i.rangeStart=a,i.rangeEnd=l}return i}function Ya(t,e){const s=new Error(`GAP ${t.gap?"tag":"attribute"} found`),i={type:B.MEDIA_ERROR,details:L.FRAG_GAP,fatal:!1,frag:t,error:s,networkDetails:null};return e&&(i.part=e),(e||t).stats.aborted=!0,new it(i)}class it extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class IR{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const s in this.keyUriToKeyInfo){const i=this.keyUriToKeyInfo[s].loader;if(i){if(e&&e!==i.context.frag.type)return;i.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const s=this.keyUriToKeyInfo[e];(s.mediaKeySessionContext||s.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const s=this.keyUriToKeyInfo[e].loader;s&&s.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,s=L.KEY_LOAD_ERROR,i,n,r){return new it({type:B.NETWORK_ERROR,details:s,fatal:!1,frag:e,response:r,error:i,networkDetails:n})}loadClear(e,s){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:n}=e;for(let r=0;r<s.length;r++){const o=s[r];if(n<=o.cc&&(i==="initSegment"||o.sn==="initSegment"||i<o.sn)){this.emeController.selectKeySystemFormat(o).then(a=>{o.setKeyFormat(a)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(s=>this.loadInternal(e,s)):this.loadInternal(e)}loadInternal(e,s){var i,n;s&&e.setKeyFormat(s);const r=e.decryptdata;if(!r){const c=new Error(s?`Expected frag.decryptdata to be defined after setting format ${s}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,L.KEY_LOAD_ERROR,c))}const o=r.uri;if(!o)return Promise.reject(this.createKeyLoadError(e,L.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${o}"`)));let a=this.keyUriToKeyInfo[o];if((i=a)!=null&&i.decryptdata.key)return r.key=a.decryptdata.key,Promise.resolve({frag:e,keyInfo:a});if((n=a)!=null&&n.keyLoadPromise){var l;switch((l=a.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return a.keyLoadPromise.then(c=>(r.key=c.keyInfo.decryptdata.key,{frag:e,keyInfo:a}))}}switch(a=this.keyUriToKeyInfo[o]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return r.keyFormat==="identity"?this.loadKeyHTTP(a,e):this.loadKeyEME(a,e);case"AES-128":return this.loadKeyHTTP(a,e);default:return Promise.reject(this.createKeyLoadError(e,L.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e,s){const i={frag:s,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const n=this.emeController.loadKey(i);
10if(n)return(e.keyLoadPromise=n.then(r=>(e.mediaKeySessionContext=r,i))).catch(r=>{throw e.keyLoadPromise=null,r})}return Promise.resolve(i)}loadKeyHTTP(e,s){const i=this.config,n=i.loader,r=new n(i);return s.keyLoader=e.loader=r,e.keyLoadPromise=new Promise((o,a)=>{const l={keyInfo:e,frag:s,responseType:"arraybuffer",url:e.decryptdata.uri},c=i.keyLoadPolicy.default,d={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,g,m)=>{const{frag:y,keyInfo:S,url:E}=g;if(!y.decryptdata||S!==this.keyUriToKeyInfo[E])return a(this.createKeyLoadError(y,L.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),m));S.decryptdata.key=y.decryptdata.key=new Uint8Array(h.data),y.keyLoader=null,S.loader=null,o({frag:y,keyInfo:S})},onError:(h,f,g,m)=>{this.resetLoader(f),a(this.createKeyLoadError(s,L.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),g,Re({url:l.url,data:void 0},h)))},onTimeout:(h,f,g)=>{this.resetLoader(f),a(this.createKeyLoadError(s,L.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),g))},onAbort:(h,f,g)=>{this.resetLoader(f),a(this.createKeyLoadError(s,L.INTERNAL_ABORTED,new Error("key loading aborted"),g))}};r.load(l,d,u)})}resetLoader(e){const{frag:s,keyInfo:i,url:n}=e,r=i.loader;s.keyLoader===r&&(s.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[n],r&&r.destroy()}}class LR{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(){}}const RR={length:0,start:()=>0,end:()=>0};class Z{static isBuffered(e,s){try{if(e){const i=Z.getBuffered(e);for(let n=0;n<i.length;n++)if(s>=i.start(n)&&s<=i.end(n))return!0}}catch{}return!1}static bufferInfo(e,s,i){try{if(e){const n=Z.getBuffered(e),r=[];let o;for(o=0;o<n.length;o++)r.push({start:n.start(o),end:n.end(o)});return this.bufferedInfo(r,s,i)}}catch{}return{len:0,start:s,end:s,nextStart:void 0}}static bufferedInfo(e,s,i){s=Math.max(0,s),e.sort(function(c,d){const u=c.start-d.start;return u||d.end-c.end});let n=[];if(i)for(let c=0;c<e.length;c++){const d=n.length;if(d){const u=n[d-1].end;e[c].start-u<i?e[c].end>u&&(n[d-1].end=e[c].end):n.push(e[c])}else n.push(e[c])}else n=e;let r=0,o,a=s,l=s;for(let c=0;c<n.length;c++){const d=n[c].start,u=n[c].end;if(s+i>=d&&s<u)a=d,l=u,r=l-s;else if(s+i<d){o=d;break}}return{len:r,start:a||0,end:l||0,nextStart:o}}static getBuffered(e){try{return e.buffered}catch(s){return v.log("failed to get media.buffered",s),RR}}}class _o{constructor(e,s,i,n=0,r=-1,o=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=zs(),this.buffering={audio:zs(),video:zs(),audiovideo:zs()},this.level=e,this.sn=s,this.id=i,this.size=n,this.part=r,this.partial=o}}function zs(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Eh(t,e){let s=null;for(let i=0,n=t.length;i<n;i++){const r=t[i];if(r&&r.cc===e){s=r;break}}return s}function CR(t,e,s){return!!(e.details&&(s.endCC>s.startCC||t&&t.cc<s.startCC))}function _R(t,e,s=0){const i=t.fragments,n=e.fragments;if(!n.length||!i.length){v.log("No fragments to align");return}const r=Eh(i,n[0].cc);if(!r||r&&!r.startPTS){v.log("No frag in previous level to align on");return}return r}function ja(t,e){if(t){const s=t.start+e;t.start=t.startPTS=s,t.endPTS=s+t.duration}}function wo(t,e){const s=e.fragments;for(let i=0,n=s.length;i<n;i++)ja(s[i],t);e.fragmentHint&&ja(e.fragmentHint,t),e.alignedSliding=!0}function wR(t,e,s){e&&(DR(t,s,e),!s.alignedSliding&&e.details&&kR(s,e.details),!s.alignedSliding&&e.details&&!s.skippedSegments&&Sh(e.details,s))}function DR(t,e,s){if(CR(t,s,e)){const i=_R(s.details,e);i&&N(i.start)&&(v.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),wo(i.start,e))}}function kR(t,e){if(!e.fragments.length||!t.hasProgramDateTime||!e.hasProgramDateTime)return;const s=e.fragments[0].programDateTime,i=t.fragments[0].programDateTime,n=(i-s)/1e3+e.fragments[0].start;n&&N(n)&&(v.log(`Adjusting PTS using programDateTime delta ${i-s}ms, sliding:${n.toFixed(3)} ${t.url} `),wo(n,t))}function bh(t,e){if(!t.hasProgramDateTime||!e.hasProgramDateTime)return;const s=t.fragments,i=e.fragments;if(!s.length||!i.length)return;const n=Math.round(i.length/2)-1,r=i[n],o=Eh(s,r.cc)||s[Math.round(s.length/2)-1],a=r.programDateTime,l=o.programDateTime;if(a===null||l===null)return;const c=(l-a)/1e3-(o.start-r.start);wo(c,t)}class PR{constructor(e,s){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=s}
vendor: 25,651 bytes, line 10
10decrypt(e,s){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},s,e)}}class OR{constructor(e,s){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=s}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function MR(t){const e=t.byteLength,s=e&&new DataView(t.buffer).getUint8(e-1);return s?wt(t,0,e-s):t}class NR{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 s=new DataView(e),i=new Uint32Array(4);for(let n=0;n<4;n++)i[n]=s.getUint32(n*4);return i}initTable(){const e=this.sBox,s=this.invSBox,i=this.subMix,n=i[0],r=i[1],o=i[2],a=i[3],l=this.invSubMix,c=l[0],d=l[1],u=l[2],h=l[3],f=new Uint32Array(256);let g=0,m=0,y=0;for(y=0;y<256;y++)y<128?f[y]=y<<1:f[y]=y<<1^283;for(y=0;y<256;y++){let S=m^m<<1^m<<2^m<<3^m<<4;S=S>>>8^S&255^99,e[g]=S,s[S]=g;const E=f[g],T=f[E],R=f[T];let I=f[S]*257^S*16843008;n[g]=I<<24|I>>>8,r[g]=I<<16|I>>>16,o[g]=I<<8|I>>>24,a[g]=I,I=R*16843009^T*65537^E*257^g*16843008,c[S]=I<<24|I>>>8,d[S]=I<<16|I>>>16,u[S]=I<<8|I>>>24,h[S]=I,g?(g=E^f[f[f[R^E]]],m^=f[f[m]]):g=m=1}}expandKey(e){const s=this.uint8ArrayToUint32Array_(e);let i=!0,n=0;for(;n<s.length&&i;)i=s[n]===this.key[n],n++;if(i)return;this.key=s;const r=this.keySize=s.length;if(r!==4&&r!==6&&r!==8)throw new Error("Invalid aes key size="+r);const o=this.ksRows=(r+6+1)*4;let a,l;const c=this.keySchedule=new Uint32Array(o),d=this.invKeySchedule=new Uint32Array(o),u=this.sBox,h=this.rcon,f=this.invSubMix,g=f[0],m=f[1],y=f[2],S=f[3];let E,T;for(a=0;a<o;a++){if(a<r){E=c[a]=s[a];continue}T=E,a%r===0?(T=T<<8|T>>>24,T=u[T>>>24]<<24|u[T>>>16&255]<<16|u[T>>>8&255]<<8|u[T&255],T^=h[a/r|0]<<24):r>6&&a%r===4&&(T=u[T>>>24]<<24|u[T>>>16&255]<<16|u[T>>>8&255]<<8|u[T&255]),c[a]=E=(c[a-r]^T)>>>0}for(l=0;l<o;l++)a=o-l,l&3?T=c[a]:T=c[a-4],l<4||a<=4?d[l]=T:d[l]=g[u[T>>>24]]^m[u[T>>>16&255]]^y[u[T>>>8&255]]^S[u[T&255]],d[l]=d[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,s,i){const n=this.keySize+6,r=this.invKeySchedule,o=this.invSBox,a=this.invSubMix,l=a[0],c=a[1],d=a[2],u=a[3],h=this.uint8ArrayToUint32Array_(i);let f=h[0],g=h[1],m=h[2],y=h[3];const S=new Int32Array(e),E=new Int32Array(S.length);let T,R,I,k,w,D,P,C,F,O,z,ve,se,re;const te=this.networkToHostOrderSwap;for(;s<S.length;){for(F=te(S[s]),O=te(S[s+1]),z=te(S[s+2]),ve=te(S[s+3]),w=F^r[0],D=ve^r[1],P=z^r[2],C=O^r[3],se=4,re=1;re<n;re++)T=l[w>>>24]^c[D>>16&255]^d[P>>8&255]^u[C&255]^r[se],R=l[D>>>24]^c[P>>16&255]^d[C>>8&255]^u[w&255]^r[se+1],I=l[P>>>24]^c[C>>16&255]^d[w>>8&255]^u[D&255]^r[se+2],k=l[C>>>24]^c[w>>16&255]^d[D>>8&255]^u[P&255]^r[se+3],w=T,D=R,P=I,C=k,se=se+4;T=o[w>>>24]<<24^o[D>>16&255]<<16^o[P>>8&255]<<8^o[C&255]^r[se],R=o[D>>>24]<<24^o[P>>16&255]<<16^o[C>>8&255]<<8^o[w&255]^r[se+1],I=o[P>>>24]<<24^o[C>>16&255]<<16^o[w>>8&255]<<8^o[D&255]^r[se+2],k=o[C>>>24]<<24^o[w>>16&255]<<16^o[D>>8&255]<<8^o[P&255]^r[se+3],E[s]=te(T^f),E[s+1]=te(k^g),E[s+2]=te(I^m),E[s+3]=te(R^y),f=F,g=O,m=z,y=ve,s=s+4}return E.buffer}}const FR=16;class Do{constructor(e,{removePKCS7Padding:s=!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=s,s)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}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:s}=this;if(!e||s)return this.reset(),null;const i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?MR(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,s,i){return this.useSoftware?new Promise((n,r)=>{this.softwareDecrypt(new Uint8Array(e),s,i);const o=this.flush();o?n(o.buffer):r(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),s,i)}softwareDecrypt(e,s,i){const{currentIV:n,currentResult:r,remainderData:o}=this;this.logOnce("JS AES decrypt"),o&&(e=Mt(o,e),this.remainderData=null);const a=this.getValidChunk(e);if(!a.length)return null;n&&(i=n);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new NR),l.expandKey(s);const c=r;return this.currentResult=l.decrypt(a.buffer,0,i),this.currentIV=wt(a,-16).buffer,c||null}webCryptoDecrypt(e,s,i){const n=this.subtle;return(this.key!==s||!this.fastAesKey)&&(this.key=s,this.fastAesKey=new OR(n,s)),this.fastAesKey.expandKey().then(r=>n?(this.logOnce("WebCrypto AES decrypt"),new PR(n,new Uint8Array(i)).decrypt(e.buffer,r)):Promise.reject(new Error("web crypto not initialized"))).catch(r=>(v.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${r.name}: ${r.message}`),this.onWebCryptoError(e,s,i)))}onWebCryptoError(e,s,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,s,i);const n=this.flush();if(n)return n.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let s=e;const i=e.length-e.length%FR;return i!==e.length&&(s=wt(e,0,i),this.remainderData=wt(e,i)),s}logOnce(e){this.logEnabled&&(v.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const UR={toString:function(t){let e="";const s=t.length;for(let i=0;i<s;i++)e+=`[${t.start(i).toFixed(3)}-${t.end(i).toFixed(3)}]`;return e}},_={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 ko extends LR{constructor(e,s,i,n,r){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=_.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.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=r,this.logPrefix=n,this.log=v.log.bind(v,`${n}:`),this.warn=v.warn.bind(v,`${n}:`),this.hls=e,this.fragmentLoader=new AR(e.config),this.keyLoader=i,this.fragmentTracker=s,this.config=e.config,this.decrypter=new Do(e.config),e.on(p.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=_.STOPPED}_streamEnded(e,s){if(s.live||e.nextStart||!e.end||!this.media)return!1;const i=s.partList;if(i!=null&&i.length){const r=i[i.length-1];return Z.isBuffered(this.media,r.start+r.duration/2)}const n=s.fragments[s.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levels[this.levelLastLoaded])==null?void 0:e.details}}onMediaAttached(e,s){const i=this.media=this.mediaBuffer=s.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);const n=this.config;this.levels&&n.autoStartLoad&&this.state===_.STOPPED&&this.startLoad(n.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:s,media:i,mediaBuffer:n,state:r}=this,o=i?i.currentTime:0,a=Z.bufferInfo(n||i,o,e.maxBufferHole);if(this.log(`media seeking to ${N(o)?o.toFixed(3):o}, state: ${r}`),this.state===_.ENDED)this.resetLoadingState();else if(s){const l=e.maxFragLookUpTolerance,c=s.start-l,d=s.start+s.duration+l;if(!a.len||d<a.start||c>a.end){const u=o>d;(o<c||u)&&(u&&s.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),s.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(o,1/0,this.playlistType,!0),this.lastCurrentTime=o),!this.loadedmetadata&&!a.len&&(this.nextLoadPosition=this.startPosition=o),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,s){this.startTimeOffset=s.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=_.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,s,i){this._loadFragForPlayback(e,s,i)}_loadFragForPlayback(e,s,i){const n=r=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${r.part?" p: "+r.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(r)};this._doFragLoad(e,s,i,n).then(r=>{if(!r)return;const o=this.state;if(this.fragContextChanged(e)){(o===_.FRAG_LOADING||!this.fragCurrent&&o===_.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=_.IDLE);return}"payload"in r&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(p.FRAG_LOADED,r)),this._handleFragmentLoadComplete(r)}).catch(r=>{this.state===_.STOPPED||this.state===_.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var s;const{fragmentTracker:i}=this;if(i.getState(e)===he.APPENDING){const r=e.type,o=this.getFwdBufferInfo(this.mediaBuffer,r),a=Math.max(e.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(a)&&i.removeFragment(e)}else((s=this.mediaBuffer)==null?void 0:s.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===he.PARTIAL&&i.removeFragment(e))}flushMainBuffer(e,s,i=null){if(!(e-s))return;const n={startOffset:e,endOffset:s,type:i};this.hls.trigger(p.BUFFER_FLUSHING,n)}_loadInitSegment(e,s){this._doFragLoad(e,s).then(i=>{if(!i||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:n}=this,{payload:r}=i,o=e.decryptdata;if(r&&r.byteLength>0&&o&&o.key&&o.iv&&o.method==="AES-128"){const a=self.performance.now();return this.decrypter.decrypt(new Uint8Array(r),o.key.buffer,o.iv.buffer).catch(l=>{throw n.trigger(p.ERROR,{type:B.MEDIA_ERROR,details:L.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{const c=self.performance.now();return n.trigger(p.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:a,tdecrypt:c}}),i.payload=l,i})}return i}).then(i=>{const{fragCurrent:n,hls:r,levels:o}=this;if(!o)throw new Error("init load aborted, missing levels");const a=e.stats;this.state=_.IDLE,s.fragmentError=0,e.data=new Uint8Array(i.payload),a.parsing.start=a.buffering.start=self.performance.now(),a.parsing.end=a.buffering.end=self.performance.now(),i.frag===n&&r.trigger(p.FRAG_BUFFERED,{stats:a,frag:n,part:null,id:e.type}),this.tick()}).catch(i=>{this.state===_.STOPPED||this.state===_.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}fragContextChanged(e){const{fragCurrent:s}=this;return!e||!s||e.level!==s.level||e.sn!==s.sn||e.urlId!==s.urlId}fragBufferedComplete(e,s){var i,n,r,o;const a=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${e.type} sn: ${e.sn}${s?" part: "+s.index:""} of ${this.playlistType===$.MAIN?"level":"track"} ${e.level} (frag:[${((i=e.startPTS)!=null?i:NaN).toFixed(3)}-${((n=e.endPTS)!=null?n:NaN).toFixed(3)}] > buffer:${a?UR.toString(Z.getBuffered(a)):"(detached)"})`),this.state=_.IDLE,a&&(!this.loadedmetadata&&e.type==$.MAIN&&a.buffered.length&&((r=this.fragCurrent)==null?void 0:r.sn)===((o=this.fragPrevious)==null?void 0:o.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:s}=this;if(!s)return;const{frag:i,part:n,partsLoaded:r}=e,o=!r||r.length===0||r.some(l=>!l),a=new _o(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!o);s.flush(a)}_handleFragmentLoadProgress(e){}_doFragLoad(e,s,i=null,n){var r;const o=s?.details;if(!this.levels||!o)throw new Error(`frag load aborted, missing level${o?"":" detail"}s`);let a=null;if(e.encrypted&&!((r=e.decryptdata)!=null&&r.key)?(this.log(`Loading key for ${e.sn} of [${o.startSN}-${o.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=_.KEY_LOADING,this.fragCurrent=e,a=this.keyLoader.load(e).then(d=>{if(!this.fragContextChanged(d.frag))return this.hls.trigger(p.KEY_LOADED,d),this.state===_.KEY_LOADING&&(this.state=_.IDLE),d}),this.hls.trigger(p.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(a=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&o.encryptedFragments.length&&this.keyLoader.loadClear(e,o.encryptedFragments),i=Math.max(e.start,i||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){const d=o.partList;if(d&&n){i>e.end&&o.fragmentHint&&(e=o.fragmentHint);const u=this.getNextPart(d,e,i);if(u>-1){const h=d[u];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${o.startSN}-${o.endSN}] parts [0-${u}-${d.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=_.FRAG_LOADING;let f;return a?f=a.then(g=>!g||this.fragContextChanged(g.frag)?null:this.doFragPartsLoad(e,h,s,n)).catch(g=>this.handleFragLoadError(g)):f=this.doFragPartsLoad(e,h,s,n).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(p.FRAG_LOADING,{frag:e,part:h,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(d,i))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${o?"of ["+o.startSN+"-"+o.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),N(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=_.FRAG_LOADING;const l=this.config.progressive;let c;return l&&a?c=a.then(d=>!d||this.fragContextChanged(d?.frag)?null:this.fragmentLoader.load(e,n)).catch(d=>this.handleFragLoadError(d)):c=Promise.all([this.fragmentLoader.load(e,l?n:void 0),a]).then(([d])=>(!l&&d&&n&&n(d),d)).catch(d=>this.handleFragLoadError(d)),this.hls.trigger(p.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c}doFragPartsLoad(e,s,i,n){return new Promise((r,o)=>{var a;const l=[],c=(a=i.details)==null?void 0:a.partList,d=u=>{this.fragmentLoader.loadPart(e,u,n).then(h=>{l[u.index]=h;const f=h.part;this.hls.trigger(p.FRAG_LOADED,h);const g=Va(i,e.sn,u.index+1)||vh(c,e.sn,u.index+1);if(g)d(g);else return r({frag:e,part:f,partsLoaded:l})}).catch(o)};d(s)})}handleFragLoadError(e){if("data"in e){const s=e.data;e.data&&s.details===L.INTERNAL_ABORTED?this.handleFragLoadAborted(s.frag,s.part):this.hls.trigger(p.ERROR,s)}else this.hls.trigger(p.ERROR,{type:B.OTHER_ERROR,details:L.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const s=this.getCurrentContext(e);if(!s||this.state!==_.PARSING){!this.fragCurrent&&this.state!==_.STOPPED&&this.state!==_.ERROR&&(this.state=_.IDLE);return}const{frag:i,part:n,level:r}=s,o=self.performance.now();i.stats.parsing.end=o,n&&(n.stats.parsing.end=o),this.updateLevelTiming(i,n,r,e.partial)}getCurrentContext(e){const{levels:s,fragCurrent:i}=this,{level:n,sn:r,part:o}=e;if(!(s!=null&&s[n]))return this.warn(`Levels object was unset while buffering fragment ${r} of level ${n}. The current chunk will not be buffered.`),null;const a=s[n],l=o>-1?Va(a,r,o):null,c=l?l.fragment:gR(a,r,i);return c?(i&&i!==c&&(c.stats=i.stats),{frag:c,part:l,level:a}):null}bufferFragmentData(e,s,i,n,r){var o;if(!e||this.state!==_.PARSING)return;const{data1:a,data2:l}=e;let c=a;if(a&&l&&(c=Mt(a,l)),!((o=c)!=null&&o.length))return;const d={type:e.type,frag:s,part:i,chunkMeta:n,parent:s.type,data:c};if(this.hls.trigger(p.BUFFER_APPENDING,d),e.dropped&&e.independent&&!i){if(r)return;this.flushBufferGap(s)}}flushBufferGap(e){const s=this.media;if(!s)return;if(!Z.isBuffered(s,s.currentTime)){this.flushMainBuffer(0,e.start);return}const i=s.currentTime,n=Z.bufferInfo(s,i,0),r=e.duration,o=Math.min(this.config.maxFragLookUpTolerance*2,r*.25),a=Math.max(Math.min(e.start-o,n.end-o),i+o);e.start-a>o&&this.flushMainBuffer(a,e.start)}getFwdBufferInfo(e,s){const i=this.getLoadPosition();return N(i)?this.getFwdBufferInfoAtPos(e,i,s):null}getFwdBufferInfoAtPos(e,s,i){const{config:{maxBufferHole:n}}=this,r=Z.bufferInfo(e,s,n);if(r.len===0&&r.nextStart!==void 0){const o=this.fragmentTracker.getBufferedFrag(s,i);if(o&&r.nextStart<o.end)return Z.bufferInfo(e,s,Math.max(r.nextStart,n))}return r}getMaxBufferLength(e){const{config:s}=this;let i;return e?i=Math.max(8*s.maxBufferSize/e,s.maxBufferLength):i=s.maxBufferLength,Math.min(i,s.maxMaxBufferLength)}reduceMaxBufferLength(e){const s=this.config,i=e||s.maxBufferLength;return s.maxMaxBufferLength>=i?(s.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${s.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,s=$.MAIN){const i=this.fragmentTracker.getAppendedFrag(e,$.MAIN);return i&&"fragment"in i?i.fragment:i}getNextFragment(e,s){const i=s.fragments,n=i.length;if(!n)return null;const{config:r}=this,o=i[0].start;let a;if(s.live){const l=r.initialLiveManifestSize;if(n<l)return this.warn(`Not enough fragments to start playback (have: ${n}, need: ${l})`),null;!s.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(a=this.getInitialLiveFragment(s,i),this.startPosition=a?this.hls.liveSyncPosition||a.start:e)}else e<=o&&(a=i[0]);if(!a){const l=r.lowLatencyMode?s.partEnd:s.fragmentEnd;a=this.getFragmentAtPosition(e,l,s)}return this.mapToInitFragWhenRequired(a)}isLoopLoading(e,s){const i=this.fragmentTracker.getState(e);return(i===he.OK||i===he.PARTIAL&&!!e.gap)&&this.nextLoadPosition>s}getNextFragmentLoopLoading(e,s,i,n,r){const o=e.gap,a=this.getNextFragment(this.nextLoadPosition,s);if(a===null)return a;if(e=a,o&&e&&!e.gap&&i.nextStart){const l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,n);if(l!==null&&i.len+l.len>=r)return this.log(`buffer full after gaps in "${n}" 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,s,i){let n=-1,r=!1,o=!0;for(let a=0,l=e.length;a<l;a++){const c=e[a];if(o=o&&!c.independent,n>-1&&i<c.start)break;const d=c.loaded;d?n=-1:(r||c.independent||o)&&c.fragment===s&&(n=a),r=d}return n}loadedEndOfParts(e,s){const i=e[e.length-1];return i&&s>i.start&&i.loaded}getInitialLiveFragment(e,s){const i=this.fragPrevious;let n=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),n=mR(s,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){const r=i.sn+1;if(r>=e.startSN&&r<=e.endSN){const o=s[r-e.startSN];i.cc===o.cc&&(n=o,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=SR(s,i.cc),n&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`))}}else{const r=this.hls.liveSyncPosition;r!==null&&(n=this.getFragmentAtPosition(r,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n}getFragmentAtPosition(e,s,i){const{config:n}=this;let{fragPrevious:r}=this,{fragments:o,endSN:a}=i;const{fragmentHint:l}=i,c=n.maxFragLookUpTolerance,d=i.partList,u=!!(n.lowLatencyMode&&d!=null&&d.length&&l);u&&l&&!this.bitrateTest&&(o=o.concat(l),a=l.sn);let h;if(e<s){const f=e>s-c?0:c;h=Ds(r,o,e,f)}else h=o[o.length-1];if(h){const f=h.sn-i.startSN,g=this.fragmentTracker.getState(h);if((g===he.OK||g===he.PARTIAL&&h.gap)&&(r=h),r&&h.sn===r.sn&&(!u||d[0].fragment.sn>h.sn)&&r&&h.level===r.level){const y=o[f+1];h.sn<a&&this.fragmentTracker.getState(y)!==he.OK?h=y:h=null}}return h}synchronizeToLiveEdge(e){const{config:s,media:i}=this;if(!i)return;const n=this.hls.liveSyncPosition,r=i.currentTime,o=e.fragments[0].start,a=e.edge,l=r>=o-s.maxFragLookUpTolerance&&r<=a;if(n!==null&&i.duration>n&&(r<n||!l)){const c=s.liveMaxLatencyDuration!==void 0?s.liveMaxLatencyDuration:s.liveMaxLatencyDurationCount*e.targetduration;(!l&&i.readyState<4||r<a-c)&&(this.loadedmetadata||(this.nextLoadPosition=n),i.readyState&&(this.warn(`Playback: ${r.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : ${n.toFixed(3)}`),i.currentTime=n))}}alignPlaylists(e,s){const{levels:i,levelLastLoaded:n,fragPrevious:r}=this,o=n!==null?i[n]:null,a=e.fragments.length;if(!a)return this.warn("No fragments in live playlist"),0;const l=e.fragments[0].start,c=!s,d=e.alignedSliding&&N(l);if(c||!d&&!l){wR(r,o,e);const u=e.fragments[0].start;return this.log(`Live playlist sliding: ${u.toFixed(2)} start-sn: ${s?s.startSN:"na"}->${e.startSN} prev-sn: ${r?r.sn:"na"} fragments: ${a}`),u}return l}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,s){let i=this.startPosition;if(i<s&&(i=-1),i===-1||this.lastCurrentTime===-1){const n=this.startTimeOffset!==null,r=n?this.startTimeOffset:e.startTimeOffset;r!==null&&N(r)?(i=s+r,r<0&&(i+=e.totalduration),i=Math.min(Math.max(s,i),s+e.totalduration),this.log(`Start time offset ${r} found in ${n?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):e.live?i=this.hls.liveSyncPosition||s:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}getLoadPosition(){const{media:e}=this;let s=0;return this.loadedmetadata&&e?s=e.currentTime:this.nextLoadPosition&&(s=this.nextLoadPosition),s}handleFragLoadAborted(e,s){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${s?" part "+s.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==_.FRAG_LOADING_WAITING_RETRY)&&(this.state=_.IDLE)}onFragmentOrKeyLoadError(e,s){if(s.chunkMeta&&!s.frag){const u=this.getCurrentContext(s.chunkMeta);u&&(s.frag=u.frag)}const i=s.frag;if(!i||i.type!==e||!this.levels)return;if(this.fragContextChanged(i)){var n;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(n=this.fragCurrent)==null?void 0:n.url}`);return}const r=s.details===L.FRAG_GAP;r&&this.fragmentTracker.fragBuffered(i,!0);const o=s.errorAction,{action:a,retryCount:l=0,retryConfig:c}=o||{};if(o&&a===Se.RetryRequest&&c){var d;this.resetStartWhenNotLoaded((d=this.levelLastLoaded)!=null?d:i.level);const u=Ro(c,l);this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${s.details}, retrying loading ${l+1}/${c.maxNumRetry} in ${u}ms`),o.resolved=!0,this.retryDate=self.performance.now()+u,this.state=_.FRAG_LOADING_WAITING_RETRY}else c&&o?(this.resetFragmentErrors(e),l<c.maxNumRetry?r||(o.resolved=!0):v.warn(`${s.details} reached or exceeded max retry (${l})`)):o?.action===Se.SendAlternateToPenaltyBox?this.state=_.WAITING_LEVEL:this.state=_.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===_.PARSING||this.state===_.PARSED){const s=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,s),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len);const r=!n;return r&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${s} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),r}return!1}resetFragmentErrors(e){e===$.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==_.STOPPED&&(this.state=_.IDLE)}afterBufferFlushed(e,s,i){if(!e)return;const n=Z.getBuffered(e);this.fragmentTracker.detectEvictedFragments(s,n,i),this.state===_.ENDED&&this.resetLoadingState()}
10resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=_.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const s=this.levels?this.levels[e].details:null;s!=null&&s.live?(this.startPosition=-1,this.setStartPosition(s,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){var s;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((s=this.levelLastLoaded)!=null?s:e.level),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,s,i,n){var r;const o=i.details;if(!o){this.warn("level.details undefined");return}if(Object.keys(e.elementaryStreams).reduce((l,c)=>{const d=e.elementaryStreams[c];if(d){const u=d.endPTS-d.startPTS;if(u<=0)return this.warn(`Could not parse fragment ${e.sn} ${c} duration reliably (${u})`),l||!1;const h=n?0:yh(o,e,d.startPTS,d.endPTS,d.startDTS,d.endDTS);return this.hls.trigger(p.LEVEL_PTS_UPDATED,{details:o,level:i,drift:h,type:c,frag:e,start:d.startPTS,end:d.endPTS}),!0}return l},!1))i.fragmentError=0;else if(((r=this.transmuxer)==null?void 0:r.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(i.fragmentError===0&&(i.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(p.ERROR,{type:B.MEDIA_ERROR,details:L.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=_.PARSED,this.hls.trigger(p.FRAG_PARSED,{frag:e,part:s})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){if(e.event==="demuxerWorker"){var s,i,n;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((s=(i=this.levelLastLoaded)!=null?i:(n=this.fragCurrent)==null?void 0:n.level)!=null?s:0),this.resetLoadingState()}}set state(e){const s=this._state;s!==e&&(this._state=e,this.log(`${s}->${e}`))}get state(){return this._state}}function xh(){return self.SourceBuffer||self.WebKitSourceBuffer}function BR(){const t=Ji();if(!t)return!1;const e=xh(),s=t&&typeof t.isTypeSupported=="function"&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function";return!!s&&!!i}function $R(){var t;const e=xh();return typeof(e==null||(t=e.prototype)==null?void 0:t.changeType)=="function"}function VR(){return typeof __HLS_WORKER_BUNDLE__=="function"}function GR(){const t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(t);return{worker:new self.Worker(e),objectURL:e}}function HR(t){const e=new self.URL(t,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function je(t="",e=9e4){return{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Ah{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,s,i,n){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,s){return!1}appendFrame(e,s,i){}demux(e,s){this.cachedData&&(e=Mt(this.cachedData,e),this.cachedData=null);let i=Si(e,0),n=i?i.length:0,r;const o=this._audioTrack,a=this._id3Track,l=i?IL(i):void 0,c=e.length;for((this.basePTS===null||this.frameIndex===0&&N(l))&&(this.basePTS=KR(l,s,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ke.audioId3,duration:Number.POSITIVE_INFINITY});n<c;){if(this.canParse(e,n)){const d=this.appendFrame(o,e,n);d?(this.frameIndex++,this.lastPTS=d.sample.pts,n+=d.length,r=n):n=c}else AL(e,n)?(i=Si(e,n),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ke.audioId3,duration:Number.POSITIVE_INFINITY}),n+=i.length,r=n):n++;if(n===c&&r!==c){const d=wt(e,r);this.cachedData?this.cachedData=Mt(this.cachedData,d):this.cachedData=d}}return{audioTrack:o,videoTrack:je(),id3Track:a,textTrack:je()}}demuxSampleAes(e,s,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const s=this.cachedData;return s&&(this.cachedData=null,this.demux(s,0)),{audioTrack:this._audioTrack,videoTrack:je(),id3Track:this._id3Track,textTrack:je()}}destroy(){}}const KR=(t,e,s)=>{if(N(t))return t*90;const i=s?s.baseTime*9e4/s.timescale:0;return e*9e4+i};function WR(t,e,s,i){let n,r,o,a;const l=navigator.userAgent.toLowerCase(),c=i,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=((e[s+2]&192)>>>6)+1;const u=(e[s+2]&60)>>>2;if(u>d.length-1){t.trigger(p.ERROR,{type:B.MEDIA_ERROR,details:L.FRAG_PARSING_ERROR,fatal:!0,reason:`invali
10d ADTS sampling index:${u}`});return}return o=(e[s+2]&1)<<2,o|=(e[s+3]&192)>>>6,v.log(`manifest codec:${i}, ADTS type:${n}, samplingIndex:${u}`),/firefox/i.test(l)?u>=6?(n=5,a=new Array(4),r=u-3):(n=2,a=new Array(2),r=u):l.indexOf("android")!==-1?(n=2,a=new Array(2),r=u):(n=5,a=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&u>=6?r=u-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(u>=6&&o===1||/vivaldi/i.test(l))||!i&&o===1)&&(n=2,a=new Array(2)),r=u)),a[0]=n<<3,a[0]|=(u&14)>>1,a[1]|=(u&1)<<7,a[1]|=o<<3,n===5&&(a[1]|=(r&14)>>1,a[2]=(r&1)<<7,a[2]|=8,a[3]=0),{config:a,samplerate:d[u],channelCount:o,codec:"mp4a.40."+n,manifestCodec:c}}function Ih(t,e){return t[e]===255&&(t[e+1]&246)===240}function Lh(t,e){return t[e+1]&1?7:9}function Po(t,e){return(t[e+3]&3)<<11|t[e+4]<<3|(t[e+5]&224)>>>5}function qR(t,e){return e+5<t.length}function xi(t,e){return e+1<t.length&&Ih(t,e)}function YR(t,e){return qR(t,e)&&Ih(t,e)&&Po(t,e)<=t.length-e}function jR(t,e){if(xi(t,e)){const s=Lh(t,e);if(e+s>=t.length)return!1;const i=Po(t,e);if(i<=s)return!1;const n=e+i;return n===t.length||xi(t,n)}return!1}function Rh(t,e,s,i,n){if(!t.samplerate){const r=WR(e,s,i,n);if(!r)return;t.config=r.config,t.samplerate=r.samplerate,t.channelCount=r.channelCount,t.codec=r.codec,t.manifestCodec=r.manifestCodec,v.log(`parsed codec:${t.codec}, rate:${r.samplerate}, channels:${r.channelCount}`)}}function Ch(t){return 1024*9e4/t}function zR(t,e){const s=Lh(t,e);if(e+s<=t.length){const i=Po(t,e)-s;if(i>0)return{headerLength:s,frameLength:i}}}function _h(t,e,s,i,n){const r=Ch(t.samplerate),o=i+n*r,a=zR(e,s);let l;if(a){const{frameLength:u,headerLength:h}=a,f=h+u,g=Math.max(0,s+f-e.length);g?(l=new Uint8Array(f-h),l.set(e.subarray(s+h,e.length),0)):l=e.subarray(s+h,s+f);const m={unit:l,pts:o};return g||t.samples.push(m),{sample:m,length:f,missing:g}}const c=e.length-s;return l=new Uint8Array(c),l.set(e.subarray(s,e.length),0),{sample:{unit:l,pts:o},length:c,missing:-1}}class XR extends Ah{constructor(e,s){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=s}resetInitSegment(e,s,i,n){super.resetInitSegment(e,s,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:s,duration:n,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let i=(Si(e,0)||[]).length;for(let n=e.length;i<n;i++)if(jR(e,i))return v.log("ADTS sync word found !"),!0;return!1}canParse(e,s){return YR(e,s)}appendFrame(e,s,i){Rh(e,this.observer,s,i,e.manifestCodec);const n=_h(e,s,i,this.basePTS,this.frameIndex);if(n&&n.missing===0)return n}}const QR=/\/emsg[-/]ID3/i;class JR{constructor(e,s){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=s}resetTimeStamp(){}resetInitSegment(e,s,i,n){const r=this.videoTrack=je("video",1),o=this.audioTrack=je("audio",1),a=this.txtTrack=je("text",1);if(this.id3Track=je("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const l=dh(e);if(l.video){const{id:c,timescale:d,codec:u}=l.video;r.id=c,r.timescale=a.timescale=d,r.codec=u}if(l.audio){const{id:c,timescale:d,codec:u}=l.audio;o.id=c,o.timescale=d,o.codec=u}a.id=ah.text,r.sampleDuration=0,r.duration=o.duration=n}resetContiguity(){this.remainderData=null}static probe(e){return e=e.length>16384?e.subarray(0,16384):e,K(e,["moof"]).length>0}demux(e,s){this.timeOffset=s;let i=e;const n=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=Mt(this.remainderData,e));const a=$L(i);this.remainderData=a.remainder,n.samples=a.valid||new Uint8Array}else n.samples=i;const o=this.extractID3Track(n,s);return r.samples=La(s,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,s=this.videoTrack,i=this.txtTrack;s.samples=this.remainderData||new Uint8Array,this.remainderData=null;const n=this.extractID3Track(s,this.timeOffset);return i.samples=La(e,s),{videoTrack:s,audioTrack:je(),id3Track:n,textTrack:je()}}extractID3Track(e,s){const i=this.id3Track;if(e.samples.length){const n=K(e.samples,["emsg"]);
vendor: 9,401 bytes, line 10
10n&&n.forEach(r=>{const o=HL(r);if(QR.test(o.schemeIdUri)){const a=N(o.presentationTime)?o.presentationTime/o.timeScale:s+o.presentationTimeDelta/o.timeScale;let l=o.eventDuration===4294967295?Number.POSITIVE_INFINITY:o.eventDuration/o.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);const c=o.payload;i.samples.push({data:c,len:c.byteLength,dts:a,pts:a,type:Ke.emsg,duration:l})}})}return i}demuxSampleAes(e,s,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}let Xs=null;const ZR=[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],eC=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],tC=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],sC=[0,1,1,4];function wh(t,e,s,i,n){if(s+24>e.length)return;const r=Dh(e,s);if(r&&s+r.frameLength<=e.length){const o=r.samplesPerFrame*9e4/r.sampleRate,a=i+n*o,l={unit:e.subarray(s,s+r.frameLength),pts:a,dts:a};return t.config=[],t.channelCount=r.channelCount,t.samplerate=r.sampleRate,t.samples.push(l),{sample:l,length:r.frameLength,missing:0}}}function Dh(t,e){const s=t[e+1]>>3&3,i=t[e+1]>>1&3,n=t[e+2]>>4&15,r=t[e+2]>>2&3;if(s!==1&&n!==0&&n!==15&&r!==3){const o=t[e+2]>>1&1,a=t[e+3]>>6,l=s===3?3-i:i===3?3:4,c=ZR[l*14+n-1]*1e3,u=eC[(s===3?0:s===2?1:2)*3+r],h=a===3?1:2,f=tC[s][i],g=sC[i],m=f*8*g,y=Math.floor(f*c/u+o)*g;if(Xs===null){const T=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Xs=T?parseInt(T[1]):0}return Xs&&Xs<=87&&i===2&&c>=224e3&&a===0&&(t[e+3]=t[e+3]|128),{sampleRate:u,channelCount:h,frameLength:y,samplesPerFrame:m}}}function Oo(t,e){return t[e]===255&&(t[e+1]&224)===224&&(t[e+1]&6)!==0}function kh(t,e){return e+1<t.length&&Oo(t,e)}function iC(t,e){return Oo(t,e)&&4<=t.length-e}function nC(t,e){if(e+1<t.length&&Oo(t,e)){const i=Dh(t,e);let n=4;i!=null&&i.frameLength&&(n=i.frameLength);const r=e+n;return r===t.length||kh(t,r)}return!1}class za{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,s=this.bytesAvailable,i=e.byteLength-s,n=new Uint8Array(4),r=Math.min(4,s);if(r===0)throw new Error("no bytes available");n.set(e.subarray(i,i+r)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=r*8,this.bytesAvailable-=r}skipBits(e){let s;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,s=e>>3,e-=s<<3,this.bytesAvailable-=s,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let s=Math.min(this.bitsAvailable,e);const i=this.word>>>32-s;if(e>32&&v.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=s,this.bitsAvailable>0)this.word<<=s;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return s=e-s,s>0&&this.bitsAvailable?i<<s|this.readBits(s):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!==0)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 s=8,i=8,n;for(let r=0;r<e;r++)i!==0&&(n=this.readEG(),i=(s+n+256)%256),s=i===0?s:i}readSPS(){let e=0,s=0,i=0,n=0,r,o,a;const l=this.readUByte.bind(this),c=this.readBits.bind(this),d=this.readUEG.bind(this),u=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),g=this.skipUEG.bind(this),m=this.skipScalingList.bind(this);l();const y=l();if(c(5),h(3),l(),g(),y===100||y===110||y===122||y===244||y===44||y===83||y===86||y===118||y===128){const k=d();if(k===3&&h(1),g(),g(),h(1),u())for(o=k!==3?8:12,a=0;a<o;a++)u()&&(a<6?m(16):m(64))}g();const S=d();if(S===0)d();else if(S===1)for(h(1),f(),f(),r=d(),a=0;a<r;a++)f();g(),h(1);const E=d(),T=d(),R=c(1);R===0&&h(1),h(1),u()&&(e=d(),s=d(),i=d(),n=d());let I=[1,1];if(u()&&u())switch(l()){case 1:I=[1,1];break;case 2:I=[12,11];break;case 3:I=[10,11];break;case 4:I=[16,11];break;case 5:I=[40,33];break;case 6:I=[24,11];break;case 7:I=[20,11];break;case 8:I=[32,11];break;case 9:I=[80,33];break;case 10:I=[18,11];break;case 11:I=[15,11];break;case 12:I=[64,33];break;case 13:I=[160,99];break;case 14:I=[4,3];break;case 15:I=[3,2];break;case 16:I=[2,1];break;case 255:{I=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((E+1)*16-e*2-s*2),height:(2-R)*(T+1)*16-(R?2:4)*(i+n),pixelRatio:I}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class rC{constructor(e,s,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Do(s,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,s,i){const n=e[s].unit;if(n.length<=16)return;const r=n.subarray(16,n.length-n.length%16),o=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(o).then(a=>{const l=new Uint8Array(a);n.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,s+1,i)})}decryptAacSamples(e,s,i){for(;;s++){if(s>=e.length){i();return}if(!(e[s].unit.length<32)&&(this.decryptAacSample(e,s,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const s=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(s);let n=0;for(let r=32;r<e.length-16;r+=160,n+=16)i.set(e.subarray(r,r+16),n);return i}getAvcDecryptedUnit(e,s){const i=new Uint8Array(s);let n=0;for(let r=32;r<e.length-16;r+=160,n+=16)e.set(i.subarray(n,n+16),r);return e}decryptAvcSample(e,s,i,n,r){const o=fh(r.data),a=this.getAvcEncryptedData(o);this.decryptBuffer(a.buffer).then(l=>{r.data=this.getAvcDecryptedUnit(o,l),this.decrypter.isSync()||this.decryptAvcSamples(e,s,i+1,n)})}decryptAvcSamples(e,s,i,n){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;s++,i=0){if(s>=e.length){n();return}const r=e[s].units;for(;!(i>=r.length);i++){const o=r[i];if(!(o.data.length<=48||o.type!==1&&o.type!==5)&&(this.decryptAvcSample(e,s,i,n,o),!this.decrypter.isSync()))return}}}}const ye=188;class ut{constructor(e,s,i){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=s,this.typeSupported=i}static probe(e){const s=ut.syncOffset(e);return s>0&&v.warn(`MPEG2-TS detected but first sync word found @ offset ${s}`),s!==-1}static syncOffset(e){const s=e.length;let i=Math.min(ye*5,e.length-ye)+1,n=0;for(;n<i;){let r=!1,o=-1,a=0;for(let l=n;l<s;l+=ye)if(e[l]===71){if(a++,o===-1&&(o=l,o!==0&&(i=Math.min(o+ye*99,e.length-ye)+1)),r||(r=er(e,l)===0),r&&a>1&&(o===0&&a>2||l+ye>i))return o}else{if(a)return-1;break}n++}return-1}static createTrack(e,s){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:ah[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?s:void 0}}resetInitSegment(e,s,i,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=ut.createTrack("video"),this._audioTrack=ut.createTrack("audio",n),this._id3Track=ut.createTrack("id3"),this._txtTrack=ut.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=s,this.videoCodec=i,this._duration=n}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_avcTrack:s,_id3Track:i}=this;e&&(e.pesData=null),s&&(s.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(e,s,i=!1,n=!1){i||(this.sampleAes=null);let r;const o=this._avcTrack,a=this._audioTrack,l=this._id3Track,c=this._txtTrack;let d=o.pid,u=o.pesData,h=a.pid,f=l.pid,g=a.pesData,m=l.pesData,y=null,S=this.pmtParsed,E=this._pmtId,T=e.length;if(this.remainderData&&(e=Mt(this.remainderData,e),T=e.length,this.remainderData=null),T<ye&&!n)return this.remainderData=e,{audioTrack:a,videoTrack:o,id3Track:l,textTrack:c};const R=Math.max(0,ut.syncOffset(e));T-=(T-R)%ye,T<e.byteLength&&!n&&(this.remainderData=new Uint8Array(e.buffer,T,e.buffer.byteLength-T));let I=0;for(let w=R;w<T;w+=ye)if(e[w]===71){const D=!!(e[w+1]&64),P=er(e,w),C=(e[w+3]&48)>>4;let F;if(C>1){if(F=w+5+e[w+4],F===w+ye)continue}else F=w+4;switch(P){case d:D&&(u&&(r=Ht(u))&&this.parseAVCPES(o,c,r,!1),u={data:[],size:0}),u&&(u.data.push(e.subarray(F,w+ye)),u.size+=w+ye-F);break;case h:if(D){if(g&&(r=Ht(g)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,r);break;case"mp3":this.parseMPEGPES(a,r);break}g={data:[],size:0}}g&&(g.data.push(e.subarray(F,w+ye)),g.size+=w+ye-F);break;case f:D&&(m&&(r=Ht(m))&&this.parseID3PES(l,r),m={data:[],size:0}),m&&(m.data.push(e.subarray(F,w+ye)),m.size+=w+ye-F);break;case 0:D&&(F+=e[F]+1),E=this._pmtId=oC(e,F);break;case E:{D&&(F+=e[F]+1);
10const O=aC(e,F,this.typeSupported,i);d=O.avc,d>0&&(o.pid=d),h=O.audio,h>0&&(a.pid=h,a.segmentCodec=O.segmentCodec),f=O.id3,f>0&&(l.pid=f),y!==null&&!S&&(v.warn(`MPEG-TS PMT found at ${w} after unknown PID '${y}'. Backtracking to sync byte @${R} to parse all TS packets.`),y=null,w=R-188),S=this.pmtParsed=!0;break}case 17:case 8191:break;default:y=P;break}}else I++;if(I>0){const w=new Error(`Found ${I} TS packet/s that do not start with 0x47`);this.observer.emit(p.ERROR,p.ERROR,{type:B.MEDIA_ERROR,details:L.FRAG_PARSING_ERROR,fatal:!1,error:w,reason:w.message})}o.pesData=u,a.pesData=g,l.pesData=m;const k={audioTrack:a,videoTrack:o,id3Track:l,textTrack:c};return n&&this.extractRemainingSamples(k),k}flush(){const{remainderData:e}=this;this.remainderData=null;let s;return e?s=this.demux(e,-1,!1,!0):s={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(s),this.sampleAes?this.decrypt(s,this.sampleAes):s}extractRemainingSamples(e){const{audioTrack:s,videoTrack:i,id3Track:n,textTrack:r}=e,o=i.pesData,a=s.pesData,l=n.pesData;let c;if(o&&(c=Ht(o))?(this.parseAVCPES(i,r,c,!0),i.pesData=null):i.pesData=o,a&&(c=Ht(a))){switch(s.segmentCodec){case"aac":this.parseAACPES(s,c);break;case"mp3":this.parseMPEGPES(s,c);break}s.pesData=null}else a!=null&&a.size&&v.log("last AAC PES packet truncated,might overlap between fragments"),s.pesData=a;l&&(c=Ht(l))?(this.parseID3PES(n,c),n.pesData=null):n.pesData=l}demuxSampleAes(e,s,i){const n=this.demux(e,i,!0,!this.config.progressive),r=this.sampleAes=new rC(this.observer,this.config,s);return this.decrypt(n,r)}decrypt(e,s){return new Promise(i=>{const{audioTrack:n,videoTrack:r}=e;n.samples&&n.segmentCodec==="aac"?s.decryptAacSamples(n.samples,0,()=>{r.samples?s.decryptAvcSamples(r.samples,0,0,()=>{i(e)}):i(e)}):r.samples&&s.decryptAvcSamples(r.samples,0,0,()=>{i(e)})})}destroy(){this._duration=0}parseAVCPES(e,s,i,n){const r=this.parseAVCNALu(e,i.data);let o=this.avcSample,a,l=!1;i.data=null,o&&r.length&&!e.audFound&&(us(o,e),o=this.avcSample=Qs(!1,i.pts,i.dts,"")),r.forEach(c=>{var d;switch(c.type){case 1:{let h=!1;a=!0;const f=c.data;if(l&&f.length>4){const g=new za(f).readSliceType();(g===2||g===4||g===7||g===9)&&(h=!0)}if(h){var u;(u=o)!=null&&u.frame&&!o.key&&(us(o,e),o=this.avcSample=null)}o||(o=this.avcSample=Qs(!0,i.pts,i.dts,"")),o.frame=!0,o.key=h;break}case 5:a=!0,(d=o)!=null&&d.frame&&!o.key&&(us(o,e),o=this.avcSample=null),o||(o=this.avcSample=Qs(!0,i.pts,i.dts,"")),o.key=!0,o.frame=!0;break;case 6:{a=!0,hh(c.data,1,i.pts,s.samples);break}case 7:if(a=!0,l=!0,!e.sps){const h=c.data,g=new za(h).readSPS();e.width=g.width,e.height=g.height,e.pixelRatio=g.pixelRatio,e.sps=[h],e.duration=this._duration;const m=h.subarray(1,4);let y="avc1.";for(let S=0;S<3;S++){let E=m[S].toString(16);E.length<2&&(E="0"+E),y+=E}e.codec=y}break;case 8:a=!0,e.pps||(e.pps=[c.data]);break;case 9:a=!1,e.audFound=!0,o&&us(o,e),o=this.avcSample=Qs(!1,i.pts,i.dts,"");break;case 12:a=!0;break;default:a=!1,o&&(o.debug+="unknown NAL "+c.type+" ");break}o&&a&&o.units.push(c)}),n&&o&&(us(o,e),this.avcSample=null)}getLastNalUnit(e){var s;let i=this.avcSample,n;if((!i||i.units.length===0)&&(i=e[e.length-1]),(s=i)!=null&&s.units){const r=i.units;n=r[r.length-1]}return n}parseAVCNALu(e,s){const i=s.byteLength;let n=e.naluState||0;const r=n,o=[];let a=0,l,c,d,u=-1,h=0;for(n===-1&&(u=0,h=s[0]&31,n=0,a=1);a<i;){if(l=s[a++],!n){n=l?0:1;continue}if(n===1){n=l?0:2;continue}if(!l)n=3;else if(l===1){if(u>=0){const f={data:s.subarray(u,a-n-1),type:h};o.push(f)}else{const f=this.getLastNalUnit(e.samples);if(f&&(r&&a<=4-r&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-r)),c=a-n-1,c>0)){const g=new Uint8Array(f.data.byteLength+c);g.set(f.data,0),g.set(s.subarray(0,c),f.data.byteLength),f.data=g,f.state=0}}a<i?(d=s[a]&31,u=a,h=d,n=0):n=-1}else n=0}if(u>=0&&n>=0){const f={data:s.subarray(u,i),type:h,state:n};o.push(f)}if(o.length===0){const f=this.getLastNalUnit(e.samples);if(f){const g=new Uint8Array(f.data.byteLength+s.byteLength);g.set(f.data,0),g.set(s,f.data.byteLength),f.data=g}}return e.naluState=n,o}parseAACPES(e,s){let i=0;const n=this.aacOverFlow;let r=s.data;if(n){this.aacOverFlow=null;const u=n.missing,h=n.sample.unit.byteLength;if(u===-1){const f=new Uint8Array(h+r.byteLength);f.set(n.sample.unit,0),f.set(r,h),r=f}else{const f=h-u;n.sample.unit.set(r.subarray(0,u),f),e.samples.push(n.sample),i=n.missing}}let o,a;for(o=i,a=r.length;o<a-1&&!xi(r,o);o++);if(o!==i){let u;const h=o<a-1;h?u=`AAC PES did not start with ADTS header,offset:${o}`:u="No ADTS header found in AAC PES";const f=new Error(u);if(v.warn(`parsing error: ${u}`),this.observer.emit(p.ERROR,p.ERROR,{type:B.MEDIA_ERROR,details:L.FRAG_PARSING_ERROR,fatal:!1,levelRetry:h,error:f,reason:u}),!h)return}Rh(e,this.observer,r,o,this.audioCodec);let l;if(s.pts!==void 0)l=s.pts;else if(n){const u=Ch(e.samplerate);l=n.sample.pts+u}else{v.warn("[tsdemuxer]: AAC PES unknown PTS");return}let c=0,d;for(;o<a;)if(d=_h(e,r,o,l,c),o+=d.length,d.missing){this.aacOverFlow=d;break}else for(c++;o<a-1&&!xi(r,o);o++);}parseMPEGPES(e,s){const i=s.data,n=i.length;let r=0,o=0;const a=s.pts;if(a===void 0){v.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<n;)if(kh(i,o)){const l=wh(e,i,o,a,r);if(l)o+=l.length,r++;else break}else o++}parseID3PES(e,s){if(s.pts===void 0){v.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=de({}
10,s,{type:this._avcTrack?Ke.emsg:Ke.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}}function Qs(t,e,s,i){return{key:t,frame:!1,pts:e,dts:s,units:[],debug:i,length:0}}function er(t,e){return((t[e+1]&31)<<8)+t[e+2]}function oC(t,e){return(t[e+10]&31)<<8|t[e+11]}function aC(t,e,s,i){const n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},r=(t[e+1]&15)<<8|t[e+2],o=e+3+r-4,a=(t[e+10]&15)<<8|t[e+11];for(e+=12+a;e<o;){const l=er(t,e);switch(t[e]){case 207:if(!i){v.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:n.audio===-1&&(n.audio=l);break;case 21:n.id3===-1&&(n.id3=l);break;case 219:if(!i){v.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:n.avc===-1&&(n.avc=l);break;case 3:case 4:s.mpeg!==!0&&s.mp3!==!0?v.log("MPEG audio found, not supported in this browser"):n.audio===-1&&(n.audio=l,n.segmentCodec="mp3");break;case 36:v.warn("Unsupported HEVC stream type found");break}e+=((t[e+3]&15)<<8|t[e+4])+5}return n}function Ht(t){let e=0,s,i,n,r,o;const a=t.data;if(!t||t.size===0)return null;for(;a[0].length<19&&a.length>1;){const c=new Uint8Array(a[0].length+a[1].length);c.set(a[0]),c.set(a[1],a[0].length),a[0]=c,a.splice(1,1)}if(s=a[0],(s[0]<<16)+(s[1]<<8)+s[2]===1){if(i=(s[4]<<8)+s[5],i&&i>t.size-6)return null;const c=s[7];c&192&&(r=(s[9]&14)*536870912+(s[10]&255)*4194304+(s[11]&254)*16384+(s[12]&255)*128+(s[13]&254)/2,c&64?(o=(s[14]&14)*536870912+(s[15]&255)*4194304+(s[16]&254)*16384+(s[17]&255)*128+(s[18]&254)/2,r-o>60*9e4&&(v.warn(`${Math.round((r-o)/9e4)}s delta between PTS and DTS, align them`),r=o)):o=r),n=s[8];let d=n+9;if(t.size<=d)return null;t.size-=d;const u=new Uint8Array(t.size);for(let h=0,f=a.length;h<f;h++){s=a[h];let g=s.byteLength;if(d)if(d>g){d-=g;continue}else s=s.subarray(d),g-=d,d=0;u.set(s,e),e+=g}return i&&(i-=n+3),{data:u,pts:r,dts:o,len:i}}return null}function us(t,e){if(t.units.length&&t.frame){if(t.pts===void 0){const s=e.samples,i=s.length;if(i){const n=s[i-1];t.pts=n.pts,t.dts=n.dts}else{e.dropped++;return}}e.samples.push(t)}t.debug.length&&v.log(t.pts+"/"+t.dts+":"+t.debug)}class lC extends Ah{resetInitSegment(e,s,i,n){super.resetInitSegment(e,s,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:s,duration:n,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let i=(Si(e,0)||[]).length;for(let n=e.length;i<n;i++)if(nC(e,i))return v.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,s){return iC(e,s)}appendFrame(e,s,i){if(this.basePTS!==null)return wh(e,s,i,this.basePTS,this.frameIndex)}}class Xa{static getSilentFrame(e,s){switch(e){case"mp4a.40.2":if(s===1)return new Uint8Array([0,200,0,128,35,128]);if(s===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(s===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(s===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(s===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(s===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(s===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(s===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(s===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 ct=Math.pow(2,32)-1;class A{static init(){A.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in A.types)A.types.hasOwnProperty(e)&&(A.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const s=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]),i=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]);A.HDLR_TYPES={video:s,audio:i};const n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new
vendor: 5,749 bytes, line 10
10Uint8Array([0,0,0,0,0,0,0,0]);A.STTS=A.STSC=A.STCO=r,A.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),A.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),A.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),A.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const o=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);A.FTYP=A.box(A.types.ftyp,o,l,o,a),A.DINF=A.box(A.types.dinf,A.box(A.types.dref,n))}static box(e,...s){let i=8,n=s.length;const r=n;for(;n--;)i+=s[n].byteLength;const o=new Uint8Array(i);for(o[0]=i>>24&255,o[1]=i>>16&255,o[2]=i>>8&255,o[3]=i&255,o.set(e,4),n=0,i=8;n<r;n++)o.set(s[n],i),i+=s[n].byteLength;return o}static hdlr(e){return A.box(A.types.hdlr,A.HDLR_TYPES[e])}static mdat(e){return A.box(A.types.mdat,e)}static mdhd(e,s){s*=e;const i=Math.floor(s/(ct+1)),n=Math.floor(s%(ct+1));return A.box(A.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,i>>24,i>>16&255,i>>8&255,i&255,n>>24,n>>16&255,n>>8&255,n&255,85,196,0,0]))}static mdia(e){return A.box(A.types.mdia,A.mdhd(e.timescale,e.duration),A.hdlr(e.type),A.minf(e))}static mfhd(e){return A.box(A.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"?A.box(A.types.minf,A.box(A.types.smhd,A.SMHD),A.DINF,A.stbl(e)):A.box(A.types.minf,A.box(A.types.vmhd,A.VMHD),A.DINF,A.stbl(e))}static moof(e,s,i){return A.box(A.types.moof,A.mfhd(e),A.traf(i,s))}static moov(e){let s=e.length;const i=[];for(;s--;)i[s]=A.trak(e[s]);return A.box.apply(null,[A.types.moov,A.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(A.mvex(e)))}static mvex(e){let s=e.length;const i=[];for(;s--;)i[s]=A.trex(e[s]);return A.box.apply(null,[A.types.mvex,...i])}static mvhd(e,s){s*=e;const i=Math.floor(s/(ct+1)),n=Math.floor(s%(ct+1)),r=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,i>>24,i>>16&255,i>>8&255,i&255,n>>24,n>>16&255,n>>8&255,n&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 A.box(A.types.mvhd,r)}static sdtp(e){const s=e.samples||[],i=new Uint8Array(4+s.length);let n,r;for(n=0;n<s.length;n++)r=s[n].flags,i[n+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return A.box(A.types.sdtp,i)}static stbl(e){return A.box(A.types.stbl,A.stsd(e),A.box(A.types.stts,A.STTS),A.box(A.types.stsc,A.STSC),A.box(A.types.stsz,A.STSZ),A.box(A.types.stco,A.STCO))}static avc1(e){let s=[],i=[],n,r,o;for(n=0;n<e.sps.length;n++)r=e.sps[n],o=r.byteLength,s.push(o>>>8&255),s.push(o&255),s=s.concat(Array.prototype.slice.call(r));for(n=0;n<e.pps.length;n++)r=e.pps[n],o=r.byteLength,i.push(o>>>8&255),i.push(o&255),i=i.concat(Array.prototype.slice.call(r));const a=A.box(A.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|e.sps.length].concat(s).concat([e.pps.length]).concat(i))),l=e.width,c=e.height,d=e.pixelRatio[0],u=e.pixelRatio[1];return A.box(A.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]),a,A.box(A.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),A.box(A.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,d&255,u>>24,u>>16&255,u>>8&255,u&255])))}static esds(e){const s=e.config.length;return new Uint8Array([0,0,0,0,3,23+s,0,1,0,4,15+s,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([s]).concat(e.config).concat([6,1,2]))}static mp4a(e){const s=e.samplerate;return A.box(A.types.mp4a,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,s>>8&255,s&255,0,0]),A.box(A.types.esds,A.esds(e)))}static mp3(e){const s=e.samplerate;return A.box(A.types[".mp3"],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,s>>8&255,s&255,0,0]))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?A.box(A.types.stsd,A.STSD,A.mp3(e)):A.box(A.types.stsd,A.STSD,A.mp4a(e)):A.box(A.types.stsd,A.STSD,A.avc1(e))}static tkhd(e){const s=e.id,i=e.duration*e.timescale,n=e.width,r=e.height,o=Math.floor(i/(ct+1)),a=Math.floor(i%(ct+1));return A.box(A.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,s>>24&255,s>>16&255,s>>8&255,s&255,0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,a>>24,a>>16&255,a>>8&255,a&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,n>>8&255,n&255,0,0,r>>8&255,r&255,0,0]))}static traf(e,s){const i=A.sdtp(e),n=e.id,r=Math.floor(s/(ct+1)),o=Math.floor(s%(ct+1));return A.box(A.types.traf,A.box(A.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255])),A.box(A.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,r&255,o>>24,o>>16&255,o>>8&255,o&255])),A.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,A.box(A.types.trak,A.tkhd(e),A.mdia(e))}static trex(e){const s=e.id;return A.box(A.types.trex,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,s){const i=e.samples||[],n=i.length,r=12+16*n,o=new Uint8Array(r);let a,l,c,d,u,h;for(s+=8+r,o.set([e.type==="video"?1:0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,n&255,s>>>24&255,s>>>16&255,s>>>8&255,s&255],0),a=0;a<n;a++)l=i[a],c=l.duration,d=l.size,u=l.flags,h=l.cts,o.set([c>>>24&255,c>>>16&255,c>>>8&255,c&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,u.degradPrio&61440,u.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*a);return A.box(A.types.trun,o)}
10static initSegment(e){A.types||A.init();const s=A.moov(e),i=new Uint8Array(A.FTYP.byteLength+s.byteLength);return i.set(A.FTYP),i.set(s,A.FTYP.byteLength),i}}A.types=void 0;A.HDLR_TYPES=void 0;A.STTS=void 0;A.STSC=void 0;A.STCO=void 0;A.STSZ=void 0;A.VMHD=void 0;A.SMHD=void 0;A.STSD=void 0;A.FTYP=void 0;A.DINF=void 0;const Ph=9e4;function Mo(t,e,s=1,i=!1){const n=t*e*s;return i?Math.round(n):n}function cC(t,e,s=1,i=!1){return Mo(t,e,1/s,i)}function hs(t,e=!1){return Mo(t,1e3,1/Ph,e)}function dC(t,e=1){return Mo(t,Ph,1/e)}const uC=10*1e3,Qa=1024,hC=1152;let Js=null,Sn=null;class vn{constructor(e,s,i,n=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=s,this.typeSupported=i,this.ISGenerated=!1,Js===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Js=o?parseInt(o[1]):0}if(Sn===null){const r=navigator.userAgent.match(/Safari\/(\d+)/i);Sn=r?parseInt(r[1]):0}}destroy(){}resetTimeStamp(e){v.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){v.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){v.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let s=!1;const i=e.reduce((n,r)=>{const o=r.pts-n;return o<-4294967296?(s=!0,Ue(n,r.pts)):o>0?n:r.pts},e[0].pts);return s&&v.debug("PTS rollover detected"),i}remux(e,s,i,n,r,o,a,l){let c,d,u,h,f,g,m=r,y=r;const S=e.pid>-1,E=s.pid>-1,T=s.samples.length,R=e.samples.length>0,I=a&&T>0||T>1;if((!S||R)&&(!E||I)||this.ISGenerated||a){this.ISGenerated||(u=this.generateIS(e,s,r,o));const w=this.isVideoContiguous;let D=-1,P;if(I&&(D=fC(s.samples),!w&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,D>0){v.warn(`[mp4-remuxer]: Dropped ${D} out of ${T} video samples due to a missing keyframe`);const C=this.getVideoStartPts(s.samples);s.samples=s.samples.slice(D),s.dropped+=D,y+=(s.samples[0].pts-C)/s.inputTimeScale,P=y}else D===-1&&(v.warn(`[mp4-remuxer]: No keyframe found out of ${T} video samples`),g=!1);if(this.ISGenerated){if(R&&I){const C=this.getVideoStartPts(s.samples),O=(Ue(e.samples[0].pts,C)-C)/s.inputTimeScale;m+=Math.max(0,O),y+=Math.max(0,-O)}if(R){if(e.samplerate||(v.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(e,s,r,o)),d=this.remuxAudio(e,m,this.isAudioContiguous,o,E||I||l===$.AUDIO?y:void 0),I){const C=d?d.endPTS-d.startPTS:0;s.inputTimeScale||(v.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(e,s,r,o)),c=this.remuxVideo(s,y,w,C)}}else I&&(c=this.remuxVideo(s,y,w,0));c&&(c.firstKeyFrame=D,c.independent=D!==-1,c.firstKeyFramePTS=P)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(f=Oh(i,r,this._initPTS,this._initDTS)),n.samples.length&&(h=Mh(n,r,this._initPTS))),{audio:d,video:c,initSegment:u,independent:g,text:h,id3:f}}generateIS(e,s,i,n){const r=e.samples,o=s.samples,a=this.typeSupported,l={},c=this._initPTS;let d=!c||n,u="audio/mp4",h,f,g;if(d&&(h=f=1/0),e.config&&r.length&&(e.timescale=e.samplerate,e.segmentCodec==="mp3"&&(a.mpeg?(u="audio/mpeg",e.codec=""):a.mp3&&(e.codec="mp3")),l.audio={id:"audio",container:u,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&a.mpeg?new Uint8Array(0):A.initSegment([e]),metadata:{channelCount:e.channelCount}},d&&(g=e.inputTimeScale,!c||g!==c.timescale?h=f=r[0].pts-Math.round(g*i):d=!1)),s.sps&&s.pps&&o.length&&(s.timescale=s.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:s.codec,initSegment:A.initSegment([s]),metadata:{width:s.width,height:s.height}},d))if(g=s.inputTimeScale,!c||g!==c.timescale){const m=this.getVideoStartPts(o),y=Math.round(g*i);f=Math.min(f,Ue(o[0].dts,m)-y),h=Math.min(h,m-y)}else d=!1;if(Object.keys(l).length)return this.ISGenerated=!0,d?(this._initPTS={baseTime:h,timescale:g},this._initDTS={baseTime:f,timescale:g}):h=g=void 0,{tracks:l,initPTS:h,timescale:g}}remuxVideo(e,s,i,n){const r=e.inputTimeScale,o=e.samples,a=[],l=o.length,c=this._initPTS;let d=this.nextAvcDts,u=8,h=this.videoSampleDuration,f,g,m=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,S=!1;if(!i||d===null){const M=s*r,U=o[0].pts-Ue(o[0].dts,o[0].pts);d=M-U}const E=c.baseTime*r/c.timescale;for(let M=0;M<l;M++){const U=o[M];U.pts=Ue(U.pts-E,d),U.dts=Ue(U.dts-E,d),U.dts<o[M>0?M-1:M].dts&&(S=!0)}S&&o.sort(function(M,U){const X=M.dts-U.dts,J=M.pts-U.pts;return X||J}
vendor: 19,830 bytes, lines 10-13
10),f=o[0].dts,g=o[o.length-1].dts;const T=g-f,R=T?Math.round(T/(l-1)):h||e.inputTimeScale/30;if(i){const M=f-d,U=M>R,X=M<-1;if((U||X)&&(U?v.warn(`AVC: ${hs(M,!0)} ms (${M}dts) hole between fragments detected, filling it`):v.warn(`AVC: ${hs(-M,!0)} ms (${M}dts) overlapping between fragments detected`),!X||d>=o[0].pts)){f=d;const J=o[0].pts-M;o[0].dts=f,o[0].pts=J,v.log(`Video: First PTS/DTS adjusted: ${hs(J,!0)}/${hs(f,!0)}, delta: ${hs(M,!0)} ms`)}}f=Math.max(0,f);let I=0,k=0;for(let M=0;M<l;M++){const U=o[M],X=U.units,J=X.length;let Y=0;for(let ce=0;ce<J;ce++)Y+=X[ce].data.length;k+=Y,I+=J,U.length=Y,U.dts=Math.max(U.dts,f),m=Math.min(U.pts,m),y=Math.max(U.pts,y)}g=o[l-1].dts;const w=k+4*I+8;let D;try{D=new Uint8Array(w)}catch(M){this.observer.emit(p.ERROR,p.ERROR,{type:B.MUX_ERROR,details:L.REMUX_ALLOC_ERROR,fatal:!1,error:M,bytes:w,reason:`fail allocating video mdat ${w}`});return}const P=new DataView(D.buffer);P.setUint32(0,w),D.set(A.types.mdat,4);let C=!1,F=Number.POSITIVE_INFINITY,O=Number.POSITIVE_INFINITY,z=Number.NEGATIVE_INFINITY,ve=Number.NEGATIVE_INFINITY;for(let M=0;M<l;M++){const U=o[M],X=U.units;let J=0;for(let Oe=0,Ve=X.length;Oe<Ve;Oe++){const Me=X[Oe],bt=Me.data,Zi=Me.data.byteLength;P.setUint32(u,Zi),u+=4,D.set(bt,u),u+=Zi,J+=4+Zi}let Y;if(M<l-1)h=o[M+1].dts-U.dts,Y=o[M+1].pts-U.pts;else{const Oe=this.config,Ve=M>0?U.dts-o[M-1].dts:R;if(Y=M>0?U.pts-o[M-1].pts:R,Oe.stretchShortVideoTrack&&this.nextAudioPts!==null){const Me=Math.floor(Oe.maxBufferHole*r),bt=(n?m+n*r:this.nextAudioPts)-U.pts;bt>Me?(h=bt-Ve,h<0?h=Ve:C=!0,v.log(`[mp4-remuxer]: It is approximately ${bt/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=Ve}else h=Ve}const ce=Math.round(U.pts-U.dts);F=Math.min(F,h),z=Math.max(z,h),O=Math.min(O,Y),ve=Math.max(ve,Y),a.push(new Ja(U.key,h,J,ce))}if(a.length){if(Js){if(Js<70){const M=a[0].flags;M.dependsOn=2,M.isNonSync=0}}else if(Sn&&ve-O<z-F&&R/z<.025&&a[0].cts===0){v.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let M=f;for(let U=0,X=a.length;U<X;U++){const J=M+a[U].duration,Y=M+a[U].cts;if(U<X-1){const ce=J+a[U+1].cts;a[U].duration=ce-Y}else a[U].duration=U?a[U-1].duration:R;a[U].cts=0,M=J}}}h=C||!h?R:h,this.nextAvcDts=d=g+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;const te={data1:A.moof(e.sequenceNumber++,f,de({},e,{samples:a})),data2:D,startPTS:m/r,endPTS:(y+h)/r,startDTS:f/r,endDTS:d/r,type:"video",hasAudio:!1,hasVideo:!0,nb:a.length,dropped:e.dropped};return e.samples=[],e.dropped=0,te}remuxAudio(e,s,i,n,r){const o=e.inputTimeScale,a=e.samplerate?e.samplerate:o,l=o/a,c=e.segmentCodec==="aac"?Qa:hC,d=c*l,u=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],g=r!==void 0;let m=e.samples,y=h?0:8,S=this.nextAudioPts||-1;const E=s*o,T=u.baseTime*o/u.timescale;if(this.isAudioContiguous=i=i||m.length&&S>0&&(n&&Math.abs(E-S)<9e3||Math.abs(Ue(m[0].pts-T,E)-S)<20*d),m.forEach(function(re){re.pts=Ue(re.pts-T,E)}),!i||S<0){if(m=m.filter(re=>re.pts>=0),!m.length)return;r===0?S=0:n&&!g?S=Math.max(0,E):S=m[0].pts}if(e.segmentCodec==="aac"){const re=this.config.maxAudioFramesDrift;for(let te=0,M=S;te<m.length;te++){const U=m[te],X=U.pts,J=X-M,Y=Math.abs(1e3*J/o);if(J<=-re*d&&g)te===0&&(v.warn(`Audio frame @ ${(X/o).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*J/o)} ms.`),this.nextAudioPts=S=M=X);else if(J>=re*d&&Y<uC&&g){let ce=Math.round(J/d);M=X-ce*d,M<0&&(ce--,M+=d),te===0&&(this.nextAudioPts=S=M),v.warn(`[mp4-remuxer]: Injecting ${ce} audio frame @ ${(M/o).toFixed(3)}s due to ${Math.round(1e3*J/o)} ms gap.`);for(let Oe=0;Oe<ce;Oe++){const Ve=Math.max(M,0);let Me=Xa.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Me||(v.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Me=U.unit.subarray()),m.splice(te,0,{unit:Me,pts:Ve}),M+=d,te++}}U.pts=M,M+=d}}let R=null,I=null,k,w=0,D=m.length;for(;D--;)w+=m[D].unit.byteLength;for(let re=0,te=m.length;re<te;re++){const M=m[re],U=M.unit;let X=M.pts;if(I!==null){const Y=f[re-1];Y.duration=Math.round((X-I)/l)}else if(i&&e.segmentCodec==="aac"&&(X=S),R=X,w>0){w+=y;try{k=new Uint8Array(w)}catch(Y){this.observer.emit(p.ERROR,p.ERROR,{type:B.MUX_ERROR,details:L.REMUX_ALLOC_ERROR,fatal:!1,error:Y,bytes:w,reason:`fail allocating audio mdat ${w}`});return}h||(new DataView(k.buffer).setUint32(0,w),k.set(A.types.mdat,4))}else return;k.set(U,y);const J=U.byteLength;y+=J,f.push(new Ja(!0,c,J,0)),I=X}const P=f.length;if(!P)return;const C=f[f.length-1];this.nextAudioPts=S=I+l*C.duration;const F=h?new Uint8Array(0):A.moof(e.sequenceNumber++,R/l,de({},e,{samples:f}));e.samples=[];const O=R/o,z=S/o,se={data1:F,data2:k,startPTS:O,endPTS:z,startDTS:O,endDTS:z,type:"audio",hasAudio:!0,hasVideo:!1,nb:P};return this.isAudioContiguous=!0,se}remuxEmptyAudio(e,s,i,n){const r=e.inputTimeScale,o=e.samplerate?e.samplerate:r,a=r/o,l=this.nextAudioPts,c=this._initDTS,d=c.baseTime*9e4/c.timescale,u=(l!==null?l:n.startDTS*r)+d,h=n.endDTS*r+d,f=a*Qa,g=Math.ceil((h-u)/f),m=Xa.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(v.warn("[mp4-remuxer]: remux empty Audio"),!m){v.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const y=[];for(let S=0;S<g;S++){const E=u+S*f;y.push({unit:m,pts:E,dts:E})}return e.samples=y,this.remuxAudio(e,s,i,!1)}}function Ue(t,e){let s;if(e===null)return t;for(e<t?s=-8589934592:s=8589934592;Math.abs(t-e)>4294967296;)t+=s;return t}function fC(t){for(let e=0;e<t.length;e++)if(t[e].key)return e;return-1}function Oh(t,e,s,i){const n=t.samples.length;if(!n)return;const r=t.inputTimeScale;for(let a=0;a<n;a++){const l=t.samples[a];l.pts=Ue(l.pts-s.baseTime*r/s.timescale,e*r)/r,l.dts=Ue(l.dts-i.baseTime*r/i.timescale,e*r)/r}const o=t.samples;return t.samples=[],{samples:o}}function Mh(t,e,s){const i=t.samples.length;if(!i)return;const n=t.inputTimeScale;for(let o=0;o<i;o++){const a=t.samples[o];a.pts=Ue(a.pts-s.baseTime*n/s.timescale,e*n)/n}t.samples.sort((o,a)=>o.pts-a.pts);const r=t.samples;return t.samples=[],{samples:r}}class Ja{constructor(e,s,i,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=s,this.size=i,this.cts=n,this.flags=new gC(e)}}class gC{constructor(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}}class pC{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,s,i,n){this.audioCodec=s,this.videoCodec=i,this.generateInitSegment(ML(e,n)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:s,videoCodec:i}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const n=this.initData=dh(e);s||(s=Za(n.audio,j.AUDIO)),i||(i=Za(n.video,j.VIDEO));const r={};n.audio&&n.video?r.audiovideo={container:"video/mp4",codec:s+","+i,initSegment:e,id:"main"}:n.audio?r.audio={container:"audio/mp4",codec:s,initSegment:e,id:"audio"}:n.video?r.video={container:"video/mp4",codec:i,initSegment:e,id:"main"}:v.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=r}remux(e,s,i,n,r,o){var a,l;let{initPTS:c,lastEndTime:d}=this;const u={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};N(d)||(d=this.lastEndTime=r||0);const h=s.samples;if(!(h!=null&&h.length))return u;const f={initPTS:void 0,timescale:1};let g=this.initData;if((a=g)!=null&&a.length||(this.generateInitSegment(h),g=this.initData),!((l=g)!=null&&l.length))return v.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),u;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const m=FL(h,g),y=NL(g,h),S=y===null?r:y;(mC(c,S,r,m)||f.timescale!==c.timescale&&o)&&(f.initPTS=S-r,c&&c.timescale===1&&v.warn(`Adjusting initPTS by ${f.initPTS-c.baseTime}`),this.initPTS=c={baseTime:f.initPTS,timescale:1});const E=e?S-c.baseTime/c.timescale:d,T=E+m;BL(g,h,c.baseTime/c.timescale),m>0?this.lastEndTime=T:(v.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const R=!!g.audio,I=!!g.video;let k="";R&&(k+="audio"),I&&(k+="video");const w={data1:h,startPTS:E,startDTS:E,endPTS:T,endDTS:T,type:k,hasAudio:R,hasVideo:I,nb:1,dropped:0};return u.audio=w.type==="audio"?w:void 0,u.video=w.type!=="audio"?w:void 0,u.initSegment=f,u.id3=Oh(i,r,c,c),n.samples.length&&(u.text=Mh(n,r,c)),u}}function mC(t,e,s,i){if(t===null)return!0;const n=Math.max(i,1),r=e-t.baseTime/t.timescale;return Math.abs(r-s)>n}function Za(t,e){const s=t?.codec;return s&&s.length>4?s:s==="hvc1"||s==="hev1"?"hvc1.1.6.L120.90":s==="av01"?"av01.0.04M.08":s==="avc1"||e===j.VIDEO?"avc1.42e01e":"mp4a.40.5"}let nt;try{nt=self.performance.now.bind(self.performance)}catch{v.debug("Unable to use Performance API on this environment"),nt=typeof self<"u"&&self.Date.now}const Tn=[{demux:JR,remux:pC},{demux:ut,remux:vn},{demux:XR,remux:vn},{demux:lC,remux:vn}];class el{constructor(e,s,i,n,r){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=s,this.config=i,this.vendor=n,this.id=r}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,s,i,n){const r=i.transmuxing;r.executeStart=nt();let o=new Uint8Array(e);const{currentTransmuxState:a,transmuxConfig:l}=this;n&&(this.currentTransmuxState=n);const{contiguous:c,discontinuity:d,trackSwitch:u,accurateTimeOffset:h,timeOffset:f,initSegmentChange:g}=n||a,{audioCodec:m,videoCodec:y,defaultInitPts:S,duration:E,initSegmentData:T}=l,R=yC(o,s);if(R&&R.method==="AES-128"){const D=this.getDecrypter();if(D.isSync()){let P=D.softwareDecrypt(o,R.key.buffer,R.iv.buffer);if(i.part>-1&&(P=D.flush()),!P)return r.executeEnd=nt(),En(i);o=new Uint8Array(P)}else return this.decryptionPromise=D.webCryptoDecrypt(o,R.key.buffer,R.iv.buffer).then(P=>{const C=this.push(P,null,i);return this.decryptionPromise=null,C}),this.decryptionPromise}const I=this.needsProbing(d,u);if(I){const D=this.configureTransmuxer(o);if(D)return v.warn(`[transmuxer] ${D.message}`),this.observer.emit(p.ERROR,p.ERROR,{type:B.MEDIA_ERROR,details:L.FRAG_PARSING_ERROR,fatal:!1,error:D,reason:D.message}),r.executeEnd=nt(),En(i)}(d||u||g||I)&&this.resetInitSegment(T,m,y,E,s),(d||g||I)&&this.resetInitialTimestamp(S),c||this.resetContiguity();const k=this.transmux(o,R,f,h,i),w=this.currentTransmuxState;return w.contiguous=!0,w.discontinuity=!1,w.trackSwitch=!1,r.executeEnd=nt(),k}flush(e){const s=e.transmuxing;s.executeStart=nt();const{decrypter:i,currentTransmuxState:n,decryptionPromise:r}=this;if(r)return r.then(()=>this.flush(e));const o=[],{timeOffset:a}=n;if(i){const u=i.flush();u&&o.push(this.push(u,null,e))}const{demuxer:l,remuxer:c}=this;if(!l||!c)return s.executeEnd=nt(),[En(e)];const d=l.flush(a);return ri(d)?d.then(u=>(this.flushRemux(o,u,e),o)):(this.flushRemux(o,d,e),o)}flushRemux(e,s,i){const{audioTrack:n,videoTrack:r,id3Track:o,textTrack:a}=s,{accurateTimeOffset:l,timeOffset:c}=this.currentTransmuxState;v.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const d=this.remuxer.remux(n,r,o,a,c,l,!0,this.id);e.push({remuxResult:d,chunkMeta:i}),i.transmuxing.executeEnd=nt()}resetInitialTimestamp(e){const{demuxer:s,remuxer:i}=this;!s||!i||(s.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:s}=this;!e||!s||(e.resetContiguity(),s.resetNextTimestamp())}resetInitSegment(e,s,i,n,r){const{demuxer:o,remuxer:a}=this;!o||!a||(o.resetInitSegment(e,s,i,n),a.resetInitSegment(e,s,i,r))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,s,i,n,r){let o;return s&&s.method==="SAMPLE-AES"?o=this.transmuxSampleAes(e,s,i,n,r):o=this.transmuxUnencrypted(e,i,n,r),o}transmuxUnencrypted(e,s,i,n){const{audioTrack:r,videoTrack:o,id3Track:a,textTrack:l}=this.demuxer.demux(e,s,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,o,a,l,s,i,!1,this.id),chunkMeta:n}}transmuxSampleAes(e,s,i,n,r){return this.demuxer.demuxSampleAes(e,s,i).then(o=>({remuxResult:this.remuxer.remux(o.audioTrack,o.videoTrack,o.id3Track,o.textTrack,i,n,!1,this.id),chunkMeta:r}))}configureTransmuxer(e){const{config:s,observer:i,typeSupported:n,vendor:r}=this;let o;for(let u=0,h=Tn.length;u<h;u++)if(Tn[u].demux.probe(e)){o=Tn[u];break}if(!o)return new Error("Failed to find demuxer by probing fragment data");const a=this.demuxer,l=this.remuxer,c=o.remux,d=o.demux;(!l||!(l instanceof c))&&(this.remuxer=new c(i,s,n,r)),(!a||!(a instanceof d))&&(this.demuxer=new d(i,s,n),this.probe=d.probe)}needsProbing(e,s){return!this.demuxer||!this.remuxer||e||s}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Do(this.config)),e}}function yC(t,e){let s=null;return t.byteLength>0&&e!=null&&e.key!=null&&e.iv!==null&&e.method!=null&&(s=e),s}const En=t=>({remuxResult:{},chunkMeta:t});function ri(t){return"then"in t&&t.then instanceof Function}class SC{constructor(e,s,i,n,r){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=s,this.initSegmentData=i,this.duration=n,this.defaultInitPts=r||null}}class vC{constructor(e,s,i,n,r,o){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=s,this.accurateTimeOffset=i,this.trackSwitch=n,this.timeOffset=r,this.initSegmentChange=o}}var Nh={exports:{}};(function(t){var e=Object.prototype.hasOwnProperty,s="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(s=!1));function n(l,c,d){this.fn=l,this.context=c,this.once=d||!1}function r(l,c,d,u,h){if(typeof d!="function")throw new TypeError("The listener must be a function");var f=new n(d,u||l,h),g=s?s+c:c;return l._events[g]?l._events[g].fn?l._events[g]=[l._events[g],f]:l._events[g].push(f):(l._events[g]=f,l._eventsCount++),l}function o(l,c){--l._eventsCount===0?l._events=new i:delete l._events[c]}function a(){this._events=new i,this._eventsCount=0}a.prototype.eventNames=function(){var c=[],d,u;if(this._eventsCount===0)return c;for(u in d=this._events)e.call(d,u)&&c.push(s?u.slice(1):u);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(d)):c},a.prototype.listeners=function(c){var d=s?s+c:c,u=this._events[d];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,f=u.length,g=new Array(f);h<f;h++)g[h]=u[h].fn;return g},a.prototype.listenerCount=function(c){var d=s?s+c:c,u=this._events[d];return u?u.fn?1:u.length:0},a.prototype.emit=function(c,d,u,h,f,g){var m=s?s+c:c;if(!this._events[m])return!1;var y=this._events[m],S=arguments.length,E,T;if(y.fn){switch(y.once&&this.removeListener(c,y.fn,void 0,!0),S){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,d),!0;case 3:return y.fn.call(y.context,d,u),!0;case 4:return y.fn.call(y.context,d,u,h),!0;case 5:return y.fn.call(y.context,d,u,h,f),!0;case 6:return y.fn.call(y.context,d,u,h,f,g),!0}for(T=1,E=new Array(S-1);T<S;T++)E[T-1]=arguments[T];y.fn.apply(y.context,E)}else{var R=y.length,I;for(T=0;T<R;T++)switch(y[T].once&&this.removeListener(c,y[T].fn,void 0,!0),S){case 1:y[T].fn.call(y[T].context);break;case 2:y[T].fn.call(y[T].context,d);break;case 3:y[T].fn.call(y[T].context,d,u);break;case 4:y[T].fn.call(y[T].context,d,u,h);break;default:if(!E)for(I=1,E=new Array(S-1);I<S;I++)E[I-1]=arguments[I];y[T].fn.apply(y[T].context,E)}}return!0},a.prototype.on=function(c,d,u){return r(this,c,d,u,!1)},a.prototype.once=function(c,d,u){return r(this,c,d,u,!0)},a.prototype.removeListener=function(c,d,u,h){var f=s?s+c:c;if(!this._events[f])return this;if(!d)return o(this,f),this;var g=this._events[f];if(g.fn)g.fn===d&&(!h||g.once)&&(!u||g.context===u)&&o(this,f);else{for(var m=0,y=[],S=g.length;m<S;m++)(g[m].fn!==d||h&&!g[m].once||u&&g[m].context!==u)&&y.push(g[m]);y.length?this._events[f]=y.length===1?y[0]:y:o(this,f)}return this},a.prototype.removeAllListeners=function(c){var d;return c?(d=s?s+c:c,this._events[d]&&o(this,d)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=s,a.EventEmitter=a,t.exports=a})(Nh);var TC=Nh.exports,No=rL(TC);const bn=Ji()||{isTypeSupported:()=>!1};class Fh{constructor(e,s,i,n){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 r=e.config;this.hls=e,this.id=s,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;const o=(c,d)=>{d=d||{},d.frag=this.frag,d.id=this.id,c===p.ERROR&&(this.error=d.error),this.hls.trigger(c,d)};this.observer=new No,this.observer.on(p.FRAG_DECRYPTED,o),this.observer.on(p.ERROR,o);const a={mp4:bn.isTypeSupported("video/mp4"),mpeg:bn.isTypeSupported("audio/mpeg"),mp3:bn.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(r.workerPath||VR())){try{r.workerPath?(v.log(`loading Web Worker ${r.workerPath} for "${s}"`),this.workerContext=HR(r.workerPath)):(v.log(`injecting Web Worker for "${s}"`),this.workerContext=GR()),this.onwmsg=u=>this.onWorkerMessage(u);const{worker:d}=this.workerContext;d.addEventListener("message",this.onwmsg),d.onerror=u=>{const h=new Error(`${u.message} (${u.filename}:${u.lineno})`);r.enableWorker=!1,v.warn(`Error in "${s}" Web Worker, fallback to inline`),this.hls.trigger(p.ERROR,{type:B.OTHER_ERROR,details:L.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},d.postMessage({cmd:"init",typeSupported:a,vendor:l,id:s,config:JSON.stringify(r)})}catch(d){v.warn(`Error setting up "${s}" Web Worker, fallback to inline`,d),this.resetWorker(),this.error=null,this.transmuxer=new el(this.observer,a,r,l,s)}return}this.transmuxer=new el(this.observer,a,r,l,s)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:s}=this.workerContext;s&&self.URL.revokeObjectURL(s),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 s=this.transmuxer;s&&(s.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,s,i,n,r,o,a,l,c,d){var u,h;c.transmuxing.start=self.performance.now();const{transmuxer:f}=this,g=o?o.start:r.start,m=r.decryptdata,y=this.frag,S=!(y&&r.cc===y.cc),E=!(y&&c.level===y.level),T=y?c.sn-y.sn:-1,R=this.part?c.part-this.part.index:-1,I=T===0&&c.id>1&&c.id===y?.stats.chunkCount,k=!E&&(T===1||T===0&&(R===1||I&&R<=0)),w=self.performance.now();(E||T||r.stats.parsing.start===0)&&(r.stats.parsing.start=w),o&&(R||!k)&&(o.stats.parsing.start=w);const D=!(y&&((u=r.initSegment)==null?void 0:u.url)===((h=y.initSegment)==null?void 0:h.url)),P=new vC(S,k,l,E,g,D);if(!k||S||D){v.log(`[transmuxer-interface, ${r.type}]: Starting new transmux session for sn: ${c.sn} p: ${c.part} level: ${c.level} id: ${c.id} 11 discontinuity: ${S} 12 trackSwitch: ${E} 13 contiguous: ${k}
14 accurateTimeOffset: ${l} 15 timeOffset: ${g} 16 initSegmentChange: ${D}`);const C=new SC(i,n,s,a,d);this.configureTransmuxer(C)}if(this.frag=r,this.part=o,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:m,chunkMeta:c,state:P},e instanceof ArrayBuffer?[e]:[]);else if(f){const C=f.push(e,m,c,P);ri(C)?(f.async=!0,C.then(F=>{this.handleTransmuxComplete(F)}).catch(F=>{this.transmuxerError(F,c,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(C))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:s}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(s){let i=s.flush(e);ri(i)||s.async?(ri(i)||(i=Promise.resolve(i)),i.then(r=>{this.handleFlushResult(r,e)}).catch(r=>{this.transmuxerError(r,e,"transmuxer-interface flush error")})):this.handleFlushResult(i,e)}}transmuxerError(e,s,i){this.hls&&(this.error=e,this.hls.trigger(p.ERROR,{type:B.MEDIA_ERROR,details:L.FRAG_PARSING_ERROR,chunkMeta:s,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,s){e.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(s)}onWorkerMessage(e){const s=e.data,i=this.hls;switch(s.event){case"init":{var n;const r=(n=this.workerContext)==null?void 0:n.objectURL;r&&self.URL.revokeObjectURL(r);break}case"transmuxComplete":{this.handleTransmuxComplete(s.data);break}case"flush":{this.onFlush(s.data);break}case"workerLog":v[s.data.logType]&&v[s.data.logType](s.data.message);break;default:{s.data=s.data||{},s.data.frag=this.frag,s.data.id=this.id,i.trigger(s.event,s.data);break}}}configureTransmuxer(e){const{transmuxer:s}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):s&&s.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const EC=250,xn=2,bC=.1,xC=.05;class AC{constructor(e,s,i,n){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=s,this.fragmentTracker=i,this.hls=n}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,s){const{config:i,media:n,stalled:r}=this;if(n===null)return;const{currentTime:o,seeking:a}=n,l=this.seeking&&!a,c=!this.seeking&&a;if(this.seeking=a,o!==e){if(this.moved=!0,r!==null){if(this.stallReported){const S=self.performance.now()-r;v.warn(`playback not stuck anymore @${o}, after ${Math.round(S)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(c||l){this.stalled=null;return}if(n.paused&&!a||n.ended||n.playbackRate===0||!Z.getBuffered(n).length)return;const d=Z.bufferInfo(n,o,0),u=d.len>0,h=d.nextStart||0;if(!u&&!h)return;if(a){const S=d.len>xn,E=!h||s&&s.start<=o||h-o>xn&&!this.fragmentTracker.getPartialFragment(o);if(S||E)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var f;const S=Math.max(h,d.start||0)-o,E=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,R=(E==null||(f=E.details)==null?void 0:f.live)?E.details.targetduration*2:xn,I=this.fragmentTracker.getPartialFragment(o);if(S>0&&(S<=R||I)){this._trySkipBufferHole(I);return}}const g=self.performance.now();if(r===null){this.stalled=g;return}const m=g-r;if(!a&&m>=EC&&(this._reportStall(d),!this.media))return;const y=Z.bufferInfo(n,o,i.maxBufferHole);this._tryFixBufferStall(y,m)}_tryFixBufferStall(e,s){const{config:i,fragmentTracker:n,media:r}=this;if(r===null)return;const o=r.currentTime,a=n.getPartialFragment(o);a&&(this._trySkipBufferHole(a)||!this.media)||(e.len>i.maxBufferHole||e.nextStart&&e.nextStart-o<i.maxBufferHole)&&s>i.highBufferWatchdogPeriod*1e3&&(v.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:s,media:i,stallReported:n}=this;if(!n&&i){this.stallReported=!0;const r=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(e)})`);v.warn(r.message),s.trigger(p.ERROR,{type:B.MEDIA_ERROR,details:L.BUFFER_STALLED_ERROR,fatal:!1,error:r,buffer:e.len})}}_trySkipBufferHole(e){const{config:s,hls:i,media:n}=this;if(n===null)return 0;const r=n.currentTime,o=Z.bufferInfo(n,r,0),a=r<o.start?o.start:o.nextStart;if(a){const l=o.len<=s.maxBufferHole,c=o.len>0&&o.len<1&&n.readyState<3,d=a-r;if(d>0&&(l||c)){if(d>s.maxBufferHole){const{fragmentTracker:h}=this;let f=!1;if(r===0){const g=h.getAppendedFrag(0,$.MAIN);g&&a<g.end&&(f=!0)}if(!f){const g=e||h.getAppendedFrag(r,$.MAIN);if(g){let m=!1,y=g.end;for(;y<a;){const S=h.getPartialFragment(y);if(S)y+=S.duration;else{m=!0;break}}if(m)return 0}}}const u=Math.max(a+xC,r+bC);if(v.warn(`skipping hole, adjusting currentTime from ${r} to ${u}`),this.moved=!0,this.stalled=null,n.currentTime=u,e&&!e.gap){const h=new Error(`fragment loaded with buffer holes, seeking from ${r} to ${u}`);i.trigger(p.ERROR,{type:B.MEDIA_ERROR,details:L.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return u}}return 0}_tryNudgeBuffer(){const{config:e,hls:s,media:i,nudgeRetry:n}=this;if(i===null)return;const r=i.currentTime;if(this.nudgeRetry++,n<e.nudgeMaxRetry){const o=r+(n+1)*e.nudgeOffset,a=new Error(`Nudging 'currentTime' from ${r} to ${o}`);v.warn(a.message),i.currentTime=o,s.trigger(p.ERROR,{type:B.MEDIA_ERROR,details:L.BUFFER_NUDGE_ON_STALL,error:a,fatal:!1})}else{const o=new Error(`Playhead still not moving while enough data buffered @${r} after ${e.nudgeMaxRetry} nudges`);v.error(o.message),s.trigger(p.ERROR,{type:B.MEDIA_ERROR,details:L.BUFFER_STALLED_ERROR,error:o,fatal:!0})}}}const IC=100;class LC extends ko{constructor(e,s,i){super(e,s,i,"[stream-controller]",$.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;
16e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(p.ERROR,this.onError,this),e.on(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this),e.on(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(p.ERROR,this.onError,this),e.off(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this),e.off(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(e){if(this.levels){const{lastCurrentTime:s,hls:i}=this;if(this.stopLoad(),this.setInterval(IC),this.level=-1,!this.startFragRequested){let n=i.startLevel;n===-1&&(i.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=i.nextAutoLevel),this.level=i.nextLoadLevel=n,this.loadedmetadata=!1}s>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${s.toFixed(3)}`),e=s),this.state=_.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=_.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case _.WAITING_LEVEL:{var e;const{levels:i,level:n}=this,r=i==null||(e=i[n])==null?void 0:e.details;if(r&&(!r.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(r))break;this.state=_.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=_.IDLE;break}break}case _.FRAG_LOADING_WAITING_RETRY:{var s;const i=self.performance.now(),n=this.retryDate;(!n||i>=n||(s=this.media)!=null&&s.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=_.IDLE)}break}this.state===_.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:s,levels:i,media:n}
16=this,{config:r,nextLoadLevel:o}=e;if(s===null||!n&&(this.startFragRequested||!r.startFragPrefetch)||this.altAudio&&this.audioOnly||!(i!=null&&i[o]))return;const a=i[o],l=this.getMainFwdBufferInfo();if(l===null)return;const c=this.getLevelDetails();if(c&&this._streamEnded(l,c)){const y={};this.altAudio&&(y.type="video"),this.hls.trigger(p.BUFFER_EOS,y),this.state=_.ENDED;return}e.loadLevel!==o&&e.manualLevel===-1&&this.log(`Adapting to level ${o} from level ${this.level}`),this.level=e.nextLoadLevel=o;const d=a.details;if(!d||this.state===_.WAITING_LEVEL||d.live&&this.levelLastLoaded!==o){this.level=o,this.state=_.WAITING_LEVEL;return}const u=l.len,h=this.getMaxBufferLength(a.maxBitrate);if(u>=h)return;this.backtrackFragment&&this.backtrackFragment.start>l.end&&(this.backtrackFragment=null);const f=this.backtrackFragment?this.backtrackFragment.start:l.end;let g=this.getNextFragment(f,d);if(this.couldBacktrack&&!this.fragPrevious&&g&&g.sn!=="initSegment"&&this.fragmentTracker.getState(g)!==he.OK){var m;const S=((m=this.backtrackFragment)!=null?m:g).sn-d.startSN,E=d.fragments[S-1];E&&g.cc===E.cc&&(g=E,this.fragmentTracker.removeFragment(E))}else this.backtrackFragment&&l.len&&(this.backtrackFragment=null);if(g&&this.isLoopLoading(g,f)){if(!g.gap){const S=this.audioOnly&&!this.altAudio?j.AUDIO:j.VIDEO,E=(S===j.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,S,$.MAIN)}g=this.getNextFragmentLoopLoading(g,d,l,$.MAIN,h)}g&&(g.initSegment&&!g.initSegment.data&&!this.bitrateTest&&(g=g.initSegment),this.loadFragment(g,a,f))}loadFragment(e,s,i){const n=this.fragmentTracker.getState(e);this.fragCurrent=e,n===he.NOT_LOADED||n===he.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,s):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,s)):(this.startFragRequested=!0,super.loadFragment(e,s,i)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,$.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:s}=this;if(s!=null&&s.readyState){let i;const n=this.getAppendedFrag(s.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);const r=this.getLevelDetails();if(r!=null&&r.live){const a=this.getMainFwdBufferInfo();if(!a||a.len<r.targetduration*2)return}if(!s.paused&&e){const a=this.hls.nextLoadLevel,l=e[a],c=this.fragLastKbps;c&&this.fragCurrent?i=this.fragCurrent.duration*l.maxBitrate/(1e3*c)+1:i=0}else i=0;const o=this.getBufferedFrag(s.currentTime+i);if(o){const a=this.followingBufferedFrag(o);if(a){this.abortCurrentFrag();const l=a.maxStartPTS?a.maxStartPTS:a.start,c=a.duration,d=Math.max(o.end,l+Math.min(Math.max(c-this.config.maxFragLookUpTolerance,c*.5),c*.75));this.flushMainBuffer(d,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 _.KEY_LOADING:case _.FRAG_LOADING:case _.FRAG_LOADING_WAITING_RETRY:case _.PARSING:case _.PARSED:this.state=_.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,s){super.flushMainBuffer(e,s,this.altAudio?"video":null)}onMediaAttached(e,s){super.onMediaAttached(e,s);const i=s.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new AC(this.config,i,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,s=e?e.currentTime:null;N(s)&&this.log(`Media seeked to ${s.toFixed(3)}`);const i=this.getMainFwdBufferInfo();if(i===null||i.len===0){this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(p.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(e,s){let i=!1,n=!1,r;
16s.levels.forEach(o=>{r=o.audioCodec,r&&(r.indexOf("mp4a.40.2")!==-1&&(i=!0),r.indexOf("mp4a.40.5")!==-1&&(n=!0))}),this.audioCodecSwitch=i&&n&&!$R(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=s.levels,this.startFragRequested=!1}onLevelLoading(e,s){const{levels:i}=this;if(!i||this.state!==_.IDLE)return;const n=i[s.level];(!n.details||n.details.live&&this.levelLastLoaded!==s.level||this.waitForCdnTuneIn(n.details))&&(this.state=_.WAITING_LEVEL)}onLevelLoaded(e,s){var i;const{levels:n}=this,r=s.level,o=s.details,a=o.totalduration;if(!n){this.warn(`Levels were reset while loading level ${r}`);return}this.log(`Level ${r} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${a}`);const l=n[r],c=this.fragCurrent;c&&(this.state===_.FRAG_LOADING||this.state===_.FRAG_LOADING_WAITING_RETRY)&&(c.level!==s.level||c.urlId!==l.urlId)&&c.loader&&this.abortCurrentFrag();let d=0;if(o.live||(i=l.details)!=null&&i.live){if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed)return;d=this.alignPlaylists(o,l.details)}if(l.details=o,this.levelLastLoaded=r,this.hls.trigger(p.LEVEL_UPDATED,{details:o,level:r}),this.state===_.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=_.IDLE}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,d),this.tick()}_handleFragmentLoadProgress(e){var s;const{frag:i,part:n,payload:r}=e,{levels:o}=this;if(!o){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const a=o[i.level],l=a.details;if(!l){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const c=a.videoCodec,d=l.PTSKnown||!l.live,u=(s=i.initSegment)==null?void 0:s.data,h=this._getAudioCodec(a),f=this.transmuxer=this.transmuxer||new Fh(this.hls,$.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=n?n.index:-1,m=g!==-1,y=new _o(i.level,i.sn,i.stats.chunkCount,r.byteLength,g,m),S=this.initPTS[i.cc];f.push(r,u,h,c,i,n,l.totalduration,d,y,S)}onAudioTrackSwitching(e,s){const i=this.altAudio;if(!!!s.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 o=this.fragCurrent;o&&(this.log("Switching to main audio track, cancel main fragment load"),o.abortRequests(),this.fragmentTracker.removeFragment(o)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const r=this.hls;i&&(r.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),r.trigger(p.AUDIO_TRACK_SWITCHED,s)}}onAudioTrackSwitched(e,s){const i=s.id,n=!!this.hls.audioTracks[i].url;if(n){const r=this.videoBuffer;r&&this.mediaBuffer!==r&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=r)}this.altAudio=n,this.tick()}onBufferCreated(e,s){const i=s.tracks;let n,r,o=!1;for(const a in i){const l=i[a];if(l.id==="main"){if(r=a,n=l,a==="video"){const c=i[a];c&&(this.videoBuffer=c.buffer)}}else o=!0}o&&n?(this.log(`Alternate track found, use ${r}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}onFragBuffered(e,s){const{frag:i,part:n}=s;if(i&&i.type!==$.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===_.PARSED&&(this.state=_.IDLE);return}const r=n?n.stats:i.stats;this.fragLastKbps=Math.round(8*r.total/(r.buffering.end-r.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,n)}onError(e,s){var i;if(s.fatal){this.state=_.ERROR;return}switch(s.details){case L.FRAG_GAP:case L.FRAG_PARSING_ERROR:case L.FRAG_DECRYPT_ERROR:case L.FRAG_LOAD_ERROR:case L.FRAG_LOAD_TIMEOUT:case L.KEY_LOAD_ERROR:case L.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError($.MAIN,s);break;case L.LEVEL_LOAD_ERROR:case L.LEVEL_LOAD_TIMEOUT:case L.LEVEL_PARSING_ERROR:!s.levelRetry&&this.state===_.WAITING_LEVEL&&((i=s.context)==null?void 0:i.type)===q.LEVEL&&(this.state=_.IDLE);break;case L.BUFFER_FULL_ERROR:if(!s.parent||s.parent!=="main")return;this.reduceLengthAndFlushBuffer(s)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case L.INTERNAL_EXCEPTION:this.recoverWorkerError(s);break}}
16checkBuffer(){const{media:e,gapController:s}=this;if(!(!e||!s||!e.readyState)){if(this.loadedmetadata||!Z.getBuffered(e).length){const i=this.state!==_.IDLE?this.fragCurrent:null;s.poll(this.lastCurrentTime,i)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=_.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:s}){if(s!==j.AUDIO||this.audioOnly&&!this.altAudio){const i=(s===j.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,s,$.MAIN)}}onLevelsUpdated(e,s){this.levels=s.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const s=e.currentTime;let i=this.startPosition;if(i>=0&&s<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${s}`);return}const n=Z.getBuffered(e),o=(n.length?n.start(0):0)-i;o>0&&(o<this.config.maxBufferHole||o<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${o} to match buffer start`),i+=o,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${s}`),e.currentTime=i}}_getAudioCodec(e){let s=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&s&&(this.log("Swapping audio codec"),s.indexOf("mp4a.40.5")!==-1?s="mp4a.40.2":s="mp4a.40.5"),s}_loadBitrateTestFrag(e,s){e.bitrateTest=!0,this._doFragLoad(e,s).then(i=>{const{hls:n}=this;if(!i||this.fragContextChanged(e))return;s.fragmentError=0,this.state=_.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const r=e.stats;r.parsing.start=r.parsing.end=r.buffering.start=r.buffering.end=self.performance.now(),n.trigger(p.FRAG_LOADED,i),e.bitrateTest=!1})}_handleTransmuxComplete(e){var s;const i="main",{hls:n}=this,{remuxResult:r,chunkMeta:o}=e,a=this.getCurrentContext(o);if(!a){this.resetWhenMissingContext(o);return}const{frag:l,part:c,level:d}=a,{video:u,text:h,id3:f,initSegment:g}=r,{details:m}=d,y=this.altAudio?void 0:r.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=_.PARSING,g){if(g!=null&&g.tracks){const T=l.initSegment||l;this._bufferInitSegment(d,g.tracks,T,o),n.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:T,id:i,tracks:g.tracks})}const S=g.initPTS,E=g.timescale;N(S)&&(this.initPTS[l.cc]={baseTime:S,timescale:E},n.trigger(p.INIT_PTS_FOUND,{frag:l,id:i,initPTS:S,timescale:E}))}if(u&&m&&l.sn!=="initSegment"){const S=m.fragments[l.sn-1-m.startSN],E=l.sn===m.startSN,T=!S||l.cc>S.cc;if(r.independent!==!1){const{startPTS:R,endPTS:I,startDTS:k,endDTS:w}=u;if(c)c.elementaryStreams[u.type]={startPTS:R,endPTS:I,startDTS:k,endDTS:w};else if(u.firstKeyFrame&&u.independent&&o.id===1&&!T&&(this.couldBacktrack=!0),u.dropped&&u.independent){const D=this.getMainFwdBufferInfo(),P=(D?D.end:this.getLoadPosition())+this.config.maxBufferHole,C=u.firstKeyFramePTS?u.firstKeyFramePTS:R;if(!E&&P<C-this.config.maxBufferHole&&!T){this.backtrack(l);return}else T&&(l.gap=!0);l.setElementaryStreamInfo(u.type,l.start,I,l.start,w,!0)}l.setElementaryStreamInfo(u.type,R,I,k,w),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(u,l,c,o,E||T)}else if(E||T)l.gap=!0;else{this.backtrack(l);return}}if(y){const{startPTS:S,endPTS:E,startDTS:T,endDTS:R}=y;c&&(c.elementaryStreams[j.AUDIO]={startPTS:S,endPTS:E,startDTS:T,endDTS:R}),l.setElementaryStreamInfo(j.AUDIO,S,E,T,R),this.bufferFragmentData(y,l,c,o)}if(m&&f!=null&&(s=f.samples)!=null&&s.length){const S={id:i,frag:l,details:m,samples:f.samples};n.trigger(p.FRAG_PARSING_METADATA,S)}if(m&&h){const S={id:i,frag:l,details:m,samples:h.samples};n.trigger(p.FRAG_PARSING_USERDATA,S)}}_bufferInitSegment(e,s,i,n){if(this.state!==_.PARSING)return;this.audioOnly=!!s.audio&&!s.video,this.altAudio&&!this.audioOnly&&delete s.audio;const{audio:r,video:o,audiovideo:a}=s;if(r){let l=e.audioCodec;const c=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),r.metadata.channelCount!==1&&c.indexOf("firefox")===-1&&(l="mp4a.40.5")),c.indexOf("android")!==-1&&r.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}"`),r.levelCodec=l,r.id="main",this.log(`Init audio buffer, container:${r.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${r.codec}]`)}o&&(o.levelCodec=e.videoCodec,o.id="main",this.log(`Init video buffer, container:${o.container}, codecs[level/parsed]=[${e.videoCodec||""}/${o.codec}]`)),a&&this.log(`Init audiovideo buffer, container:${a.container}, codecs[level/parsed]=[${e.attrs.CODECS||""}/${a.codec}
16]`),this.hls.trigger(p.BUFFER_CODECS,s),Object.keys(s).forEach(l=>{const d=s[l].initSegment;d!=null&&d.byteLength&&this.hls.trigger(p.BUFFER_APPENDING,{type:l,data:d,frag:i,part:null,chunkMeta:n,parent:i.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,$.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=_.IDLE}checkFragmentChanged(){const e=this.media;let s=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(Z.isBuffered(e,i)?s=this.getAppendedFrag(i):Z.isBuffered(e,i+.1)&&(s=this.getAppendedFrag(i+.1)),s){this.backtrackFragment=null;const n=this.fragPlaying,r=s.level;(!n||s.sn!==n.sn||n.level!==r||s.urlId!==n.urlId)&&(this.fragPlaying=s,this.hls.trigger(p.FRAG_CHANGED,{frag:s}),(!n||n.level!==r)&&this.hls.trigger(p.LEVEL_SWITCHED,{level:r}))}}}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 s=e.currentTime,i=this.currentFrag;if(i&&N(s)&&N(i.programDateTime)){const n=i.programDateTime+(s-i.start)*1e3;return new Date(n)}}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 Kt{constructor(e,s=0,i=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_=s,this.totalWeight_=i}sample(e,s){const i=Math.pow(this.alpha_,e);this.estimate_=s*(1-i)+i*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 RC{constructor(e,s,i,n=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_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_
16=new Kt(e),this.fast_=new Kt(s),this.defaultTTFB_=n,this.ttfb_=new Kt(e)}update(e,s){const{slow_:i,fast_:n,ttfb_:r}=this;i.halfLife!==e&&(this.slow_=new Kt(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==s&&(this.fast_=new Kt(s,n.getEstimate(),n.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new Kt(e,r.getEstimate(),r.getTotalWeight()))}sample(e,s){e=Math.max(e,this.minDelayMs_);const i=8*s,n=e/1e3,r=i/n;this.fast_.sample(n,r),this.slow_.sample(n,r)}sampleTTFB(e){const s=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(s,2)/2);this.ttfb_.sample(i,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(){}}class CC{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;const s=e.config;this.bwEstimator=new RC(s.abrEwmaSlowVoD,s.abrEwmaFastVoD,s.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(p.FRAG_LOADING,this.onFragLoading,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:e}=this;e.off(p.FRAG_LOADING,this.onFragLoading,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(e,s){var i;const n=s.frag;this.ignoreFragment(n)||(this.fragCurrent=n,this.partCurrent=(i=s.part)!=null?i:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(e,s){this.clearTimer()}getTimeToLoadFrag(e,s,i,n){const r=e+i/s,o=n?this.lastLevelLoadSec:0;return r+o}onLevelLoaded(e,s){const i=this.hls.config,{total:n,bwEstimate:r}=s.stats;N(n)&&N(r)&&(this.lastLevelLoadSec=8*n/r),s.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:e,partCurrent:s,hls:i}=this,{autoLevelEnabled:n,media:r}=i;if(!e||!r)return;const o=performance.now(),a=s?s.stats:e.stats,l=s?s.duration:e.duration,c=o-a.loading.start;if(a.aborted||a.loaded&&a.loaded===a.total||e.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||r.paused||!r.playbackRate||!r.readyState)return;const d=i.mainForwardBufferInfo;if(d===null)return;const u=this.bwEstimator.getEstimateTTFB(),h=Math.abs(r.playbackRate);if(c<=Math.max(u,1e3*(l/(h*2))))return;const f=d.len/h;if(f>=2*l/h)return;const g=a.loading.first?a.loading.first-a.loading.start:-1,m=a.loaded&&g>-1,y=this.bwEstimator.getEstimate(),{levels:S,minAutoLevel:E}=i,T=S[e.level],R=a.total||Math.max(a.loaded,Math.round(l*T.maxBitrate/8));let I=c-g;I<1&&m&&(I=Math.min(c,a.loaded*8/y));const k=m?a.loaded*1e3/I:0,w=k?(R-a.loaded)/k:R*8/y+u/1e3;if(w<=f)return;const D=k?k*8:y;let P=Number.POSITIVE_INFINITY,C;for(C=e.level-1;C>E;C--){const F=S[C].maxBitrate;if(P=this.getTimeToLoadFrag(u/1e3,D,l*F,!S[C].details),P<f)break}P>=w||P>l*10||(i.nextLoadLevel=C,m?this.bwEstimator.sample(c-Math.min(u,g),a.loaded):this.bwEstimator.sampleTTFB(c),this.clearTimer(),v.warn(`[abr] Fragment ${e.sn}${s?" part "+s.index:""} of level ${e.level} is loading too slowly; 17 Time to underbuffer: ${f.toFixed(3)} s 18 Estimated load time for current fragment: ${w.toFixed(3)} s 19 Estimated load time for down switch fragment: ${P.toFixed(3)} s 20 TTFB estimate: ${g} 21 Current BW estimate: ${N(y)?(y/1024).toFixed(3):"Unknown"} Kb/s 22 New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s 23 Aborting and switching to level ${C}`),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),i.trigger(p.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:s,stats:a}))}onFragLoaded(e,{frag:s,part:i}){const n=i?i.stats:s.stats;if(s.type===$.MAIN&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(s)){if
23(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const r=i?i.duration:s.duration,o=this.hls.levels[s.level],a=(o.loaded?o.loaded.bytes:0)+n.loaded,l=(o.loaded?o.loaded.duration:0)+r;o.loaded={bytes:a,duration:l},o.realBitrate=Math.round(8*a/l)}if(s.bitrateTest){const r={stats:n,frag:s,part:i,id:s.type};this.onFragBuffered(p.FRAG_BUFFERED,r),s.bitrateTest=!1}}}onFragBuffered(e,s){const{frag:i,part:n}=s,r=n!=null&&n.stats.loaded?n.stats:i.stats;if(r.aborted||this.ignoreFragment(i))return;const o=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(o,r.loaded),r.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=o/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==$.MAIN||e.sn==="initSegment"}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const e=this._nextAutoLevel,s=this.bwEstimator;if(e!==-1&&!s.canEstimate())return e;let i=this.getNextABRAutoLevel();if(e!==-1){const n=this.hls.levels;if(n.length>Math.max(e,i)&&n[e].loadError<=n[i].loadError)return e}return e!==-1&&(i=Math.min(e,i)),i}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:s,hls:i}=this,{maxAutoLevel:n,config:r,minAutoLevel:o,media:a}=i,l=s?s.duration:e?e.duration:0,c=a&&a.playbackRate!==0?Math.abs(a.playbackRate):1,d=this.bwEstimator?this.bwEstimator.getEstimate():r.abrEwmaDefaultEstimate,u=i.mainForwardBufferInfo,h=(u?u.len:0)/c;let f=this.findBestLevel(d,o,n,h,r.abrBandWidthFactor,r.abrBandWidthUpFactor);if(f>=0)return f;v.trace(`[abr] ${h?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let g=l?Math.min(l,r.maxStarvationDelay):r.maxStarvationDelay,m=r.abrBandWidthFactor,y=r.abrBandWidthUpFactor;if(!h){const S=this.bitrateTestDelay;S&&(g=(l?Math.min(l,r.maxLoadingDelay):r.maxLoadingDelay)-S,v.trace(`[abr] bitrate test took ${Math.round(1e3*S)}ms, set first fragment max fetchDuration to ${Math.round(1e3*g)} ms`),m=y=1)}return f=this.findBestLevel(d,o,n,h+g,m,y),Math.max(f,0)}findBestLevel(e,s,i,n,r,o){var a;const{fragCurrent:l,partCurrent:c,lastLoadedFragLevel:d}=this,{levels:u}=this.hls,h=u[d],f=!!(h!=null&&(a=h.details)!=null&&a.live),g=h?.codecSet,m=c?c.duration:l?l.duration:0,y=this.bwEstimator.getEstimateTTFB()/1e3;let S=s,E=-1;for(let T=i;T>=s;T--){const R=u[T];if(!R||g&&R.codecSet!==g){R&&(S=Math.min(T,S),E=Math.max(T,E));continue}E!==-1&&v.trace(`[abr] Skipped level(s) ${S}-${E} with CODECS:"${u[E].attrs.CODECS}"; not compatible with "${h.attrs.CODECS}"`);const I=R.details,k=(c?I?.partTarget:I?.averagetargetduration)||m;let w;T<=d?w=r*e:w=o*e;const D=u[T].maxBitrate,P=this.getTimeToLoadFrag(y,w,D*k,I===void 0);if(v.trace(`[abr] level:${T} adjustedbw-bitrate:${Math.round(w-D)} avgDuration:${k.toFixed(1)} maxFetchDuration:${n.toFixed(1)} fetchDuration:${P.toFixed(1)}`),w>D&&(P===0||!N(P)||f&&!this.bitrateTestDelay||P<n))return T}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}}class Uh{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:s}=this;let i;if(e.length)e.length===1?i=e[0]:i=_C(e,s);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function _C(t,e){const s=new Uint8Array(e);let i=0;for(let n=0;n<t.length;n++){const r=t[n];s.set(r,i),i+=r.length}return s}const tl=100;class wC extends ko{constructor(e,s,i){super(e,s,i,"[audio-stream-controller]",$.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.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(p.ERROR,this.onError,this),e.on(p.BUFFER_RESET,this.onBufferReset,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this),e.on(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;
23e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(p.ERROR,this.onError,this),e.off(p.BUFFER_RESET,this.onBufferReset,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this),e.off(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:s,id:i,initPTS:n,timescale:r}){if(i==="main"){const o=s.cc;this.initPTS[s.cc]={baseTime:n,timescale:r},this.log(`InitPTS for cc: ${o} found from main: ${n}`),this.videoTrackCC=o,this.state===_.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=_.STOPPED;return}const s=this.lastCurrentTime;this.stopLoad(),this.setInterval(tl),s>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${s.toFixed(3)}`),e=s,this.state=_.IDLE):(this.loadedmetadata=!1,this.state=_.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case _.IDLE:this.doTickIdle();break;case _.WAITING_TRACK:{var e;const{levels:i,trackId:n}=this,r=i==null||(e=i[n])==null?void 0:e.details;if(r){if(this.waitForCdnTuneIn(r))break;this.state=_.WAITING_INIT_PTS}break}case _.FRAG_LOADING_WAITING_RETRY:{var s;const i=performance.now(),n=this.retryDate;(!n||i>=n||(s=this.media)!=null&&s.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=_.IDLE);break}case _.WAITING_INIT_PTS:{const i=this.waitingData;if(i){const{frag:n,part:r,cache:o,complete:a}=i;if(this.initPTS[n.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=_.FRAG_LOADING;const l=o.flush(),c={frag:n,part:r,payload:l,networkDetails:null};this._handleFragmentLoadProgress(c),a&&super._handleFragmentLoadComplete(c)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${n.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const l=this.getLoadPosition(),c=Z.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);Zn(c.end,this.config.maxFragLookUpTolerance,n)<0&&(this.log(`Waiting fragment cc (${n.cc}) @ ${n.start} cancelled because another fragment at ${c.end} is needed`),this.clearWaitingFragment())}}else this.state=_.IDLE}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=_.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:e,levels:s,media:i,trackId:n}=this,r=e.config;if(!(s!=null&&s[n])||!i&&(this.startFragRequested||!r.startFragPrefetch))return;const o=s[n],a=o.details;if(!a||a.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(a)){this.state=_.WAITING_TRACK;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,j.AUDIO,$.AUDIO));const c=this.getFwdBufferInfo(l,$.AUDIO);if(c===null)return;const{bufferedTrack:d,switchingTrack:u}=this;if(!u&&this._streamEnded(c,a)){e.trigger(p.BUFFER_EOS,{type:"audio"}),this.state=_.ENDED;return}const h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,$.MAIN),f=c.len,g=this.getMaxBufferLength(h?.len);if(f>=g&&!u)return;const y=a.fragments[0].start;let S=c.end;if(u&&i){const I=this.getLoadPosition();d&&u.attrs!==d.attrs&&(S=I),a.PTSKnown&&I<y&&(c.end>
23y||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=y+.05)}let E=this.getNextFragment(S,a),T=!1;if(E&&this.isLoopLoading(E,S)&&(T=!!E.gap,E=this.getNextFragmentLoopLoading(E,a,c,$.MAIN,g)),!E){this.bufferFlushed=!0;return}const R=h&&E.start>h.end+a.targetduration;if(R||!(h!=null&&h.len)&&c.len){const I=this.getAppendedFrag(E.start,$.MAIN);if(I===null||(T||(T=!!I.gap||!!R&&h.len===0),R&&!T||T&&c.nextStart&&c.nextStart<I.end))return}this.loadFragment(E,o,S)}getMaxBufferLength(e){const s=super.getMaxBufferLength();return e?Math.min(Math.max(s,e),this.config.maxMaxBufferLength):s}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:s}){this.resetTransmuxer(),this.levels=s.map(i=>new ws(i))}onAudioTrackSwitching(e,s){const i=!!s.url;this.trackId=s.id;const{fragCurrent:n}=this;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?this.setInterval(tl):this.resetTransmuxer(),i?(this.switchingTrack=s,this.state=_.IDLE):(this.switchingTrack=null,this.bufferedTrack=s,this.state=_.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,s){this.mainDetails=s.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(p.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,s){var i;if(this.mainDetails==null){this.cachedTrackLoadedData=s;return}const{levels:n}=this,{details:r,id:o}=s;if(!n){this.warn(`Audio tracks were reset while loading level ${o}`);return}this.log(`Track ${o} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`);const a=n[o];let l=0;if(r.live||(i=a.details)!=null&&i.live){const c=this.mainDetails;if(r.fragments[0]||(r.deltaUpdateFailed=!0),r.deltaUpdateFailed||!c)return;!a.details&&r.hasProgramDateTime&&c.hasProgramDateTime?(bh(r,c),l=r.fragments[0].start):l=this.alignPlaylists(r,a.details)}a.details=r,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!r.live)&&this.setStartPosition(a.details,l),this.state===_.WAITING_TRACK&&!this.waitForCdnTuneIn(r)&&(this.state=_.IDLE),this.tick()}_handleFragmentLoadProgress(e){var s;const{frag:i,part:n,payload:r}
23=e,{config:o,trackId:a,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const c=l[a];if(!c){this.warn("Audio track is undefined on fragment load progress");return}const d=c.details;if(!d){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const u=o.defaultAudioCodec||c.audioCodec||"mp4a.40.2";let h=this.transmuxer;h||(h=this.transmuxer=new Fh(this.hls,$.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const f=this.initPTS[i.cc],g=(s=i.initSegment)==null?void 0:s.data;if(f!==void 0){const y=n?n.index:-1,S=y!==-1,E=new _o(i.level,i.sn,i.stats.chunkCount,r.byteLength,y,S);h.push(r,g,u,"",i,n,d.totalduration,!1,E,f)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${d.startSN} ,${d.endSN}],track ${a}`);const{cache:m}=this.waitingData=this.waitingData||{frag:i,part:n,cache:new Uh,complete:!1};m.push(new Uint8Array(r)),this.waitingVideoCC=this.videoTrackCC,this.state=_.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,s){const i=s.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),s.tracks.video&&(this.videoBuffer=s.tracks.video.buffer||null)}onFragBuffered(e,s){const{frag:i,part:n}=s;if(i.type!==$.AUDIO){if(!this.loadedmetadata&&i.type===$.MAIN){const r=this.videoBuffer||this.media;r&&Z.getBuffered(r).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(i.sn!=="initSegment"){this.fragPrevious=i;const r=this.switchingTrack;r&&(this.bufferedTrack=r,this.switchingTrack=null,this.hls.trigger(p.AUDIO_TRACK_SWITCHED,Re({},r)))}this.fragBufferedComplete(i,n)}onError(e,s){var i;if(s.fatal){this.state=_.ERROR;return}switch(s.details){case L.FRAG_GAP:case L.FRAG_PARSING_ERROR:case L.FRAG_DECRYPT_ERROR:case L.FRAG_LOAD_ERROR:case L.FRAG_LOAD_TIMEOUT:case L.KEY_LOAD_ERROR:case L.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError($.AUDIO,s);break;case L.AUDIO_TRACK_LOAD_ERROR:case L.AUDIO_TRACK_LOAD_TIMEOUT:case L.LEVEL_PARSING_ERROR:!s.levelRetry&&this.state===_.WAITING_TRACK&&((i=s.context)==null?void 0:i.type)===q.AUDIO_TRACK&&(this.state=_.IDLE);break;case L.BUFFER_FULL_ERROR:if(!s.parent||s.parent!=="audio")return;this.reduceLengthAndFlushBuffer(s)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case L.INTERNAL_EXCEPTION:this.recoverWorkerError(s);break}}onBufferFlushed(e,{type:s}){s===j.AUDIO&&(this.bufferFlushed=!0,this.state===_.ENDED&&(this.state=_.IDLE))}_handleTransmuxComplete(e){var s;const i="audio",{hls:n}=this,{remuxResult:r,chunkMeta:o}=e,a=this.getCurrentContext(o);if(!a){this.resetWhenMissingContext(o);return}const{frag:l,part:c,level:d}=a,{details:u}=d,{audio:h,text:f,id3:g,initSegment:m}=r;if(this.fragContextChanged(l)||!u){this.fragmentTracker.removeFragment(l);return}if(this.state=_.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),m!=null&&m.tracks){const y=l.initSegment||l;this._bufferInitSegment(m.tracks,y,o),n.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:y,id:i,tracks:m.tracks})}if(h){const{startPTS:y,endPTS:S,startDTS:E,endDTS:T}=h;c&&(c.elementaryStreams[j.AUDIO]={startPTS:y,endPTS:S,startDTS:E,endDTS:T}),l.setElementaryStreamInfo(j.AUDIO,y,S,E,T),this.bufferFragmentData(h,l,c,o)}if(g!=null&&(s=g.samples)!=null&&s.length){const y=de({id:i,frag:l,details:u},g);n.trigger(p.FRAG_PARSING_METADATA,y)}if(f){const y=de({id:i,frag:l,details:u},f);n.trigger(p.FRAG_PARSING_USERDATA,y)}}_bufferInitSegment(e,s,i){if(this.state!==_.PARSING)return;e.video&&delete e.video;const n=e.audio;if(!n)return;n.levelCodec=n.codec,n.id="audio",this.log(`Init audio buffer, container:${n.container}, codecs[parsed]=[${n.codec}]`),this.hls.trigger(p.BUFFER_CODECS,e);const r=n.initSegment;if(r!=null&&r.byteLength){const o={type:"audio",frag:s,part:null,chunkMeta:i,parent:s.type,data:r};this.hls.trigger(p.BUFFER_APPENDING,o)}this.tick()}loadFragment(e,s,i){const n=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||n===he.NOT_LOADED||n===he.PARTIAL){var r;e.sn==="initSegment"?this._loadInitSegment(e,s):(r=s.details)!=null&&r.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=_.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(e,s,i))}else this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){const{hls:s,media:i,bufferedTrack:n}=this,r=n?.attrs,o=e.attrs;
23i&&r&&(r.CHANNELS!==o.CHANNELS||r.NAME!==o.NAME||r.LANGUAGE!==o.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=e,this.switchingTrack=null,s.trigger(p.AUDIO_TRACK_SWITCHED,Re({},e))}}class DC extends Co{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(p.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(p.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,s){this.tracks=s.audioTracks||[]}onAudioTrackLoaded(e,s){const{id:i,groupId:n,details:r}=s,o=this.tracksInGroup[i];if(!o||o.groupId!==n){this.warn(`Track with id:${i} and group:${n} not found in active group ${o.groupId}`);return}const a=o.details;o.details=s.details,this.log(`audio-track ${i} "${o.name}" lang:${o.lang} group:${n} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,s,a)}onLevelLoading(e,s){this.switchLevel(s.level)}onLevelSwitching(e,s){this.switchLevel(s.level)}switchLevel(e){const s=this.hls.levels[e];if(!(s!=null&&s.audioGroupIds))return;const i=s.audioGroupIds[s.urlId];if(this.groupId!==i){this.groupId=i||null;const n=this.tracks.filter(o=>!i||o.groupId===i);this.selectDefaultTrack&&!n.some(o=>o.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=n;const r={audioTracks:n};this.log(`Updating audio tracks, ${n.length} track(s) found in group:${i}`),this.hls.trigger(p.AUDIO_TRACKS_UPDATED,r),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(e,s){s.fatal||!s.context||s.context.type===q.AUDIO_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(s))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioTrack(e){const s=this.tracksInGroup;if(e<0||e>=s.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();const i=this.currentTrack;s[this.trackId];const n=s[e],{groupId:r,name:o}=n;if(this.log(`Switching to audio-track ${e} "${o}" lang:${n.lang} group:${r}`),this.trackId=e,this.currentTrack=n,this.selectDefaultTrack=!1,this.hls.trigger(p.AUDIO_TRACK_SWITCHING,Re({},n)),n.details&&!n.details.live)return;const a=this.switchParams(n.url,i?.details);this.loadPlaylist(a)}selectInitialTrack(){const e=this.tracksInGroup,s=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(s!==-1)this.setAudioTrack(s);else{const i=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${e.length}`);this.warn(i.message),this.hls.trigger(p.ERROR,{type:B.MEDIA_ERROR,details:L.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}}findTrackId(e){const s=this.tracksInGroup;for(let i=0;i<s.length;i++){const n=s[i];if((!this.selectDefaultTrack||n.default)&&(!e||e.attrs["STABLE-RENDITION-ID"]!==void 0&&e.attrs["STABLE-RENDITION-ID"]===n.attrs["STABLE-RENDITION-ID"]||e.name===n.name&&e.lang===n.lang))return n.id}return-1}loadPlaylist(e){super.loadPlaylist();const s=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(s)){const i=s.id,n=s.groupId;let r=s.url;if(e)try{r=e.addDirectives(r)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}this.log(`loading audio-track playlist ${i} "${s.name}" lang:${s.lang} group:${n}`),this.clearTimer(),this.hls.trigger(p.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:n,deliveryDirectives:e||null})}}}function Bh(t,e){if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(!kC(t[s].attrs,e[s].attrs))return!1;return!0}function kC(t,e){const s=t["STABLE-RENDITION-ID"];return s?s===e["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(i=>t[i]!==e[i])}const sl=500;class PC extends ko{constructor(e,s,i){super(e,s,i,"[subtitle-stream-controller]",$.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){const{hls:e}=this;
23e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.ERROR,this.onError,this),e.on(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(p.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(p.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.ERROR,this.onError,this),e.off(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(p.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(p.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=_.IDLE,this.setInterval(sl),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,s){this.mainDetails=s.details}onSubtitleFragProcessed(e,s){const{frag:i,success:n}=s;if(this.fragPrevious=i,this.state=_.IDLE,!n)return;const r=this.tracksBuffered[this.currentTrackId];if(!r)return;let o;const a=i.start;for(let c=0;c<r.length;c++)if(a>=r[c].start&&a<=r[c].end){o=r[c];break}const l=i.start+i.duration;o?o.end=l:(o={start:a,end:l},r.push(o)),this.fragmentTracker.fragBuffered(i)}onBufferFlushing(e,s){const{startOffset:i,endOffset:n}=s;if(i===0&&n!==Number.POSITIVE_INFINITY){const r=n-1;if(r<=0)return;s.endOffsetSubtitles=Math.max(0,r),this.tracksBuffered.forEach(o=>{for(let a=0;a<o.length;){if(o[a].end<=r){o.shift();continue}else if(o[a].start<r)o[a].start=r;else break;a++}}),this.fragmentTracker.removeFragmentsInRange(i,r,$.SUBTITLE)}}onFragBuffered(e,s){if(!this.loadedmetadata&&s.frag.type===$.MAIN){var i;(i=this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)}}onError(e,s){const i=s.frag;i?.type===$.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==_.STOPPED&&(this.state=_.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:s}){if(Bh(this.levels,s)){this.levels=s.map(i=>new ws(i));return}this.tracksBuffered=[],this.levels=s.map(i=>{const n=new ws(i);return this.tracksBuffered[n.id]=[],n}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,$.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,s){if(this.currentTrackId=s.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}const i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(sl)}onSubtitleTrackLoaded(e,s){var i;const{details:n,id:r}=s,{currentTrackId:o,levels:a}=this;if(!a.length)return;const l=a[o];if(r>=a.length||r!==o||!l)return;this.mediaBuffer=this.mediaBufferTimeRanges;let c=0;if(n.live||(i=l.details)!=null&&i.live){const d=this.mainDetails;if(n.deltaUpdateFailed||!d)return;const u=d.fragments[0];l.details?(c=this.alignPlaylists(n,l.details),c===0&&u&&(c=u.start,Jn(n,c))):n.hasProgramDateTime&&d.hasProgramDateTime?(bh(n,d),c=n.fragments[0].start):u&&(c=u.start,Jn(n,c))}l.details=n,this.levelLastLoaded=r,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(l.details,c),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===_.IDLE&&(Ds(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0))}_handleFragmentLoadComplete(e){const{frag:s,payload:i}=e,n=s.decryptdata,r=this.hls;if(!this.fragContextChanged(s)&&i&&i.byteLength>0&&n&&n.key&&n.iv&&n.method==="AES-128"){const o=performance.now();
vendor: 4,346 bytes, line 23
23this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer).catch(a=>{throw r.trigger(p.ERROR,{type:B.MEDIA_ERROR,details:L.FRAG_DECRYPT_ERROR,fatal:!1,error:a,reason:a.message,frag:s}),a}).then(a=>{const l=performance.now();r.trigger(p.FRAG_DECRYPTED,{frag:s,payload:a,stats:{tstart:o,tdecrypt:l}})}).catch(a=>{this.warn(`${a.name}: ${a.message}`),this.state=_.IDLE})}}doTick(){if(!this.media){this.state=_.IDLE;return}if(this.state===_.IDLE){const{currentTrackId:e,levels:s}=this,i=s[e];if(!s.length||!i||!i.details)return;const{config:n}=this,r=this.getLoadPosition(),o=Z.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,n.maxBufferHole),{end:a,len:l}=o,c=this.getFwdBufferInfo(this.media,$.MAIN),d=i.details,u=this.getMaxBufferLength(c?.len)+d.levelTargetDuration;if(l>u)return;const h=d.fragments,f=h.length,g=d.edge;let m=null;const y=this.fragPrevious;if(a<g){const S=n.maxFragLookUpTolerance,E=a>g-S?0:S;m=Ds(y,h,Math.max(h[0].start,a),E),!m&&y&&y.start<h[0].start&&(m=h[0])}else m=h[f-1];if(!m)return;if(m=this.mapToInitFragWhenRequired(m),m.sn!=="initSegment"){const S=m.sn-d.startSN,E=h[S-1];E&&E.cc===m.cc&&this.fragmentTracker.getState(E)===he.NOT_LOADED&&(m=E)}this.fragmentTracker.getState(m)===he.NOT_LOADED&&this.loadFragment(m,i,a)}}getMaxBufferLength(e){const s=super.getMaxBufferLength();return e?Math.max(s,e):s}loadFragment(e,s,i){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,s):(this.startFragRequested=!0,super.loadFragment(e,s,i))}get mediaBufferTimeRanges(){return new OC(this.tracksBuffered[this.currentTrackId]||[])}}class OC{constructor(e){this.buffered=void 0;const s=(i,n,r)=>{if(n=n>>>0,n>r-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${r})`);return e[n][i]};this.buffered={get length(){return e.length},end(i){return s("end",i,e.length)},start(i){return s("start",i,e.length)}}}}class MC extends Co{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){const{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(p.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(p.ERROR,this.onError,this)}onMediaAttached(e,s){this.media=s.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.trackChangeListener,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),An(this.media.textTracks).forEac
23h(s=>{Yt(s)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,s){this.tracks=s.subtitleTracks}onSubtitleTrackLoaded(e,s){const{id:i,details:n}=s,{trackId:r}=this,o=this.tracksInGroup[r];if(!o){this.warn(`Invalid subtitle track id ${i}`);return}const a=o.details;o.details=s.details,this.log(`subtitle track ${i} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,s,a)}onLevelLoading(e,s){this.switchLevel(s.level)}onLevelSwitching(e,s){this.switchLevel(s.level)}switchLevel(e){const s=this.hls.levels[e];if(!(s!=null&&s.textGroupIds))return;const i=s.textGroupIds[s.urlId],n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){const r=this.tracks.filter(l=>!i||l.groupId===i);this.tracksInGroup=r;const o=this.findTrackId(n?.name)||this.findTrackId();this.groupId=i||null;const a={subtitleTracks:r};this.log(`Updating subtitle tracks, ${r.length} track(s) found in "${i}" group-id`),this.hls.trigger(p.SUBTITLE_TRACKS_UPDATED,a),o!==-1&&this.setSubtitleTrack(o,n)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId,n)}findTrackId(e){const s=this.tracksInGroup;for(let i=0;i<s.length;i++){const n=s[i];if((!this.selectDefaultTrack||n.default)&&(!e||e===n.name))return n.id}return-1}onError(e,s){s.fatal||!s.context||s.context.type===q.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.checkRetry(s)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1;const s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,s)}loadPlaylist(e){super.loadPlaylist();const s=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(s)){const i=s.id,n=s.groupId;let r=s.url;if(e)try{r=e.addDirectives(r)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}this.log(`Loading subtitle playlist for id ${i}`),this.hls.trigger(p.SUBTITLE_TRACK_LOADING,{url:r,id:i,groupId:n,deliveryDirectives:e||null})}}toggleTrackModes(e){const{media:s,trackId:i}=this;if(!s)return;const n=An(s.textTracks),r=n.filter(a=>a.groupId===this.groupId);if(e===-1)[].slice.call(n).forEach(a=>{a.mode="disabled"});else{const a=r[i];a&&(a.mode="disabled")}const o=r[e];o&&(o.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(e,s){var i;const n=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(e===-1||(i=n[e])!=null&&i.details)||e<-1||e>=n.length)return;this.clearTimer();const r=n[e];if(this.log(`Switching to subtitle-track ${e}`+(r?` "${r.name}" lang:${r.lang} group:${r.groupId}`:"")),this.trackId=e,r){const{id:o,groupId:a="",name:l,type:c,url:d}=r;this.hls.trigger(p.SUBTITLE_TRACK_SWITCH,{id:o,groupId:a,name:l,type:c,url:d});const u=this.switchParams(r.url,s?.details);this.loadPlaylist(u)}else this.hls.trigger(p.SUBTITLE_TRACK_SWITCH,{id:e})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=-1;const s=An(this.media.textTracks);for(let i=0;i<s.length;i++)if(s[i].mode==="hidden")e=i;else if(s[i].mode==="showing"){e=i;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}}function An(t){const e=[];for(let s=0;s<t.length;s++){const i=t[s];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&e.push(t[s])}return e}class NC{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,s){const i=this.queues[s];i.push(e),i.length===1&&this.buffers[s]&&this.executeNext(s)}insertAbort(e,s){this.queues[s].unshift(e),this.executeNext(s)}appendBlocker(e){let s;const i=new Promise(r=>{s=r}),n={execute:s,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(n,e),i}executeNext(e){const{buffers:s,queues:i}=this,n=s[e],r=i[e];if(r.length){const o=r[0];try{o.execute()}catch(a){v.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),o.onError(a),n!=null&&n.updating||(r.shift(),this.executeNext(e))}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const il=Ji(),nl=/([ha]vc.)(?:\.[^.,]+)+/;class FC{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.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{const{media:s,mediaSource:i}=this;v.log("[buffer-controller]: Media source opened"),s&&(s.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(p.MEDIA_ATTA
23CHED,{media:s})),i&&i.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{v.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{v.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:s,_objectUrl:i}=this;s&&s.src!==i&&v.error(`Media element src was set while attaching MediaSource (${i} > ${s.src})`)},this.hls=e,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}registerListeners(){const{hls:e}=this;e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.BUFFER_RESET,this.onBufferReset,this),e.on(p.BUFFER_APPENDING,this.onBufferAppending,this),e.on(p.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.BUFFER_EOS,this.onBufferEos,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.FRAG_PARSED,this.onFragParsed,this),e.on(p.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.BUFFER_RESET,this.onBufferReset,this),e.off(p.BUFFER_APPENDING,this.onBufferAppending,this),e.off(p.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.BUFFER_EOS,this.onBufferEos,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.FRAG_PARSED,this.onFragParsed,this),e.off(p.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new NC(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,s){let i=2;(s.audio&&!s.video||!s.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,v.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,s){const i=this.media=s.media;if(i&&il){const n=this.mediaSource=new il;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(n),this._objectUrl=i.src,i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:e,mediaSource:s,_objectUrl:i}=this;if(s){if(v.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(n){v.warn(`[buffer-controller]: onMediaDetaching: ${n.message} while calling endOfStream`)}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),i&&self.URL.revokeObjectURL(i),e.src===i?(e.removeAttribute("src"),e.load()):v.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(p.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{const s=this.sourceBuffer[e];try{s&&(this.removeBufferListeners(e),this.mediaSource&&this.mediaSource.removeSourceBuffer(s),this.sourceBuffer[e]=void 0)}catch(i){v.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,i)}}),this._initSourceBuffer()}onBufferCodecs(e,s){const i=this.getSourceBufferTypes().length;Object.keys(s).forEach(n=>{if(i){const r=this.tracks[n];if(r&&typeof r.buffer.changeType=="function"){const{id:o,codec:a,levelCodec:l,container:c,metadata:d}=s[n],u=(r.levelCodec||r.codec).replace(nl,"$1"),h=(l||a).replace(nl,"$1");if(u!==h){const f=`${c};codecs=${l||a}`;this.appendChangeType(n,f),v.log(`[buffer-controller]: switching codec ${u} to ${h}`),this.tracks[n]={buffer:r.buffer,codec:a,container:c,levelCodec:l,metadata:d,id:o}}}}else this.pendingTracks[n]=s[n]}),!i&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(e,s){const{operationQueue:i}=this,n={execute:()=>{const r=this.sourceBuffer[e];r&&(v.log(`[buffer-controller]: changing ${e} sourceBuffer type to ${s}`),r.changeType(s)),i.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:r=>{v.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,r)}};i.append(n,e)}onBufferAppending(e,s){const{hls:i,operationQueue:n,tracks:r}=this,{data:o,type:a,frag:l,part:c,chunkMeta:d}=s,u=d.buffering[a],h=self.performance.now();u.start=h;const f=l.stats.buffering,g=c?c.stats.buffering:null;f.start===0&&(f.start=h),g&&g.start===0&&(g.start=h);const m=r.audio;let y=!1;a==="audio"&&m?.container==="audio/mpeg"&&(y=!this.lastMpegAudioChunk||d.id===1||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);const S=l.start,E={execute:()=>{if(u.executeStart=self.performance.now(),y){const T=this.sourceBuffer[a];if(T){const R=S-T.timestampOffset;Math.abs(R)>=.1&&(v.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${S} (delta: ${R}) sn: ${l.sn}
23)`),T.timestampOffset=S)}}this.appendExecutor(o,a)},onStart:()=>{},onComplete:()=>{const T=self.performance.now();u.executeEnd=u.end=T,f.first===0&&(f.first=T),g&&g.first===0&&(g.first=T);const{sourceBuffer:R}=this,I={};for(const k in R)I[k]=Z.getBuffered(R[k]);this.appendError=0,this.hls.trigger(p.BUFFER_APPENDED,{type:a,frag:l,part:c,chunkMeta:d,parent:l.type,timeRanges:I})},onError:T=>{v.error(`[buffer-controller]: Error encountered while trying to append to the ${a} SourceBuffer`,T);const R={type:B.MEDIA_ERROR,parent:l.type,details:L.BUFFER_APPEND_ERROR,frag:l,part:c,chunkMeta:d,error:T,err:T,fatal:!1};T.code===DOMException.QUOTA_EXCEEDED_ERR?R.details=L.BUFFER_FULL_ERROR:(this.appendError++,R.details=L.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(v.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),R.fatal=!0)),i.trigger(p.ERROR,R)}};n.append(E,a)}onBufferFlushing(e,s){const{operationQueue:i}=this,n=r=>({execute:this.removeExecutor.bind(this,r,s.startOffset,s.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(p.BUFFER_FLUSHED,{type:r})},onError:o=>{v.warn(`[buffer-controller]: Failed to remove from ${r} SourceBuffer`,o)}});s.type?i.append(n(s.type),s.type):this.getSourceBufferTypes().forEach(r=>{i.append(n(r),r)})}onFragParsed(e,s){const{frag:i,part:n}=s,r=[],o=n?n.elementaryStreams:i.elementaryStreams;o[j.AUDIOVIDEO]?r.push("audiovideo"):(o[j.AUDIO]&&r.push("audio"),o[j.VIDEO]&&r.push("video"));const a=()=>{const l=self.performance.now();i.stats.buffering.end=l,n&&(n.stats.buffering.end=l);const c=n?n.stats:i.stats;this.hls.trigger(p.FRAG_BUFFERED,{frag:i,part:n,stats:c,id:i.type})};r.length===0&&v.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(a,r)}onFragChanged(e,s){this.flushBackBuffer()}onBufferEos(e,s){this.getSourceBufferTypes().reduce((n,r)=>{const o=this.sourceBuffer[r];return o&&(!s.type||s.type===r)&&(o.ending=!0,o.ended||(o.ended=!0,v.log(`[buffer-controller]: ${r} sourceBuffer now EOS`))),n&&!!(!o||o.ended)},!0)&&(v.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(r=>{const o=this.sourceBuffer[r];o&&(o.ending=!1)});const{mediaSource:n}=this;if(!n||n.readyState!=="open"){n&&v.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${n.readyState}`);return}v.log("[buffer-controller]: Calling mediaSource.endOfStream()"),n.endOfStream()}))}onLevelUpdated(e,{details:s}){s.fragments.length&&(this.details=s,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:e,details:s,media:i,sourceBuffer:n}=this;if(!i||s===null)return;const r=this.getSourceBufferTypes();if(!r.length)return;const o=s.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!N(o)||o<0)return;const a=i.currentTime,l=s.levelTargetDuration,c=Math.max(o,l),d=Math.floor(a/l)*l-c;r.forEach(u=>{const h=n[u];if(h){const f=Z.getBuffered(h);if(f.length>0&&d>f.start(0)){if(e.trigger(p.BACK_BUFFER_REACHED,{bufferEnd:d}),s.live)e.trigger(p.LIVE_BACK_BUFFER_REACHED,{bufferEnd:d});else if(h.ended&&f.end(f.length-1)-a<l*2){v.info(`[buffer-controller]: Cannot flush ${u} back buffer while SourceBuffer is in ended state`);return}e.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:d,type:u})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:e,hls:s,media:i,mediaSource:n}=this,r=e.fragments[0].start+e.totalduration,o=i.duration,a=N(n.duration)?n.duration:0;e.live&&s.config.liveDurationInfinity?(v.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(r>a&&r>o||!N(o))&&(v.log(`[buffer-controller]: Updating Media Source duration to ${r.toFixed(3)}`),n.duration=r)}updateSeekableRange(e){const s=this.mediaSource,i=e.fragments;if(i.length&&e.live&&s!=null&&s.setLiveSeekableRange){const r=Math.max(0,i[0].start),o=Math.max(r,r+e.totalduration);
23s.setLiveSeekableRange(r,o)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:s,pendingTracks:i}=this,n=Object.keys(i).length;if(n&&!e||n===2){this.createSourceBuffers(i),this.pendingTracks={};const r=this.getSourceBufferTypes();if(r.length)this.hls.trigger(p.BUFFER_CREATED,{tracks:this.tracks}),r.forEach(o=>{s.executeNext(o)});else{const o=new Error("could not create source buffer for media codec(s)");this.hls.trigger(p.ERROR,{type:B.MEDIA_ERROR,details:L.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:o,reason:o.message})}}}createSourceBuffers(e){const{sourceBuffer:s,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(const n in e)if(!s[n]){const r=e[n];if(!r)throw Error(`source buffer exists for track ${n}, however track does not`);const o=r.levelCodec||r.codec,a=`${r.container};codecs=${o}`;v.log(`[buffer-controller]: creating sourceBuffer(${a})`);try{const l=s[n]=i.addSourceBuffer(a),c=n;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[n]={buffer:l,codec:o,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id}}catch(l){v.error(`[buffer-controller]: error while trying to add sourceBuffer: ${l.message}`),this.hls.trigger(p.ERROR,{type:B.MEDIA_ERROR,details:L.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,mimeType:a})}}}_onSBUpdateStart(e){const{operationQueue:s}=this;s.current(e).onStart()}_onSBUpdateEnd(e){const{operationQueue:s}=this;s.current(e).onComplete(),s.shiftAndExecuteNext(e)}_onSBUpdateError(e,s){const i=new Error(`${e} SourceBuffer error`);v.error(`[buffer-controller]: ${i}`,s),this.hls.trigger(p.ERROR,{type:B.MEDIA_ERROR,details:L.BUFFER_APPENDING_ERROR,error:i,fatal:!1});const n=this.operationQueue.current(e);n&&n.onError(s)}removeExecutor(e,s,i){const{media:n,mediaSource:r,operationQueue:o,sourceBuffer:a}=this,l=a[e];if(!n||!r||!l){v.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),o.shiftAndExecuteNext(e);return}const c=N(n.duration)?n.duration:1/0,d=N(r.duration)?r.duration:1/0,u=Math.max(0,s),h=Math.min(i,c,d);h>u&&!l.ending?(l.ended=!1,v.log(`[buffer-controller]: Removing [${u},${h}] from the ${e} SourceBuffer`),l.remove(u,h)):o.shiftAndExecuteNext(e)}appendExecutor(e,s){const{operationQueue:i,sourceBuffer:n}=this,r=n[s];if(!r){v.warn(`[buffer-controller]: Attempting to append to the ${s} SourceBuffer, but it does not exist`),i.shiftAndExecuteNext(s);return}r.ended=!1,r.appendBuffer(e)}blockBuffers(e,s=this.getSourceBufferTypes()){if(!s.length){v.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}const{operationQueue:i}=this,n=s.map(r=>i.appendBlocker(r));Promise.all(n).then(()=>{e(),s.forEach(r=>{const o=this.sourceBuffer[r];o!=null&&o.updating||i.shiftAndExecuteNext(r)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,s,i){const n=this.sourceBuffer[e];if(!n)return;const r=i.bind(this,e);this.listeners[e].push({event:s,listener:r}),n.addEventListener(s,r)}removeBufferListeners(e){const s=this.sourceBuffer[e];s&&this.listeners[e].forEach(i=>{s.removeEventListener(i.event,i.listener)})}}const rl={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},$h=function(e){let s=e;return rl.hasOwnProperty(e)&&(s=rl[e]),String.fromCharCode(s)},He=15,st=100,UC={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},BC={17:2,18:4,21:6,22:8,23:10,19:13,20:15},$C={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},VC={25:2,26:4,29:6,30:8,31:10,27:13,28:15},GC=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class HC{constructor(){this.time=null,this.verboseLevel=0}log(e,s){if(this.verboseLevel>=e){const i=typeof s=="function"?s():s;v.log(`${this.time} [${e}] ${i}`)}}}const It=function(e){const s=[];for(let i=0;i<e.length;i++)s.push(e[i].toString(16));return s};class Vh{constructor(e,s,i,n,r){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=s||!1,this.italics=i||!1,this.background=n||"black",this.flash=r||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const s=["foreground","underline","italics","background","flash"];for(let i=0;i<s.length;i++){const n=s[i];e.hasOwnProperty(n)&&(this[n]=e[n])}}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 KC{constructor(e,s,i,n,r,o){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new Vh(s,i,n,r,o)}reset(){this.uchar=" ",this.penState.reset()}setChar(e,s){this.uchar=e,this.penState.copy(s)}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 WC{constructor(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let s=0;s<st;s++)this.chars.push(new KC);this.logger=e,this.pos=0,this.currPenState=new Vh}equals(e){let s=!0;for(let i=0;i<st;i++)if(!this.chars[i].equals(e.chars[i])){s=!1;break}return s}copy(e){for(let s=0;s<st;s++)this.chars[s].copy(e.chars[s])}isEmpty(){let e=!0;for(let s=0;s<st;s++)if(!this.chars[s].isEmpty()){e=!1;break}return e}
vendor: 5,798 bytes, lines 23-24
23setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>st&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=st)}moveCursor(e){const s=this.pos+e;if(e>1)for(let i=this.pos+1;i<s+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(s)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const s=$h(e);if(this.pos>=st){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+s+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(s,this.currPenState),this.moveCursor(1)}clearFromPos(e){let s;for(s=e;s<st;s++)this.chars[s].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let s=!0;for(let i=0;i<st;i++){const n=this.chars[i].uchar;n!==" "&&(s=!1),e.push(n)}return s?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class In{constructor(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let s=0;s<He;s++)this.rows.push(new WC(e));this.logger=e,this.currRow=He-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let e=0;e<He;e++)this.rows[e].clear();this.currRow=He-1}equals(e){let s=!0;for(let i=0;i<He;i++)if(!this.rows[i].equals(e.rows[i])){s=!1;break}return s}copy(e){for(let s=0;s<He;s++)this.rows[s].copy(e.rows[s])}isEmpty(){let e=!0;for(let s=0;s<He;s++)if(!this.rows[s].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 s=e.row-1;if(this.nrRollUpRows&&s<this.nrRollUpRows-1&&(s=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==s){for(let a=0;a<He;a++)this.rows[a].clear();const r=this.currRow+1-this.nrRollUpRows,o=this.lastOutputScreen;if(o){const a=o.rows[r].cueStartTime,l=this.logger.time;if(a&&l!==null&&a<l)for(let c=0;c<this.nrRollUpRows;c++)this.rows[s-this.nrRollUpRows+c+1].copy(o.rows[r+c])}}this.currRow=s;const i=this.rows[this.currRow];if(e.indent!==null){const r=e.indent,o=Math.max(r-1,0);i.setCursor(e.indent),e.color=i.chars[o].penState.foreground}const n={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(n)}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,s=this.rows.splice(e,1)[0];s.clear(),this.rows.splice(this.currRow,0,s),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const s=[];let i="",n=-1;for(let r=0;r<He;r++){const o=this.rows[r].getTextString();o&&(n=r+1,e?s.push("Row "+n+": '"+o+"'"):s.push(o.trim()))}return s.length>0&&(e?i="["+s.join(" | ")+"]":i=s.join(` 24`)),i}getTextAndFormat(){return this.rows}}class ol{constructor(e,s,i){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=s,this.mode=null,this.verbose=0,this.displayedMemory=new In(i),this.nonDisplayedMemory=new In(i),this.lastOutputScreen=new In(i),this.currRollUpRow=this.displayedMemory.rows[He-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[He-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 i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);const s=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>s+": "+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})}
24ccRDC(){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 s={flash:!1};if(s.underline=e%2===1,s.italics=e>=46,s.italics)s.foreground="white";else{const i=Math.floor(e/2)-16,n=["white","green","blue","cyan","red","yellow","magenta"];s.foreground=n[i]}this.logger.log(2,"MIDROW: "+JSON.stringify(s)),this.writeScreen.setPen(s)}outputDataUpdate(e=!1){const s=this.logger.time;s!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=s:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,s,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:s),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 al{constructor(e,s,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const n=new HC;this.channels=[null,new ol(e,s,n),new ol(e+1,i,n)],this.cmdHistory=cl(),this.logger=n}getHandler(e){return this.channels[e].getHandler()}setHandler(e,s){this.channels[e].setHandler(s)}addData(e,s){let i,n,r,o=!1;this.logger.time=e;for(let a=0;a<s.length;a+=2)if(n=s[a]&127,r=s[a+1]&127,!(n===0&&r===0)){if(this.logger.log(3,"["+It([s[a],s[a+1]])+"] -> ("+It([n,r])+")"),i=this.parseCmd(n,r),i||(i=this.parseMidrow(n,r)),i||(i=this.parsePAC(n,r)),i||(i=this.parseBackgroundAttributes(n,r)),!i&&(o=this.parseChars(n,r),o)){const l=this.currentChannel;l&&l>0?this.channels[l].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!i&&!o&&this.logger.log(2,"Couldn't parse cleaned data "+It([n,r])+" orig: "+It([s[a],s[a+1]]))}}parseCmd(e,s){const{cmdHistory:i}=this,n=(e===20||e===28||e===21||e===29)&&s>=32&&s<=47,r=(e===23||e===31)&&s>=33&&s<=35;if(!(n||r))return!1;if(ll(e,s,i))return Wt(null,null,i),this.logger.log(3,"Repeated command ("+It([e,s])+") is dropped"),!0;const o=e===20||e===21||e===23?1:2,a=this.channels[o];return e===20||e===21||e===28||e===29?s===32?a.ccRCL():s===33?a.ccBS():s===34?a.ccAOF():s===35?a.ccAON():s===36?a.ccDER():s===37?a.ccRU(2):s===38?a.ccRU(3):s===39?a.ccRU(4):s===40?a.ccFON():s===41?a.ccRDC():s===42?a.ccTR():s===43?a.ccRTD():s===44?a.ccEDM():s===45?a.ccCR():s===46?a.ccENM():s===47&&a.ccEOC():a.ccTO(s-32),Wt(e,s,i),this.currentChannel=o,!0}parseMidrow(e,s){let i=0;if((e===17||e===25)&&s>=32&&s<=47){if(e===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const n=this.channels[i];return n?(n.ccMIDROW(s),this.logger.log(3,"MIDROW ("+It([e,s])+")"),!0):!1}return!1}parsePAC(e,s){let i;const n=this.cmdHistory,r=(e>=17&&e<=23||e>=25&&e<=31)&&s>=64&&s<=127,o=(e===16||e===24)&&s>=64&&s<=95;if(!(r||o))return!1;if(ll(e,s,n))return Wt(null,null,n),!0;const a=e<=23?1:2;s>=64&&s<=95?i=a===1?UC[e]:$C[e]:i=a===1?BC[e]:VC[e];const l=this.channels[a];return l?(l.setPAC(this.interpretPAC(i,s)),Wt(e,s,n),this.currentChannel=a,!0):!1}interpretPAC(e,s){let i;const n={color:null,italics:!1,indent:null,underline:!1,row:e};return s>95?i=s-96:i=s-64,n.underline=(i&1)===1,i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=Math.floor((i-16)/2)*4,n}parseChars(e,s){let i,n=null,r=null;if(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19){let o;r===17?o=s+80:r===18?o=s+112:o=s+144,this.logger.log(2,"Special char '"+$h(o)+"' in channel "+i),n=[o]}else e>=32&&e<=127&&(n=s===0?[e]:[e,s]);if(n){const o=It(n);this.logger.log(3,"Char codes = "+o.join(",")),Wt(e,s,this.cmdHistory)}return n}
vendor: 17,712 bytes, lines 24-34
24parseBackgroundAttributes(e,s){const i=(e===16||e===24)&&s>=32&&s<=47,n=(e===23||e===31)&&s>=45&&s<=47;if(!(i||n))return!1;let r;const o={};e===16||e===24?(r=Math.floor((s-32)/2),o.background=GC[r],s%2===1&&(o.background=o.background+"_semi")):s===45?o.background="transparent":(o.foreground="black",s===47&&(o.underline=!0));const a=e<=23?1:2;return this.channels[a].setBkgData(o),Wt(e,s,this.cmdHistory),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const s=this.channels[e];s&&s.reset()}this.cmdHistory=cl()}cueSplitAtTime(e){for(let s=0;s<this.channels.length;s++){const i=this.channels[s];i&&i.cueSplitAtTime(e)}}}function Wt(t,e,s){s.a=t,s.b=e}function ll(t,e,s){return s.a===t&&s.b===e}function cl(){return{a:null,b:null}}class Zs{constructor(e,s){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=s}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,s,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=s,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var Fo=(function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;const t=["","lr","rl"],e=["start","middle","end","left","right"];function s(a,l){if(typeof l!="string"||!Array.isArray(a))return!1;const c=l.toLowerCase();return~a.indexOf(c)?c:!1}function i(a){return s(t,a)}function n(a){return s(e,a)}function r(a,...l){let c=1;for(;c<arguments.length;c++){const d=arguments[c];for(const u in d)a[u]=d[u]}return a}function o(a,l,c){const d=this,u={enumerable:!0};d.hasBeenReset=!1;let h="",f=!1,g=a,m=l,y=c,S=null,E="",T=!0,R="auto",I="start",k=50,w="middle",D=50,P="middle";Object.defineProperty(d,"id",r({},u,{get:function(){return h},set:function(C){h=""+C}})),Object.defineProperty(d,"pauseOnExit",r({},u,{get:function(){return f},set:function(C){f=!!C}})),Object.defineProperty(d,"startTime",r({},u,{get:function(){return g},set:function(C){if(typeof C!="number")throw new TypeError("Start time must be set to a number.");g=C,this.hasBeenReset=!0}})),Object.defineProperty(d,"endTime",r({},u,{get:function(){return m},set:function(C){if(typeof C!="number")throw new TypeError("End time must be set to a number.");m=C,this.hasBeenReset=!0}})),Object.defineProperty(d,"text",r({},u,{get:function(){return y},set:function(C){y=""+C,this.hasBeenReset=!0}})),Object.defineProperty(d,"region",r({},u,{get:function(){return S},set:function(C){S=C,this.hasBeenReset=!0}})),Object.defineProperty(d,"vertical",r({},u,{get:function(){return E},set:function(C){const F=i(C);if(F===!1)throw new SyntaxError("An invalid or illegal string was specified.");E=F,this.hasBeenReset=!0}})),Object.defineProperty(d,"snapToLines",r({},u,{get:function(){return T},set:function(C){T=!!C,this.hasBeenReset=!0}})),Object.defineProperty(d,"line",r({},u,{get:function(){return R},set:function(C){if(typeof C!="number"&&C!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");R=C,this.hasBeenReset=!0}})),Object.defineProperty(d,"lineAlign",r({},u,{get:function(){return I},set:function(C){const F=n(C);if(!F)throw new SyntaxError("An invalid or illegal string was specified.");I=F,this.hasBeenReset=!0}})),Object.defineProperty(d,"position",r({},u,{get:function(){return k},set:function(C){if(C<0||C>100)throw new Error("Position must be between 0 and 100.");k=C,this.hasBeenReset=!0}})),Object.defineProperty(d,"positionAlign",r({},u,{get:function(){return w},set:function(C){const F=n(C);if(!F)throw new SyntaxError("An invalid or illegal string was specified.");w=F,this.hasBeenReset=!0}})),Object.defineProperty(d,"size",r({},u,{get:function(){return D},set:function(C){if(C<0||C>100)throw new Error("Size must be between 0 and 100.");D=C,this.hasBeenReset=!0}})),Object.defineProperty(d,"align",r({},u,{get:function(){return P},set:function(C){const F=n(C);if(!F)throw new SyntaxError("An invalid or illegal string was specified.");P=F,this.hasBeenReset=!0}})),d.displayState=void 0}return o.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},o})();class qC{decode(e,s){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function Gh(t){function e(i,n,r,o){return(i|0)*3600+(n|0)*60+(r|0)+parseFloat(o||0)}const s=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return s?parseFloat(s[2])>59?e(s[2],s[3],0,s[4]):e(s[1],s[2],s[3],s[4]):null}class YC{constructor(){this.values=Object.create(null)}set(e,s){!this.get(e)&&s!==""&&(this.values[e]=s)}get(e,s,i){return i?this.has(e)?this.values[e]:s[i]:this.has(e)?this.values[e]:s}has(e){return e in this.values}alt(e,s,i){for(let n=0;n<i.length;++n)if(s===i[n]){this.set(e,s);break}}integer(e,s){/^-?\d+$/.test(s)&&this.set(e,parseInt(s,10))}percent(e,s){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(s)){const i=parseFloat(s);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}function Hh(t,e,s,i){const n=i?t.split(i):[t];for(const r in n){if(typeof n[r]!="string")continue;const o=n[r].split(s);if(o.length!==2)continue;const a=o[0],l=o[1];e(a,l)}}const tr=new Fo(0,0,""),ei=tr.align==="middle"?"middle":"center";function jC(t,e,s){const i=t;function n(){const a=Gh(t);if(a===null)throw new Error("Malformed timestamp: "+i);return t=t.replace(/^[^\sa-zA-Z-]+/,""),a}function r(a,l){const c=new YC;Hh(a,function(h,f){let g;switch(h){case"region":for(let m=s.length-1;m>=0;m--)if(s[m].id===f){c.set(h,s[m].region);break}break;case"vertical":c.alt(h,f,["rl","lr"]);break;case"line":g=f.split(","),c.integer(h,g[0]),c.percent(h,g[0])&&c.set("snapToLines",!1),c.alt(h,g[0],["auto"]),g.length===2&&c.alt("lineAlign",g[1],["start",ei,"end"]);break;case"position":g=f.split(","),c.percent(h,g[0]),g.length===2&&c.alt("positionAlign",g[1],["start",ei,"end","line-left","line-right","auto"]);break;case"size":c.percent(h,f);break;case"align":c.alt(h,f,["start",ei,"end","left","right"]);break}},/:/,/\s/),l.region=c.get("region",null),l.vertical=c.get("vertical","");let d=c.get("line","auto");d==="auto"&&tr.line===-1&&(d=-1),l.line=d,l.lineAlign=c.get("lineAlign","start"),l.snapToLines=c.get("snapToLines",!0),l.size=c.get("size",100),l.align=c.get("align",ei);let u=c.get("position","auto");u==="auto"&&tr.position===50&&(u=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=u}function o(){t=t.replace(/^\s+/,"")}if(o(),e.startTime=n(),o(),t.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);t=t.slice(3),o(),e.endTime=n(),o(),r(t,e)}function Kh(t){return t.replace(/<br(?: \/)?>/gi,` 25`)}class zC{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new qC,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const s=this;e&&(s.buffer+=s.decoder.decode(e,{stream:!0}));function i(){let r=s.buffer,o=0;for(r=Kh(r);o<r.length&&r[o]!=="\r"&&r[o]!==` 26`;)++o;const a=r.slice(0,o);return r[o]==="\r"&&++o,r[o]===` 27`&&++o,s.buffer=r.slice(o),a}function n(r){Hh(r,function(o,a){},/:/)}try{let r="";if(s.state==="INITIAL"){if(!/\r\n|\n/.test(s.buffer))return this;r=i();const a=r.match(/^()?WEBVTT([ \t].*)?$/);if(!(a!=null&&a[0]))throw new Error("Malformed WebVTT signature.");s.state="HEADER"}let o=!1;for(;s.buffer;){if(!/\r\n|\n/.test(s.buffer))return this;switch(o?o=!1:r=i(),s.state){case"HEADER":/:/.test(r)?n(r):r||(s.state="ID");continue;case"NOTE":r||(s.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(r)){s.state="NOTE";break}if(!r)continue;if(s.cue=new Fo(0,0,""),s.state="CUE",r.indexOf("-->")===-1){s.cue.id=r;continue}case"CUE":if(!s.cue){s.state="BADCUE";continue}try{jC(r,s.cue,s.regionList)}catch{s.cue=null,s.state="BADCUE";continue}s.state="CUETEXT";continue;case"CUETEXT":{const a=r.indexOf("-->")!==-1;if(!r||a&&(o=!0)){s.oncue&&s.cue&&s.oncue(s.cue),s.cue=null,s.state="ID";continue}if(s.cue===null)continue;s.cue.text&&(s.cue.text+=` 28`),s.cue.text+=r}continue;case"BADCUE":r||(s.state="ID")}}}catch{s.state==="CUETEXT"&&s.cue&&s.oncue&&s.oncue(s.cue),s.cue=null,s.state=s.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=` 29 30`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(s){e.onparsingerror&&e.onparsingerror(s)}return e.onflush&&e.onflush(),this}}const XC=/\r\n|\n\r|\n|\r/g,Ln=function(e,s,i=0){return e.slice(i,i+s.length)===s},QC=function(e){let s=parseInt(e.slice(-3));const i=parseInt(e.slice(-6,-4)),n=parseInt(e.slice(-9,-7)),r=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!N(s)||!N(i)||!N(n)||!N(r))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return s+=1e3*i,s+=60*1e3*n,s+=3600*1e3*r,s},Rn=function(e){let s=5381,i=e.length;for(;i;)s=s*33^e.charCodeAt(--i);return(s>>>0).toString()};function Uo(t,e,s){return Rn(t.toString())+Rn(e.toString())+Rn(s)}const JC=function(e,s,i){let n=e[s],r=e[n.prevCC];if(!r||!r.new&&n.new){e.ccOffset=e.presentationOffset=n.start,n.new=!1;return}for(;(o=r)!=null&&o.new;){var o;e.ccOffset+=n.start-r.start,n.new=!1,n=r,r=e[n.prevCC]}e.presentationOffset=i};function ZC(t,e,s,i,n,r,o){const a=new zC,l=Qe(new Uint8Array(t)).trim().replace(XC,` 31`).split(` 32`),c=[],d=e?dC(e.baseTime,e.timescale):0;let u="00:00.000",h=0,f=0,g,m=!0;a.oncue=function(y){const S=s[i];let E=s.ccOffset;const T=(h-d)/9e4;if(S!=null&&S.new&&(f!==void 0?E=s.ccOffset=S.start:JC(s,i,T)),T){if(!e){g=new Error("Missing initPTS for VTT MPEGTS");return}E=T-s.presentationOffset}const R=y.endTime-y.startTime,I=Ue((y.startTime+E-f)*9e4,n*9e4)/9e4;y.startTime=Math.max(I,0),y.endTime=Math.max(I+R,0);const k=y.text.trim();y.text=decodeURIComponent(encodeURIComponent(k)),y.id||(y.id=Uo(y.startTime,y.endTime,k)),y.endTime>0&&c.push(y)},a.onparsingerror=function(y){g=y},a.onflush=function(){if(g){o(g);return}r(c)},l.forEach(y=>{if(m)if(Ln(y,"X-TIMESTAMP-MAP=")){m=!1,y.slice(16).split(",").forEach(S=>{Ln(S,"LOCAL:")?u=S.slice(6):Ln(S,"MPEGTS:")&&(h=parseInt(S.slice(7)))});try{f=QC(u)/1e3}catch(S){g=S}return}else y===""&&(m=!1);a.parse(y+` 33`)}),a.flush()}const Cn="stpp.ttml.im1t",Wh=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,qh=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,e_={left:"start",center:"center",right:"end",start:"start",end:"end"};function dl(t,e,s,i){const n=K(new Uint8Array(t),["mdat"]);if(n.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const r=n.map(a=>Qe(a)),o=cC(e.baseTime,1,e.timescale);try{r.forEach(a=>s(t_(a,o)))}catch(a){i(a)}}function t_(t,e){const n=new DOMParser().parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},o=Object.keys(r).reduce((u,h)=>(u[h]=n.getAttribute(`ttp:${h}`)||r[h],u),{}),a=n.getAttribute("xml:space")!=="preserve",l=ul(_n(n,"styling","style")),c=ul(_n(n,"layout","region")),d=_n(n,"body","[begin]");return[].map.call(d,u=>{const h=Yh(u,a);if(!h||!u.hasAttribute("begin"))return null;const f=Dn(u.getAttribute("begin"),o),g=Dn(u.getAttribute("dur"),o);let m=Dn(u.getAttribute("end"),o);if(f===null)throw hl(u);if(m===null){if(g===null)throw hl(u);m=f+g}const y=new Fo(f-e,m-e,h);y.id=Uo(y.startTime,y.endTime,y.text);const S=c[u.getAttribute("region")],E=l[u.getAttribute("style")],T=s_(S,E,l),{textAlign:R}=T;if(R){const I=e_[R];I&&(y.lineAlign=I),y.align=R}return de(y,T),y}).filter(u=>u!==null)}function _n(t,e,s){const i=t.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(s)):[]}function ul(t){return t.reduce((e,s)=>{const i=s.getAttribute("xml:id");return i&&(e[i]=s),e},{})}function Yh(t,e){return[].slice.call(t.childNodes).reduce((s,i,n)=>{var r;return i.nodeName==="br"&&n?s+` 34`:(r=i.childNodes)!=null&&r.length?Yh(i,e):e?s+i.textContent.trim().replace(/\s+/g," "):s+i.textContent},"")}function s_(t,e,s){const i="http://www.w3.org/ns/ttml#styling";let n=null;const r=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],o=t!=null&&t.hasAttribute("style")?t.getAttribute("style"):null;return o&&s.hasOwnProperty(o)&&(n=s[o]),r.reduce((a,l)=>{const c=wn(e,i,l)||wn(t,i,l)||wn(n,i,l);return c&&(a[l]=c),a},{})}function wn(t,e,s){return t&&t.hasAttributeNS(e,s)?t.getAttributeNS(e,s):null}function hl(t){return new Error(`Could not parse ttml timestamp ${t}`)}function Dn(t,e){if(!t)return null;let s=Gh(t);return s===null&&(Wh.test(t)?s=i_(t,e):qh.test(t)&&(s=n_(t,e))),s}function i_(t,e){const s=Wh.exec(t),i=(s[4]|0)+(s[5]|0)/e.subFrameRate;return(s[1]|0)*3600+(s[2]|0)*60+(s[3]|0)+i/e.frameRate}function n_(t,e){const s=qh.exec(t),i=Number(s[1]);switch(s[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}class r_{constructor(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=fl(),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}},this.config.enableCEA708Captions){const s=new Zs(this,"textTrack1"),i=new Zs(this,"textTrack2"),n=new Zs(this,"textTrack3"),r=new Zs(this,"textTrack4");this.cea608Parser1=new al(1,s,i),this.cea608Parser2=new al(3,n,r)}e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(p.FRAG_LOADING,this.onFragLoading,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this),e.on(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(p.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(p.FRAG_LOADING,this.onFragLoading,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this),e.off(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(p.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(e,s,i,n,r){let o=!1;for(let a=r.length;a--;){const l=r[a],c=a_(l[0],l[1],s,i);if(c>=0&&(l[0]=Math.min(l[0],s),l[1]=Math.max(l[1],i),o=!0,c/(i-s)>.5))return}if(o||r.push([s,i]),this.config.renderTextTracksNatively){const a=this.captionsTracks[e];this.Cues.newCue(a,s,i,n)}else{const a=this.Cues.newCue(null,s,i,n);this.hls.trigger(p.CUES_PARSED,{type:"captions",cues:a,track:e})}}onInitPtsFound(e,{frag:s,id:i,initPTS:n,timescale:r}){const{unparsedVttFrags:o}=this;i==="main"&&(this.initPTS[s.cc]={baseTime:n,timescale:r}),o.length&&(this.unparsedVttFrags=[],o.forEach(a=>{this.onFragLoaded(p.FRAG_LOADED,a)}))}getExistingTrack(e){const{media:s}=this;if(s)for(let i=0;i<s.textTracks.length;i++){const n=s.textTracks[i];if(n[e])return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:s,captionsTracks:i,media:n}=this,{label:r,languageCode:o}=s[e],a=this.getExistingTrack(e);if(a)i[e]=a,Yt(i[e]),ph(i[e],n);else{const l=this.createTextTrack("captions",r,o);l&&(l[e]=!0,i[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const s=this.captionsProperties[e];if(!s)return;const i=s.label,n={_id:e,label:i,kind:"captions",default:s.media?!!s.media.default:!1,closedCaptions:s.media};this.nonNativeCaptionsTracks[e]=n,this.hls.trigger(p.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}createTextTrack(e,s,i){const n=this.media;if(n)return n.addTextTrack(e,s,i)}onMediaAttaching(e,s){this.media=s.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach(s=>{Yt(e[s]),delete e[s]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=fl(),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 s=e.textTracks;
34if(s)for(let i=0;i<s.length;i++)Yt(s[i])}onSubtitleTracksUpdated(e,s){const i=s.subtitleTracks||[],n=i.some(r=>r.textCodec===Cn);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(Bh(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const o=this.media?this.media.textTracks:null;this.tracks.forEach((a,l)=>{let c;if(o&&l<o.length){let d=null;for(let u=0;u<o.length;u++)if(o_(o[u],a)){d=o[u];break}d&&(c=d)}if(c)Yt(c);else{const d=this._captionsOrSubtitlesFromCharacteristics(a);c=this.createTextTrack(d,a.name,a.lang),c&&(c.mode="disabled")}c&&(c.groupId=a.groupId,this.textTracks.push(c))})}else if(this.tracks.length){const o=this.tracks.map(a=>({label:a.name,kind:a.type.toLowerCase(),default:a.default,subtitleTrack:a}));this.hls.trigger(p.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:o})}}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){const s=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(s&&i)return"captions"}return"subtitles"}onManifestLoaded(e,s){this.config.enableCEA708Captions&&s.captions&&s.captions.forEach(i=>{const n=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!n)return;const r=`textTrack${n[1]}`,o=this.captionsProperties[r];o&&(o.label=i.name,i.lang&&(o.languageCode=i.lang),o.media=i)})}closedCaptionsForLevel(e){const s=this.hls.levels[e.level];return s?.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,s){const{cea608Parser1:i,cea608Parser2:n,lastSn:r,lastPartIndex:o}=this;if(!(!this.enabled||!(i&&n))&&s.frag.type===$.MAIN){var a,l;const c=s.frag.sn,d=(a=s==null||(l=s.part)==null?void 0:l.index)!=null?a:-1;c===r+1||c===r&&d===o+1||(i.reset(),n.reset()),this.lastSn=c,this.lastPartIndex=d}}onFragLoaded(e,s){const{frag:i,payload:n}=s;if(i.type===$.SUBTITLE)if(n.byteLength){const r=i.decryptdata,o="stats"in s;if(r==null||!r.encrypted||o){const a=this.tracks[i.level],l=this.vttCCs;l[i.cc]||(l[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),a&&a.textCodec===Cn?this._parseIMSC1(i,n):this._parseVTTs(s)}}else this.hls.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,s){const i=this.hls;dl(s,this.initPTS[e.cc],n=>{this._appendCues(n,e.level),i.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},n=>{v.log(`Failed to parse IMSC1: ${n}`),i.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:n})})}_parseVTTs(e){var s;const{frag:i,payload:n}=e,{initPTS:r,unparsedVttFrags:o}=this,a=r.length-1;if(!r[i.cc]&&a===-1){o.push(e);return}const l=this.hls,c=(s=i.initSegment)!=null&&s.data?Mt(i.initSegment.data,new Uint8Array(n)):n;ZC(c,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,d=>{this._appendCues(d,i.level),l.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},d=>{const u=d.message==="Missing initPTS for VTT MPEGTS";u?o.push(e):this._fallbackToIMSC1(i,n),v.log(`Failed to parse VTT cue: ${d}`),!(u&&a>i.cc)&&l.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:d})})}_fallbackToIMSC1(e,s){const i=this.tracks[e.level];i.textCodec||dl(s,this.initPTS[e.cc],()=>{i.textCodec=Cn,this._parseIMSC1(e,s)},()=>{i.textCodec="wvtt"})}_appendCues(e,s){const i=this.hls;if(this.config.renderTextTracksNatively){const n=this.textTracks[s];if(!n||n.mode==="disabled")return;e.forEach(r=>mh(n,r))}else{const n=this.tracks[s];if(!n)return;const r=n.default?"default":"subtitles"+s;i.trigger(p.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}onFragDecrypted(e,s){const{frag:i}=s;i.type===$.SUBTITLE&&this.onFragLoaded(p.FRAG_LOADED,s)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,s){const{cea608Parser1:i,cea608Parser2:n}=this;if(!this.enabled||!(i&&n))return;const{frag:r,samples:o}=s;if(!(r.type===$.MAIN&&this.closedCaptionsForLevel(r)==="NONE"))for(let a=0;a<o.length;a++){const l=o[a].bytes;if(l){const c=this.extractCea608Data(l);i.addData(o[a].pts,c[0]),n.addData(o[a].pts,c[1])}}}onBufferFlushing(e,{startOffset:s,endOffset:i,endOffsetSubtitles:n,type:r}){const{media:o}=this;
vendor: 21,481 bytes, lines 34-35
34if(!(!o||o.currentTime<i)){if(!r||r==="video"){const{captionsTracks:a}=this;Object.keys(a).forEach(l=>zn(a[l],s,i))}if(this.config.renderTextTracksNatively&&s===0&&n!==void 0){const{textTracks:a}=this;Object.keys(a).forEach(l=>zn(a[l],s,n))}}}extractCea608Data(e){const s=[[],[]],i=e[0]&31;let n=2;for(let r=0;r<i;r++){const o=e[n++],a=127&e[n++],l=127&e[n++];if(a===0&&l===0)continue;if((4&o)!==0){const d=3&o;(d===0||d===1)&&(s[d].push(a),s[d].push(l))}}return s}}function o_(t,e){return!!t&&t.label===e.name&&!(t.textTrack1||t.textTrack2)}function a_(t,e,s,i){return Math.min(e,i)-Math.max(t,s)}function fl(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class Bo{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.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(p.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(p.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,s){const i=this.hls.levels[s.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,s){this.media=s.media instanceof HTMLVideoElement?s.media:null,this.clientRect=null}onManifestParsed(e,s){const i=this.hls;this.restrictedLevels=[],this.firstLevel=s.firstLevel,i.config.capLevelToPlayerSize&&s.video&&this.startCapping()}onBufferCodecs(e,s){this.hls.config.capLevelToPlayerSize&&s.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const e=this.hls.levels;if(e.length){const s=this.hls;s.autoLevelCapping=this.getMaxLevel(e.length-1),s.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=s.autoLevelCapping}}}getMaxLevel(e){const s=this.hls.levels;if(!s.length)return-1;const i=s.filter((n,r)=>this.isLevelAllowed(n)&&r<=e);return this.clientRect=null,Bo.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}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,s={width:0,height:0};if(e){const i=e.getBoundingClientRect();s.width=i.width,s.height=i.height,!s.width&&!s.height&&(s.width=i.right-i.left||e.width||0,s.height=i.bottom-i.top||e.height||0)}return this.clientRect=s,s}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(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,s,i){if(!(e!=null&&e.length))return-1;const n=(o,a)=>a?o.width!==a.width||o.height!==a.height:!0;let r=e.length-1;for(let o=0;o<e.length;o+=1){const a=e[o];if((a.width>=s||a.height>=i)&&n(a,e[o+1])){r=o;break}}return r}}class l_{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(p.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,s){const i=this.hls.config;if(i.capLevelOnFPSDrop){const n=s.media instanceof self.HTMLVideoElement?s.media:null;this.media=n,n&&typeof n.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}checkFPS(e,s,i){const n=performance.now();if(s){if(this.lastTime){const r=n-this.lastTime,o=i-this.lastDroppedFrames,a=s-this.lastDecodedFrames,l=1e3*o/r,c=this.hls;if(c.trigger(p.FPS_DROP,{currentDropped:o,currentDecoded:a,totalDroppedFrames:i}),l>0&&o>c.config.fpsDroppedMonitoringThreshold*a){let d=c.currentLevel;v.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(c.autoLevelCapping===-1||c.autoLevelCapping>=d)&&(d=d-1,c.trigger(p.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:c.currentLevel}),c.autoLevelCapping=d,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=i,this.lastDecodedFrames=s}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const s=e.getVideoPlaybackQuality();this.checkFPS(e,s.totalVideoFrames,s.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}const ti="[eme]";class zt{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=zt.CDMCleanupPromise?[zt.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=v.debug.bind(v,ti),this.log=v.log.bind(v,ti),this.warn=v.warn.bind(v,ti),this.error=v.error.bind(v,ti),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.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(p.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(p.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:s,widevineLicenseUrl:i}=this.config,n=s[e];if(n)return n.licenseUrl;if(e===ne.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){const{drmSystems:s}=this.config,i=s[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const s=this.hls.levels,i=(o,a,l)=>!!o&&l.indexOf(o)===a,n=s.map(o=>o.audioCodec).filter(i),r=s.map(o=>o.videoCodec).filter(i);return n.length+r.length===0&&r.push("avc1.42e01e"),new Promise((o,a)=>{const l=c=>{const d=c.shift();this.getMediaKeysPromise(d,n,r).then(u=>o({keySystem:d,mediaKeys:u})).catch(u=>{c.length?l(c):u instanceof Ne?a(u):a(new Ne({type:B.KEY_SYSTEM_ERROR,details:L.KEY_SYSTEM_NO_ACCESS,error:u,fatal:!0},u.message))})};l(e)})}requestMediaKeySystemAccess(e,s){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let n=`Configured requestMediaKeySystemAccess is not a function ${i}`;return ih===null&&self.location.protocol==="http:"&&(n=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(n))}return i(e,s)}getMediaKeysPromise(e,s,i){const n=bL(e,s,i,this.config.drmSystemOptions),r=this.keySystemAccessPromises[e];let o=r?.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(n)}`),o=this.requestMediaKeySystemAccess(e,n);const a=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),o.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);const c=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),a.mediaKeys=l.createMediaKeys().then(d=>(this.log(`Media-keys created for "${e}"`),c.then(u=>u?this.setMediaKeysServerCertificate(d,e,u):d))),a.mediaKeys.catch(d=>{this.error(`Failed to create media-keys for "${e}"}: ${d}`)}),a.mediaKeys})}return o.then(()=>r.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:s,mediaKeys:i}){this.log(`Creating key-system session "${s}" keyId: ${Ye.hexDump(e.keyId||[])}`);const n=i.createSession(),r={decryptdata:e,keySystem:s,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r}renewKeySession(e){const s=e.decryptdata;if(s.pssh){const i=this.createMediaKeySessionContext(e),n=this.getKeyIdString(s),r="cenc";this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(i,r,s.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 Ye.hexDump(e.keyId)}updateKeySession(e,s){var i;const n=e.mediaKeysSession;return this.log(`Updating key-session "${n.sessionId}" for keyID ${Ye.hexDump(((i=e.decryptdata)==null?void 0:i.keyId)||[])} 35 } (data length: ${s&&s.byteLength})`),n.update(s)}selectKeySystemFormat(e){const s=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${s.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(s)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((s,i)=>{const n=dn(this.config),r=e.map(Aa).filter(o=>!!o&&n.indexOf(o)!==-1);return this.getKeySystemSelectionPromise(r).then(({keySystem:o})=>{const a=Ia(o);a?s(a):i(new Error(`Unable to find format for key-system "${o}"`))}).catch(i)})}loadKey(e){const s=e.keyInfo.decryptdata,i=this.getKeyIdString(s),n=`(keyId: ${i} format: "${s.keyFormat}" method: ${s.method} uri: ${s.uri})`;this.log(`Starting session for key ${n}`);let r=this.keyIdToKeySessionPromise[i];return r||(r=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(s).then(({keySystem:o,mediaKeys:a})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${n}`),this.attemptSetMediaKeys(o,a).then(()=>{this.throwIfDestroyed();const l=this.createMediaKeySessionContext({keySystem:o,mediaKeys:a,decryptdata:s});return this.generateRequestWithPreferredKeySession(l,"cenc",s.pssh,"playlist-key")}))),r.catch(o=>this.handleError(o))),r}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof Ne?this.hls.trigger(p.ERROR,e.data):this.hls.trigger(p.ERROR,{type:B.KEY_SYSTEM_ERROR,details:L.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const s=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[s];if(!i){const n=Aa(e.keyFormat),r=n?[n]:dn(this.config);return this.attemptKeySystemAccess(r)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=dn(this.config)),e.length===0)throw new Ne({type:B.KEY_SYSTEM_ERROR,details:L.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:s,initData:i}=e;if(this.debug(`"${e.type}" event: init data type: "${s}"`),i===null)return;let n,r;if(s==="sinf"&&this.config.drmSystems[ne.FAIRPLAY]){const d=pe(new Uint8Array(i));try{const u=Io(JSON.parse(d).sinf),h=uh(new Uint8Array(u));if(!h)return;n=h.subarray(8,24),r=ne.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const d=qL(i);if(d===null)return;d.version===0&&d.systemId===sh.WIDEVINE&&d.data&&(n=d.data.subarray(8,24)),r=EL(d.systemId)}if(!r||!n)return;const o=Ye.hexDump(n),{keyIdToKeySessionPromise:a,mediaKeySessions:l}=this;let c=a[o];for(let d=0;d<l.length;d++){const u=l[d],h=u.decryptdata;if(h.pssh||!h.keyId)continue;const f=Ye.hexDump(h.keyId);if(o===f||h.uri.replace(/-/g,"").indexOf(o)!==-1){c=a[f],delete a[f],h.pssh=new Uint8Array(i),h.keyId=n,c=a[o]=c.then(()=>this.generateRequestWithPreferredKeySession(u,s,i,"encrypted-event-key-match"));break}}c||(c=a[o]=this.getKeySystemSelectionPromise([r]).then(({keySystem:d,mediaKeys:u})=>{var h;this.throwIfDestroyed();const f=new _s("ISO-23001-7",o,(h=Ia(d))!=null?h:"");return f.pssh=new Uint8Array(i),f.keyId=n,this.attemptSetMediaKeys(d,u).then(()=>{this.throwIfDestroyed();const g=this.createMediaKeySessionContext({decryptdata:f,keySystem:d,mediaKeys:u});return this.generateRequestWithPreferredKeySession(g,s,i,"encrypted-event-no-match")})})),c.catch(d=>this.handleError(d))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,s){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const n=Promise.all(i).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(s)});return this.setMediaKeysQueue.push(n),n.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(r=>i.indexOf(r)===-1)})}generateRequestWithPreferredKeySession(e,s,i,n){var r,o;const a=(r=this.config.drmSystems)==null||(o=r[e.keySystem])==null?void 0:o.generateRequest;if(a)try{const h=a.call(this.hls,s,i,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");s=h.initDataType,i=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(i===null)return this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(e);const c=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${n}": ${c} (init data type: ${s} length: ${i?i.byteLength:null})`);const d=new No;e.mediaKeysSession.onmessage=h=>{const f=e.mediaKeysSession;if(!f){d.emit("error",new Error("invalid state"));return}const{messageType:g,message:m}=h;this.log(`"${g}" message event for session "${f.sessionId}" message size: ${m.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,m).catch(y=>{this.handleError(y),d.emit("error",y)}):g==="license-release"?e.keySystem===ne.FAIRPLAY&&(this.updateKeySession(e,th("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},e.mediaKeysSession.onkeystatuseschange=h=>{if(!e.mediaKeysSession){d.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);const g=e.keyStatus;d.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${c}`),this.renewKeySession(e))};const u=new Promise((h,f)=>{d.on("error",f),d.on("keyStatus",g=>{g.startsWith("usable")?h():g==="output-restricted"?f(new Ne({type:B.KEY_SYSTEM_ERROR,details:L.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?f(new Ne({type:B.KEY_SYSTEM_ERROR,details:L.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?f(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(s,i).then(()=>{var h;this.log(`Request generated for key-session "${(h=e.mediaKeysSession)==null?void 0:h.sessionId}" keyId: ${c}`)}).catch(h=>{throw new Ne({type:B.KEY_SYSTEM_ERROR,details:L.KEY_SYSTEM_NO_SESSION,error:h,fatal:!1},`Error generating key-session request: ${h}`)}).then(()=>u).catch(h=>{throw d.removeAllListeners(),this.removeSession(e),h}).then(()=>(d.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((s,i)=>{this.log(`key status change "${s}" for keyStatuses keyId: ${Ye.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Ye.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=s})}fetchServerCertificate(e){const s=this.config,i=s.loader,n=new i(s),r=this.getServerCertificateUrl(e);return r?(this.log(`Fetching serverCertificate for "${e}"`),new Promise((o,a)=>{const l={responseType:"arraybuffer",url:r},c=s.certLoadPolicy.default,d={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,g,m)=>{o(h.data)},onError:(h,f,g,m)=>{a(new Ne({type:B.KEY_SYSTEM_ERROR,details:L.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:Re({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${r}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,g)=>{a(new Ne({type:B.KEY_SYSTEM_ERROR,details:L.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${r})`))},onAbort:(h,f,g)=>{a(new Error("aborted"))}};n.load(l,d,u)})):Promise.resolve()}setMediaKeysServerCertificate(e,s,i){return new Promise((n,r)=>{e.setServerCertificate(i).then(o=>{this.log(`setServerCertificate ${o?"success":"not supported by CDM"} (${i?.byteLength}) on "${s}"`),n(e)}).catch(o=>{r(new Ne({type:B.KEY_SYSTEM_ERROR,details:L.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:o,fatal:!0},o.message))})})}renewLicense(e,s){return this.requestLicense(e,new Uint8Array(s)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(n=>{throw new Ne({type:B.KEY_SYSTEM_ERROR,details:L.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:n,fatal:!0},n.message)}))}setupLicenseXHR(e,s,i,n){const r=this.config.licenseXhrSetup;return r?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return r.call(this.hls,e,s,i,n)}).catch(o=>{if(!i.decryptdata)throw o;return e.open("POST",s,!0),r.call(this.hls,e,s,i,n)}).then(o=>(e.readyState||e.open("POST",s,!0),{xhr:e,licenseChallenge:o||n})):(e.open("POST",s,!0),Promise.resolve({xhr:e,licenseChallenge:n}))}requestLicense(e,s){const i=this.config.keyLoadPolicy.default;return new Promise((n,r)=>{const o=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${o}`);const a=new XMLHttpRequest;a.responseType="arraybuffer",a.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return r(new Error("invalid state"));if(a.readyState===4)if(a.status===200){this._requestLicenseFailureCount=0;let l=a.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);const c=this.config.licenseResponseCallback;if(c)try{l=c.call(this.hls,a,o,e)}catch(d){this.error(d)}n(l)}else{const l=i.errorRetry,c=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>c||a.status>=400&&a.status<500)r(new Ne({type:B.KEY_SYSTEM_ERROR,details:L.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:o,data:void 0,code:a.status,text:a.statusText}},`License Request XHR failed (${o}). Status: ${a.status} (${a.statusText})`));else{const d=c-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${d} attempts left`),this.requestLicense(e,s).then(n,r)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=a,this.setupLicenseXHR(a,o,e,s).then(({xhr:l,licenseChallenge:c})=>{l.send(c)})})}onMediaAttached(e,s){if(!this.config.emeEnabled)return;const i=s.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,s=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={},_s.clearKeyUriToKeyIdMap();const i=s.length;zt.CDMCleanupPromise=Promise.all(s.map(n=>this.removeSession(n)).concat(e?.setMediaKeys(null).catch(n=>{this.log(`Could not clear media keys: ${n}. media.src: ${e?.src}`)}))).then(()=>
35{i&&(this.log("finished closing key sessions and clearing media keys"),s.length=0)}).catch(n=>{this.log(`Could not close sessions and clear media keys: ${n}. media.src: ${e?.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:s}){if(!(!s||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=s.reduce((n,r)=>(n.indexOf(r.keyFormat)===-1&&n.push(r.keyFormat),n),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(e){const{mediaKeysSession:s,licenseXhr:i}=e;if(s){this.log(`Remove licenses and keys and close session ${s.sessionId}`),s.onmessage=null,s.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const n=this.mediaKeySessions.indexOf(e);return n>-1&&this.mediaKeySessions.splice(n,1),s.remove().catch(r=>{this.log(`Could not remove session: ${r}`)}).then(()=>s.close()).catch(r=>{this.log(`Could not close session: ${r}`)})}}}zt.CDMCleanupPromise=void 0;class Ne extends Error{constructor(e,s){super(s),this.data=void 0,e.error||(e.error=new Error(s)),this.data=e,e.err=e.error}}const c_=1;var be={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",
35KEY:"k",OTHER:"o"};const d_="h";class ht{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.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=n=>{try{this.apply(n,{ot:be.MANIFEST,su:!this.initialized})}catch(r){v.warn("Could not generate manifest CMCD data.",r)}},this.applyFragmentData=n=>{try{const r=n.frag,o=this.hls.levels[r.level],a=this.getObjectType(r),l={d:r.duration*1e3,ot:a};(a===be.VIDEO||a===be.AUDIO||a==be.MUXED)&&(l.br=o.bitrate/1e3,l.tb=this.getTopBandwidth(a)/1e3,l.bl=this.getBufferLength(a)),this.apply(n,l)}catch(r){v.warn("Could not generate segment CMCD data.",r)}},this.hls=e;const s=this.config=e.config,{cmcd:i}=s;i!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||ht.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}registerListeners(){const e=this.hls;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHED,this.onMediaDetached,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHED,this.onMediaDetached,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(e,s){this.media=s.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,s){var i,n;this.audioBuffer=(i=s.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(n=s.tracks.video)==null?void 0:n.buffer}createData(){var e;return{v:c_,sf:d_,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,s={}){de(s,this.createData());const i=s.ot===be.INIT||s.ot===be.VIDEO||s.ot===be.MUXED;if(this.starved&&i&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){const n=ht.toHeaders(s);if(!Object.keys(n).length)return;e.headers||(e.headers={}),de(e.headers,n)}else{const n=ht.toQuery(s);if(!n)return;e.url=ht.appendQueryToUri(e.url,n)}}getObjectType(e){const{type:s}=e;if(s==="subtitle")return be.TIMED_TEXT;if(e.sn==="initSegment")return be.INIT;if(s==="audio")return be.AUDIO;if(s==="main")return this.hls.audioTracks.length?be.VIDEO:be.MUXED}getTopBandwidth(e){let s=0,i;const n=this.hls;if(e===be.AUDIO)i=n.audioTracks;else{const r=n.maxAutoLevel,o=r>-1?r+1:n.levels.length;i=n.levels.slice(0,o)}for(const r of i)r.bitrate>s&&(s=r.bitrate);return s>0?s:NaN}getBufferLength(e){const s=this.hls.media,i=e===be.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!s?NaN:Z.bufferInfo(i,s.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,s=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(r){this.loader=void 0,this.loader=new i(r)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(r,o,a){s(r),this.loader.load(r,o,a)}}}createFragmentLoader(){const{fLoader:e}=this.config,s=this.applyFragmentData,i=e||this.config.loader;return class{constructor(r){this.loader=void 0,this.loader=new i(r)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(r,o,a){s(r),this.loader.load(r,o,a)}}}static uuid(){const e=URL.createObjectURL(new Blob),s=e.toString();return URL.revokeObjectURL(e),s.slice(s.lastIndexOf("/")+1)}static serialize(e){const s=[],i=c=>!Number.isNaN(c)&&c!=null&&c!==""&&c!==!1,n=c=>Math.round(c),r=c=>n(c/100)*100,a={br:n,d:n,bl:r,dl:r,mtp:r,nor:c=>encodeURIComponent(c),rtp:r,tb:n},l=Object.keys(e||{}).sort();for(const c of l){let d=e[c];if(!i(d)||c==="v"&&d===1||c=="pr"&&d===1)continue;const u=a[c];u&&(d=u(d));const h=typeof d;let f;c==="ot"||c==="sf"||c==="st"?f=`${c}=${d}`:h==="boolean"?f=c:h==="number"?f=`${c}=${d}`:f=`${c}=${JSON.stringify(d)}`,s.push(f)}return s.join(",")}static toHeaders(e){const s=Object.keys(e),i={},n=["Object","Request","Session","Status"],r=[{},{},{},{}],o={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const a of s){const l=o[a]!=null?o[a]:1;r[l][a]=e[a]}for(let a=0;a<r.length;a++){const l=ht.serialize(r[a]);l&&(i[`CMCD-${n[a]}`]=l)}return i}static toQuery(e){return`CMCD=${encodeURIComponent(ht.serialize(e))}`}static appendQueryToUri(e,s){if(!s)return e;const i=e.includes("?")?"&":"?";return`${e}${i}${s}`}}const u_=3e5;class h_{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=v.log.bind(v,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.ERROR,this.onError,this))}
35startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){const e=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,e)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const s=this.levels;s&&(this.levels=s.filter(i=>i!==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,s){const{contentSteering:i}=s;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,s){this.audioTracks=s.audioTracks,this.subtitleTracks=s.subtitleTracks}onError(e,s){const{errorAction:i}=s;if(i?.action===Se.SendAlternateToPenaltyBox&&i.flags===Fe.MoveAllAlternatesMatchingHost){let n=this.pathwayPriority;const r=this.pathwayId;this.penalizedPathways[r]||(this.penalizedPathways[r]=performance.now()),!n&&this.levels&&(n=this.levels.reduce((o,a)=>(o.indexOf(a.pathwayId)===-1&&o.push(a.pathwayId),o),[])),n&&n.length>1&&(this.updatePathwayPriority(n),i.resolved=this.pathwayId!==r)}}filterParsedLevels(e){this.levels=e;let s=this.getLevelsForPathway(this.pathwayId);if(s.length===0){const i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),s=this.getLevelsForPathway(i),this.pathwayId=i}return s.length!==e.length?(this.log(`Found ${s.length}/${e.length} levels in Pathway "${this.pathwayId}"`),s):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(s=>e===s.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let s;const i=this.penalizedPathways,n=performance.now();
35Object.keys(i).forEach(r=>{n-i[r]>u_&&delete i[r]});for(let r=0;r<e.length;r++){const o=e[r];if(i[o])continue;if(o===this.pathwayId)return;const a=this.hls.nextLoadLevel,l=this.hls.levels[a];if(s=this.getLevelsForPathway(o),s.length>0){this.log(`Setting Pathway to "${o}"`),this.pathwayId=o,this.hls.trigger(p.LEVELS_UPDATED,{levels:s});const c=this.hls.levels[a];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=a);break}}}clonePathways(e){const s=this.levels;if(!s)return;const i={},n={};e.forEach(r=>{const{ID:o,"BASE-ID":a,"URI-REPLACEMENT":l}=r;if(s.some(d=>d.pathwayId===o))return;const c=this.getLevelsForPathway(a).map(d=>{const u=de({},d);u.details=void 0,u.url=jh(d.uri,d.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l);const h=new ie(d.attrs);h["PATHWAY-ID"]=o;const f=h.AUDIO&&`${h.AUDIO}_clone_${o}`,g=h.SUBTITLES&&`${h.SUBTITLES}_clone_${o}`;f&&(i[h.AUDIO]=f,h.AUDIO=f),g&&(n[h.SUBTITLES]=g,h.SUBTITLES=g),u.attrs=h;const m=new ws(u);return bi(m,"audio",f),bi(m,"text",g),m});s.push(...c),gl(this.audioTracks,i,l,o),gl(this.subtitleTracks,n,l,o)})}loadSteeringManifest(e){const s=this.hls.config,i=s.loader;this.loader&&this.loader.destroy(),this.loader=new i(s);let n;try{n=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(n.protocol!=="data:"){const d=(this.hls.bandwidthEstimate||s.abrEwmaDefaultEstimate)|0;n.searchParams.set("_HLS_pathway",this.pathwayId),n.searchParams.set("_HLS_throughput",""+d)}const r={responseType:"json",url:n.href},o=s.steeringManifestLoadPolicy.default,a=o.errorRetry||o.timeoutRetry||{},l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},c={onSuccess:(d,u,h,f)=>{this.log(`Loaded steering manifest: "${n}"`);const g=d.data;if(g.VERSION!==1){this.log(`Steering VERSION ${g.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=g.TTL;const{"RELOAD-URI":m,"PATHWAY-CLONES":y,"PATHWAY-PRIORITY":S}=g;if(m)try{this.uri=new self.URL(m,n).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${m}`);return}this.scheduleRefresh(this.uri||h.url),y&&this.clonePathways(y),S&&this.updatePathwayPriority(S)},onError:(d,u,h,f)=>{if(this.log(`Error loading steering manifest: ${d.code} ${d.text} (${u.url})`),this.stopLoad(),d.code===410){this.enabled=!1,this.log(`Steering manifest ${u.url} no longer available`);return}let g=this.timeToLoad*1e3;if(d.code===429){const m=this.loader;if(typeof m?.getResponseHeader=="function"){const y=m.getResponseHeader("Retry-After");y&&(g=parseFloat(y)*1e3)}this.log(`Steering manifest ${u.url} rate limited`);return}this.scheduleRefresh(this.uri||u.url,g)},onTimeout:(d,u,h)=>{this.log(`Timeout loading steering manifest (${u.url})`),this.scheduleRefresh(this.uri||u.url)}};this.log(`Requesting steering manifest: ${n}`),this.loader.load(r,l,c)}scheduleRefresh(e,s=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(e)},s)}}function gl(t,e,s,i){t&&Object.keys(e).forEach(n=>{const r=t.filter(o=>o.groupId===n).map(o=>{const a=de({},o);return a.details=void 0,a.attrs=new ie(a.attrs),a.url=a.attrs.URI=jh(o.url,o.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",s),a.groupId=a.attrs["GROUP-ID"]=e[n],a.attrs["PATHWAY-ID"]=i,a});t.push(...r)})}function jh(t,e,s,i){const{HOST:n,PARAMS:r,[s]:o}=i;let a;e&&(a=o?.[e],a&&(t=a));const l=new self.URL(t);return n&&!a&&(l.host=n),r&&Object.keys(r).sort().forEach(c=>{c&&l.searchParams.set(c,r[c])}),l.href}const f_=/^age:\s*[\d.]+\s*$/im;class zh{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=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Xi,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=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,s,i){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=s,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:e,context:s}=this;if(!e)return;const i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;const r=this.xhrSetup;r?Promise.resolve().then(()=>
35{if(!this.stats.aborted)return r(i,s.url)}).catch(o=>(i.open("GET",s.url,!0),r(i,s.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,s,e)}).catch(o=>{this.callbacks.onError({code:i.status,text:o.message},s,i,n)}):this.openAndSendXhr(i,s,e)}openAndSendXhr(e,s,i){e.readyState||e.open("GET",s.url,!0);const n=this.context.headers,{maxTimeToFirstByteMs:r,maxLoadTimeMs:o}=i.loadPolicy;if(n)for(const a in n)e.setRequestHeader(a,n[a]);s.rangeEnd&&e.setRequestHeader("Range","bytes="+s.rangeStart+"-"+(s.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=s.responseType,self.clearTimeout(this.requestTimeout),i.timeout=r&&N(r)?r:o,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:s,stats:i}=this;if(!e||!s)return;const n=s.readyState,r=this.config;if(!i.aborted&&n>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),r.timeout!==r.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),r.timeout=r.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),n===4)){self.clearTimeout(this.requestTimeout),s.onreadystatechange=null,s.onprogress=null;const o=s.status,a=s.responseType!=="text";if(o>=200&&o<300&&(a&&s.response||s.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const l=a?s.response:s.responseText,c=s.responseType==="arraybuffer"?l.byteLength:l.length;if(i.loaded=i.total=c,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;const d=this.callbacks.onProgress;if(d&&d(i,e,l,s),!this.callbacks)return;const u={url:s.responseURL,data:l,code:o};this.callbacks.onSuccess(u,i,e,s)}else{const l=r.loadPolicy.errorRetry,c=i.retry;Ei(l,c,!1,o)?this.retry(l):(v.error(`${o} while loading ${e.url}`),this.callbacks.onError({code:o,text:s.statusText},e,s,i))}}}loadtimeout(){var e;const s=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,i=this.stats.retry;if(Ei(s,i,!0))this.retry(s);else{v.warn(`timeout while loading ${this.context.url}`);const n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:s,stats:i}=this;this.retryDelay=Ro(e,i.retry),i.retry++,v.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${s.url}, retrying ${i.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 s=this.stats;s.loaded=e.loaded,e.lengthComputable&&(s.total=e.total)}getCacheAge(){let e=null;if(this.loader&&f_.test(this.loader.getAllResponseHeaders())){const s=this.loader.getResponseHeader("age");e=s?parseFloat(s):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 g_(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const p_=/(\d+)-(\d+)\/(\d+)/;class pl{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||v_,this.controller=new self.AbortController,this.stats=new Xi}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const e=this.response;e!=null&&e.ok||(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,s,i){const n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();const r=m_(e,this.controller.signal),o=i.onProgress,a=e.responseType==="arraybuffer",l=a?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:d}=s.loadPolicy;this.context=e,this.config=s,this.callbacks=i,this.request=this.fetchSetup(e,r),self.clearTimeout(this.requestTimeout),s.timeout=c&&N(c)?c:d,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(n,e,this.response)},s.timeout),self.fetch(this.request).then(u=>{this.response=this.loader=u;const h=Math.max(self.performance.now(),n.loading.start);
35if(self.clearTimeout(this.requestTimeout),s.timeout=d,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(n,e,this.response)},d-(h-n.loading.start)),!u.ok){const{status:f,statusText:g}=u;throw new T_(g||"fetch, bad network response",f,u)}return n.loading.first=h,n.total=S_(u.headers)||n.total,o&&N(s.highWaterMark)?this.loadProgressively(u,n,e,s.highWaterMark,o):a?u.arrayBuffer():e.responseType==="json"?u.json():u.text()}).then(u=>{const{response:h}=this;self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);const f=u[l];f&&(n.loaded=n.total=f);const g={url:h.url,data:u,code:h.status};o&&!N(s.highWaterMark)&&o(n,e,u,h),i.onSuccess(g,n,e,h)}).catch(u=>{if(self.clearTimeout(this.requestTimeout),n.aborted)return;const h=u&&u.code||0,f=u?u.message:null;i.onError({code:h,text:f},e,u?u.details:null,n)})}getCacheAge(){let e=null;if(this.response){const s=this.response.headers.get("age");e=s?parseFloat(s):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,s,i,n=0,r){const o=new Uh,a=e.body.getReader(),l=()=>a.read().then(c=>{if(c.done)return o.dataLength&&r(s,i,o.flush(),e),Promise.resolve(new ArrayBuffer(0));const d=c.value,u=d.length;return s.loaded+=u,u<n||o.dataLength?(o.push(d),o.dataLength>=n&&r(s,i,o.flush(),e)):r(s,i,d,e),l()}).catch(()=>Promise.reject());return l()}}function m_(t,e){const s={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(de({},t.headers))};return t.rangeEnd&&s.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),s}function y_(t){const e=p_.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}function S_(t){const e=t.get("Content-Range");if(e){const i=y_(e);if(N(i))return i}const s=t.get("Content-Length");if(s)return parseInt(s)}function v_(t,e){return new self.Request(t.url,e)}class T_ extends Error{constructor(e,s,i){super(e),this.code=void 0,this.details=void 0,this.code=s,this.details=i}}const E_=/\s/,b_={newCue(t,e,s,i){const n=[];let r,o,a,l,c;const d=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(r=i.rows[h],a=!0,l=0,c="",!r.isEmpty()){var u;for(let m=0;m<r.chars.length;m++)E_.test(r.chars[m].uchar)&&a?l++:(c+=r.chars[m].uchar,a=!1);r.cueStartTime=e,e===s&&(s+=1e-4),l>=16?l--:l++;const f=Kh(c.trim()),g=Uo(e,s,f);t!=null&&(u=t.cues)!=null&&u.getCueById(g)||(o=new d(e,s,f),o.id=g,o.line=h+1,o.align="left",o.position=10+Math.min(80,Math.floor(l*8/32)*10),n.push(o))}return t&&n.length&&(n.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),n.forEach(h=>mh(t,h))),n}},x_={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},A_=Re(Re({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength: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:zh,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:CC,bufferController:FC,capLevelController:Bo,errorController:TR,fpsController:l_,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:ih,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,cert
35LoadPolicy:{default:x_},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},I_()),{},{subtitleStreamController:PC,subtitleTrackController:MC,timelineController:r_,audioStreamController:wC,audioTrackController:DC,emeController:zt,cmcdController:ht,contentSteeringController:h_});function I_(){return{cueHandler:b_,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 L_(t,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 s=sr(t),i=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(r=>{const o=`${r==="level"?"playlist":r}LoadPolicy`,a=e[o]===void 0,l=[];n.forEach(c=>{const d=`${r}Loading${c}`,u=e[d];if(u!==void 0&&a){l.push(d);const h=s[o].default;switch(e[o]={default:h},c){case"TimeOut":h.maxLoadTimeMs=u,h.maxTimeToFirstByteMs=u;break;case"MaxRetry":h.errorRetry.maxNumRetry=u,h.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":h.errorRetry.retryDelayMs=u,h.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=u,h.timeoutRetry.maxRetryDelayMs=u;break}}}),l.length&&v.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${o}": ${JSON.stringify(e[o])}`)}),Re(Re({},s),e)}function sr(t){return t&&typeof t=="object"?Array.isArray(t)?t.map(sr):Object.keys(t).reduce((e,s)=>(e[s]=sr(t[s]),e),{}):t}function R_(t){const e=t.loader;e!==pl&&e!==zh?(v.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):g_()&&(t.loader=pl,t.progressive=!0,t.enableSoftwareAES=!0,v.log("[config]: Progressive streaming enabled, using FetchLoader"))}class Ct{static get version(){return"1.4.10"}static isSupported(){return BR()}static get Events(){return p}static get ErrorTypes(){return B}static get ErrorDetails(){return L}static get DefaultConfig(){return Ct.defaultConfig?Ct.defaultConfig:A_}static set DefaultConfig(e){Ct.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new No,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,uL(e.debug||!1,"Hls instance");const s=this.config=L_(Ct.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,s.progressive&&R_(s);const{abrController:i,bufferController:n,capLevelController:r,errorController:o,fpsController:a}=s,l=new o(this),c=this.abrController=new i(this),d=this.bufferController=new n(this),u=this.capLevelController=new r(this),h=new a(this),f=new tR(this),g=new oR(this),m=s.contentSteeringController,y=m?new m(this):null,S=this.levelController=new bR(this,y),E=new xR(this),T=new IR(this.config),R=this.streamController=new LC(this,E,T);u.setStreamController(R),h.setStreamController(R);const I=[f,S,R];y&&I.splice(1,0,y),this.networkControllers=I;const k=[c,d,u,h,g,E];this.audioTrackController=this.createController(s.audioTrackController,I);const w=s.audioStreamController;w&&I.push(new w(this,E,T)),this.subtitleTrackController=this.createController(s.subtitleTrackController,I);const D=s.subtitleStreamController;D&&I.push(new D(this,E,T)),this.createController(s.timelineController,k),T.emeController=this.emeController=this.createController(s.emeController,k),this.cmcdController=this.createController(s.cmcdController,k),this.latencyController=this.createController(aR,k),this.coreComponents=k,I.push(l);const P=l.onErrorOut;typeof P=="function"&&this.on(p.ERROR,P,l)}createController(e,s){if(e){const i=new e(this);return s&&s.push(i),i}return null}on(e,s,i=this){this._emitter.on(e,s,i)}once(e,s,i=this){this._emitter.once(e,s,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,s,i=this,n){this._emitter.off(e,s,i,n)}listeners(e){return this._emitter.listeners(e)}emit(e,s,i){return this._emitter.emit(e,s,i)}
35trigger(e,s){if(this.config.debug)return this.emit(e,e,s);try{return this.emit(e,e,s)}catch(i){v.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(p.ERROR,{type:B.OTHER_ERROR,details:L.INTERNAL_EXCEPTION,fatal:!1,event:e,error:i})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){v.log("destroy"),this.trigger(p.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(s=>s.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(s=>s.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){v.log("attachMedia"),this._media=e,this.trigger(p.MEDIA_ATTACHING,{media:e})}detachMedia(){v.log("detachMedia"),this.trigger(p.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const s=this.media,i=this.url,n=this.url=Ao.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});v.log(`loadSource:${n}`),s&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(s)),this.trigger(p.MANIFEST_LOADING,{url:e})}startLoad(e=-1){v.log(`startLoad(${e})`),this.networkControllers.forEach(s=>{s.startLoad(e)})}stopLoad(){v.log("stopLoad"),this.networkControllers.forEach(e=>{e.stopLoad()})}swapAudioCodec(){v.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){v.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,s=0){this.levelController.removeLevel(e,s)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){v.log(`set currentLevel:${e}`),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){v.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){v.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){v.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){v.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 s=!!e;s!==this.config.capLevelToPlayerSize&&(s?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=s)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(v.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){Qn.indexOf(e)>-1&&(this._maxHdcpLevel=e)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:s}}=this;if(!e)return 0;const i=e.length;for(let n=0;n<i;n++)if(e[n].maxBitrate>=s)return n;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:s,maxHdcpLevel:i}=this;let n;if(s===-1&&e&&e.length?n=e.length-1:n=s,i)for(let r=n;r--;){const o=e[r].attrs["HDCP-LEVEL"];if(o&&o<=i)return r}return n}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}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 s=this.audioTrackController;s&&(s.audioTrack=e)}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 s=this.subtitleTrackController;s&&(s.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const s=this.subtitleTrackController;s&&(s.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}}Ct.defaultConfig=void 0;const C_=t=>{let e="";return e+=String.fromCharCode(t[0]),e+=String.fromCharCode(t[1]),e+=String.fromCharCode(t[2]),e+=String.fromCharCode(t[3]),e},__=t=>{const e=new DataView(t.buffer,t.byteOffset,t.byteLength),s=[];let i;for(let n=0;n<t.length;n+=i)switch(i=e.getUint32(n),n+=4,t[n]&31){case 1:s.push("NDR");break;case 5:s.push("IDR");break;case 6:s.push("SEI");break;case 7:s.push("SPS");break;case 8:s.push("PPS");break;case 9:s.push("AUD");break;default:s.push(t[n]&31);break}return s},w_={mdat(t){return{byteLength:t.byteLength,nals:__(t)}}},uO=t=>{const e=[],s=new DataView(t.buffer,t.byteOffset,t.byteLength);let i=0,n,r,o,a;for(;i<t.byteLength;)n=s.getUint32(i),r=C_(t.subarray(i+4,i+8)),o=n>1?i+n:t.byteLength,a=(w_[r]||(l=>({data:l})))(t.subarray(i+8,o)),a.size=n,a.type=r,e.push(a),i=o;return e},hO=(t,e="head")=>new Promise(s=>{const i=document.createElement("script");i.src=t,i.onload=s,document.getElementsByTagName(e)[0].appendChild(i)}),D_=(t,e="body")=>{const s=document.createElement("script");s.innerHTML=t,document.getElementsByTagName(e)[0].appendChild(s)},Ge=H("tv-stats"),k_={ethernet:"lan",wifi:"wifi",cellular:"mobile"},ml={hls:"hls",native:"native"};class fO{channelId="";playbackTime=0;mediaId="";pbsId="";isLive=!1;playIntervalNum=0;dvrDelayMs=0;isTv=!1;isArchive=!1;isVitrina=!1;connectionType;playerId="";systemMiniplayerTimeMs=0;secondScreenTimeMs=0;errorEventsCnt=0;isPlaybackAborted=!1;commonSizeFragsKbps=0;commonTimeFragsLoadingSeconds=0;minimalFragsKbps=0;languages=[];playingLanguageIndex=0;playingRenditionIndex=0;fullScreenStartTime=0;fullScreenTime=0;windowedStartTime=0;windowedTime=0;audioOnlyStartTime=0;audioOnlyTime=0;startTopQualityTime=0;startLowQualityTime=0;qualitySwitchesCnt=0;lowQualityTime=0;topQualityTime=0;bufferStartTime=0;bufferingEventsCnt=0;bufferTime=0;playingTimeStart=0;playingTimeStop=0;initTime=0;externalPlayerPlatform="";vodSourceId="";vodTitleId="";vodSeasonId="";vodEpisodeId="";vodMediaItemId="";hlsLevels=[];ctx=void 0;constructor(e){const s=e.channelId,i=e?.mediaId||"",n=e.pbsId||"",r=!!e.isVitrina,o=e?.vodMediaItemId||"";if(!e.isArchive&&!i){Ge.warn("could not init TV stats, mediaId is not set");return}if(!n&&!r){Ge.warn("could not init TV stats, pbsId is not set");return}if(e.isArchive&&!o){Ge.warn("could not init TV stats, vodMediaItemId is not set");return}Ge.info("init",r?{channelId:s}:{channelId:s,mediaId:i,pbsId:n}),this.ctx=e.ctx,this.channelId=s,this.mediaId=i,this.vodMediaItemId=o,this.isTv=e.isTv,this.isArchive=e.isArchive,this.isVitrina=r,this.playerId=e.playerId,this.getNetworkType(),this.languages=e.languages||[],this.playingLanguageIndex=e.languageIndex||0,this.pbsId=n,this.externalPlayerPlatform=e.externalPlayerPlatform,this.vodSourceId=e?.vodSourceId||"",this.vodTitleId=e?.vodTitleId||"",this.vodSeasonId=e?.vodSeasonId||"",this.vodEpisodeId=e?.vodEpisodeId||""}get eventDuration(){return Math.round(this.elapsedTime/1e3)}get startTime(){return this.playingTimeStart===0?this.elapsedTime:this.playingTimeStart-this.initTime}get elapsedTime(){return this.playingTimeStop-this.initTime}get playingTime(){return this.playingTimeStart===0?0:this.playingTimeStop-this.playingTimeStart-this.bufferTime}get averageFragsKbps(){return Math.round(this.commonSizeFragsKbps/this.commonTimeFragsLoadingSeconds)||0}get isPlayingStarted(){return this.playingTimeStart>0}get nativePlayerVersion(){const e=ss(this.ctx);return`${El(e)} ${Cf(e)}`}initPlaying(){this.resetStats(),this.initTime=Date.now(),Ge.info("initPlaying",{initTime:new Date(this.initTime)})}startPlaying(e,s,i=!1){this.playingTimeStart=Date.now(),this.playbackTime=s,this.isLive=i,this.dvrDelayMs=e,Ge.info("startPlaying",{dvrDelayMs:e,isLive:i,startTime:this.startTime,playbackTime:s}),Vr()?this.startFullScreen():(this.stopFullScreen(),this.startWindowedScreen())}stopPlaying(e=!1){this.initTime&&(this.playingTimeStop=Date.now(),this.isPlaybackAborted=e,this.playIntervalNum++,Ge.info("stopPlaying"),this.stopBuffer(),this.stopFullScreen(),this.stopWindowedScreen(),this.stopLowQuality(),this.stopTopQuality(),this.sendStatistics(),this.resetStats())}addHlsLevels(e){this.hlsLevels=e}startFullScreen(){this.stopWindowedScreen(),this.stopAudioOnly(),this.fullScreenStartTime=Date.now()}stopFullScreen(){this.fullScreenStartTime&&(this.fullScreenTime+=Date.now()-this.fullScreenStartTime,this.fullScreenStartTime=0)}startAudioOnly(){this.stopWindowedScreen(),this.stopFullScreen(),this.audioOnlyStartTime=Date.now()}stopAudioOnly(){this.audioOnlyStartTime&&(this.audioOnlyTime+=Date.now()-this.audioOnlyStartTime,this.audioOnlyStartTime=0)}startWindowedScreen(){this.stopFullScreen(),this.stopAudioOnly(),this.windowedStartTime=Date.now()}stopWindowedScreen(){this.windowedStartTime&&(this.windowedTime+=Date.now()-this.windowedStartTime,this.windowedStartTime=0)}setPlayingLanguageIndex(e){this.playingLanguageIndex=e}setPlayingRenditionIndex(e){this.playingRenditionIndex=e}startBuffer(){this.isPlayingStarted&&this.bufferStartTime===0&&(this.bufferingEventsCnt++,this.bufferStartTime=Date.now())}stopBuffer(){this.bufferStartTime&&this.isPlayingStarted&&(this.bufferTime+=Date.now()-this.bufferStartTime,this.bufferStartTime=0)}addFrag(e){const s=e.size*.008,i=e.time*.001,n=Math.round(s/i);this.commonSizeFragsKbps+=s,this.commonTimeFragsLoadingSeconds+=i,this.minimalFragsKbps=this.minimalFragsKbps?Math.min(this.minimalFragsKbps,n):n}resetStats(){this.initTime=0,this.fullScreenStartTime=0,this.bufferingEventsCnt=0,this.fullScreenTime=0,this.windowedTime=0,this.topQualityTime=0,this.lowQualityTime=0,this.bufferTime=0,this.bufferStartTime=0,this.playingTimeStart=0,this.playingTimeStop=0,this.windowedStartTime=0,this.commonSizeFragsKbps=0,this.audioOnlyTime=0,this.commonTimeFragsLoadingSeconds=0,this.minimalFragsKbps=0,this.isPlaybackAborted=!1}startLowQuality(){this.startLowQualityTime=Date.now()}stopLowQuality(){this.startLowQualityTime&&(this.lowQualityTime+=Date.now()-this.startLowQualityTime,this.startLowQualityTime=0)}startTopQuality(){this.startTopQualityTime=Date.now()}stopTopQuality(){this.startTopQualityTime&&(this.topQualityTime+=Date.now()-this.startTopQualityTime,this.startTopQualityTime=0)}
35changeQuality(e){this.isPlayingStarted&&this.qualitySwitchesCnt++,this.startLowQualityTime?this.stopLowQuality():this.startTopQualityTime&&this.stopTopQuality();const s=this.hlsLevels[e];if(s){const i=this.hlsLevels.map(o=>o.bitrate),n=ms(i)===s.bitrate,r=pt(i)===s.bitrate;n?this.startTopQuality():r&&this.startLowQuality()}}getNetworkType(){const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;e&&(this.connectionType=k_?.[e?.type||""]||void 0)}prepareData(){return this.isVitrina?this.prepareDataVitrina():this.prepareDataRegular()}prepareDataVitrina(){return{ChannelId:this.channelId,PlaybackTime:this.playbackTime,EventDuration:this.eventDuration}}prepareDataRegular(){const e=this.languages[this.playingLanguageIndex]?.renditions?.[this.playingRenditionIndex],s=this.languages[this.playingLanguageIndex],i=this.playerId===ml.hls?Ct.version:this.nativePlayerVersion,n={ChannelId:this.channelId,MediaId:this.mediaId,PbsId:this.pbsId,VodMediaItemId:this.vodMediaItemId,VodSourceId:this.vodSourceId,VodTitleId:this.vodTitleId,VodSeasonId:this.vodSeasonId,VodEpisodeId:this.vodEpisodeId,IsPrograms:this.isArchive,IsLive:this.isLive,PlayerId:this.playerId,PlayerVersion:i,DvrDelayMs:this.dvrDelayMs,LanguageId:s?.id||"",IsLanguageDefault:s?.default||!1,RenditionId:e?.id||"",IsRenditionDefault:e?.default||!1,BufferingEventsCnt:this.bufferingEventsCnt,ErrorEventsCnt:this.errorEventsCnt,PlayIntervalNum:this.playIntervalNum,EventDuration:this.eventDuration,PlaybackTime:this.playbackTime,RebufferingTimeMs:this.bufferTime,ElapsedTimeMs:this.elapsedTime,PlayingTimeMs:this.playingTime,StartTimeMs:this.startTime,AudioOnlyTimeMs:this.audioOnlyTime,SystemMiniplayerTimeMs:this.systemMiniplayerTimeMs,SecondScreenTimeMs:this.secondScreenTimeMs,QualitySwitchesCnt:this.qualitySwitchesCnt,LowQualityTimeMs:this.lowQualityTime,TopQualityTimeMs:this.topQualityTime,WindowedTimeMs:this.windowedTime,FullScreenTimeMs:this.fullScreenTime,IsPlaybackAborted:this.isPlaybackAborted};return this.playerId!==ml.native&&(this.averageFragsKbps>0&&(n.AverageEstimatedBandwidthKbps=this.averageFragsKbps),this.minimalFragsKbps>0&&(n.MinimumEstimatedBandwidthKbps=this.minimalFragsKbps)),this.connectionType&&(n.ConnectionType=this.connectionType),n}checkData(){return Date.now()-this.initTime<Zf*1e3||this.initTime===0?!1:this.startTime<0?(Ge.warn("unable sendStatistics, incorrect startTime:",this.startTime),!1):this.playingTime<0?(Ge.warn("unable sendStatistics, incorrect playingTime:",this.playingTime),!1):!0}sendStatistics(){if(!this.checkData())return;const e=this.prepareData();try{Ge.info("sendStatistics"),Qy(this.ctx,e,this.externalPlayerPlatform)}catch(s){Ge.error(s)}}}var P_=Object.getOwnPropertyDescriptor,O_=(t,e,s,i)=>{for(var n=i>1?void 0:i?P_(e,s):e,r=t.length-1,o;r>=0;r--)(o=t[r])&&(n=o(n)||n);return n};let yl=class extends rr(Wn){get channels(){return ee.tvChannels.filteredChannelsSelector(this.$store)}get favoriteChannels(){return ee.tvChannels.favoritesSelector(this.$store)}get currentGenre(){return ee.tvChannels.currentGenreSelector(this.$store)}get isCurrentGenreFavorites(){return this.currentGenre===fe.favourite}getLiveProgram(t){return ee.tvEpgV2.onAirLiveProgramSelector(this.$store,t)}getNextProgram(t){return ee.tvEpgV2.onAirNextProgramSelector(this.$store,t)}getChannelById(t){return ee.tvChannels.channelByIdSelector(this.$store,t)}getChannelLogo(t){return wi(t)}getLiveProgramSrc(t){return this.getLiveProgram(t)?.logoUrl||""}getLiveProgramTitle(t){return this.getLiveProgram(t)?.title||""}getLiveProgramStartTimeHM(t){return fa(this.getLiveProgram(t)?.scheduledFor.begin)}getNextProgramTitle(t){return this.getNextProgram(t)?.title||""}getNextProgramStartTimeHM(t){return fa(this.getNextProgram(t)?.scheduledFor.begin)}getNextProgramStartsIn(t){return this.getNextProgram(t)?.startsIn}};yl=O_([Zt],yl);const M_=window.self!==window.top,N_=H("marketing-external-code"),gO=async t=>{const s=new URLSearchParams(document.location.search).get("utm_source"),i=Ce.get(Lt.lfstrmPartner),n=Ce.get(Lt.lfstrmPartnerTs),r=i&&n,o=s||i||"";if(!o)return;const a=await gy(o);if(!a)return;const l=Date.now(),c=Ee(t),u=(Number(n)||l)+a.ttlDay*864e5;if(c?s&&!i||!s&&i&&l<u||o===s:l<=u){try{D_(a.code)}catch(f){N_.error(f)}
35c&&(!i||r)&&s&&!M_&&document.addEventListener("click",()=>{Ce.set(Lt.lfstrmPartner,s),Ce.set(Lt.lfstrmPartnerTs,l)},{once:!0})}i&&l>u&&(Ce.remove(Lt.lfstrmPartner),Ce.remove(Lt.lfstrmPartnerTs))};class F_{timestamp;constructor(){this.timestamp=Date.now()}getMS(){return Date.now()-this.timestamp}start(){this.timestamp=Date.now()}}class U_{testName;resource;constructor(e,s){this.testName=e.toLowerCase(),this.resource=s}checkAverageMs(e,s){const i=ps(ni(s))||0,n=i<=e.threshold;return this.prepareResult(e,n,i,"diagnostics_check_average_ms")}checkMaxMs(e,s){const i=ms(ni(s))||0,n=i<=e.threshold;return this.prepareResult(e,n,i,"diagnostics_check_max_ms")}checkMinMs(e,s){const i=pt(ni(s))||0,n=i<=e.threshold;return this.prepareResult(e,n,i,"diagnostics_check_min_ms")}checkSuccessfulAttempts(e,s){const i=s>=e.threshold;return this.prepareResult(e,i,s,"diagnostics_check_successful_attempts")}checkFailedAttempts(e,s){const i=s<=e.threshold;return this.prepareResult(e,i,s,"diagnostics_check_failed_attempts")}checkMinChunkDownloadSpeed(e,s){const i=pt(s)||0,n=i>=e.threshold;return this.prepareResult(e,n,i,"diagnostics_check_min_chunk_download_speed",!0)}checkAvgChunkDownloadSpeed(e,s){const i=ps(s)||0,n=i>=e.threshold;return this.prepareResult(e,n,i,"diagnostics_check_avg_chunk_download_speed",!0)}checkMinFileDownloadSpeed(e,s){const i=pt(s)||0,n=i>=e.threshold;return this.prepareResult(e,n,i,"diagnostics_check_min_file_download_speed",!0)}checkAvgFileDownloadSpeed(e,s){const i=pt(s)||0,n=i>=e.threshold;return this.prepareResult(e,n,i,"diagnostics_check_avg_file_download_speed",!0)}prepareResult(e,s,i,n,r=!1){if(s)return null;let o="",a="";return e.threshold&&(r?(o=ya(ma(e.threshold)),a=ya(ma(i))):(o=Math.round(e.threshold).toString(),a=Math.round(i).toString())),{...e,code:e.title,thresholdFormatted:o,result:i,resultFormatted:a,translationKey:n}}}class pO{requestStopWatch;payload;requestTime;successfulAttempts;failedAttempts;isChunksTest;constructor(e){this.requestStopWatch=new F_,this.payload=e,this.requestTime=[],this.successfulAttempts=0,this.failedAttempts=0,this.isChunksTest=!!e.chunkSizeBytes&&!!e.numChunks}run(){const{attempts:e}=this.payload;return qI(e).reduce((s,i,n)=>s.then(()=>this.sendRequest(n+1)).then(()=>{this.successfulAttempts+=1}).catch(()=>{this.failedAttempts+=1}),Promise.resolve()).then(()=>({...this.payload,stat:this.getStat(),failedChecks:this.doChecks()}))}doChecks(){const{title:e,humanReadableResource:s,checkList:i}=this.payload,n=new U_(e,s),r={};return i.forEach(o=>{let a=null;switch(o.type){case"avg-ms":a=n.checkAverageMs(o,this.requestTime);break;case"max-ms":a=n.checkMaxMs(o,this.requestTime);break;case"min-ms":a=n.checkMinMs(o,this.requestTime);break;case"successful-attempts":a=n.checkSuccessfulAttempts(o,this.successfulAttempts);break;case"failed-attempts":a=n.checkFailedAttempts(o,this.failedAttempts);break;case"min-chunk-download-speed":a=n.checkMinChunkDownloadSpeed(o,this.getChunkDownloadSpeed());break;case"avg-chunk-download-speed":a=n.checkAvgChunkDownloadSpeed(o,this.getChunkDownloadSpeed());break;case"min-file-download-speed":a=n.checkMinFileDownloadSpeed(o,this.getFileDownloadSpeed());break;case"avg-file-download-speed":a=n.checkAvgFileDownloadSpeed(o,this.getFileDownloadSpeed());break}a&&(r[a.type]=a)}),Object.values(r)}sendRequest(e){return this.isChunksTest||this.recordRequestStartTime(),this.doSendRequest(e).finally(()=>{this.isChunksTest||this.recordRequestEndTime(e)})}doSendRequest(e){const{timeLimitMs:s,chunkSizeBytes:i,numChunks:n}=this.payload;return new Promise((r,o)=>{const a=new XMLHttpRequest;if(a.timeout=s,a.onerror=()=>o(new Error("Network error")),a.ontimeout=()=>o(new Error("Target host is not responding")),a.onload=()=>r(),a.open("GET",this.getUrl()),i&&n){this.recordRequestStartTime(),a.setRequestHeader("Range",`bytes=0-${i*n}`);let l=1,c=!0;a.onprogress=d=>{c&&d.loaded>=d.total?this.recordRequestEndTime(e):d.loaded>l*i&&(this.recordRequestEndTime(e),c=!1,d.loaded<d.total&&(c=!0,this.recordRequestStartTime(),l++))}}a.send()})}getUrl(){return`${this.payload.resource}?_=${new Date().getTime()}`}getChunkDownloadSpeed(){const e=this.payload.chunkSizeBytes||0,s=ga(e),i=[];return this.requestTime.forEach(n=>
35{n.forEach(r=>{const o=pa(r);i.push(this.calcSpeed(s,o))})}),i}getFileDownloadSpeed(){const e=this.payload.chunkSizeBytes||0,s=ga(e),i=this.payload.numChunks||0,n=s*i;return this.requestTime.map(r=>{const o=WI(r)||0,a=pa(o);return this.calcSpeed(n,a)})}getStat(){let e=[];this.requestTime.forEach(i=>{e=e.concat(i)});const s={resource:this.payload.resource,attempts:this.payload.attempts,successfulAttempts:this.successfulAttempts,failedAttempts:this.failedAttempts,requestTime:{max:ms(e)||0,min:pt(e)||0,avg:Math.round(ps(e)||0)}};return this.payload.type==="xhr-speed"?{...s,chunkDownloadSpeed:{max:ms(this.getChunkDownloadSpeed())||0,min:pt(this.getChunkDownloadSpeed())||0,avg:Math.round(ps(this.getChunkDownloadSpeed())||0)},fileDownloadSpeed:{max:ms(this.getFileDownloadSpeed())||0,min:pt(this.getFileDownloadSpeed())||0,avg:Math.round(ps(this.getFileDownloadSpeed())||0)}}:s}recordRequestStartTime(){this.requestStopWatch.start()}recordRequestEndTime(e){const s=e-1;this.requestTime[s]=this.requestTime[s]||[],this.requestTime[s].push(this.requestStopWatch.getMS())}calcSpeed(e,s){return s>0?Math.max(e/s,0):0}}const mO=async t=>v0.post(x.oldSmotreshkaPremiumPage,t);export{jf as $,l0 as A,NT as B,FT as C,Rl as D,Cl as E,Iv as F,yt as G,Ow as H,Dt as I,lw as J,HI as K,CD as L,SP as M,DD as N,o0 as O,gs as P,yD as Q,aw as R,UP as S,dw as T,sP as U,Xf as V,tP as W,Ck as X,iP as Y,Zk as Z,Qo as _,ee as a,kD as a$,Bs as a0,ge as a1,_l as a2,Ak as a3,z_ as a4,sw as a5,Xy as a6,rt as a7,Aw as a8,Xk as a9,qy as aA,VP as aB,Ce as aC,Lt as aD,Hk as aE,mD as aF,Be as aG,GP as aH,HP as aI,Ek as aJ,Tk as aK,nk as aL,vk as aM,zo as aN,Og as aO,le as aP,si as aQ,Lv as aR,Bk as aS,pk as aT,mk as aU,Fk as aV,Ef as aW,$w as aX,dk as aY,a0 as aZ,Bw as a_,xP as aa,wl as ab,Eo as ac,Vk as ad,Gk as ae,Kk as af,Wk as ag,Fv as ah,W_ as ai,jk as aj,Yk as ak,me as al,Te as am,ft as an,Mw as ao,$P as ap,Iw as aq,Cw as ar,Lw as as,zA as at,Hy as au,Gy as av,_e as aw,Wy as ax,Ky as ay,Yy as az,Je as b,Uk as b$,Gw as b0,Vw as b1,Uw as b2,_D as b3,wD as b4,gw as b5,yP as b6,pP as b7,mP as b8,Wn as b9,hb as bA,yg as bB,yw as bC,ik as bD,or as bE,On as bF,tg as bG,fD as bH,jt as bI,zk as bJ,zD as bK,hr as bL,Jw as bM,li as bN,WI as bO,Ea as bP,Hn as bQ,Tw as bR,nP as bS,cp as bT,Df as bU,Ct as bV,bP as bW,oe as bX,lr as bY,oD as bZ,rw as b_,Rf as ba,Wo as bb,El as bc,ds as bd,H_ as be,Nw as bf,dc as bg,wi as bh,SD as bi,JD as bj,KP as bk,ek as bl,RP as bm,j_ as bn,jD as bo,Fw as bp,qP as bq,YP as br,WP as b
35s,XP as bt,zP as bu,QP as bv,JP as bw,_i as bx,vw as by,Ci as bz,ci as c,wI as c$,ID as c0,LD as c1,Vr as c2,Ai as c3,oi as c4,Nl as c5,Qf as c6,Zw as c7,eD as c8,sD as c9,qD as cA,sy as cB,ND as cC,bg as cD,vP as cE,RD as cF,uP as cG,rP as cH,hP as cI,oP as cJ,dP as cK,cP as cL,lP as cM,aP as cN,ED as cO,bD as cP,xD as cQ,og as cR,hf as cS,qe as cT,Hw as cU,vs as cV,rO as cW,oO as cX,ok as cY,ak as cZ,rk as c_,tD as ca,ow as cb,Ok as cc,Nk as cd,Pl as ce,fw as cf,di as cg,Pw as ch,Ib as ci,iw as cj,ap as ck,gt as cl,JI as cm,Q_ as cn,Mk as co,BP as cp,gb as cq,qk as cr,bs as cs,Or as ct,nw as cu,FD as cv,_w as cw,kI as cx,pD as cy,CP as cz,KD as d,Ni as d$,DI as d0,OP as d1,_P as d2,PP as d3,kP as d4,BD as d5,lc as d6,Kn as d7,fe as d8,$s as d9,Z_ as dA,np as dB,IP as dC,hO as dD,fO as dE,zw as dF,qw as dG,jw as dH,Ww as dI,Yw as dJ,Kw as dK,eP as dL,_k as dM,ae as dN,Td as dO,yu as dP,cD as dQ,TP as dR,Qu as dS,Sw as dT,VD as dU,$D as dV,qT as dW,Xw as dX,Qw as dY,yl as dZ,Tr as d_,WD as da,mw as db,oo as dc,zb as dd,NP as de,cw as df,kt as dg,Qk as dh,hw as di,kn as dj,Dk as dk,wk as dl,Xu as dm,ZP as dn,ZD as dp,rD as dq,tw as dr,qo as ds,X_ as dt,uO as du,ze as dv,EP as dw,LP as dx,ww as dy,J_ as dz,FP as e,bk as e$,fp as e0,oS as e1,Tv as e2,K_ as e3,wS as e4,DP as e5,Jk as e6,pw as e7,rg as e8,wP as e9,_f as eA,Y_ as eB,ew as eC,ck as eD,rs as eE,Ze as eF,yk as eG,Rw as eH,fP as eI,gP as eJ,AP as eK,aA as eL,go as eM,aD as eN,sg as eO,Sk as eP,Pu as eQ,fo as eR,uk as eS,fk as eT,kw as eU,hk as eV,Dw as eW,vD as eX,AD as eY,Pi as eZ,bE as e_,HD as ea,tO as eb,eO as ec,iO as ed,nO as ee,sO as ef,lO as eg,sk as eh,MP as ei,ai as ej,tc as ek,gD as el,gg as em,jo as en,Ew as eo,bw as ep,xw as eq,QD as er,uD as es,TD as et,hD as eu,q_ as ev,gO as ew,aO as ex,lD as ey,OD as ez,fa as f,xk as f0,Ty as f1,Hd as f2,$k as f3,iD as f4,nD as f5,x as f6,lk as f7,tk as f8,pO as f9,MD as fa,ma as fb,ya as fc,mO as fd,Ox as fe,Ik as ff,gk as fg,dD as fh,Eg as fi,Zg as fj,ss as g,GD as h,ks as i,Rk as j,Lk as k,H as l,up as m,bI as n,XD as o,vI as p,GI as q,vt as r,PD as s,YD as t,kk as u,Pk as v,uw as w,UD as x,pc as y,DT as z};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.